mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 17:58:41 +00:00
79 lines
2.0 KiB
JavaScript
79 lines
2.0 KiB
JavaScript
/**
|
|
* Tab manager class.
|
|
*
|
|
* @author OMS Development Team <dev@oms.com>
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
* @copyright 2013 Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0 * @since 1.0.0
|
|
*/
|
|
(function (jsOMS, undefined)
|
|
{
|
|
jsOMS.Autoloader.defineNamespace('jsOMS.UI');
|
|
|
|
/**
|
|
* @constructor
|
|
*
|
|
* @since 1.0.0
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
*/
|
|
jsOMS.UI.TabManager = function (responseManager)
|
|
{
|
|
this.responseManager = responseManager;
|
|
};
|
|
|
|
/**
|
|
* Bind & rebind UI elements.
|
|
*
|
|
* @param {string} [id] Element id
|
|
*
|
|
* @method
|
|
*
|
|
* @since 1.0.0
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
*/
|
|
jsOMS.UI.TabManager.prototype.bind = function (id)
|
|
{
|
|
if (typeof id !== 'undefined') {
|
|
this.bindElement(document.getElementById(id));
|
|
} else {
|
|
var tabs = document.querySelectorAll('.tabview');
|
|
|
|
for (var i = 0; i < tabs.length; i++) {
|
|
this.bindElement(tabs[i]);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Bind & rebind UI element.
|
|
*
|
|
* @param {Object} [e] Element id
|
|
*
|
|
* @method
|
|
*
|
|
* @since 1.0.0
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
*/
|
|
jsOMS.UI.TabManager.prototype.bindElement = function (e)
|
|
{
|
|
var nodes = e.querySelectorAll('.tab-links a');
|
|
|
|
nodes.addEventListener('click', function (evt)
|
|
{
|
|
/* Change Tab */
|
|
var attr = this.getAttribute('href').substring(1),
|
|
cont = this.parentNode.parentNode.parentNode.children[1];
|
|
|
|
jsOMS.removeClass(jsOMS.getByClass(this.parentNode.parentNode, 'active'), 'active');
|
|
jsOMS.addClass(this.parentNode, 'active');
|
|
jsOMS.removeClass(jsOMS.getByClass(cont, 'active'), 'active');
|
|
jsOMS.addClass(jsOMS.getByClass(cont, attr), 'active');
|
|
|
|
/* Modify url */
|
|
|
|
jsOMS.preventAll(evt);
|
|
});
|
|
};
|
|
}(window.jsOMS = window.jsOMS || {}));
|