").addClass(i.navContainerClass).appendTo(this.$element)).addClass("disabled"),this._controls.$previous=o("<"+i.navElement+">").addClass(i.navClass[0]).html(i.navText[0]).prependTo(this._controls.$relative).on("click",o.proxy(function(){this.prev(i.navSpeed)},this)),this._controls.$next=o("<"+i.navElement+">").addClass(i.navClass[1]).html(i.navText[1]).appendTo(this._controls.$relative).on("click",o.proxy(function(){this.next(i.navSpeed)},this)),i.dotsData||(this._templates=[o("
").addClass(i.dotClass).append(o("
")).prop("outerHTML")]),this._controls.$absolute=(i.dotsContainer?o(i.dotsContainer):o("").addClass(i.dotsClass).appendTo(this.$element)).addClass("disabled"),this._controls.$absolute.on("click","div",o.proxy(function(t){var e=o(t.target).parent().is(this._controls.$absolute)?o(t.target).index():o(t.target).parent().index();t.preventDefault(),this.to(e,i.dotsSpeed)},this)),this._overrides)this._core[t]=o.proxy(this[t],this)},e.prototype.destroy=function(){var t,e,i,n;for(t in this._handlers)this.$element.off(t,this._handlers[t]);for(e in this._controls)this._controls[e].remove();for(n in this.overides)this._core[n]=this._overrides[n];for(i in Object.getOwnPropertyNames(this))"function"!=typeof this[i]&&(this[i]=null)},e.prototype.update=function(){var t,e,i=this._core.clones().length/2,n=i+this._core.items().length,s=this._core.maximum(!0),o=this._core.settings,r=o.center||o.autoWidth||o.dotsData?1:o.dotsEach||o.items;if("page"!==o.slideBy&&(o.slideBy=Math.min(o.slideBy,o.items)),o.dots||"page"==o.slideBy)for(this._pages=[],t=i,e=0;t
=this._core.maximum(!0))),this._controls.$absolute.toggleClass("disabled",!e.dots||i),e.dots&&(t=this._pages.length-this._controls.$absolute.children().length,e.dotsData&&0!=t?this._controls.$absolute.html(this._templates.join("")):0=e},this)).pop()},e.prototype.getPosition=function(t){var e,i,n=this._core.settings;return"page"==n.slideBy?(e=o.inArray(this.current(),this._pages),i=this._pages.length,t?++e:--e,e=this._pages[(e%i+i)%i].start):(e=this._core.relative(this._core.current()),i=this._core.items().length,t?e+=n.slideBy:e-=n.slideBy),e},e.prototype.next=function(t){o.proxy(this._overrides.to,this._core)(this.getPosition(!0),t)},e.prototype.prev=function(t){o.proxy(this._overrides.to,this._core)(this.getPosition(!1),t)},e.prototype.to=function(t,e,i){var n;!i&&this._pages.length?(n=this._pages.length,o.proxy(this._overrides.to,this._core)(this._pages[(t%n+n)%n].start,e)):o.proxy(this._overrides.to,this._core)(t,e)},o.fn.owlCarousel.Constructor.Plugins.Navigation=e}(window.Zepto||window.jQuery,window,document),function(n,s){"use strict";var e=function(t){this._core=t,this._hashes={},this.$element=this._core.$element,this._handlers={"initialized.owl.carousel":n.proxy(function(t){t.namespace&&"URLHash"===this._core.settings.startPosition&&n(s).trigger("hashchange.owl.navigation")},this),"prepared.owl.carousel":n.proxy(function(t){if(t.namespace){var e=n(t.content).find("[data-hash]").addBack("[data-hash]").attr("data-hash");if(!e)return;this._hashes[e]=t.content}},this),"changed.owl.carousel":n.proxy(function(t){if(t.namespace&&"position"===t.property.name){var i=this._core.items(this._core.relative(this._core.current())),e=n.map(this._hashes,function(t,e){return t===i?e:null}).join();if(!e||s.location.hash.slice(1)===e)return;s.location.hash=e}},this)},this._core.options=n.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers),n(s).on("hashchange.owl.navigation",n.proxy(function(){var t=s.location.hash.substring(1),e=this._core.$stage.children(),i=this._hashes[t]&&e.index(this._hashes[t]);void 0!==i&&i!==this._core.current()&&this._core.to(this._core.relative(i),!1,!0)},this))};e.Defaults={URLhashListener:!1},e.prototype.destroy=function(){var t,e;for(t in n(s).off("hashchange.owl.navigation"),this._handlers)this._core.$element.off(t,this._handlers[t]);for(e in Object.getOwnPropertyNames(this))"function"!=typeof this[e]&&(this[e]=null)},n.fn.owlCarousel.Constructor.Plugins.Hash=e}(window.Zepto||window.jQuery,window,document),function(s,t,e,o){var r=s("").get(0).style,a="Webkit Moz O ms".split(" "),i={transition:{end:{WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"}},animation:{end:{WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd",animation:"animationend"}}},n=function(){return!!u("transform")},l=function(){return!!u("perspective")},c=function(){return!!u("animation")};function u(t,i){var n=!1,e=t.charAt(0).toUpperCase()+t.slice(1);return s.each((t+" "+a.join(e+" ")+e).split(" "),function(t,e){if(r[e]!==o)return n=!i||e,!1}),n}function h(t){return u(t,!0)}!function(){return!!u("transition")}()||(s.support.transition=new String(h("transition")),s.support.transition.end=i.transition.end[s.support.transition]),c()&&(s.support.animation=new String(h("animation")),s.support.animation.end=i.animation.end[s.support.animation]),n()&&(s.support.transform=new String(h("transform")),s.support.transform3d=l())}(window.Zepto||window.jQuery,window,document),function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.PhotoSwipeUI_Default=e()}(this,function(){"use strict";return function(s,a){function t(t){if(k)return!0;t=t||window.event,T.timeToIdle&&T.mouseUsed&&!w&&L();for(var e,i,n=(t.target||t.srcElement).getAttribute("class")||"",s=0;sT.fitControlsWidth){var i=T.barsSize;if(T.captionEl&&"auto"===i.bottom)if(m||((m=a.createEl("pswp__caption pswp__caption--fake")).appendChild(a.createEl("pswp__caption__center")),d.insertBefore(m,p),a.addClass(d,"pswp__ui--fit")),T.addCaptionHTMLFn(t,m,!0)){var n=m.clientHeight;e.bottom=parseInt(n,10)||44}else e.bottom=i.top;else e.bottom="auto"===i.bottom?0:i.bottom;e.top=i.top}else e.top=e.bottom=0}var h,d,p,m,f,g,v,y,w,_,x,b,C,A,T,k,E,I,S=this,z=!1,D=!0,M=!0,P={barsSize:{top:44,bottom:"auto"},closeElClasses:["item","caption","zoom-wrap","ui","top-bar"],timeToIdle:4e3,timeToIdleOutside:1e3,loadingIndicatorDelay:1e3,addCaptionHTMLFn:function(t,e){return t.title?(e.children[0].innerHTML=t.title,!0):(e.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 s.currItem.src||""},getPageURLForShare:function(){return window.location.href},getTextForShare:function(){return s.currItem.title||""},indexIndicatorSep:" / ",fitControlsWidth:1200},O=function(){for(var t,e,i,n,s="",o=0;o"+t.label+"",T.parseShareButtonOut&&(s=T.parseShareButtonOut(t,s));v.children[0].innerHTML=s,v.children[0].onclick=r},$=0,L=function(){clearTimeout(I),$=0,w&&S.setIdle(!1)},R=function(t){b!==t&&(i(x,"preloader--active",!t),b=t)},F=[{name:"caption",option:"captionEl",onInit:function(t){p=t}},{name:"share-modal",option:"shareEl",onInit:function(t){v=t},onTap:function(){o()}},{name:"button--share",option:"shareEl",onInit:function(t){g=t},onTap:function(){o()}},{name:"button--zoom",option:"zoomEl",onTap:s.toggleDesktopZoom},{name:"counter",option:"counterEl",onInit:function(t){f=t}},{name:"button--close",option:"closeEl",onTap:s.close},{name:"button--arrow--left",option:"arrowEl",onTap:s.prev},{name:"button--arrow--right",option:"arrowEl",onTap:s.next},{name:"button--fs",option:"fullscreenEl",onTap:function(){h.isFullscreen()?h.exit():h.enter()}},{name:"preloader",option:"preloaderEl",onInit:function(t){x=t}}];S.init=function(){a.extend(s.options,P,!0),T=s.options,d=a.getChildByClass(s.scrollWrap,"pswp__ui"),_=s.listen,function(){var e;_("onVerticalDrag",function(t){D&&t<.95?S.hideControls():!D&&.95<=t&&S.showControls()}),_("onPinchClose",function(t){D&&t<.9?(S.hideControls(),e=!0):e&&!D&&.9=Ue()-1&&n<0)&&(t=_e.x+n*g.mainScrollEndFriction)}_e.x=t,ie(t,H)}function c(t,e){var i=xe[t]-Kt[t];return Zt[t]+Wt[t]+i-e/V*i}function w(t,e){t.x=e.x,t.y=e.y,e.id&&(t.id=e.id)}function d(t){t.x=Math.round(t.x),t.y=Math.round(t.y)}function _(t,e){var i=Qe(f.currItem,Bt,t);return e&&(Mt=i),i}function x(t){return t||(t=f.currItem),t.initialZoomLevel}function b(t){return t||(t=f.currItem),0e.min[t]?(i[t]=e.min[t],!0):i[t]Mt.min[t]||rMt.min[t]&&(i=g.panEndFriction,Mt.min[t]-r,n=Mt.min[t]-Zt[t]),(n<=0||c<0)&&1me.x&&(o=me.x)):Mt.min.x!==Mt.max.x&&(s=r)):(rf.currItem.fitRatio&&(Ht[t]+=e[t]*i)}function L(t){if(!("mousedown"===t.type&&0f.currItem.fitRatio&&Me(wt):$e())}}var j,N,W,Z,H,B,U,K,q,G,V,Q,Y,X,J,tt,et,it,nt,st,ot,rt,at,lt,ct,ut,ht,dt,pt,mt,ft,gt,vt,yt,wt,_t,xt,bt,Ct,At,Tt,kt,Et,It,St,zt,Dt,Mt,Pt,Ot,$t,Lt,Rt,Ft,jt,Nt,Wt={x:0,y:0},Zt={x:0,y:0},Ht={x:0,y:0},Bt={},Ut=0,Kt={},qt={x:0,y:0},Gt=0,Vt=!0,Qt=[],Yt={},Xt=!1,Jt={},te=function(t){Pt&&(t&&(G>f.currItem.fitRatio?Xt||(Ye(f.currItem,!1,!0),Xt=!0):Xt&&(Ye(f.currItem),Xt=!1)),s(Pt,Ht.x,Ht.y,G))},ee=function(t){t.container&&s(t.container.style,t.initialPosition.x,t.initialPosition.y,t.initialZoomLevel,t)},ie=function(t,e){e[rt]=Q+t+"px, 0px"+Y},ne=null,se=function(){ne&&(m.unbind(document,"mousemove",se),m.addClass(p,"pswp--has_mouse"),g.mouseUsed=!0,v("mouseUsed")),ne=setTimeout(function(){ne=null},100)},oe={},re=0,ae={shout:v,listen:o,viewportSize:Bt,options:g,isMainScrollAnimating:function(){return Ot},getZoomLevel:function(){return G},getCurrentIndex:function(){return Z},isDragging:function(){return Ct},isZooming:function(){return zt},setScrollOffset:function(t,e){Kt.x=t,mt=Kt.y=e,v("updateScrollOffset",Kt)},applyZoomPan:function(t,e,i,n){Ht.x=e,Ht.y=i,G=t,te(n)},init:function(){if(!j&&!N){var t;f.framework=m,f.template=p,f.bg=m.getChildByClass(p,"pswp__bg"),ht=p.className,j=!0,ft=m.detectFeatures(),ct=ft.raf,ut=ft.caf,rt=ft.transform,pt=ft.oldIE,f.scrollWrap=m.getChildByClass(p,"pswp__scroll-wrap"),f.container=m.getChildByClass(f.scrollWrap,"pswp__container"),H=f.container.style,f.itemHolders=tt=[{el:f.container.children[0],wrap:0,index:-1},{el:f.container.children[1],wrap:0,index:-1},{el:f.container.children[2],wrap:0,index:-1}],tt[0].el.style.display=tt[2].el.style.display="none",function(){if(rt){var t=ft.perspective&&!lt;return Q="translate"+(t?"3d(":"("),Y=ft.perspective?", 0px)":")"}rt="left",m.addClass(p,"pswp--ie"),ie=function(t,e){e.left=t+"px"},ee=function(t){var e=1=Ue())&&(Z=0),f.currItem=Be(Z),(ft.isOldIOSPhone||ft.isOldAndroid)&&(Vt=!1),p.setAttribute("aria-hidden","false"),g.modal&&(Vt?p.style.position="fixed":(p.style.position="absolute",p.style.top=m.getScrollY()+"px")),void 0===mt&&(v("initialLayout"),mt=dt=m.getScrollY());var i="pswp--open ";for(g.mainClass&&(i+=g.mainClass+" "),g.showHideOpacity&&(i+="pswp--animate_opacity "),i+=lt?"pswp--touch":"pswp--notouch",i+=ft.animationName?" pswp--css_animation":"",i+=ft.svg?" pswp--svg":"",m.addClass(p,i),f.updateSize(),B=-1,Gt=null,t=0;t<3;t++)ie((t+B)*qt.x,tt[t].el.style);pt||m.bind(f.scrollWrap,K,f),o("initialZoomInEnd",function(){f.setContent(tt[0],Z-1),f.setContent(tt[2],Z+1),tt[0].el.style.display=tt[2].el.style.display="block",g.focus&&p.focus(),m.bind(document,"keydown",f),ft.transform&&m.bind(f.scrollWrap,"click",f),g.mouseUsed||m.bind(document,"mousemove",se),m.bind(window,"resize scroll orientationchange",f),v("bindEvents")}),f.setContent(tt[1],Z),f.updateCurrItem(),v("afterInit"),Vt||(X=setInterval(function(){re||Ct||zt||G!==f.currItem.initialZoomLevel||f.updateSize()},1e3)),m.addClass(p,"pswp--visible")}},close:function(){j&&(N=!(j=!1),v("close"),m.unbind(window,"resize scroll orientationchange",f),m.unbind(window,"scroll",q.scroll),m.unbind(document,"keydown",f),m.unbind(document,"mousemove",se),ft.transform&&m.unbind(f.scrollWrap,"click",f),Ct&&m.unbind(window,U,f),clearTimeout(gt),v("unbindEvents"),Ke(f.currItem,null,!0,f.destroy))},destroy:function(){v("destroy"),Ne&&clearTimeout(Ne),p.setAttribute("aria-hidden","true"),p.className=ht,X&&clearInterval(X),m.unbind(f.scrollWrap,K,f),m.unbind(window,"scroll",f),Ce(),E(),Jt=null},panTo:function(t,e,i){i||(t>Mt.min.x?t=Mt.min.x:tMt.min.y?e=Mt.min.y:ef.currItem.initialZoomLevel+f.currItem.initialZoomLevel/15&&(jt=!0);var n=1,s=x(),o=b();if(iMt.min[e]?n.backAnimDestination[e]=Mt.min[e]:Ht[e]=Ue()&&(Z=g.loop?0:Ue()-1,s=!0),s&&!g.loop||(Gt+=n,Ut-=n,i=!0));var a,l=qt.x*Ut,c=Math.abs(l-_e.x);return a=i||l>_e.x==0The image could not be loaded. ',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return We.length}},Qe=function(t,e,i){if(!t.src||t.loadError)return t.w=t.h=0,t.initialZoomLevel=t.fitRatio=1,t.bounds={center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}},t.initialPosition=t.bounds.center,t.bounds;var n=!i;if(n&&(t.vGap||(t.vGap={top:0,bottom:0}),v("parseVerticalMargin",t)),qe.x=e.x,qe.y=e.y-t.vGap.top-t.vGap.bottom,n){var s=qe.x/t.w,o=qe.y/t.h;t.fitRatio=sqe.x?Math.round(qe.x-e):n.center.x,n.max.y=i>qe.y?Math.round(qe.y-i)+t.vGap.top:n.center.y,n.min.x=e>qe.x?0:n.center.x,n.min.y=i>qe.y?t.vGap.top:n.center.y}(t,t.w*i,t.h*i),n&&i===t.initialZoomLevel&&(t.initialPosition=t.bounds.center),t.bounds):void 0},Ye=function(t,e,i){if(t.src){e||(e=t.container.lastChild);var n=i?t.w:Math.round(t.w*t.fitRatio),s=i?t.h:Math.round(t.h*t.fitRatio);t.placeholder&&!t.loaded&&(t.placeholder.style.width=n+"px",t.placeholder.style.height=s+"px"),e.style.width=n+"px",e.style.height=s+"px"}};i("Controller",{publicMethods:{lazyLoadItem:function(t){t=l(t);var e=Be(t);e&&(!e.loaded&&!e.loading||J)&&(v("gettingData",t,e),e.src&&Re(e))},initController:function(){m.extend(g,Ve,!0),f.items=We=t,Be=f.getItemAt,Ue=g.getNumItemsFn,g.loop,Ue()<3&&(g.loop=!1),o("beforeChange",function(t){var e,i=g.preload,n=null===t||0<=t,s=Math.min(i[0],Ue()),o=Math.min(i[1],Ue());for(e=1;e<=(n?o:s);e++)f.lazyLoadItem(Z+e);for(e=1;e<=(n?s:o);e++)f.lazyLoadItem(Z-e)}),o("initialLayout",function(){f.currItem.initialLayout=g.getThumbBoundsFn&&g.getThumbBoundsFn(Z)}),o("mainScrollAnimComplete",je),o("initialZoomInEnd",je),o("destroy",function(){for(var t,e=0;e=Mt.max.x&&i<=Mt.min.y&&i>=Mt.max.y)&&t.preventDefault(),f.panTo(e,i)},toggleDesktopZoom:function(t){t=t||{x:Bt.x/2+Kt.x,y:Bt.y/2+Kt.y};var e=g.getDoubleTapZoom(!0,f.currItem),i=G===e;f.mouseZoomedIn=!i,f.zoomTo(i?f.currItem.initialZoomLevel:e,t,333),m[(i?"remove":"add")+"Class"](p,"pswp--zoomed-in")}}});function ii(){return fi.hash.substring(1)}function ni(){oi&&clearTimeout(oi),ai&&clearTimeout(ai)}function si(){var t=ii(),e={};if(t.length<5)return e;var i,n=t.split("&");for(i=0;it._pfLastSize)&&(t._pfLastSize=t.offsetWidth,i=t.sizes,t.sizes+=",100vw",setTimeout(function(){t.sizes=i}))}function r(){var t,e=document.querySelectorAll("picture > img, img[srcset][sizes]");for(t=0;t=",/max-([a-z-\s]+):/g,"e.$1<=",/calc([^)]+)/g,"($1)",/(\d+[\.]*[\d]*)([a-z]+)/g,"($1 * e.$2)",/^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/gi,"")+";"}),function(t,e){var i;if(!(t in I))if(I[t]=!1,e&&(i=t.match(Z)))I[t]=i[1]*D[i[2]];else try{I[t]=new Function("e",H(t))(D)}catch(t){}return I[t]}),at=function(t){if(a){var e,i,n,s=t||{};if(s.elements&&1===s.elements.nodeType&&("IMG"===s.elements.nodeName.toUpperCase()?s.elements=[s.elements]:(s.context=s.elements,s.elements=null)),n=(e=s.elements||w.qsa(s.context||o,s.reevaluate||s.reselect?w.sel:w.selShort)).length){for(w.setupRun(s),P=!0,i=0;iimg,img[srcset]",w.sel=w.selShort,w.cfg=_,w.DPR=z||1,w.u=D,w.types=f,w.setSize=e,w.makeUrl=n(function(t){return M.href=t,M.href}),w.qsa=function(t,e){return"querySelector"in t?t.querySelectorAll(e):[]},w.matchesMedia=function(){return t.matchMedia&&(matchMedia("(min-width: 0.1em)")||{}).matches?w.matchesMedia=function(t){return!t||matchMedia(t).matches}:w.matchesMedia=w.mMQ,w.matchesMedia.apply(this,arguments)},w.mMQ=function(t){return!t||rt(t)},w.calcLength=function(t){var e=rt(t,!0)||!1;return e<0&&(e=!1),e},w.supportsType=function(t){return!t||f[t]},w.parseSize=n(function(t){var e=(t||"").match(A);return{media:e&&e[1],length:e&&e[2]}}),w.parseSet=function(t){return t.cands||(t.cands=function(n,h){function t(t){var e,i=t.exec(n.substring(r));if(i)return e=i[0],r+=e.length,e}var d,p,e,i,s,o=n.length,r=0,m=[];function a(){var t,e,i,n,s,o,r,a,l,c=!1,u={};for(n=0;ny)||(l.cached=!0,l.res>=y&&(r=l))),!r)for(t.sort(lt),r=t[(o=t.length)-1],n=0;n=y){r=t[s=n-1]&&(u||a!==w.makeUrl(i.url))&&(h=t[s].res,d=i.res,p=y,m=t[s].cached,g=f=void 0,p<("saveData"===_.algorithm?2.7"))&&b.css("position",r.css("position")),(_=function(){var t,e,i;if(!p)return v=C.height(),t=parseInt(w.css("border-top-width"),10),e=parseInt(w.css("padding-top"),10),a=parseInt(w.css("padding-bottom"),10),l=w.offset().top+t+e,c=w.height(),f&&(m=f=!1,null==k&&(r.insertAfter(b),b.detach()),r.css({position:"",top:"",width:"",bottom:""}).removeClass(S),i=!0),u=r.offset().top-(parseInt(r.css("margin-top"),10)||0)-E,h=r.outerHeight(!0),d=r.css("float"),b&&b.css({width:s(r),height:h,display:r.css("display"),"vertical-align":r.css("vertical-align"),float:d}),i?n():void 0})(),h!==c)return g=void 0,y=E,x=I,n=function(){var t,e,i,n,s,o;if(!p)return i=!1,null!=x&&(x-=1)<=0&&(x=I,_(),i=!0),i||C.height()===v||(_(),i=!0),n=D.scrollTop(),null!=g&&(e=n-g),g=n,f?(A&&(s=c+l=opinion_js_settings.header_sticky_offset?a("body").hasClass("opinion-header-sticky-active")||a("body").addClass("opinion-header-sticky-active"):a("body").hasClass("opinion-header-sticky-active")&&a("body").removeClass("opinion-header-sticky-active"):e>=opinion_js_settings.header_sticky_offset?a("body").hasClass("opinion-header-sticky-active")||a("body").addClass("opinion-header-sticky-active"):a("body").hasClass("opinion-header-sticky-active")&&a("body").removeClass("opinion-header-sticky-active"),this.settings.window_last_top=e},sticky_bottom:function(){return!!opinion_js_settings.single_sticky_bottom&&(!!a(".opinion-sticky-bottom").length&&void a("body").imagesLoaded(function(){var t=a(".opinion-single").height()<1100?200:300,e=a(".opinion-single").offset().top+a(".opinion-single").height()-a(window).height(),i=a("#opinion-footer").offset().top-a(window).height(),n=a(window).scrollTop();t')}),a("body").imagesLoaded(function(){var t=a(".opinion-sticky"),s=window.matchMedia("(min-width: "+l.settings.breakpoints.lg_spec+"px)").matches?52:26;t.each(function(){var t=a(this).closest(".section-content").find(".opinion-order-1"),e=a(this).parent(),i=(a(".opinion-header-sticky").length&&!opinion_js_settings.header_sticky_up?a(".opinion-header-sticky").outerHeight():0)+("fixed"==l.settings.admin_bar.position?l.settings.admin_bar.height:0)+s,n=a(this).children().addClass("widget-sticky");window.matchMedia("(min-width: "+l.settings.breakpoints.lg+"px)").matches?(e.height(t.height()),a(this).stick_in_parent({offset_top:i})):(e.css("height","auto"),e.css("min-height","1px"),n.unwrap()),l.masonry_widgets()})})):l.masonry_widgets()},masonry_widgets:function(){if(!a(".opinion-sidebar").not(".opinion-sidebar-hidden").length)return!1;a("body").imagesLoaded(function(){a(".opinion-sidebar").not(".opinion-sidebar-hidden").each(function(){window.matchMedia("(min-width: "+l.settings.breakpoints.lg+"px)").matches?a(this).hasClass("has-masonry")&&a(this).removeClass("has-masonry").masonry("destroy"):a(this).addClass("has-masonry").masonry({columnWidth:".col-md-6",percentPosition:!0})})})},masonry_layouts:function(){a(".opinion-masonry").each(function(){var t=a(this),e=a(this).attr("class").match(/opinion-masonry-base-(\d+)/)[1];t.imagesLoaded(function(){t.find(".opinion-posts").masonry({columnWidth:".col-lg-"+e,percentPosition:!0})})})},overlay_open:function(){a("body").on("click",".opinion-open-popup",function(t){t.preventDefault(),a("body").addClass("overlay-action-open overlay-lock"),a(this).next().clone().appendTo(".opinion-action-overlay")}),a("body").on("click",".opinion-action-close",function(){a("body").removeClass("overlay-action-open overlay-lock overlay-sidebar-open"),a(".opinion-action-overlay").html("")}),a(document).keyup(function(t){27==t.keyCode&&a("body").hasClass("overlay-action-open")&&(a("body").removeClass("overlay-action-open overlay-lock overlay-sidebar-open"),a(".opinion-action-overlay").html(""))})},sidebar_open:function(){a("body").on("click",".opinion-open-sidebar",function(t){t.preventDefault();var e="fixed"==l.settings.admin_bar.position||0==a(window).scrollTop()?l.settings.admin_bar.height:0;a(".opinion-sidebar-hidden").css("top",e),a("body").addClass("overlay-action-open overlay-lock overlay-sidebar-open")}),a("body").on("click",".opinion-action-close",function(){a("body").removeClass("overlay-action-open overlay-lock overlay-sidebar-open")})},overlay_close:function(){a("body").on("mouseup",".opinion-action-overlay",function(t){t.preventDefault(),t.target===this&&(a("body").removeClass("overlay-action-open overlay-lock overlay-sidebar-open"),a(".opinion-action-overlay").html(""))})},gutenberg_gallery:function(){var t=a(".wp-block-gallery");if(t.length){var n=document.querySelectorAll(".wp-block-gallery img");t.find("a").each(function(t){var e=n[t].naturalWidth,i=n[t].naturalHeight;a(this).attr("data-size",JSON.stringify({w:e,h:i}))})}},popup:function(){if(!opinion_js_settings.gallery_popup)return!1;a("body").on("click",".gallery-item a, a.opinion-popup-img, .wp-block-gallery a",function(t){t.preventDefault();var e=document.querySelectorAll(".pswp")[0],n=[],s=0,o=a(this),i=!!o.closest(".gallery, .wp-block-gallery").hasClass("owl-carousel"),r=[];r=!o.hasClass("opinion-popup-img")?i?a(this).closest(".gallery, .wp-block-gallery").find(".owl-item:not(.cloned) .gallery-item a, .owl-item:not(.cloned) .blocks-gallery-item a"):a(this).closest(".gallery, .wp-block-gallery").find(".gallery-item a, .blocks-gallery-item a"):a("a.opinion-popup-img"),a.each(r,function(t){o.attr("href")==a(this).attr("href")&&(s=t);var e=JSON.parse(a(this).attr("data-size")),i={src:a(this).attr("href"),w:e.w,h:e.h,title:a(this).closest("figure").find("figcaption").html()};n.push(i)}),new PhotoSwipe(e,PhotoSwipeUI_Default,n,{history:!1,index:s,preload:[2,2],captionEl:!0,fullscreenEl:!1,zoomEl:!1,shareEl:!1,preloaderEl:!0,closeOnScroll:!1}).init()})},pagination:function(){if(a("body").on("click",".opinion-pagination.load-more > a",function(t){t.preventDefault(),l.load_more_items({opener:a(this),url:a(this).attr("href"),next_url_selector:".opinion-pagination.load-more > a"},function(){})}),!a(".opinion-pagination.opinion-infinite-scroll").length)return!1;a(window).scroll(function(){if(l.settings.infinite_allow&&a(".opinion-pagination").length){var t=a(".opinion-pagination"),e=t.find("a");a(this).scrollTop()>t.offset().top-a(this).height()-200&&(l.settings.infinite_allow=!1,l.load_more_items({opener:e,url:e.attr("href"),next_url_selector:".opinion-pagination.opinion-infinite-scroll a"},function(){l.settings.infinite_allow=!0}))}})},load_more_items:function(t,o){a(".opinion-pagination").toggleClass("opinion-loader-active");var r=a.extend({},{opener:"",url:"",next_url_selector:".load-more > a"},t);a("
").load(r.url,function(){var e=a(this).find(r.next_url_selector).attr("href"),i=a(this).find("title").text(),n=a(this).find(".opinion-items").children(),s=r.opener.closest(".section-content").find(".opinion-items");n.imagesLoaded(function(){n.hide().appendTo(s).fadeIn(),void 0!==e?a(r.next_url_selector).attr("href",e):a(r.next_url_selector).closest(".opinion-pagination").parent().fadeOut("fast").remove();var t={prev:window.location.href,next:r.url,offset:a(window).scrollTop(),prev_title:window.document.title,next_title:i};l.push_state(t),a(".opinion-pagination").toggleClass("opinion-loader-active"),l.sidebar(),o()})})},push_state:function(t){var e={prev:window.location.href,next:"",offset:a(window).scrollTop(),prev_title:window.document.title,next_title:window.document.title,increase_counter:!0},i=a.extend({},e,t);i.increase_counter&&(l.settings.pushes.up++,l.settings.pushes.down++),delete i.increase_counter,l.settings.pushes.url.push(i),window.document.title=i.next_title,window.history.pushState(i,"",i.next)},check_history:function(){if(!a(".opinion-pagination.load-more").length&&!a(".opinion-pagination.opinion-infinite-scroll").length)return!1;l.push_state({increase_counter:!1});var t,e=0;a(window).scroll(function(){l.settings.pushes.url[l.settings.pushes.up].offset!==t&&a(window).scrollTop()l.settings.pushes.url[l.settings.pushes.down].offset&&(e=l.settings.pushes.url[l.settings.pushes.down].offset,t=0,window.document.title=l.settings.pushes.url[l.settings.pushes.down].next_title,window.history.replaceState(l.settings.pushes.url,"",l.settings.pushes.url[l.settings.pushes.down].next),l.settings.pushes.up=l.settings.pushes.down,l.settings.pushes.down a, .page_item_has_children > a, .cat-parent > a").after(''),a(".widget").on("click",".opinion-accordion-nav",function(){a(this).closest("li").find("ul.sub-menu:first, ul.children:first").slideToggle("fast").parent().toggleClass("active")})},module_slider:function(){a("body").imagesLoaded(function(){a(".opinion-module-slider").each(function(){var t=a(this).find(".opinion-items").addClass("owl-carousel"),e=a(this).hasClass("slider-has-nav"),i=t.children().first().attr("class"),n=i.match(/col-(\d+)/);n=null===n?1:12/n[1];var s=i.match(/col-md-(\d+)/);s=null===s?n:12/s[1];var o=i.match(/col-lg-(\d+)/);o=null===o?s:12/o[1],t.owlCarousel({rtl:!!opinion_js_settings.rtl_mode,center:!1,loop:!0,items:n,margin:26,stagePadding:0,navContainerClass:"owl-nav container",nav:!e,navText:['',''],onInitialized:function(t){var e=a(t.currentTarget);e.removeClass("row"),e.find(".owl-item").each(function(){a(this).children().removeClass()})},responsive:{570:{items:s},970:{items:o},1100:{items:o,margin:52}}}),e&&a(this).on("click",".opinion-slider-nav a",function(){a(this).hasClass("prev")?t.trigger("prev.owl.carousel"):t.trigger("next.owl.carousel")})})})},gallery_slider:function(){a("body").imagesLoaded(function(){a(".gallery-columns-1, .wp-block-gallery.columns-1").each(function(){a(this).addClass("owl-carousel").owlCarousel({rtl:!!opinion_js_settings.rtl_mode,loop:!0,items:1,autoHeight:!0,navText:['',''],nav:!0})})})},instagram_slider:function(){var t=a(".opinion-section-instagram .meks-instagram-widget");t.length&&(t.hasClass("owl-carousel")||t.addClass("owl-carousel"),t.owlCarousel({rtl:!!opinion_js_settings.rtl_mode,loop:!0,nav:!0,autoWidth:!1,center:!0,fluidSpeed:300,margin:0,items:3,navText:['',''],lazyLoad:!0,responsive:{570:{items:5}}}))},scroll_animate:function(){a("body").on("click",".opinion-scroll-animate",function(t){t.preventDefault();var e=this.hash,i=a(e),n=opinion_js_settings.header_sticky?a(".opinion-header-sticky").height():0;a("html, body").stop().animate({scrollTop:i.offset().top-n},900,"swing",function(){window.location.hash=e})})},reverse_menu:function(){a(".opinion-header").on("mouseenter","ul li",function(){a(this).find("ul").length&&a(window).width()-(a(this).find("ul").offset().left+a(this).find("ul").outerWidth())<0&&a(this).find("ul").addClass("opinion-rev")})},object_fit_cover:function(){a("body").imagesLoaded(function(){objectFitImages(".entry-media img")})},align_full_fix:function(){if(a("body").hasClass("opinion-sidebar-none")){var t=".alignfull { width: "+a(window).width()+"px; margin-left: -"+a(window).width()/2+"px; margin-right: -"+a(window).width()/2+"px; right:50%; left:50%; }";a("#opinion-align-fix").length?a("#opinion-align-fix").html(t):a("head").append('")}}};a(document).ready(function(){l.init()}),a(window).resize(function(){l.resize()}),a(window).scroll(function(){l.scroll()})}(jQuery);;
!function(){"use strict";var e,t={noop:function(){},texturize:function(e){return(e=(e=(e=(e+="").replace(/'/g,"’").replace(/'/g,"’")).replace(/"/g,"”").replace(/"/g,"”").replace(/"/g,"”").replace(/[\u201D]/g,"”")).replace(/([\w]+)=[\d]+;(.+?)[\d]+;/g,'$1="$2"')).trim()},applyReplacements:function(e,t){if(e)return t?e.replace(/{(\d+)}/g,function(e,r){return void 0!==t[r]?t[r]:e}):e},getBackgroundImage:function(e){var t=document.createElement("canvas"),r=t.getContext&&t.getContext("2d");if(e){r.filter="blur(20px) ",r.drawImage(e,0,0);var o=t.toDataURL("image/png");return t=null,o}}},r=function(){function e(e,t){return Element.prototype.matches?e.matches(t):Element.prototype.msMatchesSelector?e.msMatchesSelector(t):void 0}function r(e,t,r,o){if(!e)return o();e.style.removeProperty("display"),e.style.opacity=t,e.style.pointerEvents="none";var a=function(i,n){var l=(performance.now()-i)/n;l<1?(e.style.opacity=t+(r-t)*l,requestAnimationFrame(()=>a(i,n))):(e.style.opacity=r,e.style.removeProperty("pointer-events"),o())};requestAnimationFrame(function(){requestAnimationFrame(function(){a(performance.now(),200)})})}return{closest:function(t,r){if(t.closest)return t.closest(r);var o=t;do{if(e(o,r))return o;o=o.parentElement||o.parentNode}while(null!==o&&1===o.nodeType);return null},matches:e,hide:function(e){e&&(e.style.display="none")},show:function(e){e&&(e.style.display="block")},fadeIn:function(e,o){r(e,0,1,o=o||t.noop)},fadeOut:function(e,o){o=o||t.noop,r(e,1,0,function(){e&&(e.style.display="none"),o()})},scrollToElement:function(e,t,r){if(!e||!t)return r?r():void 0;var o=t.querySelector(".jp-carousel-info-extra");o&&(o.style.minHeight=window.innerHeight-64+"px");var a=!0,i=Date.now(),n=t.scrollTop,l=Math.max(0,e.offsetTop-Math.max(0,window.innerHeight-function(e){var t=e.querySelector(".jp-carousel-info-footer"),r=e.querySelector(".jp-carousel-info-extra"),o=e.querySelector(".jp-carousel-info-content-wrapper");if(t&&r&&o){var a=window.getComputedStyle(r),i=parseInt(a.paddingTop,10)+parseInt(a.paddingBottom,10);return i=isNaN(i)?0:i,o.offsetHeight+t.offsetHeight+i}return 0}(t)))-t.scrollTop;function s(){a=!1}l=Math.min(l,t.scrollHeight-window.innerHeight),t.addEventListener("wheel",s),function e(){var c,u=Date.now(),d=(c=(u-i)/300)<.5?2*c*c:1-Math.pow(-2*c+2,2)/2,p=(d=d>1?1:d)*l;if(t.scrollTop=n+p,u<=i+300&&a)return requestAnimationFrame(e);r&&r(),o&&(o.style.minHeight=""),a=!1,t.removeEventListener("wheel",s)}()},getJSONAttribute:function(e,t){if(e&&e.hasAttribute(t))try{return JSON.parse(e.getAttribute(t))}catch{return}},convertToPlainText:function(e){var t=document.createElement("div");return t.textContent=e,t.innerHTML},stripHTML:function(e){return e.replace(/<[^>]*>?/gm,"")},emitEvent:function(e,t,r){var o;try{o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r||null})}catch{(o=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,r||null)}e.dispatchEvent(o)},isTouch:function(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch}}}();function o(){var o,a,i,n,l="",s=!1,c="div.gallery, div.tiled-gallery, ul.wp-block-gallery, ul.blocks-gallery-grid, figure.wp-block-gallery.has-nested-images, div.wp-block-jetpack-tiled-gallery, a.single-image-gallery",u=".gallery-item, .tiled-gallery-item, .blocks-gallery-item, .tiled-gallery__item",d=u+", .wp-block-image",p={},m="undefined"!=typeof wpcom&&wpcom.carousel&&wpcom.carousel.stat?wpcom.carousel.stat:t.noop,g="undefined"!=typeof wpcom&&wpcom.carousel&&wpcom.carousel.pageview?wpcom.carousel.pageview:t.noop;function h(t){if(!s)switch(t.which){case 38:t.preventDefault(),p.overlay.scrollTop-=100;break;case 40:t.preventDefault(),p.overlay.scrollTop+=100;break;case 39:t.preventDefault(),e.slideNext();break;case 37:case 8:t.preventDefault(),e.slidePrev();break;case 27:t.preventDefault(),k()}}function f(){s=!0}function v(){s=!1}function y(e){e.role="button",e.tabIndex=0,e.ariaLabel=jetpackCarouselStrings.image_label}function w(){p.overlay||(p.overlay=document.querySelector(".jp-carousel-overlay"),p.container=p.overlay.querySelector(".jp-carousel-wrap"),p.gallery=p.container.querySelector(".jp-carousel"),p.info=p.overlay.querySelector(".jp-carousel-info"),p.caption=p.info.querySelector(".jp-carousel-caption"),p.commentField=p.overlay.querySelector("#jp-carousel-comment-form-comment-field"),p.emailField=p.overlay.querySelector("#jp-carousel-comment-form-email-field"),p.authorField=p.overlay.querySelector("#jp-carousel-comment-form-author-field"),p.urlField=p.overlay.querySelector("#jp-carousel-comment-form-url-field"),window.innerWidth<=760&&Math.round(window.innerWidth/760*110)<40&&r.isTouch(),[p.commentField,p.emailField,p.authorField,p.urlField].forEach(function(e){e&&(e.addEventListener("focus",f),e.addEventListener("blur",v))}),p.overlay.addEventListener("click",function(e){var t,o,a=e.target,i=!!r.closest(a,".jp-carousel-close-hint"),n=!!window.matchMedia("(max-device-width: 760px)").matches;a===p.overlay?n||k():i?k():a.classList.contains("jp-carousel-image-download")?m("download_original_click"):a.classList.contains("jp-carousel-comment-login")?(t=p.currentSlide,o=t?t.attrs.attachmentId:"0",window.location.href=jetpackCarouselStrings.login_url+"%23jp-carousel-"+o):r.closest(a,"#jp-carousel-comment-form-container")?function(e){var t=e.target,o=r.getJSONAttribute(p.container,"data-carousel-extra")||{},a=p.currentSlide.attrs.attachmentId,i=document.querySelector("#jp-carousel-comment-form-submit-and-info-wrapper"),n=document.querySelector("#jp-carousel-comment-form-spinner"),l=document.querySelector("#jp-carousel-comment-form-button-submit"),s=document.querySelector("#jp-carousel-comment-form");if(p.commentField&&p.commentField.getAttribute("id")===t.getAttribute("id"))f(),r.show(i);else if(r.matches(t,'input[type="submit"]')){e.preventDefault(),e.stopPropagation(),r.show(n),s.classList.add("jp-carousel-is-disabled");var c={action:"post_attachment_comment",nonce:jetpackCarouselStrings.nonce,blog_id:o.blog_id,id:a,comment:p.commentField.value};if(!c.comment.length)return void j(jetpackCarouselStrings.no_comment_text,!1);if(1!==Number(jetpackCarouselStrings.is_logged_in)&&(c.email=p.emailField.value,c.author=p.authorField.value,c.url=p.urlField.value,1===Number(jetpackCarouselStrings.require_name_email))){if(!c.email.length||!c.email.match("@"))return void j(jetpackCarouselStrings.no_comment_email,!1);if(!c.author.length)return void j(jetpackCarouselStrings.no_comment_author,!1)}var u=new XMLHttpRequest;u.open("POST",jetpackCarouselStrings.ajaxurl,!0),u.setRequestHeader("X-Requested-With","XMLHttpRequest"),u.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),u.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE&&this.status>=200&&this.status<300){var e;try{e=JSON.parse(this.response)}catch{return void j(jetpackCarouselStrings.comment_post_error,!1)}"approved"===e.comment_status?j(jetpackCarouselStrings.comment_approved,!0):"unapproved"===e.comment_status?j(jetpackCarouselStrings.comment_unapproved,!0):j(jetpackCarouselStrings.comment_post_error,!1),I(),_(a),l.value=jetpackCarouselStrings.post_comment,r.hide(n),s.classList.remove("jp-carousel-is-disabled")}else j(jetpackCarouselStrings.comment_post_error,!1)};var d=[];for(var m in c)if(m){var g=encodeURIComponent(m)+"="+encodeURIComponent(c[m]);d.push(g.replace(/%20/g,"+"))}var h=d.join("&");u.send(h)}}(e):(r.closest(a,".jp-carousel-photo-icons-container")||a.classList.contains("jp-carousel-photo-title"))&&function(e){e.preventDefault();var t=e.target,o=p.info.querySelector(".jp-carousel-info-extra"),a=p.info.querySelector(".jp-carousel-image-meta"),i=p.info.querySelector(".jp-carousel-comments-wrapper"),n=p.info.querySelector(".jp-carousel-icon-info"),l=p.info.querySelector(".jp-carousel-icon-comments");function s(){l&&l.classList.remove("jp-carousel-selected"),n.classList.toggle("jp-carousel-selected"),i&&i.classList.remove("jp-carousel-show"),a&&(a.classList.toggle("jp-carousel-show"),a.classList.contains("jp-carousel-show")?o.classList.add("jp-carousel-show"):o.classList.remove("jp-carousel-show"))}function c(){n&&n.classList.remove("jp-carousel-selected"),l.classList.toggle("jp-carousel-selected"),a&&a.classList.remove("jp-carousel-show"),i&&(i.classList.toggle("jp-carousel-show"),i.classList.contains("jp-carousel-show")?o.classList.add("jp-carousel-show"):o.classList.remove("jp-carousel-show"))}(r.closest(t,".jp-carousel-icon-info")||t.classList.contains("jp-carousel-photo-title"))&&(a&&a.classList.contains("jp-carousel-show")?r.scrollToElement(p.overlay,p.overlay,s):(s(),r.scrollToElement(p.info,p.overlay))),r.closest(t,".jp-carousel-icon-comments")&&(i&&i.classList.contains("jp-carousel-show")?r.scrollToElement(p.overlay,p.overlay,c):(c(),r.scrollToElement(p.info,p.overlay)))}(e)}),window.addEventListener("keydown",h),p.overlay.addEventListener("jp_carousel.afterOpen",function(){v(),p.slides.length<=1||(p.slides.length<=5?r.show(p.info.querySelector(".jp-swiper-pagination")):r.show(p.info.querySelector(".jp-carousel-pagination")))}),p.overlay.addEventListener("jp_carousel.beforeClose",function(){f(),document.documentElement.style.removeProperty("height"),e&&e.enable(),r.hide(p.info.querySelector(".jp-swiper-pagination")),r.hide(p.info.querySelector(".jp-carousel-pagination"))}),p.overlay.addEventListener("jp_carousel.afterClose",function(){window.history.pushState?history.pushState("",document.title,window.location.pathname+window.location.search):window.location.href="",l="",p.isOpen=!1}),p.overlay.addEventListener("touchstart",function(e){e.touches.length>1&&e.preventDefault()}))}function j(e,t){var o=p.overlay.querySelector("#jp-carousel-comment-post-results"),a="jp-carousel-comment-post-"+(t?"success":"error");o.innerHTML=''+e+"",r.hide(p.overlay.querySelector("#jp-carousel-comment-form-spinner")),p.overlay.querySelector("#jp-carousel-comment-form").classList.remove("jp-carousel-is-disabled"),r.show(o)}function b(){var e=document.querySelectorAll("a img[data-attachment-id]");Array.prototype.forEach.call(e,function(e){var t=e.parentElement,o=t.parentElement;if(!o.classList.contains("gallery-icon")&&!r.closest(o,u)&&t.hasAttribute("href")){var a=!1;t.getAttribute("href").split("?")[0]===e.getAttribute("data-orig-file").split("?")[0]&&1===Number(jetpackCarouselStrings.single_image_gallery_media_file)&&(a=!0),t.getAttribute("href")===e.getAttribute("data-permalink")&&(a=!0),a&&(y(e),t.classList.add("single-image-gallery"),t.setAttribute("data-carousel-extra",JSON.stringify({blog_id:Number(jetpackCarouselStrings.blog_id)})))}})}function S(t,r){p.isOpen?(L(r),e.slideTo(r+1)):F(t,{startIndex:r})}function L(e){(!e||e<0||e>p.slides.length)&&(e=0),p.currentSlide=p.slides[e];var o,a,i=p.currentSlide,n=i.attrs.attachmentId;H(p.slides[e]),function(e){var t=[],r=p.slides.length;if(r>1){var o=e>0?e-1:r-1;t.push(o);var a=e"+jetpackCarouselStrings[o]+"
"+a+""}}t.innerHTML=r,t.style.removeProperty("display")}(p.slides[e].attrs.imageMeta),function(e){if(!e)return!1;var r,o=[e.attrs.origWidth,e.attrs.origHeight],a=document.createElement("a");a.href=e.attrs.src.replace(/\?.+$/,""),r=null!==a.hostname.match(/^i[\d]{1}\.wp\.com$/i)?a.href:e.attrs.origFile.replace(/\?.+$/,"");var i=p.info.querySelector(".jp-carousel-download-text"),n=p.info.querySelector(".jp-carousel-image-download");i.innerHTML=t.applyReplacements(jetpackCarouselStrings.download_original,o),n.setAttribute("href",r),n.style.removeProperty("display")}(i),1===Number(jetpackCarouselStrings.display_comments)&&(o=p.slides[e].attrs.commentsOpened,a=p.info.querySelector("#jp-carousel-comment-form-container"),1===parseInt(o,10)?r.fadeIn(a):r.fadeOut(a),_(n),r.hide(p.info.querySelector("#jp-carousel-comment-post-results")));var s=p.info.querySelector(".jp-carousel-pagination");if(s&&p.slides.length>5){var c=e+1;s.innerHTML=""+c+" / "+p.slides.length+""}jetpackCarouselStrings.stats&&((new Image).src=document.location.protocol+"//pixel.wp.com/g.gif?"+jetpackCarouselStrings.stats+"&post="+encodeURIComponent(n)+"&rand="+Math.random()),g(n),window.location.hash=l="#jp-carousel-"+n}function k(){document.body.style.overflow=a,document.documentElement.style.overflow=i,I(),f(),r.emitEvent(p.overlay,"jp_carousel.beforeClose"),window.scrollTo(window.scrollX||window.pageXOffset||0,n||0),e.destroy(),p.isOpen=!1,p.slides=[],p.currentSlide=void 0,p.gallery.innerHTML="",r.fadeOut(p.overlay,function(){r.emitEvent(p.overlay,"jp_carousel.afterClose")})}function x(e){if("object"!=typeof e&&(e={}),void 0===e.origFile)return"";if(void 0===e.origWidth||void 0===e.maxWidth)return e.origFile;if(void 0===e.mediumFile||void 0===e.largeFile)return e.origFile;var t=document.createElement("a");t.href=e.largeFile;var r=/^i[0-2]\.wp\.com$/i.test(t.hostname),o=q(e.largeFile,e.origWidth,r),a=parseInt(o[0],10),i=parseInt(o[1],10);if(e.origMaxWidth=e.maxWidth,e.origMaxHeight=e.maxHeight,void 0!==window.devicePixelRatio&&window.devicePixelRatio>1&&(e.maxWidth=e.maxWidth*window.devicePixelRatio,e.maxHeight=e.maxHeight*window.devicePixelRatio),a>=e.maxWidth||i>=e.maxHeight)return e.largeFile;var n=q(e.mediumFile,e.origWidth,r),l=parseInt(n[0],10),s=parseInt(n[1],10);if(l>=e.maxWidth||s>=e.maxHeight)return e.mediumFile;if(r){if(-1===e.largeFile.lastIndexOf("?"))return e.largeFile;var c=function(e){var t;try{t=new URL(e)}catch(t){return e}var r=["quality","ssl","filter","brightness","contrast","colorize","smooth"],o=Array.from(t.searchParams.entries());return t.search="",o.forEach(([e,o])=>{r.includes(e)&&t.searchParams.append(e,o)}),t}(e.largeFile);return(e.origWidth>e.maxWidth||e.origHeight>e.maxHeight)&&(e.origMaxWidth=2*e.maxWidth,e.origMaxHeight=2*e.maxHeight,c.searchParams.set("fit",e.origMaxWidth+","+e.origMaxHeight)),c.toString()}return e.origFile}function q(e,t,r){var o,a=r?e.replace(/.*=([\d]+%2C[\d]+).*$/,"$1"):e.replace(/.*-([\d]+x[\d]+)\..+$/,"$1");return"9999"===(o=a!==e?r?a.split("%2C"):a.split("x"):[t,0])[0]&&(o[0]="0"),"9999"===o[1]&&(o[1]="0"),o}function A(e){return e>=1?Math.round(10*e)/10+"s":"1/"+Math.round(1/e)+"s"}function E(e){return!e.match(" ")&&e.match("_")?"":e}function _(e,t){var a=void 0===t,i=p.info.querySelector(".jp-carousel-icon-comments .jp-carousel-has-comments-indicator");if(i.classList.remove("jp-carousel-show"),clearInterval(o),e){(!t||t<1)&&(t=0);var n=p.info.querySelector(".jp-carousel-comments"),l=p.info.querySelector("#jp-carousel-comments-loading");r.show(l),a&&(r.hide(n),n.innerHTML="");var s=new XMLHttpRequest,c=jetpackCarouselStrings.ajaxurl+"?action=get_attachment_comments&nonce="+jetpackCarouselStrings.nonce+"&id="+e+"&offset="+t;s.open("GET",c),s.setRequestHeader("X-Requested-With","XMLHttpRequest");var u=function(){r.fadeIn(n),r.fadeOut(l)};s.onload=function(){if(p.currentSlide&&p.currentSlide.attrs.attachmentId===e){var c,d=s.status>=200&&s.status<300;try{c=JSON.parse(s.responseText)}catch{}if(!d||!c||!Array.isArray(c))return u();a&&(n.innerHTML="");for(var m=0;m
",n.appendChild(h),clearInterval(o),o=setInterval(function(){p.container.scrollTop+150>window.innerHeight&&(_(e,t+10),clearInterval(o))},300)}c.length>0&&(r.show(n),i.innerText=c.length,i.classList.add("jp-carousel-show")),r.hide(l)}},s.onerror=u,s.send()}}function H(e){var t=e.el,r=e.attrs,o=t.querySelector("img");if(!o.hasAttribute("data-loaded")){var a=!!r.previewImage,i=r.thumbSize;!a||i&&t.offsetWidth>i.width?o.src=r.src:o.src=r.previewImage,o.setAttribute("itemprop","image"),o.setAttribute("data-loaded",1)}}function T(t){var r=t.el;e&&e.slides&&(r=e.slides[e.activeIndex]);var o=t.attrs.originalElement;o.complete&&0!==o.naturalHeight?C(t,r,o):o.onload=function(){C(t,r,o)}}function C(e,r,o){var a=t.getBackgroundImage(o);e.backgroundImage=a,r.style.backgroundImage="url("+a+")",r.style.backgroundSize="cover"}function I(){p.commentField&&(p.commentField.value="")}function M(e,o){p.slides=[];var a={width:window.innerWidth,height:window.innerHeight-64};0!==o&&null!==e[o].getAttribute("data-gallery-src")&&((new Image).src=e[o].getAttribute("data-gallery-src"));var i=!!r.closest(e[0],".tiled-gallery.type-rectangular");Array.prototype.forEach.call(e,function(e,o){var n=r.closest(e,"a"),l=e.getAttribute("data-orig-file")||e.getAttribute("src-orig"),s=e.getAttribute("data-attachment-id")||e.getAttribute("data-id")||"0",c=document.querySelector('img[data-attachment-id="'+s+'"] + figcaption');c=c?c.innerHTML:e.getAttribute("data-image-caption");var u={originalElement:e,attachmentId:s,commentsOpened:e.getAttribute("data-comments-opened")||"0",imageMeta:r.getJSONAttribute(e,"data-image-meta")||{},title:e.getAttribute("data-image-title")||"",desc:e.getAttribute("data-image-description")||"",mediumFile:e.getAttribute("data-medium-file")||"",largeFile:e.getAttribute("data-large-file")||"",origFile:l||"",thumbSize:{width:e.naturalWidth,height:e.naturalHeight},caption:c||"",permalink:n&&n.getAttribute("href"),src:l||e.getAttribute("src")||""},d=r.closest(e,".tiled-gallery-item"),m=d&&d.querySelector(".tiled-gallery-caption"),g=m&&m.innerHTML;g&&(u.caption=g);var h=function(e){var t=e.getAttribute("data-orig-size")||"";if(t){var r=t.split(",");return{width:parseInt(r[0],10),height:parseInt(r[1],10)}}return{width:e.getAttribute("data-original-width")||e.getAttribute("width")||void 0,height:e.getAttribute("data-original-height")||e.getAttribute("height")||void 0}}(e);if(u.origWidth=h.width||u.thumbSize.width,u.origHeight=h.height||u.thumbSize.height,"undefined"!=typeof wpcom&&wpcom.carousel&&wpcom.carousel.generateImgSrc?u.src=wpcom.carousel.generateImgSrc(e,a):u.src=x({origFile:u.src,origWidth:u.origWidth,origHeight:u.origHeight,maxWidth:a.width,maxHeight:a.height,mediumFile:u.mediumFile,largeFile:u.largeFile}),e.setAttribute("data-gallery-src",u.src),"0"!==u.attachmentId){u.title=t.texturize(u.title),u.desc=t.texturize(u.desc),u.caption=t.texturize(u.caption);var f=new Image,v=document.createElement("div");v.classList.add("swiper-slide"),v.setAttribute("itemprop","associatedMedia"),v.setAttribute("itemscope",""),v.setAttribute("itemtype","https://schema.org/ImageObject");var y=document.createElement("div");y.classList.add("swiper-zoom-container"),p.gallery.appendChild(v),v.appendChild(y),y.appendChild(f),v.setAttribute("data-attachment-id",u.attachmentId),v.setAttribute("data-permalink",u.permalink),v.setAttribute("data-orig-file",u.origFile),i&&(u.previewImage=u.src);var w={el:v,attrs:u,index:o};p.slides.push(w)}})}function F(e,t){if(!window.JetpackSwiper){var o=document.querySelector("#jp-carousel-loading-overlay");r.show(o);var a=document.createElement("script");return a.id="jetpack-carousel-swiper-js",a.src=window.jetpackSwiperLibraryPath.url,a.async=!0,a.onload=function(){r.hide(o),O(e,t)},a.onerror=function(){r.hide(o)},void document.head.appendChild(a)}O(e,t)}function O(t,o){var l,s={imgSelector:".gallery-item [data-attachment-id], .tiled-gallery-item [data-attachment-id], img[data-attachment-id], img[data-id]",startIndex:0},c=r.getJSONAttribute(t,"data-carousel-extra");if(!c)return;const u=t.querySelectorAll(s.imgSelector);if(u.length&&(w(),!p.isOpen)){for(var d in p.isOpen=!0,a=getComputedStyle(document.body).overflow,document.body.style.overflow="hidden",i=getComputedStyle(document.documentElement).overflow,document.documentElement.style.overflow="hidden",n=window.scrollY||window.pageYOffset||0,p.container.setAttribute("data-carousel-extra",JSON.stringify(c)),m(["open","view_image"]),o||{})s[d]=o[d];-1===s.startIndex&&(s.startIndex=0),r.emitEvent(p.overlay,"jp_carousel.beforeOpen"),p.gallery.innerHTML="",p.overlay.style.opacity=1,p.overlay.style.display="block",M(u,s.startIndex),(e=new window.JetpackSwiper(".jp-carousel-swiper-container",{centeredSlides:!0,zoom:!0,loop:p.slides.length>1,enabled:p.slides.length>1,pagination:{el:".jp-swiper-pagination",clickable:!0},navigation:{nextEl:".jp-swiper-button-next",prevEl:".jp-swiper-button-prev"},initialSlide:s.startIndex,on:{init:function(){L(s.startIndex)}},preventClicks:!1,preventClicksPropagation:!1,preventInteractionOnTransition:!r.isTouch(),threshold:5})).on("slideChange",function(e){L(e.realIndex),p.overlay.classList.remove("jp-carousel-hide-controls")}),e.on("zoomChange",function(e,t){t>1&&p.overlay.classList.add("jp-carousel-hide-controls"),1===t&&p.overlay.classList.remove("jp-carousel-hide-controls")}),e.on("doubleTap",function(e){if(clearTimeout(l),1===e.zoom.scale)var t=setTimeout(function(){p.overlay.classList.remove("jp-carousel-hide-controls"),clearTimeout(t)},150)}),e.on("tap",function(){e.zoom.scale>1&&(l=setTimeout(function(){p.overlay.classList.toggle("jp-carousel-hide-controls")},150))}),r.fadeIn(p.overlay,function(){r.emitEvent(p.overlay,"jp_carousel.afterOpen")})}}function W(e){if("click"!==e.type){if("keydown"===e.type){const t=document.activeElement.parentElement,r=t&&t.classList.contains("tiled-gallery__item");" "!==e.key&&"Enter"!==e.key||!r||R(e)}}else R(e)}function N(e){var t=e.parentElement,o=t.parentElement,a=null;return o&&o.classList.contains("wp-block-image")?a=t.getAttribute("href"):t&&t.classList.contains("wp-block-image")&&t.querySelector(":scope > a")&&(a=t.querySelector(":scope > a").getAttribute("href")),!(a&&a.split("?")[0]!==e.getAttribute("data-orig-file").split("?")[0]&&a!==e.getAttribute("data-permalink")||t.classList.contains("gallery-caption")||r.matches(t,"figcaption"))}function R(e){if(window.CSS&&window.CSS.supports&&window.CSS.supports("display","grid")){var t,o=e.target,a=r.closest(o,c);if(a){if(!(t=a)||!t.getAttribute("data-carousel-extra"))return;if(!N(o))return;document.documentElement.style.height="auto",e.preventDefault(),e.stopPropagation();var i=r.closest(o,d),n=Array.prototype.indexOf.call(a.querySelectorAll(d),i);F(a,{startIndex:n})}}}document.body.addEventListener("click",W),document.body.addEventListener("keydown",W),document.querySelectorAll(u+"img").forEach(function(e){N(e)&&y(e)}),1===Number(jetpackCarouselStrings.single_image_gallery)&&(b(),document.body.addEventListener("is.post-load",function(){b()})),window.addEventListener("hashchange",function(){var e=/jp-carousel-(\d+)/;if(window.location.hash&&e.test(window.location.hash)){if(window.location.hash!==l||!p.isOpen)if(window.location.hash&&p.gallery&&!p.isOpen&&history.back)history.back();else{l=window.location.hash;for(var t=window.location.hash.match(e),r=parseInt(t[1],10),o=document.querySelectorAll(c),a=0;a
{
if ( document.readyState !== 'loading' ) {
resolve();
} else {
window.addEventListener( 'DOMContentLoaded', () => resolve() );
}
} );
function JetpackLikesPostMessage( message, target ) {
if ( typeof message === 'string' ) {
try {
message = JSON.parse( message );
} catch {
return;
}
}
if ( target && typeof target.postMessage === 'function' ) {
try {
target.postMessage(
JSON.stringify( {
type: 'likesMessage',
data: message,
} ),
'*'
);
} catch {
// Ignore error
}
}
}
function JetpackLikesBatchHandler() {
const requests = [];
document.querySelectorAll( 'div.jetpack-likes-widget-unloaded' ).forEach( widget => {
if ( jetpackLikesWidgetBatch.indexOf( widget.id ) > -1 ) {
return;
}
if ( ! jetpackIsScrolledIntoView( widget ) ) {
return;
}
jetpackLikesWidgetBatch.push( widget.id );
var regex = /like-(post|comment)-wrapper-(\d+)-(\d+)-(\w+)/,
match = regex.exec( widget.id ),
info;
if ( ! match || match.length !== 5 ) {
return;
}
info = {
blog_id: match[ 2 ],
width: widget.width,
};
if ( 'post' === match[ 1 ] ) {
info.post_id = match[ 3 ];
} else if ( 'comment' === match[ 1 ] ) {
info.comment_id = match[ 3 ];
}
info.obj_id = match[ 4 ];
requests.push( info );
} );
if ( requests.length > 0 ) {
JetpackLikesPostMessage(
{ event: 'initialBatch', requests: requests },
window.frames[ 'likes-master' ]
);
}
}
function JetpackLikesMessageListener( event ) {
let message = event && event.data;
if ( typeof message === 'string' ) {
try {
message = JSON.parse( message );
} catch {
return;
}
}
const type = message && message.type;
const data = message && message.data;
if ( type !== 'likesMessage' || typeof data.event === 'undefined' ) {
return;
}
// We only allow messages from one origin
const allowedOrigin = 'https://widgets.wp.com';
if ( allowedOrigin !== event.origin ) {
return;
}
switch ( data.event ) {
case 'masterReady':
jetpackLikesDocReadyPromise.then( () => {
jetpackLikesMasterReady = true;
const stylesData = {
event: 'injectStyles',
};
const sdTextColor = document.querySelector( '.sd-text-color' );
const sdLinkColor = document.querySelector( '.sd-link-color' );
const sdTextColorStyles = ( sdTextColor && getComputedStyle( sdTextColor ) ) || {};
const sdLinkColorStyles = ( sdLinkColor && getComputedStyle( sdLinkColor ) ) || {};
// enable reblogs if we're on a single post page
if ( document.body.classList.contains( 'single' ) ) {
JetpackLikesPostMessage( { event: 'reblogsEnabled' }, window.frames[ 'likes-master' ] );
}
stylesData.textStyles = {
color: sdTextColorStyles.color,
fontFamily: sdTextColorStyles[ 'font-family' ],
fontSize: sdTextColorStyles[ 'font-size' ],
direction: sdTextColorStyles.direction,
fontWeight: sdTextColorStyles[ 'font-weight' ],
fontStyle: sdTextColorStyles[ 'font-style' ],
textDecoration: sdTextColorStyles[ 'text-decoration' ],
};
stylesData.linkStyles = {
color: sdLinkColorStyles.color,
fontFamily: sdLinkColorStyles[ 'font-family' ],
fontSize: sdLinkColorStyles[ 'font-size' ],
textDecoration: sdLinkColorStyles[ 'text-decoration' ],
fontWeight: sdLinkColorStyles[ 'font-weight' ],
fontStyle: sdLinkColorStyles[ 'font-style' ],
};
JetpackLikesPostMessage( stylesData, window.frames[ 'likes-master' ] );
JetpackLikesBatchHandler();
} );
break;
// We're keeping this for planned future follow ups.
// @see: https://github.com/Automattic/jetpack/pull/42361#discussion_r1995338815
case 'showLikeWidget':
break;
// We're keeping this for planned future follow ups.
// @see: https://github.com/Automattic/jetpack/pull/42361#discussion_r1995338815
case 'showCommentLikeWidget':
break;
case 'killCommentLikes':
// If kill switch for comment likes is enabled remove all widgets wrappers and `Loading...` placeholders.
document
.querySelectorAll( '.jetpack-comment-likes-widget-wrapper' )
.forEach( wrapper => wrapper.remove() );
break;
case 'clickReblogFlair':
if ( wpcom_reblog && typeof wpcom_reblog.toggle_reblog_box_flair === 'function' ) {
wpcom_reblog.toggle_reblog_box_flair( data.obj_id );
}
break;
case 'hideOtherGravatars': {
hideLikersPopover();
break;
}
case 'showOtherGravatars': {
const container = document.querySelector( '#likes-other-gravatars' );
if ( ! container ) {
break;
}
const list = container.querySelector( 'ul' );
container.style.display = 'none';
list.innerHTML = '';
container
.querySelectorAll( '.likes-text span' )
.forEach( item => ( item.textContent = data.totalLikesLabel ) );
( data.likers || [] ).forEach( async ( liker, index ) => {
if ( liker.profile_URL.substr( 0, 4 ) !== 'http' ) {
// We only display gravatars with http or https schema
return;
}
const element = document.createElement( 'li' );
list.append( element );
const profileLink = encodeURI( liker.profile_URL );
const avatarLink = encodeURI( liker.avatar_URL );
element.innerHTML = `
`;
// Add some extra attributes through native methods, to ensure strings are sanitized.
element.classList.add( liker.css_class );
element.querySelector( 'img' ).alt = data.avatarAltTitle.replace( '%s', liker.name );
element.querySelector( 'span' ).innerText = liker.name;
if ( index === data.likers.length - 1 ) {
element.addEventListener( 'keydown', e => {
if ( e.key === 'Tab' && ! e.shiftKey ) {
e.preventDefault();
hideLikersPopover();
JetpackLikesPostMessage(
{ event: 'focusLikesCount', parent: data.parent },
window.frames[ 'likes-master' ]
);
}
} );
}
} );
const positionPopup = function () {
const containerStyle = getComputedStyle( container );
const isRtl = containerStyle.direction === 'rtl';
const el = document.querySelector( `*[name='${ data.parent }']` );
const rect = el.getBoundingClientRect();
const win = el.ownerDocument.defaultView;
const offset = {
top: rect.top + win.pageYOffset,
left: rect.left + win.pageXOffset,
};
let containerLeft = 0;
container.style.top = offset.top + data.position.top - 1 + 'px';
if ( isRtl ) {
const visibleAvatarsCount = data && data.likers ? Math.min( data.likers.length, 5 ) : 0;
// 24px is the width of the avatar + 4px is the padding between avatars
containerLeft = offset.left + data.position.left + 24 * visibleAvatarsCount + 4;
container.style.transform = 'translateX(-100%)';
} else {
containerLeft = offset.left + data.position.left;
}
container.style.left = containerLeft + 'px';
// Container width - padding
const initContainerWidth = data.width - 20;
const rowLength = Math.floor( initContainerWidth / 37 );
// # of rows + (avatar + avatar padding) + text above + container padding
let height = Math.ceil( data.likers.length / rowLength ) * 37 + 17 + 22;
if ( height > 204 ) {
height = 204;
}
// If the popup overflows viewport width, we should show it on the next line.
// Push it offscreen to calculated rendered width.
container.style.left = '-9999px';
container.style.display = 'block';
// If the popup exceeds the viewport width,
// flip the position of the popup.
const containerWidth = container.offsetWidth;
const containerRight = containerLeft + containerWidth;
if ( containerRight > win.innerWidth ) {
containerLeft = rect.right - containerWidth;
}
// Set the container left
container.style.left = containerLeft + 'px';
container.setAttribute( 'aria-hidden', 'false' );
};
positionPopup();
container.focus();
const debounce = function ( func, wait ) {
var timeout;
return function () {
var context = this;
var args = arguments;
clearTimeout( timeout );
timeout = setTimeout( function () {
func.apply( context, args );
}, wait );
};
};
const debouncedPositionPopup = debounce( positionPopup, 100 );
// Keep a reference of this function in the element itself
// so that we can destroy it later
container.__resizeHandler = debouncedPositionPopup;
// When window is resized, resize the popup.
window.addEventListener( 'resize', debouncedPositionPopup );
container.focus();
}
}
}
window.addEventListener( 'message', JetpackLikesMessageListener );
function hideLikersPopover() {
const container = document.querySelector( '#likes-other-gravatars' );
if ( container ) {
container.style.display = 'none';
container.setAttribute( 'aria-hidden', 'true' );
// Remove the resize event listener and cleanup.
const resizeHandler = container.__resizeHandler;
if ( resizeHandler ) {
window.removeEventListener( 'resize', resizeHandler );
delete container.__resizeHandler;
}
}
}
document.addEventListener( 'click', hideLikersPopover );
function JetpackLikesWidgetQueueHandler() {
var wrapperID;
if ( ! jetpackLikesMasterReady ) {
setTimeout( JetpackLikesWidgetQueueHandler, 500 );
return;
}
// Restore widgets to initial unloaded state when they are scrolled out of view.
jetpackUnloadScrolledOutWidgets();
var unloadedWidgetsInView = jetpackGetUnloadedWidgetsInView();
if ( unloadedWidgetsInView.length > 0 ) {
// Grab any unloaded widgets for a batch request
JetpackLikesBatchHandler();
}
for ( var i = 0, length = unloadedWidgetsInView.length; i <= length - 1; i++ ) {
wrapperID = unloadedWidgetsInView[ i ].id;
if ( ! wrapperID ) {
continue;
}
jetpackLoadLikeWidgetIframe( wrapperID );
}
}
function jetpackLoadLikeWidgetIframe( wrapperID ) {
if ( typeof wrapperID === 'undefined' ) {
return;
}
const wrapper = document.querySelector( '#' + wrapperID );
wrapper.querySelectorAll( 'iframe' ).forEach( iFrame => iFrame.remove() );
const placeholder = wrapper.querySelector( '.likes-widget-placeholder' );
// Post like iframe
if ( placeholder && placeholder.classList.contains( 'post-likes-widget-placeholder' ) ) {
const postLikesFrame = document.createElement( 'iframe' );
postLikesFrame.classList.add( 'post-likes-widget', 'jetpack-likes-widget' );
postLikesFrame.name = wrapper.dataset.name;
postLikesFrame.src = wrapper.dataset.src;
postLikesFrame.height = '55px';
postLikesFrame.width = '100%';
postLikesFrame.frameBorder = '0';
postLikesFrame.scrolling = 'no';
postLikesFrame.title = wrapper.dataset.title;
placeholder.after( postLikesFrame );
}
// Comment like iframe
if ( placeholder.classList.contains( 'comment-likes-widget-placeholder' ) ) {
const commentLikesFrame = document.createElement( 'iframe' );
commentLikesFrame.class = 'comment-likes-widget-frame jetpack-likes-widget-frame';
commentLikesFrame.name = wrapper.dataset.name;
commentLikesFrame.src = wrapper.dataset.src;
commentLikesFrame.height = '18px';
commentLikesFrame.width = '100%';
commentLikesFrame.frameBorder = '0';
commentLikesFrame.scrolling = 'no';
wrapper.querySelector( '.comment-like-feedback' ).after( commentLikesFrame );
jetpackCommentLikesLoadedWidgets.push( commentLikesFrame );
}
wrapper.classList.remove( 'jetpack-likes-widget-unloaded' );
wrapper.classList.add( 'jetpack-likes-widget-loading' );
wrapper.querySelector( 'iframe' ).addEventListener( 'load', e => {
JetpackLikesPostMessage(
{ event: 'loadLikeWidget', name: e.target.name, width: e.target.width },
window.frames[ 'likes-master' ]
);
wrapper.classList.remove( 'jetpack-likes-widget-loading' );
wrapper.classList.add( 'jetpack-likes-widget-loaded' );
} );
}
function jetpackGetUnloadedWidgetsInView() {
const unloadedWidgets = document.querySelectorAll( 'div.jetpack-likes-widget-unloaded' );
return [ ...unloadedWidgets ].filter( item => jetpackIsScrolledIntoView( item ) );
}
function jetpackIsScrolledIntoView( element ) {
const top = element.getBoundingClientRect().top;
const bottom = element.getBoundingClientRect().bottom;
// Allow some slack above and bellow the fold with jetpackLikesLookAhead,
// with the aim of hiding the transition from unloaded to loaded widget from users.
return top + jetpackLikesLookAhead >= 0 && bottom <= window.innerHeight + jetpackLikesLookAhead;
}
function jetpackUnloadScrolledOutWidgets() {
for ( let i = jetpackCommentLikesLoadedWidgets.length - 1; i >= 0; i-- ) {
const currentWidgetIframe = jetpackCommentLikesLoadedWidgets[ i ];
if ( ! jetpackIsScrolledIntoView( currentWidgetIframe ) ) {
const widgetWrapper =
currentWidgetIframe &&
currentWidgetIframe.parentElement &&
currentWidgetIframe.parentElement.parentElement;
// Restore parent class to 'unloaded' so this widget can be picked up by queue manager again if needed.
widgetWrapper.classList.remove( 'jetpack-likes-widget-loaded' );
widgetWrapper.classList.remove( 'jetpack-likes-widget-loading' );
widgetWrapper.classList.add( 'jetpack-likes-widget-unloaded' );
// Remove it from the list of loaded widgets.
jetpackCommentLikesLoadedWidgets.splice( i, 1 );
// Remove comment like widget iFrame.
currentWidgetIframe.remove();
}
}
}
var jetpackWidgetsDelayedExec = function ( after, fn ) {
var timer;
return function () {
clearTimeout( timer );
timer = setTimeout( fn, after );
};
};
var jetpackOnScrollStopped = jetpackWidgetsDelayedExec( 250, JetpackLikesWidgetQueueHandler );
// Load initial batch of widgets, prior to any scrolling events.
JetpackLikesWidgetQueueHandler();
// Add event listener to execute queue handler after scroll.
window.addEventListener( 'scroll', jetpackOnScrollStopped, true );
;