| 7 |
!function(e,t){"use strict";"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.baguetteBox=t()}(this,function(){"use strict";var s,l,r,u,i,c='<svg width="44" height="60"><polyline points="30 10 10 30 30 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"stroke-linecap="butt" fill="none" stroke-linejoin="round"/></svg>',d='<svg width="44" height="60"><polyline points="14 10 34 30 14 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"stroke-linecap="butt" fill="none" stroke-linejoin="round"/></svg>',g='<svg width="30" height="30"><g stroke="rgb(160,160,160)" stroke-width="4"><line x1="5" y1="5" x2="25" y2="25"/><line x1="5" y1="25" x2="25" y2="5"/></g></svg>',f={},m={captions:!0,buttons:"auto",fullScreen:!1,noScrollbars:!1,bodyClass:"baguetteBox-open",titleTag:!1,async:!1,preload:2,animation:"slideIn",afterShow:null,afterHide:null,onChange:null,overlayBackgroundColor:"rgba(0,0,0,.8)"},p={},v=[],n=0,o=!1,t={},a=!1,b=/.+\.(gif|jpe?g|png|webp|mp4|webm)/i,h=/.+\.(mp4|webm)/i,y={},w=[],E=null,k=function(e){-1!==e.target.id.indexOf("baguette-img")&&q()},x=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,X()},C=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,R()},B=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,q()},T=function(e){t.count++,1<t.count&&(t.multitouch=!0),t.startX=e.changedTouches[0].pageX,t.startY=e.changedTouches[0].pageY},N=function(e){a||t.multitouch||(e.preventDefault?e.preventDefault():e.returnValue=!1,40<(e=e.touches[0]||e.changedTouches[0]).pageX-t.startX?(a=!0,X()):e.pageX-t.startX<-40?(a=!0,R()):100<t.startY-e.pageY&&q())},A=function(){t.count--,t.count<=0&&(t.multitouch=!1),a=!1},L=function(){A()},P=function(e){"block"===s.style.display&&s.contains&&!s.contains(e.target)&&(e.stopPropagation(),j())};function S(e){var t;y.hasOwnProperty(e)&&(t=y[e].galleries,[].forEach.call(t,function(e){[].forEach.call(e,function(e){G(e.imageElement,"click",e.eventHandler)}),v===e&&(v=[])}),delete y[e])}function F(e){switch(e.keyCode){case 37:X();break;case 39:R();break;case 27:q();break;case 36:(t=e)&&t.preventDefault(),!void D(0);break;case 35:(t=e)&&t.preventDefault(),!void D(v.length-1)}var t}function H(e,t){if(v!==e){for(v=e,function(e){for(var t in e=e||{},m)f[t]=m[t],void 0!==e[t]&&(f[t]=e[t]);l.style.transition=l.style.webkitTransition="fadeIn"===f.animation?"opacity .4s ease":"slideIn"===f.animation?"":"none","auto"===f.buttons&&("ontouchstart"in window||1===v.length)&&(f.buttons=!1),r.style.display=u.style.display=f.buttons?"":"none";try{s.style.backgroundColor=f.overlayBackgroundColor}catch(e){}}(t);l.firstChild;)l.removeChild(l.firstChild);for(var n,o=[],i=[],a=w.length=0;a<e.length;a++)(n=K("div")).className="full-image",n.id="baguette-img-"+a,w.push(n),o.push("baguetteBox-figure-"+a),i.push("baguetteBox-figcaption-"+a),l.appendChild(w[a]);s.setAttribute("aria-labelledby",o.join(" ")),s.setAttribute("aria-describedby",i.join(" "))}}function I(e){f.noScrollbars&&(document.documentElement.style.overflowY="hidden",document.body.style.overflowY="scroll"),"block"!==s.style.display&&(U(document,"keydown",F),t={count:0,startX:null,startY:null},O(n=e,function(){V(n),W(n)}),z(),s.style.display="block",f.fullScreen&&(s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.mozRequestFullScreen&&s.mozRequestFullScreen()),setTimeout(function(){s.className="visible",f.bodyClass&&document.body.classList&&document.body.classList.add(f.bodyClass),f.afterShow&&f.afterShow()},50),f.onChange&&f.onChange(n,w.length),E=document.activeElement,j(),o=!0)}function j(){(f.buttons?r:i).focus()}function q(){f.noScrollbars&&(document.documentElement.style.overflowY="auto",document.body.style.overflowY="auto"),"none"!==s.style.display&&(G(document,"keydown",F),s.className="",setTimeout(function(){s.style.display="none",document.fullscreen&&(document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()),f.bodyClass&&document.body.classList&&document.body.classList.remove(f.bodyClass),f.afterHide&&f.afterHide(),Y(),E&&E.focus(),o=!1},500))}function Y(){[].forEach.call(w,function(e){0<e.getElementsByTagName("video").length&&e.getElementsByTagName("video")[0].pause()})}function O(t,n){var e,o,i,a,s,l=w[t],r=v[t],u=!1;void 0!==l&&(u=h.test(r.imageElement.href)||"video"===r.imageElement.getAttribute("data-content-type")),void 0!==l&&void 0!==r&&(l.getElementsByTagName("img")[0]&&!u||l.getElementsByTagName("video")[0]&&u?n&&n():(a=r.imageElement,e=(u?a.getElementsByTagName("video"):a.getElementsByTagName("img"))[0],o="function"==typeof f.captions?f.captions.call(v,a):a.getAttribute("data-caption")||a.title,r=(u?function(e){var t=e.href;if(e.dataset){var n,o=[];for(n in e.dataset)"at-"!==n.substring(0,3)||isNaN(n.substring(3))||(o[n.replace("at-","")]=e.dataset[n]);for(var i=Object.keys(o).sort(function(e,t){return parseInt(e,10)<parseInt(t,10)?-1:1}),a=window.innerWidth*window.devicePixelRatio,s=0;s<i.length-1&&i[s]<a;)s++;t=o[i[s]]||t}return t}:function(e){var t=e.href;if(e.dataset){var n,o=[];for(n in e.dataset)"at-"!==n.substring(0,3)||isNaN(n.substring(3))||(o[n.replace("at-","")]=e.dataset[n]);for(var i=Object.keys(o).sort(function(e,t){return parseInt(e,10)<parseInt(t,10)?-1:1}),a=window.innerWidth*window.devicePixelRatio,s=0;s<i.length-1&&i[s]<a;)s++;t=o[i[s]]||t}return t})(a),(i=K("figure")).id="baguetteBox-figure-"+t,i.innerHTML='<div class="baguetteBox-spinner"><div class="baguetteBox-double-bounce1"></div><div class="baguetteBox-double-bounce2"></div></div>',f.captions&&o&&((a=K("figcaption")).id="baguetteBox-figcaption-"+t,a.innerHTML=o,i.appendChild(a)),l.appendChild(i),u?((s=K("video")).addEventListener("loadeddata",function(){var e=document.querySelector("#baguette-img-"+t+" .baguetteBox-spinner");i.removeChild(e),!f.async&&n&&n()}),(u=K("source")).setAttribute("src",r),s.appendChild(u),f.titleTag&&o&&(s.title=o),i.appendChild(s)):((s=K("img")).onload=function(){var e=document.querySelector("#baguette-img-"+t+" .baguetteBox-spinner");i.removeChild(e),!f.async&&n&&n()},s.setAttribute("src",r),s.alt=e&&e.alt||"",f.titleTag&&o&&(s.title=o),i.appendChild(s)),f.async&&n&&n()))}function R(){return D(n+1)}function X(){return D(n-1)}function D(e,t){return!o&&0<=e&&e<t.length?(H(t,f),I(e),!0):e<0?(f.animation&&M("left"),!1):e>=w.length?(f.animation&&M("right"),!1):(O(n=e,function(){V(n),W(n)}),z(),f.onChange&&f.onChange(n,w.length),!0)}function M(e){l.className="bounce-from-"+e,setTimeout(function(){l.className=""},400)}function z(){Y();var e=100*-n+"%";"fadeIn"===f.animation?(l.style.opacity=0,setTimeout(function(){p.transforms?l.style.transform=l.style.webkitTransform="translate3d("+e+",0,0)":l.style.left=e,l.style.opacity=1},400)):p.transforms?l.style.transform=l.style.webkitTransform="translate3d("+e+",0,0)":l.style.left=e,0<w[n].getElementsByTagName("video").length&&w[n].getElementsByTagName("video")[0].play()}function V(e){e-n>=f.preload||O(e+1,function(){V(e+1)})}function W(e){n-e>=f.preload||O(e-1,function(){W(e-1)})}function U(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent("on"+t,function(e){(e=e||window.event).target=e.target||e.srcElement,n(e)})}function G(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent("on"+t,n)}function J(e){return document.getElementById(e)}function K(e){return document.createElement(e)}return[].forEach||(Array.prototype.forEach=function(e,t){for(var n=0;n<this.length;n++)e.call(t,this[n],n,this)}),[].filter||(Array.prototype.filter=function(e,t,n,o,i){for(n=this,o=[],i=0;i<n.length;i++)e.call(t,n[i],i,n)&&o.push(n[i]);return o}),{run:function(e,t){var n,a,o;return p.transforms=void 0!==(n=K("div")).style.perspective||void 0!==n.style.webkitPerspective,p.svg=((n=K("div")).innerHTML="<svg/>","http://www.w3.org/2000/svg"===(n.firstChild&&n.firstChild.namespaceURI)),p.passiveEvents=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t)}catch(e){}return e}(),(s=J("baguetteBox-overlay"))?(l=J("baguetteBox-slider"),r=J("previous-button"),u=J("next-button"),i=J("close-button")):((s=K("div")).setAttribute("role","dialog"),s.id="baguetteBox-overlay",document.getElementsByTagName("body")[0].appendChild(s),(l=K("div")).id="baguetteBox-slider",s.appendChild(l),(r=K("button")).setAttribute("type","button"),r.id="previous-button",r.setAttribute("aria-label","Previous"),r.innerHTML=p.svg?c:"<",s.appendChild(r),(u=K("button")).setAttribute("type","button"),u.id="next-button",u.setAttribute("aria-label","Next"),u.innerHTML=p.svg?d:">",s.appendChild(u),(i=K("button")).setAttribute("type","button"),i.id="close-button",i.setAttribute("aria-label","Close"),i.innerHTML=p.svg?g:"×",s.appendChild(i),r.className=u.className=i.className="baguetteBox-button",function(){var e=p.passiveEvents?{passive:!1}:null,t=p.passiveEvents?{passive:!0}:null;U(s,"click",k),U(r,"click",x),U(u,"click",C),U(i,"click",B),U(l,"contextmenu",L),U(s,"touchstart",T,t),U(s,"touchmove",N,e),U(s,"touchend",A),U(document,"focus",P,!0)}()),S(e),e=e,a=t,t=document.querySelectorAll(e),o={galleries:[],nodeList:t},y[e]=o,[].forEach.call(t,function(e){a&&a.filter&&(b=a.filter);var i,t=[],t="A"===e.tagName?[e]:e.getElementsByTagName("a");0!==(t=[].filter.call(t,function(e){if(-1===e.className.indexOf(a&&a.ignoreClass))return b.test(e.href)||"image"===e.getAttribute("data-content-type")||"video"===e.getAttribute("data-content-type")})).length&&(i=[],[].forEach.call(t,function(e,t){function n(e){e.preventDefault?e.preventDefault():e.returnValue=!1,H(i,a),I(t)}var o={eventHandler:n,imageElement:e};U(e,"click",n),i.push(o)}),o.galleries.push(i))}),o.galleries},show:D,showNext:R,showPrevious:X,hide:q,destroy:function(){var e,t;e=p.passiveEvents?{passive:!1}:null,t=p.passiveEvents?{passive:!0}:null,G(s,"click",k),G(r,"click",x),G(u,"click",C),G(i,"click",B),G(l,"contextmenu",L),G(s,"touchstart",T,t),G(s,"touchmove",N,e),G(s,"touchend",A),G(document,"focus",P,!0),function(){for(var e in y)y.hasOwnProperty(e)&&S(e)}(),G(document,"keydown",F),document.getElementsByTagName("body")[0].removeChild(document.getElementById("baguetteBox-overlay")),y={},v=[],n=0}}}); |