summaryrefslogtreecommitdiff
path: root/chimere/templates
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/templates')
-rw-r--r--chimere/templates/chimere/edit.html143
-rw-r--r--chimere/templates/tinymce/tinymce_init.js17
2 files changed, 62 insertions, 98 deletions
diff --git a/chimere/templates/chimere/edit.html b/chimere/templates/chimere/edit.html
index d31cb79..b6e0963 100644
--- a/chimere/templates/chimere/edit.html
+++ b/chimere/templates/chimere/edit.html
@@ -3,7 +3,7 @@
{% if error_message %}<div class='edit errorlist'>
<legend>{% trans "Error" %}</legend>
<p>{{ error_message }}</p>
-{% endif %}</div>
+</div>{% endif %}
{% if is_modification and is_superuser %}<div class='warning'><p>{% trans "You are logged as an administrator. Your modifications will be taking into account immediately." %}</p></div>{% endif %}
<div class='edit'>
{% block editactions %}
@@ -20,6 +20,11 @@
<form enctype="multipart/form-data" method='post'
action='{% block edit_url %}{% url "editmarker" %}{% endblock %}{% if item_id %}{{item_id}}/{% endif %}'
id='proposition_form'>
+ {% if form.errors %}
+ <div class="alert alert-danger">
+ Il y a des erreurs sur le formulaire, veuillez les corriger.
+ </div>
+ {% endif %}
{% csrf_token %}
<p>* {% trans "indicates a mandatory field" %}</p>
@@ -90,33 +95,6 @@
{% inline_formset "Multimedia files" formset_multi %}
{% inline_formset "Picture files" formset_picture %}
-
- {% if filtered_properties %}
- <script type='text/javascript'>
- var cat_filters = new Array();
- var cat_to_hide = new Array();
- {% for property in filtered_properties %}
- cat_to_hide.push('#id_{{property.getNamedId}}');
- {% for subcat in property.subcategories.all %}
- if(!cat_filters['{{subcat.id}}']) cat_filters['{{subcat.id}}'] = new Array();
- cat_filters['{{subcat.id}}'].push('#id_{{property.getNamedId}}');
- {% endfor %}
- {% endfor %}
- $('.bsmSelect').change(function(){
- for (idx in cat_to_hide){
- $(cat_to_hide[idx]).parent().hide();
- }
- var vals = $('#id_categories').val();
- for (val_id in vals){
- var val = vals[val_id];
- for (ids in cat_filters[val]){
- $(cat_filters[val][ids]).parent().show();
- }
- }
- });
- $('.bsmSelect').change();
- </script>
- {% endif %}
</div>
<div class='personalform'>
<h5>{% trans "Personal information"%}</h5>
@@ -147,77 +125,52 @@
</div>
{% bootstrap_modal "upload_in_progress" %}
<script text='text/javascript'>
- var upload = '<p>{% trans "Upload in progress. Please wait..." %}</p>\n';
- upload += "<p><img alt='Ajax loader' src='{{STATIC_URL}}chimere/img/ajax-loader.gif'/></p>";
-
- function displayProgress(){
- $('#upload_in_progress .modal-body').html(upload);
- $('#upload_in_progress').modal("show");
- }
- $(function(){
- register_subactions();
- {% comment %}
- {% if route %}
- var edition_type = 'route';
- {% if itinerary_form %}
- $("#chimere_itinerary_form").appendTo($("#itinerary_field"));
- $('#main_map').chimere('updateRoutingInput');{% endif%}
- {% else %}
- var edition_type = 'marker';
- $('#main_map').chimere('updateMarkerInput');
+ filter_categories = function() {
+ {% if filtered_properties %}
+ var cat_filters = new Array();
+ var cat_to_hide = new Array();
+ {% for property in filtered_properties %}
+ cat_to_hide.push('#id_{{property.getNamedId}}');
+ {% for subcat in property.subcategories.all %}
+ if(!cat_filters['{{subcat.id}}']) cat_filters['{{subcat.id}}'] = new Array();
+ cat_filters['{{subcat.id}}'].push('#id_{{property.getNamedId}}');
+ {% endfor %}
+ {% endfor %}
+ $('.bsmSelect').change(function(){
+ for (idx in cat_to_hide){
+ $(cat_to_hide[idx]).parent().hide();
+ }
+ var vals = $('#id_categories').val();
+ for (val_id in vals){
+ var val = vals[val_id];
+ for (ids in cat_filters[val]){
+ $(cat_filters[val][ids]).parent().show();
+ }
+ }
+ });
+ $('.bsmSelect').change();
{% endif %}
- {% endcomment %}
+ };
- $('#modal-edit button.btn-primary').unbind("click");
- $('#modal-edit button.btn-primary').click(function(){
- // JS tests because if a file is submited there is no way
- // to refill the form with (browser security issue)
- if (typeof tinyMCE !== 'undefined') tinyMCE.triggerSave();
- validation = [
- '{% if geom_name == 'marker' %}point{% else %}{{geom_name}}{% endif %}',
- 'categories',{% if event %}
- 'start_date',{% endif %}
- ];
+ {% if route %}
+ edition_type = 'route';
+ {% else %}
+ edition_type = 'marker';
+ {% endif %}
+ edition_event = {% if event %} true {% else %} false {% endif %};
+ edition_error = "{% trans 'There are missing/erroneous fields.' %}";
- $("input[required]").each(function(){
- validation.push($(this).attr('name'));
- });
+ {% comment %}
+ {% if itinerary_form %}
+ $("#chimere_itinerary_form").appendTo($("#itinerary_field"));
+ $('#main_map').chimere('updateRoutingInput');{% endif%}
+ {% endcomment %}
- var validated = true;
- for (var idx=0; idx<validation.length ;idx++){
- var input_id = validation[idx];
- var selec = '[name=' + input_id + ']';
- var val = jQuery(selec).val();
- if (!val || val == '0' || val == '' || val == 'None' ||
- (input_id == 'id_submiter_email' &&
- !isValidEmailAddress(val))){
- jQuery(selec).parent().addClass('warning');
- jQuery(selec).parent().addClass('error');
- validated = false;
- } else {
- jQuery(selec).parent().removeClass('warning');
- jQuery(selec).parent().removeClass('error');
- }
- }
- if (!validated){
- alert("{%trans "There are missing/erroneous fields."%}");
- $('#modal-edit').animate(
- { scrollTop: 0 }, 'fast');
- return false;
- }
- $("#proposition_form").ajaxForm();
- $('#modal-edit').animate({ scrollTop: 0 });
- displayProgress();
- $("#proposition_form").ajaxSubmit({
- success:function(msg){
- $('#upload_in_progress').modal("hide");
- $("#modal-edit").modal("hide");
- $("#modal-default-message .modal-body").html(msg);
- $('#modal-default-message').modal("show");
- }
- });
- return false;
- });
+ var upload = '<p>{% trans "Upload in progress. Please wait..." %}</p>\n';
+ upload += "<p><img alt='Ajax loader' src='{{STATIC_URL}}chimere/img/ajax-loader.gif'/></p>";
+
+ $(function(){
+ init_modal_window();
});
</script>
</form>
diff --git a/chimere/templates/tinymce/tinymce_init.js b/chimere/templates/tinymce/tinymce_init.js
index 8ebceb3..23bf340 100644
--- a/chimere/templates/tinymce/tinymce_init.js
+++ b/chimere/templates/tinymce/tinymce_init.js
@@ -1,4 +1,6 @@
(function($) {
+
+ if (typeof(textara_list) === 'undefined') textara_list = [];
{% if is_admin_inline %}
$(function() {
{% endif %}
@@ -17,9 +19,18 @@
if (typeof selector != 'undefined') {
tinymce4_config['selector'] = selector;
}
- // only the next line is added in chimere to force reinit
- tinymce.remove(tinymce4_config['selector']);
- tinymce.init(tinymce4_config);
+
+ textara_list.push(
+ function(){
+ // next line is added in chimere to force reinit
+ tinymce.remove(tinymce4_config['selector']);
+
+ setTimeout(function(){
+ tinymce.init(tinymce4_config);
+ }, 300);
+ }
+ )
+ textara_list[textara_list.length - 1]();
} // End tinymce4_init
{% if not is_admin_inline %}
tinymce4_init();