Fix #1023: close sidebar after clicking a link on mobile

This commit is contained in:
Samy Pessé
2015-11-25 10:25:58 +01:00
parent 5a8c4d5a4e
commit 9bc89c24f5
3 changed files with 1772 additions and 1758 deletions
+3 -1
View File
@@ -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);
}
};
+6 -1
View File
@@ -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