/**
* @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.
*
// 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) {
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();
});
"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];
}
},
+ /**
+ * 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();
});