diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-10-06 09:42:49 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-10-06 09:42:49 +0200 |
commit | ce1e0e187339976fc3cae7ef70bcfdd0eaf68981 (patch) | |
tree | c71ab2b8badd7a54759790bde083cab721796d92 /theme/javascript/core/sidebar.js | |
parent | bcb224d1cb0add4285538f03956f6f6a1574e49a (diff) | |
parent | c2775b3b63e92a7047f019a9d56851ce4fdd6c02 (diff) | |
download | gitbook-ce1e0e187339976fc3cae7ef70bcfdd0eaf68981.zip gitbook-ce1e0e187339976fc3cae7ef70bcfdd0eaf68981.tar.gz gitbook-ce1e0e187339976fc3cae7ef70bcfdd0eaf68981.tar.bz2 |
Merge pull request #964 from GitbookIO/features/plugin_api
Better APIs for Plugins
Diffstat (limited to 'theme/javascript/core/sidebar.js')
-rwxr-xr-x | theme/javascript/core/sidebar.js | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/theme/javascript/core/sidebar.js b/theme/javascript/core/sidebar.js deleted file mode 100755 index 828dc73..0000000 --- a/theme/javascript/core/sidebar.js +++ /dev/null @@ -1,56 +0,0 @@ -define([ - "jQuery", - "lodash", - "utils/storage", - "utils/platform", - "core/state" -], function($, _, storage, platform, state) { - // Toggle sidebar with or withour animation - var toggleSidebar = function(_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); - - storage.set("sidebar", isOpen()); - }; - - // Return true if sidebar is open - var isOpen = function() { - 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(); - }); - - // Init last state if not mobile - if (!platform.isMobile) { - toggleSidebar(storage.get("sidebar", true), false); - } - }; - - // Filter summary with a list of path - var filterSummary = function(paths) { - var $summary = $(".book-summary"); - - $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 { - init: init, - toggle: toggleSidebar, - filter: filterSummary - } -});
\ No newline at end of file |