diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-03-16 13:03:41 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-16 13:03:41 -0600 |
commit | cd4ebe2777b268f916a5edbbbc49f65504a1e12b (patch) | |
tree | e3d5f10ec1e071bd1de2b4a85aa4ee3ae4503fb6 /settings | |
parent | 2a9d1a7147b5494d2c8dda15a9ab4f74527b4a97 (diff) | |
parent | b8ef61645522322486a055df40d3d773964de720 (diff) | |
download | nextcloud-server-cd4ebe2777b268f916a5edbbbc49f65504a1e12b.tar.gz nextcloud-server-cd4ebe2777b268f916a5edbbbc49f65504a1e12b.zip |
Merge pull request #3008 from nextcloud/appmenu-experiment
Show apps in header
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/apps.js | 105 |
1 files changed, 75 insertions, 30 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js index b73b4a35b3f..8be18c4e9c0 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -451,22 +451,39 @@ OC.Settings.Apps = OC.Settings.Apps || { rebuildNavigation: function() { $.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php')).done(function(response){ - if(response.status === 'success'){ - var idsToKeep = {}; - var navEntries=response.nav_entries; + if(response.status === 'success') { + var addedApps = {}; + var navEntries = response.nav_entries; var container = $('#apps ul'); - for(var i=0; i< navEntries.length; i++){ + + // remove disabled apps + for (var i = 0; i < navEntries.length; i++) { var entry = navEntries[i]; - idsToKeep[entry.id] = true; + if(container.children('li[data-id="' + entry.id + '"]').length === 0) { + addedApps[entry.id] = true; + } + } + container.children('li[data-id]').each(function (index, el) { + var id = $(el).data('id'); + // remove all apps that are not in the correct order + if ((navEntries[index] && navEntries[index].id !== $(el).data('id'))) { + $(el).remove(); + $('#appmenu li[data-id='+id+']').remove(); + } + }); - if(container.children('li[data-id="'+entry.id+'"]').length === 0){ - var li=$('<li></li>'); + var previousEntry; + // add enabled apps to #navigation and #appmenu + for (var i = 0; i < navEntries.length; i++) { + var entry = navEntries[i]; + if (container.children('li[data-id="' + entry.id + '"]').length === 0) { + var li = $('<li></li>'); li.attr('data-id', entry.id); var img = '<svg width="32" height="32" viewBox="0 0 32 32">'; img += '<defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" /></filter></defs>'; img += '<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="' + entry.icon + '" class="app-icon" /></svg>'; - var a=$('<a></a>').attr('href', entry.href); - var filename=$('<span></span>'); + var a = $('<a></a>').attr('href', entry.href); + var filename = $('<span></span>'); var loading = $('<div class="icon-loading-dark"></div>').css('display', 'none'); filename.text(entry.name); a.prepend(filename); @@ -474,33 +491,61 @@ OC.Settings.Apps = OC.Settings.Apps || { a.prepend(img); li.append(a); - // append the new app as last item in the list - // which is the "add apps" entry with the id - // #apps-management - $('#apps-management').before(li); - - // scroll the app navigation down - // so the newly added app is seen - $('#navigation').animate({ - scrollTop: $('#navigation').height() - }, 'slow'); + $('#navigation li[data-id=' + previousEntry.id + ']').after(li); // draw attention to the newly added app entry // by flashing it twice - $('#header .menutoggle') - .animate({opacity: 0.5}) - .animate({opacity: 1}) - .animate({opacity: 0.5}) - .animate({opacity: 1}) - .animate({opacity: 0.75}); + if(addedApps[entry.id]) { + $('#header .menutoggle') + .animate({opacity: 0.5}) + .animate({opacity: 1}) + .animate({opacity: 0.5}) + .animate({opacity: 1}) + .animate({opacity: 0.75}); + } } - } - container.children('li[data-id]').each(function(index, el) { - if (!idsToKeep[$(el).data('id')]) { - $(el).remove(); + if ($('#appmenu ul').children('li[data-id="' + entry.id + '"]').length === 0) { + // add apps to #appmenu until it is full + if ($('#appmenu li').not('.hidden').length < 8) { + var li = $('<li></li>'); + li.attr('data-id', entry.id); + var img = '<img src="' + entry.icon + '" class="app-icon">'; + var a = $('<a></a>').attr('href', entry.href); + var filename = $('<span></span>'); + var loading = $('<div class="icon-loading-dark"></div>').css('display', 'none'); + filename.text(entry.name); + a.prepend(filename); + a.prepend(loading); + a.prepend(img); + li.append(a); + $('#appmenu li[data-id='+ previousEntry.id+']').after(li); + if(addedApps[entry.id]) { + li.animate({opacity: 0.5}) + .animate({opacity: 1}) + .animate({opacity: 0.5}) + .animate({opacity: 1}); + } + } } - }); + previousEntry = entry; + // do not show apps from #appmenu in #navigation + if(i < 7) { + $('#navigation li').eq(i).addClass('in-header'); + } else { + $('#navigation li').eq(i).removeClass('in-header'); + } + } + + + + if (navEntries.length > 7) { + $('#more-apps').show(); + $('#apps-management').hide(); + } else { + $('#more-apps').hide(); + $('#apps-management').show(); + } } }); }, |