summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <hey@jancborchardt.net>2014-06-05 17:06:21 +0200
committerJan-Christoph Borchardt <hey@jancborchardt.net>2014-06-05 17:06:21 +0200
commit96278e0201f947a8aba0897a97167b672c6ec6e0 (patch)
treeb1a7be54da307651f9d0e0959f543fa3c0bba498 /core/js
parent86a9cb2a6b167a216f5bd39350ea5cf4fd2305f6 (diff)
downloadnextcloud-server-96278e0201f947a8aba0897a97167b672c6ec6e0.tar.gz
nextcloud-server-96278e0201f947a8aba0897a97167b672c6ec6e0.zip
close sidebar when switching navigation entry, except on add or change settings
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js20
-rw-r--r--core/js/tests/specHelper.js3
2 files changed, 23 insertions, 0 deletions
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,