-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom.js
389 lines (315 loc) · 12.7 KB
/
custom.js
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
$(function() {
'use strict'
// ______________LOADER
$("#global-loader").fadeOut("slow");
// This template is mobile first so active menu in navbar
// has submenu displayed by default but not in desktop
// so the code below will hide the active menu if it's in desktop
if (window.matchMedia('(min-width: 992px)').matches) {
$('.main-navbar .active').removeClass('show');
$('.main-header-menu .active').removeClass('show');
}
// Shows header dropdown while hiding others
$('.main-header .dropdown > a').on('click', function(e) {
e.preventDefault();
$(this).parent().toggleClass('show');
$(this).parent().siblings().removeClass('show');
$(this).find('.drop-flag').removeClass('show');
});
$('.country-flag1').on('click', function(e){
$(this).parent().toggleClass('show');
$('.main-header .dropdown > a').parent().siblings().removeClass('show');
});
// ______________Full screen
$(document).on("click", ".full-screen", function toggleFullScreen() {
$('html').addClass('fullscreen-button');
if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
}
} else {
$('html').removeClass('fullscreen-button');
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
})
// ______________ RATING STAR
var ratingOptions = {
selectors: {
starsSelector: '.rating-stars',
starSelector: '.rating-star',
starActiveClass: 'is--active',
starHoverClass: 'is--hover',
starNoHoverClass: 'is--no-hover',
targetFormElementSelector: '.rating-value'
}
};
$(".rating-stars").ratingStars(ratingOptions);
// ______________Cover Image
$(".cover-image").each(function() {
var attr = $(this).attr('data-bs-image-src');
if (typeof attr !== typeof undefined && attr !== false) {
$(this).css('background', 'url(' + attr + ') center center');
}
});
// ______________Toast
$(".toast").toast();
/* Headerfixed */
$(window).on("scroll", function(e){
if ($(window).scrollTop() >= 66) {
$('main-header').addClass('fixed-header');
}
else {
$('.main-header').removeClass('fixed-header');
}
});
// ______________Search
$('body, .main-header form[role="search"] button[type="reset"]').on('click keyup', function(event) {
if (event.which == 27 && $('.main-header form[role="search"]').hasClass('active') ||
$(event.currentTarget).attr('type') == 'reset') {
closeSearch();
}
});
function closeSearch() {
var $form = $('.main-header form[role="search"].active')
$form.find('input').val('');
$form.removeClass('active');
}
// Show Search if form is not active // event.preventDefault() is important, this prevents the form from submitting
$(document).on('click', '.main-header form[role="search"]:not(.active) button[type="submit"]', function(event) {
event.preventDefault();
var $form = $(this).closest('form'),
$input = $form.find('input');
$form.addClass('active');
$input.focus();
});
// if your form is ajax remember to call `closeSearch()` to close the search container
$(document).on('click', '.main-header form[role="search"].active button[type="submit"]', function(event) {
event.preventDefault();
var $form = $(this).closest('form'),
$input = $form.find('input');
$('#showSearchTerm').text($input.val());
closeSearch()
});
/* ----------------------------------- */
// Showing submenu in navbar while hiding previous open submenu
$('.main-navbar .with-sub').on('click', function(e) {
e.preventDefault();
$(this).parent().toggleClass('show');
$(this).parent().siblings().removeClass('show');
});
// this will hide dropdown menu from open in mobile
$('.dropdown-menu .main-header-arrow').on('click', function(e) {
e.preventDefault();
$(this).closest('.dropdown').removeClass('show');
});
// this will show navbar in left for mobile only
$('#mainNavShow, #azNavbarShow').on('click', function(e) {
e.preventDefault();
$('body').addClass('main-navbar-show');
});
// this will hide currently open content of page
// only works for mobile
$('#mainContentLeftShow').on('click touch', function(e) {
e.preventDefault();
$('body').addClass('main-content-left-show');
});
// This will hide left content from showing up in mobile only
$('#mainContentLeftHide').on('click touch', function(e) {
e.preventDefault();
$('body').removeClass('main-content-left-show');
});
// this will hide content body from showing up in mobile only
$('#mainContentBodyHide').on('click touch', function(e) {
e.preventDefault();
$('body').removeClass('main-content-body-show');
})
// navbar backdrop for mobile only
$('body').append('<div class="main-navbar-backdrop"></div>');
$('.main-navbar-backdrop').on('click touchstart', function() {
$('body').removeClass('main-navbar-show');
});
// Close dropdown menu of header menu
$(document).on('click touchstart', function(e) {
e.stopPropagation();
// closing of dropdown menu in header when clicking outside of it
var dropTarg = $(e.target).closest('.main-header .dropdown').length;
if (!dropTarg) {
$('.main-header .dropdown').removeClass('show');
}
// closing nav sub menu of header when clicking outside of it
if (window.matchMedia('(min-width: 992px)').matches) {
// Navbar
var navTarg = $(e.target).closest('.main-navbar .nav-item').length;
if (!navTarg) {
$('.main-navbar .show').removeClass('show');
}
// Header Menu
var menuTarg = $(e.target).closest('.main-header-menu .nav-item').length;
if (!menuTarg) {
$('.main-header-menu .show').removeClass('show');
}
if ($(e.target).hasClass('main-menu-sub-mega')) {
$('.main-header-menu .show').removeClass('show');
}
} else {
//
if (!$(e.target).closest('#mainMenuShow').length) {
var hm = $(e.target).closest('.main-header-menu').length;
if (!hm) {
$('body').removeClass('main-header-menu-show');
}
}
}
});
$('#mainMenuShow').on('click', function(e) {
e.preventDefault();
$('body').toggleClass('main-header-menu-show');
})
$('.main-header-menu .with-sub').on('click', function(e) {
e.preventDefault();
$(this).parent().toggleClass('show');
$(this).parent().siblings().removeClass('show');
})
$('.main-header-menu-header .close').on('click', function(e) {
e.preventDefault();
$('body').removeClass('main-header-menu-show');
})
$(".card-header-right .card-option .fe fe-chevron-left").on("click", function() {
var a = $(this);
if (a.hasClass("icofont-simple-right")) {
a.parents(".card-option").animate({
width: "35px",
})
} else {
a.parents(".card-option").animate({
width: "180px",
})
}
$(this).toggleClass("fe fe-chevron-right").fadeIn("slow")
});
// ___________TOOLTIP
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
// __________POPOVER
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
// Enable Eva-icons with SVG markup
eva.replace();
// ______________Horizontal-menu Active Class
$(document).ready(function() {
$(".horizontalMenu-list li a").each(function() {
var pageUrl = window.location.href.split(/[?#]/)[0];
if (this.href == pageUrl) {
$(this).addClass("active");
$(this).parent().addClass("active"); // add active to li of the current link
$(this).parent().parent().prev().addClass("active"); // add active class to an anchor
$(this).parent().parent().prev().click(); // click the item to make it drop
}
});
});
// ______________Active Class
$(document).ready(function() {
$(".horizontalMenu-list li a").each(function() {
var pageUrl = window.location.href.split(/[?#]/)[0];
if (this.href == pageUrl) {
$(this).addClass("active");
$(this).parent().addClass("active"); // add active to li of the current link
$(this).parent().parent().prev().addClass("active"); // add active class to an anchor
$(this).parent().parent().prev().click(); // click the item to make it drop
}
});
$(".horizontal-megamenu li a").each(function() {
var pageUrl = window.location.href.split(/[?#]/)[0];
if (this.href == pageUrl) {
$(this).addClass("active");
$(this).parent().addClass("active"); // add active to li of the current link
$(this).parent().parent().parent().parent().parent().parent().parent().prev().addClass("active"); // add active class to an anchor
$(this).parent().parent().prev().click(); // click the item to make it drop
}
});
$(".horizontalMenu-list .sub-menu .sub-menu li a").each(function() {
var pageUrl = window.location.href.split(/[?#]/)[0];
if (this.href == pageUrl) {
$(this).addClass("active");
$(this).parent().addClass("active"); // add active to li of the current link
$(this).parent().parent().parent().parent().prev().addClass("active"); // add active class to an anchor
$(this).parent().parent().prev().click(); // click the item to make it drop
}
});
});
// ______________ Back to Top
var btn = $('#back-to-top');
$(window).scroll(function() {
if ($(window).scrollTop() > 300) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
btn.on('click', function(e) {
e.preventDefault();
$('html, body').animate({scrollTop:0}, '300');
});
// ______________Skins
////////////////////////////////////////////////////
/* ############# Horizontal version ########*/
//////////////////////////////////////////////////
/* ########### Horizontal Light ###########*/
// $('body').addClass('horizontal-light'); //
/* ########### Horizontal color ###########*/
// $('body').addClass('horizontal-color'); //
/* ########### Horizontal dark ###########*/
// $('body').addClass(' horizontal-dark'); //
/* ########### Horizontal gradient ###########*/
// $('body').addClass(' horizontal-gradient'); //
////////////////////////////////////////////////////
/* ############# Leftmenu version ########*/
//////////////////////////////////////////////////
/* ########### Leftmenu Light ###########*/
// $('body').addClass('leftmenu-light'); //
/* ########### Leftmenu color ###########*/
// $('body').addClass('leftmenu-color'); //
/* ########### Leftmenu dark ###########*/
// $('body').addClass('leftmenu-dark'); //
/* ########### Leftmenu gradient ###########*/
// $('body').addClass('leftmenu-gradient'); //
////////////////////////////////////////////////////
/* ############# Leftmenu Light Image ########*/
//////////////////////////////////////////////////
/* ########### backgroundimage-1 ###########*/
// $('body').addClass(' leftbgimage1');
/* ########### backgroundimage-2 ###########*/
// $('body').addClass('leftbgimage2'); //
/* ########### backgroundimage-3 ###########*/
// $('body').addClass(' leftbgimage3'); //
/* ########### backgroundimage-4 ###########*/
// $('body').addClass(' leftbgimage4'); //
/* ########### backgroundimage-5 ###########*/
// $('body').addClass(' leftbgimage5'); //
////////////////////////////////////////////////////
/* ############# Body Style ########*/
//////////////////////////////////////////////////
// $('body').addClass(' body-style1'); //
/*Theme Layouts*/
// $('body').addClass('dark-theme');
/*-- width styles ---*/
// $('body').addClass('boxed'); //
});