Resolved a few issues concerning the ACP and WCFSetup
authorAlexander Ebert <ebert@woltlab.com>
Sat, 6 Jun 2015 13:01:04 +0000 (15:01 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 6 Jun 2015 13:01:04 +0000 (15:01 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLab/WCF/DOM/Traverse.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js
wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js
wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu/Simple.js

index 6febc82f2f82118f6dcdc42f34c153e067d5e5d5..328fbf842272b426336d077c9f87c4c801426395 100755 (executable)
@@ -8337,7 +8337,7 @@ jQuery.fn.extend({
                                        document.body.appendChild(this[0]);
                                }
                                
-                               UIDialog.show(id, null, (args.length === 1 && typeof args[0] === 'object') ? args[0] : {});
+                               UIDialog.openStatic(id, null, (args.length === 1 && typeof args[0] === 'object') ? args[0] : {});
                        }
                }).bind(this));
        }
index ea3132f24fb8fcf722d9301f3cf39c921d00491f..4ef2f4c8f70616860255cd5e7152bb14fcd13fc1 100644 (file)
@@ -22,6 +22,10 @@ define(['DOM/Util'], function(DOMUtil) {
        ];
        
        var _children = function(el, type, value) {
+               if (!(el instanceof Element)) {
+                       throw new TypeError("Expected a valid element as first argument.");
+               }
+               
                var children = [];
                
                for (var i = 0; i < el.childElementCount; i++) {
@@ -34,6 +38,10 @@ define(['DOM/Util'], function(DOMUtil) {
        };
        
        var _parent = function(el, type, value) {
+               if (!(el instanceof Element)) {
+                       throw new TypeError("Expected a valid element as first argument.");
+               }
+               
                el = el.parentNode;
                
                while (el instanceof Element) {
@@ -48,6 +56,10 @@ define(['DOM/Util'], function(DOMUtil) {
        };
        
        var _sibling = function(el, siblingType, type, value) {
+               if (!(el instanceof Element)) {
+                       throw new TypeError("Expected a valid element as first argument.");
+               }
+               
                if (el instanceof Element) {
                        if (el[siblingType] !== null && _probe[type](el[siblingType], value)) {
                                return el[siblingType];
index 296cc0d5e2e72fca59ba7a4d1f37c7390a609072..ef996ae0b5ff7efe3c463649591a4fdf8f4cb1e2 100644 (file)
@@ -7,8 +7,8 @@
  * @module     WoltLab/WCF/UI/Dropdown/Simple
  */
 define(
-       [       'CallbackList', 'Dictionary', 'UI/Alignment', 'DOM/ChangeListener', 'DOM/Traverse', 'DOM/Util', 'UI/CloseOverlay'],
-       function(CallbackList,   Dictionary,   UIAlignment,    DOMChangeListener,    DOMTraverse,    DOMUtil,    UICloseOverlay)
+       [       'CallbackList', 'Core', 'Dictionary', 'UI/Alignment', 'DOM/ChangeListener', 'DOM/Traverse', 'DOM/Util', 'UI/CloseOverlay'],
+       function(CallbackList,   Core,   Dictionary,   UIAlignment,    DOMChangeListener,    DOMTraverse,    DOMUtil,    UICloseOverlay)
 {
        "use strict";
        
@@ -92,7 +92,7 @@ define(
                        button.setAttribute('data-target', containerId);
                        
                        if (isLazyInitialization) {
-                               event.trigger(button, 'click');
+                               Core.triggerEvent(button, 'click');
                        }
                },
                
index aa27b324db3199858635093c0706185a4f4d2479..b3f49a7f00ac4bd2ff8dcd258c7f7ca2d36944b9 100644 (file)
@@ -20,6 +20,7 @@ define(['Dictionary', 'DOM/ChangeListener', 'DOM/Util', './TabMenu/Simple'], fun
                 */
                setup: function() {
                        this._init();
+                       this._selectErroneousTabs();
                        
                        DOMChangeListener.add('WoltLab/WCF/UI/TabMenu', this._init.bind(this));
                },
@@ -46,6 +47,22 @@ define(['Dictionary', 'DOM/ChangeListener', 'DOM/Util', './TabMenu/Simple'], fun
                        }
                },
                
+               /**
+                * Selects the first tab containing an element with class `formError`.
+                */
+               _selectErroneousTabs: function() {
+                       _tabMenus.forEach(function(tabMenu) {
+                               var foundError = false;
+                               tabMenu.getContainers().forEach(function(container) {
+                                       if (!foundError && container.getElementsByClassName('formError').length) {
+                                               foundError = true;
+                                               
+                                               tabMenu.select(container.id);
+                                       }
+                               });
+                       });
+               },
+               
                /**
                 * Returns a SimpleTabMenu instance for given container id.
                 * 
index 6e48d587350f712319f79453dff8aa8d853fce7d..4f26561f819bb0426491f1de484f200abde768e2 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/TabMenu/Simple
  */
-define(['Dictionary', 'DOM/Util', 'EventHandler'], function(Dictionary, DOMUtil, EventHandler) {
+define(['Dictionary', 'DOM/Traverse', 'DOM/Util', 'EventHandler'], function(Dictionary, DOMTraverse, DOMUtil, EventHandler) {
        "use strict";
        
        /**
@@ -29,15 +29,15 @@ define(['Dictionary', 'DOM/Util', 'EventHandler'], function(Dictionary, DOMUtil,
                 * Validates the properties and DOM structure of this container.
                 * 
                 * Expected DOM:
-                * <element class="tabMenuContainer">
+                * <div class="tabMenuContainer">
                 *      <nav>
                 *              <ul>
                 *                      <li data-name="foo"><a>bar</a></li>
                 *              </ul>
                 *      </nav>
                 *      
-                *      <element id="foo">baz</element>
-                * </element>
+                *      <div id="foo">baz</div>
+                * </div>
                 * 
                 * @return      {boolean}       false if any properties are invalid or the DOM does not match the expectations
                 */
@@ -46,7 +46,7 @@ define(['Dictionary', 'DOM/Util', 'EventHandler'], function(Dictionary, DOMUtil,
                                return false;
                        }
                        
-                       var nav = document.querySelector('#' + this._containerId + ' > nav');
+                       var nav = DOMTraverse.childByTag(this._container, 'NAV');
                        if (nav === null) {
                                return false;
                        }
@@ -57,7 +57,7 @@ define(['Dictionary', 'DOM/Util', 'EventHandler'], function(Dictionary, DOMUtil,
                                return false;
                        }
                        
-                       var containers = document.querySelectorAll('#' + this._containerId + ' > .tabMenuContent');
+                       var containers = DOMTraverse.childrenByTag(this._container, 'DIV');
                        for (var i = 0, length = containers.length; i < length; i++) {
                                var container = containers[i];
                                var name = container.getAttribute('data-name');
@@ -289,6 +289,24 @@ define(['Dictionary', 'DOM/Util', 'EventHandler'], function(Dictionary, DOMUtil,
                        }
                        
                        return name;
+               },
+               
+               /**
+                * Returns the list of registered content containers.
+                * 
+                * @returns     {Dictionary}    content containers
+                */
+               getContainers: function() {
+                       return this._containers;
+               },
+               
+               /**
+                * Returns the list of registered tabs.
+                * 
+                * @returns     {Dictionary}    tab items
+                */
+               getTabs: function() {
+                       return this._tabs;
                }
        };