heroweb/poc/in/assets/js/plugins/photoswipe-ui-default.min.js
2024-09-02 07:28:06 +02:00

7 lines
9.6 KiB
JavaScript

/**
*
* UI on top of main sliding area (caption, arrows, close button, etc.).
* Built just using public methods/properties of PhotoSwipe.
*
*/
!function(b,a){"function"==typeof define&&define.amd?define(a):"object"==typeof exports?module.exports=a():b.PhotoSwipeUI_Default=a()}(this,function(){return function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,a=this,w=!1,x=!0,y=!0,z={barsSize:{top:44,bottom:"auto"},closeElClasses:["item","caption","zoom-wrap","ui","top-bar"],timeToIdle:4e3,timeToIdleOutside:1e3,loadingIndicatorDelay:1e3,addCaptionHTMLFn:function(a,b){return a.title?(b.children[0].innerHTML=a.title,!0):(b.children[0].innerHTML="",!1)},closeEl:!0,captionEl:!0,fullscreenEl:!0,zoomEl:!0,shareEl:!0,counterEl:!0,arrowEl:!0,preloaderEl:!0,tapToClose:!1,tapToToggleControls:!0,clickToCloseNonZoomable:!0,shareButtons:[{id:"facebook",label:"Share on Facebook",url:"https://www.facebook.com/sharer/sharer.php?u={{url}}"},{id:"twitter",label:"Tweet",url:"https://twitter.com/intent/tweet?text={{text}}&url={{url}}"},{id:"pinterest",label:"Pin it",url:"http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}"},{id:"download",label:"Download image",url:"{{raw_image_url}}",download:!0}],getImageURLForShare:function(){return b.currItem.src||""},getPageURLForShare:function(){return window.location.href},getTextForShare:function(){return b.currItem.title||""},indexIndicatorSep:" / ",fitControlsWidth:1200},A=function(a){if(s)return!0;a=a||window.event,r.timeToIdle&&r.mouseUsed&&!l&&J();for(var b,e,f=(a.target||a.srcElement).getAttribute("class")||"",d=0;d<R.length;d++)(b=R[d]).onTap&&f.indexOf("pswp__"+b.name)> -1&&(b.onTap(),e=!0);e&&(a.stopPropagation&&a.stopPropagation(),s=!0,t=setTimeout(function(){s=!1},c.features.isOldAndroid?600:30))},B=function(a,b,d){c[(d?"add":"remove")+"Class"](a,"pswp__"+b)},C=function(){var a=1===r.getNumItemsFn();a!==q&&(B(e,"ui--one-slide",a),q=a)},D=function(){B(j,"share-modal--hidden",y)},E=function(){return(y=!y)?(c.removeClass(j,"pswp__share-modal--fade-in"),setTimeout(function(){y&&D()},300)):(D(),setTimeout(function(){y||c.addClass(j,"pswp__share-modal--fade-in")},30)),y||G(),!1},F=function(a){var c=(a=a||window.event).target||a.srcElement;return b.shout("shareLinkClick",a,c),!!c.href&&(!!c.hasAttribute("download")||(window.open(c.href,"pswp_share","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,top=100,left="+(window.screen?Math.round(screen.width/2-275):100)),y||E(),!1))},G=function(){for(var a,e,c,f,g,b="",d=0;d<r.shareButtons.length;d++)a=r.shareButtons[d],c=r.getImageURLForShare(a),f=r.getPageURLForShare(a),g=r.getTextForShare(a),e=a.url.replace("{{url}}",encodeURIComponent(f)).replace("{{image_url}}",encodeURIComponent(c)).replace("{{raw_image_url}}",c).replace("{{text}}",encodeURIComponent(g)),b+='<a href="'+e+'" target="_blank" class="pswp__share--'+a.id+'"'+(a.download?"download":"")+">"+a.label+"</a>",r.parseShareButtonOut&&(b=r.parseShareButtonOut(a,b));j.children[0].innerHTML=b,j.children[0].onclick=F},H=function(b){for(var a=0;a<r.closeElClasses.length;a++)if(c.hasClass(b,"pswp__"+r.closeElClasses[a]))return!0},I=0,J=function(){clearTimeout(v),I=0,l&&a.setIdle(!1)},K=function(b){var c=(b=b||window.event).relatedTarget||b.toElement;c&&"HTML"!==c.nodeName||(clearTimeout(v),v=setTimeout(function(){a.setIdle(!0)},r.timeToIdleOutside))},L=function(){r.fullscreenEl&&!c.features.isOldAndroid&&(d||(d=a.getFullscreenAPI()),d?(c.bind(document,d.eventK,a.updateFullscreen),a.updateFullscreen(),c.addClass(b.template,"pswp--supports-fs")):c.removeClass(b.template,"pswp--supports-fs"))},M=function(){r.preloaderEl&&(N(!0),m("beforeChange",function(){clearTimeout(p),p=setTimeout(function(){b.currItem&&b.currItem.loading?b.allowProgressiveImg()&&(!b.currItem.img||b.currItem.img.naturalWidth)||N(!1):N(!0)},r.loadingIndicatorDelay)}),m("imageLoadComplete",function(c,a){b.currItem===a&&N(!0)}))},N=function(a){o!==a&&(B(n,"preloader--active",!a),o=a)},O=function(h){var a=h.vGap;if(!b.likelyTouchDevice||r.mouseUsed||screen.width>r.fitControlsWidth){var d=r.barsSize;if(r.captionEl&&"auto"===d.bottom){if(g||((g=c.createEl("pswp__caption pswp__caption--fake")).appendChild(c.createEl("pswp__caption__center")),e.insertBefore(g,f),c.addClass(e,"pswp__ui--fit")),r.addCaptionHTMLFn(h,g,!0)){var i=g.clientHeight;a.bottom=parseInt(i,10)||44}else a.bottom=d.top}else a.bottom="auto"===d.bottom?0:d.bottom;a.top=d.top}else a.top=a.bottom=0},P=function(){r.timeToIdle&&m("mouseUsed",function(){c.bind(document,"mousemove",J),c.bind(document,"mouseout",K),u=setInterval(function(){2== ++I&&a.setIdle(!0)},r.timeToIdle/2)})},Q=function(){var b;m("onVerticalDrag",function(b){x&&b<.95?a.hideControls():!x&&b>=.95&&a.showControls()}),m("onPinchClose",function(c){x&&c<.9?(a.hideControls(),b=!0):b&&!x&&c>.9&&a.showControls()}),m("zoomGestureEnded",function(){b=!1})},R=[{name:"caption",option:"captionEl",onInit:function(a){f=a}},{name:"share-modal",option:"shareEl",onInit:function(a){j=a},onTap:function(){E()}},{name:"button--share",option:"shareEl",onInit:function(a){i=a},onTap:function(){E()}},{name:"button--zoom",option:"zoomEl",onTap:b.toggleDesktopZoom},{name:"counter",option:"counterEl",onInit:function(a){h=a}},{name:"button--close",option:"closeEl",onTap:b.close},{name:"button--arrow--left",option:"arrowEl",onTap:b.prev},{name:"button--arrow--right",option:"arrowEl",onTap:b.next},{name:"button--fs",option:"fullscreenEl",onTap:function(){d.isFullscreen()?d.exit():d.enter()}},{name:"preloader",option:"preloaderEl",onInit:function(a){n=a}}],S=function(){var d,f,g,a=function(a){if(a)for(var h=a.length,b=0;b<h;b++){f=(d=a[b]).className;for(var e=0;e<R.length;e++)g=R[e],f.indexOf("pswp__"+g.name)> -1&&(r[g.option]?(c.removeClass(d,"pswp__element--disabled"),g.onInit&&g.onInit(d)):c.addClass(d,"pswp__element--disabled"))}};a(e.children);var b=c.getChildByClass(e,"pswp__top-bar");b&&a(b.children)};a.init=function(){c.extend(b.options,z,!0),r=b.options,e=c.getChildByClass(b.scrollWrap,"pswp__ui"),m=b.listen,Q(),m("beforeChange",a.update),m("doubleTap",function(a){var c=b.currItem.initialZoomLevel;b.getZoomLevel()!==c?b.zoomTo(c,a,333):b.zoomTo(r.getDoubleTapZoom(!1,b.currItem),a,333)}),m("preventDragEvent",function(b,d,c){var a=b.target||b.srcElement;a&&a.getAttribute("class")&&b.type.indexOf("mouse")> -1&&(a.getAttribute("class").indexOf("__caption")>0||/(SMALL|STRONG|EM)/i.test(a.tagName))&&(c.prevent=!1)}),m("bindEvents",function(){c.bind(e,"pswpTap click",A),c.bind(b.scrollWrap,"pswpTap",a.onGlobalTap),b.likelyTouchDevice||c.bind(b.scrollWrap,"mouseover",a.onMouseOver)}),m("unbindEvents",function(){y||E(),u&&clearInterval(u),c.unbind(document,"mouseout",K),c.unbind(document,"mousemove",J),c.unbind(e,"pswpTap click",A),c.unbind(b.scrollWrap,"pswpTap",a.onGlobalTap),c.unbind(b.scrollWrap,"mouseover",a.onMouseOver),d&&(c.unbind(document,d.eventK,a.updateFullscreen),d.isFullscreen()&&(r.hideAnimationDuration=0,d.exit()),d=null)}),m("destroy",function(){r.captionEl&&(g&&e.removeChild(g),c.removeClass(f,"pswp__caption--empty")),j&&(j.children[0].onclick=null),c.removeClass(e,"pswp__ui--over-close"),c.addClass(e,"pswp__ui--hidden"),a.setIdle(!1)}),r.showAnimationDuration||c.removeClass(e,"pswp__ui--hidden"),m("initialZoomIn",function(){r.showAnimationDuration&&c.removeClass(e,"pswp__ui--hidden")}),m("initialZoomOut",function(){c.addClass(e,"pswp__ui--hidden")}),m("parseVerticalMargin",O),S(),r.shareEl&&i&&j&&(y=!0),C(),P(),L(),M()},a.setIdle=function(a){l=a,B(e,"ui--idle",a)},a.update=function(){x&&b.currItem?(a.updateIndexIndicator(),r.captionEl&&(r.addCaptionHTMLFn(b.currItem,f),B(f,"caption--empty",!b.currItem.title)),w=!0):w=!1,y||E(),C()},a.updateFullscreen=function(a){a&&setTimeout(function(){b.setScrollOffset(0,c.getScrollY())},50),c[(d.isFullscreen()?"add":"remove")+"Class"](b.template,"pswp--fs")},a.updateIndexIndicator=function(){r.counterEl&&(h.innerHTML=b.getCurrentIndex()+1+r.indexIndicatorSep+r.getNumItemsFn())},a.onGlobalTap=function(d){var e=(d=d||window.event).target||d.srcElement;if(!s){if(d.detail&&"mouse"===d.detail.pointerType){if(H(e)){b.close();return}c.hasClass(e,"pswp__img")&&(1===b.getZoomLevel()&&b.getZoomLevel()<=b.currItem.fitRatio?r.clickToCloseNonZoomable&&b.close():b.toggleDesktopZoom(d.detail.releasePoint))}else if(r.tapToToggleControls&&(x?a.hideControls():a.showControls()),r.tapToClose&&(c.hasClass(e,"pswp__img")||H(e))){b.close();return}}},a.onMouseOver=function(a){B(e,"ui--over-close",H((a=a||window.event).target||a.srcElement))},a.hideControls=function(){c.addClass(e,"pswp__ui--hidden"),x=!1},a.showControls=function(){x=!0,w||a.update(),c.removeClass(e,"pswp__ui--hidden")},a.supportsFullscreen=function(){var a=document;return!!(a.exitFullscreen||a.mozCancelFullScreen||a.webkitExitFullscreen||a.msExitFullscreen)},a.getFullscreenAPI=function(){var a,c=document.documentElement,d="fullscreenchange";return c.requestFullscreen?a={enterK:"requestFullscreen",exitK:"exitFullscreen",elementK:"fullscreenElement",eventK:d}:c.mozRequestFullScreen?a={enterK:"mozRequestFullScreen",exitK:"mozCancelFullScreen",elementK:"mozFullScreenElement",eventK:"moz"+d}:c.webkitRequestFullscreen?a={enterK:"webkitRequestFullscreen",exitK:"webkitExitFullscreen",elementK:"webkitFullscreenElement",eventK:"webkit"+d}:c.msRequestFullscreen&&(a={enterK:"msRequestFullscreen",exitK:"msExitFullscreen",elementK:"msFullscreenElement",eventK:"MSFullscreenChange"}),a&&(a.enter=function(){if(k=r.closeOnScroll,r.closeOnScroll=!1,"webkitRequestFullscreen"!==this.enterK)return b.template[this.enterK]();b.template[this.enterK](Element.ALLOW_KEYBOARD_INPUT)},a.exit=function(){return r.closeOnScroll=k,document[this.exitK]()},a.isFullscreen=function(){return document[this.elementK]}),a}}})