From 526f87f2d4fbb7c2f7c65faaef6e3c8a518e29be Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 16 Jun 2013 20:59:39 +0200 Subject: [PATCH] Showing loading overlay if requests takes longer than 250ms --- wcfsetup/install/files/js/WCF.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index db67d0310b..fb791b3799 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1648,6 +1648,12 @@ WCF.LoadingOverlayHandler = { */ _loadingOverlay: null, + /** + * WCF.PeriodicalExecuter instance + * @var WCF.PeriodicalExecuter + */ + _pending: null, + /** * Adds one loading-request and shows the loading overlay if nessercery */ @@ -1658,7 +1664,18 @@ WCF.LoadingOverlayHandler = { this._activeRequests++; if (this._activeRequests == 1) { - this._loadingOverlay.stop(true, true).fadeIn(100); + if (this._pending === null) { + var self = this; + this._pending = new WCF.PeriodicalExecuter(function(pe) { + if (self._activeRequests) { + self._loadingOverlay.stop(true, true).fadeIn(100); + } + + pe.stop(); + self._pending = null; + }, 250); + } + } }, @@ -1668,6 +1685,11 @@ WCF.LoadingOverlayHandler = { hide: function() { this._activeRequests--; if (this._activeRequests == 0) { + if (this._pending !== null) { + this._pending.stop(); + this._pending = null; + } + this._loadingOverlay.stop(true, true).fadeOut(100); } }, -- 2.20.1