/* # ----------------------------------------------------------------------------- # ~/assets/theme/j1/modules/backstretch/js/backstretch.min.js # Backstretch v.2.1.16 implementation for J1 Theme. # # Product/Info: # https://jekyll.one # http://srobbin.com/jquery-plugins/backstretch/ # # Copyright (C) 2023, 2024 Juergen Adams # Copyright (C) 2017 Daniel Cohen Gindi # Copyright (C) 2012 Scott Robbin # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE # Backstretch is licensed under the MIT License. # See: https://github.com/danielgindi/jquery-backstretch # ----------------------------------------------------------------------------- */ "use strict";!function(t,e,i){var r,a=/^.*(youtu\.be\/|youtube\.com\/v\/|youtube\.com\/embed\/|youtube\.com\/watch\?v=|youtube\.com\/watch\?.*\&v=)([^#\&\?]*).*/i;t.fn.backstretch=function(r,a){var o,n=arguments;return 0===t(e).scrollTop()&&e.scrollTo(0,0),this.each((function(e){var s=t(this),h=s.data("backstretch");if(h){if("string"==typeof n[0]&&"function"==typeof h[n[0]]){var c=h[n[0]].apply(h,Array.prototype.slice.call(n,1));return c===h&&(c=i),void(c!==i&&((o=o||[])[e]=c))}a=t.extend(h.options,a),h.hasOwnProperty("destroy")&&h.destroy(!0)}if(!r||r&&0===r.length){var d=s.css("background-image");d&&"none"!==d?r=[{url:s.css("backgroundImage").replace(/url\(|\)|"|'/g,"")}]:t.error("No images were supplied for Backstretch, or element must have a CSS-defined background image.")}h=new w(this,r,a||{}),s.data("backstretch",h)})),o?1===o.length?o[0]:o:this},t.backstretch=function(e,i){return t("body").backstretch(e,i).data("backstretch")},t.expr[":"].backstretch=function(e){return t(e).data("backstretch")!==i},t.fn.backstretch.defaults={debug:!1,duration:5e3,transition:"fade",transitionDuration:0,animateFirst:!0,alignX:.5,alignY:.5,paused:!1,start:0,preload:2,preloadSize:1,resolutionRefreshRate:2500,resolutionChangeRatioThreshold:.1};var o,n,s,h,c,d,l={wrap:{left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zIndex:-999999},itemWrapper:{position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"100%",height:"100%",zIndex:-999999},item:{position:"absolute",margin:0,padding:0,border:"none",width:"100%",height:"100%",maxWidth:"none"}},u=(o=function(t){for(var e=1;eparseInt(i.width,10);)t[r]=t[r-1],--r;t[r]=i}return t},n=function(t,i,r){for(var a,o,n=e.devicePixelRatio||1,s=z(),h=(S(),i>t?"portrait":t>i?"landscape":"square"),c=0,d=0;d=a)));d++);return r[Math.min(d,c)]},s=function(t,e){if("string"==typeof t)t=t.replace(/{{(width|height)}}/g,e);else if(t instanceof Array)for(var i=0;i=i.length&&(r=0,a=0),o<0&&(o=a),o=Math.min(o,a);var s=i.slice(r+o,a-o);if(i=i.slice(r,o),a=i.length)for(var h,l=0,u=function(){++l===a&&(d(i,n,!s),e(s,0,0,o,n))},g=0;g=this.images.length&&(this.options.start=this.images.length-1),this.options.start<0&&(this.options.start=0),this.isBody=i===document.body;var o=t(e);this.$container=t(i),this.$root=this.isBody?A?o:t(document):this.$container,this.originalImages=this.images,this.images=u(this.options.alwaysTestWindowResolution?o:this.$root,this.originalImages),g(this.images,this.options.start||0,this.options.preload||1);var n=this.$container.children(".backstretch").first();if(this.$wrap=n.length?n:t('
').css(this.options.bypassCss?{}:l.wrap).appendTo(this.$container),!this.options.bypassCss){if(!this.isBody){var s=this.$container.css("position"),h=this.$container.css("zIndex");this.$container.css({position:"static"===s?"relative":s,zIndex:"auto"===h?0:h}),this.$wrap.css({zIndex:-999998})}this.$wrap.css({position:this.isBody&&A?"fixed":"absolute"})}this.index=this.options.start,this.show(this.index),o.on("resize.backstretch",t.proxy(this.resize,this)).on("orientationchange.backstretch",t.proxy((function(){this.isBody&&0===e.pageYOffset&&(e.scrollTo(0,1),this.resize())}),this))};w.prototype={resize:function(){try{var a=log4javascript.getLogger("j1.core.attic"),o=this.options.alwaysTestWindowResolution?t(e):this.$root,n=o.width(),s=o.height(),h=n/(this._lastResizeContainerWidth||0),c=s/(this._lastResizeContainerHeight||0),d=this.options.resolutionChangeRatioThreshold||0;if((n!==this._lastResizeContainerWidth||s!==this._lastResizeContainerHeight)&&(Math.abs(h-1)>=d||isNaN(h)||Math.abs(c-1)>=d||isNaN(c))&&(this._lastResizeContainerWidth=n,this._lastResizeContainerHeight=s,this.images=u(o,this.originalImages),this.options.preload&&g(this.images,(this.index+1)%this.images.length,this.options.preload),1===this.images.length&&this._currentImage.url!==this.images[0].url)){var l=this;clearTimeout(l._selectAnotherResolutionTimeout),l._selectAnotherResolutionTimeout=setTimeout((function(){l.show(0)}),this.options.resolutionRefreshRate)}var p,f,y={left:0,top:0,right:"auto",bottom:"auto"},v=this.isBody?this.$root.width():this.$root.innerWidth(),m=this.isBody?e.innerHeight?e.innerHeight:this.$root.height():this.$root.innerHeight(),w=this.$itemWrapper.data("width"),_=this.$itemWrapper.data("height"),$=w/_||1,T=this._currentImage.alignX===i?this.options.alignX:this._currentImage.alignX,k=this._currentImage.alignY===i?this.options.alignY:this._currentImage.alignY,x=b(this._currentImage.scale||this.options.scale);if(this.options.debug&&(r="\nresize: boxHeight x boxWidth: "+m+" x "+v,a.debug(r)),"fit"===x||"fit-smaller"===x){if(f=_,(p=w)>v||f>m||"fit-smaller"===x){var W=v/m;W>$?(p=Math.floor(m*$),f=m):W<$?(p=v,f=Math.floor(v/$)):(p=v,f=m)}}else"fill"===x?(p=v,f=m):(p=Math.max(m*$,v),f=Math.max(p/$,m));y.top=-(f-m)*k,y.left=-(p-v)*T,y.width=p,y.height=f,this.options.bypassCss||this.$wrap.css({width:v,height:m}).find(">.backstretch-item").not(".deleteable").each((function(){t(this).find("img,video,iframe").css(y)}));var I=t.Event("backstretch.resize",{relatedTarget:this.$container[0]});this.$container.trigger(I,this)}catch(t){r="resize: jadams, IE7 hack to let it fail gracefully: "+t,a.warn(r)}return this},show:function(e,r){var a=log4javascript.getLogger("j1.core.attic");if(!(Math.abs(e)>this.images.length-1)){var o=this,n=o.$wrap.find(">.backstretch-item").addClass("deleteable"),s=o.videoWrapper,h={relatedTarget:o.$container[0]};o.$container.trigger(t.Event("backstretch.before",h),[o,e]),this.index=e;var c=o.images[e];clearTimeout(o._cycleTimeout),delete o.videoWrapper;var d=p(c);return d?(o.videoWrapper=new _(c),o.$item=o.videoWrapper.$video.css("pointer-events","none")):o.$item=t(""),o.$itemWrapper=t('
').append(o.$item),this.options.bypassCss?o.$itemWrapper.css({display:"none"}):(o.$itemWrapper.css(l.itemWrapper),o.$item.css(l.item)),o.$item.bind(d?"canplay":"load",(function(c){var l=t(this).parent(),u=l.data("options");r&&(u=t.extend({},u,r));var p=this.naturalWidth||this.videoWidth||this.width,g=this.naturalHeight||this.videoHeight||this.height;l.data("width",p).data("height",g);var f=function(t){return u[t]!==i?u[t]:o.options[t]},y=f("transition"),v=f("transitionEasing"),m=f("transitionDuration"),b=function(){s&&(s.stop(),s.destroy()),n.remove(),!o.paused&&o.images.length>1&&o.cycle(),!o.options.bypassCss&&o.isBody,t(["before","after","show"]).each((function(){o.$container.trigger(t.Event("backstretch."+this,h),[o,e])})),d&&o.videoWrapper.play()};o.firstShow&&!o.options.animateFirst||!m||!y?(l.show(),b()):function(e){var r=e.transition||"fade";"string"==typeof r&&r.indexOf("|")>-1&&(r=r.split("|")),r instanceof Array&&(r=r[Math.round(Math.random()*(r.length-1))]);var a=e.new,o=e.old?e.old:t([]);switch(r.toString().toLowerCase()){default:case"fade":a.fadeIn({duration:e.duration,complete:e.complete,easing:e.easing||i});break;case"fadeinout":case"fade_in_out":var n=function(){a.fadeIn({duration:e.duration/2,complete:e.complete,easing:e.easing||i})};o.length?o.fadeOut({duration:e.duration/2,complete:n,easing:e.easing||i}):n();break;case"pushleft":case"push_left":case"pushright":case"push_right":case"pushup":case"push_up":case"pushdown":case"push_down":case"coverleft":case"cover_left":case"coverright":case"cover_right":case"coverup":case"cover_up":case"coverdown":case"cover_down":var s=r.match(/^(cover|push)_?(.*)$/),h="left"===s[2]?"right":"right"===s[2]?"left":"down"===s[2]?"top":"up"===s[2]?"bottom":"right",c={display:""},d={};if(c[h]="-100%",d[h]=0,a.css(c).animate(d,{duration:e.duration,complete:function(){a.css(h,""),e.complete.apply(this,arguments)},easing:e.easing||i}),"push"===s[1]&&o.length){var l={};l[h]="100%",o.animate(l,{duration:e.duration,complete:function(){o.css("display","none")},easing:e.easing||i})}}}({new:l,old:n,transition:y,duration:m,easing:v,complete:b}),o.firstShow=!1;var w=this.naturalWidth||this.videoWidth||this.width,_="show: imageHeight x imageWidth: "+(this.naturalHeight||this.videoHeight||this.height)+" x "+w;o.options.debug&&a.debug(_);var $="#"+o.$container[0].id,T=setInterval((function(){t($).is(":visible")&&(a.debug("\ncontainer visible on id: "+$),o.resize(),clearInterval(T))}),10)})),o.$itemWrapper.appendTo(o.$wrap),o.$item.attr("alt",c.alt||""),o.$itemWrapper.data("options",c),d||o.$item.attr("src",c.url),o._currentImage=c,o}},current:function(){return this.index},next:function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift(this.index1){clearTimeout(this._cycleTimeout);var e=this._currentImage&&this._currentImage.duration||this.options.duration,i=p(this._currentImage),r=function(){this.$item.off(".cycle"),this.paused||this.next()};if(i){if(!this._currentImage.loop){var a=0;this.$item.on("playing.cycle",(function(){var e=t(this).data("player");clearTimeout(a),void 0!==e&&(a=setTimeout((function(){e.pause(),e.$video.trigger("ended")}),1e3*(e.getDuration()-e.getCurrentTime())))})).on("ended.cycle",(function(){clearTimeout(a)}))}this.$item.on("error.cycle initerror.cycle",t.proxy(r,this))}i&&!this._currentImage.duration?this.$item.on("ended.cycle",t.proxy(r,this)):this._cycleTimeout=setTimeout(t.proxy(r,this),e)}return this},destroy:function(i){t(e).off("resize.backstretch orientationchange.backstretch"),this.videoWrapper&&this.videoWrapper.destroy(),clearTimeout(this._cycleTimeout),i||this.$wrap.remove(),this.$container.removeData("backstretch")}};var _=function(){this.init.apply(this,arguments)};_.prototype.init=function(r){var o,n=this,s=function(){n.$video=o,n.video=o[0]},h="video";if(r.url instanceof Array||!a.test(r.url)||(h="youtube"),n.type=h,"youtube"===h){_.loadYoutubeAPI(),n.ytId=r.url.match(a)[2];var c="https://www.youtube.com/embed/"+n.ytId+"?rel=0&autoplay=0&showinfo=0&controls=0&modestbranding=1&cc_load_policy=0&disablekb=1&iv_load_policy=3&loop=0&enablejsapi=1&origin="+encodeURIComponent(e.location.origin);n.__ytStartMuted=!!r.mute||r.mute===i,o=t("