From 96278e0201f947a8aba0897a97167b672c6ec6e0 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 5 Jun 2014 17:06:21 +0200 Subject: close sidebar when switching navigation entry, except on add or change settings --- core/js/js.js | 20 ++++++++++++++++++++ core/js/tests/specHelper.js | 3 +++ 2 files changed, 23 insertions(+) (limited to 'core/js') diff --git a/core/js/js.js b/core/js/js.js index 123c4ad8e81..5c14cf34bb3 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1132,6 +1132,7 @@ function initCore() { setupMainMenu(); + // App sidebar on mobile var snapper = new Snap({ element: document.getElementById('app-content'), @@ -1146,6 +1147,25 @@ function initCore() { snapper.open('left'); } }); + // close sidebar when switching navigation entry + var $appNavigation = $('#app-navigation'); + $appNavigation.delegate('a', 'click', function(event) { + var $target = $(event.target); + // don't hide navigation when changing settings or adding things + if($target.is('.app-navigation-noclose') || + $target.closest('.app-navigation-noclose').length) { + return; + } + if($target.is('.add-new') || + $target.closest('.add-new').length) { + return; + } + if($target.is('#app-settings') || + $target.closest('#app-settings').length) { + return; + } + snapper.close(); + }); } $(document).ready(initCore); diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index fc5043c2f49..f7ec7856ba7 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -68,6 +68,9 @@ window.oc_appconfig = { }; window.oc_defaults = {}; +// mock for Snap.js plugin +window.Snap = function() {}; + // global setup for all tests (function setupTests() { var fakeServer = null, -- cgit v1.2.3