bibliotheks-und-archivinfor.../docsify/zoom-image.min.js

2 lines
9.0 KiB
JavaScript
Raw Normal View History

2020-06-23 12:40:50 +02:00
!function(){function t(e){return"IMG"===e.tagName}function w(e){return e&&1===e.nodeType}function L(e){return".svg"===(e.currentSrc||e.src).substr(-4).toLowerCase()}function p(e){try{return Array.isArray(e)?e.filter(t):function(e){return NodeList.prototype.isPrototypeOf(e)}(e)?[].slice.call(e).filter(t):w(e)?[e].filter(t):"string"==typeof e?[].slice.call(document.querySelectorAll(e)).filter(t):[]}catch(e){throw new TypeError("The provided selector is invalid.\nExpects a CSS selector, a Node element, a NodeList or an array.\nSee: https://github.com/francoischalifour/medium-zoom")}}function g(e,t){var o=H({bubbles:!1,cancelable:!1,detail:void 0},t);if("function"==typeof window.CustomEvent)return new CustomEvent(e,o);var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,o.bubbles,o.cancelable,o.detail),n}function v(e,t){function o(){for(var e=arguments,t=arguments.length,o=Array(t),n=0;n<t;n++)o[n]=e[n];var i=o.reduce(function(e,t){return[].concat(e,p(t))},[]);return i.filter(function(e){return-1===c.indexOf(e)}).forEach(function(e){c.push(e),e.classList.add("medium-zoom-image")}),d.forEach(function(e){var t=e.type,o=e.listener,n=e.options;i.forEach(function(e){e.addEventListener(t,o,n)})}),f}function n(e){function r(){var e={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},t=void 0,o=void 0;if(b.container)if(b.container instanceof Object)t=(e=H({},e,b.container)).width-e.left-e.right-2*b.margin,o=e.height-e.top-e.bottom-2*b.margin;else{var n=(w(b.container)?b.container:document.querySelector(b.container)).getBoundingClientRect(),i=n.width,r=n.height,d=n.left,a=n.top;e=H({},e,{width:i,height:r,left:d,top:a})}t=t||e.width-2*b.margin,o=o||e.height-2*b.margin;var m=E.zoomedHd||E.original,c=L(m)?t:m.naturalWidth||t,l=L(m)?o:m.naturalHeight||o,u=m.getBoundingClientRect(),s=u.top,f=u.left,p=u.width,g=u.height,v=Math.min(c,t)/p,h=Math.min(l,o)/g,z=Math.min(v,h),y="scale("+z+") translate3d("+((t-p)/2-f+b.margin+e.left)/z+"px, "+((o-g)/2-s+b.margin+e.top)/z+"px, 0)";E.zoomed.style.transform=y,E.zoomedHd&&(E.zoomedHd.style.transform=y)}var d=(0<arguments.length&&void 0!==e?e:{}).target;return new a(function(t){if(d&&-1===c.indexOf(d))t(f);else{if(E.zoomed)t(f);else{if(d)E.original=d;else{if(!(0<c.length))return void t(f);var e=c;E.original=e[0]}if(E.original.dispatchEvent(g("medium-zoom:open",{detail:{zoom:f}})),u=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,l=!0,E.zoomed=function(e){var t=e.getBoundingClientRect(),o=t.top,n=t.left,i=t.width,r=t.height,d=e.cloneNode(),a=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,m=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;return d.removeAttribute("id"),d.style.position="absolute",d.style.top=o+a+"px",d.style.left=n+m+"px",d.style.width=i+"px",d.style.height=r+"px",d.style.transform="",d}(E.original),document.body.appendChild(s),b.template){var o=w(b.template)?b.template:document.querySelector(b.template);E.template=document.createElement("div"),E.template.appendChild(o.content.cloneNode(!0)),document.body.appendChild(E.template)}if(document.body.appendChild(E.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),E.original.classList.add("medium-zoom-image--hidden"),E.zoomed.classList.add("medium-zoom-image--opened"),E.zoomed.addEventListener("click",m),E.zoomed.addEventListener("transitionend",function e(){l=!1,E.zoomed.removeEventListener("transitionend",e),E.original.dispatchEvent(g("medium-zoom:opened",{detail:{zoom:f}})),t(f)}),E.original.getAttribute("data-zoom-src")){E.zoomedHd=E.zoomed.cloneNode(),E.zoomedHd.removeAttribute("srcset"),E.zoomedHd.removeAttribute("sizes"),E.zoomedHd.src=E.zoomed.getAttribute("data-zoom-src"),E.zoomedHd.onerror=function(){clearInterval(n),console.warn("Unable to reach the zoom image target "+E.zoomedHd.src),E.zoomedHd=null,r()};var n=setInterval(function(){E.zoomedHd.complete&&(clearInterval(n),E.zoomedHd.classList