From da57fbc93a6df7f477bf680f1a97c1b43075f3b5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 26 Oct 2012 20:12:14 +0200 Subject: [PATCH] show/hide navigation entries after enabling/disabling app --- core/ajax/navigationdetect.php | 22 ++++++++++++++++++++++ settings/js/apps.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 core/ajax/navigationdetect.php diff --git a/core/ajax/navigationdetect.php b/core/ajax/navigationdetect.php new file mode 100644 index 0000000000..c7d0bd38db --- /dev/null +++ b/core/ajax/navigationdetect.php @@ -0,0 +1,22 @@ + array_values($navIds), 'nav_entries' => $navigation)); diff --git a/settings/js/apps.js b/settings/js/apps.js index 8de95100c4..e45abf9b3d 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -51,6 +51,7 @@ OC.Settings.Apps = OC.Settings.Apps || { } else { element.data('active',false); + OC.Settings.Apps.removeNavigation(appid); element.val(t('settings','Enable')); } },'json'); @@ -61,6 +62,7 @@ OC.Settings.Apps = OC.Settings.Apps || { OC.dialogs.alert('Error while enabling app','Error'); } else { + OC.Settings.Apps.addNavigation(appid); element.data('active',true); element.val(t('settings','Disable')); } @@ -87,6 +89,38 @@ OC.Settings.Apps = OC.Settings.Apps || { applist.last().after(app); } return app; + }, + removeNavigation: function(appid){ + $.getJSON(OC.filePath('core','ajax','navigationdetect.php'), {app: appid}).done(function(response){ + if(response.status === 'success'){ + var navIds=response.nav_ids; + for(var i=0; i< navIds.length; i++){ + $('#apps').children('li[data-id="'+navIds[i]+'"]').remove(); + } + } + }); + }, + addNavigation: function(appid){ + $.getJSON(OC.filePath('core','ajax','navigationdetect.php'), {app: appid}).done(function(response){ + if(response.status === 'success'){ + var navEntries=response.nav_entries; + for(var i=0; i< navEntries.length; i++){ + var entry = navEntries[i]; + var container = $('#apps'); + + if(container.children('li[data-id="'+entry.id+'"]').length === 0){ + var li=$('
  • '); + li.attr('data-id', entry.id); + var a=$(''); + a.attr('style', 'background-image: url('+entry.icon+')'); + a.text(entry.name); + a.attr('href', entry.href); + li.append(a); + container.append(li); + } + } + } + }); } };