1
|
|
|
(function($) { |
2
|
|
|
'use strict'; |
3
|
|
|
$(function() { |
4
|
|
|
var body = $('body'); |
5
|
|
|
var contentWrapper = $('.content-wrapper'); |
|
|
|
|
6
|
|
|
var scroller = $('.container-scroller'); |
|
|
|
|
7
|
|
|
var footer = $('.footer'); |
|
|
|
|
8
|
|
|
var sidebar = $('.sidebar'); |
9
|
|
|
|
10
|
|
|
//Add active class to nav-link based on url dynamically |
11
|
|
|
//Active class can be hard coded directly in html file also as required |
12
|
|
|
|
13
|
|
|
function addActiveClass(element) { |
14
|
|
|
if (current === "") { |
15
|
|
|
//for root url |
16
|
|
|
if (element.attr('href').indexOf("index.html") !== -1) { |
17
|
|
|
element.parents('.nav-item').last().addClass('active'); |
18
|
|
|
if (element.parents('.sub-menu').length) { |
19
|
|
|
element.closest('.collapse').addClass('show'); |
20
|
|
|
element.addClass('active'); |
21
|
|
|
} |
22
|
|
|
} |
23
|
|
|
} else { |
24
|
|
|
//for other url |
25
|
|
|
if (element.attr('href').indexOf(current) !== -1) { |
26
|
|
|
element.parents('.nav-item').last().addClass('active'); |
27
|
|
|
if (element.parents('.sub-menu').length) { |
28
|
|
|
element.closest('.collapse').addClass('show'); |
29
|
|
|
element.addClass('active'); |
30
|
|
|
} |
31
|
|
|
if (element.parents('.submenu-item').length) { |
32
|
|
|
element.addClass('active'); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
var current = location.pathname.split("/").slice(-1)[0].replace(/^\/|\/$/g, ''); |
39
|
|
|
$('.nav li a', sidebar).each(function() { |
40
|
|
|
var $this = $(this); |
41
|
|
|
addActiveClass($this); |
42
|
|
|
}) |
43
|
|
|
|
44
|
|
|
//Close other submenu in sidebar on opening any |
45
|
|
|
|
46
|
|
|
sidebar.on('show.bs.collapse', '.collapse', function() { |
47
|
|
|
sidebar.find('.collapse.show').collapse('hide'); |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
//Change sidebar |
52
|
|
|
$('[data-toggle="minimize"]').on("click", function() { |
53
|
|
|
body.toggleClass('sidebar-icon-only'); |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
//checkbox and radios |
57
|
|
|
$(".form-check label,.form-radio label").append('<i class="input-helper"></i>'); |
58
|
|
|
|
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
// focus input when clicking on search icon |
62
|
|
|
$('#navbar-search-icon').click(function() { |
63
|
|
|
$("#navbar-search-input").focus(); |
64
|
|
|
}); |
65
|
|
|
|
66
|
|
|
})(jQuery); |