mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-02-13 15:28:41 +00:00
Improve navigation to class step 1
This commit is contained in:
parent
067375f2f6
commit
b6a95d55eb
|
|
@ -11,15 +11,15 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/** @namespace jsOMS.Modules.Navigation.Models */
|
/** @namespace jsOMS.Modules.Navigation.Models */
|
||||||
//jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Navigation');
|
jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Navigation');
|
||||||
|
|
||||||
|
jsOMS.Modules.Navigation = class {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation = function ()
|
constructor() {
|
||||||
{
|
|
||||||
this.navigation = {};
|
this.navigation = {};
|
||||||
/** global: jsOMS */
|
/** global: jsOMS */
|
||||||
/** global: localStorage */
|
/** global: localStorage */
|
||||||
|
|
@ -27,14 +27,6 @@
|
||||||
this.rawNavData = this.rawNavData !== null ? this.rawNavData : {};
|
this.rawNavData = this.rawNavData !== null ? this.rawNavData : {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Module id
|
|
||||||
*
|
|
||||||
* @var {string}
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
jsOMS.Modules.Navigation.MODULE_NAME = '1000500001';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind navigation
|
* Bind navigation
|
||||||
*
|
*
|
||||||
|
|
@ -44,8 +36,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.prototype.bind = function (id)
|
bind (id) {
|
||||||
{
|
|
||||||
const e = typeof id === 'undefined' ? document.getElementsByClassName('nav') : [document.getElementById(id)],
|
const e = typeof id === 'undefined' ? document.getElementsByClassName('nav') : [document.getElementById(id)],
|
||||||
length = e.length;
|
length = e.length;
|
||||||
|
|
||||||
|
|
@ -63,8 +54,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.prototype.bindElement = function (e)
|
bindElement (e) {
|
||||||
{
|
|
||||||
if (typeof e === 'undefined' || !e) {
|
if (typeof e === 'undefined' || !e) {
|
||||||
// todo: do logging here
|
// todo: do logging here
|
||||||
|
|
||||||
|
|
@ -99,8 +89,7 @@
|
||||||
e.scrollLeft = this.navigation[e.id].getScrollPosition().x;
|
e.scrollLeft = this.navigation[e.id].getScrollPosition().x;
|
||||||
|
|
||||||
// Bind minimize/maximize
|
// Bind minimize/maximize
|
||||||
jsOMS.addEventListenerToAll(extend, 'click', function ()
|
jsOMS.addEventListenerToAll(extend, 'click', function () {
|
||||||
{
|
|
||||||
let box = document.getElementById(this.getAttribute('for'));
|
let box = document.getElementById(this.getAttribute('for'));
|
||||||
|
|
||||||
if (!box.checked) {
|
if (!box.checked) {
|
||||||
|
|
@ -113,19 +102,26 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bind show/hide
|
// Bind show/hide
|
||||||
e.nextElementSibling.addEventListener('change', function ()
|
e.nextElementSibling.addEventListener('change', function () {
|
||||||
{
|
|
||||||
self.navigation[e.id].setVisible(this.checked);
|
self.navigation[e.id].setVisible(this.checked);
|
||||||
localStorage.setItem(jsOMS.Modules.Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
localStorage.setItem(jsOMS.Modules.Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bind scroll
|
// Bind scroll
|
||||||
e.addEventListener('scroll', function ()
|
e.addEventListener('scroll', function () {
|
||||||
{
|
|
||||||
self.navigation[e.id].setScrollPosition(this.scrollLeft, this.scrollTop);
|
self.navigation[e.id].setScrollPosition(this.scrollLeft, this.scrollTop);
|
||||||
localStorage.setItem(jsOMS.Modules.Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
localStorage.setItem(jsOMS.Modules.Navigation.MODULE_NAME, JSON.stringify(self.navigation));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module id
|
||||||
|
*
|
||||||
|
* @var {string}
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
jsOMS.Modules.NavigationMODULE_NAME = '1000500001';
|
||||||
}(window.jsOMS = window.jsOMS || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
||||||
jsOMS.ready(function ()
|
jsOMS.ready(function ()
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
/** @namespace jsOMS.Modules.Navigation.Models */
|
/** @namespace jsOMS.Modules.Navigation.Models */
|
||||||
jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Navigation.Models');
|
jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Navigation.Models');
|
||||||
|
|
||||||
|
jsOMS.Modules.Navigation.Models.Navigation = class {
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
*
|
*
|
||||||
|
|
@ -20,7 +21,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation = function (data)
|
constructor (data)
|
||||||
{
|
{
|
||||||
if (typeof data === 'undefined') {
|
if (typeof data === 'undefined') {
|
||||||
this.scrollPosition = {x: 0, y: 0};
|
this.scrollPosition = {x: 0, y: 0};
|
||||||
|
|
@ -45,7 +46,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.setScrollPosition = function (x, y)
|
setScrollPosition (x, y)
|
||||||
{
|
{
|
||||||
this.scrollPosition.x = x;
|
this.scrollPosition.x = x;
|
||||||
this.scrollPosition.y = y;
|
this.scrollPosition.y = y;
|
||||||
|
|
@ -58,7 +59,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.getScrollPosition = function ()
|
getScrollPosition ()
|
||||||
{
|
{
|
||||||
return this.scrollPosition;
|
return this.scrollPosition;
|
||||||
};
|
};
|
||||||
|
|
@ -72,7 +73,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.setOpen = function (id)
|
setOpen (id)
|
||||||
{
|
{
|
||||||
this.openCategories[id] = true;
|
this.openCategories[id] = true;
|
||||||
};
|
};
|
||||||
|
|
@ -86,7 +87,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.setClose = function (id)
|
setClose (id)
|
||||||
{
|
{
|
||||||
delete this.openCategories[id];
|
delete this.openCategories[id];
|
||||||
};
|
};
|
||||||
|
|
@ -98,22 +99,22 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.getOpen = function ()
|
getOpen ()
|
||||||
{
|
{
|
||||||
return this.openCategories;
|
return this.openCategories;
|
||||||
};
|
};
|
||||||
|
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.active = function (id)
|
active (id)
|
||||||
{
|
{
|
||||||
this.allInactive();
|
this.allInactive();
|
||||||
};
|
};
|
||||||
|
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.allInactive = function ()
|
allInactive ()
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.inactive = function (id)
|
inactive (id)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -126,7 +127,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.setVisible = function (visible)
|
setVisible (visible)
|
||||||
{
|
{
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
};
|
};
|
||||||
|
|
@ -138,8 +139,9 @@
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
jsOMS.Modules.Navigation.Models.Navigation.prototype.isVisible = function ()
|
isVisible ()
|
||||||
{
|
{
|
||||||
return this.visible;
|
return this.visible;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}(window.jsOMS = window.jsOMS || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user