/* * author: ovsexia * version: 2.6.3 * name: Xtiper * describe: 弹层弹窗解决方案 */ ;!function(window, undefined){ var Xclass = function(config){ var that = this; //按钮失焦 that.loseblur(); //客户端 that.ifmob = /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent); //主id var rand = Math.random().toString().split('.')[1]; var mainid = 'xtiper_'+rand; that.mainid = mainid; //参数配置 config = that.namefix(config); that.c = config; var xcstr = ''; if(typeof(config.reset)!="undefined" && config.reset!==null && config.reset===false){ for(var key in config){ if(config[key]!=null){ xcstr += config[key].toString(); } } that.xcstr = that.xcstrRep(xcstr); }else{ that.xcstr = xcstr; } //关闭 if(config.model=='close'){ that.close(config.closeid); return false; } //关闭 if(config.model=='closeAll'){ that.closeAll(); return false; } //入口 that.creat(); }; Xclass.pt = Xclass.prototype; //让所有按钮失去焦点 Xclass.pt.loseblur = function(){ var button = document.getElementsByTagName('button'); if(button.length>0){ for(var i=0;i0){ for(var i=0;i' : ''; } html += c.tip+'

'; } //弹幕 else if(c.model=='danmu'){ var danmuli = document.getElementsByClassName('xtiper_danmu'); if(danmuli.length>300 || document.hidden){ return false; } html += '

'; if(c.icon){ html += c.iconFlag===true ? '' : ''; } html += c.tip+'

'; } //气泡层 else if(c.model=='tips'){ that.newelement = document.getElementById(c.element) || c.element; if(c.bgcolor){ html += '

'+c.tip+'

'; }else{ html += '

'+c.tip+'

'; } html += ''; } //弹窗层 else if(c.model=='win'){ if(c.type=='alert'){ c.btn = c.btn!=null ? c.btn : ['确定']; c.btn1 = 1==2 ? null : function(){return false;}; c.btn2 = null; c.btn3 = null; c.btn4 = null; }else if(c.type=='confirm'){ c.btn = c.btn!=null ? c.btn : ['确定','取消']; c.btn1 = c.btn1!=null ? c.btn1 : function(){return false;}; c.btn2 = c.btn2!=null ? c.btn2 : null; c.btn3 = c.btn3!=null ? c.btn3 : null; c.btn4 = c.btn4!=null ? c.btn4 : null; } xtiper_con_icon = c.icon ? ' xtiper_con_icon' : ''; var btnclass = new Array(); btnclass[0] = c.btn1!=null ? ' class="xactive"' : ''; btnclass[1] = c.btn2!=null ? ' class="xactive"' : ''; btnclass[2] = c.btn3!=null ? ' class="xactive"' : ''; btnclass[3] = c.btn4!=null ? ' class="xactive"' : ''; var btnfun = new Array(); btnfun[0] = c.btn1 ? c.btn1 : null; btnfun[1] = c.btn2 ? c.btn2 : null; btnfun[2] = c.btn3 ? c.btn3 : null; btnfun[3] = c.btn4 ? c.btn4 : null; that.btnfun = btnfun; if(c.maxWidth){ c.width = that.maxSize(c.width,c.maxWidth); } if(c.shade===true){ html += '
'; } html += '
'; html += '

'+c.title+'

'; if(c.min===true){ html += '
'; } html += '
'; html += '
'; var iconer = that.iconer(); html += '
'+iconer+'
'+c.tip; if(c.type=='alert' && c.times > 0){ c.times++; html += '('+c.times+')'; } html += '
'; html += '
    '; for(var i=0;i<4;i++){ if(c.btn[i]){ html += ''+c.btn[i]+''; } } html += '
'; } //页面层 else if(c.model=='open'){ //是否已经触发过 ifxoff = that.findxoff(); if(ifxoff===true){ return false; } if(c.maxWidth){ c.width = that.maxSize(c.width,c.maxWidth); } if(c.maxHeight){ c.height = that.maxSize(c.height,c.maxHeight); } //满屏页面不能最大化 if(c.width=='100%' && c.height=='100%'){ c.max = false; } var width = that.getsize(c.width); var height = that.getsize(c.height) || ['', '']; if(height[1]=='%'){ var bheight = window.innerHeight * height[0] / 100; height[0] = Math.round(bheight); height[1] = 'px'; } var height_css = ''; if(c.title){ height_css = ' xtit'; }else{ if(c.move=== true){ height_css = ' xmin'; } } var newcontent; var xtiper_over = ''; if(c.over===false){ xtiper_over = ' xtiper_over'; } if(c.type=='ready' || c.type=='noready'){ //内容 var fir = c.content.substr(0,1), element, content, reg; if(fir=='#'){ element = document.getElementById(c.content.substr(1, c.content.length)); }else if(fir=='.'){ element = document.getElementsByClassName(c.content.substr(1, c.content.length))[0]; }else{ return false; } if(!element){ return false; } if(c.type=='ready'){ content = element.outerHTML; //移除id reg = /\s+(id\=["'][A-z0-9_-]*["'])/g; content = content.replace(reg,''); }else{ content = element.innerHTML; reg = /\<\!\-{2}[\s\n]*([\S\s]*)[\s\n]*\-{2}\>/; var match = content.match(reg); if(!match || !match[1]){ return false; } content = match[1]; } newcontent = '
'+content+'
'; }else if(c.type=='url'){ //页面 var scrolling = 'auto'; if(c.over===false){ var scrolling = 'no'; } newcontent = '
'; }else if(c.type=='html'){ //html代码 newcontent = '
'+c.content+'
'; }else if(c.type=='photo'){ //相册 var img = document.getElementsByTagName('img'); if(img.length==0){ return false; } var photo = new Array(); for(var i=0;i'+c.index+' / '+photo.length+''; if(photo.length>1){ li += '
'; } li += '
    '; var xhref, xsrc; var xindex = c.index - 1; for(var i=0;i

    '+(xhref ? '' : '')+''+(xhref ? '' : '')+(i==xindex && that.ifmob===true ? '' : '')+'

    '; } li += '
'; newcontent = '
'+li+'
'; } if(c.shade===true){ html += '
'; } if(c.app===true){ html += '
'; if(c.title){ html += '
'+c.title+'
'; } }else{ html += '
'; if(c.title){ html += '

'+c.title+'

'; if(c.min===true){ html += '
'; } if(c.max===true){ html += '
'; } if(c.closeBtn===true){ html += '
'; } html += '
'; }else{ if(c.move===true){ html += '
'; } if(c.closeBtn===true){ html += '
'; }; } } html += newcontent; html += '
'; } //加载层 else if(c.model=='load'){ html = '
'; if(c.tip){ html += ''+c.tip+''; } html += '
'; } //面板菜单 else if(c.model=='sheet'){ var btnfun = new Array(); btnfun[0] = c.btn1 ? c.btn1 : null; btnfun[1] = c.btn2 ? c.btn2 : null; btnfun[2] = c.btn3 ? c.btn3 : null; btnfun[3] = c.btn4 ? c.btn4 : null; btnfun[4] = c.btn5 ? c.btn5 : null; btnfun[5] = c.btn6 ? c.btn6 : null; btnfun[6] = c.btn7 ? c.btn7 : null; btnfun[7] = c.btn8 ? c.btn8 : null; that.btnfun = btnfun; var align = 'xtiper_sheet_' + c.align; html += '
'; if(c.title){ html += '
'+c.title+'
'; } html += '
    '; var licon,href,target; for(var i=0;i'; }else{ if(typeof(btnfun[i])=='object'){ href = btnfun[i][0]; target = btnfun[i][1] ? btnfun[i][1] : ''; if(target && target.substr(0,1)!='_'){ target = '_'+target; } target = ' target="'+target+'"'; }else{ href = btnfun[i]; target = ''; } licon = '

    '+c.btn[i]+'

    '; } }else{ licon = '

    '+c.btn[i]+'

    '; } html += '
  • '+licon+'
  • '; } if(!c.force){ html += '
  • '+c.btnClose+'

  • '; } html += '
'; } return html; }; Xclass.pt.iconer = function(){ var that = this; var c = that.c; var html = ''; if(c.icon){ if(c.iconFlag===true){ html = ''; }else{ html = ''; } } return html; }; Xclass.pt.findxoff = function(){ var that = this; var c = that.c; var xoff = document.getElementsByClassName('xtiper'); var xoffdiv; for(var i=0;i1){ if(c.light===true){ xtipdiv.classList.add('xtiper_danmu_light'); } } } //气泡层 else if(c.model=='tips'){ xtipdiv.classList.add('xtiper_tips'); xtipdiv.classList.add('xtiper_tips_'+c.pos); xtipdiv.style.width = xtipdiv.offsetWidth + 'px'; //定位 var newelement = document.getElementById(c.element) || c.element; var S = document.documentElement.scrollTop || document.body.scrollTop; var C = newelement.getBoundingClientRect(); var W = newelement.offsetWidth; var H = newelement.offsetHeight; var dtop = S + C.top; var dleft = C.left; var B = 10; if(c.pos=='left'){ var selfWidth = xtipdiv.offsetWidth; dleft = dleft - selfWidth - B; }else if(c.pos=='right'){ dleft = dleft + W + B; }else if(c.pos=='top'){ var selfHeight = xtipdiv.offsetHeight; dtop = dtop - selfHeight - B; }else if(c.pos=='bottom'){ dtop = dtop + H + B; } xtipdiv.style.left = dleft + 'px'; xtipdiv.style.top = dtop + 'px'; } //弹窗层 else if(c.model=='win' || c.model=='open'){ xtipdiv.classList.add('xtiper_win'); if(c.shade===true){ xtipdiv.classList.add('xtiper_win_fixed'); } var maincss = c.app===true ? 'xtiper_sheet' : 'xtiper_main'; var xtiper_main = xtipdiv.getElementsByClassName(maincss)[0]; var xtiper_tit = xtipdiv.getElementsByClassName('xtiper_tit')[0]; //原始窗口大小 that.dataset(xtipdiv, 'xwidth', xtiper_main.offsetWidth); that.dataset(xtipdiv, 'xheight', xtiper_main.offsetHeight); if(c.reset===false){ that.dataset(xtipdiv, 'xreset', 1); } if(c.model=='open' && that.xcstr){ that.dataset(xtipdiv,'xcstr',that.xcstr); } if(c.min===true || c.max===true){ var xmcss = 'xmcss'; var y = 0; if(c.min===true){ y++; } if(c.max===true){ y++; } xmcss = xmcss + y; if(xtiper_tit){ xtiper_tit.classList.add(xmcss); } } var xleft, xtop; if(c.model=='win'){ var width = that.getsize(c.width); if(width && width[1]=='%'){ xleft = (100 - width[0]) / 2 + '%'; }else{ xleft = (window.innerWidth - xtiper_main.offsetWidth) / 2 + 'px'; } xtop = (window.innerHeight - xtiper_main.offsetHeight) / 2 + 'px'; xtiper_main.style.height = xtiper_main.offsetHeight + 'px'; xtiper_main.style.left = xleft; xtiper_main.style.top = xtop; }else if(c.model=='open'){ if(c.type=='ready'){ xtiper_main.getElementsByClassName('xtiper_content')[0].firstChild.style.display = ''; } if(c.app===false){ var width = that.getsize(c.width); if(c.type=='photo' && c.autoHeight===true){ var xindex = c.index - 1; var imgdiv = xtipdiv.getElementsByClassName('xtiper_photo_li')[xindex].getElementsByTagName('img')[0]; imgdiv.onload = function(){ var img = imgdiv.offsetHeight; img = img + 100; if(img > window.innerHeight){ if(c.title){ img = window.innerHeight; }else{ img = window.innerHeight - 26; } } xtop = (window.innerHeight - img) / 2; xtop = c.y ? xtop + c.y : xtop; xtop = xtop + 'px'; xtiper_main.style.height = img + 'px'; if(width[1]=='%'){ xleft = (100 - width[0]) / 2; xleft = c.x ? xleft + c.x : xleft; xleft = xleft + width[1]; }else{ xleft = (window.innerWidth - xtiper_main.offsetWidth) / 2; xleft = c.x ? xleft + c.x : xleft; xleft = xleft + 'px'; } xtiper_main.style.left = xleft; xtiper_main.style.top = xtop; } }else{ xtiper_main.style.height = xtiper_main.offsetHeight + 'px'; xtop = (window.innerHeight - xtiper_main.offsetHeight) / 2; xtop = c.y ? xtop + c.y : xtop; xtop = xtop + 'px'; } if(width[1]=='%'){ xleft = (100 - width[0]) / 2; xleft = c.x ? xleft + c.x : xleft; xleft = xleft + width[1]; }else{ xleft = (window.innerWidth - xtiper_main.offsetWidth) / 2; xleft = c.x ? xleft + c.x : xleft; xleft = xleft + 'px'; } xtiper_main.style.left = xleft; xtiper_main.style.top = xtop; } } if(c.shade===false){ xtiper_main.style.position = 'fixed'; } } //加载层 else if(c.model=='load'){ xtipdiv.classList.add('xtiper_win'); xtipdiv.classList.add('xtiper_win_fixed'); } //面板菜单 else if(c.model=='sheet'){ xtipdiv.classList.add('xtiper_win'); xtipdiv.classList.add('xtiper_win_fixed'); } if(c.zindex){ xtipdiv.style.zIndex = c.zindex; } }; //添加动画效果 Xclass.pt.on = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; setTimeout(function(){ xtipdiv.classList.add('xon'); },1); }; //后续处理 Xclass.pt.after = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; //短消息、气泡层 if(c.model=='msg' || c.model=='tips'){ //自动关闭 that.autoClose(); } //弹幕 else if(c.model=='danmu'){ that.danmuStar(); xtipdiv.addEventListener('mouseenter', function() { that.danmuStop(); }); xtipdiv.addEventListener('mouseleave', function() { that.danmuStar(); }); } //弹窗层、页面层 else if(c.model=='win' || c.model=='open'){ if(c.model=='win'){ //绑定按钮事件 var button = xtipdiv.getElementsByTagName('button'); var btnfun = that.btnfun; for(var i=0;i<4;i++){ that.bclick(button[i], btnfun[i], true); } } //绑定最小化 if(c.min){ var minbtn = xtipdiv.getElementsByClassName('xtiper_min')[0]; if(minbtn){ minbtn.addEventListener('click', function() { that.minmax('min'); }); } } //绑定最大化 if(c.max){ var maxbtn = xtipdiv.getElementsByClassName('xtiper_max')[0]; if(maxbtn){ maxbtn.addEventListener('click', function() { that.minmax('max'); }); } } //绑定鼠标拖动 if(c.move===true){ that.drag(true); } //绑定关闭按钮及遮罩点击关闭 that.shade(); //绑定键盘事件 if(c.model=='win' || c.model=='open'){ that.key(); } //自动关闭 if(c.model=='win' && c.type=='alert' && c.times>0){ that.autoClose(); } //相册按钮 if(c.type=='photo'){ that.photo(); var xindex = c.index - 1; var li = xtipdiv.getElementsByClassName('xtiper_photo_li')[xindex]; var xtiper_words = xtipdiv.getElementsByClassName('xtiper_words')[0]; xtiper_words.innerHTML = that.dataset(li, 'xtitle'); } } //加载层 else if(c.model=='load'){ //自动关闭 that.autoClose(); } //面板菜单 else if(c.model=='sheet'){ //绑定关闭按钮及遮罩点击关闭 that.shade(); var btnfun = that.btnfun; var xtipdiv_appli = xtipdiv.getElementsByClassName('xtiper_sheet_li'); var btnlen = xtipdiv_appli.length; if(!c.force){ btnlen = btnlen - 1; } //绑定按钮事件 for(var i=0;i 120){ that.close(); }else{ li[i].style.left = ''; li[i].style.top = ''; xtiper_content.style.backgroundColor = 'rgba(0,0,0,1)'; } } } } } }; Xclass.pt.photo = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; var ul = xtipdiv.getElementsByClassName('xtiper_photo_ul')[0]; var li = xtipdiv.getElementsByClassName('xtiper_photo_li'); var prev = xtipdiv.getElementsByClassName('xtiper_photo_prev')[0]; var next = xtipdiv.getElementsByClassName('xtiper_photo_next')[0]; if(prev && li.length>1){ prev.addEventListener('click', function(){ that.photoBtn('prev'); }); } if(next && li.length>1){ next.addEventListener('click', function(){ that.photoBtn('next'); }); } //移动端 if(that.ifmob===true && li.length>1){ var aa = null; var moveX1, moveX2, moveY1, moveY2, xx, yy; ul.addEventListener('touchstart', function(e){ moveX1 = e.changedTouches[0].pageX; moveY1 = e.changedTouches[0].pageY; that.touchmove(false); }); ul.addEventListener('touchmove', function(e){ moveX2 = e.changedTouches[0].pageX; moveY2 = e.changedTouches[0].pageY; xx = moveX2 - moveX1; yy = moveY2 - moveY1; if(Math.abs(xx)>Math.abs(yy)){ aa = aa ? aa : 'left'; }else{ aa = aa ? aa : 'top'; } that.ulli(li, aa, xx, yy); }); ul.addEventListener('touchend', function(e){ if(moveX1 > moveX2){ if((moveX1 - moveX2 > 40) && aa=='left'){ that.photoBtn('next'); } }else{ if((moveX2 - moveX1 > 40) && aa=='left'){ that.photoBtn('prev'); } } that.ulli(li, aa, '', yy, true); aa = null; }); ul.addEventListener('click', function(e){ that.close(); }); }else{ ul.addEventListener('touchstart', function(e){ return false; }); ul.addEventListener('touchend', function(e){ return false; }); ul.addEventListener('click', function(e){ return false; }); } }; Xclass.pt.photoBtn = function(type){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; var li = xtipdiv.getElementsByClassName('xtiper_photo_li'); var xtiper_main = xtipdiv.getElementsByClassName('xtiper_main')[0]; if(xtiper_main.classList.contains('xtiper_main_photo')===true){ return false; } xtiper_main.classList.add('xtiper_main_photo'); var index = 0, old = 0; for(var i=0;i li.length - 1){ index = 0; } } that.now = index; var xnum = index + 1; var xtiper_num = xtiper_main.getElementsByClassName('xtiper_num')[0]; xtiper_num.innerHTML = xnum; var xtiper_words = xtiper_main.getElementsByClassName('xtiper_words')[0]; var img; for(var i=0;i window.innerHeight){ if(c.title){ img = window.innerHeight; }else{ img = window.innerHeight - 26; } } xtiper_main.style.height = img+'px'; xtiper_main.style.top = ((window.innerHeight - img)/2)+'px'; } }else{ li[i].classList.remove('xon'); } if(i==old){ li[i].classList.add('xold_'+type); }else{ li[i].classList.remove('xold_prev'); li[i].classList.remove('xold_next'); } } setTimeout(function(){ li[old].classList.remove('xold_'+type); xtiper_main.classList.remove('xtiper_main_photo'); },401); }; Xclass.pt.appScroll = function(e){ e.preventDefault(); }; Xclass.pt.touchmove = function(type){ var that = this; if(type===false){ document.body.addEventListener('touchmove', that.appScroll, {passive:false}); }else{ document.body.removeEventListener('touchmove', that.appScroll, {passive:false}); } }; Xclass.pt.xcstrRep = function(str){ str = str.replace(/[\s\n\r]/g,''); //空格换行回车 str = encodeURIComponent(str).toLowerCase(); var reparr = [[/true/g,'1'],[/false/g,'0'],[/%/g,''],[/\(/g,''],[/\)/g,''],[/open/g,'o'],[/ready/g,'r'],[/noready/g,'n'],[/url/g,'u'],[/html/g,'h'],[/photo/g,'p'],[/function/g,'f'],[/99999/g,'9']]; for(var i=0;i window.innerWidth){ var result = (newsize[0]>100 ? 100 : newsize[0])+'%'; return result; }else{ return oldval; } }else{ return oldval; } }; //弹幕开始 Xclass.pt.danmuStar = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; xtipdiv.classList.add('xtiper_danmu_animate'); if(xtipdiv.style.animationDuration==''){ xtipdiv.style.animationDuration = '6s'; } var danmutime = Number(xtipdiv.style.animationDuration.replace(/s/,'')); that.dataset(xtipdiv, 'xdanmu', danmutime); that.outtime = setTimeout(function(){ that.close(); },(danmutime*1000)+1); }; //弹幕停止 Xclass.pt.danmuStop = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; var bwidth = document.body.offsetWidth + 22; var newtranslate = xtipdiv.getBoundingClientRect().left; xtipdiv.style.transform = 'translateX('+newtranslate+'px)'; if(that.outtime){ clearInterval(that.outtime); that.outtime = null; } var progress = newtranslate / bwidth; var lesstime = 6 * progress; if(lesstime < 0.4){ lesstime = 0.4; } that.dataset(xtipdiv, 'xdanmu', lesstime); xtipdiv.style.animationDuration = lesstime+'s'; xtipdiv.classList.remove('xtiper_danmu_animate'); }; //绑定按钮事件 Xclass.pt.bclick = function(btn, fun, ifclose){ var that = this; if(btn){ if(fun && typeof(fun)=='function'){ btn.addEventListener('click', function() { fun(); that.close(); }); }else{ if(ifclose===true){ btn.addEventListener('click', function() { that.close(); }); } } } }; //自动关闭 Xclass.pt.autoClose = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; //倒计时 if(xtipdiv.getElementsByClassName('xtiper_times')[0]){ var times = c.times - 1; var i = times; var fn = function() { xtiper_times = xtipdiv.getElementsByClassName('xtiper_times')[0]; xtiper_times.innerHTML = i; if(i<=0){ that.close(); clearInterval(that.timer); that.timer = null; } i--; }; that.timer = setInterval(fn, 1000); fn(); }else{ var times = c.times; if(times && times!=0){ setTimeout(function(){ that.close(); },times*1000); } } }; //锁定滚动条 Xclass.pt.lock = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; if(c.lock===true){ that.dataset(xtipdiv, 'xlock', 1); document.documentElement.style.overflowY = 'hidden'; that.touchmove(false); } }; //解除锁定滚动条 Xclass.pt.unlock = function(){ var that = this; var flag = 0; var winli = document.getElementsByClassName('xtiper_win'); for(var i=0;i document.body.offsetWidth - drag_main.offsetWidth + overX){ moveX = document.body.offsetWidth - drag_main.offsetWidth + overX; } if(moveY < 0){ moveY = 0 }else if(moveY > window.innerHeight - drag_main.offsetHeight + overY){ moveY = window.innerHeight - drag_main.offsetHeight + overY; } drag_main.style.left = moveX + 'px'; drag_main.style.top = moveY + 'px' }; document.onmouseup = function(event){ drag_main.classList.remove('xon'); this.onmousemove = null; this.onmouseup = null; //修复低版本ie bug if(typeof drag_main.releaseCapture != 'undefined'){ drag_main.releaseCapture(); } }; }; }else{ drag.onmousedown = function(event){ return false; document.onmousemove = function(event){ return false; }; document.onmouseup = function(event){ return false; }; } } }; //绑定关闭按钮及遮罩点击关闭 Xclass.pt.shade = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; var close = xtipdiv.getElementsByClassName('xtiper_close')[0]; if(close){ close.addEventListener('click', function() { that.close(); if(c.end && typeof(c.end)=='function'){ c.end(); } }); } if(c.shadeClose){ var bg = xtipdiv.getElementsByClassName('xtiper_bg')[0]; bg.addEventListener('click', function() { if(c.model=='sheet' && c.force){ xtip.msg(c.force); return false; }else{ that.close(); if(c.end && typeof(c.end)=='function'){ c.end(); } } }); } }; //键盘事件 Xclass.pt.key = function(){ var that = this; var c = that.c; var xtipdiv = that.xtipdiv; document.onkeydown = function(event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if(e){ if(e.keyCode==27){ //按 Esc that.close(); }else if(e.keyCode==13) { //按 Enter if(c.model=='win'){ //多按钮取消回车事件 if(c.btn2 || c.btn3){ return false; } that.close(); if(c.btn1 && typeof(c.btn1)=='function'){ c.btn1(); c.btn1 = null; } return false; } } else{ return e; } } }; }; /* * 关闭层 * 关闭层id * 是否检查锁定层 checkLock */ Xclass.pt.close = function(closeid){ var that = this; var c = that.c; var checkLock = false; if(closeid){ var xtipdiv = document.getElementById(closeid); if(!xtipdiv){ return false; } if(that.dataset(xtipdiv, 'xlock')==1){ checkLock = true; } }else{ var xtipdiv = that.xtipdiv; if(c.lock===true){ checkLock = true; } } if(!xtipdiv){ return false; } //弹幕类型不用延时 var closenow = false; if(xtipdiv.classList.contains('xtiper_danmu')===true){ closenow = true; }else{ closenow = false; } //不用延时关闭 if(closenow===true){ var parent_xtipdiv = xtipdiv.parentNode; if(parent_xtipdiv){ parent_xtipdiv.removeChild(xtipdiv); } }else{ if(that.dataset(xtipdiv, 'xreset')==1){ xtipdiv.classList.add('xoff'); if(c.lock===true){ that.unlock(); } setTimeout(function(){ xtipdiv.style.zIndex = '-99999'; if(c.min===true){ that.minmax('min',1); } if(c.max===true){ that.minmax('max',1); } if(c.model=='open' && c.type=='photo'){ if(that.ifmob===true){ var xtiper_content = xtipdiv.getElementsByClassName('xtiper_content')[0]; xtiper_content.style.backgroundColor = 'rgba(0,0,0,1)'; } var li = xtipdiv.getElementsByClassName('xtiper_photo_li'); if(li.length>0){ for(var i=0;i