From 90bc0471f9de780e3adec9886d12246ec6732459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 2 Nov 2018 14:41:31 +0100 Subject: [PATCH] Cleanup app menu registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- core/js/js.js | 35 ++++++--------------------------- core/js/tests/specs/coreSpec.js | 21 +++++++++++++------- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index 026cc6bb0d689..e403311952bf1 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1447,23 +1447,18 @@ function initCore() { */ function setupMainMenu() { - // init the more-apps menu - OC.registerMenu($('#more-apps > a'), $('#navigation')); - // toggle the navigation - var $toggle = $('#header .header-appname-container'); + var $toggle = $('#more-apps > a'); var $navigation = $('#navigation'); var $appmenu = $('#appmenu'); - // init the menu + // init the more-apps menu OC.registerMenu($toggle, $navigation); - $toggle.data('oldhref', $toggle.attr('href')); - $toggle.attr('href', '#'); - $navigation.hide(); // show loading feedback $navigation.delegate('a', 'click', function(event) { var $app = $(event.target); + if(!$app.is('a')) { $app = $app.closest('a'); } @@ -1486,6 +1481,9 @@ function initCore() { $appmenu.delegate('a', 'click', function(event) { var $app = $(event.target); + if ($app.parent().hasClass('menutoggle')) { + return; + } if(!$app.is('a')) { $app = $app.closest('a'); } @@ -1539,27 +1537,6 @@ function initCore() { setupUserMenu(); setupContactsMenu(); - // move triangle of apps dropdown to align with app name triangle - // 2 is the additional offset between the triangles - if($('#navigation').length) { - $('#header #nextcloud + .menutoggle').on('click', function(){ - $('#menu-css-helper').remove(); - var caretPosition = $('.header-appname + .icon-caret').offset().left - 2; - if(caretPosition > 255) { - // if the app name is longer than the menu, just put the triangle in the middle - return; - } else { - $('head').append(''); - } - }); - $('#header #appmenu .menutoggle').on('click', function() { - $('#appmenu').toggleClass('menu-open'); - if($('#appmenu').is(':visible')) { - $('#menu-css-helper').remove(); - } - }); - } - var resizeMenu = function() { var appList = $('#appmenu li'); var rightHeaderWidth = $('.header-right').outerWidth(); diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 67b7d77be6c0c..7097771ed2cdf 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -552,14 +552,17 @@ describe('Core base tests', function() { beforeEach(function() { jQuery.fx.off = true; clock = sinon.useFakeTimers(); - $('#testArea').append('