1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-08 08:35:31 +02:00

[ticket/10805] Clear loading alert timeout after ajax request finished

The timeout for the "request timed out" popup should be cleared if it
finished. Since it is currently not cleared, the timeout alert appears as
an extra overlay if another ajaxified function is ran within 5 seconds of
the initial function call. This patch will take care of clearing the
timeout if either the success (function return_handler()) or error
(function error_handler()) functions are called.

PHPBB3-10805
This commit is contained in:
Marc Alexander 2012-12-19 16:41:25 +01:00
parent e444f5bf2a
commit 5d07ddffaf

View File

@ -13,6 +13,7 @@ var keymap = {
var dark = $('#darkenwrapper');
var loading_alert = $('#loadingalert');
var phpbbAlertTimer = 0;
/**
@ -30,7 +31,7 @@ phpbb.loading_alert = function() {
loading_alert.show();
dark.fadeIn(phpbb.alert_time, function() {
// Wait five seconds and display an error if nothing has been returned by then.
setTimeout(function() {
phpbbAlertTimer = setTimeout(function() {
if (loading_alert.is(':visible'))
{
phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req'));
@ -42,6 +43,16 @@ phpbb.loading_alert = function() {
return loading_alert;
}
/**
* Clear loading alert timeout
*/
phpbb.clearLoadingTimeout = function() {
if (phpbbAlertTimer != 0) {
clearTimeout(phpbbAlertTimer);
phpbbAlertTimer = 0;
}
}
/**
* Display a simple alert similar to JSs native alert().
*
@ -271,6 +282,8 @@ phpbb.ajaxify = function(options) {
{
var alert;
phpbb.clearLoadingTimeout();
// Is a confirmation required?
if (typeof res.S_CONFIRM_ACTION === 'undefined')
{
@ -341,6 +354,7 @@ phpbb.ajaxify = function(options) {
{
var alert;
phpbb.clearLoadingTimeout();
alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text'));
}