forked from project-sunbird/project-sunbird.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.tocLight.js
57 lines (51 loc) · 1.65 KB
/
jquery.tocLight.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
/*
* jQuery Table of Content Generator Support for Jekyll v1.0
*
* https://github.com/dafi/jekyll-tocmd-generator
* Examples and documentation at: https://github.com/dafi/jekyll-tocmd-generator
*
* Requires: jQuery v1.7+
*
* Copyright (c) 2013 Davide Ficano
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
$.toc = {};
$.toc.clickHideButton = function(settings) {
var config = {
saveShowStatus: false,
hideText: 'hide',
showText: 'show'};
if (settings) {
$.extend(config, settings);
}
$('#toctogglelink').click(function() {
var ul = $($('#toc ul')[0]);
if (ul.is(':visible')) {
ul.hide();
$(this).text(config.showText);
if (config.saveShowStatus) {
$.cookie('toc-hide', '1', { expires: 365, path: '/' });
}
$('#toc').addClass('tochidden');
} else {
ul.show();
$(this).text(config.hideText);
if (config.saveShowStatus) {
$.removeCookie('toc-hide', { path: '/' });
}
$('#toc').removeClass('tochidden');
}
return false;
});
if (config.saveShowStatus && $.cookie('toc-hide')) {
var ul = $($('#toc ul')[0]);
ul.hide();
$('#toctogglelink').text(config.showText);
$('#toc').addClass('tochidden');
}
}
})(jQuery);