var showalert = function(msg,modeltype=0){ jalert(msg, "温馨提示",null,modeltype); } window.alert=showalert; window.countertimer={}; $.alerts={ verticaloffset:-75, horizontaloffset:0, repositiononresize:true, overlayopacity:0.5, overlaycolor:'#fff', draggable:true, okbutton: ( typeof js_comm_alert_okbutton != "undefined" ? js_comm_alert_okbutton : ' 确定 '), cancelbutton: ( typeof js_comm_alert_cancelbutton != "undefined" ? js_comm_alert_cancelbutton : ' 取消 '), dialogclass:null ,alert:function(message,title,callback){ if(title==null)title='alert'; if(callback){ $.alerts._show(title,message,null,'confirm',function(result){ if(callback)callback(result); }); }else{ $.alerts._show(title,message,null,'alert',function(result){ if(callback)callback(result); }); } } ,_show:function(title,msg,value,type,callback){ $.alerts._hide(); $.alerts._overlay('show'); $("body").append(''); if($.alerts.dialogclass)$("#popup_container").addclass($.alerts.dialogclass); var pos=('undefined' == typeof(document.body.style.maxheight))?'absolute':'fixed'; $("#popup_container").css({ //position:pos,zindex:99999,padding:0,margin:0 }); $("#popup_title").text(title); $("#popup_content").addclass(type); $("#popup_message").text(msg); $("#popup_message").html($("#popup_message").text().replace(/\n/g,'
')); $("#popup_container").css({ //minwidth:$("#popup_container").outerwidth(),maxwidth:$("#popup_container").outerwidth(), //minwidth:'290px',maxwidth:'290px', }); $.alerts._reposition(); $.alerts._maintainposition(true); switch(type){ case'alert': if(msg.indexof('已经')>-1 || msg.indexof('成功')>-1 || msg.indexof('发送')>-1 || msg.indexof('支持')>-1){ $("#popup_content").css('background','url(/exusers/images/170317/check.png) no-repeat 50% 20px'); }else{ $("#popup_content").css('background','url(/exusers/images/170317/warning.png) no-repeat 50% 20px'); } if(msg.indexof('频繁发送')>-1){ $("#popup_content").css('background','url(/exusers/images/170317/warning.png) no-repeat 50% 20px'); } $("#popup_content").css('background-size','60px'); $("#popup_message").append(''); $("#popup_ok").click(function(){ $.alerts._hide(); callback(true) }); $("#popup_ok").focus().keypress(function(e){ if(e.keycode==13||e.keycode==27)$("#popup_ok").trigger('click') }); break case'confirm': if(msg.indexof('成功')>-1 || msg.indexof('发送到')>-1){ $("#popup_content").css('background','url(/exusers/images/170317/check.png) no-repeat 50% 20px'); $("#popup_content").css('background-size','60px'); }else{ $("#popup_content").css('background','url(/exusers/images/170317/warning.png) no-repeat 50% 20px'); $("#popup_content").css('background-size','60px'); } $("#popup_message").append(''); $("#popup_ok").click(function(){ $.alerts._hide(); callback(true) }); $("#popup_cancel").click(function(){ $.alerts._hide(); callback(false) }); $("#popup_ok").focus().keypress(function(e){ if(e.keycode==13||e.keycode==27)$("#popup_ok").trigger('click') }); break }; if($.alerts.draggable){ try{ $("#popup_container").draggable({ handle:$("#popup_title") }); $("#popup_title").css({ cursor:'move' }) } catch(e){} } } ,_canlogin:function(msg,title,type,islogin){ $.alerts._hide(); $.alerts._overlay('show',1); $("body").append(''); if($.alerts.dialogclass)$("#popup_container").addclass($.alerts.dialogclass); var pos=('undefined' == typeof(document.body.style.maxheight))?'absolute':'fixed'; $("#popup_title").text(title); $("#popup_content").addclass(type); $("#popup_message").text(msg); $("#popup_message").html($("#popup_message").text().replace(/\n/g,'
')); $.alerts._reposition(); $.alerts._maintainposition(true); if(msg.indexof('成功')>-1 || msg.indexof('发送到')>-1){ $("#popup_content").css('background','url(/exusers/images/170317/check.png) no-repeat 50% 20px'); $("#popup_content").css('background-size','60px'); }else{ $("#popup_content").css('background','url(/exusers/images/170317/warning.png) no-repeat 50% 20px'); $("#popup_content").css('background-size','60px'); } var login_txt = (typeof js_comm_alert_login != "undefined") ? js_comm_alert_login : '登录'; var goreturn_txt = typeof js_comm_alert_goreturn != "undefined" ? js_comm_alert_goreturn : '返回'; if(islogin == 2) { $("#popup_message").append(''); }else{ $("#popup_message").append(''); } $("#popup_cancel").click(function(){ history.back(); }); $("#popup_ok").focus().keypress(function(e){ if(e.keycode==13||e.keycode==27)$("#popup_ok").trigger('click') }); if($.alerts.draggable){ try{ $("#popup_container").draggable({ handle:$("#popup_title") }); $("#popup_title").css({ cursor:'move' }) } catch(e){} } } ,_hide:function(){ $("#popup_container").remove(); $.alerts._overlay('hide'); $.alerts._maintainposition(false) } ,_overlay:function(status,type){ switch(status){ case'show':$.alerts._overlay('hide'); $("body").append(''); if(type == 1) { $("#popup_overlay").css({ position:'fixed',zindex:99999,top:'0px',left:'0px',width:'100%',height:$(document).height(),background:'#fff',opacity:1 }); }else{ $("#popup_overlay").css({ position:'absolute',zindex:99998,top:'0px',left:'0px',width:'100%',height:$(document).height(),background:$.alerts.overlaycolor,opacity:$.alerts.overlayopacity }); } break; case'hide':$("#popup_overlay").remove(); break } } ,_reposition:function(){ var top=(($(window).height()/ 2) - ($("#popup_container").outerheight() /2))+$.alerts.verticaloffset; var left=(($(window).width()/ 2) - ($("#popup_container").outerwidth() /2))+$.alerts.horizontaloffset; if(top<0)top=0; if(left<0)left=0; if('undefined' == typeof(document.body.style.maxheight))top=top+$(window).scrolltop(); $("#popup_container").css({ //top:top+'px',left:left+'px' //top:'50px',left:left+'px' }); $("#popup_overlay").height($(document).height()) } ,_maintainposition:function(status){ if($.alerts.repositiononresize){ switch(status){ case true:$(window).bind('resize',function(){ $.alerts._reposition() }); break; case false:$(window).unbind('resize'); break } } } }; jalert=function(message,title,callback,modeltype){ if(modeltype) { $.alerts._canlogin(message,title,null,modeltype) }else{ $.alerts.alert(message,title,callback) } }