fix jquery issues reported by idea

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1376878 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-08-24 09:59:56 +00:00
parent 8ffeff592c
commit d3926adc7d
2 changed files with 57 additions and 57 deletions

View File

@ -19,22 +19,22 @@
appendArchivaVersion=function(){
return "_archivaVersion="+window.archivaRuntimeInfo.version;
}
};
timestampNoCache=function(){
if (window.archivaRuntimeInfo.version.match("SNAPSHOT$")){
return "&archivaTimestamp="+window.archivaRuntimeInfo.timestamp+(window.archivaRuntimeInfo.devMode?"&_="+jQuery.now():"");
}
return "";
}
};
appendTemplateUrl=function(){
return appendArchivaVersion()+timestampNoCache();
}
};
appendJsNoCacheUrl=function(){
return appendArchivaVersion()+timestampNoCache();
}
};
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/en",
@ -117,4 +117,4 @@ $.ajax({
});
})
}
})
});

View File

@ -28,15 +28,15 @@ function(jquery,ui,sammy,tmpl) {
*/
reccordLoginCookie=function(user) {
$.cookie('redback_login', ko.toJSON(user));
}
};
getUserFromLoginCookie=function(){
return $.parseJSON($.cookie('redback_login'));
}
};
deleteLoginCookie=function(){
$.cookie('redback_login', null);
}
};
logout=function(doScreenChange){
deleteLoginCookie();
@ -50,7 +50,7 @@ function(jquery,ui,sammy,tmpl) {
$.ajax({
url: 'restServices/redbackServices/loginService/logout'
});
}
};
@ -75,13 +75,13 @@ function(jquery,ui,sammy,tmpl) {
$("#topbar-menu-container").find("[redback-permissions]").each(function(element){
checkElementKarma(this);
});
$("#sidebar-content [redback-permissions]").each(function(element){
$("#sidebar-content").find("[redback-permissions]").each(function(element){
checkElementKarma(this);
});
checkUrlParams();
}
});
}
};
checkElementKarma=function(element){
var bindingValue = $(element).attr("redback-permissions");
@ -98,7 +98,7 @@ function(jquery,ui,sammy,tmpl) {
} else {
$(element).show();
}
}
};
hideElementWithKarma=function(){
$("#topbar-menu-container [redback-permissions]").each(function(element){
@ -109,7 +109,7 @@ function(jquery,ui,sammy,tmpl) {
$(this).hide();
});
$.log("hideElementWithKarma");
}
};
//------------------------------------//
// Change UI with appearance settings //
@ -119,31 +119,32 @@ function(jquery,ui,sammy,tmpl) {
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="<a href='"+url+"' class='brand'>";
if (data.logoLocation) {
link+="<img src='"+data.logoLocation+"' style='max-height: 30px'/>";
} else if (data.name) {
link+=data.name;
} else {
link+="Archiva";
}
link+="</a>";
$("#organisation-logo").html(link);
var organisationLogo=$("#organisation-logo");
if(data.url){
var url = data.url.startsWith("http://") || data.url.startsWith("https://") ? data.url : "http://"+data.url;
var link="<a href='"+url+"' class='brand'>";
if (data.logoLocation) {
link+="<img src='"+data.logoLocation+"' style='max-height: 30px'/>";
} else if (data.name) {
link+=data.name;
} else {
link+="Archiva";
}
link+="</a>";
organisationLogo.html(link);
}
if (!data.url && data.name){
$("#organisation-logo").html("<a href='/' class='brand'>"+data.name+"</a>");
organisationLogo.html("<a href='/' class='brand'>"+data.name+"</a>");
}
if (!data.url && !data.name){
$("#organisation-logo").html("<a href='/' class='brand'>Archiva</a>");
organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
}
},
error: function() {
$("#organisation-logo").html("<a href='/' class='brand'>Archiva</a>");
organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
}
});
}
};
MainMenuViewModel=function() {
@ -274,7 +275,7 @@ function(jquery,ui,sammy,tmpl) {
searchViewModel.search("restServices/archivaServices/searchService/searchArtifacts",repos);//,repositoryIds);
},searchViewModel);
}
};
this.get("#advancedsearch/:queryterms",function(){
advancedSearchRoute(this.params);
@ -298,8 +299,6 @@ function(jquery,ui,sammy,tmpl) {
var artifactId= this.params.artifactId;
$.log("get #artifact:"+groupId+":"+artifactId);
goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
return;
});
this.get('#artifact~:repositoryId/:groupId/:artifactId',function(context){
var groupId= this.params.groupId;
@ -307,7 +306,6 @@ function(jquery,ui,sammy,tmpl) {
var repositoryId = this.params.repositoryId;
$.log("get #artifact:"+groupId+":"+artifactId);
goToBrowseArtifactDetail(groupId,artifactId,repositoryId);//,null,null);
return;
});
var checkArtifactDetailContent=function(groupId,artifactId,version,repositoryId,tabToActivate,idContentToCheck,contentDisplayFn){
@ -316,19 +314,19 @@ function(jquery,ui,sammy,tmpl) {
var htmlIdSelect = $("#main-content #"+htmlId );
if(htmlIdSelect.html()!=null){
if( $.trim(htmlIdSelect.html().length)>0){
$("#main-content #"+tabToActivate).tab('show')
$("#main-content #"+tabToActivate).tab('show');
return;
}
}
generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,
function(artifactVersionDetailViewModel){
$("#main-content #"+tabToActivate).tab('show')
$("#main-content #"+tabToActivate).tab('show');
if(contentDisplayFn){
contentDisplayFn(groupId,artifactId,version,artifactVersionDetailViewModel);
}
}
);
}
};
this.get('#artifact/:groupId/:artifactId/:version',function(context){
@ -388,7 +386,7 @@ function(jquery,ui,sammy,tmpl) {
var calculateUsedBy=function(groupId,artifactId,version){
var dependeesContentDiv=$("#main-content #artifact-details-used-by-content" );
var dependeesContentDiv=$("#main-content" ).find("#artifact-details-used-by-content" );
if( $.trim(dependeesContentDiv.html()).length<1){
dependeesContentDiv.html(mediumSpinnerImg());
var dependeesUrl="restServices/archivaServices/browseService/dependees/"+encodeURIComponent(groupId);
@ -407,7 +405,7 @@ function(jquery,ui,sammy,tmpl) {
}
});
}
}
};
this.get('#artifact-used-by/:groupId/:artifactId/:version',function(context){
@ -429,7 +427,7 @@ function(jquery,ui,sammy,tmpl) {
var calculateMetadatas=function(groupId,artifactId,version,artifactVersionDetailViewModel){
var metadatasContentDiv=$("#main-content #artifact-details-metadatas-content" );
var metadatasContentDiv=$("#main-content" ).find("#artifact-details-metadatas-content" );
var metadatasUrl="restServices/archivaServices/browseService/metadatas/"+encodeURIComponent(groupId);
metadatasUrl+="/"+encodeURIComponent(artifactId);
metadatasUrl+="/"+encodeURIComponent(version);
@ -450,7 +448,7 @@ function(jquery,ui,sammy,tmpl) {
artifactVersionDetailViewModel.entries(entries);
}
});
}
};
this.get('#artifact-metadatas/:groupId/:artifactId/:version',function(context){
@ -501,34 +499,35 @@ function(jquery,ui,sammy,tmpl) {
ko.utils.arrayFirst(baseItems.concat(self.usersMenuItems, self.administrationMenuItems), function(p) {
if ( p.href == "#"+self.activeMenuId()) {
p.func();
return;
}
});
});
//this.get('', function () { this.app.runRoute('get', '#search') });
});
}
};
userLoggedCallbackFn=function(user){
$.log("userLoggedCallbackFn:"+ (user?user.username:null));
var loginLink=$("#login-link");
var registerLink=$("#register-link");
var changePasswordLink=$("#change-password-link");
if (!user) {
$("#login-link").show();
$("#register-link").show();
$("#change-password-link").hide();
loginLink.show();
registerLink.show();
changePasswordLink.hide();
checkUrlParams();
} else {
$("#change-password-link").show();
changePasswordLink.show();
$("#logout-link").show();
$("#register-link").hide();
$("#login-link").hide();
registerLink.hide();
loginLink.hide();
decorateMenuWithKarma(user);
}
}
};
checkSecurityLinks=function(){
userLogged(userLoggedCallbackFn);
}
};
checkCreateAdminLink=function(callbackFn){
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
@ -536,12 +535,13 @@ function(jquery,ui,sammy,tmpl) {
dataType: 'json',
success: function(data) {
var adminExists = data;
var createAdminLink=$("#create-admin-link");
if (adminExists == false) {
$("#create-admin-link").show();
createAdminLink.show();
$("#login-link").hide();
$("#register-link").hide();
} else {
$("#create-admin-link").hide();
createAdminLink.hide();
}
if(callbackFn){
callbackFn()
@ -549,7 +549,7 @@ function(jquery,ui,sammy,tmpl) {
$.log("adminExists:"+adminExists);
}
});
}
};
// handle url with registration link
checkUrlParams=function(){
@ -572,11 +572,11 @@ function(jquery,ui,sammy,tmpl) {
window.sammyArchivaApplication.setLocation("#search");
}
}
};
hasKarma=function(karmaName){
return $.inArray(karmaName,window.redbackModel.operatioNames)>=0;
}
};
startArchivaApplication=function(){
@ -603,7 +603,7 @@ function(jquery,ui,sammy,tmpl) {
window.sammyArchivaApplication.run();
}
};
drawQuickSearchAutocomplete=function(){