From: Magnus Kühn Date: Tue, 12 Feb 2013 14:38:53 +0000 (+0100) Subject: Adding WCF.LoadingOverlayHandler.updateIcon() X-Git-Tag: 2.0.0_Beta_1~488^2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4dbe4dc20bacab7f0d0811126752270bde82220a;p=GitHub%2FWoltLab%2FWCF.git Adding WCF.LoadingOverlayHandler.updateIcon() --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index bff2bf2953..bda85578ee 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1416,6 +1416,21 @@ WCF.LoadingOverlayHandler = { if (this._activeRequests == 0) { this._loadingOverlay.stop(true, true).fadeOut(100); } + }, + + /** + * Updates a icon to/from spinner + * + * @param jQuery target + * @pram boolean loading + */ + updateIcon: function(target, loading) { + var $method = (loading === undefined || loading ? 'addClass' : 'removeClass'); + + target.find('.icon')[$method]('icon-spinner'); + if (target.hasClass('icon')) { + target[$method]('icon-spinner'); + } } }; @@ -1724,7 +1739,7 @@ WCF.Action.Delete = Class.extend({ WCF.System.Confirmation.show($target.data('confirmMessage'), $.proxy(this._execute, this), { target: $target }); } else { - this._updateIcon($target); + WCF.LoadingOverlayHandler.updateIcon($target); this._sendRequest($target); } }, @@ -1740,22 +1755,10 @@ WCF.Action.Delete = Class.extend({ return; } - this._updateIcon(parameters.target); + WCF.LoadingOverlayHandler.updateIcon(parameters.target); this._sendRequest(parameters.target); }, - /** - * Searches for an icon and updates it to a spinner. - * - * @param jQuery $target - */ - _updateIcon: function($target) { - $target.find('.icon').removeClass('icon-remove').addClass('icon-spinner'); - if ($target.hasClass('icon')) { - $target.removeClass('icon-remove').addClass('icon-spinner'); - } - }, - /** * Sends the request * @@ -1881,6 +1884,7 @@ WCF.Action.Toggle = Class.extend({ WCF.System.Confirmation.show($target.data('confirmMessage'), $.proxy(this._execute, this), { target: $target }); } else { + WCF.LoadingOverlayHandler.updateIcon($target); this._sendRequest($target); } }, @@ -1896,6 +1900,7 @@ WCF.Action.Toggle = Class.extend({ return; } + WCF.LoadingOverlayHandler.updateIcon(parameters.target); this._sendRequest(parameters.target); }, @@ -1945,6 +1950,7 @@ WCF.Action.Toggle = Class.extend({ */ _toggleButton: function($container, $toggleButton) { // toggle icon source + WCF.LoadingOverlayHandler.updateIcon($toggleButton, false); if ($toggleButton.hasClass('icon-off')) { $toggleButton.removeClass('icon-off').addClass('icon-circle-blank'); $newTitle = ($toggleButton.data('enableTitle') ? $toggleButton.data('enableTitle') : WCF.Language.get('wcf.global.button.enable'));