From 10134a32c0a210ff517e05ca97960e638304044f Mon Sep 17 00:00:00 2001 From: Oswaldo Acauan Date: Sun, 17 Nov 2013 22:14:04 -0200 Subject: [PATCH] feat(drawer): Close after clicking on pjax link #8 --- src/assets/js/drawer.js | 6 +++++- src/assets/js/scripts.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/assets/js/drawer.js b/src/assets/js/drawer.js index 4c46ba4e..ea8fc84c 100644 --- a/src/assets/js/drawer.js +++ b/src/assets/js/drawer.js @@ -21,6 +21,9 @@ var Drawer = (function ($, Mzr) { close: function() { _body.removeClass('drawer-open'); }, + isOpen: function() { + return _body.hasClass('drawer-open'); + }, bindOverlay: function() { _overlay.on('click', function(e) { e.preventDefault(); @@ -46,7 +49,8 @@ var Drawer = (function ($, Mzr) { return { init: module.init, open: module.open, - close: module.close + close: module.close, + isOpen: module.isOpen }; }(jQuery, Modernizr)); diff --git a/src/assets/js/scripts.js b/src/assets/js/scripts.js index 5279bcb2..69798e20 100644 --- a/src/assets/js/scripts.js +++ b/src/assets/js/scripts.js @@ -35,7 +35,11 @@ // PJax bindings // ================= if ($.support.pjax) { - $document.on('pjax:start', function() { NProgress.start(); }); + $document.on('pjax:start', function() { + NProgress.start(); + if(Drawer.isOpen()) + Drawer.close(); + }); $document.on('pjax:end', function() { if(ga !== undefined) { ga('set', 'location', window.location.href);