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(){var t=document.createElement("div"),r,i,n;return t.className="obj rolebg",r=document.createElement("div"),t.appendChild(r),i=document.createElement("span"),t.appendChild(i),n=document.createElement("input"),n.type="text",n.id="newName",n.value="新建角色",n.onfocus=function(){this.select()},n.onblur=doCreateRole,n.onkeydown=chkEnter,i.appendChild(n),$f("objsDiv").appendChild(t),$f("newName").focus(),!1}function doCreateRole(){var n=$.trim(this.value);if(n=="")return this.focus(),!1;this.disabled="disabled";PageMethods.addRole(n,createRole_callback)}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 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")}})