summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/image/view.min.js
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes/blocks/image/view.min.js')
-rw-r--r--wp-includes/blocks/image/view.min.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/wp-includes/blocks/image/view.min.js b/wp-includes/blocks/image/view.min.js
index af1d512..da52394 100644
--- a/wp-includes/blocks/image/view.min.js
+++ b/wp-includes/blocks/image/view.min.js
@@ -1 +1 @@
-"use strict";(self.__WordPressPrivateInteractivityAPI__=self.__WordPressPrivateInteractivityAPI__||[]).push([[354],{699:function(e,t,i){var o=i(754);const n=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];let a,r=!1,c=0;function l(e){!r&&Date.now()-c>450&&window.scrollTo(e.core.image.scrollLeftReset,e.core.image.scrollTopReset)}function g(e,t){let{naturalWidth:i,naturalHeight:o,offsetWidth:n,offsetHeight:a}=t,{x:r,y:c}=t.getBoundingClientRect();const l=i/o;let g=n/a;if("contain"===e.core.image.scaleAttr)if(l>g){const e=n/l;c+=(a-e)/2,a=e}else{const e=a*l;r+=(n-e)/2,n=e}g=n/a;let d=parseFloat("none"!==e.core.image.targetWidth?e.core.image.targetWidth:i),m=parseFloat("none"!==e.core.image.targetHeight?e.core.image.targetHeight:o),s=d/m,h=d,u=m,f=d,w=m;if(l.toFixed(2)!==s.toFixed(2)){if(l>s){const e=d/l;m-e>d?(m=e,d=e*l):m=d/l}else{const e=m*l;d-e>m?(d=e,m=e/l):d=m*l}f=d,w=m,s=d/m,g>s?(h=d,u=h/g):(u=m,h=u*g)}(n>f||a>w)&&(f=n,w=a);let b=0;window.innerWidth>480?b=80:window.innerWidth>1920&&(b=160);const x=Math.min(window.innerWidth-b,f),p=Math.min(window.innerHeight-80,w);g>x/p?(f=x,w=f/g):(w=p,f=w*g);const E=n/f,y=d*(f/h),v=m*(w/u);let A=document.getElementById("wp-lightbox-styles");A||(A=document.createElement("style"),A.id="wp-lightbox-styles",document.head.appendChild(A)),A.innerHTML=`\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${c}px;\n\t\t\t--wp--lightbox-initial-left-position: ${r}px;\n\t\t\t--wp--lightbox-container-width: ${f+1}px;\n\t\t\t--wp--lightbox-container-height: ${w+1}px;\n\t\t\t--wp--lightbox-image-width: ${y}px;\n\t\t\t--wp--lightbox-image-height: ${v}px;\n\t\t\t--wp--lightbox-scale: ${E};\n\t\t}\n\t`}(0,o.h)({state:{core:{image:{windowWidth:window.innerWidth,windowHeight:window.innerHeight}}},actions:{core:{image:{showLightbox:({context:e,event:t})=>{e.core.image.imageLoaded&&(e.core.image.initialized=!0,e.core.image.lastFocusedElement=window.document.activeElement,e.core.image.scrollDelta=0,e.core.image.pointerType=t.pointerType,e.core.image.lightboxEnabled=!0,g(e,e.core.image.imageRef),e.core.image.scrollTopReset=window.pageYOffset||document.documentElement.scrollTop,e.core.image.scrollLeftReset=window.pageXOffset||document.documentElement.scrollLeft,a=l.bind(null,e),window.addEventListener("scroll",a,!1))},hideLightbox:async({context:e})=>{e.core.image.hideAnimationEnabled=!0,e.core.image.lightboxEnabled&&(setTimeout((function(){window.removeEventListener("scroll",a),e.core.image.lightboxTriggerRef.focus({preventScroll:!0})}),450),e.core.image.lightboxEnabled=!1)},handleKeydown:({context:e,actions:t,event:i})=>{e.core.image.lightboxEnabled&&("Tab"!==i.key&&9!==i.keyCode||(i.shiftKey&&window.document.activeElement===e.core.image.firstFocusableElement?(i.preventDefault(),e.core.image.lastFocusableElement.focus()):i.shiftKey||window.document.activeElement!==e.core.image.lastFocusableElement||(i.preventDefault(),e.core.image.firstFocusableElement.focus())),"Escape"!==i.key&&27!==i.keyCode||t.core.image.hideLightbox({context:e,event:i}))},handleLoad:({context:e,effects:t,ref:i})=>{e.core.image.imageLoaded=!0,e.core.image.imageCurrentSrc=i.currentSrc,t.core.image.setButtonStyles({context:e,ref:i})},handleTouchStart:()=>{r=!0},handleTouchMove:({context:e,event:t})=>{e.core.image.lightboxEnabled&&t.preventDefault()},handleTouchEnd:()=>{c=Date.now(),r=!1}}}},selectors:{core:{image:{roleAttribute:({context:e})=>e.core.image.lightboxEnabled?"dialog":null,ariaModal:({context:e})=>e.core.image.lightboxEnabled?"true":null,dialogLabel:({context:e})=>e.core.image.lightboxEnabled?e.core.image.dialogLabel:null,lightboxObjectFit:({context:e})=>{if(e.core.image.initialized)return"cover"},enlargedImgSrc:({context:e})=>e.core.image.initialized?e.core.image.imageUploadedSrc:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="}}},effects:{core:{image:{initOriginImage:({context:e,ref:t})=>{e.core.image.imageRef=t,e.core.image.lightboxTriggerRef=t.parentElement.querySelector(".lightbox-trigger"),t.complete&&(e.core.image.imageLoaded=!0,e.core.image.imageCurrentSrc=t.currentSrc)},initLightbox:async({context:e,ref:t})=>{if(e.core.image.lightboxEnabled){const i=t.querySelectorAll(n);e.core.image.firstFocusableElement=i[0],e.core.image.lastFocusableElement=i[i.length-1],t.focus()}},setButtonStyles:({context:e,ref:t})=>{const{naturalWidth:i,naturalHeight:o,offsetWidth:n,offsetHeight:a}=t;if(0===i||0===o)return;const r=t.parentElement,c=t.parentElement.clientWidth;let l=t.parentElement.clientHeight;const g=r.querySelector("figcaption");if(g){const e=window.getComputedStyle(g);l=l-g.offsetHeight-parseFloat(e.marginTop)-parseFloat(e.marginBottom)}const d=l-a,m=c-n;if("contain"===e.core.image.scaleAttr){const t=i/o;if(t>=n/a){const i=n/t;e.core.image.imageButtonTop=(a-i)/2+d+16,e.core.image.imageButtonRight=m+16}else{const i=a*t;e.core.image.imageButtonTop=d+16,e.core.image.imageButtonRight=(n-i)/2+m+16}}else e.core.image.imageButtonTop=d+16,e.core.image.imageButtonRight=m+16},setStylesOnResize:({state:e,context:t,ref:i})=>{t.core.image.lightboxEnabled&&(e.core.image.windowWidth||e.core.image.windowHeight)&&g(t,i)}}}}},{afterLoad:({state:e})=>{window.addEventListener("resize",function(e,t=50){let i;return()=>{const o=()=>{i=null,e()};clearTimeout(i),i=setTimeout(o,t)}}((()=>{e.core.image.windowWidth=window.innerWidth,e.core.image.windowHeight=window.innerHeight})))}})}},function(e){var t;t=699,e(e.s=t)}]); \ No newline at end of file
+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=(t=>{var n={};return e.d(n,t),n})({getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store});let o,r,i=!1,l=0;const{state:a,actions:c,callbacks:s}=(0,n.store)("core/image",{state:{currentImage:{},get overlayOpened(){return a.currentImage.currentSrc},get roleAttribute(){return a.overlayOpened?"dialog":null},get ariaModal(){return a.overlayOpened?"true":null},get enlargedSrc(){return a.currentImage.uploadedSrc||"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},get imgStyles(){return a.overlayOpened&&`${a.currentImage.imgStyles?.replace(/;$/,"")}; object-fit:cover;`}},actions:{showLightbox(){const t=(0,n.getContext)();t.imageRef?.complete&&(a.scrollTopReset=document.documentElement.scrollTop,a.scrollLeftReset=document.documentElement.scrollLeft,t.currentSrc=t.imageRef.currentSrc,o=t.imageRef,r=t.buttonRef,a.currentImage=t,a.overlayEnabled=!0,s.setOverlayStyles())},hideLightbox(){a.overlayEnabled&&(setTimeout((function(){r.focus({preventScroll:!0}),a.currentImage={},o=null,r=null}),450),a.showClosingAnimation=!0,a.overlayEnabled=!1)},handleKeydown(t){if(a.overlayEnabled){if("Tab"===t.key){t.preventDefault();const{ref:e}=(0,n.getElement)();e.querySelector("button").focus()}"Escape"===t.key&&c.hideLightbox()}},handleTouchMove(t){a.overlayEnabled&&t.preventDefault()},handleTouchStart(){i=!0},handleTouchEnd(){l=Date.now(),i=!1},handleScroll(){a.overlayOpened&&!i&&Date.now()-l>450&&window.scrollTo(a.scrollLeftReset,a.scrollTopReset)}},callbacks:{setOverlayStyles(){if(!o)return;let{naturalWidth:t,naturalHeight:e,offsetWidth:n,offsetHeight:r}=o,{x:i,y:l}=o.getBoundingClientRect();const c=t/e;let s=n/r;if("contain"===a.currentImage.scaleAttr)if(c>s){const t=n/c;l+=(r-t)/2,r=t}else{const t=r*c;i+=(n-t)/2,n=t}s=n/r;let g=parseFloat("none"!==a.currentImage.targetWidth?a.currentImage.targetWidth:t),u=parseFloat("none"!==a.currentImage.targetHeight?a.currentImage.targetHeight:e),d=g/u,h=g,m=u,p=g,f=u;if(c.toFixed(2)!==d.toFixed(2)){if(c>d){const t=g/c;u-t>g?(u=t,g=t*c):u=g/c}else{const t=u*c;g-t>u?(g=t,u=t/c):g=u*c}p=g,f=u,d=g/u,s>d?(h=g,m=h/s):(m=u,h=m*s)}(n>p||r>f)&&(p=n,f=r);let w=0;window.innerWidth>480?w=80:window.innerWidth>1920&&(w=160);const y=Math.min(window.innerWidth-w,p),b=Math.min(window.innerHeight-80,f);s>y/b?(p=y,f=p/s):(f=b,p=f*s);const x=n/p,v=g*(p/h),A=u*(f/m);a.overlayStyles=`\n\t\t\t\t:root {\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${l}px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${i}px;\n\t\t\t\t\t--wp--lightbox-container-width: ${p+1}px;\n\t\t\t\t\t--wp--lightbox-container-height: ${f+1}px;\n\t\t\t\t\t--wp--lightbox-image-width: ${v}px;\n\t\t\t\t\t--wp--lightbox-image-height: ${A}px;\n\t\t\t\t\t--wp--lightbox-scale: ${x};\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 t=(0,n.getContext)(),{ref:e}=(0,n.getElement)();t.imageRef=e;const{naturalWidth:o,naturalHeight:r,offsetWidth:i,offsetHeight:l}=e;if(0===o||0===r)return;const a=e.parentElement,c=e.parentElement.clientWidth;let s=e.parentElement.clientHeight;const g=a.querySelector("figcaption");if(g){const t=window.getComputedStyle(g);["absolute","fixed"].includes(t.position)||(s=s-g.offsetHeight-parseFloat(t.marginTop)-parseFloat(t.marginBottom))}const u=s-l,d=c-i;if("contain"===t.scaleAttr){const e=o/r;if(e>=i/l){const n=i/e;t.imageButtonTop=(l-n)/2+u+16,t.imageButtonRight=d+16}else{const n=l*e;t.imageButtonTop=u+16,t.imageButtonRight=(i-n)/2+d+16}}else t.imageButtonTop=u+16,t.imageButtonRight=d+16},setOverlayFocus(){if(a.overlayEnabled){const{ref:t}=(0,n.getElement)();t.focus()}},initTriggerButton(){const t=(0,n.getContext)(),{ref:e}=(0,n.getElement)();t.buttonRef=e}}},{lock:!0}); \ No newline at end of file