diff options
Diffstat (limited to 'theme/javascript')
-rw-r--r-- | theme/javascript/platform.js | 4 | ||||
-rw-r--r-- | theme/javascript/sidebar.js | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/theme/javascript/platform.js b/theme/javascript/platform.js index 9721fb7..b6fb453 100644 --- a/theme/javascript/platform.js +++ b/theme/javascript/platform.js @@ -1,3 +1,5 @@ module.exports = { - isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) + isMobile: function() { + return (document.width <= 600); + } }; diff --git a/theme/javascript/sidebar.js b/theme/javascript/sidebar.js index d381822..9fc1e8e 100644 --- a/theme/javascript/sidebar.js +++ b/theme/javascript/sidebar.js @@ -25,9 +25,14 @@ function isOpen() { // Prepare sidebar: state and toggle button function init() { // Init last state if not mobile - if (!platform.isMobile) { + if (!platform.isMobile()) { toggleSidebar(storage.get('sidebar', true), false); } + + // Close sidebar after clicking a link on mobile + $(document).on('click', '.book-summary li.chapter a', function(e) { + if (platform.isMobile()) toggleSidebar(false, false); + }); } // Filter summary with a list of path |