function getNameFromObj(n){return $(n.nextSibling).text().replace(new RegExp(String.fromCharCode(160),"g")," ")}function showObjMenu(n){var i=getEventSrc(n),t;return HasPanelShowing()||(srcObj=i,$("#curRoleName").val(getNameFromObj(i)),HideAllMenu(),t=$(srcObj).parent().is(".role_locked"),$("#showAttributes").nextAll().css("display",t?"none":""),$("#anony").prev().addBack().css("display",t?"":"none"),ShowPop("menu_obj",!0,n)),CanelEvent(n)}function showBodyMenu(n){var t=$(n.srcElement||n.target),i,r;return t.is("a,.menu,.obj > div")?!1:t.is("#newName")?!0:t.is(".obj > span")&&(i=t.closest(".obj").addClass("temp"),r=within(t,n),i.removeClass("temp"),r)?(HideAllMenu(),!0):(HasPanelShowing()||(HideAllMenu(),ShowPop("menu_body",!0,n)),CanelEvent(n))}function listUsers(){location="users.aspx?role="+$.url.encode(getNameFromObj(srcObj))}function doDefault(n){srcObj=getEventSrc(n);$f("curRoleName").value=getNameFromObj(srcObj);__doPostBack("showAttributes","")}function del(){if(!confirm("确定要删除该角色吗？"))return!1;var n=getNameFromObj(srcObj);return PageMethods.delRole(n,delRole_callback),!1}function delRole_callback(n){if(n==""){var t=srcObj.parentNode;t.parentNode.removeChild(t)}else alert(n)}function createRole(n){var i=document.createElement("div"),f,u,t,r,e;if(i.className="obj rolebg",f=document.createElement("div"),i.appendChild(f),u=document.createElement("span"),i.appendChild(u),t=document.createElement("input"),t.type="text",t.id="newName",n){for(r=1,e=$("#objsDiv").prop("outerHTML");e.indexOf(">"+n+"("+r+")<\/span>")>0;)r++;t.value=n+"("+r+")"}else t.value="新建角色";return t.onfocus=function(){this.select()},t.onblur=function(){var t=$.trim(this.value);if(t=="")return this.focus(),!1;this.disabled="disabled";PageMethods.addRole(t,n||null,createRole_callback)},t.onkeydown=chkEnter,u.appendChild(t),$f("objsDiv").appendChild(i),t.focus(),!1}function createRole_callback(n){var t=$f("newName"),r,u,i;n==""?(r=$(t).closest(".obj"),attMouseEvent(r),u=document.createTextNode(t.value),t.parentNode.replaceChild(u,t)):(i=t.parentNode.parentNode,i.parentNode.removeChild(i),alert(n))}function setReadLevel(){var t=$("#attr_cbRead"),n=t.is(":checked");$("#attr_infoReadLevel").css("display",n?"":"none");$("#attr_cbComment,label[for='attr_cbComment']").css("display",n?"":"none");$("#attr_cbAdmin,label[for='attr_cbAdmin']").css("display",n?"":"none")}function setBatchSend(n){$(n).parent().find("span:first").css("display",$(n).is(":checked")?"":"none")}function cloneRole(){var n=srcObj.nextSibling.firstChild,t=n.nodeValue;return createRole(t)}function renameRole(){var t=srcObj.nextSibling.firstChild,n=document.createElement("input");return n.type="text",n.id="newName",n.value=t.nodeValue,n.onfocus=function(){this.select()},n.onblur=function(){var n=this,i,r;if(n.value==oriNameNode.nodeValue)return n.parentNode.replaceChild(oriNameNode,n),!1;if(i=n.value.trim(),i=="")return n.focus(),!1;n.disabled="disabled";r=$(t).text();PageMethods.RenameRole(r,i,renameRole_callback)},n.onkeydown=chkEnter,oriNameNode=t.cloneNode(!0),t.parentNode.replaceChild(n,t),$f("newName").focus(),!1}function renameRole_callback(n){var t=$f("newName"),i;n==""?(i=document.createTextNode(t.value),t.parentNode.replaceChild(i,t)):(t.parentNode.replaceChild(oriNameNode,t),alert(n))}function ShowFilter(n,t){var i="advSearch.aspx?mode=temp"+(t?"&SessionName="+t:"")+"&tid="+n+"&readonly=true&timeStamp="+(new Date).getTime();return window.showModelessDialog?(window.showModelessDialog(i,window,"dialogHeight:400px;dialogWidth:560px;center:yes;status:no;help:0;scroll:0"),!1):toOpen(i,560,410)}var srcObj;$(function(){$(window).on("blur scroll selectstart",HideAllMenu);if($(document).click(HideAllMenu),isPc)document.oncontextmenu=showBodyMenu;else{$(document).on("mousedown",function(){$(this).data("menushown",$(".menu,#newName").is(":visible"))}).click(function(n){HideAllMenu();!$(this).data("menushown")&&$(getEventSrc(n)).is("html,body,form,.obj span")&&showBodyMenu(n)}).on("touchstart",function(){return!0});longPress(document,function(n){$(getEventSrc(n)).is("html,form,body")&&showBodyMenu(n)});$(body).addClass("noselect")}})