From 9450b40445d60b9e85c33fd75c1e6b0df8fc3eb9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 23 Dec 2012 00:00:19 +0000 Subject: [PATCH] reuse selector git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1425379 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/general-admin.js | 10 ++++++---- .../src/main/webapp/js/archiva/utils.js | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 377ff9a79..374bee46e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -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); } }); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index d42596eec..76963b69a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -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( "" + error.message + "" ); } } 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(){