From bc8cd0ff842532551d64f9416927a641ac8749a5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 31 May 2015 01:39:49 +0200 Subject: [PATCH] Transformed singletons into object literals --- wcfsetup/install/files/js/WoltLab/WCF/Ajax.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/Ajax/Jsonp.js | 9 ++++----- .../install/files/js/WoltLab/WCF/Ajax/Status.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js | 7 +++---- .../files/js/WoltLab/WCF/BootstrapFrontend.js | 7 +++---- .../install/files/js/WoltLab/WCF/CallbackList.js | 2 +- .../js/WoltLab/WCF/Controller/Notice/Dismiss.js | 7 +++---- .../files/js/WoltLab/WCF/Controller/Popover.js | 9 ++++----- .../files/js/WoltLab/WCF/Controller/Sitemap.js | 7 +++---- .../js/WoltLab/WCF/Controller/Style/Changer.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/Core.js | 7 +++---- .../files/js/WoltLab/WCF/DOM/Change/Listener.js | 7 +++---- .../install/files/js/WoltLab/WCF/DOM/Traverse.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/DOM/Util.js | 13 +++---------- .../files/js/WoltLab/WCF/Date/Time/Relative.js | 11 ++++------- .../install/files/js/WoltLab/WCF/Environment.js | 7 +++---- .../install/files/js/WoltLab/WCF/Event/Handler.js | 13 ++++++------- wcfsetup/install/files/js/WoltLab/WCF/Language.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/NumberUtil.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/StringUtil.js | 7 +++---- .../install/files/js/WoltLab/WCF/UI/Alignment.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js | 7 +++---- .../files/js/WoltLab/WCF/UI/Dropdown/Simple.js | 11 +++++------ wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js | 7 +++---- wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js | 7 +++---- 26 files changed, 84 insertions(+), 117 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js index eaf6bb8b2c..1d32756690 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js @@ -12,10 +12,9 @@ define(['AjaxRequest', 'Core', 'ObjectMap'], function(AjaxRequest, Core, ObjectM var _requests = new ObjectMap(); /** - * @constructor + * @exports WoltLab/WCF/Ajax */ - function Ajax() {}; - Ajax.prototype = { + var Ajax = { /** * Shorthand function to perform a request against the WCF-API with overrides * for success and failure callbacks. @@ -87,5 +86,5 @@ define(['AjaxRequest', 'Core', 'ObjectMap'], function(AjaxRequest, Core, ObjectM } }; - return new Ajax(); + return Ajax; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Jsonp.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Jsonp.js index 12a7de89ea..6f501d513f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Jsonp.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Jsonp.js @@ -10,10 +10,9 @@ define(['Core'], function(Core) { "use strict"; /** - * @constructor + * @exports WoltLab/WCF/Ajax/Jsonp */ - function AjaxJsonp() {}; - AjaxJsonp.prototype = { + var AjaxJsonp = { /** * Issues a JSONP request. * @@ -57,12 +56,12 @@ define(['Core'], function(Core) { url += options.parameterName + '=' + callbackName; var script = document.createElement('script'); - script.setAttribute('async', true); + script.async = true; script.setAttribute('src', url); document.head.appendChild(script); } }; - return new AjaxJsonp(); + return AjaxJsonp; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Status.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Status.js index 7eedcc80ac..ef0425f3b4 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Status.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Status.js @@ -14,10 +14,9 @@ define(['Language'], function(Language) { var _timeoutShow = null; /** - * @constructor + * @exports WoltLab/WCF/Ajax/Status */ - function AjaxStatus() {} - AjaxStatus.prototype = { + var AjaxStatus = { /** * Initializes the status overlay on first usage. */ @@ -73,5 +72,5 @@ define(['Language'], function(Language) { } }; - return new AjaxStatus(); + return AjaxStatus; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js b/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js index 659313b7a8..cc9ac288f6 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js @@ -33,10 +33,9 @@ define( window.WCF.Language.addObject = Language.addObject; /** - * @constructor + * @exports WoltLab/WCF/Bootstrap */ - function Bootstrap() {} - Bootstrap.prototype = { + var Bootstrap = { /** * Initializes the core UI modifications and unblocks jQuery's ready event. */ @@ -76,5 +75,5 @@ define( } }; - return new Bootstrap(); + return Bootstrap; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js index 20dfb36287..c0db4f006a 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/BootstrapFrontend.js @@ -10,10 +10,9 @@ define(['Ajax', 'WoltLab/WCF/Bootstrap', 'WoltLab/WCF/Controller/Sitemap', 'Wolt "use strict"; /** - * @constructor + * @exports WoltLab/WCF/BootstrapFrontend */ - function BootstrapFrontend() {} - BootstrapFrontend.prototype = { + var BootstrapFrontend = { /** * Bootstraps general modules and frontend exclusive ones. * @@ -54,5 +53,5 @@ define(['Ajax', 'WoltLab/WCF/Bootstrap', 'WoltLab/WCF/Controller/Sitemap', 'Wolt } }; - return new BootstrapFrontend(); + return BootstrapFrontend; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js b/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js index 35921724ac..0aa106ea35 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js @@ -40,7 +40,7 @@ define(['Dictionary'], function(Dictionary) { * @param {string} identifier arbitrary string to group and identify callbacks */ remove: function(identifier) { - this._dictionary.delete(identifier); + this._dictionary['delete'](identifier); }, /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js index 2a0d58645a..502898cb9f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js @@ -10,10 +10,9 @@ define(['Ajax'], function(Ajax) { "use strict"; /** - * @constructor + * @exports WoltLab/WCF/Controller/Notice/Dismiss */ - function ControllerNoticeDismiss() {}; - ControllerNoticeDismiss.prototype = { + var ControllerNoticeDismiss = { /** * Initializes dismiss buttons. */ @@ -53,5 +52,5 @@ define(['Ajax'], function(Ajax) { } }; - return new ControllerNoticeDismiss(); + return ControllerNoticeDismiss; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js index fec8f529e9..b106cc0da5 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js @@ -36,10 +36,9 @@ define(['Ajax', 'Dictionary', 'Environment', 'DOM/ChangeListener', 'DOM/Util', ' /** @const */ var DELAY_HIDE = 500; /** - * @constructor + * @exports WoltLab/WCF/Controller/Popover */ - function ControllerPopover() {}; - ControllerPopover.prototype = { + var ControllerPopover = { /** * Builds popover DOM elements and binds event listeners. */ @@ -418,9 +417,9 @@ define(['Ajax', 'Dictionary', 'Environment', 'DOM/ChangeListener', 'DOM/Util', ' throw new TypeError("Expected a valid callback for parameter 'success'."); } - Ajax.apiProxy(this, data, success, failure); + Ajax.api(this, data, success, failure); } }; - return new ControllerPopover(); + return ControllerPopover; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js index b950051e65..7e6c6888c2 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js @@ -13,10 +13,9 @@ define(['Ajax', 'EventHandler', 'Language', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu var _dialog = null; /** - * @constructor + * @exports WoltLab/WCF/Controller/Sitemap */ - function ControllerSitemap() {}; - ControllerSitemap.prototype = { + var ControllerSitemap = { /** * Binds click handler. */ @@ -93,5 +92,5 @@ define(['Ajax', 'EventHandler', 'Language', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu } }; - return new ControllerSitemap(); + return ControllerSitemap; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js index 9ea7a3ce82..37240ca419 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js @@ -10,10 +10,9 @@ define(['Ajax', 'Language', 'UI/Dialog'], function(Ajax, Language, UIDialog) { "use strict"; /** - * @constructor + * @exports WoltLab/WCF/Controller/Style/Changer */ - function ControllerStyleChanger() {}; - ControllerStyleChanger.prototype = { + var ControllerStyleChanger = { /** * Adds the style changer to the bottom navigation. */ @@ -89,5 +88,5 @@ define(['Ajax', 'Language', 'UI/Dialog'], function(Ajax, Language, UIDialog) { } }; - return new ControllerStyleChanger(); + return ControllerStyleChanger; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Core.js b/wcfsetup/install/files/js/WoltLab/WCF/Core.js index b37850c543..eab4c836d8 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Core.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Core.js @@ -41,10 +41,9 @@ define([], function() { }; /** - * @constructor + * @exports WoltLab/WCF/Core */ - function Core() {}; - Core.prototype = { + var Core = { /** * Deep clones an object. * @@ -195,5 +194,5 @@ define([], function() { } }; - return new Core(); + return Core; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js index 71972d90ea..e295c7dd04 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js @@ -14,10 +14,9 @@ define(['CallbackList'], function(CallbackList) { var _hot = false; /** - * @constructor + * @exports WoltLab/WCF/DOM/Change/Listener */ - function Listener() { }; - Listener.prototype = { + var Listener = { /** * @see WoltLab/WCF/CallbackList#add */ @@ -49,5 +48,5 @@ define(['CallbackList'], function(CallbackList) { } }; - return new Listener(); + return Listener; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Traverse.js b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Traverse.js index cc2416bc7a..ea3132f24f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Traverse.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Traverse.js @@ -58,10 +58,9 @@ define(['DOM/Util'], function(DOMUtil) { }; /** - * @constructor + * @exports WoltLab/WCF/DOM/Traverse */ - function DOMTraverse() {}; - DOMTraverse.prototype = { + var DOMTraverse = { /** * Examines child elements and returns the first child matching the given selector. * @@ -248,5 +247,5 @@ define(['DOM/Util'], function(DOMUtil) { } }; - return new DOMTraverse(); + return DOMTraverse; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Util.js b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Util.js index 596f88370f..34298c5516 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Util.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Util.js @@ -21,10 +21,9 @@ define([], function() { var _idCounter = 0; /** - * @constructor + * @exports WoltLab/WCF/DOM/Util */ - function DOMUtil() {}; - DOMUtil.prototype = { + var DOMUtil = { /** * Returns a DocumentFragment containing the provided HTML string as DOM nodes. * @@ -202,11 +201,5 @@ define([], function() { } }; - var domUtilObj = new DOMUtil(); - - // expose methods on the window object for backwards-compatibility - window.domUtilGetUniqueId = domUtilObj.getUniqueId.bind(domUtilObj); - window.domUtilIdentify = domUtilObj.identify.bind(domUtilObj); - - return domUtilObj; + return DOMUtil; }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js index 2fdb2b0b86..3fcb5693cd 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js @@ -9,20 +9,17 @@ define(['DOM/ChangeListener', 'Language', 'WoltLab/WCF/Timer/Repeating'], function(DOMChangeListener, Language, Repeating) { "use strict"; - var _elements = null; + var _elements = document.getElementsByTagName('time'); var _offset = null; /** - * @constructor + * @exports WoltLab/WCF/Date/Time/Relative */ - function DateTimeRelative() {}; - DateTimeRelative.prototype = { + var DateTimeRelative = { /** * Transforms