reuse selector

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1425379 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-23 00:00:19 +00:00
parent faa30809eb
commit 9450b40445
2 changed files with 19 additions and 7 deletions

View File

@ -1409,12 +1409,13 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
}
saveRedbackRuntimeConfiguration=function(){
var valid = $("#main-content").find("#redback-runtime-general-form-id").valid();
var mainContent=$("#main-content");
var valid = mainContent.find("#redback-runtime-general-form-id").valid();
if (valid==false) {
return;
}
$.log("saveRedbackRuntimeConfiguration");
var saveButton = $("#redback-runtime-configuration-save" );
var saveButton = mainContent.find("#redback-runtime-configuration-save" );
saveButton.button('loading');
clearUserMessages();
var userMessages=$("#user-messages");
@ -1474,7 +1475,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
}
activateRedbackRuntimeGeneralFormValidation=function(){
var validator = $("#main-content" ).find("#redback-runtime-general-form-id").validate({
var formSelector=$("#main-content" ).find("#redback-runtime-general-form-id");
var validator = formSelector.validate({
rules: {
usersCacheTimeToLiveSeconds : {
digits: true,
@ -1488,7 +1490,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
}
},
showErrors: function(validator, errorMap, errorList) {
customShowError("#main-content #redback-runtime-general-form-id",validator,errorMap,errorMap);
customShowError(formSelector,validator,errorMap,errorMap);
}
});
}

View File

@ -324,15 +324,25 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
removeValidationErrorMessages(selector);
for ( var i = 0; errorList[i]; i++ ) {
var error = errorList[i];
var field = $(selector).find("#"+error.element.id);
if (typeof selector == 'string') {
var field = $(selector).find("#"+error.element.id);
} else {
var field = selector.find("#"+error.element.id);
}
field.parents( "div.control-group" ).addClass( "error" );
field.parent().append( "<span class=\"help-inline\">" + error.message + "</span>" );
}
}
removeValidationErrorMessages=function(selector){
$(selector).find("div.control-group" ).removeClass( "error" );
$(selector).find("span.help-inline").remove();
if (typeof selector == 'string') {
$(selector).find("div.control-group" ).removeClass( "error" );
$(selector).find("span.help-inline").remove();
} else {
selector.find("div.control-group" ).removeClass( "error" );
selector.find("span.help-inline").remove();
}
}
appendArchivaVersion=function(){