2 lines
7.7 KiB
JavaScript
2 lines
7.7 KiB
JavaScript
|
!function(){var T=Object.assign||function(e){for(var t,o=1;o<arguments.length;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},x=["IMG"],S=[27,81],N=function(e){return-1<x.indexOf(e.tagName)},j=function(e){return e.naturalWidth!==e.width},M=function(e){return e&&1===e.nodeType},e=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=t.margin,n=void 0===o?0:o,i=t.background,r=void 0===i?"#fff":i,d=t.scrollOffset,a=void 0===d?48:d,l=t.metaClick,c=t.container,m=t.template,s=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{bubbles:!1,cancelable:!1,detail:void 0};if("function"==typeof window.CustomEvent)return new CustomEvent(e,t);var o=document.createEvent("CustomEvent");return o.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),o},u=function(){if(H.original){if(H.original.dispatchEvent(s("show")),O=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,A=!0,H.zoomed=(o=H.original,n=o.getBoundingClientRect(),i=n.top,r=n.left,d=n.width,a=n.height,l=o.cloneNode(),c=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,m=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0,l.removeAttribute("id"),l.style.position="absolute",l.style.top=i+c+"px",l.style.left=r+m+"px",l.style.width=d+"px",l.style.height=a+"px",l.style.transform="",l),document.body.appendChild(k),E.template){var e=M(E.template)?E.template:document.querySelector(E.template);H.template=document.createElement("div"),H.template.appendChild(e.content.cloneNode(!0)),document.body.appendChild(H.template)}if(document.body.appendChild(H.zoomed),requestAnimationFrame(function(){document.body.classList.add("medium-zoom--open")}),H.original.style.visibility="hidden",H.zoomed.classList.add("medium-zoom-image--open"),H.zoomed.addEventListener("click",p),H.zoomed.addEventListener("transitionend",v),H.original.getAttribute("data-zoom-target")){H.zoomedHd=H.zoomed.cloneNode(),H.zoomedHd.src=H.zoomed.getAttribute("data-zoom-target"),H.zoomedHd.onerror=function(){clearInterval(t),console.error("Unable to reach the zoom image target "+H.zoomedHd.src),H.zoomedHd=null,b()};var t=setInterval(function(){H.zoomedHd.naturalWidth&&(clearInterval(t),H.zoomedHd.classList.add("medium-zoom-image--open"),H.zoomedHd.addEventListener("click",p),document.body.appendChild(H.zoomedHd),b())},10)}else b()}var o,n,i,r,d,a,l,c,m},p=function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,o=function(){A||!H.original||(H.original.dispatchEvent(s("hide")),A=!0,document.body.classList.remove("medium-zoom--open"),H.zoomed.style.transform="",H.zoomedHd&&(H.zoomedHd.style.transform="",H.zoomedHd.removeEventListener("click",e)),H.template&&(H.template.style.transition="opacity 150ms",H.template.style.opacity=0),H.zoomed.removeEventListener("click",e),H.zoomed.addEventListener("transitionend",h))};0<t?setTimeout(o,t):o()},f=function(e){e&&e.target?(H.original=e.target,u()):H.original?p():(H.original=C[0],u())},g=function(e){return(e.metaKey||e.ctrlKey)&&E.metaClick?window.open(e.target.getAttribute("data-original")||e.target.parentNode.href||e.target.src,"_blank"):(e.preventDefault(),void f(e))},v=function e(){A=!1,H.zoomed.removeEventListener("transitionend",e),H.original.dispatchEvent(s("shown"))},h=function e(){H.original&&(H.original.style.visibility="",document.body.removeChild(H.zoomed),H.zoomedHd&&document.body.removeChild(H.zoomedHd),document.body.removeChild(k),H.zoomed.classList.remove("medium-zoom-image--open"),H.template&&document.body.removeChild(H.template),A=!1,H.zoomed.removeEventListener("transitionend",e),H.original.dispatchEvent(s("hidden")),H.original=null,H.zoomed=null,H.zoomedHd=null,H.template=null)},y=function(){if(!A&&H.original){var e=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(O-e)>E.scrollOffset&&p(150)}},z=function(e){-1<S.indexOf(e.keyCode||e.which)&&p()},b=function(){var e=Math.min;if(H.original){var t,o,n={width:window.innerWidth,h
|