/* * 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 function hideAllMessages() { var messagesHeights = new Array(); // this array will store height for each for (i=0; i

'+ response.message+'

'); link.hide(); } }, dataType: "json" }); $('form[name="search"]').attr('action', old_form_action); // $.getJSON(url, function(response) { // if (response.status == 'mustbeconnected') // { // $(location).attr('href', url_index); // } // // if (response.count) // { // $('ul.elements').append(response.html); // $('img.elements_more_loader').hide(); // recolorize_element_list(); // } // // if (response.end || response.count < 1) // { // $('img.elements_more_loader').hide(); // $('ul.elements').after('

'+ // response.message+'

'); // link.hide(); // } // }); 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) { if (response.status == 'mustbeconnected') { $(location).attr('href', url_index); } $('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){ if (response.status == 'mustbeconnected') { $(location).attr('href', url_index); } 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(); } }); 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'); // 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) { if (response.status == 'mustbeconnected') { $(location).attr('href', url_index); } // 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){ if (response.status == 'mustbeconnected') { $(location).attr('href', url_index); } var li = $('li#'+response.dom_id); if (response.status == 'success') { li.html(response.html); 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 = $('