/**
* 使用方法:
* 开启:maskutil.mask();
* 关闭:maskutil.unmask();
*
* maskutil.mask('其它提示文字...');
*/
var maskutil = (function(){
var $mask,$maskmsg;
var defmsg = '正在处理...';
function init(){
if(!$mask){
$mask = $("
")
.css({
'position' : 'absolute'
,'left' : '0'
,'top' : '0'
,'width' : '100%'
,'height' : '100%'
,'opacity' : '0.3'
,'filter' : 'alpha(opacity=30)'
,'display' : 'none'
,'background-color': '#ccc'
})
.appendto("body");
}
if(!$maskmsg){
$maskmsg = $(" 正在处理,请稍后。。。
")
.css({
'position': 'absolute'
,'top': '50%'
,'margin-top': '-20px'
,'padding': '5px 20px 5px 20px'
,'width': 'auto'
,'border-width': '1px'
,'border-style': 'solid'
,'display': 'none'
,'background-color': '#ffffff'
,'font-size':'14px'
})
.appendto("body");
}
$mask.css({width:"100%",height:$(document).height()});
var scrolltop = $(document.body).scrolltop();
$maskmsg.css({
left:( $(document.body).outerwidth(true) - 190 ) / 2
,top:( ($(window).height() - 45) / 2 ) + scrolltop
});
}
return {
mask:function(msg){
init();
$mask.show();
$maskmsg.append().show();
}
,unmask:function(){
$mask.hide();
$maskmsg.hide();
}
}
}());