// add loading when page is loading $('body').addClass('loading'); $(window).on('load', function() { // remove loading when page is loaded $('body').removeClass('loading'); // alert using modal when loading is removed $('.modal.auto-show').each(function() { if (!$('body').hasClass('modal-open')) { $(this).modal('show').addClass('shown'); } // trigger next modal $(this).on('hidden.bs.modal', function(e) { $('.modal.auto-show:not(.shown)').first().modal('show').addClass('shown'); }); }); }); // add loading when form submit $('form').submit(function() { if (!$('body').hasClass('live')) $('body').addClass('loading'); }); // add loading when ajax $(document).on({ ajaxStart: function() { if (!$('body').hasClass('live')) $('body').addClass('loading'); }, ajaxStop: function() { $('body').removeClass('loading'); } }); // notification using bootstrap toast //$('.toast').toast('show'); // initiate and show alert modal function modalAlert(title=gettext('Error'), body=gettext('Error'), btnDismissText=gettext('Close')) { var modal = ''; $('.wrapper').append(modal); $('.modal:last').modal('show').addClass('shown'); }