$(window).on('start_loading', function() { $('.loading').show(); }); $(window).on('end_loading', function() { $('.loading').hide(); }); $(document).ready(function() { $('*[data-toggle="tooltip"]').tooltip(); $('*[data-toggle="popover"]').popover(); $('*[required=required]').removeAttr('required'); $('input[type=checkbox]').each(function() { if ($(this)[0]) { var name = $(this).attr('name') ? $(this).attr('name') : ''; if (name.indexOf('delete_') !== -1 && !$(this).hasClass('delete_checkbox')) { $(this).parent().remove(); } } }); if ($('.message').html()) { $('.message').animate({ opacity: 1 }, 500); $('.message').delay(3000).animate({ opacity: 0 }); } }); $('.message').live( 'click', function(event) { console.log("toto"); $(event.target).hide(); } ); var redirect = function(url) { document.location.href = url; } $('.node_form form').live( 'submit', function(event) { event.preventDefault(); $('.modal-footer input[type=submit]').button('toggle') var $form = $(this); var $message = $form.find('.message').html('').fadeIn(); var nodeId = $(this).data('node'); $(window).trigger('start_loading'); $.post($form.attr('action'), $form.serialize()) .success(function(data) { $('.node_form').html(data); $('.node_form').find('.message').fadeIn().delay(3000).fadeOut(); $('#' + nodeId).slideUp().load(document.location.href + ' #' + nodeId + ' > div:first-child', function(data) { $('#' + nodeId).slideDown() }); }) .error(function() { $(window).trigger('end_loading'); $message.append($('
').addClass('alert alert-error').html(trans('cms.js.request.error'))).fadeIn().delay(3000).fadeOut(); }) .complete(function() { $('.modal-footer input[type=submit]').button('reset') }); } ); $('.accordion-toggle').live( 'click', function() { $('.accordion-toggle').parent().removeClass('opened'); $(this).parent().addClass('opened'); $input = $(this).find('input[type=radio]').attr('checked', 'checked'); if ($input.val() == 'url') { $('.nodeUrl').hide(); } else { $('.nodeUrl').show(); } } ); $('.accordion-toggle input[type=radio]').live( 'click', function() { $(this).attr('checked', 'checked'); } ); $('.batch_th input').live( 'click', function() { $('.batch_td input').each(function() { if ($(this).attr('checked')) { $(this).removeAttr('checked'); } else { $(this).attr('checked', 'checked'); } }); } ); var modale_it = function(data, title, locked) { var preview = $('