/* * Scripts de Muzi.ch * Rédigé et propriété de Sevajol Bastien (http://www.bux.fr) sauf si mention * contraire sur la fonction. * */ // Messages flashs var myMessages = ['info','warning','error','success']; // define the messages types var window_login_or_subscription_opened = false; var popin_opened = false; function hideAllMessages() { var messagesHeights = new Array(); // this array will store height for each for (i=0; i

'+ response.message+'

'); link.hide(); } }, dataType: "json" }); if (!$(this).hasClass('event_view')) { $('form[name="search"]').attr('action', old_form_action); } return false; }); tag_box_input_value = $('ul.tagbox input[type="text"]').val(); // Filtre et affichage éléments ajax $('form[name="search"] input[type="submit"]').click(function(){ $('ul.elements').html(''); $('div.no_elements').hide(); $('img.elements_more_loader').show(); }); $('form[name="search"]').ajaxForm(function(response) { window.ResponseController.execute( response, function(){}, function(){} ); $('ul.elements').html(response.html); if (response.count) { $('img.elements_more_loader').hide(); $('span.elements_more').show(); $('a.elements_more').show(); } if (response.count < 1) { $('img.elements_more_loader').hide(); $('ul.elements').after('

'+ response.message+'

'); $('a.elements_more').hide() ; } $('ul.tagbox input[type="text"]').val($('ul.tagbox input[type="text"]').val()); }); // Suppression d'un element $('a.element_remove_link').jConfirmAction({ question : string_element_delete_confirm_sentence, yesAnswer : string_element_delete_confirm_yes, cancelAnswer : string_element_delete_confirm_no, onYes: function(link){ var li = link.parents('li.element'); li.find('img.element_loader').show(); $.getJSON(link.attr('href'), function(response){ window.ResponseController.execute( response, function(){}, function(){} ); if (response.status == 'success') { li.remove(); } else { li.find('img.element_loader').hide(); } }); return false; }, onOpen: function(link){ var li = link.parents('li.element'); li.find('a.element_edit_link').addClass('mustBeDisplayed'); li.find('a.element_remove_link').addClass('mustBeDisplayed'); }, onClose: function(link){ var li = link.parents('li.element'); li.find('a.element_edit_link').removeClass('mustBeDisplayed'); li.find('a.element_remove_link').removeClass('mustBeDisplayed'); li.find('a.element_edit_link').hide(); li.find('a.element_remove_link').hide(); } }); // Retrait d'un element d'un groupe $('a.element_remove_from_group_link').jConfirmAction({ question : string_removefromgroup_sentence, yesAnswer : string_removefromgroup_confirm_yes, cancelAnswer : string_removefromgroup_confirm_no, onYes: function(link){ var li = link.parents('li.element'); li.find('img.element_loader').show(); $.getJSON(link.attr('href'), function(response){ window.ResponseController.execute( response, function(){}, function(){} ); if (response.status == 'success') { li.remove(); } else { li.find('img.element_loader').hide(); } }); return false; } }); var elements_edited = new Array(); // Ouverture du formulaire de modification $('a.element_edit_link').live('click', function(){ var link = $(this); var li = link.parents('li.element'); li.addClass('selected'); // On garde en mémoire l'élément édité en cas d'annulation elements_edited[li.attr('id')] = li.html(); var div_loader = li.find('div.loader'); li.html(div_loader); li.find('img.element_loader').show(); $.getJSON($(this).attr('href'), function(response) { window.ResponseController.execute( response, function(){}, function(){} ); // On prépare le tagBox li.html(response.html); // Pour le click sur l'input de saisie de tag //li.find('ul.tagbox li.input input[type="text"]').formDefaults(); var options = new Array(); options.form_name = response.form_name; options.tag_init = response.tags; ajax_query_timestamp = null; //$("#tags_prompt_list_"+response.form_name).tagBox(options); // On rend ce formulaire ajaxFormable $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){ var li = $(this).parents('li.element'); li.prepend(div_loader); li.find('img.element_loader').show(); }); $('form[name="'+response.form_name+'"]').ajaxForm(function(response){ window.ResponseController.execute( response, function(){}, function(){} ); var li = $('li#'+response.dom_id); if (response.status == 'success') { li.html(response.html); li.removeClass('selected'); delete(elements_edited[li.attr('id')]); } else if (response.status == 'error') { li.find('img.element_loader').hide(); li.find('ul.error_list').remove(); var ul_errors = $('