$(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($('