@hodgef/press-theme
Version:
Press Theme for PRSS
2 lines • 6.66 kB
JavaScript
(()=>{var t={374:()=>{!function(t){"use strict";t.fn.emulateTransitionEnd=function(o){var e=!1,i=this;t(this).one("bsTransitionEnd",function(){e=!0});return setTimeout(function(){e||t(i).trigger(t.support.transition.end)},o),this},t(function(){t.support.transition=function(){var t=document.createElement("bootstrap"),o={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var e in o)if(void 0!==t.style[e])return{end:o[e]};return!1}(),t.support.transition&&(t.event.special.bsTransitionEnd={bindType:t.support.transition.end,delegateType:t.support.transition.end,handle:function(o){if(t(o.target).is(this))return o.handleObj.handler.apply(this,arguments)}})})}(jQuery),function(t){"use strict";function o(){this._activeZoom=this._initialScrollPosition=this._initialTouchPosition=this._touchMoveListener=null,this._$document=t(document),this._$window=t(window),this._$body=t(document.body),this._boundClick=t.proxy(this._clickHandler,this)}function e(o){this._fullHeight=this._fullWidth=this._overlay=this._targetImageWrap=null,this._targetImage=o,this._$body=t(document.body)}o.prototype.listen=function(){this._$body.on("click",'[data-action="zoom"]',t.proxy(this._zoom,this))},o.prototype._zoom=function(o){var i=o.target;if(i&&"IMG"==i.tagName&&!this._$body.hasClass("zoom-overlay-open"))return o.metaKey||o.ctrlKey?window.open(o.target.getAttribute("data-original")||o.target.src,"_blank"):void(i.width>=t(window).width()-e.OFFSET||(this._activeZoomClose(!0),this._activeZoom=new e(i),this._activeZoom.zoomImage(),this._$window.on("scroll.zoom",t.proxy(this._scrollHandler,this)),this._$document.on("keyup.zoom",t.proxy(this._keyHandler,this)),this._$document.on("touchstart.zoom",t.proxy(this._touchStart,this)),document.addEventListener?document.addEventListener("click",this._boundClick,!0):document.attachEvent("onclick",this._boundClick,!0),"bubbles"in o?o.bubbles&&o.stopPropagation():o.cancelBubble=!0))},o.prototype._activeZoomClose=function(t){this._activeZoom&&(t?this._activeZoom.dispose():this._activeZoom.close(),this._$window.off(".zoom"),this._$document.off(".zoom"),document.removeEventListener("click",this._boundClick,!0),this._activeZoom=null)},o.prototype._scrollHandler=function(o){null===this._initialScrollPosition&&(this._initialScrollPosition=t(window).scrollTop());var e=this._initialScrollPosition-t(window).scrollTop();Math.abs(e)>=40&&this._activeZoomClose()},o.prototype._keyHandler=function(t){27==t.keyCode&&this._activeZoomClose()},o.prototype._clickHandler=function(t){t.preventDefault?t.preventDefault():event.returnValue=!1,"bubbles"in t?t.bubbles&&t.stopPropagation():t.cancelBubble=!0,this._activeZoomClose()},o.prototype._touchStart=function(o){this._initialTouchPosition=o.touches[0].pageY,t(o.target).on("touchmove.zoom",t.proxy(this._touchMove,this))},o.prototype._touchMove=function(o){Math.abs(o.touches[0].pageY-this._initialTouchPosition)>10&&(this._activeZoomClose(),t(o.target).off("touchmove.zoom"))},e.OFFSET=80,e._MAX_WIDTH=2560,e._MAX_HEIGHT=4096,e.prototype.zoomImage=function(){var o=document.createElement("img");o.onload=t.proxy(function(){this._fullHeight=Number(o.height),this._fullWidth=Number(o.width),this._zoomOriginal()},this),o.src=this._targetImage.src},e.prototype._zoomOriginal=function(){this._targetImageWrap=document.createElement("div"),this._targetImageWrap.className="zoom-img-wrap",this._targetImage.parentNode.insertBefore(this._targetImageWrap,this._targetImage),this._targetImageWrap.appendChild(this._targetImage),t(this._targetImage).addClass("zoom-img").attr("data-action","zoom-out"),this._overlay=document.createElement("div"),this._overlay.className="zoom-overlay",document.body.appendChild(this._overlay),this._calculateZoom(),this._triggerAnimation()},e.prototype._calculateZoom=function(){this._targetImage.offsetWidth;var o=this._fullWidth,i=this._fullHeight,a=(t(window).scrollTop(),o/this._targetImage.width),n=t(window).height()-e.OFFSET,r=t(window).width()-e.OFFSET,s=o/i,l=r/n;this._imgScaleFactor=r>o&&n>i?a:l>s?n/i*a:r/o*a},e.prototype._triggerAnimation=function(){this._targetImage.offsetWidth;var o=t(this._targetImage).offset(),e=t(window).scrollTop()+t(window).height()/2,i=t(window).width()/2,a=o.top+this._targetImage.height/2,n=o.left+this._targetImage.width/2;this._translateY=e-a,this._translateX=i-n;var r="scale("+this._imgScaleFactor+")",s="translate("+this._translateX+"px, "+this._translateY+"px)";t.support.transition&&(s+=" translateZ(0)"),t(this._targetImage).css({"-webkit-transform":r,"-ms-transform":r,transform:r}),t(this._targetImageWrap).css({"-webkit-transform":s,"-ms-transform":s,transform:s}),this._$body.addClass("zoom-overlay-open")},e.prototype.close=function(){return this._$body.removeClass("zoom-overlay-open").addClass("zoom-overlay-transitioning"),t(this._targetImage).css({"-webkit-transform":"","-ms-transform":"",transform:""}),t(this._targetImageWrap).css({"-webkit-transform":"","-ms-transform":"",transform:""}),t.support.transition?void t(this._targetImage).one(t.support.transition.end,t.proxy(this.dispose,this)).emulateTransitionEnd(300):this.dispose()},e.prototype.dispose=function(){this._targetImageWrap&&this._targetImageWrap.parentNode&&(t(this._targetImage).removeClass("zoom-img").attr("data-action","zoom"),this._targetImageWrap.parentNode.replaceChild(this._targetImage,this._targetImageWrap),this._overlay.parentNode.removeChild(this._overlay),this._$body.removeClass("zoom-overlay-transitioning"))},t(function(){(new o).listen()})}(jQuery)}},o={};function e(i){var a=o[i];if(void 0!==a)return a.exports;var n=o[i]={exports:{}};return t[i](n,n.exports,e),n.exports}e.n=t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},e.d=(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},e.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),(()=>{"use strict";var t,o;e(374);"true"===localStorage.getItem("dark-mode")&&document.body.classList.add("dark"),null===(t=document.querySelector(".toggle-dark-mode"))||void 0===t||t.addEventListener("click",function(){document.body.classList.toggle("dark"),localStorage.setItem("dark-mode",document.body.classList.contains("dark")?"true":"false")}),null===(o=document.querySelectorAll(".post-inner-content img"))||void 0===o||o.forEach(function(t){if(t&&!t.classList.contains("no-zoom")&&"none"!==t.getAttribute("data-action")){var o=new Image;o.onload=function(){o.naturalWidth>500&&o.naturalHeight>500&&t.setAttribute("data-action","zoom")},o.src=t.getAttribute("src")||""}})})()})();
//# sourceMappingURL=client.js.map