-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashforge.js
More file actions
142 lines (109 loc) · 3.61 KB
/
dashforge.js
File metadata and controls
142 lines (109 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
$(function(){
'use strict'
//feather.replace();
////////// NAVBAR //////////
// Initialize PerfectScrollbar of navbar menu for mobile only
if(window.matchMedia('(max-width: 991px)').matches) {
const psNavbar = new PerfectScrollbar('#navbarMenu', {
suppressScrollX: true
});
//console.log("mobile111");
}
// Showing sub-menu of active menu on navbar when mobile
function showNavbarActiveSub() {
if(window.matchMedia('(max-width: 991px)').matches) {
$('#navbarMenu .active').addClass('show');
//console.log("mobile222");
var rwrapper=document.getElementById("rwrapper");
rwrapper.style.display="none";
} else {
$('#navbarMenu .active').removeClass('show');
//console.log("mobile333");
var rwrapper=document.getElementById("rwrapper");
rwrapper.style.display="block";
}
}
showNavbarActiveSub()
$(window).resize(function(){
showNavbarActiveSub()
//.log("mobile444");
})
// Initialize backdrop for overlay purpose
$('body').append('<div class="backdrop"></div>');
// Showing sub menu of navbar menu while hiding other siblings
$('.navbar-menu .with-sub .nav-link').on('click', function(e){
e.preventDefault();
$(this).parent().toggleClass('show');
$(this).parent().siblings().removeClass('show');
//if(window.matchMedia('(max-width: 991px)').matches) {
// psNavbar.update();
//}
})
// Closing dropdown menu of navbar menu
$(document).on('click touchstart', function(e){
e.stopPropagation();
// closing nav sub menu of header when clicking outside of it
if(window.matchMedia('(min-width: 992px)').matches) {
var navTarg = $(e.target).closest('.navbar-menu .nav-item').length;
if(!navTarg) {
$('.navbar-header .show').removeClass('show');
}
}
})
$('#mainMenuClose').on('click', function(e){
e.preventDefault();
$('body').removeClass('navbar-nav-show');
});
$('#sidebarMenuOpen').on('click', function(e){
e.preventDefault();
$('body').addClass('sidebar-show');
})
// Navbar Search
$('#navbarSearch').on('click', function(e){
e.preventDefault();
$('.navbar-search').addClass('visible');
$('.backdrop').addClass('show');
})
$('#navbarSearchClose').on('click', function(e){
e.preventDefault();
$('.navbar-search').removeClass('visible');
$('.backdrop').removeClass('show');
})
////////// SIDEBAR //////////
// Initialize PerfectScrollbar for sidebar menu
if($('#sidebarMenu').length) {
const psSidebar = new PerfectScrollbar('#sidebarMenu', {
suppressScrollX: true
});
// Showing sub menu in sidebar
$('.sidebar-nav .with-sub').on('click', function(e){
e.preventDefault();
$(this).parent().toggleClass('show');
psSidebar.update();
})
}
$('#mainMenuOpen').on('click touchstart', function(e){
e.preventDefault();
$('body').addClass('navbar-nav-show');
})
$('#sidebarMenuClose').on('click', function(e){
e.preventDefault();
$('body').removeClass('sidebar-show');
})
// hide sidebar when clicking outside of it
$(document).on('click touchstart', function(e){
e.stopPropagation();
// closing of sidebar menu when clicking outside of it
if(!$(e.target).closest('.burger-menu').length) {
var sb = $(e.target).closest('.sidebar').length;
var nb = $(e.target).closest('.navbar-menu-wrapper').length;
if(!sb && !nb) {
if($('body').hasClass('navbar-nav-show')) {
$('body').removeClass('navbar-nav-show');
} else {
$('body').removeClass('sidebar-show');
}
}
}
});
})