腾讯弹窗插件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html  xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta  http-equiv = "Content-Type"  content = "text/html;charset=utf-8"  />
< title >无标题文档</ title >
< link  rel = "stylesheet"  href = "msgbox.css"  />
< script  type = "text/javascript"  src = "msgbox.js" ></ script >
< script >
function clickme(i){
     var tip = "";
     switch(i){
         case 1:
             tip = "服务器繁忙,请稍后再试。";
         break;
         case 4:
             tip = "设置成功!";
         break;
         case 5:
             tip = "数据拉取失败";
         break;
         case 6:
             tip = "正在加载中,请稍后...";
         break;
     }
     ZENG.msgbox.show(tip, i);
}
function clickhide(){
     ZENG.msgbox._hide();
}
function clickautohide(i){
     var tip = "";
     switch(i){
         case 1:
             tip = "服务器繁忙,请稍后再试。";
         break;
         case 4:
             tip = "设置成功!";
         break;
         case 5:
             tip = "数据拉取失败";
         break;
         case 6:
             tip = "正在加载中,请稍后...";
         break;
     }
     ZENG.msgbox.show(tip, i, 3000);
}
</ script >
</ head >
 
< body >
< p >4种不同提示图标</ p >
< input  type = "button"  value = "图标1"  onclick = "clickme(1)"  />
< input  type = "button"  value = "图标4"  onclick = "clickme(4)"  />
< input  type = "button"  value = "图标5"  onclick = "clickme(5)"  />
< input  type = "button"  value = "图标6"  onclick = "clickme(6)"  />
< p >隐藏</ p >
< input  type = "button"  value = "隐藏"  onclick = "clickhide()"  />
< p >3秒后自动隐藏</ p >
< input  type = "button"  value = "图标1"  onclick = "clickautohide(1)"  />
< input  type = "button"  value = "图标4"  onclick = "clickautohide(4)"  />
< input  type = "button"  value = "图标5"  onclick = "clickautohide(5)"  />
< input  type = "button"  value = "图标6"  onclick = "clickautohide(6)"  />
< div  class = "zeng_msgbox_layer_wrap"  id = "q_Msgbox"  style = "top:100px;display:block" >
< span  class = "zeng_msgbox_layer"  style = "z-index:10000"  id = "mode_tips_v2" >
< span  class = "gtl_ico_hits" ></ span >您当前没有任何修改< span  class = "gtl_end" ></ span ></ span ></ div >
< div  class = "zeng_msgbox_layer_wrap"  id = "q_Msgbox"  style = "top:200px;display:block" >
< span  class = "zeng_msgbox_layer"  style = "z-index:10000"  id = "mode_tips_v2" >
< span  class = "gtl_ico_fail" ></ span >服务器出错了< span  class = "gtl_end" ></ span ></ span ></ div >
< div  class = "zeng_msgbox_layer_wrap"  id = "q_Msgbox"  style = "top:300px;display:block" >
< span  class = "zeng_msgbox_layer"  style = "z-index:10000"  id = "mode_tips_v2" >
< span  class = "gtl_ico_succ" ></ span >恭喜,添加成功!< span  class = "gtl_end" ></ span ></ span ></ div >
< div  style = "top:400px;display:block"  id = "q_Msgbox"  class = "zeng_msgbox_layer_wrap" >
< span  id = "mode_tips_v2"  style = "z-index:10000"  class = "zeng_msgbox_layer" >
< span  class = "gtl_ico_clear" ></ span >< span  class = "gtl_ico_loading" ></ span >正在加载中,请稍后...< span  class = "gtl_end" ></ span ></ span ></ div >
< div  class = "zeng_msgbox_layer_wrap"  id = "q_Msgbox"  style = " display:block" ></ div >
</ body >
</ html >

CSS文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@charset  "utf-8" ;
/* CSS Document */
 
