CoreFiles by mySites.guru
view.min.js1 lines, 4,663 bytes, from wordpress-6.8.13.zip
Raw History Compare with 6.8.12
md5
e053fe3fccb5808abf9c8627775bbc24
sha1
da0fbd175fbcc548c24a5f0d8285a0c6df932165
sha256
685b5721645cdbe080b585a17dfd6ff20ae6064bc15855ff5f841007d85b82b0
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,withSyncEvent:()=>t.withSyncEvent});let o=!1,r=0;function i(t){const e=a.metadata[t];return Object.hasOwn(a.metadata,t)?e:void 0}const{state:a,actions:l,callbacks:c}=(0,n.store)("core/image",{state:{currentImageId:null,get currentImage(){return i(a.currentImageId)},get overlayOpened(){return null!==a.currentImageId},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 figureStyles(){return a.overlayOpened&&`${a.currentImage.figureStyles?.replace(/margin[^;]*;?/g,"")};`},get imgStyles(){return a.overlayOpened&&`${a.currentImage.imgStyles?.replace(/;$/,"")}; object-fit:cover;`},get imageButtonRight(){const{imageId:t}=(0,n.getContext)();return i(t)?.imageButtonRight},get imageButtonTop(){const{imageId:t}=(0,n.getContext)();return i(t)?.imageButtonTop},get isContentHidden(){const t=(0,n.getContext)();return a.overlayEnabled&&a.currentImageId===t.imageId},get isContentVisible(){const t=(0,n.getContext)();return!a.overlayEnabled&&a.currentImageId===t.imageId}},actions:{showLightbox(){const{imageId:t}=(0,n.getContext)();i(t)?.imageRef?.complete&&(a.scrollTopReset=document.documentElement.scrollTop,a.scrollLeftReset=document.documentElement.scrollLeft,a.overlayEnabled=!0,a.currentImageId=t,c.setOverlayStyles())},hideLightbox(){a.overlayEnabled&&(a.showClosingAnimation=!0,a.overlayEnabled=!1,setTimeout((function(){a.currentImage.buttonRef.focus({preventScroll:!0}),a.currentImageId=null}),450))},handleKeydown:(0,n.withSyncEvent)((t=>{if(a.overlayEnabled){if("Tab"===t.key){t.preventDefault();const{ref:e}=(0,n.getElement)();e.querySelector("button").focus()}"Escape"===t.key&&l.hideLightbox()}})),handleTouchMove:(0,n.withSyncEvent)((t=>{a.overlayEnabled&&t.preventDefault()})),handleTouchStart(){o=!0},handleTouchEnd(){r=Date.now(),o=!1},handleScroll(){a.overlayOpened&&!o&&Date.now()-r>450&&window.scrollTo(a.scrollLeftReset,a.scrollTopReset)}},callbacks:{setOverlayStyles(){if(!a.overlayEnabled)return;let{naturalWidth:t,naturalHeight:e,offsetWidth:n,offsetHeight:o}=a.currentImage.imageRef,{x:r,y:i}=a.currentImage.imageRef.getBoundingClientRect();const l=t/e;let c=n/o;if("contain"===a.currentImage.scaleAttr)if(l>c){const t=n/l;i+=(o-t)/2,o=t}else{const t=o*l;r+=(n-t)/2,n=t}c=n/o;let g=parseFloat("none"!==a.currentImage.targetWidth?a.currentImage.targetWidth:t),s=parseFloat("none"!==a.currentImage.targetHeight?a.currentImage.targetHeight:e),d=g/s,u=g,m=s,h=g,p=s;if(l.toFixed(2)!==d.toFixed(2)){if(l>d){const t=g/l;s-t>g?(s=t,g=t*l):s=g/l}else{const t=s*l;g-t>s?(g=t,s=t/l):g=s*l}h=g,p=s,d=g/s,c>d?(u=g,m=u/c):(m=s,u=m*c)}(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),w=Math.min(window.innerHeight-80,p);c>y/w?(h=y,p=h/c):(p=w,h=p*c);const b=n/h,v=g*(h/u),I=s*(p/m);a.overlayStyles=`\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${i}px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${r}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: ${v}px;\n\t\t\t\t\t--wp--lightbox-image-height: ${I}px;\n\t\t\t\t\t--wp--lightbox-scale: ${b};\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${window.innerWidth-document.documentElement.clientWidth}px;\n\t\t\t\t`},setButtonStyles(){const{imageId:t}=(0,n.getContext)(),e=i(t);if(!e)return;const{ref:o}=(0,n.getElement)();e.imageRef=o,e.currentSrc=o.currentSrc;const{naturalWidth:r,naturalHeight:a,offsetWidth:l,offsetHeight:c}=o;if(0===r||0===a)return;const g=o.parentElement,s=o.parentElement.clientWidth;let d=o.parentElement.clientHeight;const u=g.querySelector("figcaption");if(u){const t=window.getComputedStyle(u);["absolute","fixed"].includes(t.position)||(d=d-u.offsetHeight-parseFloat(t.marginTop)-parseFloat(t.marginBottom))}const m=d-c,h=s-l;let p=m+16,f=h+16;if("contain"===e.scaleAttr){const t=r/a;if(t>=l/c){p=(c-l/t)/2+m+16,f=h+16}else{p=m+16,f=(l-c*t)/2+h+16}}e.imageButtonTop=p,e.imageButtonRight=f},setOverlayFocus(){if(a.overlayEnabled){const{ref:t}=(0,n.getElement)();t.focus()}},initTriggerButton(){const{imageId:t}=(0,n.getContext)(),{ref:e}=(0,n.getElement)(),o=i(t);o&&(o.buttonRef=e)}}},{lock:!0});

The same content is in 2 releases, WordPress 6.8.12 to 6.8.13. See them all, or every version of this file.