From 7548825743bd2f7a65105b224c4eabe325c893b5 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Tue, 28 Mar 2017 15:04:56 +0200 Subject: Responsive app menu 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 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'core/js') diff --git a/core/js/js.js b/core/js/js.js index 883431b2b02..5fdafa6e412 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1482,6 +1482,53 @@ function initCore() { }); } + var resizeMenu = function() { + var maxApps = 8; + var appList = $('#appmenu li'); + var availableWidth = $('#header-left').width() - $('#nextcloud').width() - 44; + var appCount = Math.floor((availableWidth)/44); + console.log(appCount); + // show a maximum of 8 apps + if(appCount >= maxApps) { + appCount = maxApps; + } + // show at least 2 apps in the popover + if(appList.length-1-appCount >= 1) { + appCount--; + } + + $('#more-apps a').removeClass('active'); + var lastShownApp; + for (var k = 0; k < appList.length-1; k++) { + var name = $(appList[k]).data('id'); + if(k < appCount) { + $(appList[k]).removeClass('hidden'); + $('#apps li[data-id=' + name + ']').addClass('in-header'); + lastShownApp = appList[k]; + } else { + $(appList[k]).addClass('hidden'); + $('#apps li[data-id=' + name + ']').removeClass('in-header'); + // move active app to last position if it is active + if(appCount > 0 && $(appList[k]).children('a').hasClass('active')) { + $(lastShownApp).addClass('hidden'); + $('#apps li[data-id=' + $(lastShownApp).data('id') + ']').removeClass('in-header'); + $(appList[k]).removeClass('hidden'); + $('#apps li[data-id=' + name + ']').addClass('in-header'); + } + } + } + + // show/hide more apps icon + if($('#apps li:not(.in-header)').length === 0) { + $('#more-apps').hide(); + $('#navigation').hide(); + } else { + $('#more-apps').show(); + } + }; + $(window).resize(resizeMenu); + resizeMenu(); + // just add snapper for logged in users if($('#app-navigation').length && !$('html').hasClass('lte9')) { -- cgit v1.2.3 From 27b19aaba1c9a710bb2b1d3338a74ba05ea0678e Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Tue, 25 Apr 2017 17:31:04 +0200 Subject: Fix loading spinner for new app menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- core/css/header.scss | 31 ++++++++++++++++++------------- core/js/js.js | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 13 deletions(-) (limited to 'core/js') diff --git a/core/css/header.scss b/core/css/header.scss index 3805dd493e7..619852faf60 100644 --- a/core/css/header.scss +++ b/core/css/header.scss @@ -294,19 +294,21 @@ nav { max-height: 32px; max-width: 32px; } - /* loading feedback for apps */ - .app-loading { - .icon-loading-small-dark { - display: inline !important; - position: absolute; - left: 12px; - width: 16px; - height: 16px; - } - .app-icon { - -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)'; - opacity: 0; - } + +} + +/* loading feedback for apps */ +.app-loading { + .icon-loading-small-dark { + display: inline !important; + position: absolute; + left: 12px; + width: 16px; + height: 16px; + } + .app-icon { + -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)'; + opacity: 0; } } @@ -467,6 +469,9 @@ nav { opacity: .6; } } + .app-loading .icon-loading-small-dark { + top:12px; + } li:hover a, diff --git a/core/js/js.js b/core/js/js.js index 5fdafa6e412..95c00dd6448 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1398,6 +1398,7 @@ function initCore() { // toggle the navigation var $toggle = $('#header .header-appname-container'); var $navigation = $('#navigation'); + var $appmenu = $('#appmenu'); // init the menu OC.registerMenu($toggle, $navigation); @@ -1427,6 +1428,20 @@ function initCore() { OC.hideMenus(function(){return false}); } }); + + $appmenu.delegate('a', 'click', function(event) { + var $app = $(event.target); + if(!$app.is('a')) { + $app = $app.closest('a'); + } + if(event.which === 1 && !event.ctrlKey && !event.metaKey) { + $app.addClass('app-loading'); + } else { + // Close navigation when opening app in + // a new tab + OC.hideMenus(function(){return false}); + } + }); } function setupUserMenu() { -- cgit v1.2.3