From 30c17b5d869713e4274fb5f33f29c2bf5fe639ea Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 24 Aug 2012 13:37:20 +0000 Subject: [PATCH] some jquery selector optims git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1376908 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/webapp/js/archiva/network-proxies.js | 12 +++--- .../webapp/js/archiva/proxy-connectors.js | 10 ++--- .../main/webapp/js/archiva/repositories.js | 20 +++++----- .../webapp/js/archiva/repository-groups.js | 4 +- .../src/main/webapp/js/archiva/search.js | 18 ++++----- .../src/main/webapp/js/archiva/utils.js | 5 ++- .../src/main/webapp/js/redback/redback.js | 5 ++- .../src/main/webapp/js/redback/roles.js | 28 ++++++------- .../src/main/webapp/js/redback/user.js | 40 ++++++++++--------- .../src/main/webapp/js/redback/users.js | 2 +- 10 files changed, 74 insertions(+), 70 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js index 0bf6e12cb..1c7239c1e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js @@ -61,7 +61,7 @@ define("archiva.network-proxies",["jquery","i18n","jquery.tmpl","bootstrap","jqu this.bulkMode=false || bulkMode; this.save=function(){ - if (!$("#main-content #network-proxy-edit-form").valid()){ + if (!$("#main-content" ).find("#network-proxy-edit-form").valid()){ return; } if (!this.bulkMode){ @@ -215,12 +215,12 @@ define("archiva.network-proxies",["jquery","i18n","jquery.tmpl","bootstrap","jqu mainContent.find("#network-proxies-view-tabs").on('show', function (e) { if ($(e.target).attr("href")=="#network-proxies-edit") { var viewModel = new NetworkProxyViewModel(new NetworkProxy(),false,networkProxiesViewModel); - ko.applyBindings(viewModel,$("#main-content #network-proxies-edit").get(0)); + ko.applyBindings(viewModel,$("#main-content" ).find("#network-proxies-edit").get(0)); activateNetworkProxyFormValidation(); clearUserMessages(); } if ($(e.target).attr("href")=="#network-proxies-view") { - $("#main-content #network-proxies-view-tabs-li-edit a").html($.i18n.prop("add")); + $("#main-content" ).find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("add")); clearUserMessages(); } @@ -252,10 +252,10 @@ define("archiva.network-proxies",["jquery","i18n","jquery.tmpl","bootstrap","jqu ], pageSize: 5, gridUpdateCallBack: function(networkProxy){ - $("#main-content #networkProxiesTable [title]").tooltip(); + $("#main-content" ).find("#networkProxiesTable [title]").tooltip(); } }); - ko.applyBindings(networkProxiesViewModel,$("#main-content #network-proxies-view").get(0)); + ko.applyBindings(networkProxiesViewModel,$("#main-content" ).find("#network-proxies-view").get(0)); } ) } @@ -270,7 +270,7 @@ define("archiva.network-proxies",["jquery","i18n","jquery.tmpl","bootstrap","jqu } activateNetworkProxyFormValidation=function(){ - var editForm=$("#main-content #network-proxy-edit-form"); + var editForm=$("#main-content" ).find("#network-proxy-edit-form"); var validator = editForm.validate({ rules: {id: { required: true, diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js index d897a34ff..65177c55f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js @@ -150,7 +150,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq } changePolicyOption=function(id){ - var selectedOption=$("#main-content #policy-"+id + " option:selected"); + var selectedOption=$("#main-content").find("#policy-"+id ).find("option:selected"); if (selectedOption.length>0){ var value = selectedOption.val(); $.log("changePolicyOption:"+id+":"+value); @@ -172,7 +172,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq addBlacklistPattern=function(){ - var pattern = $("#main-content #blacklist-value").val(); + var pattern = $("#main-content").find("#blacklist-value").val(); var tab = self.proxyConnector.blackListPatterns(); tab.push(pattern); self.proxyConnector.blackListPatterns(tab); @@ -185,7 +185,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq } addWhitelistPattern=function(){ - var pattern = $("#main-content #whitelist-value").val(); + var pattern = $("#main-content" ).find("#whitelist-value").val(); var tab = self.proxyConnector.whiteListPatterns(); tab.push(pattern); self.proxyConnector.whiteListPatterns(tab); @@ -430,7 +430,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq var managedRepository = getManagedRepository(proxyConnector.sourceRepoId()); var proxyConnectorEditOrderViewModel=new ProxyConnectorEditOrderViewModel(proxyConnectors,self,managedRepository); - ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content #proxy-connector-edit-order").get(0)); + ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content").find("#proxy-connector-edit-order").get(0)); activateProxyConnectorsEditOrderTab(); } @@ -439,7 +439,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq data: self.proxyConnectors, pageSize: 5, gridUpdateCallBack: function(){ - $("#main-content #proxyConnectorsTable [title]").tooltip(); + $("#main-content" ).find("#proxyConnectorsTable" ).find("[title]").tooltip(); } }); var mainContent = $("#main-content"); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js index 97576bc51..9df4a6da6 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js @@ -178,7 +178,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery this.availableLayouts = window.managedRepositoryTypes; this.save=function(){ - var valid = $("#main-content #managed-repository-edit-form").valid(); + var valid = $("#main-content").find("#managed-repository-edit-form").valid(); if (valid==false) { return; } @@ -261,7 +261,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery } activateManagedRepositoryFormValidation=function(){ - var validator = $("#main-content #managed-repository-edit-form").validate({ + var validator = $("#main-content" ).find("#managed-repository-edit-form").validate({ rules: { daysOlder : { digits: true, @@ -314,7 +314,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery clearUserMessages(); openDialogConfirm( function(){ - $("#dialog-confirm-modal #modal-login-footer").append(smallSpinnerImg()); + $("#dialog-confirm-modal" ).find("#modal-login-footer").append(smallSpinnerImg()); var checked = $("#managed-repository-scan-now-all").get(0).checked; var url = "restServices/archivaServices/repositoriesService/scanRepositoryNow?"; url += "repositoryId="+encodeURIComponent(managedRepository.id()); @@ -351,7 +351,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery clearUserMessages(); openDialogConfirm( function(){ - $("#dialog-confirm-modal #modal-login-footer").append(smallSpinnerImg()); + $("#dialog-confirm-modal").find("#modal-login-footer").append(smallSpinnerImg()); var url = "restServices/archivaServices/managedRepositoriesService/deleteManagedRepository?"; url += "repositoryId="+encodeURIComponent(managedRepository.id()); @@ -645,7 +645,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery this.availableLayouts = window.managedRepositoryTypes; this.save=function(){ - var valid = $("#main-content #remote-repository-edit-form").valid(); + var valid = $("#main-content" ).find("#remote-repository-edit-form").valid(); if (valid==false) { return; } @@ -815,7 +815,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery activateRemoteRepositoryFormValidation=function(){ // FIXME find a way to activate cronExpression validation only if downloadRemote is activated ! - var validator = $("#main-content #remote-repository-edit-form").validate({ + var validator = $("#main-content" ).find("#remote-repository-edit-form").validate({ rules: { id: { required: true, @@ -891,7 +891,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery ], pageSize: 5, gridUpdateCallBack: function(){ - $("#main-content #managed-repositories-table").find("[title]").tooltip(); + $("#main-content" ).find("#managed-repositories-table").find("[title]").tooltip(); } }); var mainContent = $("#main-content"); @@ -928,7 +928,7 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery ], pageSize: 5, gridUpdateCallBack: function(){ - $("#main-content #remote-repositories-table").find("[title]").tooltip(); + $("#main-content" ).find("#remote-repositories-table").find("[title]").tooltip(); } }); var mainContent = $("#main-content"); @@ -960,13 +960,13 @@ define("archiva.repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery success: function(data) { var viewModel = new RemoteRepositoryViewModel(new RemoteRepository(),false,remoteRepositoriesViewModel); viewModel.networkProxies(mapNetworkProxies(data)); - ko.applyBindings(viewModel,$("#main-content #remote-repository-edit").get(0)); + ko.applyBindings(viewModel,$("#main-content" ).find("#remote-repository-edit").get(0)); activateRemoteRepositoryFormValidation(); } }) } if ($(e.target).attr("href")=="#remote-repositories-view") { - $("#main-content #remote-repository-edit-li a").html($.i18n.prop("add")); + $("#main-content" ).find("#remote-repository-edit-li" ).find("a").html($.i18n.prop("add")); } }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js index feb1510c3..9744d4f4d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js @@ -111,8 +111,8 @@ function() { $.log("editRepositoryGroup:"+repositoryGroup.id()+",repositories:"+repositoryGroup.repositories().length+",managed:"+repositoryGroup.managedRepositories().length); var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,true,self); activateRepositoryGroupEditTab(); - ko.applyBindings(repositoryGroupViewModel,$("#main-content #repository-groups-edit" ).get(0)); - $("#main-content #repository-groups-view-tabs-li-edit a").html($.i18n.prop("edit")); + ko.applyBindings(repositoryGroupViewModel,$("#main-content").find("#repository-groups-edit" ).get(0)); + $("#main-content" ).find("#repository-groups-view-tabs-li-edit" ).find("a").html($.i18n.prop("edit")); } this.saveRepositoryGroup=function(repositoryGroup){ 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 ec69ac2a4..12391a106 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 @@ -147,10 +147,10 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno return entries; } displayArtifactInfo=function(){ - if ($("#main-content #artifact-info:visible" ).length>0) { - $("#main-content #artifact-info" ).hide(); + if ($("#main-content").find("#artifact-info:visible" ).length>0) { + $("#main-content").find("#artifact-info" ).hide(); } else { - $("#main-content #artifact-info" ).show(); + $("#main-content").find("#artifact-info" ).show(); } } @@ -483,7 +483,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno success:function(data){ self.artifacts.remove(artifact); displaySuccessMessage( $.i18n.prop('artifact.deleted')); - $("#main-content #artifact-details-download-content" ).html(smallSpinnerImg()); + $("#main-content").find("#artifact-details-download-content" ).html(smallSpinnerImg()); // reload datas from server var artifactDownloadInfosUrl = "restServices/archivaServices/browseService/artifactDownloadInfos/"+encodeURIComponent(self.artifactVersionDetailViewModel.groupId); artifactDownloadInfosUrl+="/"+encodeURIComponent(self.artifactVersionDetailViewModel.artifactId)+"/"+encodeURIComponent(self.artifactVersionDetailViewModel.version); @@ -557,7 +557,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno if(classifier){ entriesUrl+="&c="+encodeURIComponent(classifier); } - $("#main-content #artifact_content_tree").fileTree({ + $("#main-content").find("#artifact_content_tree").fileTree({ script: entriesUrl, root: "" },function(file) { @@ -855,7 +855,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } getSelectedBrowsingRepository=function(){ - var selectedOption=$("#main-content #select_browse_repository option:selected" ); + var selectedOption=$("#main-content").find("#select_browse_repository").find("option:selected" ); if (selectedOption.length>0){ var repoId=selectedOption.val(); return repoId; @@ -873,7 +873,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno if (selectedRepo){ url+="?repositoryId="+encodeURIComponent(selectedRepo); } - $( "#main-content #browse-autocomplete" ).autocomplete({ + $( "#main-content").find("#browse-autocomplete" ).autocomplete({ minLength: 2, source: function(request, response){ var query = ""; @@ -1412,7 +1412,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } applyAutocompleteOnHeader=function(property,resultViewModel){ - $( "#main-content #search-filter-auto-"+property ).autocomplete({ + $( "#main-content").find("#search-filter-auto-"+property ).autocomplete({ minLength: 0, source: function(request, response){ var founds=[]; @@ -1543,7 +1543,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno if ($.trim(queryTerm).length<1){ var errorList=[{ message: $.i18n.prop("search.artifact.search.form.terms.empty"), - element: $("#main-content #search-basic-form #search-terms" ).get(0) + element: $("#main-content").find("#search-basic-form").find("#search-terms" ).get(0) }]; customShowError("#main-content #search-basic-form", null, null, errorList); return; 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 a3831c99c..eaa13b1f9 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 @@ -163,8 +163,9 @@ require(["jquery","jquery.tmpl","i18n"], function(jquery,jqueryTmpl,i18n) { } $("#dialog-confirm-modal-header-title").html(title); $("#dialog-confirm-modal-body-text").html(bodyText); + var dialogConfirmModalOk=$("#dialog-confirm-modal-ok"); if (okMessage){ - $("#dialog-confirm-modal-ok").html(okMessage); + dialogConfirmModalOk.html(okMessage); } if (cancelMessage){ dialogCancel.html(cancelMessage); @@ -172,7 +173,7 @@ require(["jquery","jquery.tmpl","i18n"], function(jquery,jqueryTmpl,i18n) { window.modalConfirmDialog.modal('show'); // unbind previous events !! - var dialogConfirmModalOk=$("#dialog-confirm-modal-ok"); + dialogConfirmModalOk.off( ); dialogConfirmModalOk.on("click", okFn); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js index 3a7d0a954..347436fe5 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback.js @@ -97,8 +97,9 @@ define("redback",["jquery","utils","jquery.validate","jquery.json","knockout", * open the register modal box */ registerBox=function(){ + var modalRegister=$("#modal-register"); if (window.modalRegisterWindow==null) { - window.modalRegisterWindow = $("#modal-register").modal({backdrop:'static',show:false}); + window.modalRegisterWindow = modalRegister.modal({backdrop:'static',show:false}); window.modalRegisterWindow.bind('hidden', function () { $("#modal-register-err-message").hide(); }) @@ -109,7 +110,7 @@ define("redback",["jquery","utils","jquery.validate","jquery.json","knockout", customShowError("#user-register-form",validator,errorMap,errorMap); } }); - $("#modal-register").delegate("#modal-register-ok", "click keydown keypress", function(e) { + modalRegister.delegate("#modal-register-ok", "click keydown keypress", function(e) { e.preventDefault(); register(); }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js index 46fae1b6f..53c5e1970 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js @@ -312,34 +312,34 @@ define("redback.roles",["jquery","utils","i18n","jquery.validate","knockout","kn } activateRolesGridTab=function(){ - $("#main-content #roles-view-tabs li").removeClass("active"); - $("#main-content #roles-view-tabs-content div").removeClass("active"); + $("#main-content").find("#roles-view-tabs").find("li").removeClass("active"); + $("#main-content").find("#roles-view-tabs-content").find("div").removeClass("active"); // activate roles grid tab - $("#main-content #roles-view-tabs-content #roles-view").addClass("active"); - $("#main-content #roles-view-tabs-li-roles-grid").addClass("active"); + $("#main-content").find("#roles-view-tabs-content").find("#roles-view").addClass("active"); + $("#main-content").find("#roles-view-tabs-li-roles-grid").addClass("active"); } activateRoleEditTab=function(){ - $("#main-content #roles-view-tabs li").removeClass("active"); - $("#main-content #roles-view-tabs-content div").removeClass("active"); + $("#main-content").find("#roles-view-tabs").find("li").removeClass("active"); + $("#main-content").find("#roles-view-tabs-content").find("div").removeClass("active"); // activate role edit tab - $("#main-content #roles-view-tabs-content #role-edit").addClass("active"); + $("#main-content").find("#roles-view-tabs-content").find("#role-edit").addClass("active"); $("#roles-view-tabs-li-roles-edit").addClass("active"); } activateRoleUsersListTab=function(){ - $("#main-content #role-edit-users-li").removeClass("active"); - $("#main-content #role-edit-users").removeClass("active"); + $("#main-content").find("#role-edit-users-li").removeClass("active"); + $("#main-content").find("#role-edit-users").removeClass("active"); // activate roles grid tab - $("#main-content #role-view-users-li").addClass("active"); - $("#main-content #role-view-users").addClass("active"); + $("#main-content").find("#role-view-users-li").addClass("active"); + $("#main-content").find("#role-view-users").addClass("active"); } activateRoleUsersEditTab=function(){ - $("#main-content #role-view-users-li").removeClass("active"); - $("#main-content #role-view-users").removeClass("active"); + $("#main-content").find("#role-view-users-li").removeClass("active"); + $("#main-content").find("#role-view-users").removeClass("active"); // activate role edit tab - $("#main-content #role-edit-users").addClass("active"); + $("#main-content").find("#role-edit-users").addClass("active"); $("#role-edit-users-li").addClass("active"); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index 3994edc58..fb01642a7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -107,7 +107,7 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno successFnCallback(currentUser); } clearForm("#main-content #user-create"); - $("#main-content #user-create").hide(); + $("#main-content").find("#user-create").hide(); activateUsersGridTab(); return this; } else { @@ -170,7 +170,7 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno if (updated == true) { clearUserMessages(); displaySuccessMessage($.i18n.prop("user.updated",currentUser.username())); - $("#main-content #users-view-tabs-li-user-edit a").html($.i18n.prop("add")); + $("#main-content").find("#users-view-tabs-li-user-edit").find("a").html($.i18n.prop("add")); clearForm("#main-content #user-create"); activateUsersGridTab(); return this; @@ -188,7 +188,7 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno this.save=function(){ $.log("user.save create:"+window.redbackModel.createUser); if (window.redbackModel.createUser==true){ - var valid = $("#main-content #user-create").valid(); + var valid = $("#main-content").find("#user-create").valid(); if (valid==false) { $.log("user#save valid:false"); @@ -298,7 +298,7 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno * open a modal box to create admin user */ adminCreateBox=function() { - + var mainContent=$("#main-content"); $.ajax("restServices/redbackServices/userService/isAdminUserExists", { type: "GET", @@ -308,9 +308,9 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno if (adminExists == false) { window.redbackModel.createUser=true; - $("#main-content").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}'); + mainContent.attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}'); var viewModel = new AdminUserViewModel(); - ko.applyBindings(viewModel,$("#main-content" ).get(0)); + ko.applyBindings(viewModel,mainContent.get(0)); $.log("adminCreateBox"); $("#user-create").validate({ rules: { @@ -420,8 +420,9 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno decorateMenuWithKarma(user); return; } - $("#modal-login-err-message").html($.i18n.prop("incorrect.username.password")); - $("#modal-login-err-message").show(); + var modalLoginErrMsg=$("#modal-login-err-message"); + modalLoginErrMsg.html($.i18n.prop("incorrect.username.password")); + modalLoginErrMsg.show(); } /** @@ -487,11 +488,12 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno } passwordReset=function(){ - var username = $("#user-login-form-username" ).val(); + var userLoginFormUsername=$("#user-login-form-username" ); + var username = userLoginFormUsername.val(); if(username.trim().length<1){ var errorList=[{ message: $.i18n.prop("username.cannot.be.empty"), - element: $("#user-login-form-username").get(0) + element: userLoginFormUsername.get(0) }]; customShowError("#user-login-form", null, null, errorList); return; @@ -627,7 +629,7 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno window.modalEditUserBox.bind('hidden', function () { $("#modal-user-edit-err-message").hide(); }) - $("#modal-user-edit #modal-user-edit-ok").on( "click keydown keypress", function(e) { + $("#modal-user-edit").find("#modal-user-edit-ok").on( "click keydown keypress", function(e) { e.preventDefault(); $.log("user.js#editUserDetailsBox"); var valid = $("#user-edit-form").valid(); @@ -636,19 +638,19 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno } var user = { username:currentUser.username, - fullName:$("#modal-user-edit #fullname").val(), - email:$("#modal-user-edit #email").val(), - previousPassword:$("#modal-user-edit #userEditFormCurrentPassword").val(), - password:$("#modal-user-edit #userEditFormNewPassword").val(), - confirmPassword:$("#modal-user-edit #userEditFormNewPasswordConfirm").val() + fullName:$("#modal-user-edit").find("#fullname").val(), + email:$("#modal-user-edit").find("#email").val(), + previousPassword:$("#modal-user-edit").find("#userEditFormCurrentPassword").val(), + password:$("#modal-user-edit").find("#userEditFormNewPassword").val(), + confirmPassword:$("#modal-user-edit").find("#userEditFormNewPasswordConfirm").val() }; editUserDetails(user); }); } var currentUser = getUserFromLoginCookie(); - $("#modal-user-edit #username").html(currentUser.username); - $("#modal-user-edit #fullname").val(currentUser.fullName); - $("#modal-user-edit #email").val(currentUser.email); + $("#modal-user-edit").find("#username").html(currentUser.username); + $("#modal-user-edit").find("#fullname").val(currentUser.fullName); + $("#modal-user-edit").find("#email").val(currentUser.email); window.modalEditUserBox.modal('show'); $("#user-edit-form").validate({ rules: { diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js index fd8502b8b..e4778b386 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js @@ -216,7 +216,7 @@ define("redback.users",["jquery","utils","i18n","jquery.validate","knockout","kn } saveUser=function(){ - var valid = $("#main-content #user-create").valid(); + var valid = $("#main-content").find("#user-create").valid(); if (valid==false) { return; } -- 2.39.5