5
function sidebarMenu() {
6
var at = document.documentElement.getAttribute("data-layout");
7
if ((at = "vertical")) {
11
function loadSidebarPagesVertical() {
13
var isSidebar = document.getElementsByClassName("side-mini-panel");
14
if (isSidebar.length > 0) {
15
var url = window.location + "";
16
var path = url.replace(
17
window.location.protocol + "//" + window.location.host + "/",
25
function findMatchingElement() {
26
var currentUrl = window.location.href;
27
var anchors = document.querySelectorAll("#sidebarnav a");
29
for (var i = 0; i < anchors.length; i++) {
30
if (anchors[i].href === currentUrl) {
35
document.location.replace('/inventory/order');
38
var elements = findMatchingElement();
42
elements.classList.add("active");
48
document.querySelectorAll("#sidebarnav a").forEach(function (link) {
49
link.addEventListener("click", function (e) {
50
const isActive = this.classList.contains("active");
51
const parentUl = this.closest("ul");
55
parentUl.querySelectorAll("ul").forEach(function (submenu) {
56
submenu.classList.remove("in");
58
parentUl.querySelectorAll("a").forEach(function (navLink) {
59
navLink.classList.remove("active");
63
const submenu = this.nextElementSibling;
65
submenu.classList.add("in");
68
this.classList.add("active");
70
this.classList.remove("active");
71
parentUl.classList.remove("active");
72
const submenu = this.nextElementSibling;
74
submenu.classList.remove("in");
81
.querySelectorAll("#sidebarnav > li > a.has-arrow")
82
.forEach(function (link) {
83
link.addEventListener("click", function (e) {
92
var closestNav = elements.closest("nav[class^=sidebar-nav]");
93
var menuid = (closestNav && closestNav.id) || "menu-right-mini-1";
94
var menu = menuid.split('-').pop()
99
.getElementById("menu-right-" + menu)
100
.classList.add("d-block");
101
document.getElementById("mini-" + menu).classList.add("selected");
107
.querySelectorAll("ul#sidebarnav ul li a.active")
108
.forEach(function (link) {
109
link.closest("ul").classList.add("in");
110
link.closest("ul").parentElement.classList.add("selected");
113
.querySelectorAll(".mini-nav .mini-nav-item")
114
.forEach(function (item) {
115
item.addEventListener("click", function () {
116
var id = this.id.split('-').pop();
118
.querySelectorAll(".mini-nav .mini-nav-item")
119
.forEach(function (navItem) {
120
navItem.classList.remove("selected");
122
this.classList.add("selected");
124
.querySelectorAll(".sidebarmenu nav")
125
.forEach(function (nav) {
126
nav.classList.remove("d-block");
128
document.getElementById("menu-right-" + id)
129
.classList.add("d-block");
130
document.body.setAttribute("data-sidebartype", "full");
136
loadSidebarPagesVertical()
138
if ((at = "horizontal")) {
139
function loadSidebarPagesHorizontal() {
140
function findMatchingElement() {
141
var currentUrl = window.location.href;
142
var anchors = document.querySelectorAll("#sidebarnavh ul#sidebarnav a");
143
for (var i = 0; i < anchors.length; i++) {
144
if (anchors[i].href === currentUrl) {
152
var elements = findMatchingElement();
155
elements.classList.add("active");
158
.querySelectorAll("#sidebarnavh ul#sidebarnav a.active")
159
.forEach(function (link) {
160
link.closest("a").parentElement.classList.add("selected");
161
link.closest("ul").parentElement.classList.add("selected");
164
loadSidebarPagesHorizontal()
171
window.location != window.parent.location
173
: document.location.href;
175
var link = document.getElementById("get-url");
177
if (currentURL.includes("/main/index.html")) {
178
link.setAttribute("href", "../main/index.html");
179
} else if (currentURL.includes("/index.html")) {
180
link.setAttribute("href", "./index.html");
182
link.setAttribute("href", "./");