From 57014d6ab0e5884d542ec0df42ef5f8b12c2f8bc Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 11 Jul 2012 10:32:34 +0000 Subject: [PATCH] start using sammy for navigation while browsing tru the ui git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360109 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 49 ++++++++++--------- .../src/main/webapp/js/archiva/search.js | 7 +++ 2 files changed, 33 insertions(+), 23 deletions(-) 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 639edc1e2..d4edb8141 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 @@ -64,29 +64,8 @@ function() { resetPasswordForm(resetPassword); return; } - - var artifact= $.urlParam("artifact"); - var repositoryId = $.urlParam("repositoryId"); - // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin - // or groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1 - // repository in param repositoryId - if (artifact){ - if ( artifact.indexOf(':')>=0){ - var splitted = artifact.split(':'); - $.log("splitted.length:"+splitted.length); - if(splitted.length==2){ - displayBrowseArtifactDetail(splitted[0],splitted[1],null,null); - return; - } else if (splitted.length==3) { - generalDisplayArtifactDetailsVersionView(splitted[0],splitted[1],splitted[2],repositoryId); - return; - } else { - displayWarningMessage( $.i18n.prop("shortcut.artifact.illegal")); - } - } - } // by default display search screen - displaySearch(); + window.sammyArchivaApplication.setLocation("#search"); } hasKarma=function(karmaName){ @@ -256,6 +235,30 @@ function() { this.activeMenuId = ko.observable(); window.sammyArchivaApplication = Sammy(function () { + // #artifact-(optionnal repositoryId) + // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin + // or groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1 + this.get('#artifact/:groupId/:artifactId',function(context){ + var groupId= this.params['groupId']; + var artifactId= this.params['artifactId']; + $.log("get #artifact:"+groupId+":"+artifactId); + goToBrowseArtifactDetail(groupId,artifactId);//,null,null); + return; + + }); + this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){ + + var repositoryId = this.params['repositoryId']; + var groupId= this.params['groupId']; + var artifactId= this.params['artifactId']; + var version= this.params['version']; + + if(!version){ + displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null); + } else { + generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId); + } + }); this.get('#browse/:groupId',function(context){ var groupId = this.params['groupId']; if (groupId){ @@ -274,7 +277,7 @@ function() { }); }); - this.get('', function () { this.app.runRoute('get', '#Search') }); + this.get('', function () { this.app.runRoute('get', '#search') }); } ); sammyArchivaApplication.run(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index 98299440a..54d4ad6a4 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -59,6 +59,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno $.log("displayProjectEntry:"+id+",groupId:"+self.groupId+",values:"+values); displayArtifactDetail(self.groupId,values,self); + //window.sammyArchivaApplication.setLocation("#artifact/"+self.groupId+"/"+values); } @@ -829,6 +830,12 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } displayBrowseArtifactDetail=function(groupId, artifactId){ + window.sammyArchivaApplication.setLocation("#artifact/"+groupId+"/"+artifactId); + //displayArtifactDetail(groupId,artifactId,null,null); + } + + goToBrowseArtifactDetail=function(groupId, artifactId){ + $.log("displayBrowseArtifactDetail"); displayBrowseGroupId(groupId); displayArtifactDetail(groupId,artifactId,null,null); } -- 2.39.5