From f2e420cc80c20ecf1e7a180423609c17d0015516 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 27 Jul 2011 16:16:35 +0200 Subject: [PATCH] Added spinner and global icon storage --- wcfsetup/install/files/js/WCF.js | 59 +++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index e4e4a12ddb..198555b9b2 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -582,6 +582,27 @@ WCF.Action.Proxy.prototype = { */ setOption: function(optionName, optionData) { this.options[optionName] = optionData; + }, + + /** + * Displays a spinner image for given element. + * + * @param jQuery element + */ + showSpinner: function(element) { + element = $(element); + + if (element.getTagName() !== 'img') { + console.debug('Given element is not an image, aborting.'); + return; + } + + // force element dimensions + element.attr('width', element.attr('width')); + element.attr('height', element.attr('height')); + + // replace image + element.attr('src', WCF.Icon.get('wcf.global.spinner')); } }; @@ -688,10 +709,12 @@ WCF.Action.Delete.prototype = { if ($target.data('confirmMessage')) { if (confirm($target.data('confirmMessage'))) { + this.proxy.showSpinner($target); this._sendRequest($target); } } else { + this.proxy.showSpinner($target); this._sendRequest($target); } @@ -1048,7 +1071,7 @@ WCF.Language = { _variables: new WCF.Dictionary(), /** - * @see WCF.Dictionary.addObject() + * @see WCF.Dictionary.add() */ add: function(key, value) { this._variables.add(key, value); @@ -1072,6 +1095,40 @@ WCF.Language = { } }; +/** + * Icon collection used across all JavaScript classes. + * + * @see WCF.Dictionary + */ +WCF.Icon = { + /** + * list of icons + * @var WCF.Dictionary + */ + _icons: new WCF.Dictionary(), + + /** + * @see WCF.Dictionary.add() + */ + add: function(name, path) { + this._icons.add(name, path); + }, + + /** + * @see WCF.Dictionary.addObject() + */ + addObject: function(object) { + this._icons.addObject(object); + }, + + /** + * @see WCF.Dictionary.get() + */ + get: function(name) { + return this._icons.get(name); + } +}; + /** * Number utilities. */ -- 2.20.1