forked from henrygd/bigpicture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBigPicture.min.js
1 lines (1 loc) · 4.36 KB
/
BigPicture.min.js
1
!function(){function t(){function t(){var t=P[G]("button");return t.className="bp-x",t[R]="×",t}M=[];var o=P[G]("STYLE");o[R]="#bp_caption,#bp_container{bottom:0;left:0;right:0;position:fixed;opacity:0}#bp_container>*,.bp-x,#bp_loader{position:absolute;right:0}#bp_container{top:0;z-index:9999;background:rgba(0,0,0,.7);opacity:0;pointer-events:none;transition:opacity .35s}#bp_loader{top:0;left:0;bottom:0;display:-webkit-flex;display:flex;margin:0;cursor:wait;z-index:9}#bp_loader svg{width:40%;max-height:40%;margin:auto;"+d("animation:","ldr .7s infinite linear;")+"}"+s("keyframes ldr{to{"+d("transform:","rotate(1turn);")+"}}")+"#bp_container img,#bp_sv,#bp_vid{max-height:96%;max-width:96%;top:0;bottom:0;left:0;margin:auto;box-shadow:0 0 3em rgba(0,0,0,.4);z-index:-1}#bp_sv{width:171vh}#bp_caption{font-size:.9em;padding:1.3em;background:rgba(15,15,15,.94);color:#fff;text-align:center;transition:opacity .3s}.bp-x{font-family:Arial;top:0;cursor:pointer;opacity:.8;font-size:3em;padding:0 .3em;color:#fff;background:transparent;border:0;text-shadow:0 0 2px #000}#bp_caption .bp-x{left:2%;top:auto;right:auto;bottom:100%;padding:0 .6em;background:#d74040;border-radius:2px 2px 0 0;font-size:2.3em;text-shadow:none}.bp-x:hover,.bp-x:focus{opacity:1}.bp-x:active{outline:0}@media (max-aspect-ratio:9/5){#bp_sv{height:53vw}}",P.head[F](o),b=P[G]("DIV"),b.id="bp_container",b.onclick=a,y=t(),b[F](y),m=P[G]("IMG"),g=P[G]("VIDEO"),g.id="bp_vid",g.autoplay=!0,g.controls=!0,g.loop=!0,z=P[G]("DIV"),z.id="bp_caption",T=t(),T.onclick=function(){p(z,"opacity:0"),J(function(){E=!1,b[H](z)},300)},z[F](T),I=P[G]("SPAN"),z[F](I),S=P[G]("DIV"),S.id="bp_loader",S[R]='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 399 399"><path d="M341 58.5C303 20.8 253 0 199.6 0 146.4 0 96.2 20.8 58.5 58.5 20.8 96.2 0 146.5 0 199.7 0 253 20.8 303.2 58.5 341c37.7 37.6 88 58.4 141.2 58.4 53.3 0 103.5-20.8 141.2-58.5 37.6-37.8 58.4-88 58.4-141.3 0-53.3-20.8-103.5-58.5-141.2zm-13 12.8c34.3 34.3 53.2 80 53.2 128.4h-41c0-77.4-63-140.4-140.5-140.4-4.6 0-9 .2-13.6.7V18.7c4.6-.4 9-.5 13.7-.5 48.5 0 94 18.8 128.4 53zM199.8 322c-67.4 0-122.2-55-122.2-122.3S132.3 77.5 199.7 77.5 322 132.3 322 199.7 267 322 199.6 322z"/></svg>',h=P[G]("DIV"),h.id="bp_sv",x=P[G]("IFRAME"),x.allowFullscreen=!0,x.onload=r,p(x,"border:0px;height:100%;width:100%"),h[F](x),m.onload=r,m.onerror=r.bind(null,"image"),O[Y]("resize",function(){_&&i(!0)}),P[Y]("keyup",function(t){27===t.keyCode&&D&&a(b)}),P[Y]("focus",function(t){D&&!b.contains(t.target)&&(t.stopPropagation(),y.focus())},!0),u=!0}function o(){var t=l.getBoundingClientRect();return d("transform:","translate3D("+(t.left-(b[W]-t.width)/2)+"px, "+(t.top-(b[q]-t.height)/2)+"px, 0) scale3D("+l[W]/f[W]+", "+l[q]/f[q]+", 0);")}function e(t){x.src="https://"+(t?"www.youtube.com/embed/"+w+"?enablejsapi=1&html5=1&rel=0&showinfo=0&":"player.vimeo.com/video/"+w+"?")+"autoplay=1"}function n(){4===f.readyState?r():g.error?r("video"):k=J(n,35)}function i(t){N||(t&&p(S,"top:"+l.offsetTop+"px;left:"+l.offsetLeft+"px;height:"+l[q]+"px;width:"+l[W]+"px"),l.parentElement[t?F:H](S),_=t)}function r(t){return _&&i(),L&&L(),"string"==typeof t?(c(),alert("Error: The requested "+t+" could not be displayed.")):(A&&!V&&M.push(v),p(f,o()),p(b,"opacity:1;"+j),B=J(B,410),D=!0,void J(function(){p(f,d("transition:","transform .35s;")+d("transform:","none;")),E&&J(p.bind(null,z,"opacity:1"),250)},60))}function a(t){var e=t.target,n=[z,T,g,I];e&&e.blur(),C||~n.indexOf(e)||(f.style.cssText+=o(),p(b,j),J(c,350),K(B),D=!1,C=!0)}function c(){P.body[H](b),b[H](f),p(b,""),(f===h?x:f).removeAttribute("src"),E&&(p(z,""),b[H](z)),C=!1}function p(t,o){t.style.cssText=o}function d(t,o){var e="-webkit-",n=t+o;return e+n+t+e+o+n}function s(t){return"@-webkit-"+t+"@"+t}var l,u,b,f,m,g,h,x,v,y,w,_,k,S,z,I,E,T,D,C,M,V,A,L,B,N,O=window,P=document,F="appendChild",G="createElement",H="removeChild",R="innerHTML",j="pointer-events:auto",q="clientHeight",W="clientWidth",Y="addEventListener",J=O.setTimeout,K=O.clearTimeout;O.BigPicture=function(o){u||t(),_&&(K(k),c()),w=o.ytSrc||o.vimeoSrc,L=o.animationStart,B=o.animationEnd,N=o.noLoader,l=o.el,A=!1,E=l.getAttribute("caption"),E&&(I[R]=E,b[F](z)),w?(i(!0),f=h,e(!!o.ytSrc)):o.imgSrc?(A=!0,v=o.imgSrc,V=~M.indexOf(v),!V&&i(!0),f=m,f.src=v):o.vidSrc?(i(!0),f=g,f.src=o.vidSrc,n()):(f=m,f.src="IMG"===l.tagName?l.src:O.getComputedStyle(l).backgroundImage.replace(/^url|[\(|\)|'|"]/g,"")),b[F](f),P.body[F](b)}}();