diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-10-05 16:02:03 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-10-05 16:02:03 +0200 |
commit | 0679807517f2b53954b24434bbf7a847fe833c01 (patch) | |
tree | f325eccd4f08fef97798bef0fde4627cd5476291 /theme/javascript/core | |
parent | 7f0e4803e266e11ef3aedc041c63b99cd2cce7e2 (diff) | |
download | gitbook-0679807517f2b53954b24434bbf7a847fe833c01.zip gitbook-0679807517f2b53954b24434bbf7a847fe833c01.tar.gz gitbook-0679807517f2b53954b24434bbf7a847fe833c01.tar.bz2 |
Define specific action for toggling summary
Diffstat (limited to 'theme/javascript/core')
-rwxr-xr-x | theme/javascript/core/navigation.js | 1 | ||||
-rwxr-xr-x | theme/javascript/core/sidebar.js | 53 |
2 files changed, 24 insertions, 30 deletions
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js index 060eb7a..2e3f9eb 100755 --- a/theme/javascript/core/navigation.js +++ b/theme/javascript/core/navigation.js @@ -65,7 +65,6 @@ define([ // Update state state.update($("html")); - // recover search keyword preparePage(); }) .fail(function (e) { diff --git a/theme/javascript/core/sidebar.js b/theme/javascript/core/sidebar.js index 828dc73..2d9417e 100755 --- a/theme/javascript/core/sidebar.js +++ b/theme/javascript/core/sidebar.js @@ -1,56 +1,51 @@ define([ - "jQuery", - "lodash", - "utils/storage", - "utils/platform", - "core/state" + 'jQuery', + 'lodash', + 'utils/storage', + 'utils/platform', + 'core/state' ], function($, _, storage, platform, state) { // Toggle sidebar with or withour animation - var toggleSidebar = function(_state, animation) { + function toggleSidebar(_state, animation) { if (state != null && isOpen() == _state) return; if (animation == null) animation = true; - state.$book.toggleClass("without-animation", !animation); - state.$book.toggleClass("with-summary", _state); + state.$book.toggleClass('without-animation', !animation); + state.$book.toggleClass('with-summary', _state); - storage.set("sidebar", isOpen()); - }; + storage.set('sidebar', isOpen()); + } // Return true if sidebar is open - var isOpen = function() { - return state.$book.hasClass("with-summary"); - }; + function isOpen() { + return state.$book.hasClass('with-summary'); + } // Prepare sidebar: state and toggle button - var init = function() { - // Toggle summary - $(document).on("click", ".book-header .toggle-summary", function(e) { - e.preventDefault(); - toggleSidebar(); - }); - + function init() { // Init last state if not mobile if (!platform.isMobile) { - toggleSidebar(storage.get("sidebar", true), false); + toggleSidebar(storage.get('sidebar', true), false); } - }; + } // Filter summary with a list of path - var filterSummary = function(paths) { - var $summary = $(".book-summary"); + function filterSummary(paths) { + var $summary = $('.book-summary'); - $summary.find("li").each(function() { - var path = $(this).data("path"); + $summary.find('li').each(function() { + var path = $(this).data('path'); var st = paths == null || _.contains(paths, path); $(this).toggle(st); - if (st) $(this).parents("li").show(); + if (st) $(this).parents('li').show(); }); - }; + } return { init: init, + isOpen: isOpen, toggle: toggleSidebar, filter: filterSummary - } + }; });
\ No newline at end of file |