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));
}
];
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++) {
};
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) {
};
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];
* @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";
button.setAttribute('data-target', containerId);
if (isLazyInitialization) {
- event.trigger(button, 'click');
+ Core.triggerEvent(button, 'click');
}
},
*/
setup: function() {
this._init();
+ this._selectErroneousTabs();
DOMChangeListener.add('WoltLab/WCF/UI/TabMenu', this._init.bind(this));
},
}
},
+ /**
+ * 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.
*
* @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";
/**
* 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
*/
return false;
}
- var nav = document.querySelector('#' + this._containerId + ' > nav');
+ var nav = DOMTraverse.childByTag(this._container, 'NAV');
if (nav === null) {
return false;
}
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');
}
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;
}
};