From 5b145606dacdafbdc5d2e9ee52c00a1a358d15c1 Mon Sep 17 00:00:00 2001 From: Jonathan Reinink Date: Tue, 31 Oct 2017 20:06:36 -0400 Subject: [PATCH] Move inline nav JavaScript to nav.js file --- docs/source/_assets/js/nav.js | 36 +++++++++++++------- docs/source/_layouts/documentation.blade.php | 23 +++---------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/docs/source/_assets/js/nav.js b/docs/source/_assets/js/nav.js index 05e9953bd..42c17743f 100644 --- a/docs/source/_assets/js/nav.js +++ b/docs/source/_assets/js/nav.js @@ -3,7 +3,7 @@ $.when($.ready).then(function() { // Allow opening links in new tabs if (event.metaKey) { - return + return } // Prevent following link @@ -25,8 +25,8 @@ $.when($.ready).then(function() { var nav = $(html).find('#nav').html() var content = $(html).find('#content').html() - $('#sidebar').addClass("hidden"); - $('.js-close-sidebar').addClass("hidden"); + $('#sidebar').addClass('hidden') + $('#sidebar-close').addClass('hidden') // Update the page $('title').text(title) @@ -38,21 +38,33 @@ $.when($.ready).then(function() { // Add page load to brower history window.history.pushState({ - "title": title, - "nav": $(html).find('#nav').html(), - "content": $(html).find('#content').html() + 'title': title, + 'nav': $(html).find('#nav').html(), + 'content': $(html).find('#content').html() }, '', href) }) }) // Load page history (for back/forward nav) window.onpopstate = function(e) { - if(e.state){ + if(e.state){ - // Update the page - $('title').text(e.state.title) - $('#nav').html(e.state.nav) - $('#content').html(e.state.content) - } + // Update the page + $('title').text(e.state.title) + $('#nav').html(e.state.nav) + $('#content').html(e.state.content) + } } + + // Close sidebar (mobile) + $('#sidebar-close').on('click', function () { + $('#sidebar').addClass('hidden') + $('#sidebar-close').addClass('hidden') + }) + + // Show sidebar (mobile) + $('#sidebar-open').on('click', function () { + $('#sidebar').removeClass('hidden') + $('#sidebar-close').removeClass('hidden') + }) }) diff --git a/docs/source/_layouts/documentation.blade.php b/docs/source/_layouts/documentation.blade.php index 84d9f2903..254761090 100644 --- a/docs/source/_layouts/documentation.blade.php +++ b/docs/source/_layouts/documentation.blade.php @@ -159,15 +159,15 @@
-
+ -
+ -
- -