278 lines
9.2 KiB
JavaScript
278 lines
9.2 KiB
JavaScript
function ASMain(data){
|
||
window.dialog = dialog;
|
||
var body = $("body"),
|
||
menu = $("#main_menu"),
|
||
main_top = $("#main_top"),
|
||
sys = $("#main_sys"),
|
||
bottom = $("#main_bottom"),
|
||
board = $("#main_board"),
|
||
allMenu = board.next().show();
|
||
|
||
function bgiframeshow(obj){
|
||
return obj.show().bgiframe({conditional:/MSIE/.test(navigator.userAgent) || "ActiveXObject" in window});
|
||
}
|
||
|
||
/**
|
||
* @return
|
||
* true 打开成功
|
||
* false 打开失败
|
||
*/
|
||
function openMenu(mid){
|
||
if(!data.menu[mid]) return false;
|
||
var sParas = data.menu[mid][1]+"&_SYSTEM_MENU_FALG=0";
|
||
//AsControl.OpenView("/AppMain/MenuRedirector.jsp", "Title="+data.menu[mid][3]+"&ToDestroyAllComponent=N&Url="+data.menu[mid][0]+"&Paras="+sParas.replace(/\&/g, "~"), "_top");
|
||
//以tab方式打开操作的页面
|
||
var tabid=$(window.frames["right"].document).find("#tabs_button_T01");
|
||
if(tabid.length==0){
|
||
sParas=sParas.replace(/&/g,"~");
|
||
AsControl.OpenView("/AppMain/MenuTabContainer.jsp", "isAddMain=true&Title="+data.menu[mid][3]+"&ToDestroyAllComponent=N&Url="+data.menu[mid][0]+"&Paras="+sParas, "right");
|
||
}else{
|
||
var tWin=window.frames["right"];
|
||
if(typeof tWin.addTabItem == "function"){
|
||
var text=data.menu[mid][3];
|
||
var sURL=data.menu[mid][0];
|
||
var sPara=sParas;
|
||
tWin.addTabItem(text, sURL,sPara);
|
||
}
|
||
}
|
||
window.onbeforeunload = function (){
|
||
var bx =(event.screenX+24-top.screenLeft-top.document.documentElement.scrollWidth) > 0 && (event.screenX-top.screenLeft-top.document.documentElement.scrollWidth) < 0;
|
||
var by =(event.clientY+24<0);
|
||
//alert(bx+"|"+by+"|"+event.altKey+location.href);
|
||
//if((bx&&by) || event.altKey) {window.open("<%=sWebRootPath%>/Frame/page/sys/SessionOut.jsp","_top","");}
|
||
};
|
||
return true;
|
||
}
|
||
window.openMenu = openMenu;
|
||
|
||
menu.find("a").prepend("<span class=\"index\"></span>").append("<span class=\"index\"></span><span class=\"index\"></span><span class=\"index\"></span>").attr("href", "javascript:void(0);").click(function(){
|
||
if(openMenu(this.getAttribute("mid"))){
|
||
var ul = $(this).parent().parent();
|
||
if(!ul.parent().is(menu)) ul.hide();
|
||
}
|
||
return false;
|
||
});
|
||
|
||
menu.find("li").each(function(){
|
||
if($(">ul", this).length == 1)
|
||
$(this).addClass("main_menuf");
|
||
}).add(sys.find("li")).hover(function(){
|
||
bgiframeshow($(">ul", this));
|
||
}, function(){
|
||
$(">ul", this).hide();
|
||
});
|
||
|
||
allMenu.click(function(){
|
||
board.hide();
|
||
allMenu.hide();
|
||
});
|
||
var alis = allMenu.find(">div").click(function(e){
|
||
AsLink.stopEvent(e);
|
||
}).find("ul:first >li");
|
||
alis.find("a").attr("href", "javascript:void(0);").click(function(){
|
||
if(openMenu(this.getAttribute("mid"))){
|
||
board.hide();
|
||
allMenu.hide();
|
||
}
|
||
return false;
|
||
});
|
||
var widths = new Array(4);
|
||
var heights = new Array(parseInt((alis.length + widths.length-1)/widths.length));
|
||
alis.each(function(i){
|
||
var width = $(this).width(),
|
||
height = $(this).height(),
|
||
m = i%widths.length,
|
||
n = parseInt(i/widths.length);
|
||
if(!widths[m] || widths[m] < width) widths[m] = width;
|
||
if(!heights[n] || heights[n] < height) heights[n] = height;
|
||
}).each(function(i){
|
||
$(this).width(widths[i%widths.length]).height(heights[parseInt(i/widths.length)]);
|
||
});
|
||
var dwidth = 21*(widths.length+1); for(var i = 0; widths[i] && i < widths.length; i++) dwidth += widths[i];
|
||
allMenu.find(">div").width(dwidth);
|
||
|
||
var lis = menu.find(">ul >li");
|
||
$("<li><a class=\"all\" href=\"javascript:void(0);\"> </a></li>").insertAfter(menu.find(">ul >li:last")).click(function(){
|
||
bgiframeshow(board);
|
||
allMenu.show();
|
||
});
|
||
allMenu.hide();
|
||
function resize(){
|
||
var width = body.width();
|
||
var height = body.height();
|
||
|
||
var mwidth = 0, mmwidth = width - menu.prev().width() - (menu.next().width()+10) - 32;
|
||
lis.show().each(function(){
|
||
if(mwidth > mmwidth || (mwidth += $(this).width()) > mmwidth){
|
||
$(this).hide();
|
||
}
|
||
});
|
||
menu.width(mmwidth);
|
||
|
||
var bheight = height;
|
||
bheight -= main_top.height();
|
||
bottom.height(bheight);
|
||
}
|
||
|
||
$(window).resize(resize);
|
||
resize();
|
||
|
||
/*(function(){
|
||
var board = $('<div class="board_board"></div>').appendTo(document.body);
|
||
var msg = $('<div class="board_msg"></div>').appendTo(board);
|
||
var min = $('<div class="min_msg"></div>').appendTo(document.body).click(function(){
|
||
$(this).hide();
|
||
board.hide();
|
||
board.slideDown(500);
|
||
});
|
||
$('<span class="rightup_msg"></span>').appendTo(board)
|
||
.append($("<a title='chat'>chat</a>").click(function(){
|
||
var win = AsControl.OpenPage("/AppMain/websocketclient.jsp", "", "NewMsgFrame", "width=1000px,height=500px");
|
||
win.focus();}))
|
||
.append($("<a title='写信'>+</a>").click(function(){
|
||
var win = AsControl.OpenPage("/Frame/page/msg/MessageInfo.jsp", "", "NewMsgFrame", "width=1000px,height=300px,left="+(screen.availHeight-1000)/2+"px,top="+(screen.availHeight-300)/2+"px,toolbar=no,scrollbars=yes,resizable=yes,status=no,menubar=no");
|
||
win.focus();}))
|
||
.append($("<a title='列表' >≡</a>").click(function(){
|
||
AsDialog.PopView("/Frame/page/msg/MessageView.jsp", "", "dialogWidth:1000px;dialogHeight:460px;resizable:yes;maximize:yes;help:no;status:no;");
|
||
msg.empty();
|
||
getMsg();}))
|
||
.append($("<a title='最小化' >-</a>").click(function(){
|
||
board.show().slideUp(function(){
|
||
min.show();
|
||
});
|
||
}));
|
||
|
||
function getA(data){
|
||
var icon = "";
|
||
if(data["IsNew"]) icon += '<span class="new_msg"> </span>';
|
||
return $('<a href="javascript:void(0);" hidefocus >'+data["MessageTitle"]+icon+'</a>').click(function(){
|
||
var win = AsControl.OpenPage("/Frame/page/msg/MessageInfo.jsp", "MessageId="+data["MessageId"], "ReadMsgFrame"+data["MessageId"], "width=1000px,height=570px,top=0,left=0,toolbar=no,scrollbars=yes,resizable=yes,status=no,menubar=no");
|
||
win.focus();
|
||
$(this).remove();
|
||
});
|
||
}
|
||
|
||
function getMsg(sMessageIds){
|
||
var sUrl = sWebRootPath+"/servlet/message?rand="+new Date();
|
||
if(sMessageIds) sUrl += "&MessageIds="+sMessageIds;
|
||
$.ajax({
|
||
url : sUrl,
|
||
type : "POST",
|
||
processData : false,
|
||
async : true,
|
||
success : function(text){
|
||
if(!text) return;
|
||
var datas = new Function("return "+text)();
|
||
if(datas.length == 0) return;
|
||
|
||
var messageIds = new Array();
|
||
for(var i = 0; i < datas.length; i++){
|
||
msg.prepend(getA(datas[i]));
|
||
messageIds.push(datas[i]["MessageId"]);
|
||
}
|
||
min.click();
|
||
getMsg(messageIds.join(","));
|
||
},
|
||
error_not : function(){
|
||
alert("加载消息异常,请刷新页面或请管理员协助");
|
||
}
|
||
});
|
||
}
|
||
|
||
//getMsg();
|
||
})();*/
|
||
}
|
||
function goHome(){
|
||
AsControl.OpenComp("/Main.jsp","ToDestroyAllComponent=Y","_self");
|
||
}
|
||
function ModifyPass(){
|
||
AsDialog.PopView("/AppMain/ModifyPassword.jsp","PasswordState=0","dialogHeight=400px;dialogWidth=450px;resizable=no;scrollbars=no;status:yes;maximize:no;help:no;");
|
||
}
|
||
function sessionOut(){
|
||
if(!confirm(getMessageText("AWEW1014"))) return; // 你确实要退出吗?
|
||
AsControl.OpenComp("/AppMain/SignOut.jsp","","_top");
|
||
}
|
||
function changeLang(sLang){
|
||
AsControl.RunJsp("/Frame/page/sys/tools/ChangeLang.jsp", "Lang="+sLang);
|
||
self.location.reload();
|
||
}
|
||
function restoreUserInfo(){
|
||
var result =AsControl.RunJsp("/AppConfig/ControlCenter/restoreUserInfo.jsp","");
|
||
var $result = $(result);
|
||
var param = $result.filter("span").html();
|
||
var o = param.split(",");
|
||
$("#email").val(o[0]);
|
||
$("#mobile").val(o[2]);
|
||
$("#comptel").val(o[1]);
|
||
}
|
||
function saveUserInfo(){
|
||
var email = $("#email").val();
|
||
var mobile = $("#mobile").val();
|
||
var comptel = $("#comptel").val();
|
||
if(email && !/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/.test(email)){
|
||
alert(getMessageText("AWES2051")); // Email填写错误!
|
||
restoreUserInfo();
|
||
return;
|
||
}
|
||
if(mobile && !/^[1][3|5][0-9]{9}$/.test(mobile)){
|
||
alert(getMessageText("AWES2052")); // 手机号填写错误!
|
||
restoreUserInfo();
|
||
return;
|
||
}
|
||
if(comptel && !/^([0-9]{1,3}-)?([0-9]{2,4}-)?[0-9]{7,11}(-[0-9]{1,5})?$/.test(comptel)){
|
||
alert(getMessageText("AWES2053")); // 办公电话填写错误!
|
||
restoreUserInfo();
|
||
return;
|
||
}
|
||
var sReturn = AsControl.RunJsp("/AppConfig/ControlCenter/ChangeContactInfo.jsp", "Email="+email+"&Mobile="+mobile+"&Comptel="+comptel);
|
||
if(sReturn){
|
||
alert(sReturn);
|
||
}else{
|
||
alert("操作成功!");
|
||
}
|
||
}
|
||
function saveSkin(obj){
|
||
var path = obj.getAttribute("skinPath");
|
||
var sReturn = AsControl.RunJsp("/AppConfig/ControlCenter/ReloadSkin.jsp", "Path="+path);
|
||
if(!sReturn){
|
||
changeSkin(path, top);
|
||
$(obj).css({
|
||
"background-image" : "url("+sWebRootPath+path+"/Ayes.gif)",
|
||
"color" : "#6192b8"
|
||
}).parent().siblings().find("a").each(function(){
|
||
$(this).css({
|
||
"background-image" : "url("+sWebRootPath+this.getAttribute("skinPath")+"/A.gif)",
|
||
"color" : ""
|
||
});
|
||
});
|
||
}else{
|
||
alert(sReturn);
|
||
}
|
||
}
|
||
function changeSkin(path, win){
|
||
$("link[href*='"+sSkinPath+"']", win.document).each(function(){
|
||
var href = this.href;
|
||
this.href = href.replace(sSkinPath, path)
|
||
});
|
||
for(var i = 0; i < win.frames.length; i++){
|
||
changeSkin(path, win.frames[i]);
|
||
}
|
||
win.sSkinPath = path;
|
||
}
|
||
function overSkin(obj){
|
||
var path = obj.getAttribute("skinPath");
|
||
if(path == sSkinPath){
|
||
$(obj).css("background-image", "url("+sWebRootPath+path+"/Ayeshover.gif)");
|
||
}else{
|
||
$(obj).css("background-image", "url("+sWebRootPath+path+"/Ahover.gif)");
|
||
}
|
||
}
|
||
|
||
function outSkin(obj){
|
||
var path = obj.getAttribute("skinPath");
|
||
if(path == sSkinPath){
|
||
$(obj).css("background-image", "url("+sWebRootPath+path+"/Ayes.gif)");
|
||
}else{
|
||
$(obj).css("background-image", "url("+sWebRootPath+path+"/A.gif)");
|
||
}
|
||
} |