| /*! |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| UserManager={contextPath:"",formatMsg:function(c,a){var b=/{(\d+)}/g; |
| return c.replace(b,function(){var d=parseInt(arguments[1]); |
| return a[d] |
| }) |
| },messages:{"error.dlg.title":"Error","confirm.yes":"Yes","confirm.no":"No","button.add":"Add","searching.progress.msg":"Searching, please wait...","tooltip.removeProperty":"Remove Property","tooltip.removeMember":"Remove Member","group.updated.msg":"Updated the group","user.updated.msg":"Updated the user","user.pwd.updated.msg":"Updated the password","group.created.msg":"Created the group","user.created.msg":"Created the user"}}; |
| UserManager.SideBar={init:function(){var c,b,a,d,e; |
| b=$("ul#sidebar-nav li a"); |
| a=location.href; |
| d=location.hash; |
| if(d!=null&&d.length>0){a=a.substring(0,a.length-d.length) |
| }for(c=0; |
| c<b.length; |
| c++){e=b[c]; |
| if(a==e.href){$(e.parentNode).addClass("ui-corner-all ui-state-highlight") |
| }}}}; |
| UserManager.ErrorDlg={showError:function(b,a){if($("#error_dialog").length==0){$("body").append('<div id="error_dialog" style="display:none;"></div>') |
| }$("#error_dialog").html(a); |
| $("#error_dialog").dialog({title:b,bgiframe:true,autoOpen:false,width:400,maxHeight:500,modal:true}); |
| $("#error_dialog").dialog("open") |
| },errorHandler:function(d,g,c){var f,b; |
| try{f=UserManager.messages["error.dlg.title"]; |
| b=$.parseJSON(d.responseText); |
| if(b.error){UserManager.ErrorDlg.showError(f,b.error.message) |
| }else{UserManager.ErrorDlg.showError(f,d.responseText) |
| }}catch(a){UserManager.ErrorDlg.showError(f,d.responseText) |
| }}}; |
| UserManager.Authorizables={progressFnId:null,init:function(){$("#find-authorizables-quick-nav").buttonset().show(); |
| UserManager.Authorizables.applyResultStylesAndHandlers(); |
| $('#find-authorizables-quick-nav input[type = "radio"]').change(function(a){$("#searchOffset").val(0); |
| $("#findAuthorizablesQuery").val(""); |
| UserManager.Authorizables.runSearchFn(); |
| return false |
| }); |
| $("button#findAuthorizablesBtn").button(); |
| $("button#findAuthorizablesBtn").click(function(a){if($("#findAuthorizablesQuery").val()==""){$("#radioAll").attr("checked",true); |
| $("#radioAll").button("refresh") |
| }else{$("#radioNone").attr("checked",true); |
| $("#radioNone").button("refresh") |
| }UserManager.Authorizables.runSearchFn(0); |
| return false |
| }); |
| $(window).bind("hashchange",UserManager.Authorizables.runSearchFromHashFn); |
| $(window).trigger("hashchange") |
| },progressFn:function(){$("#authorizables-results-body").after('<div id="authorizables-results-progress" class="search-empty-msg ui-corner-all ui-state-highlight">'+UserManager.messages["searching.progress.msg"]+"</div>"); |
| UserManager.Authorizables.progressFnId=null |
| },clearProgressFn:function(){if(UserManager.Authorizables.progressFnId!=null){clearTimeout(UserManager.Authorizables.progressFnId); |
| UserManager.Authorizables.progressFnId=null |
| }$("#authorizables-results-progress").remove() |
| },runSearchFn:function(c){var a,b; |
| $("#searchOffset").val(c==undefined?"0":c); |
| a=$("#find-authorizables-form"); |
| b=a.serialize(); |
| window.location.hash=b |
| },parseHashParams:function(){var c={},h,b=/\+/g,f=/([^&;=]+)=?([^&;]*)/g,i=function(a){return decodeURIComponent(a.replace(b," ")) |
| },g=window.location.hash.substring(1); |
| while(h=f.exec(g)){c[i(h[1])]=i(h[2]) |
| }return c |
| },runSearchFromHashFn:function(){var b,c,a; |
| b=$("#find-authorizables-form"); |
| c=b.attr("action"); |
| c=c.substring(0,c.length-4)+"searchresult.html"; |
| a=UserManager.Authorizables.parseHashParams(); |
| $("#findAuthorizablesQuery").val(a.q==undefined?"":a.q); |
| $('#find-authorizables-quick-nav input[value="'+(a.sp==undefined?"":a.sp)+'"]').attr("checked",true).button("refresh"); |
| $("#searchOffset").val(a.o==undefined?"0":a.o); |
| if(a.q==undefined&&a.sp==undefined){if($("#search-result-ready-to-search").length==0){$.ajax({url:c,type:"get",success:UserManager.Authorizables.searchDoneFn,error:UserManager.ErrorDlg.errorHandler}) |
| }return |
| }$("#authorizables-results-body").hide(); |
| UserManager.Authorizables.clearProgressFn(); |
| UserManager.Authorizables.progressFnId=setTimeout(UserManager.Authorizables.progressFn,200); |
| $.ajax({url:c,type:"get",data:b.serialize(),cache:false,success:UserManager.Authorizables.searchDoneFn,error:function(e,f,d){UserManager.Authorizables.clearProgressFn(); |
| UserManager.ErrorDlg.errorHandler(e,f,d) |
| }}) |
| },searchDoneFn:function(a,c,b){UserManager.Authorizables.clearProgressFn(); |
| $("#authorizables-results-body").replaceWith(a); |
| UserManager.Authorizables.applyResultStylesAndHandlers() |
| },applyResultStylesAndHandlers:function(a,c,b){$("#search-result-body tr").mouseover(function(){$(this).addClass("ui-state-highlight") |
| }).mouseout(function(){$(this).removeClass("ui-state-highlight") |
| }).click(function(){var d=$(this).find("td a")[0].href; |
| window.location=d; |
| return false |
| }); |
| $("#first_page").button().click(function(){UserManager.Authorizables.runSearchFn(0); |
| return false |
| }); |
| $("#prev_page").button().click(function(){UserManager.Authorizables.runSearchFn($("#prev_page").val()); |
| return false |
| }); |
| $("#next_page").button().click(function(){UserManager.Authorizables.runSearchFn($("#next_page").val()); |
| return false |
| }) |
| }}; |
| UserManager.Group={}; |
| UserManager.Group.Create={init:function(){$("button#createGroupBtn").button(); |
| $("#create-group-form").validate({rules:{":name":"required"}}); |
| $("button#createGroupBtn").click(function(d){var b,a,c; |
| b=$("#create-group-form"); |
| if(!b.valid()){return false |
| }a=b.attr("action"); |
| a=a.substring(0,a.length-4)+"json"; |
| $("#redirect").attr("disabled",true); |
| c=b.serialize(); |
| $("#redirect").removeAttr("disabled"); |
| $("#create-group-body div.info-msg-block").hide(); |
| $.ajax({url:a,type:"POST",data:c,success:function(e,g,f){$("#create-group-form input[type='text']").val(""); |
| $("#create-group-body span.info-msg-text").html(UserManager.messages["group.created.msg"]); |
| $("#create-group-body div.info-msg-block").show() |
| },error:UserManager.ErrorDlg.errorHandler}); |
| return false |
| }) |
| }}; |
| UserManager.Group.Update={init:function(){$("button#updateGroupBtn").button(); |
| $("#update-group-form").validate({rules:{}}); |
| $(".remove-member").hover(function(){$(this).addClass("ui-state-hover") |
| },function(){$(this).removeClass("ui-state-hover") |
| }).click(function(b){var a=$(b.currentTarget.parentNode); |
| a.hide("slow",function(){if($("ol#declaredMembers li:visible").length==0){$("#declaredMembers__empty").show() |
| }}); |
| a.find("input").attr("name",":member@Delete"); |
| return false |
| }); |
| $(".remove-property").hover(function(){$(this).addClass("ui-state-hover") |
| },function(){$(this).removeClass("ui-state-hover") |
| }).click(function(d){var c,a,b; |
| c=$(d.currentTarget.parentNode); |
| c.hide("slow"); |
| a=c.find("input"); |
| b=a.attr("name"); |
| a.attr("name",b+"@Delete"); |
| return false |
| }); |
| $("button#updateGroupBtn").click(function(d){var b,a,c; |
| b=$("#update-group-form"); |
| if(!b.valid()){return false |
| }a=b.attr("action"); |
| a=a.substring(0,a.length-4)+"json"; |
| $("#redirect").attr("disabled",true); |
| c=b.serialize(); |
| $("#redirect").removeAttr("disabled"); |
| $("#update-group-body div.info-msg-block").hide(); |
| $.ajax({url:a,type:"POST",data:c,success:function(e,g,f){$("#update-group-body").parent().load(UserManager.contextPath+e.path+".update_body.html",function(){$("#update-group-body span.info-msg-text").html(UserManager.messages["group.updated.msg"]); |
| $("#update-group-body div.info-msg-block").show() |
| }); |
| setTimeout(function(){UserManager.Group.Update.init(); |
| $(".noscript-hide").removeClass("noscript-hide") |
| },100) |
| },error:UserManager.ErrorDlg.errorHandler}); |
| return false |
| }); |
| $("a#removeGroupLink").click(function(a){$("#remove-group-dialog").dialog({autoOpen:false,height:"auto",width:350,modal:true,resizable:false,buttons:[{text:UserManager.messages["confirm.yes"],click:function(){$("#remove-group-form").submit() |
| }},{text:UserManager.messages["confirm.no"],click:function(){$("#remove-group-dialog").dialog("close") |
| }}]}); |
| $("#remove-group-dialog").dialog("open"); |
| return false |
| }); |
| $("a#add_property").click(function(a){$("#add-property-dialog").dialog({autoOpen:false,height:"auto",width:350,modal:true,resizable:false,buttons:[{text:UserManager.messages["button.add"],click:function(){var e,c,b,d; |
| e=$("#add-property-form"); |
| if(!e.valid()){return false |
| }c=$("#newPropName").val(); |
| b=c; |
| $("#updateSubmitBtns").before('<div class="prop-line ui-helper-clearfix"><label for="'+c+'">'+b+':</label> <input id="'+c+'" type="text" name="'+c+'" /> <a href="#" class="remove-property" title="'+UserManager.messages["tooltip.removeProperty"]+'"><span class="ui-icon ui-icon-circle-close"></span></a></div>'); |
| d=$("#updateSubmitBtns").prev(); |
| d.find("a.remove-property").hover(function(){$(this).addClass("ui-state-hover") |
| },function(){$(this).removeClass("ui-state-hover") |
| }).click(function(f){var g=$(f.currentTarget.parentNode); |
| g.hide("slow",function(){g.remove() |
| }); |
| return false |
| }); |
| $("#add-property-dialog").dialog("close"); |
| d.find("input").focus() |
| }}]}); |
| $("#newPropName").val(""); |
| $("#add-property-dialog").dialog("open"); |
| return false |
| }); |
| $("#add-property-form").submit(function(b){var a=$("#add-property-dialog").dialog("option","buttons"); |
| a[0].click(); |
| return false |
| }).validate({rules:{name:"required"}}); |
| $("a#add_member").click(function(a){$("#add-member-dialog").dialog({autoOpen:false,height:"auto",width:350,modal:true,resizable:false,buttons:[{text:UserManager.messages["button.add"],click:function(){var f,c,b,g,d,e; |
| f=$("#add-group-member-form"); |
| if(!f.valid()){return false |
| }c=$("#memberName").val(); |
| b=c; |
| e=$("#memberName").data("item"); |
| if(e){if(e.label&&e.value==c){b=e.label |
| }}g='<li><input type="hidden" name=":member" value="'+c+'" /><span>'+b+'</span> <a href="#" class="remove-member" title="'+UserManager.messages["tooltip.removeMember"]+'"><span class="ui-icon ui-icon-circle-close"></span></a></li>'; |
| $("#declaredMembers__empty").hide(); |
| $("#declaredMembers").append(g); |
| d=$("#declaredMembers").find("li").last(); |
| d.find("a.remove-member").hover(function(){$(this).addClass("ui-state-hover") |
| },function(){$(this).removeClass("ui-state-hover") |
| }).click(function(i){var h=$(i.currentTarget.parentNode); |
| h.hide("slow",function(){h.remove(); |
| if($("ol#declaredMembers li:visible").length==0){$("#declaredMembers__empty").show() |
| }}); |
| return false |
| }); |
| $("#add-member-dialog").dialog("close"); |
| return false |
| }}]}); |
| $("#memberName").val(""); |
| $("#add-member-dialog").dialog("open"); |
| return false |
| }); |
| $("#add-group-member-form").submit(function(b){var a=$("#add-member-dialog").dialog("option","buttons"); |
| a[0].click(); |
| return false |
| }).validate({rules:{":member":"required"}}); |
| if($("#memberName").length>0){$("#memberName").autocomplete({source:UserManager.contextPath+"/system/userManager.autocomplete.json",minLength:1,select:function(b,c){var a=c.item; |
| $("#memberName").val(a.value).data("item",a) |
| }}).data("autocomplete")._renderItem=function(a,b){return $("<li></li>").data("item.autocomplete",b).append("<a>"+(b.label?(b.label+" ("+b.value+")"):b.value)+"</a>").appendTo(a) |
| } |
| }}}; |
| UserManager.User={}; |
| UserManager.User.Create={init:function(){$("button#createUserBtn").button(); |
| $("#create-user-form").validate({rules:{":name":"required",pwd:"required",pwdConfirm:{equalTo:"#pwd"}}}); |
| $("button#createUserBtn").click(function(d){var b,a,c; |
| b=$("#create-user-form"); |
| if(!b.valid()){return false |
| }a=b.attr("action"); |
| a=a.substring(0,a.length-4)+"json"; |
| $("#redirect").attr("disabled",true); |
| c=b.serialize(); |
| $("#redirect").removeAttr("disabled"); |
| $("#create-user-body div.info-msg-block").hide(); |
| $.ajax({url:a,type:"POST",data:c,success:function(e,g,f){$("#create-user-form input[type='text']").val(""); |
| $("#create-user-form input[type='password']").val(""); |
| $("#create-user-body span.info-msg-text").html(UserManager.messages["user.created.msg"]); |
| $("#create-user-body div.info-msg-block").show() |
| },error:UserManager.ErrorDlg.errorHandler}); |
| return false |
| }) |
| }}; |
| UserManager.User.Update={init:function(){$("button#updateUserBtn").button(); |
| $("#update-user-form").validate({rules:{}}); |
| var a=function(c){var b=$('input:radio[name=":disabled"]:checked').val(); |
| if(b=="true"){$("#disabledReasonPanel").show() |
| }else{$("#disabledReasonPanel").hide() |
| }return false |
| }; |
| $('input:radio[name=":disabled"]').change(a); |
| a(); |
| $(".remove-property").hover(function(){$(this).addClass("ui-state-hover") |
| },function(){$(this).removeClass("ui-state-hover") |
| }).click(function(f){var d,b,c; |
| d=$(f.currentTarget.parentNode); |
| d.hide("slow"); |
| b=d.find("input"); |
| c=b.attr("name"); |
| b.attr("name",c+"@Delete"); |
| return false |
| }); |
| $("button#updateUserBtn").click(function(f){var c,b,d; |
| c=$("#update-user-form"); |
| if(!c.valid()){return false |
| }b=c.attr("action"); |
| b=b.substring(0,b.length-4)+"json"; |
| $("#redirect").attr("disabled",true); |
| d=c.serialize(); |
| $("#redirect").removeAttr("disabled"); |
| $("#update-user-body div.info-msg-block").hide(); |
| $.ajax({url:b,type:"POST",data:d,success:function(e,h,g){$("#update-user-body").parent().load(UserManager.contextPath+e.path+".update_body.html",function(){$("#update-user-body span.info-msg-text").html(UserManager.messages["user.updated.msg"]); |
| $("#update-user-body div.info-msg-block").show() |
| }); |
| setTimeout(function(){UserManager.User.Update.init(); |
| if($("#update-password-form").length>0){UserManager.User.UpdatePassword.init() |
| }$(".noscript-hide").removeClass("noscript-hide") |
| },100) |
| },error:UserManager.ErrorDlg.errorHandler}); |
| return false |
| }); |
| $("a#removeUserLink").click(function(b){$("#remove-user-dialog").dialog({autoOpen:false,height:"auto",width:350,modal:true,resizable:false,buttons:[{text:UserManager.messages["confirm.yes"],click:function(){$("#remove-user-form").submit() |
| }},{text:UserManager.messages["confirm.no"],click:function(){$("#remove-user-dialog").dialog("close") |
| }}]}); |
| $("#remove-user-dialog").dialog("open"); |
| return false |
| }); |
| $("a#add_property").click(function(b){$("#add-property-dialog").dialog({autoOpen:false,height:"auto",width:350,modal:true,resizable:false,buttons:[{text:UserManager.messages["button.add"],click:function(){var f,d,c,e; |
| f=$("#add-property-form"); |
| if(!f.valid()){return false |
| }d=$("#newPropName").val(); |
| c=d; |
| $("#updateSubmitBtns").before('<div class="prop-line ui-helper-clearfix"><label for="'+d+'">'+c+':</label> <input id="'+d+'" type="text" name="'+d+'" /> <a href="#" class="remove-property" title="'+UserManager.messages["tooltip.removeProperty"]+'"><span class="ui-icon ui-icon-circle-close"></span></a></div>'); |
| e=$("#updateSubmitBtns").prev(); |
| e.find("a.remove-property").hover(function(){$(this).addClass("ui-state-hover") |
| },function(){$(this).removeClass("ui-state-hover") |
| }).click(function(g){var h=$(g.currentTarget.parentNode); |
| h.hide("slow",function(){h.remove() |
| }); |
| return false |
| }); |
| $("#add-property-dialog").dialog("close"); |
| e.find("input").focus() |
| }}]}); |
| $("#newPropName").val(""); |
| $("#add-property-dialog").dialog("open"); |
| return false |
| }); |
| $("#add-property-form").submit(function(c){var b=$("#add-property-dialog").dialog("option","buttons"); |
| b[0].click(); |
| return false |
| }).validate({rules:{name:"required"}}) |
| }}; |
| UserManager.User.UpdatePassword={init:function(){$("button#updatePasswordBtn").button(); |
| $("#update-password-form").validate({rules:{oldPwd:"required",newPwd:"required",newPwdConfirm:{equalTo:"#newPwd"}}}); |
| $("#update-password-form input[type='password']").val(""); |
| $("button#updatePasswordBtn").click(function(d){var b,a,c; |
| b=$("#update-password-form"); |
| if(!b.valid()){return false |
| }a=b.attr("action"); |
| a=a.substring(0,a.length-4)+"json"; |
| $("#pwdRedirect").attr("disabled",true); |
| c=b.serialize(); |
| $("#pwdRedirect").removeAttr("disabled"); |
| $("#update-password-body div.info-msg-block").hide(); |
| $.ajax({url:a,type:"POST",data:c,success:function(e,g,f){$("#update-password-form input[type='password']").val(""); |
| $("#update-password-body span.info-msg-text").html(UserManager.messages["user.pwd.updated.msg"]); |
| $("#update-password-body div.info-msg-block").show() |
| },error:UserManager.ErrorDlg.errorHandler}); |
| return false |
| }) |
| }}; |
| $(function(){$(".noscript-hide").removeClass("noscript-hide"); |
| if($("#sidebar-nav").length>0){UserManager.SideBar.init() |
| }if($("#find-authorizables-form").length>0){UserManager.Authorizables.init() |
| }if($("#update-group-form").length>0){UserManager.Group.Update.init() |
| }if($("#create-group-form").length>0){UserManager.Group.Create.init() |
| }if($("#update-user-form").length>0){UserManager.User.Update.init() |
| }if($("#update-password-form").length>0){UserManager.User.UpdatePassword.init() |
| }if($("#create-user-form").length>0){UserManager.User.Create.init() |
| }}); |