Changed var Foo = function() to function Foo(), added missing JSDoc
authorAlexander Ebert <ebert@woltlab.com>
Sun, 3 May 2015 19:00:46 +0000 (21:00 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 3 May 2015 19:00:46 +0000 (21:00 +0200)
12 files changed:
wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js
wcfsetup/install/files/js/WoltLab/WCF/Core.js
wcfsetup/install/files/js/WoltLab/WCF/DOM/Traverse.js
wcfsetup/install/files/js/WoltLab/WCF/DOM/Util.js
wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js
wcfsetup/install/files/js/WoltLab/WCF/Dictionary.js
wcfsetup/install/files/js/WoltLab/WCF/Event/Handler.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Alignment.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js
wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js
wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu/Simple.js

index 148d77571bec7cbe7d0fda486547e5e6d508b600..3b2aaf14bbd40f1ca1597b9f4394f885892768a7 100644 (file)
@@ -12,7 +12,7 @@ define(['Dictionary'], function(Dictionary) {
        /**
         * @constructor
         */
-       var CallbackList = function() {
+       function CallbackList() {
                this._dictionary = new Dictionary();
        };
        CallbackList.prototype = {
index 6eb70df14f84ee57b7a89e292199f1e1fb446514..892e822b2a0299a0c9819c7ade8164ecb10039cf 100644 (file)
@@ -12,7 +12,7 @@ define(['jQuery'], function($) {
        /**
         * @constructor
         */
-       var Core = function() {};
+       function Core() {};
        Core.prototype = {
                /**
                 * Initializes the core UI modifications and unblocks jQuery's ready event.
index 1eb7b5afe0e280c7be9e6ff18608d7c417def100..ff180ada0fbb68aaad4933781a71837a6f96f84f 100644 (file)
@@ -48,7 +48,7 @@ define(['DOM/Util'], function(DOMUtil) {
        /**
         * @constructor
         */
-       var DOMTraverse = function() {};
+       function DOMTraverse() {};
        DOMTraverse.prototype = {
                /**
                 * Examines parent nodes and returns the first parent that matches the given selector.
index ffa911b368b8952c2b1bf5fa865649d571b2a685..18d3a898ce813527f0a0165c1884f27068ddfd65 100644 (file)
@@ -23,7 +23,7 @@ define(function() {
        /**
         * @constructor
         */
-       var DOMUtil = function() {};
+       function DOMUtil() {};
        DOMUtil.prototype = {
                /**
                 * Returns a unique element id.
index 477d740a1b825de22b1c319dee0d2c50298469bc..2c1d76439bae959511a95e4ccad7da1919b9f16c 100644 (file)
@@ -15,7 +15,7 @@ define(function() {
        /**
         * @constructor
         */
-       var DateTimeRelative = function() {};
+       function DateTimeRelative() {};
        DateTimeRelative.prototype = {
                /**
                 * Transforms <time> elements on init and binds event listeners.
index 505253c744deb335aaf2e9405cbcdabd4b6b11ef..ce3ae6046fe2336706ba540aa5f13a121c05da43 100644 (file)
@@ -14,7 +14,7 @@ define(function() {
        /**
         * @constructor
         */
-       var Dictionary = function() {
+       function Dictionary() {
                this._dictionary = (_hasMap) ? new Map() : {};
        };
        Dictionary.prototype = {
index 21b63967bbd84e33c52bc3f258db44f55049b3b4..d6bf74f7ee232ee7f114b8a566f0bf576582d736 100644 (file)
@@ -14,7 +14,7 @@ define(['Dictionary'], function(Dictionary) {
        /**
         * @constructor
         */
-       var EventHandler = function() {};
+       function EventHandler() {};
        EventHandler.prototype = {
                /**
                 * Adds an event listener.
index bff6c610e78dd529b8fc519fdd190224d9a27aeb..25a01a7a3dfab5163e5349dcedc96c288941aecb 100644 (file)
@@ -12,57 +12,8 @@ define(['Core', 'DOM/Util'], function(Core, DOMUtil) {
        /**
         * @constructor
         */
-       var UiAlignment = function() {};
-       UiAlignment.prototype = {
-               _tryAlignmentHorizontal: function(align, elDimensions, refDimensions, refOffsets, windowWidth) {
-                       var left = 'auto';
-                       var right = 'auto';
-                       var result = true;
-                       
-                       if (align === 'left') {
-                               left = refOffsets.left;
-                               if (left + elDimensions.width > windowWidth) {
-                                       result = false;
-                               }
-                       }
-                       else {
-                               right = refOffsets.left + refDimensions.width;
-                               if (right - elDimensions.width < 0) {
-                                       result = false;
-                               }
-                       }
-                       
-                       return {
-                               left: left,
-                               right: right,
-                               result: result
-                       }
-               },
-               _tryAlignmentVertical: function(align, elDimensions, refDimensions, refOffsets, windowHeight, verticalOffset) {
-                       var bottom = 'auto';
-                       var top = 'auto';
-                       var result = true;
-                       
-                       if (align === 'top') {
-                               bottom = refOffsets.top + verticalOffset;
-                               if (bottom - elDimensions.height < 0) {
-                                       result = false;
-                               }
-                       }
-                       else {
-                               top = refOffsets.top + refDimensions.height + verticalOffset;
-                               if (top + elDimensions.height > windowHeight) {
-                                       result = false;
-                               }
-                       }
-                       
-                       return {
-                               bottom: bottom,
-                               top: top,
-                               result: result
-                       }
-               },
-               
+       function UIAlignment() {};
+       UIAlignment.prototype = {
                /**
                 * Sets the alignment for target element relatively to the reference element.
                 * 
@@ -142,8 +93,8 @@ define(['Core', 'DOM/Util'], function(Core, DOMUtil) {
                        
                        // set pointer position
                        if (options.pointer) {
-                               var pointer = null;
-                               
+                               //var pointer = null;
+                               // TODO: implement pointer support, e.g. for interactive dropdowns
                                console.debug("TODO");
                        }
                        else if (options.pointerClassNames.length === 2) {
@@ -160,8 +111,79 @@ define(['Core', 'DOM/Util'], function(Core, DOMUtil) {
                                right: right + (right !== 'auto' ? 'px' : ''),
                                top: top + (top !== 'auto' ? 'px' : '')
                        });
+               },
+               
+               /**
+                * Calculates left/right position and verifys if the element would be still within the page's boundaries.
+                * 
+                * @param       {string}                        align           align to this side of the reference element
+                * @param       {object<string, integer>}       elDimensions    element dimensions
+                * @param       {object<string, integer>}       refDimensions   reference element dimensions
+                * @param       {object<string, integer>}       refOffsets      position of reference element relative to the document
+                * @param       {integer}                       windowWidth     window width
+                * @returns     {object<string, *>}     calculation results
+                */
+               _tryAlignmentHorizontal: function(align, elDimensions, refDimensions, refOffsets, windowWidth) {
+                       var left = 'auto';
+                       var right = 'auto';
+                       var result = true;
+                       
+                       if (align === 'left') {
+                               left = refOffsets.left;
+                               if (left + elDimensions.width > windowWidth) {
+                                       result = false;
+                               }
+                       }
+                       else {
+                               right = refOffsets.left + refDimensions.width;
+                               if (right - elDimensions.width < 0) {
+                                       result = false;
+                               }
+                       }
+                       
+                       return {
+                               left: left,
+                               right: right,
+                               result: result
+                       };
+               },
+               
+               /**
+                * Calculates top/bottom position and verifys if the element would be still within the page's boundaries.
+                * 
+                * @param       {string}                        align           align to this side of the reference element
+                * @param       {object<string, integer>}       elDimensions    element dimensions
+                * @param       {object<string, integer>}       refDimensions   reference element dimensions
+                * @param       {object<string, integer>}       refOffsets      position of reference element relative to the document
+                * @param       {integer}                       windowHeight    window height
+                * @param       {integer}                       verticalOffset  desired gap between element and reference element
+                * @returns     {object<string, *>}     calculation results
+                */
+               _tryAlignmentVertical: function(align, elDimensions, refDimensions, refOffsets, windowHeight, verticalOffset) {
+                       var bottom = 'auto';
+                       var top = 'auto';
+                       var result = true;
+                       
+                       if (align === 'top') {
+                               bottom = refOffsets.top + verticalOffset;
+                               if (bottom - elDimensions.height < 0) {
+                                       result = false;
+                               }
+                       }
+                       else {
+                               top = refOffsets.top + refDimensions.height + verticalOffset;
+                               if (top + elDimensions.height > windowHeight) {
+                                       result = false;
+                               }
+                       }
+                       
+                       return {
+                               bottom: bottom,
+                               top: top,
+                               result: result
+                       };
                }
        };
        
-       return new UiAlignment();
+       return new UIAlignment();
 });
index 38c9e96d4e914c5ccb1b6a0a2f0d013f26c00b49..62b5bac7b4350ba43b29d1e5868660a9f72295f5 100644 (file)
@@ -21,7 +21,7 @@ define(
        /**
         * @constructor
         */
-       var SimpleDropdown = function() { };
+       function SimpleDropdown() { };
        SimpleDropdown.prototype = {
                /**
                 * Performs initial setup such as setting up dropdowns and binding listeners.
index ac34683b6ae1cecba182f048920938ea2cf49b71..abc03b59f97527ad14b64e5ccf49606784276528 100644 (file)
@@ -17,8 +17,8 @@ define(['jQuery', 'enquire', 'DOM/Traverse'], function($, enquire, DOMTraverse)
        /**
         * @constructor
         */
-       var UiMobile = function() {};
-       UiMobile.prototype = {
+       function UIMobile() {};
+       UIMobile.prototype = {
                /**
                 * Initializes the mobile UI using enquire.js.
                 */
index be211c846a39960182723f6e5d10961cf3a51336..0a0250119177a70a91dbaca411c8efb7f7878b07 100644 (file)
@@ -1,14 +1,34 @@
 "use strict";
 
+/**
+ * Common interface for tab menu access.
+ * 
+ * @author     Alexander Ebert
+ * @copyright  2001-2015 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module     WoltLab/WCF/UI/TabMenu
+ */
 define(['Dictionary', 'DOM/Util', './TabMenu/Simple'], function(Dictionary, DOMUtil, SimpleTabMenu) {
        var _tabMenus = new Dictionary();
        
        /**
         * @constructor
         */
-       var UiTabMenu = function() {};
-       UiTabMenu.prototype = {
-               init: function() {
+       function UITabMenu() {};
+       UITabMenu.prototype = {
+               /**
+                * Sets up tab menus and binds listeners.
+                */
+               setup: function() {
+                       this._init();
+                       
+                       // TODO: use WCF.DOMNodeInsertedHandler
+               },
+               
+               /**
+                * Initializes available tab menus.
+                */
+               _init: function() {
                        var tabMenus = document.querySelectorAll('.tabMenuContainer:not(.staticTabMenuContainer)');
                        for (var i = 0, length = tabMenus.length; i < length; i++) {
                                var container = tabMenus[i];
@@ -27,10 +47,16 @@ define(['Dictionary', 'DOM/Util', './TabMenu/Simple'], function(Dictionary, DOMU
                        }
                },
                
+               /**
+                * Returns a SimpleTabMenu instance for given container id.
+                * 
+                * @param       {string}        containerId     tab menu container id
+                * @return      {SimpleTabMenu} tab menu object
+                */
                getTabMenu: function(containerId) {
                        return _tabMenus.get(containerId);
                }
        };
        
-       return new UiTabMenu();
+       return new UITabMenu();
 });
index 6be0a66ebd3694f4587f1d523919a936d11d8002..faa6d4d2eec8d9ffba3cd0cda43688145b489f89 100644 (file)
@@ -14,7 +14,7 @@ define(['jQuery', 'Dictionary', 'DOM/Util', 'EventHandler'], function($, Diction
         * @param       {Element}       container       container element
         * @constructor
         */
-       var TabMenuSimple = function(containerId, container) {
+       function TabMenuSimple(containerId, container) {
                this._container = container;
                this._containers = new Dictionary();
                this._containerId = containerId;