/** * 信息提醒,不依赖任何乱七八糟框架及其他文件,导入 msg.js ,msg.info('哈哈哈') 一句代码使用! * 作者:管雷鸣 * 个人网站:www.guanleiming.com * 个人微信: xnx3com * 公司:潍坊雷鸣云网络科技有限公司 * 公司官网:www.leimingyun.com */ var msg = { /** * 成功的提醒 * @param text 提示文字 * @param func 关闭提示后,要执行的方法 */ success:function(text,func){ this.show(text, ''); this.delayclose(1500, func); }, /** * 失败、错误的提醒 * @param text 提示文字 * @param func 关闭提示后,要执行的方法 */ failure:function(text, func){ this.show(text, ''); this.delayclose(2500, func); }, /** * 提示信息 * @param text 提示文字 * @param func 关闭提示后,要执行的方法 */ info:function(text, func){ this.show(text, ''); this.delayclose(2500, func); }, /** * 弹出询问选择框:确定、取消 */ confirm:function(text){ return confirm(text); }, /** * 加载中、等待中的动画效果 * @param text 提示文字 */ loading:function(text){ this.show(text, ''); }, /** * 关闭各种提示,包括加载中、成功、失败、提示信息等,都可以用此强制关闭 */ close:function(){ var loadingdiv = document.getelementbyid('wangmarket_loading'); if(loadingdiv != null){ var loadingdivparent = loadingdiv.parentnode; if(loadingdivparent != null){ loadingdivparent.removechild(loadingdiv); } } }, /** * 延迟几秒后关闭弹出提示 * @param time 延迟多长时间,单位是毫秒 * @param func 关闭提示后,要执行的方法 */ delayclose(time, func){ settimeout(function(){ msg.close(); if(func != null){ func(); } },time); }, /** * 显示提示窗口,私有方法 * text 提示文字 * img 显示的图片或者svg */ show(text, img){ /** 是否是横向显示 **/ var wangmarket_loading_hengxiang = false; if(text != null && text.length > 10){ wangmarket_loading_hengxiang = true; } /** 显示前,如果还有其他正在显示的,将其都关掉 **/ this.close(); if(document.getelementsbytagname("body") != null && document.getelementsbytagname("body").length > 0){ var div=document.createelement("div"); div.id = 'wangmarket_loading'; div.style = 'position: fixed;z-index: 2147483647;margin: 0 auto;text-align: center;width: 100%;'; div.innerhtml = '' +'
' +'
' +''+img+'
' +'
'+text+'
' +'
'; +''; document.getelementsbytagname("body")[0].appendchild(div); } } }