└── js └── jquery.tocLight.js /js/jquery.tocLight.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery Table of Content Generator Support for Jekyll v1.0 3 | * 4 | * https://github.com/dafi/jekyll-tocmd-generator 5 | * Examples and documentation at: https://github.com/dafi/jekyll-tocmd-generator 6 | * 7 | * Requires: jQuery v1.7+ 8 | * 9 | * Copyright (c) 2013 Davide Ficano 10 | * 11 | * Dual licensed under the MIT and GPL licenses: 12 | * http://www.opensource.org/licenses/mit-license.php 13 | * http://www.gnu.org/licenses/gpl.html 14 | */ 15 | (function($) { 16 | $.toc = {}; 17 | $.toc.clickHideButton = function(settings) { 18 | var config = { 19 | saveShowStatus: false, 20 | hideText: 'hide', 21 | showText: 'show'}; 22 | 23 | if (settings) { 24 | $.extend(config, settings); 25 | } 26 | 27 | $('#toctogglelink').click(function() { 28 | var ul = $($('#toc ul')[0]); 29 | 30 | if (ul.is(':visible')) { 31 | ul.hide(); 32 | $(this).text(config.showText); 33 | if (config.saveShowStatus) { 34 | $.cookie('toc-hide', '1', { expires: 365, path: '/' }); 35 | } 36 | $('#toc').addClass('tochidden'); 37 | } else { 38 | ul.show(); 39 | $(this).text(config.hideText); 40 | if (config.saveShowStatus) { 41 | $.removeCookie('toc-hide', { path: '/' }); 42 | } 43 | $('#toc').removeClass('tochidden'); 44 | } 45 | return false; 46 | }); 47 | 48 | if (config.saveShowStatus && $.cookie('toc-hide')) { 49 | var ul = $($('#toc ul')[0]); 50 | 51 | ul.hide(); 52 | $('#toctogglelink').text(config.showText); 53 | $('#toc').addClass('tochidden'); 54 | } 55 | 56 | } 57 | })(jQuery); 58 | --------------------------------------------------------------------------------