From da4e0c4219e5132ffddd67fc4621840c557c132a Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 15 Oct 2013 21:37:53 -0700 Subject: [ticket/11928] Replace AJAX loading popup with animation. PHPBB3-11928 --- phpBB/assets/javascript/core.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'phpBB/assets/javascript') diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index efb945a117..dfbbd12929 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -12,7 +12,7 @@ var keymap = { }; var dark = $('#darkenwrapper'); -var loadingAlert = $('#loadingalert'); +var loadingAlert = $('#loading_indicator'); var phpbbAlertTimer = null; @@ -22,18 +22,14 @@ var phpbbAlertTimer = null; * @returns object Returns loadingAlert. */ phpbb.loadingAlert = function() { - if (dark.is(':visible')) { + if (!loadingAlert.is(':visible')) { loadingAlert.fadeIn(phpbb.alertTime); - } else { - loadingAlert.show(); - dark.fadeIn(phpbb.alertTime, function() { - // Wait fifteen seconds and display an error if nothing has been returned by then. - phpbbAlertTimer = setTimeout(function() { - if (loadingAlert.is(':visible')) { - phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req')); - } - }, 15000); - }); + // Wait fifteen seconds and display an error if nothing has been returned by then. + phpbbAlertTimer = setTimeout(function() { + if (loadingAlert.is(':visible')) { + phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req')); + } + }, 15000); } return loadingAlert; @@ -66,6 +62,10 @@ phpbb.alert = function(title, msg, fadedark) { div.find('.alert_title').html(title); div.find('.alert_text').html(msg); + if (!dark.is(':visible')) { + dark.fadeIn(phpbb.alertTime); + } + div.bind('click', function(e) { e.stopPropagation(); }); @@ -131,6 +131,10 @@ phpbb.confirm = function(msg, callback, fadedark) { var div = $('#phpbb_confirm'); div.find('.alert_text').html(msg); + if (!dark.is(':visible')) { + dark.fadeIn(phpbb.alertTime); + } + div.bind('click', function(e) { e.stopPropagation(); }); @@ -372,13 +376,16 @@ phpbb.ajaxify = function(options) { phpbb.loadingAlert(); } - $.ajax({ + var request = $.ajax({ url: action, type: method, data: data, success: returnHandler, error: errorHandler }); + request.always(function() { + loadingAlert.fadeOut(phpbb.alertTime); + }); event.preventDefault(); }); -- cgit v1.2.1