File "image.min.js"

Full Path: /home/pumpbmko/public_html/wp-content/plugins/gutenberg/build/interactivity/image.min.js
File size: 4.52 KB
MIME-type: text/x-java
Charset: utf-8

import*as t from"@wordpress/interactivity";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const n=(o={getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store},a={},e.d(a,o),a);var o,a;let r=!1,i=0;const{state:l,actions:g,callbacks:c}=(0,n.store)("core/image",{state:{currentImageId:null,get currentImage(){return l.metadata[l.currentImageId]},get overlayOpened(){return null!==l.currentImageId},get roleAttribute(){return l.overlayOpened?"dialog":null},get ariaModal(){return l.overlayOpened?"true":null},get enlargedSrc(){return l.currentImage.uploadedSrc||"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},get figureStyles(){return l.overlayOpened&&`${l.currentImage.figureStyles?.replace(/margin[^;]*;?/g,"")};`},get imgStyles(){return l.overlayOpened&&`${l.currentImage.imgStyles?.replace(/;$/,"")}; object-fit:cover;`},get imageButtonRight(){const{imageId:t}=(0,n.getContext)();return l.metadata[t].imageButtonRight},get imageButtonTop(){const{imageId:t}=(0,n.getContext)();return l.metadata[t].imageButtonTop},get isContentHidden(){const t=(0,n.getContext)();return l.overlayEnabled&&l.currentImageId===t.imageId},get isContentVisible(){const t=(0,n.getContext)();return!l.overlayEnabled&&l.currentImageId===t.imageId}},actions:{showLightbox(){const{imageId:t}=(0,n.getContext)();l.metadata[t].imageRef?.complete&&(l.scrollTopReset=document.documentElement.scrollTop,l.scrollLeftReset=document.documentElement.scrollLeft,l.overlayEnabled=!0,l.currentImageId=t,c.setOverlayStyles())},hideLightbox(){l.overlayEnabled&&(l.showClosingAnimation=!0,l.overlayEnabled=!1,setTimeout((function(){l.currentImage.buttonRef.focus({preventScroll:!0}),l.currentImageId=null}),450))},handleKeydown(t){if(l.overlayEnabled){if("Tab"===t.key){t.preventDefault();const{ref:e}=(0,n.getElement)();e.querySelector("button").focus()}"Escape"===t.key&&g.hideLightbox()}},handleTouchMove(t){l.overlayEnabled&&t.preventDefault()},handleTouchStart(){r=!0},handleTouchEnd(){i=Date.now(),r=!1},handleScroll(){l.overlayOpened&&!r&&Date.now()-i>450&&window.scrollTo(l.scrollLeftReset,l.scrollTopReset)}},callbacks:{setOverlayStyles(){if(!l.currentImage.imageRef)return;let{naturalWidth:t,naturalHeight:e,offsetWidth:n,offsetHeight:o}=l.currentImage.imageRef,{x:a,y:r}=l.currentImage.imageRef.getBoundingClientRect();const i=t/e;let g=n/o;if("contain"===l.currentImage.scaleAttr)if(i>g){const t=n/i;r+=(o-t)/2,o=t}else{const t=o*i;a+=(n-t)/2,n=t}g=n/o;let c=parseFloat("none"!==l.currentImage.targetWidth?l.currentImage.targetWidth:t),s=parseFloat("none"!==l.currentImage.targetHeight?l.currentImage.targetHeight:e),d=c/s,m=c,u=s,h=c,p=s;if(i.toFixed(2)!==d.toFixed(2)){if(i>d){const t=c/i;s-t>c?(s=t,c=t*i):s=c/i}else{const t=s*i;c-t>s?(c=t,s=t/i):c=s*i}h=c,p=s,d=c/s,g>d?(m=c,u=m/g):(u=s,m=u*g)}(n>h||o>p)&&(h=n,p=o);let f=0;window.innerWidth>480?f=80:window.innerWidth>1920&&(f=160);const y=Math.min(window.innerWidth-f,h),b=Math.min(window.innerHeight-80,p);g>y/b?(h=y,p=h/g):(p=b,h=p*g);const I=n/h,w=c*(h/m),x=s*(p/u);l.overlayStyles=`\n\t\t\t\t:root {\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${r}px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${a}px;\n\t\t\t\t\t--wp--lightbox-container-width: ${h+1}px;\n\t\t\t\t\t--wp--lightbox-container-height: ${p+1}px;\n\t\t\t\t\t--wp--lightbox-image-width: ${w}px;\n\t\t\t\t\t--wp--lightbox-image-height: ${x}px;\n\t\t\t\t\t--wp--lightbox-scale: ${I};\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${window.innerWidth-document.documentElement.clientWidth}px;\n\t\t\t\t}\n\t\t\t`},setButtonStyles(){const{imageId:t}=(0,n.getContext)(),{ref:e}=(0,n.getElement)();l.metadata[t].imageRef=e,l.metadata[t].currentSrc=e.currentSrc;const{naturalWidth:o,naturalHeight:a,offsetWidth:r,offsetHeight:i}=e;if(0===o||0===a)return;const g=e.parentElement,c=e.parentElement.clientWidth;let s=e.parentElement.clientHeight;const d=g.querySelector("figcaption");if(d){const t=window.getComputedStyle(d);["absolute","fixed"].includes(t.position)||(s=s-d.offsetHeight-parseFloat(t.marginTop)-parseFloat(t.marginBottom))}const m=s-i,u=c-r;let h=m+16,p=u+16;if("contain"===l.metadata[t].scaleAttr){const t=o/a;t>=r/i?(h=(i-r/t)/2+m+16,p=u+16):(h=m+16,p=(r-i*t)/2+u+16)}l.metadata[t].imageButtonTop=h,l.metadata[t].imageButtonRight=p},setOverlayFocus(){if(l.overlayEnabled){const{ref:t}=(0,n.getElement)();t.focus()}},initTriggerButton(){const{imageId:t}=(0,n.getContext)(),{ref:e}=(0,n.getElement)();l.metadata[t].buttonRef=e}}},{lock:!0});
//# sourceMappingURL=image.min.js.map