summaryrefslogtreecommitdiff
path: root/chimere/static/saclay/js/interface.js
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/static/saclay/js/interface.js')
-rw-r--r--chimere/static/saclay/js/interface.js105
1 files changed, 105 insertions, 0 deletions
diff --git a/chimere/static/saclay/js/interface.js b/chimere/static/saclay/js/interface.js
index cd30561..e593588 100644
--- a/chimere/static/saclay/js/interface.js
+++ b/chimere/static/saclay/js/interface.js
@@ -407,3 +407,108 @@ function toggleDrawOff() {
).addClass('toggle-button-active');
$("#main-map").chimere("deactivateCurrentControl");
}
+
+var edition_type = 'marker';
+var edition_event = false;
+var edition_error = "There are missing/erroneous fields.";
+var filter_categories = function() {};
+var displayProgress = function() {
+ $('#upload_in_progress .modal-body').html(upload);
+ $('#upload_in_progress').modal("show");
+};
+var init_widget_list = [];
+
+var init_modal_window = function(){
+ filter_categories();
+ register_subactions();
+
+ /*
+ {% 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');
+ {% endif %}
+ */
+
+ $('#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();
+
+ var geom_name = edition_type;
+ if (geom_name == 'marker'){
+ geom_name = 'point';
+ }
+
+ validation = [
+ geom_name,
+ 'categories'
+ ];
+ if (edition_event) validation.push('start_date');
+
+ $("input[required]").each(function(){
+ validation.push($(this).attr('name'));
+ });
+
+ 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');
+ }
+ }
+ $('#modal-edit').animate({ scrollTop: 0 }, 'fast');
+ if (!validated){
+ alert(edition_error);
+ return false;
+ }
+ $("#proposition_form").ajaxForm();
+ displayProgress();
+ $("#proposition_form").ajaxSubmit({
+ success:function(msg){
+ $('#upload_in_progress').modal("hide");
+
+ var html = $.parseHTML(msg);
+ if (msg.indexOf("class='edit'") !== -1){
+ $("#modal-edit .modal-body").html(html);
+ setTimeout(function(){
+ init_modal_window();
+ init_map_edit();
+ for (idx in init_widget_list){
+ init_widget_list[idx]();
+ }
+ if (typeof(textara_list) !== 'undefined'){
+ for (idx in textara_list){
+ textara_list[idx]();
+ }
+ }
+ if (typeof(datepicker_list) !== 'undefined'){
+ for (idx in datepicker_list) datepicker_list[idx]();
+ }
+ }, 300);
+ } else {
+ $("#modal-edit").modal("hide");
+ $("#modal-default-message .modal-body").html(
+ html);
+ $('#modal-default-message').modal("show");
+ }
+ }
+ });
+ return false;
+ });
+};
+