/* +------------------------------------------ | 搴旀煇浜鸿姹傦紝灏嗕笢瑗块兘鐢╦Q灏佽 | By Zinn +------------------------------------------ */ $.extend({ /************************************************** $.T({str:'', type:'btn', mask:1}); **************************************************/ T:function(v){ var a = $.extend({ main: '.T-bo', bo: '.TIPs' + new Date().getTime() + Math.ceil(Math.random()*100), css: 'T-Bin', outcss: 'hide', bgoutcss: 'hide', str: '', url: '', mask: 1, type: 'btn', time: 0, title: '', at: 'body', of: '', close: 0, scroll: 'no', offset: '', color: '', bgcolor: '', icon: 0, icolor: '', wh: [], xy: [0,0], style: '', min: '', max: '', click: function(){} }, v), t = { init: function() { t.bo = a.bo.substr(1); t.main = a.main.substr(1); if(a.type=='bar' && a.color=='') a.color='#fff'; if(a.type=='tv' && a.close==0) a.close=4; if(a.type=='iframe' && a.close==0) a.close=2; if(a.title) a.type=''; t.make(); t.view(); t.act(); if(a.move) t.move($(a.bo).find('.T-Bd')); t.move($(a.bo).find('.T-Bd .T-Tit')); return t; }, act: function(){ var bo = $(a.bo), bc = bo.find('.close,.T-Close'), bg = bo.find('.T-Bg'); t.obj = bo; if(a.time>0) t.CloseTime = setTimeout(function(){t.close();}, a.time+700); setTimeout(function(){t.offset()}, 1); $(a.bo).find('.T-Bd').addClass(a.css); $(window).resize(function(){t.offset()}); if($.IsIOS && a.position!='absolute'){ $(window).scroll(function(){t.offset()}); } if(a.click!='none'&&a.click!='null'){ t.onclose(bg); $(document).on('keypress', function(e){ var k=(e.keyCode ? e.keyCode : e.which); if(k=='13') bc.trigger('click'); }); } if(a.type=='img') t.onclose(bo); t.onclose(bc); if(typeof a.yes=='function') bo.find('.btnclose .yes').on('click', function(){a.yes()}); if(typeof a.no=='function') bo.find('.btnclose .no').on('click', function(){a.no()}); bo.find('.T-Con,.T-Tit,.btnclose,.T-Close,.T-Bg').I(); }, onclose: function(o){ o.on('click',function(){ t.close(); }); }, str: function(str){ $(a.bo).find('.T-Con > div').html(str); // t.act(); return t; }, view: function(){ var cl='
', ic=['','','','','',''], mi=a.min!='' ? ('
-
') : '', mx=a.max!='' ? ('
+
') : '', ht; ht = '' + (a.mask ? '
' : '') + '
' + mi + mx + cl + (a.type=='btn' ? '
OK
' : '') + (a.type=='confirm' ? '
' : '') + (a.type=='confirm' ? 'YES' : '') + (a.type=='confirm' ? 'NO' : '') + (a.type=='confirm' ? '
' : '') + (a.title ? '
'+ a.title + mi + mx + cl + '
' : '') + '
' + '
' + '
' + (a.icon ? '
' + ic[a.icon] + '
':'' ) + (a.type=='iframe' || a.type=='tv' ? '' : '
' + a.str + '
') + '
' + '
' ; if(a.type=='img'){ ht ='' + '
' + '
' + '' + '
' ; } $(a.bo).html(ht); $(a.bo).find('.T-Bg').addClass('bg'+a.mask); $(a.bo).find('.T-Bd').addClass(a.type+(a.at!='body'?' isAp':'')+(a.title?' T-Tit':' NotT-Tit')); if(a.type=='bar'||a.type=='tip'||a.type=='btn'||a.type=='confirm'||a.title!='') a.close=0; else if(a.close==0) a.close=1; $(a.bo).find('.T-Close').addClass('c'+a.close); $(a.bo).find('.T-Min').addClass('c'+a.close); $(a.bo).find('.T-Msg, .close, .tip-icon, .T-Min').css({'color': a.color}); if(a.bgcolor){ $(a.bo).find('.T-Bd-bg').addClass('isbg'); $(a.bo).find('.T-Bd-bg').css({'background': a.bgcolor}); } if(a.icon){ $(a.bo).find('.T-Con').addClass('T-Font T-Font'+a.icon); } $(a.bo).find('.T-Con').css({ 'width': a.wh[0] ? a.wh[0] : '', 'height': a.wh[1] ? a.wh[1] : '', 'overflow': a.scroll=='yes' ? 'auto' : (a.scroll=='no'&&a.type!='null' ? 'hidden' : '') }); }, offset: function(){ a.wh[1] = parseInt(a.wh[1]); if((a.wh[1]=='auto' || !a.wh[1]) && a.type!='tv' && a.type!='iframe'){ $(a.bo).find('.T-Con').css({height:'auto'}); } var bd=$(a.bo).find('.T-Bd'), wW=parseInt($(window).width()), wH=parseInt($(window).height()), sT=document.body.scrollTop || document.documentElement.scrollTop, bw=parseInt(bd.outerWidth()), bh=parseInt(bd.outerHeight()), ht=parseInt(bd.find('.T-Tit').outerHeight()), hm=parseInt(bd.find('.T-Msg').outerHeight()), left,top; if(a.at!='body'){ wW=$(a.at).outerWidth(); wH=$(a.at).outerHeight(); } hm=(a.wh[1]>hm||a.wh[1]0 ? a.wh[1] : hm; if(a.type!='tv'){ bh = hm<=wH*0.94?hm:wH*0.94; bd.find('.T-Con').height(bh); } if(hm>bh) $(a.bo).find('.T-Con').css({'overflow':'auto'}); top=wH*((wH/2.6>bh)?0.38:(wH/2>bh?0.46:0.5))-bh/2; left=wW/2-bw/2; if(a.top) top=a.top; if(a.left) left=a.left; if(a.bottom) top=wH-bh-ht-a.bottom; if(a.right) left=wW-bw-a.right; if(typeof a.xy=='object'){ top+=a.xy[1]; left+=a.xy[0]; } top=top<0?0:(top>(wH-bh)?(wH-bh):top); if(a.position=='absolute'||($.IsIOS&&a.type!='iframe'&&a.type!='tv'&&a.type!='img')){ top=parseFloat(sT)+parseFloat(wH/2.5-bh/2); bd.css({'position':'absolute','max-height':''}); }else{ // $('input').blur(); } bd.css({'top':top, 'left':left}); }, make: function(){ $(a.at).append('
'); if(a.type!='tv' && a.type!='iframe' && a.title==''){ $(a.at).find(a.main+'.isAalert').attr({'isqiangzhi':'1'}).find('.close').click(); //灏嗘彁绀烘€у脊绐楀幓鎺 $(a.bo).addClass('isAalert'); } if(a.type=='img') $(a.bo).find('.close').click(); }, move: function(obj){ var bd=$(a.bo).find('.T-Bd'), x0, y0, x1, y1, t0, l0, left, top, w0, h0, w1, h1; obj.addClass('move notcopy').on('mousedown',function(e0){ x0=e0.pageX; y0=e0.pageY; t0=parseInt(bd.css('top')); l0=parseInt(bd.css('left')); bd.addClass('notcopy'); w0=$(window).width(), h0=$(window).height(), w1=bd.outerWidth(), h1=bd.outerHeight(); if(a.at!='body'){ w0=$(a.at).outerWidth(); h0=$(a.at).outerHeight(); } $(window).off('mousemove').on('mousemove', function(e1){ x1=e1.pageX; y1=e1.pageY; left=l0+(x1-x0); top=t0+(y1-y0); if(left>0 && left0 && top