diff options
Diffstat (limited to 'theme/javascript/core/sidebar.js')
-rw-r--r-- | theme/javascript/core/sidebar.js | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/theme/javascript/core/sidebar.js b/theme/javascript/core/sidebar.js index c36f4fe..d318676 100644 --- a/theme/javascript/core/sidebar.js +++ b/theme/javascript/core/sidebar.js @@ -1,32 +1,31 @@ define([ + "lodash", "utils/storage", "utils/platform", "core/state" -], function(storage, platform, state) { +], function(_, storage, platform, state) { + var $summary = state.$book.find(".book-summary"); // Toggle sidebar with or withour animation var toggleSidebar = function(_state, animation) { - if (-state != null && isOpen() == _state) return; + if (state != null && isOpen() == _state) return; if (animation == null) animation = true; - var $book = state().$book; - $book.toggleClass("without-animation", !animation); - $book.toggleClass("with-summary", _state); + state.$book.toggleClass("without-animation", !animation); + state.$book.toggleClass("with-summary", _state); storage.set("sidebar", isOpen()); }; // Return true if sidebar is open var isOpen = function() { - return state().$book.hasClass("with-summary"); + return state.$book.hasClass("with-summary"); }; // Prepare sidebar: state and toggle button var init = function() { - var $book = state().$book; - // Toggle summary - $book.find(".book-header .toggle-summary").click(function(e) { + state.$book.find(".book-header .toggle-summary").click(function(e) { e.preventDefault(); toggleSidebar(); }); @@ -37,8 +36,21 @@ define([ } }; + // Filter summary with a list of path + var filterSummary = function(paths) { + $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(); + }); + }; + return { + $el: $summary, init: init, - toggle: toggleSidebar + toggle: toggleSidebar, + filter: filterSummary } });
\ No newline at end of file |