From 94489731e3566cd6ad936c410eaa4f1276783d03 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 10 Jul 2012 10:39:29 +0000 Subject: [PATCH] [MRM-1639] History navigation Submitted by Eric Barboni. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1359579 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/index.html | 10 +- .../src/main/webapp/js/archiva/main.js | 123 +- .../src/main/webapp/js/archiva/startup.js | 2 +- .../src/main/webapp/js/sammy.0.7.1.js | 2003 +++++++++++++++++ .../webapp/js/templates/archiva/menu.html | 90 +- 5 files changed, 2127 insertions(+), 101 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/sammy.0.7.1.js diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index b2f48e77b..b3ee4d0a8 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -32,6 +32,7 @@ + @@ -102,6 +103,10 @@ require.config({ baseUrl: "js/", urlArgs: ""+appendJsNoCacheUrl(), + shim: { + 'sammy':['jquery'], + 'archiva.main':["jquery","sammy"] + }, paths: { "i18n":"jquery.i18n.properties-1.0.9", "jquery": "jquery-1.7.2", @@ -124,6 +129,7 @@ "jquery.fileupload.ui":"jquery.fileupload-ui-6.6.3", "tmpl": "tmpl.min", "prettify": "prettify", + "sammy": "sammy.0.7.1", "jqueryFileTree": "jqueryFileTree-1.0.1", "redback": "redback/redback", "redback.roles": "redback/roles", @@ -145,7 +151,7 @@ - require(['domReady!','jquery','i18n','startup'], function (domReady) { + require(['jquery','i18n','sammy','startup','domReady!'], function (domReady) { loadi18n(function () { $.ajax({ url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(), @@ -155,7 +161,7 @@ window.archivaJavascriptLog=data.javascriptLog; window.archivaRuntimeInfo=data; - require(['domReady!','archiva.main'],function (domReady) { + require(['sammy','archiva.main','domReady!'],function (domReady) { $.log("startArchivaApplication"); startArchivaApplication(); $("#loadingDiv").hide(); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 1c0cdd5e1..0882addbb 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -define("archiva.main",["jquery","jquery.ui","jquery.cookie","bootstrap","archiva.search", +define("archiva.main",["jquery","sammy","jquery.ui","jquery.cookie","bootstrap","archiva.search", "jquery.validate","jquery.json","knockout","redback.templates","archiva.templates", "redback.roles","redback","archiva.general-admin","archiva.repositories", "archiva.network-proxies","archiva.proxy-connectors","archiva.repository-groups","archiva.artifacts-management"], @@ -256,58 +256,105 @@ function() { }); } - //------------------------------------// - // Change UI with appearance settings // - //------------------------------------// - updateAppearanceToolBar=function() { - $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", { - type: "GET", - dataType: 'json', - success: function(data) { - if(data.url){ - var url = data.url.startsWith("http://") || data.url.startsWith("https://") ? data.url : "http://"+data.url; - var link=""; - if (data.logoLocation) { - link+=""; - } else if (data.name) { - link+=data.name; - } else { - link+="Archiva"; - } - link+=""; - $("#organisation-logo").html(link); + //------------------------------------// + // Change UI with appearance settings // + //------------------------------------// + updateAppearanceToolBar=function() { + $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", { + type: "GET", + dataType: 'json', + success: function(data) { + if(data.url){ + var url = data.url.startsWith("http://") || data.url.startsWith("https://") ? data.url : "http://"+data.url; + var link=""; + if (data.logoLocation) { + link+=""; + } else if (data.name) { + link+=data.name; + } else { + link+="Archiva"; } - if (!data.url && data.name){ - $("#organisation-logo").html(""+data.name+""); + link+=""; + $("#organisation-logo").html(link); } - if (!data.url && !data.name){ - $("#organisation-logo").html("Archiva"); - } - }, - error: function() { - $("#organisation-logo").html("Archiva"); + if (!data.url && data.name){ + $("#organisation-logo").html(""+data.name+""); } - }); - } + if (!data.url && !data.name){ + $("#organisation-logo").html("Archiva"); + } + }, + error: function() { + $("#organisation-logo").html("Archiva"); + } + }); + } + MainMenuViewModel=function() { + + var self = this; + this.artifactMenuItems = [ + { text : $.i18n.prop('menu.artifacts') , id: null}, + { text : $.i18n.prop('menu.artifacts.search') , id: "menu-find-search-a", href: "#Search" , func: function(){displaySearch(this)}}, + { text : $.i18n.prop('menu.artifacts.browse') , id: "menu-find-browse-a", href: "#Browse" , func: function(){displayBrowse(true)}}, + { text : $.i18n.prop('menu.artifacts.upload') , id: "menu-find-upload-a", href: "#Upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}} + ]; + this.administrationMenuItems = [ + { text : $.i18n.prop('menu.administration') , id: null}, + { text : $.i18n.prop('menu.repository.groups') , id: "mmenu-repository-groups-list-a" , href: "#RepositoryGroup" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryGroups()}}, + { text : $.i18n.prop('menu.repositories') , id: "menu-repositories-list-a" , href: "#RepositoryList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoriesGrid()}}, + { text : $.i18n.prop('menu.proxy-connectors') , id: "menu-proxy-connectors-list-a" , href: "#ProxyConnectors" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayProxyConnectors()}}, + { text : $.i18n.prop('menu.network-proxies') , id: "menu-network-proxies-list-a" , href: "#NetProxies" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkProxies()}}, + { text : $.i18n.prop('menu.legacy-artifact-support') , id: "menu-legacy-support-list-a" , href: "#Legacy" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayLegacyArtifactPathSupport()}}, + { text : $.i18n.prop('menu.repository-scanning') , id: "menu-repository-scanning-list-a" , href: "#ScanningList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryScanning()}}, + { text : $.i18n.prop('menu.network-configuration') , id: "menu-network-configuration-list-a" , href: "#Network" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkConfiguration()}}, + { text : $.i18n.prop('menu.system-status') , id: "menu-system-status-list-a" , href: "#Status" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displaySystemStatus()}}, + { text : $.i18n.prop('menu.appearance-configuration') , id: "menu-appearance-list-a" , href: "#Appearance" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayAppearanceConfiguration()}}, + { text : $.i18n.prop('menu.ui-configuration') , id: "menu-ui-configuration-list-a" , href: "#UIConfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayUiConfiguration()}} + ] + + this.usersMenuItems = [ + { text : $.i18n.prop('menu.users') , id: null}, + { text : $.i18n.prop('menu.users.manage') , id: "menu-users-list-a", href: "#Users" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayUsersGrid()}}, + { text : $.i18n.prop('menu.users.roles') , id: "menu-roles-list-a", href: "#Roles" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayRolesGrid()}} + ] + this.activeMenuId = ko.observable(); + + Sammy(function () { + this.get('#:folder', function () { + self.activeMenuId(this.params.folder); + ko.utils.arrayFirst(self.artifactMenuItems.concat(self.usersMenuItems, self.administrationMenuItems), function(p) { + if ( p.href == "#"+self.activeMenuId()) { + p.func(); + } + }); + + }); + this.get('', function () { this.app.runRoute('get', '#Search') }); + } ).run(); + + } + startArchivaApplication=function(){ $.log("startArchivaApplication"); $('#topbar-menu-container').html($("#topbar_menu_tmpl" ).tmpl()); $('#sidebar-content').html($("#main_menu_tmpl").tmpl()); + ko.bindingHandlers.redbackP = { + init: function(element, valueAccessor) { + $(element).attr("redback-permissions",valueAccessor); + } + }; + ko.applyBindings(new MainMenuViewModel()); + hideElementWithKarma(); checkSecurityLinks(); checkCreateAdminLink(); $('#footer-content').html($('#footer-tmpl').tmpl(window.archivaRuntimeInfo)); - // create handlers on menu entries to add class active on click - var alinkNodes=$("#sidebar-content #main-menu").find("li a"); - alinkNodes.on("click",function(){ - alinkNodes.parent("li").removeClass("active"); - $(this).parent("li").addClass("active"); - }) - + + $( "#quick-search-autocomplete" ).autocomplete({ minLength: 3, delay: 600, diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js index 46c8ee412..57a08c023 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/startup.js @@ -17,7 +17,7 @@ * under the License. */ -define("startup",["jquery","utils"], +define("startup",["jquery","sammy","utils"], function() { // define a container object with various datas diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/sammy.0.7.1.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/sammy.0.7.1.js new file mode 100644 index 000000000..c756e225e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/sammy.0.7.1.js @@ -0,0 +1,2003 @@ +// name: sammy +// version: 0.7.1 + +// Sammy.js / http://sammyjs.org + +(function($, window) { + (function(factory){ + // Support module loading scenarios + if (typeof define === 'function' && define.amd){ + // AMD Anonymous Module + define(['jquery'], factory); + } else { + // No module loader (plain