-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy paththeme.js
26 lines (24 loc) · 932 Bytes
/
theme.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
/**
* Add the sidebar toggle capability when the sidebar exists on the page.
* Requires jQuery cookie support to persist sidebar state.
*/
$.getScript('//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js').done(function() {
var toggleSidebar = function() {
if ($('#main').hasClass('nosidebar')) {
$.removeCookie('hidesidebar', { path: '/' });
$('#main').removeClass('nosidebar');
$('#sidebar-toggle').html('»');
} else {
$.cookie('hidesidebar', '1', { path: '/' });
$('#main').addClass('nosidebar');
$('#sidebar-toggle').html('«');
}
};
if ($('#main').hasClass('nosidebar') === false) {
$('#main').append('<button id="sidebar-toggle" class="button">»</button>');
$('#sidebar-toggle').click(toggleSidebar);
if ($.cookie('hidesidebar') === '1') {
toggleSidebar();
}
}
});