-
Notifications
You must be signed in to change notification settings - Fork 2
/
redips-dialog-min.js
16 lines (16 loc) · 4.14 KB
/
redips-dialog-min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
Copyright (c) 2008-2020, www.redips.net All rights reserved.
Code licensed under the BSD License: http://www.redips.net/license/
http://www.redips.net/javascript/dialog-box/
Version 1.8.0
Mar 24, 2020.
*/
var REDIPS=REDIPS||{};
REDIPS.dialog=function(){var c,g,e,f,p=0,n=0,l,w;var m=function(a,b,d){void 0===b&&(b="");void 0===d&&(d="");f.innerHTML='<div class="redips-dialog-titlebar"><span title="Close" onclick="REDIPS.dialog.hide(\'undefined\')">'+REDIPS.dialog.closeButton+'</span></div><table class="redips-dialog-tbl" cellpadding="0" cellspacing="0"><tr><td valign="center" height="'+n+'" width="'+p+'">'+a+'<div class="redips-dialog-buttons">'+b+d+"</div></td></tr></table>";e.style.display=f.style.display="block";t(REDIPS.dialog.opLow,
5)};var x=function(a){a=a.split("|");var b=a[2];b=void 0!==b?"','"+b:"";return'<input type="button" onclick="REDIPS.dialog.hide(\''+u(a[1])+u(b)+'\');" value="'+u(a[0])+'"/>'};var y=function(a){var b;var d=a.split(",");if(1===d.length)a='<div class="redips-dialog-imgc"><img src="'+d[0]+'" height="'+(n-40)+'"/></div>';else{a='<div class="redips-dialog-imgc" style="width:'+(p-8)+'px"><table><tr>';for(b=0;b<d.length;b++)a+='<td><img src="'+d[b]+'" height="'+(n-40)+'"/></td>';a+="</tr></table></div>"}return a};
var v=function(){if("number"===typeof window.innerWidth){var a=window.innerWidth;var b=window.innerHeight;var d=window.pageXOffset;var c=window.pageYOffset}else document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)?(a=document.documentElement.clientWidth,b=document.documentElement.clientHeight,d=document.documentElement.scrollLeft,c=document.documentElement.scrollTop,e.style.width=a+"px",e.style.height=b+"px"):document.body&&(document.body.clientWidth||
document.body.clientHeight)&&(a=document.body.clientWidth,b=document.body.clientHeight,d=document.body.scrollLeft,c=document.body.scrollTop);f.style.left=(a-p)/2+"px";f.style.top=(b-n)/2+"px";e.style.top=c+"px";e.style.left=d+"px"};var t=function(a,b){e.style.opacity=a/100;e.style.filter="alpha(opacity="+a+")";a+=b;if(REDIPS.dialog.opLow<=a&&a<=REDIPS.dialog.opHigh)setTimeout(function(){t(a,b)},REDIPS.dialog.fadeSpeed);else if(REDIPS.dialog.opLow>a&&(e.style.display="none","undefined"!==l))window[l](w)};
var u=function(a){void 0!==a&&(a=a.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g," "));return a};return{opHigh:60,opLow:0,fadeSpeed:10,youtube:'<iframe width="640" height="390" src="https://www.youtube.com/embed/_youtubeId_" frameborder="0" allowfullscreen></iframe>',shown:!1,closeButton:"\u2715",init:function(){f=document.createElement("div");f.setAttribute("id","redips-dialog");g=document.createElement("div");e=document.createElement("div");e.setAttribute("id","redips-dialog-shade");var a=document.getElementsByTagName("body")[0];
a.appendChild(e);a.appendChild(f);REDIPS.event.add(window,"resize",v);REDIPS.event.add(window,"scroll",v);c=new XMLHttpRequest},show:function(a,b,d,e,f){var q="",r="",h="",l=h="";var k="";REDIPS.dialog.shown=!0;p=a;n=b;v();a=/(\.jpg|\.jpeg|\.gif|\.png)$/i;b=/(\.php|\.html|\.aspx)/i;k=/youtube:/i;void 0!==e&&(q=x(e));void 0!==f&&(r=x(f));"html"===d?m(g.innerHTML,q,r):a.test(d)?(k=d.split("|"),1===k.length?h=y(k[0]):(h=y(k[1]),l="<div>"+k[0]+"</div>"),m(h+l,q,r)):b.test(d)?(c.open("GET",d,!0),c.onreadystatechange=
function(){c.readyState===XMLHttpRequest.DONE&&(200===c.status?m(c.responseText):m("Error: ["+c.status+"] "+c.statusText))},c.setRequestHeader("X-Requested-With","XMLHttpRequest"),c.send(null)):k.test(d)?(d=d.split(":")[1],h=REDIPS.dialog.youtube.replace(/_youtubeId_/g,d),m(h)):m(h+("<div>"+d+"</div>"),q,r);REDIPS.dialog.event.displayed()},hide:function(a,b){!0===REDIPS.dialog.shown&&(REDIPS.dialog.shown=!1,l=a,w=b,t(REDIPS.dialog.opHigh,-10),f.style.display="none",f.innerHTML="",REDIPS.dialog.event.closed())},
html:function(a){g.innerHTML=a},event:{displayed:function(){},closed:function(){}}}}();REDIPS.event||(REDIPS.event=function(){return{add:function(c,g,e){c.addEventListener?c.addEventListener(g,e,!1):c.attachEvent?c.attachEvent("on"+g,e):c["on"+g]=e},remove:function(c,g,e){c.removeEventListener?c.removeEventListener(g,e,!1):c.detachEvent?c.detachEvent("on"+g,e):c["on"+g]=null}}}());