.zeng_msgbox_layer,
.zeng_msgbox_layer .gtl_ico_succ,
.zeng_msgbox_layer .gtl_ico_fail,
.zeng_msgbox_layer .gtl_ico_hits,
.zeng_msgbox_layer .gtl_ico_clear,
.zeng_msgbox_layer .gtl_end{ display :inline- block ; height : 54px ; line-height : 54px ;
font-weight : bold ; font-size : 14px ; color : #606060 ;
background-image : url ( "gb_tip_layer.png" ); _background-image : url ( "gb_tip_layer_ie6.png" ); background-repeat : no-repeat }
.zeng_msgbox_layer_wrap{ width : 100% ; position : fixed ; _position : absolute ; top : 46% ; left : 0 ; text-align : center ; z-index : 65533 }
.zeng_msgbox_layer{ background-position : 0  -161px ; background-repeat : repeat-x ; padding : 0  18px  0  9px ; margin : 0  auto ; position : relative }
.zeng_msgbox_layer .gtl_ico_succ{ background-position : -6px  0 ; left : -45px ; top : 0 ; width : 45px ; position : absolute }
.zeng_msgbox_layer .gtl_end{ background-position : 0  0 ; position : absolute ; right : -6px ; top : 0 ; width : 6px }
.zeng_msgbox_layer .gtl_ico_fail{ background-position : -6px  -108px ; position : absolute ; left : -45px ; top : 0 ; width : 45px }
.zeng_msgbox_layer .gtl_ico_hits{ background-position : -6px  -54px ; position : absolute ; left : -45px ; top : 0 ; width : 45px }
.zeng_msgbox_layer .gtl_ico_clear{ background-position : -6px  0 ; left : -5px ; width : 5px ; position : absolute ; top : 0 }
.zeng_msgbox_layer .gtl_ico_loading{  width : 16px ; height : 16px ; border : 0 ;
background-image : url (loading.gif); float : left ; margin : 19px  10px  0  5px }

msgbox.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

window.ZENG=window.ZENG || {};
 
