From a0903fa853723a801bc1400fdec0f5a4957be78c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 9 Aug 2012 21:13:00 +0000 Subject: [PATCH] optimize a bit navigation in artifact detail tabs when not recalculating when content is available git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1371488 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 28 +++++++++++++------ .../src/main/webapp/js/archiva/search.js | 10 +++++-- 2 files changed, 26 insertions(+), 12 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 a6dbf99a9..e9f4be316 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 @@ -244,13 +244,25 @@ function() { goToBrowseArtifactDetail(groupId,artifactId,repositoryId);//,null,null); return; }); + + var checkArtifactDetailContent=function(groupId,artifactId,version,repositoryId,tabToActivate){ + // no need to recalculate all stuff just activate the tab + if($("#browse_artifact_detail" ).html()!=null){ + if( $.trim($("#browse_artifact_detail" ).html().length)>0){ + $("#main-content #"+tabToActivate).tab('show') + return; + } + } + generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,function(){$("#main-content #"+tabToActivate).tab('show')}); + } + this.get('#artifact/: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; - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId); + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-info-content-a"); }); this.get('#artifact~:repositoryId/:groupId/:artifactId/:version',function(context){ @@ -258,7 +270,7 @@ function() { var groupId= this.params.groupId; var artifactId= this.params.artifactId; var version= this.params.version; - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId); + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-info-content-a"); }); this.get('#artifact-dependencies/:groupId/:artifactId/:version',function(context){ @@ -267,7 +279,8 @@ function() { var groupId= this.params.groupId; var artifactId= this.params.artifactId; var version= this.params.version; - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,function(){$("#main-content #artifact-details-dependencies-content-a").tab('show')}); + + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependencies-content-a"); }); @@ -277,8 +290,7 @@ function() { var groupId= this.params.groupId; var artifactId= this.params.artifactId; var version= this.params.version; - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,function(){$("#main-content #artifact-details-dependencies-content-a").tab('show')}); - + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependencies-content-a"); }); @@ -288,8 +300,7 @@ function() { var groupId= this.params.groupId; var artifactId= this.params.artifactId; var version= this.params.version; - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,function(){$("#main-content #artifact-details-dependency-tree-content-a").tab('show')}); - + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependency-tree-content-a"); }); this.get('#artifact-dependency-tree~:repositoryId/:groupId/:artifactId/:version',function(context){ @@ -298,8 +309,7 @@ function() { var groupId= this.params.groupId; var artifactId= this.params.artifactId; var version= this.params.version; - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,function(){$("#main-content #artifact-details-dependency-tree-content-a").tab('show')}); - + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependency-tree-content-a"); }); 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 4fde6daee..f1b6b1be5 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 @@ -193,8 +193,12 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno this.repositoryId=repositoryId; displayGroupId=function(groupId){ - displayGroupDetail(groupId,null); - } + var location ="#browse"; + if (self.repositoryId){ + location+="~"+self.repositoryId; + } + location+="/"+groupId; + window.sammyArchivaApplication.setLocation(location); } displayParent=function(){ var selectedRepo=getSelectedBrowsingRepository(); @@ -302,7 +306,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno return; } - if ($(e.target).attr("href")=="#artifact-details-used-by-content") { + if ($(e.target).attr("data-target")=="#artifact-details-used-by-content") { var dependeesContentDiv=mainContent.find("#artifact-details-used-by-content" ); if( $.trim(dependeesContentDiv.html()).length<1){ dependeesContentDiv.html(mediumSpinnerImg()); -- 2.39.5