-
Notifications
You must be signed in to change notification settings - Fork 1
/
docs.js
43 lines (38 loc) · 992 Bytes
/
docs.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
$(document).ready(function() {
$("a[data-class]").click(function() {
updateNavbarClass($(this).attr("data-class"));
});
updateNavbarClass("navbar-fixed-left");
});
function updateNavbarClass(className) {
$("nav")
.removeClass(function(index, css) {
return (css.match(/(^|\s)navbar-fixed-\S+/g) || []).join(" ");
})
.addClass(className);
$("a[data-class]")
.removeClass("active")
.parent("li")
.removeClass("active");
$('a[data-class="' + className + '"]')
.addClass("active")
.parent("li")
.addClass("active");
fixBodyMargin(className);
}
function fixBodyMargin(className) {
if (/navbar-fixed-(left|right)/.test(className)) {
$("body").removeAttr("style");
if (className === "navbar-fixed-right") {
$("body").css("marginLeft", 0);
} else {
$("body").css("marginRight", 0);
}
} else {
$("body").css({
"margin-right": 0,
"margin-left": 0,
"padding-top": "70px"
});
}
}