!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.PhotoSwipe=t()}(this,function(){"use strict";return function(m,n,e,t){var f={features:null,bind:function(e,t,n,i){var o=(i?"remove":"add")+"EventListener";t=t.split(" ");for(var a=0;a<t.length;a++)t[a]&&e[o](t[a],n,!1)},isArray:function(e){return e instanceof Array},createEl:function(e,t){t=document.createElement(t||"div");return e&&(t.className=e),t},getScrollY:function(){var e=window.pageYOffset;return e!==undefined?e:document.documentElement.scrollTop},unbind:function(e,t,n){f.bind(e,t,n,!0)},removeClass:function(e,t){t=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(t," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")},addClass:function(e,t){f.hasClass(e,t)||(e.className+=(e.className?" ":"")+t)},hasClass:function(e,t){return e.className&&new RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},getChildByClass:function(e,t){for(var n=e.firstChild;n;){if(f.hasClass(n,t))return n;n=n.nextSibling}},arraySearch:function(e,t,n){for(var i=e.length;i--;)if(e[i][n]===t)return i;return-1},extend:function(e,t,n){for(var i in t)t.hasOwnProperty(i)&&(n&&e.hasOwnProperty(i)||(e[i]=t[i]))},easing:{sine:{out:function(e){return Math.sin(e*(Math.PI/2))},inOut:function(e){return-(Math.cos(Math.PI*e)-1)/2}},cubic:{out:function(e){return--e*e*e+1}}},detectFeatures:function(){if(f.features)return f.features;var e,t,n=f.createEl().style,i="",o={};o.oldIE=document.all&&!document.addEventListener,o.touch="ontouchstart"in window,window.requestAnimationFrame&&(o.raf=window.requestAnimationFrame,o.caf=window.cancelAnimationFrame),o.pointerEvent=!!window.PointerEvent||navigator.msPointerEnabled,o.pointerEvent||(e=navigator.userAgent,!/iP(hone|od)/.test(navigator.platform)||(t=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/))&&0<t.length&&1<=(t=parseInt(t[1],10))&&t<8&&(o.isOldIOSPhone=!0),t=(t=e.match(/Android\s([0-9\.]*)/))?t[1]:0,1<=(t=parseFloat(t))&&(t<4.4&&(o.isOldAndroid=!0),o.androidVersion=t),o.isMobileOpera=/opera mini|opera mobi/i.test(e));for(var a,r,l,s=["transform","perspective","animationName"],u=["","webkit","Moz","ms","O"],c=0;c<4;c++){i=u[c];for(var d=0;d<3;d++)a=s[d],r=i+(i?a.charAt(0).toUpperCase()+a.slice(1):a),!o[a]&&r in n&&(o[a]=r);i&&!o.raf&&(i=i.toLowerCase(),o.raf=window[i+"RequestAnimationFrame"],o.raf&&(o.caf=window[i+"CancelAnimationFrame"]||window[i+"CancelRequestAnimationFrame"]))}return o.raf||(l=0,o.raf=function(e){var t=(new Date).getTime(),n=Math.max(0,16-(t-l)),i=window.setTimeout(function(){e(t+n)},n);return l=t+n,i},o.caf=function(e){clearTimeout(e)}),o.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,f.features=o}};f.detectFeatures(),f.features.oldIE&&(f.bind=function(e,t,n,i){t=t.split(" ");for(var o,a=(i?"detach":"attach")+"Event",r=function(){n.handleEvent.call(n)},l=0;l<t.length;l++)if(o=t[l])if("object"==typeof n&&n.handleEvent){if(i){if(!n["oldIE"+o])return!1}else n["oldIE"+o]=r;e[a]("on"+o,n["oldIE"+o])}else e[a]("on"+o,n)});var h=this,y={allowPanToNext:!0,spacing:.12,bgOpacity:1,mouseUsed:!1,loop:!0,pinchToClose:!0,closeOnScroll:!0,closeOnVerticalDrag:!0,verticalDragRange:.75,hideAnimationDuration:333,showAnimationDuration:333,showHideOpacity:!1,focus:!0,escKey:!0,arrowKeys:!0,mainScrollEndFriction:.35,panEndFriction:.35,isClickableElement:function(e){return"A"===e.tagName},getDoubleTapZoom:function(e,t){return e||t.initialZoomLevel<.7?1:1.33},maxSpreadZoom:1.33,modal:!0,scaleMode:"fit"};f.extend(y,t);var r,i,o,x,a,l,s,u,c,g,d,p,v,w,b,I,C,D,T,M,S,A,E,O,k,R,P,Z,F,L,z,_,N,U,H,Y,W,B,G,X,V,K,q,$,j,J,Q,ee,te,ne,ie,oe,ae,re,le,se,ue=function(){return{x:0,y:0}},ce=ue(),de=ue(),pe=ue(),me={},fe=0,he={},ye=ue(),xe=0,ge=!0,ve=[],we={},be=!1,Ie=function(e,t){f.extend(h,t.publicMethods),ve.push(e)},Ce=function(e){var t=Ht();return t-1<e?e-t:e<0?t+e:e},De={},Te=function(e,t){return De[e]||(De[e]=[]),De[e].push(t)},Me=function(e){var t=De[e];if(t){var n=Array.prototype.slice.call(arguments);n.shift();for(var i=0;i<t.length;i++)t[i].apply(h,n)}},Se=function(){return(new Date).getTime()},Ae=function(e){re=e,h.bg.style.opacity=e*y.bgOpacity},Ee=function(e,t,n,i,o){(!be||o&&o!==h.currItem)&&(i/=(o||h.currItem).fitRatio),e[A]=p+t+"px, "+n+"px"+v+" scale("+i+")"},Oe=function(e){te&&(e&&(g>h.currItem.fitRatio?be||(jt(h.currItem,!1,!0),be=!0):be&&(jt(h.currItem),be=!1)),Ee(te,pe.x,pe.y,g))},ke=function(e){e.container&&Ee(e.container.style,e.initialPosition.x,e.initialPosition.y,e.initialZoomLevel,e)},Re=function(e,t){t[A]=p+e+"px, 0px"+v},Pe=function(e,t){var n;!y.loop&&t&&(n=x+(ye.x*fe-e)/ye.x,t=Math.round(e-ct.x),(n<0&&0<t||n>=Ht()-1&&t<0)&&(e=ct.x+t*y.mainScrollEndFriction)),ct.x=e,Re(e,a)},Ze=function(e,t){var n=dt[e]-he[e];return de[e]+ce[e]+n-t/d*n},Fe=function(e,t){e.x=t.x,e.y=t.y,t.id&&(e.id=t.id)},Le=function(e){e.x=Math.round(e.x),e.y=Math.round(e.y)},ze=null,_e=function(){ze&&(f.unbind(document,"mousemove",_e),f.addClass(m,"pswp--has_mouse"),y.mouseUsed=!0,Me("mouseUsed")),ze=setTimeout(function(){ze=null},100)},Ne=function(e,t){e=Vt(h.currItem,me,e);return t&&(ee=e),e},Ue=function(e){return(e=e||h.currItem).initialZoomLevel},He=function(e){return 0<(e=e||h.currItem).w?y.maxSpreadZoom:1},Ye=function(e,t,n,i){return i===h.currItem.initialZoomLevel?(n[e]=h.currItem.initialPosition[e],!0):(n[e]=Ze(e,i),n[e]>t.min[e]?(n[e]=t.min[e],!0):n[e]<t.max[e]&&(n[e]=t.max[e],!0))},We=function(e){var t="";y.escKey&&27===e.keyCode?t="close":y.arrowKeys&&(37===e.keyCode?t="prev":39===e.keyCode&&(t="next")),t&&(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey||(e.preventDefault?e.preventDefault():e.returnValue=!1,h[t]()))},Be=function(e){e&&(K||V||ne||W)&&(e.preventDefault(),e.stopPropagation())},Ge=function(){h.setScrollOffset(0,f.getScrollY())},Xe={},Ve=0,Ke=function(e){Xe[e]&&(Xe[e].raf&&R(Xe[e].raf),Ve--,delete Xe[e])},qe=function(e){Xe[e]&&Ke(e),Xe[e]||(Ve++,Xe[e]={})},$e=function(){for(var e in Xe)Xe.hasOwnProperty(e)&&Ke(e)},je=function(e,t,n,i,o,a,r){var l,s=Se();qe(e);var u=function(){if(Xe[e]){if(l=Se()-s,i<=l)return Ke(e),a(n),void(r&&r());a((n-t)*o(l/i)+t),Xe[e].raf=k(u)}};u()},t={shout:Me,listen:Te,viewportSize:me,options:y,isMainScrollAnimating:function(){return ne},getZoomLevel:function(){return g},getCurrentIndex:function(){return x},isDragging:function(){return G},isZooming:function(){return J},setScrollOffset:function(e,t){he.x=e,L=he.y=t,Me("updateScrollOffset",he)},applyZoomPan:function(e,t,n,i){pe.x=t,pe.y=n,g=e,Oe(i)},init:function(){if(!r&&!i){var e;h.framework=f,h.template=m,h.bg=f.getChildByClass(m,"pswp__bg"),P=m.className,r=!0,z=f.detectFeatures(),k=z.raf,R=z.caf,A=z.transform,F=z.oldIE,h.scrollWrap=f.getChildByClass(m,"pswp__scroll-wrap"),h.container=f.getChildByClass(h.scrollWrap,"pswp__container"),a=h.container.style,h.itemHolders=I=[{el:h.container.children[0],wrap:0,index:-1},{el:h.container.children[1],wrap:0,index:-1},{el:h.container.children[2],wrap:0,index:-1}],I[0].el.style.display=I[2].el.style.display="none",function(){if(A){var e=z.perspective&&!O;return p="translate"+(e?"3d(":"("),v=z.perspective?", 0px)":")"}A="left",f.addClass(m,"pswp--ie"),Re=function(e,t){t.left=e+"px"},ke=function(e){var t=1<e.fitRatio?1:e.fitRatio,n=e.container.style,i=t*e.w,t=t*e.h;n.width=i+"px",n.height=t+"px",n.left=e.initialPosition.x+"px",n.top=e.initialPosition.y+"px"},Oe=function(){var e,t,n,i;te&&(e=te,n=(t=1<(i=h.currItem).fitRatio?1:i.fitRatio)*i.w,i=t*i.h,e.width=n+"px",e.height=i+"px",e.left=pe.x+"px",e.top=pe.y+"px")}}(),c={resize:h.updateSize,orientationchange:function(){clearTimeout(_),_=setTimeout(function(){me.x!==h.scrollWrap.clientWidth&&h.updateSize()},500)},scroll:Ge,keydown:We,click:Be};var t=z.isOldIOSPhone||z.isOldAndroid||z.isMobileOpera;for(z.animationName&&z.transform&&!t||(y.showAnimationDuration=y.hideAnimationDuration=0),e=0;e<ve.length;e++)h["init"+ve[e]]();n&&(h.ui=new n(h,f)).init(),Me("firstUpdate"),x=x||y.index||0,(isNaN(x)||x<0||x>=Ht())&&(x=0),h.currItem=Ut(x),(z.isOldIOSPhone||z.isOldAndroid)&&(ge=!1),m.setAttribute("aria-hidden","false"),y.modal&&(ge?m.style.position="fixed":(m.style.position="absolute",m.style.top=f.getScrollY()+"px")),L===undefined&&(Me("initialLayout"),L=Z=f.getScrollY());t="pswp--open ";for(y.mainClass&&(t+=y.mainClass+" "),y.showHideOpacity&&(t+="pswp--animate_opacity "),t+=O?"pswp--touch":"pswp--notouch",t+=z.animationName?" pswp--css_animation":"",t+=z.svg?" pswp--svg":"",f.addClass(m,t),h.updateSize(),l=-1,xe=null,e=0;e<3;e++)Re((e+l)*ye.x,I[e].el.style);F||f.bind(h.scrollWrap,u,h),Te("initialZoomInEnd",function(){h.setContent(I[0],x-1),h.setContent(I[2],x+1),I[0].el.style.display=I[2].el.style.display="block",y.focus&&m.focus(),f.bind(document,"keydown",h),z.transform&&f.bind(h.scrollWrap,"click",h),y.mouseUsed||f.bind(document,"mousemove",_e),f.bind(window,"resize scroll orientationchange",h),Me("bindEvents")}),h.setContent(I[1],x),h.updateCurrItem(),Me("afterInit"),ge||(w=setInterval(function(){Ve||G||J||g!==h.currItem.initialZoomLevel||h.updateSize()},1e3)),f.addClass(m,"pswp--visible")}},close:function(){r&&(i=!(r=!1),Me("close"),f.unbind(window,"resize scroll orientationchange",h),f.unbind(window,"scroll",c.scroll),f.unbind(document,"keydown",h),f.unbind(document,"mousemove",_e),z.transform&&f.unbind(h.scrollWrap,"click",h),G&&f.unbind(window,s,h),clearTimeout(_),Me("unbindEvents"),Yt(h.currItem,null,!0,h.destroy))},destroy:function(){Me("destroy"),Lt&&clearTimeout(Lt),m.setAttribute("aria-hidden","true"),m.className=P,w&&clearInterval(w),f.unbind(h.scrollWrap,u,h),f.unbind(window,"scroll",h),ft(),$e(),De=null},panTo:function(e,t,n){n||(e>ee.min.x?e=ee.min.x:e<ee.max.x&&(e=ee.max.x),t>ee.min.y?t=ee.min.y:t<ee.max.y&&(t=ee.max.y)),pe.x=e,pe.y=t,Oe()},handleEvent:function(e){e=e||window.event,c[e.type]&&c[e.type](e)},goTo:function(e){var t=(e=Ce(e))-x;xe=t,x=e,h.currItem=Ut(x),fe-=t,Pe(ye.x*fe),$e(),ne=!1,h.updateCurrItem()},next:function(){h.goTo(x+1)},prev:function(){h.goTo(x-1)},updateCurrZoomItem:function(e){var t;e&&Me("beforeChange",0),te=I[1].el.children.length?(t=I[1].el.children[0],f.hasClass(t,"pswp__zoom-wrap")?t.style:null):null,ee=h.currItem.bounds,d=g=h.currItem.initialZoomLevel,pe.x=ee.center.x,pe.y=ee.center.y,e&&Me("afterChange")},invalidateCurrItems:function(){b=!0;for(var e=0;e<3;e++)I[e].item&&(I[e].item.needsUpdate=!0)},updateCurrItem:function(e){if(0!==xe){var t,n=Math.abs(xe);if(!(e&&n<2)){h.currItem=Ut(x),be=!1,Me("beforeChange",xe),3<=n&&(l+=xe+(0<xe?-3:3),n=3);for(var i=0;i<n;i++)0<xe?(t=I.shift(),I[2]=t,Re((++l+2)*ye.x,t.el.style),h.setContent(t,x-n+i+1+1)):(t=I.pop(),I.unshift(t),Re(--l*ye.x,t.el.style),h.setContent(t,x+n-i-1-1));!te||1!==Math.abs(xe)||(e=Ut(C)).initialZoomLevel!==g&&(Vt(e,me),jt(e),ke(e)),xe=0,h.updateCurrZoomItem(),C=x,Me("afterChange")}}},updateSize:function(e){if(!ge&&y.modal){var t=f.getScrollY();if(L!==t&&(m.style.top=t+"px",L=t),!e&&we.x===window.innerWidth&&we.y===window.innerHeight)return;we.x=window.innerWidth,we.y=window.innerHeight,m.style.height=we.y+"px"}if(me.x=h.scrollWrap.clientWidth,me.y=h.scrollWrap.clientHeight,Ge(),ye.x=me.x+Math.round(me.x*y.spacing),ye.y=me.y,Pe(ye.x*fe),Me("beforeResize"),l!==undefined){for(var n,i,o,a=0;a<3;a++)n=I[a],Re((a+l)*ye.x,n.el.style),o=x+a-1,y.loop&&2<Ht()&&(o=Ce(o)),(i=Ut(o))&&(b||i.needsUpdate||!i.bounds)?(h.cleanSlide(i),h.setContent(n,o),1===a&&(h.currItem=i,h.updateCurrZoomItem(!0)),i.needsUpdate=!1):-1===n.index&&0<=o&&h.setContent(n,o),i&&i.container&&(Vt(i,me),jt(i),ke(i));b=!1}d=g=h.currItem.initialZoomLevel,(ee=h.currItem.bounds)&&(pe.x=ee.center.x,pe.y=ee.center.y,Oe(!0)),Me("resize")},zoomTo:function(t,e,n,i,o){e&&(d=g,dt.x=Math.abs(e.x)-pe.x,dt.y=Math.abs(e.y)-pe.y,Fe(de,pe));var e=Ne(t,!1),a={};Ye("x",e,a,t),Ye("y",e,a,t);var r=g,l=pe.x,s=pe.y;Le(a);e=function(e){1===e?(g=t,pe.x=a.x,pe.y=a.y):(g=(t-r)*e+r,pe.x=(a.x-l)*e+l,pe.y=(a.y-s)*e+s),o&&o(e),Oe(1===e)};n?je("customZoomTo",0,1,n,i||f.easing.sine.inOut,e):e(1)}},Je={},Qe={},et={},tt={},nt={},it=[],ot={},at=[],rt={},lt=0,st=ue(),ut=0,ct=ue(),dt=ue(),pt=ue(),mt=function(e,t){return rt.x=Math.abs(e.x-t.x),rt.y=Math.abs(e.y-t.y),Math.sqrt(rt.x*rt.x+rt.y*rt.y)},ft=function(){q&&(R(q),q=null)},ht=function(){G&&(q=k(ht),Et())},yt=function(e,t){return!(!e||e===document)&&(!(e.getAttribute("class")&&-1<e.getAttribute("class").indexOf("pswp__scroll-wrap"))&&(t(e)?e:yt(e.parentNode,t)))},xt={},gt=function(e,t){return xt.prevent=!yt(e.target,y.isClickableElement),Me("preventDragEvent",e,t,xt),xt.prevent},vt=function(e,t){return t.x=e.pageX,t.y=e.pageY,t.id=e.identifier,t},wt=function(e,t,n){n.x=.5*(e.x+t.x),n.y=.5*(e.y+t.y)},bt=function(){var e=pe.y-h.currItem.initialPosition.y;return 1-Math.abs(e/(me.y/2))},It={},Ct={},Dt=[],Tt=function(e){for(;0<Dt.length;)Dt.pop();return E?(se=0,it.forEach(function(e){0===se?Dt[0]=e:1===se&&(Dt[1]=e),se++})):-1<e.type.indexOf("touch")?e.touches&&0<e.touches.length&&(Dt[0]=vt(e.touches[0],It),1<e.touches.length&&(Dt[1]=vt(e.touches[1],Ct))):(It.x=e.pageX,It.y=e.pageY,It.id="",Dt[0]=It),Dt},Mt=function(e,t){var n,i,o,a=pe[e]+t[e],r=0<t[e],l=ct.x+t.x,s=ct.x-ot.x,u=a>ee.min[e]||a<ee.max[e]?y.panEndFriction:1,a=pe[e]+t[e]*u;if((y.allowPanToNext||g===h.currItem.initialZoomLevel)&&(te?"h"!==ie||"x"!==e||V||(r?(a>ee.min[e]&&(u=y.panEndFriction,ee.min[e],n=ee.min[e]-de[e]),(n<=0||s<0)&&1<Ht()?(o=l,s<0&&l>ot.x&&(o=ot.x)):ee.min.x!==ee.max.x&&(i=a)):(a<ee.max[e]&&(u=y.panEndFriction,ee.max[e],n=de[e]-ee.max[e]),(n<=0||0<s)&&1<Ht()?(o=l,0<s&&l<ot.x&&(o=ot.x)):ee.min.x!==ee.max.x&&(i=a))):o=l,"x"===e))return o!==undefined&&(Pe(o,!0),$=o!==ot.x),ee.min.x!==ee.max.x&&(i!==undefined?pe.x=i:$||(pe.x+=t.x*u)),o!==undefined;ne||$||g>h.currItem.fitRatio&&(pe[e]+=t[e]*u)},St=function(e){var t;"mousedown"===e.type&&0<e.button||(Nt?e.preventDefault():B&&"mousedown"===e.type||(gt(e,!0)&&e.preventDefault(),Me("pointerDown"),E&&((t=f.arraySearch(it,e.pointerId,"id"))<0&&(t=it.length),it[t]={x:e.pageX,y:e.pageY,id:e.pointerId}),e=(t=Tt(e)).length,j=null,$e(),G&&1!==e||(G=oe=!0,f.bind(window,s,h),Y=le=ae=W=$=K=X=V=!1,ie=null,Me("firstTouchStart",t),Fe(de,pe),ce.x=ce.y=0,Fe(tt,t[0]),Fe(nt,tt),ot.x=ye.x*fe,at=[{x:tt.x,y:tt.y}],U=N=Se(),Ne(g,!0),ft(),ht()),!J&&1<e&&!ne&&!$&&(d=g,J=X=!(V=!1),ce.y=ce.x=0,Fe(de,pe),Fe(Je,t[0]),Fe(Qe,t[1]),wt(Je,Qe,pt),dt.x=Math.abs(pt.x)-pe.x,dt.y=Math.abs(pt.y)-pe.y,Q=mt(Je,Qe))))},At=function(e){var t,n;e.preventDefault(),!E||-1<(t=f.arraySearch(it,e.pointerId,"id"))&&((n=it[t]).x=e.pageX,n.y=e.pageY),G&&(n=Tt(e),ie||K||J?j=n:ct.x!==ye.x*fe?ie="h":(e=Math.abs(n[0].x-tt.x)-Math.abs(n[0].y-tt.y),10<=Math.abs(e)&&(ie=0<e?"h":"v",j=n)))},Et=function(){if(j){var e,t,n,i,o,a=j.length;if(0!==a)if(Fe(Je,j[0]),et.x=Je.x-tt.x,et.y=Je.y-tt.y,J&&1<a)tt.x=Je.x,tt.y=Je.y,(et.x||et.y||(i=j[1],o=Qe,i.x!==o.x||i.y!==o.y))&&(Fe(Qe,j[1]),V||(V=!0,Me("zoomGestureStarted")),t=mt(Je,Qe),(n=Zt(t))>h.currItem.initialZoomLevel+h.currItem.initialZoomLevel/15&&(le=!0),e=1,a=Ue(),i=He(),n<a?y.pinchToClose&&!le&&d<=h.currItem.initialZoomLevel?(Ae(o=1-(a-n)/(a/1.2)),Me("onPinchClose",o),ae=!0):(1<(e=(a-n)/a)&&(e=1),n=a-e*(a/3)):i<n&&(1<(e=(n-i)/(6*a))&&(e=1),n=i+e*a),e<0&&(e=0),wt(Je,Qe,st),ce.x+=st.x-pt.x,ce.y+=st.y-pt.y,Fe(pt,st),pe.x=Ze("x",n),pe.y=Ze("y",n),Y=g<n,g=n,Oe());else if(ie&&(oe&&(oe=!1,10<=Math.abs(et.x)&&(et.x-=j[0].x-nt.x),10<=Math.abs(et.y)&&(et.y-=j[0].y-nt.y)),tt.x=Je.x,tt.y=Je.y,0!==et.x||0!==et.y)){if("v"===ie&&y.closeOnVerticalDrag&&"fit"===y.scaleMode&&g===h.currItem.initialZoomLevel){ce.y+=et.y,pe.y+=et.y;var r=bt();return W=!0,Me("onVerticalDrag",r),Ae(r),void Oe()}e=Se(),t=Je.x,n=Je.y,50<e-U&&((r=2<at.length?at.shift():{}).x=t,r.y=n,at.push(r),U=e),K=!0,ee=h.currItem.bounds,Mt("x",et)||(Mt("y",et),Le(pe),Oe())}}},Ot=function(e){if(z.isOldAndroid){if(B&&"mouseup"===e.type)return;-1<e.type.indexOf("touch")&&(clearTimeout(B),B=setTimeout(function(){B=0},600))}Me("pointerUp"),gt(e,!1)&&e.preventDefault(),!E||-1<(n=f.arraySearch(it,e.pointerId,"id"))&&(a=it.splice(n,1)[0],navigator.msPointerEnabled?(a.type={4:"mouse",2:"touch",3:"pen"}[e.pointerType],a.type||(a.type=e.pointerType||"mouse")):a.type=e.pointerType||"mouse");var t=Tt(e),n=t.length;if("mouseup"===e.type&&(n=0),2===n)return!(j=null);1===n&&Fe(nt,t[0]),0!==n||ie||ne||(a||("mouseup"===e.type?a={x:e.pageX,y:e.pageY,type:"mouse"}:e.changedTouches&&e.changedTouches[0]&&(a={x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,type:"touch"})),Me("touchRelease",e,a));var i,o,a=-1;if(0===n&&(G=!1,f.unbind(window,s,h),ft(),J?a=0:-1!==ut&&(a=Se()-ut)),ut=1===n?Se():-1,a=-1!==a&&a<150?"zoom":"swipe",J&&n<2&&(J=!1,1===n&&(a="zoomPointerUp"),Me("zoomGestureEnded")),j=null,K||V||ne||W)if($e(),(H=H||kt()).calculateSwipeSpeed("x"),W){bt()<y.verticalDragRange?h.close():(i=pe.y,o=re,je("verticalDrag",0,1,300,f.easing.cubic.out,function(e){pe.y=(h.currItem.initialPosition.y-i)*e+i,Ae((1-o)*e+o),Oe()}),Me("onVerticalDrag",1))}else{if(($||ne)&&0===n){if(Pt(a,H))return;a="zoomPointerUp"}ne||("swipe"===a?!$&&g>h.currItem.fitRatio&&Rt(H):Ft())}},kt=function(){var t,n,i={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(e){n=1<at.length?(t=Se()-U+50,at[at.length-2][e]):(t=Se()-N,nt[e]),i.lastFlickOffset[e]=tt[e]-n,i.lastFlickDist[e]=Math.abs(i.lastFlickOffset[e]),20<i.lastFlickDist[e]?i.lastFlickSpeed[e]=i.lastFlickOffset[e]/t:i.lastFlickSpeed[e]=0,Math.abs(i.lastFlickSpeed[e])<.1&&(i.lastFlickSpeed[e]=0),i.slowDownRatio[e]=.95,i.slowDownRatioReverse[e]=1-i.slowDownRatio[e],i.speedDecelerationRatio[e]=1},calculateOverBoundsAnimOffset:function(t,e){i.backAnimStarted[t]||(pe[t]>ee.min[t]?i.backAnimDestination[t]=ee.min[t]:pe[t]<ee.max[t]&&(i.backAnimDestination[t]=ee.max[t]),i.backAnimDestination[t]!==undefined&&(i.slowDownRatio[t]=.7,i.slowDownRatioReverse[t]=1-i.slowDownRatio[t],i.speedDecelerationRatioAbs[t]<.05&&(i.lastFlickSpeed[t]=0,i.backAnimStarted[t]=!0,je("bounceZoomPan"+t,pe[t],i.backAnimDestination[t],e||300,f.easing.sine.out,function(e){pe[t]=e,Oe()}))))},calculateAnimOffset:function(e){i.backAnimStarted[e]||(i.speedDecelerationRatio[e]=i.speedDecelerationRatio[e]*(i.slowDownRatio[e]+i.slowDownRatioReverse[e]-i.slowDownRatioReverse[e]*i.timeDiff/10),i.speedDecelerationRatioAbs[e]=Math.abs(i.lastFlickSpeed[e]*i.speedDecelerationRatio[e]),i.distanceOffset[e]=i.lastFlickSpeed[e]*i.speedDecelerationRatio[e]*i.timeDiff,pe[e]+=i.distanceOffset[e])},panAnimLoop:function(){Xe.zoomPan&&(Xe.zoomPan.raf=k(i.panAnimLoop),i.now=Se(),i.timeDiff=i.now-i.lastNow,i.lastNow=i.now,i.calculateAnimOffset("x"),i.calculateAnimOffset("y"),Oe(),i.calculateOverBoundsAnimOffset("x"),i.calculateOverBoundsAnimOffset("y"),i.speedDecelerationRatioAbs.x<.05&&i.speedDecelerationRatioAbs.y<.05&&(pe.x=Math.round(pe.x),pe.y=Math.round(pe.y),Oe(),Ke("zoomPan")))}};return i},Rt=function(e){if(e.calculateSwipeSpeed("y"),ee=h.currItem.bounds,e.backAnimDestination={},e.backAnimStarted={},Math.abs(e.lastFlickSpeed.x)<=.05&&Math.abs(e.lastFlickSpeed.y)<=.05)return e.speedDecelerationRatioAbs.x=e.speedDecelerationRatioAbs.y=0,e.calculateOverBoundsAnimOffset("x"),e.calculateOverBoundsAnimOffset("y"),!0;qe("zoomPan"),e.lastNow=Se(),e.panAnimLoop()},Pt=function(e,t){var n,i;ne||(lt=x),"swipe"===e&&(i=tt.x-nt.x,e=t.lastFlickDist.x<10,30<i&&(e||20<t.lastFlickOffset.x)?a=-1:i<-30&&(e||t.lastFlickOffset.x<-20)&&(a=1)),a&&((x+=a)<0?(x=y.loop?Ht()-1:0,o=!0):x>=Ht()&&(x=y.loop?0:Ht()-1,o=!0),o&&!y.loop||(xe+=a,fe-=a,n=!0));var o=ye.x*fe,a=Math.abs(o-ct.x),r=n||o>ct.x==0<t.lastFlickSpeed.x?(r=0<Math.abs(t.lastFlickSpeed.x)?a/Math.abs(t.lastFlickSpeed.x):333,r=Math.min(r,400),Math.max(r,250)):333;return lt===x&&(n=!1),ne=!0,Me("mainScrollAnimStart"),je("mainScroll",ct.x,o,r,f.easing.cubic.out,Pe,function(){$e(),ne=!1,lt=-1,!n&&lt===x||h.updateCurrItem(),Me("mainScrollAnimComplete")}),n&&h.updateCurrItem(!0),n},Zt=function(e){return 1/Q*e*d},Ft=function(){var e=g,t=Ue(),n=He();g<t?e=t:n<g&&(e=n);var i,o=re;return ae&&!Y&&!le&&g<t?h.close():(ae&&(i=function(e){Ae((1-o)*e+o)}),h.zoomTo(e,0,200,f.easing.cubic.out,i)),!0};Ie("Gestures",{publicMethods:{initGestures:function(){var e=function(e,t,n,i,o){D=e+t,T=e+n,M=e+i,S=o?e+o:""};(E=z.pointerEvent)&&z.touch&&(z.touch=!1),E?navigator.msPointerEnabled?e("MSPointer","Down","Move","Up","Cancel"):e("pointer","down","move","up","cancel"):z.touch?(e("touch","start","move","end","cancel"),O=!0):e("mouse","down","move","up"),s=T+" "+M+" "+S,u=D,E&&!O&&(O=1<navigator.maxTouchPoints||1<navigator.msMaxTouchPoints),h.likelyTouchDevice=O,c[D]=St,c[T]=At,c[M]=Ot,S&&(c[S]=c[M]),z.touch&&(u+=" mousedown",s+=" mousemove mouseup",c.mousedown=c[D],c.mousemove=c[T],c.mouseup=c[M]),O||(y.allowPanToNext=!1)}}});var Lt,zt,_t,Nt,Ut,Ht,Yt=function(r,e,l,t){var s;Lt&&clearTimeout(Lt),_t=Nt=!0,r.initialLayout?(s=r.initialLayout,r.initialLayout=null):s=y.getThumbBoundsFn&&y.getThumbBoundsFn(x);var u=l?y.hideAnimationDuration:y.showAnimationDuration,c=function(){Ke("initialZoom"),l?(h.template.removeAttribute("style"),h.bg.removeAttribute("style")):(Ae(1),e&&(e.style.display="block"),f.addClass(m,"pswp--animated-in"),Me("initialZoom"+(l?"OutEnd":"InEnd"))),t&&t(),Nt=!1};if(!u||!s||s.x===undefined)return Me("initialZoom"+(l?"Out":"In")),g=r.initialZoomLevel,Fe(pe,r.initialPosition),Oe(),m.style.opacity=l?0:1,Ae(1),void(u?setTimeout(function(){c()},u):c());var d,p;d=o,p=!h.currItem.src||h.currItem.loadError||y.showHideOpacity,r.miniImg&&(r.miniImg.style.webkitBackfaceVisibility="hidden"),l||(g=s.w/r.w,pe.x=s.x,pe.y=s.y-Z,h[p?"template":"bg"].style.opacity=.001,Oe()),qe("initialZoom"),l&&!d&&f.removeClass(m,"pswp--animated-in"),p&&(l?f[(d?"remove":"add")+"Class"](m,"pswp--animate_opacity"):setTimeout(function(){f.addClass(m,"pswp--animate_opacity")},30)),Lt=setTimeout(function(){var t,n,i,o,a,e;Me("initialZoom"+(l?"Out":"In")),l?(t=s.w/r.w,n=pe.x,i=pe.y,o=g,a=re,e=function(e){1===e?(g=t,pe.x=s.x,pe.y=s.y-L):(g=(t-o)*e+o,pe.x=(s.x-n)*e+n,pe.y=(s.y-L-i)*e+i),Oe(),p?m.style.opacity=1-e:Ae(a-e*a)},d?je("initialZoom",0,1,u,f.easing.cubic.out,e,c):(e(1),Lt=setTimeout(c,u+20))):(g=r.initialZoomLevel,Fe(pe,r.initialPosition),Oe(),Ae(1),p?m.style.opacity=1:Ae(1),Lt=setTimeout(c,u+20))},l?25:90)},Wt={},Bt=[],Gt={index:0,errorMsg:'<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return zt.length}},Xt=function(){return{center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}}},Vt=function(e,t,n){if(!e.src||e.loadError)return e.w=e.h=0,e.initialZoomLevel=e.fitRatio=1,e.bounds=Xt(),e.initialPosition=e.bounds.center,e.bounds;var i,o,a,r=!n;return r&&(e.vGap||(e.vGap={top:0,bottom:0}),Me("parseVerticalMargin",e)),Wt.x=t.x,Wt.y=t.y-e.vGap.top-e.vGap.bottom,r&&(i=Wt.x/e.w,o=Wt.y/e.h,e.fitRatio=i<o?i:o,"orig"===(a=y.scaleMode)?n=1:"fit"===a&&(n=e.fitRatio),1<n&&(n=1),e.initialZoomLevel=n,e.bounds||(e.bounds=Xt())),n?(i=(t=e).w*n,o=e.h*n,(a=t.bounds).center.x=Math.round((Wt.x-i)/2),a.center.y=Math.round((Wt.y-o)/2)+t.vGap.top,a.max.x=i>Wt.x?Math.round(Wt.x-i):a.center.x,a.max.y=o>Wt.y?Math.round(Wt.y-o)+t.vGap.top:a.center.y,a.min.x=i>Wt.x?0:a.center.x,a.min.y=o>Wt.y?t.vGap.top:a.center.y,r&&n===e.initialZoomLevel&&(e.initialPosition=e.bounds.center),e.bounds):void 0},Kt=function(e,t,n,i,o,a){t.loadError||i&&(t.imageAppended=!0,jt(t,i,t===h.currItem&&be),n.appendChild(i),a&&setTimeout(function(){t&&t.loaded&&t.placeholder&&(t.placeholder.style.display="none",t.placeholder=null)},500))},qt=function(e){e.loading=!0,e.loaded=!1;var t=e.img=f.createEl("pswp__img","img"),n=function(){e.loading=!1,e.loaded=!0,e.loadComplete?e.loadComplete(e):e.img=null,t.onload=t.onerror=null,t=null};return t.onload=n,t.onerror=function(){e.loadError=!0,n()},t.src=e.src,t.alt=e.alt||"",t},$t=function(e,t){if(e.src&&e.loadError&&e.container)return t&&(e.container.innerHTML=""),e.container.innerHTML=y.errorMsg.replace("%url%",e.src),!0},jt=function(e,t,n){var i;e.src&&(t=t||e.container.lastChild,i=n?e.w:Math.round(e.w*e.fitRatio),n=n?e.h:Math.round(e.h*e.fitRatio),e.placeholder&&!e.loaded&&(e.placeholder.style.width=i+"px",e.placeholder.style.height=n+"px"),t.style.width=i+"px",t.style.height=n+"px")},Jt=function(){if(Bt.length){for(var e,t=0;t<Bt.length;t++)(e=Bt[t]).holder.index===e.index&&Kt(e.index,e.item,e.baseDiv,e.img,0,e.clearPlaceholder);Bt=[]}};Ie("Controller",{publicMethods:{lazyLoadItem:function(e){e=Ce(e);var t=Ut(e);t&&(!t.loaded&&!t.loading||b)&&(Me("gettingData",e,t),t.src&&qt(t))},initController:function(){f.extend(y,Gt,!0),h.items=zt=e,Ut=h.getItemAt,Ht=y.getNumItemsFn,y.loop,Ht()<3&&(y.loop=!1),Te("beforeChange",function(e){for(var t=y.preload,n=null===e||0<=e,i=Math.min(t[0],Ht()),o=Math.min(t[1],Ht()),a=1;a<=(n?o:i);a++)h.lazyLoadItem(x+a);for(a=1;a<=(n?i:o);a++)h.lazyLoadItem(x-a)}),Te("initialLayout",function(){h.currItem.initialLayout=y.getThumbBoundsFn&&y.getThumbBoundsFn(x)}),Te("mainScrollAnimComplete",Jt),Te("initialZoomInEnd",Jt),Te("destroy",function(){for(var e,t=0;t<zt.length;t++)(e=zt[t]).container&&(e.container=null),e.placeholder&&(e.placeholder=null),e.img&&(e.img=null),e.preloader&&(e.preloader=null),e.loadError&&(e.loaded=e.loadError=!1);Bt=null})},getItemAt:function(e){return 0<=e&&(zt[e]!==undefined&&zt[e])},allowProgressiveImg:function(){return y.forceProgressiveLoading||!O||y.mouseUsed||1200<screen.width},setContent:function(t,n){y.loop&&(n=Ce(n));var e=h.getItemAt(t.index);e&&(e.container=null);var i,o,a=h.getItemAt(n);a?(Me("gettingData",n,a),t.index=n,o=(t.item=a).container=f.createEl("pswp__zoom-wrap"),!a.src&&a.html&&(a.html.tagName?o.appendChild(a.html):o.innerHTML=a.html),$t(a),Vt(a,me),!a.src||a.loadError||a.loaded?a.src&&!a.loadError&&((i=f.createEl("pswp__img","img")).style.opacity=1,i.src=a.src,jt(a,i),Kt(0,a,o,i)):(a.loadComplete=function(e){if(r){if(t&&t.index===n){if($t(e,!0))return e.loadComplete=e.img=null,Vt(e,me),ke(e),void(t.index===x&&h.updateCurrZoomItem());e.imageAppended?!Nt&&e.placeholder&&(e.placeholder.style.display="none",e.placeholder=null):z.transform&&(ne||Nt)?Bt.push({item:e,baseDiv:o,img:e.img,index:n,holder:t,clearPlaceholder:!0}):Kt(0,e,o,e.img,0,!0)}e.loadComplete=null,e.img=null,Me("imageLoadComplete",n,e)}},f.features.transform&&(e="pswp__img pswp__img--placeholder",e+=a.msrc?"":" pswp__img--placeholder--blank",e=f.createEl(e,a.msrc?"img":""),a.msrc&&(e.src=a.msrc),jt(a,e),o.appendChild(e),a.placeholder=e),a.loading||qt(a),h.allowProgressiveImg()&&(!_t&&z.transform?Bt.push({item:a,baseDiv:o,img:a.img,index:n,holder:t}):Kt(0,a,o,a.img,0,!0))),_t||n!==x?ke(a):(te=o.style,Yt(a,i||a.img)),t.el.innerHTML="",t.el.appendChild(o)):t.el.innerHTML=""},cleanSlide:function(e){e.img&&(e.img.onload=e.img.onerror=null),e.loaded=e.loading=e.img=e.imageAppended=!1}}});var Qt,en,tn={},nn=function(e,t,n){var i=document.createEvent("CustomEvent"),n={origEvent:e,target:e.target,releasePoint:t,pointerType:n||"touch"};i.initCustomEvent("pswpTap",!0,!0,n),e.target.dispatchEvent(i)};Ie("Tap",{publicMethods:{initTap:function(){Te("firstTouchStart",h.onTapStart),Te("touchRelease",h.onTapRelease),Te("destroy",function(){tn={},Qt=null})},onTapStart:function(e){1<e.length&&(clearTimeout(Qt),Qt=null)},onTapRelease:function(e,t){var n,i,o;t&&(K||X||Ve||(n=t,Qt&&(clearTimeout(Qt),Qt=null,i=n,o=tn,Math.abs(i.x-o.x)<25&&Math.abs(i.y-o.y)<25)?Me("doubleTap",n):"mouse"!==t.type?"BUTTON"===e.target.tagName.toUpperCase()||f.hasClass(e.target,"pswp__single-tap")?nn(e,t):(Fe(tn,n),Qt=setTimeout(function(){nn(e,t),Qt=null},300)):nn(e,t,"mouse")))}}}),Ie("DesktopZoom",{publicMethods:{initDesktopZoom:function(){F||(O?Te("mouseUsed",function(){h.setupDesktopZoom()}):h.setupDesktopZoom(!0))},setupDesktopZoom:function(e){en={};var t="wheel mousewheel DOMMouseScroll";Te("bindEvents",function(){f.bind(m,t,h.handleMouseWheel)}),Te("unbindEvents",function(){en&&f.unbind(m,t,h.handleMouseWheel)}),h.mouseZoomedIn=!1;var n,i=function(){h.mouseZoomedIn&&(f.removeClass(m,"pswp--zoomed-in"),h.mouseZoomedIn=!1),g<1?f.addClass(m,"pswp--zoom-allowed"):f.removeClass(m,"pswp--zoom-allowed"),o()},o=function(){n&&(f.removeClass(m,"pswp--dragging"),n=!1)};Te("resize",i),Te("afterChange",i),Te("pointerDown",function(){h.mouseZoomedIn&&(n=!0,f.addClass(m,"pswp--dragging"))}),Te("pointerUp",o),e||i()},handleMouseWheel:function(e){if(g<=h.currItem.fitRatio)return y.modal&&(!y.closeOnScroll||Ve||G?e.preventDefault():A&&2<Math.abs(e.deltaY)&&(o=!0,h.close())),!0;if(e.stopPropagation(),en.x=0,"deltaX"in e)1===e.deltaMode?(en.x=18*e.deltaX,en.y=18*e.deltaY):(en.x=e.deltaX,en.y=e.deltaY);else if("wheelDelta"in e)e.wheelDeltaX&&(en.x=-.16*e.wheelDeltaX),e.wheelDeltaY?en.y=-.16*e.wheelDeltaY:en.y=-.16*e.wheelDelta;else{if(!("detail"in e))return;en.y=e.detail}Ne(g,!0);var t=pe.x-en.x,n=pe.y-en.y;(y.modal||t<=ee.min.x&&t>=ee.max.x&&n<=ee.min.y&&n>=ee.max.y)&&e.preventDefault(),h.panTo(t,n)},toggleDesktopZoom:function(e){e=e||{x:me.x/2+he.x,y:me.y/2+he.y};var t=y.getDoubleTapZoom(!0,h.currItem),n=g===t;h.mouseZoomedIn=!n,h.zoomTo(n?h.currItem.initialZoomLevel:t,e,333),f[(n?"remove":"add")+"Class"](m,"pswp--zoomed-in")}}});var on,an,rn,ln,sn,un,cn,dn,pn,mn,fn,hn,yn={history:!0,galleryUID:1},xn=function(){return fn.hash.substring(1)},gn=function(){on&&clearTimeout(on),rn&&clearTimeout(rn)},vn=function(){var e=xn(),t={};if(e.length<5)return t;var n,i=e.split("&");for(a=0;a<i.length;a++){i[a]&&((n=i[a].split("=")).length<2||(t[n[0]]=n[1]))}if(y.galleryPIDs){for(var o=t.pid,a=t.pid=0;a<zt.length;a++)if(zt[a].pid===o){t.pid=a;break}}else t.pid=parseInt(t.pid,10)-1;return t.pid<0&&(t.pid=0),t},wn=function(){var e,t;rn&&clearTimeout(rn),Ve||G?rn=setTimeout(wn,500):(ln?clearTimeout(an):ln=!0,t=x+1,(e=Ut(x)).hasOwnProperty("pid")&&(t=e.pid),e=cn+"&gid="+y.galleryUID+"&pid="+t,dn||-1===fn.hash.indexOf(e)&&(mn=!0),t=fn.href.split("#")[0]+"#"+e,hn?"#"+e!==window.location.hash&&history[dn?"replaceState":"pushState"]("",document.title,t):dn?fn.replace(t):fn.hash=e,dn=!0,an=setTimeout(function(){ln=!1},60))};Ie("History",{publicMethods:{initHistory:function(){var e,t;f.extend(y,yn,!0),y.history&&(fn=window.location,dn=pn=mn=!1,cn=xn(),hn="pushState"in history,-1<cn.indexOf("gid=")&&(cn=(cn=cn.split("&gid=")[0]).split("?gid=")[0]),Te("afterChange",h.updateURL),Te("unbindEvents",function(){f.unbind(window,"hashchange",h.onHashChange)}),e=function(){un=!0,pn||(mn?history.back():cn?fn.hash=cn:hn?history.pushState("",document.title,fn.pathname+fn.search):fn.hash=""),gn()},Te("unbindEvents",function(){o&&e()}),Te("destroy",function(){un||e()}),Te("firstUpdate",function(){x=vn().pid}),-1<(t=cn.indexOf("pid="))&&"&"===(cn=cn.substring(0,t)).slice(-1)&&(cn=cn.slice(0,-1)),setTimeout(function(){r&&f.bind(window,"hashchange",h.onHashChange)},40))},onHashChange:function(){if(xn()===cn)return pn=!0,void h.close();ln||(sn=!0,h.goTo(vn().pid),sn=!1)},updateURL:function(){gn(),sn||(dn?on=setTimeout(wn,800):wn())}}}),f.extend(h,t)}});
(function($, publicConfig){
'use strict';
let JetReviews={
eventBus: new Vue(),
initedInstance: [],
captchaToken: false,
init: function(){
JetReviews.defineVueComponents();
this.initInstances();
window.addEventListener('jetReviews/editor/templateRenderer/renderSuccess',(event)=> {
this.initBlockInstances();
}, false);
},
initInstances: function(){
let instancesList=$('.jet-reviews-advanced');
if(! instancesList[0]){
return false;
}
instancesList.each(function(){
let $target=$(this),
instanceId=$target.attr('id'),
uniqid=$target.data('uniqid')||false,
options=window['jetReviewsWidget' + uniqid]||false;
if(! options){
let optionsScript=document.getElementById('jetReviewsWidgetOptions' + uniqid);
if(optionsScript){
eval(optionsScript.innerHTML);
options=window['jetReviewsWidget' + uniqid]||false;
}}
if(! $target[0]||! uniqid||! options){
return;
}
window.JetReviews.createJetReviewAdvancedInstance(instanceId, options);
});
},
initBlockInstances: function(){
const targetNode=document.querySelector('.jet-reviews-block-holder');
if(! targetNode) return;
const observer=new MutationObserver(function(mutationsList, observer){
for(const mutation of mutationsList){
if(mutation.type==='childList'){
const event=new Event('jetReviews/editor/block/renderSuccess');
document.dispatchEvent(event);
observer.disconnect();
}}
});
observer.observe(targetNode, { childList: true, subtree: true });
document.addEventListener('jetReviews/editor/block/renderSuccess',(event)=> {
this.initInstances();
});
},
defineVueComponents: function(){
Vue.component('jet-reviews-widget-pagination', {
template: '#jet-reviews-widget-pagination-template',
props: {
current: {
type: Number,
default: 1
},
total: {
type: Number,
default: 0
},
pageSize: {
type: Number,
default: 10
},
prevIcon: {
type: String,
default: '<svg width="7" height="12" viewBox="0 0 7 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.67089 0L-5.96046e-08 6L5.67089 12L7 10.5938L2.65823 6L7 1.40625L5.67089 0Z"/></svg>'
},
nextIcon: {
type: String,
default: '<svg width="7" height="12" viewBox="0 0 7 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.32911 0L7 6L1.32911 12L0 10.5938L4.34177 6L0 1.40625L1.32911 0Z"/></svg>'
},
customCss: {
type: String,
default: ''
},
},
data(){
return {
baseClass: 'jet-reviews-widget-pagination',
currentPage: this.current,
currentPageSize: this.pageSize
};},
watch: {
total(val){
let maxPage=Math.ceil(val / this.currentPageSize);
if(maxPage < this.currentPage){
this.currentPage=(maxPage===0 ? 1:maxPage);
}},
current(val){
this.currentPage=val;
},
pageSize(val){
this.currentPageSize=val;
}},
computed: {
classesList(){
let classesList=[
this.baseClass,
];
if(this.customCss){
classesList.push(this.customCss);
}
return classesList;
},
prevClasses (){
return [
`${this.baseClass}__item`,
`${this.baseClass}__item--prev`,
{
[`${this.baseClass}__item--disabled`]: this.currentPage===1||false
}
];
},
nextClasses (){
return [
`${this.baseClass}__item`,
`${this.baseClass}__item--next`,
{
[`${this.baseClass}__item--disabled`]: this.currentPage===this.allPages||false
}
];
},
firstPageClasses (){
return [
`${this.baseClass}__item`,
{
[`${this.baseClass}__item--active`]: this.currentPage===1
}
];
},
lastPageClasses (){
return [
`${this.baseClass}__item`,
{
[`${this.baseClass}__item--active`]: this.currentPage===this.allPages
}
];
},
allPages (){
const allPage=Math.ceil(this.total / this.currentPageSize);
return(allPage===0) ? 1:allPage;
},
},
methods: {
changePage(page){
if(this.currentPage!==page){
this.currentPage=page;
this.$emit('update:current', page);
this.$emit('on-change', page);
}},
prev (){
const current=this.currentPage;
if(current <=1){
return false;
}
this.changePage(current - 1);
},
next (){
const current=this.currentPage;
if(current >=this.allPages){
return false;
}
this.changePage(current + 1);
},
fastPrev (){
const page=this.currentPage - 5;
if(page > 0){
this.changePage(page);
}else{
this.changePage(1);
}},
fastNext (){
const page=this.currentPage + 5;
if(page > this.allPages){
this.changePage(this.allPages);
}else{
this.changePage(page);
}},
},
});
Vue.component('jet-advanced-reviews-form', {
template: '#jet-advanced-reviews-form-template',
props: {
reviewFields: Array
},
data: function(){
return ( {
reviewSubmiting: false,
reviewTitle: '',
reviewContent: '',
reviewAuthorName: '',
reviewAuthorMail: '',
reviewMedia: [],
reviewMediaPreview: [],
messageText: '',
fields: this.reviewFields,
isValidUpload: true,
trySend: false
});
},
mounted: function(){
let self=this;
Vue.nextTick().then(function (){
let reviewContent=self.$refs.reviewContent,
textarea=reviewContent.$refs.textarea;
textarea.focus();
});
if(this.$root.isUserGuest){
this.reviewAuthorName=JetReviews.getLocalStorageData('guestName', '');
this.reviewAuthorMail=JetReviews.getLocalStorageData('guestMail', '');
}},
computed: {
formControlsVisible: function(){
if(this.$root.isUserGuest){
return this.isValidReviewContent &&
this.isValidReviewTitle &&
this.isValidAuthorName &&
this.isValidAuthorEmail;
}
return this.isValidReviewContent&&this.isValidReviewTitle;
},
formMessageVisible: function(){
return ''!==this.messageText;
},
reviewTitleVisible: function(){
return this.$root.options.reviewTitleInputVisible;
},
reviewContentVisible: function(){
return this.$root.options.reviewContentInputVisible;
},
isValidReviewTitle: function(){
if(! this.trySend){
return true
}
return ''!==this.reviewTitle||! this.reviewTitleVisible;
},
isValidReviewContent: function(){
if(! this.trySend){
return true
}
return ''!==this.reviewContent||! this.reviewContentVisible;
},
isValidAuthorName: function(){
if(! this.trySend){
return true
}
return ''!==this.reviewAuthorName;
},
isValidAuthorEmail: function(){
if(! this.trySend){
return true
}
return(''!==this.reviewAuthorMail&&JetReviews.checkValidEmail(this.reviewAuthorMail) );
},
isValidMedia: function(){
return this.isValidUpload;
}},
methods: {
cancelSubmit: function(){
JetReviews.eventBus.$emit('closeNewReviewForm', { uniqId: this.$root.options.uniqId });
},
submitReview: function(){
this.trySend=true;
if(! this.formControlsVisible){
return false;
}
let self=this,
forSendingData={
source: this.$root.sourceData.source,
source_type: this.$root.sourceData.sourceType,
source_id: this.$root.sourceData.sourceId,
title: this.reviewTitle,
content: this.reviewContent,
author_id: this.$root.userData.id,
author_name: this.reviewAuthorName,
author_mail: this.reviewAuthorMail,
rating_data: this.fields,
media: this.reviewMedia,
},
recaptchaConfig=window.jetReviewPublicConfig.recaptchaConfig;
if(recaptchaConfig.enable){
window.grecaptcha.ready(function(){
grecaptcha.execute(recaptchaConfig.site_key,
{
action: 'submit_review'
}
).then(function(token){
JetReviews.captchaToken=token;
let modifyData=Object.assign({}, forSendingData, {
captcha_token: token
});
self.submitReviewHandle(modifyData);
});
});
return false;
}
this.submitReviewHandle(forSendingData);
},
submitReviewHandle: function(sendData=false){
let self=this;
if(! sendData){
console.warn('Empty new review data for sending');
return false;
}
const formData=new FormData();
formData.append('source', sendData.source);
formData.append('source_type', sendData.source_type);
formData.append('source_id', sendData.source_id) ;
formData.append('title', sendData.title);
formData.append('content', sendData.content);
formData.append('author_id', sendData.author_id);
formData.append('author_name', sendData.author_name);
formData.append('author_mail', sendData.author_mail);
formData.append('rating_data', JSON.stringify(sendData.rating_data||{}) );
formData.append('captcha_token', sendData.captcha_token||'');
for(const file of sendData.media){
formData.append('attached_media[]', file);
}
this.reviewSubmiting=true;
this.messageText='';
wp.apiFetch({
method: 'post',
path: window.jetReviewPublicConfig.submitReviewRoute,
body: formData,
}).then(function(response){
response=self.maybeModifyResponce(response);
let responseSuccess=response.success,
responseData=response.data,
responseMessage=response.message;
self.reviewSubmiting=false;
self.messageText=responseMessage;
if(self.$root.isUserGuest){
let guestReviewedItems=JetReviews.getLocalStorageData(self.$root.guestReviewedStorageName, []);
if(responseSuccess&&! guestReviewedItems.includes(self.$root.sourceData.sourceId) ){
self.$root.userData.name=self.reviewAuthorName;
self.$root.userData.mail=self.reviewAuthorMail;
JetReviews.setLocalStorageData('guestName', self.reviewAuthorName);
JetReviews.setLocalStorageData('guestMail', self.reviewAuthorMail);
guestReviewedItems.push(self.$root.sourceData.sourceId);
JetReviews.setLocalStorageData(self.$root.guestReviewedStorageName, guestReviewedItems);
}}
if(responseSuccess){
if('review-created'===response.code){
JetReviews.eventBus.$emit('addReview', {
uniqId: self.$root.options.uniqId,
reviewData: responseData.item,
});
self.$root.reviewsAverageRating=+responseData.rating;
}
self.$root.formVisible=false;
self.$root.userData.canReview.allowed=false;
self.$root.userData.canReview.message=responseMessage;
}});
},
maybeModifyResponce: function(responce=false){
let code=responce.code;
if('need-approve'===code&&''!==this.$root.options.labels.moderatorCheckMessage){
responce.message=this.$root.options.labels.moderatorCheckMessage;
}
if('already-created'===code&&''!==this.$root.options.labels.alreadyReviewedMessage){
responce.message=this.$root.options.labels.alreadyReviewedMessage;
}
return responce;
},
handleFiles(files){
this.reviewMedia=files;
},
handleUploadStatus(payload){
this.isValidUpload=payload;
},
requiredFieldsCheck(){
return true;
}}
});
Vue.component('slider-input', {
template: '#jet-advanced-reviews-slider-input-template',
props: {
value: {
type: [ String, Number ],
default: ''
},
max: {
type: [ Number ],
default: 5
},
step: {
type: [ Number ],
default: 1
},
label: {
type: [ String, Boolean ],
default: false
},
},
data: function(){
return ( {
});
},
computed: {
valueLabel: function(){
return this.value;
}},
methods: {
handleInput(event){
let value=event.target.value;
this.$emit('input', value);
this.$emit('on-change', event);
},
handleChange(event){
this.$emit('on-input-change', event);
}},
});
Vue.component('stars-input', {
template: '#jet-advanced-reviews-stars-input-template',
props: {
value: {
type: [ String, Number ],
default: ''
},
max: {
type: [ Number ],
default: 5
},
step: {
type: [ Number ],
default: 1
},
label: {
type: [ String, Boolean ],
default: false
},
},
data: function(){
return ( {
currentRating: this.value,
});
},
computed: {
valueLabel: function(){
return `${ this.value }/${ this.max }`;
},
rating: function(){
return(this.currentRating / this.max) * 100;
},
preparedRating: function(){
if(10 > this.rating){
return 10;
}
return this.rating;
},
emptyIcon: function(){
return this.$root.refsHtml.emptyStarIcon||'<i class="far fa-star"></i>';
},
emptyIcons: function(){
let icon=`<div class="jet-reviews-star">${ this.$root.refsHtml.emptyStarIcon }</div>`||'<div class="jet-reviews-star"><i class="far fa-star"></i></div>';
return icon.repeat(this.max);
},
filledIcons: function(){
let icon=`<div class="jet-reviews-star">${ this.$root.refsHtml.filledStarIcon }</div>`||`<div class="jet-reviews-star"><i class="fas fa-star"></i></div>`;
return icon.repeat(this.max);
},
ratingClass: function(){
let ratingClass='very-high-rating';
if(this.rating >=80&&this.rating <=100){
ratingClass='very-high-rating';
}
if(this.rating >=60&&this.rating <=79){
ratingClass='high-rating';
}
if(this.rating >=40&&this.rating <=59){
ratingClass='medium-rating';
}
if(this.rating >=22&&this.rating <=39){
ratingClass='low-rating';
}
if(this.rating >=0&&this.rating <=21){
ratingClass='very-low-rating';
}
return ratingClass;
},
},
methods: {
ratingClick(rating){
this.currentRating=rating;
this.$emit('input', rating);
},
ratingMouseOver(rating){
this.currentRating=rating;
},
ratingMouseOut(){
this.currentRating=this.value;
},
},
});
Vue.component('jet-advanced-reviews-item', {
template: '#jet-advanced-reviews-item-template',
props: {
itemData: Object
},
data: function(){
return ( {
commentFormVisible: false,
commentText: '',
commentAuthorName: '',
commentAuthorMail: '',
commentSubmiting: false,
approvalSubmiting: false,
parentComment: 0,
commentsVisible: false,
responseMessage: '',
detailsVisibleState: false
});
},
mounted: function(){
if(this.$root.isUserGuest){
this.commentAuthorName=JetReviews.getLocalStorageData('guestName', '');
this.commentAuthorMail=JetReviews.getLocalStorageData('guestMail', '');
let guestReviewRatedData=JetReviews.getLocalStorageData(this.$root.guestRatedStorageName, {});
if(guestReviewRatedData.hasOwnProperty(this.itemData.id) ){
this.$set(this.itemData, 'approval', guestReviewRatedData[ this.itemData.id ]);
}}
},
computed: {
isDetailsFieldsAvaliable: function(){
return 1 < this.itemData.rating_data.length;
},
detailsVisible: function(){
return this.isDetailsFieldsAvaliable&&this.detailsVisibleState;
},
averageRatingVisible: function(){
return 'average'===this.$root.options.reviewRatingType;
},
detailsRatingVisible: function(){
return 'details'===this.$root.options.reviewRatingType;
},
authorVerificationData: function(){
return 0!==this.itemData.verifications.length ? this.itemData.verifications:false;
},
isCommentsEmpty: function(){
return 0===this.itemData.comments.length;
},
isCommentsVisible: function(){
return !this.isCommentsEmpty&&this.commentsVisible;
},
itemCommentsCount: function(){
let itemCommentsCount=false;
itemCommentsCount=this.getCommentsCount(this.itemData.comments);
return itemCommentsCount;
},
pinnedVisible: function(){
return this.itemData.pinned;
},
commentControlsVisible: function(){
if(this.$root.isUserGuest){
return this.isCommentValid &&
this.isValidAuthorName &&
this.isValidAuthorEmail;
}
return this.isCommentValid;
},
averageRatingData: function(){
let ratingDatalength=this.itemData.rating_data.length,
summaryValue=0,
avarageValue=0,
summaryMax=0,
avarageMax=0;
summaryValue=this.itemData.rating_data.reduce(function(accumulator, currentValue){
return accumulator + +currentValue.field_value;
}, 0);
summaryMax=this.itemData.rating_data.reduce(function(accumulator, currentValue){
return accumulator + +currentValue.field_max;
}, 0);
avarageValue=Math.round(summaryValue / ratingDatalength);
avarageMax=Math.round(summaryMax / ratingDatalength);
return {
rating: Math.round(avarageValue * 100 / avarageMax, 1),
max: Math.round(avarageMax, 1),
value: Math.round(avarageValue, 1)
};},
addCommentIcon: function(){
return this.$root.refsHtml.newCommentButtonIcon||false;
},
showCommentsIcon: function(){
return this.$root.refsHtml.showCommentsButtonIcon||false;
},
pinnedIcon: function(){
return this.$root.refsHtml.pinnedIcon||'<i class="fas fa-thumbtack"></i>';
},
likeIcon: function(){
let emptyLike=this.$root.refsHtml.reviewEmptyLikeIcon||'<i class="far fa-thumbs-up"></i>',
filledLike=this.$root.refsHtml.reviewFilledLikeIcon||'<i class="fas fa-thumbs-up"></i>';
return ! this.itemData.approval.like ? emptyLike:filledLike;
},
dislikeIcon: function(){
let emptyDislike=this.$root.refsHtml.reviewEmptyDislikeIcon||'<i class="far fa-thumbs-down"></i>',
filledDislike=this.$root.refsHtml.reviewFilledDislikeIcon||'<i class="fas fa-thumbs-down"></i>';
return ! this.itemData.approval.dislike ? emptyDislike:filledDislike;
},
userCanComment: function(){
return this.$root.sourceData.commentsAllowed&&this.$root.userData.canComment.allowed;
},
userCanRate: function(){
return this.$root.sourceData.approvalAllowed&&this.$root.userData.canRate;
},
isValidAuthorName: function(){
return ''!==this.commentAuthorName;
},
isValidAuthorEmail: function(){
return JetReviews.checkValidEmail(this.commentAuthorMail);
},
isCommentValid: function(){
return ''!==this.commentText;
},
mediaList: function(){
if(0===this.itemData.media.length){
return false
}
return this.itemData.media;
}},
methods: {
showCommentForm: function(){
let self=this;
this.commentFormVisible = !this.commentFormVisible;
if(this.commentFormVisible){
Vue.nextTick().then(function (){
let commentContent=self.$refs.commentContent,
textarea=commentContent.$refs.textarea;
textarea.focus();
});
}},
cancelNewComment: function(){
this.commentFormVisible=false;
this.responseMessage='';
},
submitNewComment: function(){
let self=this,
forSendingData={
source: this.$root.sourceData.source,
source_type: this.$root.sourceData.sourceType,
source_id: this.$root.sourceData.sourceId,
parent_id: this.parentComment,
review_id: this.itemData.id,
author_id: this.$root.userData.id,
author_name: this.commentAuthorName,
author_mail: this.commentAuthorMail,
content: this.commentText,
},
recaptchaConfig=window.jetReviewPublicConfig.recaptchaConfig;
if(recaptchaConfig.enable){
window.grecaptcha.ready(function(){
grecaptcha.execute(recaptchaConfig.site_key,
{
action: 'submit_review_comment'
}
).then(function(token){
JetReviews.captchaToken=token;
let modifyData=Object.assign({}, forSendingData, {
captcha_token: token
});
self.submitCommentHandler(modifyData);
});
});
return false;
}
this.submitCommentHandler(forSendingData);
},
submitCommentHandler: function(sendData=false){
let self=this;
if(! sendData){
console.warn('Empty new comment data for sending');
return false;
}
this.commentSubmiting=true;
wp.apiFetch({
method: 'post',
path: window.jetReviewPublicConfig.submitReviewCommentRoute,
data: sendData,
}).then(function(response){
self.commentSubmiting=false;
self.$root.userData.name=self.commentAuthorName;
self.$root.userData.mail=self.commentAuthorMail;
JetReviews.setLocalStorageData('guestName', self.commentAuthorName);
JetReviews.setLocalStorageData('guestMail', self.commentAuthorMail);
if(response.success){
self.commentFormVisible=false;
self.commentText='';
self.itemData.comments.unshift(response.data);
self.commentsVisible=true;
}else{
self.responseMessage=response.message;
console.log(response.message);
}});
},
updateApprovalHandler: function(type){
let self=this,
altType='like'===type ? 'dislike':'like';
this.approvalSubmiting=true;
wp.apiFetch({
method: 'post',
path: window.jetReviewPublicConfig.likeReviewRoute,
data: {
review_id: self.itemData.id,
type: type,
inc: ! self.itemData.approval[ type ],
current_state: self.itemData.approval,
},
}).then(function(response){
self.approvalSubmiting=false;
if(response.success){
self.$set(self.itemData, 'approval', response.data.approval);
self.$set(self.itemData, 'like', response.data.like);
self.$set(self.itemData, 'dislike', response.data.dislike);
if(self.$root.isUserGuest){
self.updateGuestApprovalData(self.itemData.id, self.itemData.approval);
}}else{
console.log(response.message);
}});
},
updateGuestApprovalData: function($reviewId=false, rateData=false){
let guestReviewRateData=JetReviews.getLocalStorageData(this.$root.guestRatedStorageName, {});
guestReviewRateData[ $reviewId ]=rateData;
JetReviews.setLocalStorageData(this.$root.guestRatedStorageName, guestReviewRateData);
},
toggleCommentsVisible: function(){
this.commentsVisible = !this.commentsVisible;
},
getCommentsCount: function(comments, initialValue=0){
let total=comments.reduce(( accumulator, commentData)=> {
if(commentData.hasOwnProperty('children')&&0!==commentData.children.length){
let initialValue=accumulator + 1;
return this.getCommentsCount(commentData.children, initialValue);
}else{
return accumulator + 1;
}}, initialValue);
return total;
}}
});
Vue.component('jet-advanced-reviews-comment', {
template: '#jet-advanced-reviews-comment-template',
props: {
commentData: Object,
parentId: Number,
parentComments: Array,
depth: Number,
},
data: function(){
return ( {
commentsList: this.commentData.children||[],
replySubmiting: false,
replyFormVisible: false,
replyText: '',
replyAuthorName: '',
replyAuthorMail: '',
responseMessage: ''
});
},
mounted: function(){
if(this.$root.isUserGuest){
this.replyAuthorName=JetReviews.getLocalStorageData('guestName', '');
this.replyAuthorMail=JetReviews.getLocalStorageData('guestMail', '');
}},
computed: {
commentClass: function(){
return '';
},
formControlsVisible: function(){
return this.$root.sourceData.commentsAllowed;
},
submitVisible: function(){
if(this.$root.isUserGuest){
return this.isReplyTextValid &&
this.isValidAuthorName &&
this.isValidAuthorEmail;
}
return this.isReplyTextValid;
},
replyIcon: function(){
return this.$root.refsHtml.replyButtonIcon||false;
},
isValidAuthorName: function(){
return ''!==this.replyAuthorName;
},
isValidAuthorEmail: function(){
return JetReviews.checkValidEmail(this.replyAuthorMail);
},
isReplyTextValid: function(){
return ''!==this.replyText;
},
authorVerificationData: function(){
if(! this.commentData.verifications){
return false;
}
return 0!==this.commentData.verifications.length ? this.commentData.verifications:false;
},
},
methods: {
showReplyForm: function(){
let self=this;
this.replyFormVisible = !this.replyFormVisible;
if(this.replyFormVisible){
this.replyText='<b>' + this.commentData.author.name + '</b>,&nbsp;';
Vue.nextTick().then(function (){
let commentText=self.$refs.commentText,
textarea=commentText.$refs.textarea;
JetReviews.placeCaretAtEnd(textarea);
});
}},
cancelNewReply: function(){
this.replyFormVisible=false;
this.responseMessage='';
},
submitNewReply: function(){
let self=this,
forSendingData={
source: this.$root.sourceData.source,
source_type: this.$root.sourceData.sourceType,
source_id: this.$root.sourceData.sourceId,
parent_id: 0===this.depth ? this.commentData.id:this.parentId,
review_id: this.commentData.review_id,
author_id: this.$root.userData.id,
author_name: this.replyAuthorName,
author_mail: this.replyAuthorMail,
content: this.replyText,
},
recaptchaConfig=window.jetReviewPublicConfig.recaptchaConfig;
if(recaptchaConfig.enable){
window.grecaptcha.ready(function(){
grecaptcha.execute(recaptchaConfig.site_key,
{
action: 'submit_comment_reply'
}
).then(function(token){
JetReviews.captchaToken=token;
let modifyData=Object.assign({}, forSendingData, {
captcha_token: token
});
self.submitReplyHandler(modifyData);
});
});
return false;
}
this.submitReplyHandler(forSendingData);
},
submitReplyHandler: function(sendData=false){
let self=this;
if(! sendData){
console.warn('Empty review comment data for sending');
return false;
}
this.replySubmiting=true;
wp.apiFetch({
method: 'post',
path: window.jetReviewPublicConfig.submitReviewCommentRoute,
data: sendData,
}).then(function(response){
self.replySubmiting=false;
self.$root.userData.name=self.replyAuthorName;
self.$root.userData.mail=self.replyAuthorMail;
JetReviews.setLocalStorageData('guestName', self.replyAuthorName);
JetReviews.setLocalStorageData('guestMail', self.replyAuthorMail);
if(response.success){
self.replyFormVisible=false;
self.replyText='';
if(0===self.depth){
self.commentData.children.unshift(response.data);
}else{
self.parentComments.push(response.data);
}}else{
self.responseMessage=response.message;
}});
}}
});
Vue.component('points-field', {
template: '#jet-advanced-reviews-point-field-template',
props: {
before: {
type: [ Number, String, Boolean ],
default: false
},
rating: Number,
after: {
type: [ Number, String, Boolean ],
default: false
},
},
data: function(){
return ( {});
},
computed: {
isBeforeEmpty: function(){
return false===this.before||''===this.before;
},
isAfterEmpty: function(){
return false===this.after||''===this.after;
},
preparedRating: function(){
if(10 > this.rating){
return 10;
}
return this.rating;
},
ratingClass: function(){
let ratingClass='very-high-rating';
if(this.rating >=80&&this.rating <=100){
ratingClass='very-high-rating';
}
if(this.rating >=60&&this.rating <=79){
ratingClass='high-rating';
}
if(this.rating >=40&&this.rating <=59){
ratingClass='medium-rating';
}
if(this.rating >=22&&this.rating <=39){
ratingClass='low-rating';
}
if(this.rating >=0&&this.rating <=21){
ratingClass='very-low-rating';
}
return ratingClass;
}}
});
Vue.component('stars-field', {
template: '#jet-advanced-reviews-star-field-template',
props: {
before: {
type: [ Number, String, Boolean ],
default: false
},
rating: Number,
after: {
type: [ Number, String, Boolean ],
default: false
},
},
data: function(){
return ( {});
},
computed: {
isBeforeEmpty: function(){
return ! this.before||''===this.before;
},
isAfterEmpty: function(){
return ! this.after||''===this.after;
},
preparedRating: function(){
if(10 > this.rating){
return 10;
}
return this.rating;
},
emptyIcons: function(){
let icon=`<div class="jet-reviews-star">${ this.$root.refsHtml.emptyStarIcon }</div>`||'<div class="jet-reviews-star"><i class="far fa-star"></i></div>';
return icon.repeat(5);
},
filledIcons: function(){
let icon=`<div class="jet-reviews-star">${ this.$root.refsHtml.filledStarIcon }</div>`||'<div class="jet-reviews-star"><i class="fas fa-star"></i></div>';
return icon.repeat(5);
},
ratingClass: function(){
let ratingClass='very-high-rating';
if(this.rating >=80&&this.rating <=100){
ratingClass='very-high-rating';
}
if(this.rating >=60&&this.rating <=79){
ratingClass='high-rating';
}
if(this.rating >=40&&this.rating <=59){
ratingClass='medium-rating';
}
if(this.rating >=22&&this.rating <=39){
ratingClass='low-rating';
}
if(this.rating >=0&&this.rating <=21){
ratingClass='very-low-rating';
}
return ratingClass;
}},
});
Vue.component('html-textarea', {
template:'<div :class="classes" ref="textarea" contenteditable="true" tabindex="0" :data-placeholder="placeholder" :data-not-valid-label="notValidLabel" @input="updateHTML" @focus="focusHandler" @blur="blurHandler"></div>',
props: {
value: String,
isValid: {
type: Boolean,
default: true,
},
placeholder: {
type: String,
default: 'Input',
},
notValidLabel: {
type: String,
default: 'This field is required or not valid',
},
},
data: function(){
return ( {
isFocus: false,
isEmpty: true,
});
},
computed: {
classes: function(){
let classes=[
'jet-reviews-content-editable',
!this.isValid ? 'jet-reviews-content-editable--not-valid':false,
this.isFocus ? 'jet-reviews-content-editable--focus':false,
this.isPlaceholder ? 'jet-reviews-content-editable--placeholder':false,
];
return classes;
},
isPlaceholder: function(){
if(this.isFocus||! this.isEmpty){
return false;
}
return true;
}},
mounted: function (){
this.$el.innerHTML=this.value;
},
methods: {
updateHTML: function(e){
const html=e.target.innerHTML.trim();
if(html==='<br>'||html===''){
this.isEmpty=true;
this.$emit('input', '');
}else{
this.isEmpty=false;
this.$emit('input', html);
}},
focusHandler: function(e){
this.$emit('focus', e.target);
this.isFocus=true;
},
blurHandler: function(e){
this.$emit('blur', e.target);
this.isFocus=false;
}}
});
Vue.component('file-input', {
template: '#jet-reviews-widget-file-input-template',
props: {
allowedTypes: {
type: [ Array ],
default(){
return [ 'image/jpeg', 'image/png', 'image/gif' ];
}},
maxFileSize: {
type: [ Number ],
default: 5
},
uploadIcon: {
type: [ String ],
default: ''
},
uploadControlLabel: {
type: [ String ],
default: 'Upload your file here'
},
buttonLabel: {
type: [ String ],
default: 'Choose File'
},
maxFileSizeLabel: {
type: [ String ],
default: 'Maximum size'
},
},
data: function(){
return ( {
baseClass: 'jet-reviews-widget-file-input',
reviewMedia: [],
reviewMediaPreview: [],
messageText: '',
isDragOver: false,
});
},
computed: {
classesList(){
let classesList=[
this.baseClass,
this.isDragOver ? 'is-dragover':'',
];
return classesList;
},
maxSizeLabel(){
return `${ this.maxFileSizeLabel }: ${ this.maxFileSize }MB`;
},
isMessageVisible: function(){
return ''!==this.messageText;
},
maxSize: function(){
return this.maxFileSize * 1024 * 1024;
},
},
methods: {
triggerFileInput(){
this.$refs.fileInput.click();
},
handleFiles(event){
const files=Array.from(event.target.files);
this.reviewMedia=[];
this.reviewMediaPreview=[];
this.messageText='';
this.$emit('on-change', event);
this.$emit('on-send-status', true);
files.forEach(file=> {
if(! this.allowedTypes.includes(file.type) ){
this.$emit('on-send-status', false);
this.messageText='Not allowed file type';
return;
}
if(file.size > this.maxSize){
this.$emit('on-send-status', false);
this.messageText='Maximum file size exceeded';
return;
}
this.reviewMedia.push(file);
const reader=new FileReader();
reader.onload=event=> this.reviewMediaPreview.push(event.target.result);
reader.readAsDataURL(file);
});
this.$emit('on-file-change', this.reviewMedia);
},
onDragOver(){
this.isDragOver=true;
},
onDragLeave(){
this.isDragOver=false;
},
onFileDrop(event){
this.isDragOver=false;
const filesList=event?.dataTransfer?.files;
if(! filesList||filesList.length===0) return;
const files=Array.from(filesList);
this.reviewMedia=[];
this.reviewMediaPreview=[];
this.messageText='';
this.$emit('on-send-status', true);
files.forEach(file=> {
if(! this.allowedTypes.includes(file.type) ){
this.$emit('on-send-status', false);
this.messageText='Not allowed file type';
return;
};
if(file.size > this.maxSize){
this.$emit('on-send-status', false);
this.messageText='Maximum file size exceeded';
return;
};
this.reviewMedia.push(file);
const reader=new FileReader();
reader.onload=event=> this.reviewMediaPreview.push(event.target.result);
reader.readAsDataURL(file);
});
this.$emit('on-file-change', this.reviewMedia);
},
},
});
},
createJetReviewAdvancedInstance: function(instanceId, options){
if(JetReviews.initedInstance.includes(instanceId) ){
return;
}
JetReviews.initedInstance.push(instanceId);
let JetReviewAdvancedInstance=new Vue( {
el: '#' + instanceId,
data: {
uniqId: instanceId,
options: options,
reviewsLoaded: false,
getReviewsProcessing: false,
reviewsList: [],
reviewsPage: 1,
reviewsTotal: 0,
reviewsAverageRating: 0,
userData: options.userData,
sourceData: options.sourceData,
reviewTypeFields: options.reviewsFields,
formVisible: false,
isMounted: false,
refsHtml: {},
},
mounted: function(){
let self=this,
refsHtml={};
this.isMounted=true;
for(var ref in this.$refs){
Object.assign(refsHtml, { [ ref ]: this.$refs[ ref ].innerHTML });
}
this.refsHtml=refsHtml;
if(this.isUserGuest){
this.$set(this.userData, 'id', this.guestId);
this.$set(this.userData, 'name', this.guestName);
this.$set(this.userData, 'mail', this.guestMail);
let guestReviewedItems=JetReviews.getLocalStorageData(this.guestReviewedStorageName, []);
if(guestReviewedItems.includes(this.sourceData.sourceId) ){
this.$set(this.userData.canReview, 'allowed', false);
this.$set(this.userData.canReview, 'message', this.options.labels.alreadyReviewedMessage);
}}
if(this.options.reviewsListData){
this.reviewsList=this.options.reviewsListData.list;
this.reviewsTotal=+this.options.reviewsListData.total;
this.reviewsAverageRating=+this.options.reviewsListData.rating;
this.reviewsLoaded=true;
}else{
wp.apiFetch({
method: 'post',
path: window.jetReviewPublicConfig.getPublicReviewsRoute,
data: {
source: self.sourceData.source,
source_id: self.sourceData.sourceId,
page: self.reviewsPage - 1,
page_size: self.options.pageSize
},
}).then(function(response){
self.reviewsLoaded=true;
if(response.success&&response.data){
self.reviewsList=response.data.list;
self.reviewsTotal=+response.data.total;
self.reviewsAverageRating=+response.data.rating;
}else{
console.log('Error');
}});
}
JetReviews.eventBus.$on('addReview', function(payLoad){
if(self.options.uniqId!==payLoad.uniqId){
return;
}
self.formVisible=false;
let reviewData=payLoad.reviewData;
self.reviewsList.unshift(reviewData);
self.reviewsTotal +=1;
});
JetReviews.eventBus.$on('closeNewReviewForm', function(payLoad){
if(self.options.uniqId!==payLoad.uniqId){
return;
}
self.formVisible=false;
});
},
computed: {
instanceClass: function(){
let classes=[
'jet-reviews-advanced__instance',
];
if(this.isMounted){
classes.push('is-mounted');
}
return classes;
},
reviewsLength: function(){
return this.reviewsList.length;
},
reviewsListEmpty: function(){
return 0===this.reviewsList.length ? true:false;
},
preparedFields: function(){
let rawFields=this.reviewTypeFields,
preparedFields=[];
for(let fieldData of rawFields){
preparedFields.push({
field_label: fieldData.label,
field_value: +fieldData.max,
field_step: +fieldData.step,
field_max: +fieldData.max,
});
}
return preparedFields;
},
averageRating: function(){
let totalRating=0;
if(this.reviewsListEmpty){
return 0;
}
totalRating=this.reviewsList.reduce(function(sum, reviewItem){
return +reviewItem.rating + sum;
}, 0);
return Math.round(totalRating / this.reviewsList.length, 1);
},
averageValue: function(){
let summaryValue=0;
if(this.reviewsListEmpty){
return 0;
}
for(let reviewItem of this.reviewsList){
let ratingData=reviewItem.rating_data,
itemSummary=0;
for(let ratingItem of ratingData){
itemSummary +=+ratingItem.field_value
}
summaryValue +=Math.round(itemSummary / ratingData.length, 1)
}
return Math.round(summaryValue / this.reviewsList.length, 1);
},
averageMax: function(){
let totalMax=0,
fields=this.reviewTypeFields;
totalMax=fields.reduce(function(sum, field){
return +field.max + sum;
}, 0);
return Math.round(totalMax / fields.length, 1);
},
addReviewIcon: function(){
return this.refsHtml.newReviewButtonIcon||false;
},
isUserGuest: function(){
return this.userData.roles.includes('guest');
},
guestId: function(){
let guestId=JetReviews.getLocalStorageData('guestId', false);
if(! guestId){
let guestId=`guest_${ JetReviews.getUniqId() }`;
JetReviews.setLocalStorageData('guestId', guestId);
return guestId;
}
return guestId;
},
guestName: function(){
let guestName=JetReviews.getLocalStorageData('guestName', false);
if(! guestName){
JetReviews.setLocalStorageData('guestName', '');
return '';
}
return guestName;
},
guestMail: function(){
let guestMail=JetReviews.getLocalStorageData('guestMail', false);
if(! guestMail){
JetReviews.setLocalStorageData('guestMail', '');
return '';
}
return guestMail;
},
guestReviewedStorageName: function(){
return `reviewed${ JetReviews.capitalizeString(this.sourceData.source) }Items`;
},
guestRatedStorageName: function(){
return `rated${ JetReviews.capitalizeString(this.sourceData.source) }Items`;
},
guestNameFieldVisible: function(){
return this.isUserGuest&&''===this.userData.name;
},
guestMailFieldVisible: function(){
return this.isUserGuest&&''===this.userData.mail;
},
paginationVisible: function(){
return this.reviewsTotal > this.options.pageSize;
},
},
methods: {
formVisibleToggle: function(){
this.formVisible = !this.formVisible;
},
getLabelBySlug: function(slug=false){
if(! slug){
return false;
}
if(! window.jetReviewPublicConfig.labels.hasOwnProperty(slug) ){
return false;
}
return window.jetReviewPublicConfig.labels[ slug ];
},
changePageHandle: function(page){
this.reviewsPage=page;
this.getReviews();
},
getReviews: function(){
let self=this;
self.getReviewsProcessing=true;
wp.apiFetch({
method: 'post',
path: window.jetReviewPublicConfig.getPublicReviewsRoute,
data: {
source: self.sourceData.source,
source_id: self.sourceData.sourceId,
page: self.reviewsPage - 1,
page_size: self.options.pageSize,
},
}).then(function(response){
self.getReviewsProcessing=false;
self.scrollToInstance();
if(response.success&&response.data){
self.reviewsList=response.data.list;
self.reviewsTotal=+response.data.total;
self.reviewsAverageRating=+response.data.rating;
}else{
console.log('Error');
}});
},
scrollToInstance: function(){
let $instance=$(`#${ this.uniqId }`),
offsetTop=$instance.offset().top - 50;
window.scrollTo({
top: offsetTop,
behavior: 'smooth',
});
}}
});
},
getLocalStorageData: function(_key=false, _default=false){
try {
let jetReviewsData=JSON.parse(window.localStorage.getItem('jetReviewsData') );
if(_key){
if(jetReviewsData.hasOwnProperty(_key) ){
return jetReviewsData[ _key ];
}else{
return _default;
}}
return jetReviewsData;
} catch(e){
return _default;
}},
setLocalStorageData: function(key, data){
let jetReviewsData=this.getLocalStorageData()||{};
jetReviewsData[ key ]=data;
window.localStorage.setItem('jetReviewsData', JSON.stringify(jetReviewsData) );
},
getUniqId: function(){
return Math.random().toString(36).substr(2, 9);
},
capitalizeString: function(string=''){
if(typeof string!=='string'){
return ''
}
return string.charAt(0).toUpperCase() + string.slice(1);
},
placeCaretAtEnd: function(el){
el.focus();
if('undefined'!==typeof window.getSelection&&'undefined'!==typeof document.createRange){
let range=document.createRange();
range.selectNodeContents(el);
range.collapse(false);
let selection=window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}else if('undefined'!==typeof document.body.createTextRange){
let textRange=document.body.createTextRange();
textRange.moveToElementText(el);
textRange.collapse(false);
textRange.select();
}},
checkValidEmail: function(email){
var reg=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(email);
},
};
window.JetReviews=JetReviews;
JetReviews.init();
}(jQuery, window.jetReviewPublicConfig) );
(function($, elementorFrontend, publicConfig){
'use strict';
let JetReviewsElementor={
init: function(){
var widgets={
'jet-reviews.default':JetReviewsElementor.widgetJetReviewsSimple,
'jet-reviews-advanced.default':JetReviewsElementor.widgetJetReviewsAdvanced,
};
$.each(widgets, function(widget, callback){
elementorFrontend.hooks.addAction('frontend/element_ready/' + widget, callback);
});
},
widgetJetReviewsSimple: function($scope){
var $target=$scope.find('.jet-review'),
settings=$target.data('settings'),
$form=$('.jet-review__form', $target),
$submitButton=$('.jet-review__form-submit', $target),
$removeButton=$('.jet-review__item-remove', $target),
$message=$('.jet-review__form-message', $target),
$rangeControl=$('.jet-review__form-field.type-range input', $target),
ajaxRequest=null;
$rangeControl.on('input', function(event){
var $this=$(this),
$parent=$this.closest('.jet-review__form-field'),
$currentValue=$('.current-value', $parent),
value=$this.val();
$currentValue.html(value);
});
$submitButton.on('click.widgetJetReviews', function(){
addReviewHandle();
return false;
});
$removeButton.on('click.widgetJetReviews', function(){
var $this=$(this);
removeReviewHandle($this);
return false;
});
function addReviewHandle(){
var now=new Date(),
reviewTime=now.getTime(),
reviewDate=new Date(reviewTime).toLocaleString(),
sendData={
'post_id': settings['post_id'],
'review_time': reviewTime,
'review_date': reviewDate
},
serializeArray=$form.serializeObject();
sendData=jQuery.extend(sendData, serializeArray);
ajaxRequest=jQuery.ajax({
type: 'POST',
url: window.jetReviewPublicConfig.ajax_url,
data: {
'action': 'jet_reviews_add_meta_review',
'data': sendData
},
beforeSend: function(jqXHR, ajaxSettings){
if(null!==ajaxRequest){
ajaxRequest.abort();
}
$submitButton.addClass('load-state');
},
error: function(jqXHR, ajaxSettings){
},
success: function(data, textStatus, jqXHR){
var responseType=data['type'],
message=data.message||'';
if('error'===responseType){
$submitButton.removeClass('load-state');
$message.addClass('visible-state');
$('span', $message).html(message);
}
if('success'===responseType){
location.reload();
}}
});
};
function removeReviewHandle($removeButton){
var $reviewItem=$removeButton.closest('.jet-review__item'),
reviewUserId=$reviewItem.data('user-id'),
sendData={
'post_id': settings['post_id'],
'user_id': reviewUserId
};
ajaxRequest=jQuery.ajax({
type: 'POST',
url: window.jetReviewPublicConfig.ajax_url,
data: {
'action': 'jet_reviews_remove_review',
'data': sendData
},
beforeSend: function(jqXHR, ajaxSettings){
if(null!==ajaxRequest){
ajaxRequest.abort();
}
$removeButton.addClass('load-state');
},
error: function(jqXHR, ajaxSettings){
},
success: function(data, textStatus, jqXHR){
var successType=data.type,
message=data.message||'';
if('error'==successType){
}
if('success'==successType){
location.reload();
}}
});
};},
widgetJetReviewsAdvanced: function($scope){
let $target=$scope.find('.jet-reviews-advanced'),
instanceId=$target.attr('id'),
uniqid=$target.data('uniqid')||false,
options=window['jetReviewsWidget' + uniqid]||{};
if(! $target[0]||! uniqid){
return;
}
window.JetReviews.createJetReviewAdvancedInstance(instanceId, options);
},
}
$(window).on('elementor/frontend/init', JetReviewsElementor.init);
$.fn.serializeObject=function(){
var self=this,
json={},
push_counters={},
patterns={
"validate": /^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_-]+)\])*$/,
"key":      /[a-zA-Z0-9_-]+|(?=\[\])/g,
"push":     /^$/,
"fixed":    /^\d+$/,
"named":    /^[a-zA-Z0-9_-]+$/
};
this.build=function(base, key, value){
base[key]=value;
return base;
};
this.push_counter=function(key){
if(push_counters[key]===undefined){
push_counters[key]=0;
}
return push_counters[key]++;
};
$.each($(this).serializeArray(), function(){
if(!patterns.validate.test(this.name)){
return;
}
var k,
keys=this.name.match(patterns.key),
merge=this.value,
reverse_key=this.name;
while((k=keys.pop())!==undefined){
reverse_key=reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
if(k.match(patterns.push)){
merge=self.build([], self.push_counter(reverse_key), merge);
}
else if(k.match(patterns.fixed)){
merge=self.build([], k, merge);
}
else if(k.match(patterns.named)){
merge=self.build({}, k, merge);
}}
json=$.extend(true, json, merge);
});
return json;
};}(jQuery, window.elementorFrontend, window.jetReviewPublicConfig) );
(function($, elementor){
'use strict';
var JetTricks={
init: function(){
elementor.hooks.addAction('frontend/element_ready/section', JetTricks.elementorSection);
elementor.hooks.addAction('frontend/element_ready/section', JetTricks.elementorColumn);
elementor.hooks.addAction('frontend/element_ready/container', JetTricks.elementorSection);
elementor.hooks.addAction('frontend/element_ready/container', JetTricks.elementorColumn);
elementor.hooks.addAction('frontend/element_ready/column', JetTricks.elementorColumn);
elementor.hooks.addAction('frontend/element_ready/widget', JetTricks.elementorWidget);
var widgets={
'jet-view-more.default':JetTricks.widgetViewMore,
'jet-unfold.default':JetTricks.widgetUnfold,
'jet-hotspots.default':JetTricks.widgetHotspots
};
$.each(widgets, function(widget, callback){
elementor.hooks.addAction('frontend/element_ready/' + widget, callback);
});
window.elementorFrontend.elements.$window.on('elementor/nested-tabs/activate',
(event, content)=> {
const $content=$(content);
var $button=$content.find('.jet-unfold__button');
$button.off('click.jetUnfold');
JetTricks.initWidgetsHandlers($content);
JetTricks.elementorSection($content);
}
);
var loopCarouselTypes=[
'loop-carousel.post',
'loop-carousel.product',
'loop-carousel.post_taxonomy',
'loop-carousel.product_taxonomy'
];
loopCarouselTypes.forEach(function(carouselType){
elementorFrontend.hooks.addAction('frontend/element_ready/' + carouselType, function($scope, $){
$(window).on('load', function(){
var loopCarousel=$scope.find('.swiper'),
swiperInstance=loopCarousel.data('swiper'),
$button=$scope.find('.jet-unfold__button');
if(swiperInstance&&$button){
$button.off('click.jetUnfold');
JetTricks.initLoopCarouselHandlers($scope);
swiperInstance.on('slideChange', function(){
$button.off('click.jetUnfold');
JetTricks.initLoopCarouselHandlers($scope);
});
}});
});
});
},
initLoopCarouselHandlers: function($selector){
$selector.find('.elementor-widget-jet-unfold').each(function(){
var $this=$(this),
elementType=$this.data('element_type');
if(!elementType){
return;
}
if('widget'===elementType){
elementType=$this.data('widget_type');
window.elementorFrontend.hooks.doAction('frontend/element_ready/widget', $this, $);
}
window.elementorFrontend.hooks.doAction('frontend/element_ready/global', $this, $);
window.elementorFrontend.hooks.doAction('frontend/element_ready/' + elementType, $this, $);
});
},
initWidgetsHandlers: function($selector){
$selector.find('[data-element_type]').each(function(){
var excludeWidgets=[
'jet-woo-product-gallery-slider.default',
'accordion.default',
'jet-form-builder-form.default',
'nav-menu.default'
];
var $this=$(this),
elementType=$this.data('element_type');
if(!elementType){
return;
}
if('widget'===elementType){
elementType=$this.data('widget_type');
if(excludeWidgets.includes(elementType) ){
return;
}
window.elementorFrontend.hooks.doAction('frontend/element_ready/widget', $this, $);
}
window.elementorFrontend.hooks.doAction('frontend/element_ready/global', $this, $);
window.elementorFrontend.hooks.doAction('frontend/element_ready/' + elementType, $this, $);
});
},
elementorSection: function($scope){
var $target=$scope,
sectionId=$scope.data('id'),
editMode=Boolean(elementor.isEditMode()),
jetListing=$target.parents('.elementor-widget-jet-listing-grid').data('id'),
settings={};
if(window.JetTricksSettings&&window.JetTricksSettings.elements_data.sections.hasOwnProperty(sectionId) ){
settings=window.JetTricksSettings.elements_data.sections[ sectionId ];
}
if(editMode){
settings=JetTricks.sectionEditorSettings($scope);
}
if(! settings){
return false;
}
if(jQuery.isEmptyObject(settings) ){
return false;
}
if('false'===settings.particles||''===settings.particles_json){
return false;
}
if(jetListing&&$target.parent().data('elementor-type')==='jet-listing-items'){
sectionId +=jetListing + $target.parents('.jet-listing-grid__item').data('post-id');
}
var particlesId='jet-tricks-particles-instance-' + sectionId,
particlesJson=JSON.parse(settings.particles_json);
$scope.prepend('<div id="' + particlesId + '" class="jet-tricks-particles-section__instance"></div>');
if(typeof tsParticles!=='undefined'&&tsParticles.load&&tsParticles.version&&tsParticles.version.startsWith('3.')){
tsParticles.load({
id: particlesId,
options: particlesJson
});
}else if(typeof tsParticles!=='undefined'&&tsParticles.load){
tsParticles.load(particlesId, particlesJson);
}},
elementorColumn: function($scope){
var $target=$scope,
$parentSection=$scope.closest('.elementor-section'),
isLegacyModeActive = !!$target.find('> .elementor-column-wrap').length,
$window=$(window),
columnId=$target.data('id'),
editMode=Boolean(elementor.isEditMode()),
settings={},
stickyInstance=null,
stickyInstanceOptions={
topSpacing: 50,
bottomSpacing: 50,
containerSelector: isLegacyModeActive ? '.elementor-row':'.elementor-container, .e-con-inner',
innerWrapperSelector: isLegacyModeActive ? '.elementor-column-wrap':'.elementor-widget-wrap',
},
$observerTarget=$target.find('.elementor-element');
if(! editMode){
settings=$target.data('jet-settings');
if($target.hasClass('jet-sticky-column') ){
if(-1!==settings['stickyOn'].indexOf(elementorFrontend.getCurrentDeviceMode()) ){
$target.each(function(){
var $this=$(this),
elementType=$this.data('element_type');
if(settings['behavior']==='fixed'){
initFixedSticky($this, settings);
}else if(elementType!=='container'&&elementType!=='section'){
initSidebarSticky($this, settings, stickyInstanceOptions);
}else if(settings['behavior']==='scroll_until_end'){
initScrollUntilEndSticky($this, settings);
}else{
initDefaultSticky($this, settings);
}});
}}
}
function initFixedSticky($element, settings){
var offsetTop=parseInt(settings['topSpacing'])||0;
var bottomSpacing=parseInt(settings['bottomSpacing'])||0;
var $window=$(window);
var elementId=$element.data('id');
var originalOffsetTop=$element.offset().top;
var originalHeight=$element.outerHeight();
var $allStickyElements=$('.jet-sticky-column').filter(function(){
var $this=$(this);
var elementSettings=$this.data('jet-settings');
return elementSettings&&elementSettings.stickyOn.indexOf(elementorFrontend.getCurrentDeviceMode())!==-1;
});
var currentIndex=$allStickyElements.index($element);
var $nextSticky=currentIndex + 1 < $allStickyElements.length ? $allStickyElements.eq(currentIndex + 1):null;
var $stopper=null;
if($nextSticky){
$stopper=$nextSticky.closest('.elementor-top-section, .e-parent');
if(!$stopper.length){
$stopper=$nextSticky;
}}
const $placeholder=$('<div></div>')
.addClass('jet-sticky-placeholder')
.css({
display: 'none',
height: originalHeight,
width: $element.outerWidth(),
visibility: 'hidden'
});
$element.before($placeholder);
function enableSticky(){
$placeholder.show();
$element.addClass('jet-sticky-container--stuck');
var stopperTop=$stopper?.offset()?.top;
var stopPoint=stopperTop ? (stopperTop - $element.outerHeight() - offsetTop - bottomSpacing):null;
var diff=0;
if(stopPoint&&stopPoint < $window.scrollTop()){
diff=(stopPoint - $window.scrollTop());
}
$element.css({
position: 'fixed',
top: diff + 'px',
transform: `translateY(${offsetTop}px)`,
left: $placeholder.offset().left + 'px',
width: $placeholder.outerWidth() + 'px'
});
}
function disableSticky(){
$placeholder.hide();
$element.removeClass('jet-sticky-container--stuck');
$element.css({
position: '',
top: '',
transform: '',
left: '',
width: ''
});
}
function onScroll(){
var scrollTop=$window.scrollTop();
if(scrollTop >=originalOffsetTop){
enableSticky();
}else{
disableSticky();
}}
function onResize(){
originalOffsetTop=$placeholder.offset().top;
originalHeight=$element.outerHeight();
$placeholder.css({
height: originalHeight,
width: $element.outerWidth()
});
onScroll();
}
let ticking=false;
$window.on('scroll.jetStickyHeader-' + elementId, function(){
if(!ticking){
requestAnimationFrame(function(){
onScroll();
ticking=false;
});
ticking=true;
}});
$window.on('resize.jetStickyHeader-' + elementId, JetTricksTools.debounce(100, onResize));
onScroll();
$window.on('resize.jetStickyHeader-' + elementId, JetTricksTools.debounce(100, function(){
if(-1===settings['stickyOn'].indexOf(elementorFrontend.getCurrentDeviceMode())){
cleanupSticky($element, $placeholder, elementId);
}}));
}
function cleanupSticky($element, $placeholder, elementId){
$placeholder.remove();
$element.css({
position: '',
top: '',
transform: '',
left: '',
width: '',
zIndex: '',
transition: '',
willChange: ''
});
$element.removeClass('jet-sticky-container--stuck');
$window.off('scroll.jetStickyHeader-' + elementId);
$window.off('resize.jetStickyHeader-' + elementId);
}
function initSidebarSticky($element, settings, options){
options.topSpacing=settings['topSpacing'];
options.bottomSpacing=settings['bottomSpacing'];
imagesLoaded($parentSection, function(){
$target.data('stickyColumnInit', true);
stickyInstance=new StickySidebar($target[0], options);
});
var targetMutation=$target[0],
config={ attributes: true, childList: true, subtree: true };
var observer=new MutationObserver(function(mutations){
for(var mutation of mutations){
if('attributes'===mutation.type&&mutation.attributeName!=='style'){
$target[0].style.height='auto';
}}
});
observer.observe(targetMutation, config);
$window.on('resize.JetTricksStickyColumn orientationchange.JetTricksStickyColumn',
JetTricksTools.debounce(50, resizeDebounce) );
var observer=new MutationObserver(function(mutations){
if(stickyInstance){
mutations.forEach(function(mutation){
if(mutation.attributeName==='class'){
setTimeout(function(){
stickyInstance.destroy();
stickyInstance=new StickySidebar($target[0], options);
}, 100);
}});
}});
$observerTarget.each(function(){
observer.observe($(this)[0], {
attributes: true
});
});
}
function initScrollUntilEndSticky($element, settings){
const stickyHeight=$element.outerHeight();
const stickyContentBottom=$element.offset().top + stickyHeight;
const stickyViewportOffset=$window.height() - stickyHeight - settings['bottomSpacing'];
$('body').addClass('jet-sticky-container');
$window.on('scroll.jetSticky', function (){
const scrollPosition=$window.scrollTop();
if(scrollPosition + $window.height() >=stickyContentBottom){
$element.css({
position: 'sticky',
top: stickyViewportOffset + 'px',
bottom: 'auto',
left: 'auto',
zIndex: settings['zIndex'],
});
}});
$observerTarget.on('destroy.jetSticky', function (){
$window.off('scroll.jetSticky');
$('body').removeClass('jet-sticky-container');
});
}
function initDefaultSticky($element, settings){
$('body').addClass('jet-sticky-container');
$element.addClass('jet-sticky-container-sticky');
$element.css({
'top': settings['topSpacing'],
'bottom': settings['bottomSpacing']
});
}
function resizeDebounce(){
var currentDeviceMode=elementorFrontend.getCurrentDeviceMode(),
availableDevices=settings['stickyOn']||[],
isInit=$target.data('stickyColumnInit');
if(-1!==availableDevices.indexOf(currentDeviceMode) ){
if(! isInit){
$target.data('stickyColumnInit', true);
stickyInstance=new StickySidebar($target[0], stickyInstanceOptions);
stickyInstance.updateSticky();
}}else{
$target.data('stickyColumnInit', false);
stickyInstance.destroy();
}}
},
elementorWidget: function($scope){
var parallaxInstance=null,
satelliteInstance=null,
tooltipInstance=null;
parallaxInstance=new jetWidgetParallax($scope);
parallaxInstance.init();
satelliteInstance=new jetWidgetSatellite($scope);
satelliteInstance.init();
tooltipInstance=new jetWidgetTooltip($scope);
tooltipInstance.init();
},
getElementorElementSettings: function($scope){
if(window.elementorFrontend&&window.elementorFrontend.isEditMode()&&$scope.hasClass('elementor-element-edit-mode') ){
return JetTricks.getEditorElementSettings($scope);
}
return $scope.data('settings')||{};},
getEditorElementSettings: function($scope){
var modelCID=$scope.data('model-cid'),
elementData;
if(! modelCID){
return {};}
if(! elementor.hasOwnProperty('config') ){
return {};}
if(! elementor.config.hasOwnProperty('elements') ){
return {};}
if(! elementor.config.elements.hasOwnProperty('data') ){
return {};}
elementData=elementor.config.elements.data[ modelCID ];
if(! elementData){
return {};}
return elementData.toJSON();
},
widgetViewMore: function($scope){
var $target=$scope.find('.jet-view-more'),
instance=null,
settings=$target.data('settings');
instance=new jetViewMore($target, settings);
instance.init();
},
widgetUnfold: function($scope){
var $target=$scope.find('.jet-unfold'),
$button=$('.jet-unfold__button', $target),
$mask=$('.jet-unfold__mask', $target),
$content=$('.jet-unfold__content', $target),
$contentInner=$('.jet-unfold__content-inner', $target),
$trigger=$('.jet-unfold__trigger', $target),
$separator=$('.jet-unfold__separator', $target),
settings=$.extend({}, $target.data('settings'), JetTricks.getElementorElementSettings($scope) ),
maskBreakpointsHeights=[],
prevBreakpoint='',
unfoldDuration=settings['unfoldDuration']||settings['unfold_duration'],
foldDuration=settings['foldDuration']||settings['fold_duration'],
unfoldEasing=settings['unfoldEasing']||settings['unfold_easing'],
foldEasing=settings['foldEasing']||settings['fold_easing'],
maskHeightAdv=20,
heightCalc='',
autoHide=settings['autoHide']||false,
autoHideTime=settings['autoHideTime']&&0!=settings['autoHideTime']['size'] ? settings['autoHideTime']['size']:5,
hideOutsideClick=settings['hideOutsideClick']||false,
heightControlType=settings['heightControlType']||'height',
wordCount=settings['wordCount']||20,
autoHideTrigger,
activeBreakpoints=elementor.config.responsive.activeBreakpoints,
initialLoaded=false;
function updateMaskGradientClass(){
if(settings.separatorType==='gradient'){
if($target.hasClass('jet-unfold-state')||$trigger.is(':hidden')){
$mask.removeClass('jet-unfold__mask-gradient');
}else{
$mask.addClass('jet-unfold__mask-gradient');
}}
}
function calculateHeightByWordCount(){
var text=$contentInner.text().trim();
if(!text){
return 0;
}
var words=text.split(/\s+/);
var wordsToShow=Math.min(getDeviceWordCount(), words.length);
var visibleText=words.slice(0, wordsToShow).join(' ');
var $tempElement=$contentInner.clone();
$tempElement
.css({
position: 'absolute',
visibility: 'hidden',
height: 'auto',
overflow: 'visible'
})
.text(visibleText);
$contentInner.after($tempElement);
var height=$tempElement.outerHeight();
$tempElement.remove();
return height;
}
maskBreakpointsHeights['desktop']=[];
maskBreakpointsHeights['widescreen']=[];
maskBreakpointsHeights['desktop']['maskHeight']=(settings['mask_height']&&settings['mask_height']['size']&&''!=settings['mask_height']['size']) ? settings['mask_height']['size']:50;
prevBreakpoint='desktop';
Object.keys(activeBreakpoints).reverse().forEach(function(breakpointName){
if('widescreen'===breakpointName){
maskBreakpointsHeights['widescreen']['maskHeight']=(settings['mask_height_widescreen']&&settings['mask_height_widescreen']['size']&&''!=settings['mask_height_widescreen']['size']) ? settings['mask_height_widescreen']['size']:maskBreakpointsHeights['desktop']['maskHeight'];
}else{
maskBreakpointsHeights[breakpointName]=[];
var breakpointSetting=settings['mask_height_' + breakpointName];
maskBreakpointsHeights[breakpointName]['maskHeight']=(breakpointSetting&&breakpointSetting['size']&&''!=breakpointSetting['size']) ? breakpointSetting['size']:maskBreakpointsHeights[prevBreakpoint]['maskHeight'];
prevBreakpoint=breakpointName;
}});
onLoaded();
if(typeof ResizeObserver!=='undefined'){
new ResizeObserver(function(entries){
if($target.hasClass('jet-unfold-state') ){
$mask.css({
'height': $contentInner.outerHeight()
});
}}).observe($contentInner[0]);
}
if('true'===hideOutsideClick){
$(window).on('mouseup', function(event){
let container=$target;
if(!container.is(event.target)&&0===container.has(event.target).length&&$target.hasClass('jet-unfold-state') ){
$button.trigger('click');
}})
}
$target.one('transitionend webkitTransitionEnd oTransitionEnd', function(){
if(!initialLoaded){
onLoaded();
initialLoaded=true;
}});
function onLoaded(){
initialLoaded=true;
var deviceHeight=getDeviceHeight();
heightCalc=+deviceHeight + maskHeightAdv;
if(heightCalc < $contentInner.height()){
if(! $target.hasClass('jet-unfold-state') ){
$separator.css({
'opacity': '1'
});
}
if(! $target.hasClass('jet-unfold-state') ){
$mask.css({
'height': deviceHeight
});
}else{
$mask.css({
'height': $contentInner.outerHeight()
});
}
$trigger.css('display', 'flex');
updateMaskGradientClass();
}else{
$trigger.hide();
$mask.css({
'height': '100%'
});
$content.css({
'max-height': 'none'
});
$separator.css({
'opacity': '0'
});
updateMaskGradientClass();
}}
$(window).on('resize.jetWidgetUnfold orientationchange.jetWidgetUnfold', JetTricksTools.debounce(50, function(){
initialLoaded=false;
onLoaded();
}) );
$button.keypress(function(e){
if(e.which==13){
$button.click();
return false;
}});
$button.on('click.jetUnfold', function(e){
var $this=$(this),
$buttonText=$('.jet-unfold__button-text', $this),
unfoldText=$this.data('unfold-text'),
foldText=$this.data('fold-text'),
$buttonIcon=$('.jet-unfold__button-icon', $this),
unfoldIcon=$this.data('unfold-icon'),
foldIcon=$this.data('fold-icon'),
contentHeight=$contentInner.outerHeight(),
deviceHeight=getDeviceHeight();
e.preventDefault();
if(! $target.hasClass('jet-unfold-state') ){
$target.addClass('jet-unfold-state');
$separator.css({
'opacity': '0'
});
$buttonIcon.html(foldIcon);
$buttonText.html(foldText);
setTimeout(function(){
contentHeight=$contentInner.outerHeight();
anime( {
targets: $mask[0],
height: contentHeight,
duration: unfoldDuration['size'],
easing: unfoldEasing,
complete: function(anim){
$(document).trigger('jet-engine/listing/recalculate-masonry');
}});
}, 0);
if('true'===autoHide){
autoHideTrigger=setTimeout(function(){
$button.trigger('click');
}, autoHideTime * 1000);
}}else{
clearTimeout(autoHideTrigger);
$target.removeClass('jet-unfold-state');
$separator.css({
'opacity': '1'
});
$buttonIcon.html(unfoldIcon);
$buttonText.html(unfoldText);
anime( {
targets: $mask[0],
height: deviceHeight,
duration: foldDuration['size'],
easing: foldEasing,
complete: function(anim){
if('true'===settings['foldScrolling']){
$('html, body').animate({
scrollTop: $target.offset().top - settings['foldScrollOffset']['size']
}, 'slow');
}
$(document).trigger('jet-engine/listing/recalculate-masonry');
}});
}
updateMaskGradientClass();
});
function getDeviceHeight(){
if(heightControlType==='word_count'){
return calculateHeightByWordCount();
}
let device=elementorFrontend.getCurrentDeviceMode();
let heightSettings;
switch(device){
case 'mobile':
heightSettings=settings.mask_height_mobile;
break;
case 'tablet':
heightSettings=settings.mask_height_tablet;
break;
default:
heightSettings=settings.mask_height;
}
if(! heightSettings||! heightSettings.size||! heightSettings.unit){
heightSettings=settings.mask_height;
}
switch(heightSettings.unit){
case 'vh':
return(window.innerHeight * heightSettings.size) / 100;
case '%':
let parentHeight=$contentInner.parent().height();
return(parentHeight * heightSettings.size) / 100;
default:
return heightSettings.size;
}}
function getDeviceWordCount(){
let device=elementorFrontend.getCurrentDeviceMode();
let value;
switch(device){
case 'mobile':
value=settings.word_count_mobile;
break;
case 'tablet':
value=settings.word_count_tablet;
break;
default:
value=settings.word_count;
}
if(value!==null&&value!==undefined){
return parseInt(value, 10);
}
return 20;
}},
widgetHotspots: function($scope){
var $target=$scope.find('.jet-hotspots'),
$hotspots=$('.jet-hotspots__item', $target),
settings=$target.data('settings'),
editMode=Boolean(elementor.isEditMode()),
itemActiveClass='jet-hotspots__item--active';
$target.imagesLoaded().progress(function(){
$target.addClass('image-loaded');
});
$hotspots.each(function(index){
var $this=$(this),
horizontal=$this.data('horizontal-position'),
vertical=$this.data('vertical-position'),
tooltipWidth=$this.data('tooltip-width')||null,
showOnInit=$this.data('show-on-init'),
itemSelector=$this[0],
options={};
$this.css({
'left': horizontal + '%',
'top': vertical + '%'
});
if(itemSelector._tippy){
itemSelector._tippy.destroy();
}
options={
content: $this.data('tippy-content'),
arrow: settings['tooltipArrow'] ? true:false,
placement: settings['tooltipPlacement'],
trigger: settings['tooltipTrigger'],
appendTo: editMode ? document.body:$target[0],
hideOnClick: 'manual'!==settings['tooltipTrigger'],
maxWidth: 'none',
offset: [0, settings['tooltipDistance']['size']],
allowHTML: true,
interactive: settings['tooltipInteractive'] ? true:false,
onShow(instance){
$(itemSelector).addClass(itemActiveClass);
if(tooltipWidth){
instance.popper.querySelector('.tippy-box').style.width=tooltipWidth;
}},
onHidden(instance){
$(itemSelector).removeClass(itemActiveClass);
}}
if('manual'!=settings['tooltipTrigger']){
options['duration']=[ settings['tooltipShowDuration']['size'], settings['tooltipHideDuration']['size'] ];
options['animation']=settings['tooltipAnimation'];
options['delay']=settings['tooltipDelay'];
}
tippy([ itemSelector ], options);
if('manual'===settings['tooltipTrigger']&&itemSelector._tippy){
itemSelector._tippy.show();
}
if(( showOnInit==='yes'||settings['tooltipShowOnInit'])&&itemSelector._tippy){
itemSelector._tippy.show();
}});
},
columnEditorSettings: function(columnId){
var editorElements=null,
columnData={};
if(! window.elementor.hasOwnProperty('elements') ){
return false;
}
editorElements=window.elementor.elements;
if(! editorElements.models){
return false;
}
$.each(editorElements.models, function(index, obj){
$.each(obj.attributes.elements.models, function(index, obj){
if(columnId==obj.id){
columnData=obj.attributes.settings.attributes;
}});
});
return {
'sticky': columnData['jet_tricks_column_sticky']||false,
'topSpacing': columnData['jet_tricks_top_spacing']||50,
'bottomSpacing': columnData['jet_tricks_bottom_spacing']||50,
'stickyOn': columnData['jet_tricks_column_sticky_on']||[ 'desktop', 'tablet', 'mobile']
}},
sectionEditorSettings: function($scope){
var editorElements=null,
sectionData={};
if(! window.elementor.hasOwnProperty('elements') ){
return false;
}
sectionData=JetTricks.getElementorElementSettings($scope);
return {
'particles': sectionData['section_jet_tricks_particles']||'false',
'particles_json': sectionData['section_jet_tricks_particles_json']||'',
}}
};
$(window).on('elementor/frontend/init', JetTricks.init);
var JetTricksTools={
debounce: function(threshold, callback){
var timeout;
return function debounced($event){
function delayed(){
callback.call(this, $event);
timeout=null;
}
if(timeout){
clearTimeout(timeout);
}
timeout=setTimeout(delayed, threshold);
};},
widgetEditorSettings: function(widgetId){
var editorElements=null,
widgetData={};
if(!window.elementor.hasOwnProperty('elements')||!window.elementor.elements.models){
return false;
}
editorElements=window.elementor.elements;
function findWidgetById(models, widgetId){
let foundData=null;
$.each(models, function(index, obj){
if(obj.id===widgetId){
foundData=obj.attributes.settings.attributes;
return false;
}
if(obj.attributes.elements&&obj.attributes.elements.models){
foundData=findWidgetById(obj.attributes.elements.models, widgetId);
if(foundData){
return false;
}}
});
return foundData;
}
widgetData=findWidgetById(editorElements.models, widgetId)||{};
return {
'speed': widgetData['jet_tricks_widget_parallax_speed']||{ 'size': 50, 'unit': '%'},
'parallax': widgetData['jet_tricks_widget_parallax']||'false',
'invert': widgetData['jet_tricks_widget_parallax_invert']||'false',
'stickyOn': widgetData['jet_tricks_widget_parallax_on']||[ 'desktop', 'tablet', 'mobile'],
'satellite': widgetData['jet_tricks_widget_satellite']||'false',
'satelliteType': widgetData['jet_tricks_widget_satellite_type']||'text',
'satellitePosition': widgetData['jet_tricks_widget_satellite_position']||'top-center',
'satelliteText': widgetData['jet_tricks_widget_satellite_text']||'Lorem Ipsum',
'satelliteIcon': widgetData['selected_jet_tricks_widget_satellite_icon']||'',
'satelliteImage': widgetData['jet_tricks_widget_satellite_image']||'',
'satelliteLink': widgetData['jet_tricks_widget_satellite_link']||'',
'tooltip': widgetData['jet_tricks_widget_tooltip']||'false',
'tooltipDescription': widgetData['jet_tricks_widget_tooltip_description']||'Lorem Ipsum',
'tooltipPlacement': widgetData['jet_tricks_widget_tooltip_placement']||'top',
'tooltipArrow': 'true'===widgetData['jet_tricks_widget_tooltip_arrow'] ? true:false,
'xOffset': widgetData['jet_tricks_widget_tooltip_x_offset']||0,
'yOffset': widgetData['jet_tricks_widget_tooltip_y_offset']||0,
'tooltipAnimation': widgetData['jet_tricks_widget_tooltip_animation']||'shift-toward',
'tooltipTrigger': widgetData['jet_tricks_widget_tooltip_trigger']||'mouseenter',
'customSelector': widgetData['jet_tricks_widget_tooltip_custom_selector']||'',
'zIndex': widgetData['jet_tricks_widget_tooltip_z_index']||'999',
'delay': widgetData['jet_tricks_widget_tooltip_delay']||'0',
'followCursor': widgetData['jet_tricks_widget_tooltip_follow_cursor']||'false'
}}
}
window.jetViewMore=function($selector, settings){
var self=this,
$window=$(window),
$button=$('.jet-view-more__button', $selector),
defaultSettings={
sections: {},
effect: 'move-up',
showall: false
},
settings=$.extend({}, defaultSettings, settings),
sections=settings['sections'],
sectionsData={},
editMode=Boolean(elementor.isEditMode()),
readLess=settings['read_less']||false,
readMoreLabel=settings['read_more_label'],
readLessLabel=settings['read_less_label'],
readMoreIcon=settings['read_more_icon'],
readLessIcon=settings['read_less_icon'],
hideAll=settings['hide_all']||false,
isOpened=false;
self.init=function(){
self.setSectionsData();
if(editMode){
return false;
}
function hideSection($section){
if(settings['hide_effect']&&settings['hide_effect']!=='none'){
$section.addClass('view-more-hiding');
$section.addClass('jet-tricks-' + settings['hide_effect'] + '-hide-effect');
(function($currentSection){
$currentSection.on('animationend', function animationEndHandler(){
$currentSection.off('animationend', animationEndHandler);
$currentSection.removeClass('view-more-hiding');
$currentSection.removeClass('jet-tricks-' + settings['hide_effect'] + '-hide-effect');
$currentSection.css('height', '');
$currentSection.removeClass('view-more-visible');
$currentSection.removeClass('jet-tricks-' + settings['effect'] + '-effect');
});
})($section);
}else{
$section.css('height', '');
$section.removeClass('view-more-visible');
$section.removeClass('jet-tricks-' + settings['effect'] + '-effect');
}}
function showAllSections(){
for(var section in sectionsData){
var $section=sectionsData[ section ]['selector'];
sectionsData[ section ]['visible']=true;
$section.css('height', $section[0].scrollHeight + 'px');
$section.addClass('view-more-visible');
$section.addClass('jet-tricks-' + settings['effect'] + '-effect');
}}
function hideAllSections(){
for(var section in sectionsData){
var $section=sectionsData[ section ]['selector'];
sectionsData[ section ]['visible']=false;
hideSection($section);
}}
function showNextSection(){
for(var section in sectionsData){
var $section=sectionsData[ section ]['selector'];
if(!sectionsData[ section ]['visible']){
sectionsData[ section ]['visible']=true;
$section.css('height', $section[0].scrollHeight + 'px');
$section.addClass('view-more-visible');
$section.addClass('jet-tricks-' + settings['effect'] + '-effect');
break;
}}
}
function hideNextSection(){
var sectionKeys=Object.keys(sectionsData).reverse();
for (var i=0; i < sectionKeys.length; i++){
var sectionKey=sectionKeys[i];
var $section=sectionsData[sectionKey]['selector'];
if(sectionsData[sectionKey]['visible']){
sectionsData[sectionKey]['visible']=false;
hideSection($section);
break;
}}
}
$button.on('click', function(){
if(readLess){
if(!isOpened){
if(!settings.showall){
showNextSection();
var allVisible=true;
for (var section in sectionsData){
if(!sectionsData[section]['visible']){
allVisible=false;
break;
}}
if(allVisible){
$button.find('.jet-view-more__label').text(readLessLabel);
if(readLessIcon&&readLessIcon.value){
$button.find('.jet-view-more__icon').html('<i class="' + readLessIcon.value + '"></i>');
}
$button.addClass('jet-view-more__button--read-less');
isOpened=true;
}}else{
showAllSections();
$button.find('.jet-view-more__label').text(readLessLabel);
if(readLessIcon&&readLessIcon.value){
$button.find('.jet-view-more__icon').html('<i class="' + readLessIcon.value + '"></i>');
}
$button.addClass('jet-view-more__button--read-less');
isOpened=true;
}}else{
if(hideAll){
hideAllSections();
$button.find('.jet-view-more__label').text(readMoreLabel);
if(readMoreIcon&&readMoreIcon.value){
$button.find('.jet-view-more__icon').html('<i class="' + readMoreIcon.value + '"></i>');
}
$button.removeClass('jet-view-more__button--read-less');
isOpened=false;
}else{
hideNextSection();
var allHidden=true;
for (var section in sectionsData){
if(sectionsData[section]['visible']){
allHidden=false;
break;
}}
if(allHidden){
$button.find('.jet-view-more__label').text(readMoreLabel);
if(readMoreIcon&&readMoreIcon.value){
$button.find('.jet-view-more__icon').html('<i class="' + readMoreIcon.value + '"></i>');
}
$button.removeClass('jet-view-more__button--read-less');
isOpened=false;
}}
}}else{
if(!settings.showall){
showNextSection();
}else{
showAllSections();
}
var allVisible=true;
for (var section in sectionsData){
if(!sectionsData[section]['visible']){
allVisible=false;
break;
}}
if(allVisible){
$button.css({ 'display': 'none' });
}}
});
$button.keydown(function(e){
var $which=e.which||e.keyCode;
if($which==13||$which==32){
e.preventDefault();
if(readLess){
$button.trigger('click');
}else{
if(!settings.showall){
showNextSection();
}else{
showAllSections();
}
var allVisible=true;
for (var section in sectionsData){
if(!sectionsData[section]['visible']){
allVisible=false;
break;
}}
if(allVisible){
$button.css({ 'display': 'none' });
}}
}});
};
self.setSectionsData=function(){
for(var section in sections){
var $selector=$('#' + sections[ section ]);
if(! editMode){
$selector.addClass('jet-view-more-section');
}else{
$selector.addClass('jet-view-more-section-edit-mode');
}
sectionsData[ section ]={
'section_id': sections[ section ],
'selector': $selector,
'visible': false,
}}
};};
window.jetWidgetParallax=function($scope){
var self=this,
$target=$scope,
$section=$scope.closest('.elementor-top-section'),
widgetId=$scope.data('id'),
settings={},
editMode=Boolean(elementor.isEditMode()),
$window=$(window),
isSafari     = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/),
platform=navigator.platform,
safariClass=isSafari ? 'is-safari':'',
macClass='MacIntel'==platform ? ' is-mac':'';
self.init=function(){
$scope.addClass(macClass);
if(! editMode){
settings=$scope.data('jet-tricks-settings');
}else{
settings=JetTricksTools.widgetEditorSettings(widgetId);
}
if(! settings){
return false;
}
if('undefined'===typeof settings){
return false;
}
if('false'===settings['parallax']||'undefined'===typeof settings['parallax']){
return false;
}
$window.on('scroll.jetWidgetParallax resize.jetWidgetParallax', self.scrollHandler).trigger('resize.jetWidgetParallax');
};
self.scrollHandler=function(event){
var speed=+settings['speed']['size'] * 0.01,
invert='true'==settings['invert'] ? -1:1,
winHeight=$window.height(),
winScrollTop=$window.scrollTop(),
offsetTop=$scope.offset().top,
thisHeight=$scope.outerHeight(),
sectionHeight=$section.outerHeight(),
positionDelta=winScrollTop - offsetTop +(winHeight / 2),
abs=positionDelta > 0 ? 1:-1,
posY=abs * Math.pow(Math.abs(positionDelta), 0.85),
availableDevices=settings['stickyOn']||[],
currentDeviceMode=elementorFrontend.getCurrentDeviceMode();
posY=invert * Math.ceil(speed * posY);
if(-1!==availableDevices.indexOf(currentDeviceMode) ){
$target.css({
'transform': 'translateY(' + posY + 'px)'
});
}else{
$target.css({
'transform': 'translateY(0)'
});
}};};
window.jetWidgetSatellite=function($scope){
var self=this,
widgetId=$scope.data('id'),
settings={},
editMode=Boolean(elementor.isEditMode());
self.init=function(){
if(! editMode){
settings=$scope.data('jet-tricks-settings');
}else{
settings=JetTricksTools.widgetEditorSettings(widgetId);
}
if(! settings||typeof settings!=='object'){
return false;
}
if('false'===settings['satellite']||'undefined'===typeof settings['satellite']){
return false;
}
$scope.addClass('jet-satellite-widget');
$('.jet-tricks-satellite', $scope).addClass('jet-tricks-satellite--' + settings['satellitePosition']);
if(editMode&&$scope.find('.jet-tricks-satellite').length===0){
var html='';
var pos=settings['satellitePosition']||'top-center';
var link=settings['satelliteLink']||{};
var linkStart='', linkEnd='';
if(link.url){
linkStart='<a class="jet-tricks-satellite__link">';
linkEnd='</a>';
}
if(settings['satelliteType']==='text'&&settings['satelliteText']){
html='<div class="jet-tricks-satellite jet-tricks-satellite--' + pos + '"><div class="jet-tricks-satellite__inner"><div class="jet-tricks-satellite__text">' + linkStart + '<span>' + settings['satelliteText'] + '</span>' + linkEnd + '</div></div></div>';
}else if(settings['satelliteType']==='icon'&&settings['satelliteIcon']&&settings['satelliteIcon'].value){
html='<div class="jet-tricks-satellite jet-tricks-satellite--' + pos + '"><div class="jet-tricks-satellite__inner"><div class="jet-tricks-satellite__icon">' + linkStart + '<div class="jet-tricks-satellite__icon-instance jet-tricks-icon"><i class="' + settings['satelliteIcon'].value + '"></i></div>' + linkEnd + '</div></div></div>';
}else if(settings['satelliteType']==='image'&&settings['satelliteImage']&&settings['satelliteImage'].url){
html='<div class="jet-tricks-satellite jet-tricks-satellite--' + pos + '"><div class="jet-tricks-satellite__inner"><div class="jet-tricks-satellite__image">' + linkStart + '<img class="jet-tricks-satellite__image-instance" src="' + settings['satelliteImage'].url + '" alt="">' + linkEnd + '</div></div></div>';
}
if(html){
$scope.prepend(html);
}}
};};
window.jetWidgetTooltip=function($scope){
var self=this,
widgetId=$scope.data('id'),
widgetSelector=$scope[0],
tooltipSelector=widgetSelector,
settings={},
editMode=Boolean(elementor.isEditMode()),
delay,
tooltipEvent=editMode ? 'click':'mouseenter';
self.init=function(){
if(! editMode){
settings=$scope.data('jet-tricks-settings');
}else{
settings=JetTricksTools.widgetEditorSettings(widgetId);
}
if(widgetSelector._tippy){
widgetSelector._tippy.destroy();
}
if(! settings){
return false;
}
if('undefined'===typeof settings){
return false;
}
if('false'===settings['tooltip']||'undefined'===typeof settings['tooltip']||''===settings['tooltipDescription']){
return false;
}
$scope.addClass('jet-tooltip-widget');
if(settings['customSelector']){
tooltipSelector=$('.' + settings['customSelector'], $scope)[0];
}
if(editMode&&! $('#jet-tricks-tooltip-content-' + widgetId)[0]){
var template=$('<div>', {
id: 'jet-tricks-tooltip-content-' + widgetId,
class: 'jet-tooltip-widget__content'
});
template.html(settings['tooltipDescription']);
$scope.append(template);
}
tippy(
[ tooltipSelector ],
{
content: $scope.find('.jet-tooltip-widget__content')[0].innerHTML,
allowHTML: true,
appendTo: editMode ? document.body:widgetSelector,
arrow: settings['tooltipArrow'] ? true:false,
placement: settings['tooltipPlacement'],
offset: [ settings['xOffset'], settings['yOffset'] ],
animation: settings['tooltipAnimation'],
trigger: settings['tooltipTrigger'],
interactive: settings['followCursor']==='false'||settings['followCursor']==='initial',
zIndex: settings['zIndex'],
maxWidth: 'none',
delay: settings['delay']['size'] ? settings['delay']['size']:0,
followCursor: settings['followCursor']==='false' ? false:(settings['followCursor']==='true' ? true:settings['followCursor']),
onCreate: function (instance){
if(editMode){
var dataId=tooltipSelector.getAttribute('data-id');
if(dataId){
instance.popper.classList.add('tippy-' + dataId);
}}
}}
);
if(editMode&&widgetSelector._tippy){
widgetSelector._tippy.show();
}};};
}(jQuery, window.elementorFrontend) );