ZENG.dom = {getById:  function (id) {
         return  document.getElementById(id);
     },get:  function (e) {
         return  ( typeof  (e) ==  "string" ) ? document.getElementById(e) : e;
     },createElementIn:  function (tagName, elem, insertFirst, attrs) {
         var  _e = (elem = ZENG.dom.get(elem) || document.body).ownerDocument.createElement(tagName ||  "div" ), k;
         if  ( typeof  (attrs) ==  'object' ) {
             for  (k  in  attrs) {
                 if  (k ==  "class" ) {
                     _e.className = attrs[k];
                 else  if  (k ==  "style" ) {
                     _e.style.cssText = attrs[k];
                 else  {
                     _e[k] = attrs[k];
                 }
             }
         }
         insertFirst ? elem.insertBefore(_e, elem.firstChild) : elem.appendChild(_e);
         return  _e;
     },getStyle:  function (el, property) {
         el = ZENG.dom.get(el);
         if  (!el || el.nodeType == 9) {
             return  null ;
         }
         var  w3cMode = document.defaultView && document.defaultView.getComputedStyle, computed = !w3cMode ?  null 
         document.defaultView.getComputedStyle(el,  '' ), value =  "" ;
         switch  (property) {
             case  "float" :
                 property = w3cMode ?  "cssFloat"  "styleFloat" ;
                 break ;
             case  "opacity" :
                 if  (!w3cMode) {
                     var  val = 100;
                     try  {
                         val = el.filters[ 'DXImageTransform.Microsoft.Alpha' ].opacity;
                     catch  (e) {
                         try  {
                             val = el.filters( 'alpha' ).opacity;
                         catch  (e) {
                         }
                     }
                     return  val / 100;
                 else  {
                     return  parseFloat((computed || el.style)[property]);
                 }
                 break ;
             case  "backgroundPositionX" :
                 if  (w3cMode) {
                     property =  "backgroundPosition" ;
                     return  ((computed || el.style)[property]).split( " " )[0];
                 }
                 break ;
             case  "backgroundPositionY" :
                 if  (w3cMode) {
                     property =  "backgroundPosition" ;
                     return  ((computed || el.style)[property]).split( " " )[1];
                 }
                 break ;
         }
         if  (w3cMode) {
             return  (computed || el.style)[property];
         else  {
             return  (el.currentStyle[property] || el.style[property]);
         }
     },setStyle:  function (el, properties, value) {
         if  (!(el = ZENG.dom.get(el)) || el.nodeType != 1) {
             return  false ;
         }
         var  tmp, bRtn =  true , w3cMode = (tmp = document.defaultView) && tmp.getComputedStyle, 
         rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
         if  ( typeof  (properties) ==  'string' ) {
             tmp = properties;
             properties = {};
             properties[tmp] = value;
         }
         for  ( var  prop  in  properties) {
             value = properties[prop];
             if  (prop ==  'float' ) {
                 prop = w3cMode ?  "cssFloat"  "styleFloat" ;
             else  if  (prop ==  'opacity' ) {
                 if  (!w3cMode) {
                     prop =  'filter' ;
                     value = value >= 1 ?  ''  : ( 'alpha(opacity='  + Math.round(value * 100) +  ')' );
                 }
             else  if  (prop ==  'backgroundPositionX'  || prop ==  'backgroundPositionY' ) {
                 tmp = prop.slice(-1) ==  'X'  'Y'  'X' ;
                 if  (w3cMode) {
                     var  v = ZENG.dom.getStyle(el,  "backgroundPosition"  + tmp);
                     prop =  'backgroundPosition' ;
                     typeof  (value) ==  'number'  && (value = value +  'px' );
                     value = tmp ==  'Y'  ? (value +  " "  + (v ||  "top" )) : ((v ||  'left' ) +  " "  + value);
                 }
             }
             if  ( typeof  el.style[prop] !=  "undefined" ) {
                 el.style[prop] = value + ( typeof  value ===  "number"  && !rexclude.test(prop) ?  'px'  '' );
                 bRtn = bRtn &&  true ;
             else  {
                 bRtn = bRtn &&  false ;
             }
         }
         return  bRtn;
     },getScrollTop:  function (doc) {
         var  _doc = doc || document;
         return  Math.max(_doc.documentElement.scrollTop, _doc.body.scrollTop);
     },getClientHeight:  function (doc) {
         var  _doc = doc || document;
         return  _doc.compatMode ==  "CSS1Compat"  ? _doc.documentElement.clientHeight : _doc.body.clientHeight;
     }
};
 
ZENG.string = {RegExps: {trim: /^s+|s+$/g,ltrim: /^s+/,rtrim: /s+$/,nl2br: /n/g,s2nb: /[x20]{2}/g,
URIencode: /[x09x0Ax0Dx20x21-x29x2Bx2Cx2Fx3A-x3Fx5B-x5Ex60x7B-x7E]/g,escHTML: 
{re_amp: /&/g,re_lt: /</g,re_gt: />/g,re_apos: /x27/g,re_quot: /x22/g},escString: 
{bsls:  //g,sls: ///g,nl: /n/g,rt: /r/g,tab: /t/g},restXHTML: 
{re_amp: /&/g,re_lt: /&lt;/g,re_gt: /&gt;/g,re_apos: /&(?:apos| #0?39);/g,re_quot: /&quot;/g},
write: /{(d{1,2})(?::([xodQqb]))?}/g,isURL: /^(?:ht|f)tp(?:s)?: //(?:[w-.]+).w+/i,cut: /[x00-xFF]/,getRealLen: 
{r0: /[^x00-xFF]/g,r1: /[x00-xFF]/g},format: /{([dw.]+)}/g},commonReplace:  function (s, p, r) {
         return  s.replace(p, r);
     },format:  function (str) {
         var  args = Array.prototype.slice.call(arguments), v;
         str = String(args.shift());
         if  (args.length == 1 &&  typeof  (args[0]) ==  'object' ) {
             args = args[0];
         }
         ZENG.string.RegExps.format.lastIndex = 0;
         return  str.replace(ZENG.string.RegExps.format,  function (m, n) {
             v = ZENG.object.route(args, n);
             return  v === undefined ? m : v;
         });
     }};
 
 
ZENG.object = {
     routeRE: /([dw_]+)/g,
     route:  function (obj, path) {
         obj = obj || {};
         path = String(path);
         var  r = ZENG.object.routeRE, m;
         r.lastIndex = 0;
         while  ((m = r.exec(path)) !==  null ) {
             obj = obj[m[0]];
             if  (obj === undefined || obj ===  null ) {
                 break ;
             }
         }
         return  obj;
     }};
 
 
 
var  ua = ZENG.userAgent = {}, agent = navigator.userAgent;
ua.ie = 9 - ((agent.indexOf( 'Trident/5.0' ) > -1) ? 0 : 1) - (window.XDomainRequest ? 0 : 1) - (window.XMLHttpRequest ? 0 : 1);
 
 
 
if  ( typeof  (ZENG.msgbox) ==  'undefined' ) {
     ZENG.msgbox = {};
}
ZENG.msgbox._timer =  null ;
ZENG.msgbox.loadingAnimationPath = ZENG.msgbox.loadingAnimationPath || ( "loading.gif" );
ZENG.msgbox.show =  function (msgHtml, type, timeout, opts) {
     if  ( typeof  (opts) ==  'number' ) {
         opts = {topPosition: opts};
     }
     opts = opts || {};
     var  _s = ZENG.msgbox,
      template =  '<span class="zeng_msgbox_layer" style="display:none;z-index:10000;" id="mode_tips_v2">
      <span class="gtl_ico_{type}"></span>{loadIcon}{msgHtml}
      <span class="gtl_end"></span></span>'
      loading =  '<span class="gtl_ico_loading"></span>' , typeClass = [0, 0, 0, 0,  "succ" "fail" "clear" ], mBox, tips;
     _s._loadCss && _s._loadCss(opts.cssPath);
     mBox = ZENG.dom.get( "q_Msgbox" ) || ZENG.dom.createElementIn( "div" , document.body,  false , {className:  "zeng_msgbox_layer_wrap" });
     mBox.id =  "q_Msgbox" ;
     mBox.style.display =  "" ;
     mBox.innerHTML = ZENG.string.format(template, 
     {type: typeClass[type] ||  "hits" ,msgHtml: msgHtml ||  "" ,loadIcon: type == 6 ? loading :  "" });
     _s._setPosition(mBox, timeout, opts.topPosition);
};
ZENG.msgbox._setPosition =  function (tips, timeout, topPosition) {
     timeout = timeout || 5000;
     var  _s = ZENG.msgbox, bt = ZENG.dom.getScrollTop(), ch = ZENG.dom.getClientHeight(), t = Math.floor(ch / 2) - 40;
     ZENG.dom.setStyle(tips,  "top"
     ((document.compatMode ==  "BackCompat"  || ZENG.userAgent.ie < 7) ? bt : 0) + (( typeof  (topPosition) ==  "number" ) ? topPosition : t) +  "px" );
     clearTimeout(_s._timer);
     tips.firstChild.style.display =  "" ;
     timeout && (_s._timer = setTimeout(_s.hide, timeout));
};
ZENG.msgbox.hide =  function (timeout) {
     var  _s = ZENG.msgbox;
     if  (timeout) {
         clearTimeout(_s._timer);
         _s._timer = setTimeout(_s._hide, timeout);
     else  {
         _s._hide();
     }
};
ZENG.msgbox._hide =  function () {
     var  _mBox = ZENG.dom.get( "q_Msgbox" ), _s = ZENG.msgbox;
     clearTimeout(_s._timer);
     if  (_mBox) {
         var  _tips = _mBox.firstChild;
         ZENG.dom.setStyle(_mBox,  "display" "none" );
     }
};
插件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值