]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix app menu calculation for random size of the right header 12440/head
authorJulius Härtl <jus@bitgrid.net>
Mon, 27 Aug 2018 16:03:42 +0000 (18:03 +0200)
committerJulius Härtl <jus@bitgrid.net>
Tue, 13 Nov 2018 14:52:15 +0000 (15:52 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
core/js/js.js
core/js/tests/specs/coreSpec.js

index 71c26dac01ac42953139955f69b78c483a9e9847..8d79311002e34041ce062dc1731e36bf603ddc3c 100644 (file)
@@ -1573,13 +1573,14 @@ function initCore() {
 
        var resizeMenu = function() {
                var appList = $('#appmenu li');
-               var headerWidth = $('.header-left').outerWidth() - $('#nextcloud').outerWidth();
+               var rightHeaderWidth = $('.header-right').outerWidth();
+               var headerWidth = $('header').outerWidth();
                var usePercentualAppMenuLimit = 0.33;
                var minAppsDesktop = 8;
-               var availableWidth = headerWidth - $(appList).width();
+               var availableWidth =  headerWidth - $('#nextcloud').outerWidth() - (rightHeaderWidth > 210 ? rightHeaderWidth : 210)
                var isMobile = $(window).width() < 768;
                if (!isMobile) {
-                       availableWidth = headerWidth * usePercentualAppMenuLimit;
+                       availableWidth = availableWidth * usePercentualAppMenuLimit;
                }
                var appCount = Math.floor((availableWidth / $(appList).width()));
                if (isMobile && appCount > minAppsDesktop) {
@@ -1624,7 +1625,7 @@ function initCore() {
                }
        };
        $(window).resize(resizeMenu);
-       resizeMenu();
+       setTimeout(resizeMenu, 0);
 
        // just add snapper for logged in users
        if($('#app-navigation').length && !$('html').hasClass('lte9')) {
index 6766fc2789cb280924d3d8c06002b4ffd6be602b..575b4c34ba31dceeefeeb39dfc1ea7552d2dc11d 100644 (file)
@@ -550,6 +550,10 @@ describe('Core base tests', function() {
                });
                it('Clicking menu toggle toggles navigation in', function() {
                        window.initCore();
+                       // fore show more apps icon since otherwise it would be hidden since no icons are available
+                       clock.tick(1 * 1000);
+                       $('#more-apps').show();
+                       
                        expect($navigation.is(':visible')).toEqual(false);
                        $toggle.click();
                        clock.tick(1 * 1000);