-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
181 lines (160 loc) · 5.51 KB
/
Copy pathmain.js
File metadata and controls
181 lines (160 loc) · 5.51 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
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
/*! --------------------------------------------------------------
# main.js
#
# Main theme js file for Options-admin template.
# This is compressed js file. You get uncompressed version with download.
--------------------------------------------------------------*/
$(function($) {
"use strict";
// Toggle user info on sidebar
$('.user-info-handle').on('click', function(event){
event.preventDefault();
$('.user-info').toggleClass('closed');
});
// Toggle small sidebar
$('.small-nav-handle').on('click', function(event){
event.preventDefault();
$('.left-sidebar').toggleClass('small-nav');
$('.navbar-header').toggleClass('small-nav-header');
});
// Toggle Mobile Nav
$('.mobile-nav-toggle').on('click', function(event){
event.preventDefault();
$('.left-sidebar').toggle();
})
// Toggle tooltips
$('[data-toggle="tooltip"]').tooltip();
// Toggle popovers
$('[data-toggle="popover"]').popover();
// For custom modal backdrop
$('.modal[data-backdrop-color]').on('show.bs.modal hide.bs.modal', function () {
$('body').toggleClass('modal-color-'+ $(this).data('backdropColor'));
});
// Open right sidebar
$('.open-right-sidebar').on('click', function(event){
event.preventDefault();
$('.right-sidebar, .right-sidebar .sidebar-content').css('right','0px');
});
$('.right-sidebar .close-icon').on('click', function(event){
event.preventDefault();
$('.right-sidebar, .right-sidebar .sidebar-content').css('right','-400px');
});
// Initialize panel controls
$('[data-panel-control]').lobiPanel();
// Visibility of source code button
$('.src-btn').hide();
$('.toggle-help-handle').on('click', function(event){
event.preventDefault();
$('.src-btn').toggle();
});
// Visibility of source code button
$('.src-code').hide();
$('.toggle-code-handle').on('click', function(event){
event.preventDefault();
$('.src-code').toggle();
});
// Toggle full screen
$('.full-screen-handle').on('click', function(event){
event.preventDefault();
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !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.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
});
// Toggle sidebar dropdown
$('.has-children').not('.open').find('.child-nav').slideUp('100');
$('.has-children>a').on('click', function(event){
event.preventDefault();
$(this).parent().toggleClass('open');
$(this).parent().find('.child-nav').slideToggle('500');
});
// For Dropdown menu animation
var dropdownSelectors = $('.dropdown, .dropup');
// Custom function to read dropdown data
// =========================
function dropdownEffectData(target) {
// @todo - page level global?
var effectInDefault = null,
effectOutDefault = null;
var dropdown = $(target),
dropdownMenu = $('.dropdown-menu', target);
var parentUl = dropdown.parents('ul.nav');
// If parent is ul.nav allow global effect settings
if (parentUl.size() > 0) {
effectInDefault = parentUl.data('dropdown-in') || null;
effectOutDefault = parentUl.data('dropdown-out') || null;
}
return {
target: target,
dropdown: dropdown,
dropdownMenu: dropdownMenu,
effectIn: dropdownMenu.data('dropdown-in') || effectInDefault,
effectOut: dropdownMenu.data('dropdown-out') || effectOutDefault,
};
}
// Custom function to start effect (in or out)
// =========================
function dropdownEffectStart(data, effectToStart) {
if (effectToStart) {
data.dropdown.addClass('dropdown-animating');
data.dropdownMenu.addClass('animated');
data.dropdownMenu.addClass(effectToStart);
}
}
// Custom function to read when animation is over
// =========================
function dropdownEffectEnd(data, callbackFunc) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
data.dropdown.one(animationEnd, function() {
data.dropdown.removeClass('dropdown-animating');
data.dropdownMenu.removeClass('animated');
data.dropdownMenu.removeClass(data.effectIn);
data.dropdownMenu.removeClass(data.effectOut);
// Custom callback option, used to remove open class in out effect
if (typeof callbackFunc == 'function') {
callbackFunc();
}
});
}
// Bootstrap API hooks
// =========================
dropdownSelectors.on({
"show.bs.dropdown": function() {
// On show, start in effect
var dropdown = dropdownEffectData(this);
dropdownEffectStart(dropdown, dropdown.effectIn);
},
"shown.bs.dropdown": function() {
// On shown, remove in effect once complete
var dropdown = dropdownEffectData(this);
if (dropdown.effectIn && dropdown.effectOut) {
dropdownEffectEnd(dropdown, function() {});
}
},
"hide.bs.dropdown": function(e) {
// On hide, start out effect
var dropdown = dropdownEffectData(this);
if (dropdown.effectOut) {
e.preventDefault();
dropdownEffectStart(dropdown, dropdown.effectOut);
dropdownEffectEnd(dropdown, function() {
dropdown.dropdown.removeClass('open');
});
}
},
});
});