• File: ethemeImageComparison.min.js
  • Full Path: /home/havejqku/public_html/wp-admin/e0506b/wp-content/themes/xstore/js/modules/ethemeImageComparison.min.js
  • Date Modified: 09/10/2025 7:28 PM
  • File size: 7.33 KB
  • MIME-type: text/plain
  • Charset: utf-8
class ImageCompare{constructor(t,e={}){this.settings=Object.assign({showLabels:!1,labelOptions:{before:"Before",after:"After",onHover:!1},smoothing:!0,smoothingAmount:100,onHover:!1,verticalMode:!1,startingPoint:50,prefix:"etheme-image-comparison",addOverlay:!1},e),this.safariAgent=-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome"),this.el=t,this.images={},this.wrapper=null,this.control=null,this.arrowContainer=null,this.arrowAnimator=[],this.active=!1,this.arrowCoordinates={circle:[5,3],standard:[8,0]}}mount(){this.safariAgent&&(this.settings.smoothing=!1),this._getImages(),this._shapeContainer(),this._buildControl(),this._events()}_events(){this.el.addEventListener("mousedown",t=>{this._activate(!0),document.body.classList.add(this.settings.prefix+"-body"),this._slideCompare(t)}),this.el.addEventListener("mousemove",t=>this.active&&this._slideCompare(t)),this.el.addEventListener("mouseup",()=>!this.settings.onHover&&this._activate(!1)),document.body.addEventListener("mouseup",()=>{document.body.classList.remove(this.settings.prefix+"-body"),this.settings.onHover||this._activate(!1)}),this.control.addEventListener("touchstart",t=>{this._activate(!0),document.body.classList.add(this.settings.prefix+"-body")}),this.el.addEventListener("touchmove",t=>{this.active&&this._slideCompare(t)}),this.el.addEventListener("touchend",()=>{this._activate(!1),document.body.classList.remove(this.settings.prefix+"-body")}),this.el.addEventListener("mouseenter",()=>{this.settings.onHover&&this._activate(!0)})}_slideCompare(t){var e=this.el.getBoundingClientRect(),s=void 0!==t.touches?t.touches[0].clientX-e.left:t.clientX-e.left,t=void 0!==t.touches?t.touches[0].clientY-e.top:t.clientY-e.top,t=this.settings.verticalMode?t/e.height*100:s/e.width*100;0<=t&&t<=100&&(this.settings.verticalMode?this.control.style.top=`calc(${t}% - (var(--divider-width, 45px) / 2))`:this.control.style.left=`calc(${t}% - (var(--divider-width, 45px) / 2))`,this.settings.verticalMode?this.wrapper.style.height=`calc(${t}%)`:this.wrapper.style.width=`calc(${100-t}%)`)}_activate(t){this.active=t}_shapeContainer(){var t=document.createElement("span"),e=document.createElement("span");t.classList.add(this.settings.prefix+"-label",this.settings.prefix+"-label-before"),e.classList.add(this.settings.prefix+"-label",this.settings.prefix+"-label-after"),this.settings.labelOptions.onHover&&(t.classList.add("on-hover"),e.classList.add("on-hover")),t.innerHTML=this.settings.labelOptions.before||"Before",e.innerHTML=this.settings.labelOptions.after||"After",this.settings.showLabels&&(this.el.prepend(t),this.wrapper.appendChild(e)),this.settings.addOverlay&&((t=document.createElement("div")).classList.add(this.settings.prefix+"-overlay"),this.el.appendChild(t))}_buildControl(){var t=document.createElement("div"),e=document.createElement("div"),s=document.createElement("div"),i=document.createElement("div");s.classList.add(this.settings.prefix+"-theme-wrapper"),i.classList.add(this.settings.prefix+"-arrows-wrapper"),s.appendChild(i);for(var n=0;n<=1;n++){var r=document.createElement("span");let t='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="currentColor">';this.settings.verticalMode?t+=0===n?'<path d="M23.688 16.944l-11.208-10.872c-0.264-0.264-0.696-0.24-0.96 0l-11.256 10.872c-0.12 0.12-0.192 0.288-0.216 0.48 0 0.192 0.072 0.36 0.216 0.504s0.312 0.216 0.48 0.216c0.168 0 0.36-0.072 0.48-0.216l10.776-10.392 10.752 10.368c0.216 0.216 0.576 0.264 0.936 0l0.024-0.024c0.12-0.12 0.192-0.312 0.192-0.48 0.024-0.168-0.072-0.336-0.216-0.456z"></path>':'<path d="M23.784 6.072c-0.264-0.264-0.672-0.264-0.984 0l-10.8 10.416-10.8-10.416c-0.264-0.264-0.672-0.264-0.984 0-0.144 0.12-0.216 0.312-0.216 0.48 0 0.192 0.072 0.36 0.192 0.504l11.28 10.896c0.096 0.096 0.24 0.192 0.48 0.192 0.144 0 0.288-0.048 0.432-0.144l0.024-0.024 11.304-10.92c0.144-0.12 0.24-0.312 0.24-0.504 0.024-0.168-0.048-0.36-0.168-0.48z"></path>':t+=0===n?'<path d="M17.976 22.8l-10.44-10.8 10.464-10.848c0.24-0.288 0.24-0.72-0.024-0.96-0.24-0.24-0.72-0.264-0.984 0l-10.92 11.328c-0.264 0.264-0.264 0.672 0 0.984l10.92 11.28c0.144 0.144 0.312 0.216 0.504 0.216 0.168 0 0.336-0.072 0.456-0.192 0.144-0.12 0.216-0.288 0.24-0.48 0-0.216-0.072-0.384-0.216-0.528z"></path>':'<path d="M17.88 11.496l-10.728-11.304c-0.264-0.264-0.672-0.264-0.96-0.024-0.144 0.12-0.216 0.312-0.216 0.504 0 0.168 0.072 0.336 0.192 0.48l10.272 10.8-10.272 10.8c-0.12 0.12-0.192 0.312-0.192 0.504s0.072 0.36 0.192 0.504c0.12 0.144 0.312 0.216 0.48 0.216 0.144 0 0.312-0.048 0.456-0.192l0.024-0.024 10.752-11.328c0.264-0.264 0.24-0.672 0-0.936z"></path>',t+="</svg>",r.innerHTML+=t,this.arrowAnimator.push(r),i.appendChild(r)}t.classList.add(this.settings.prefix+"-control"),t.style.cssText=`
    ${this.settings.verticalMode?"height":"width "}: var(--divider-width, 45px);
    ${this.settings.verticalMode?"top":"left "}: calc(${this.settings.startingPoint}% - (var(--divider-width, 45px) / 2));
    ${!("ontouchstart"in document.documentElement)&&this.settings.smoothing?`transition: ${this.settings.smoothingAmount}ms ease-out;`:""}
    `,e.classList.add(this.settings.prefix+"-control-line"),e.style.cssText=`
      ${this.settings.verticalMode?"height":"width "}: var(--divider-line-width, 2px);
      background: var(--divider-bg-color, #2962FF);
    `;var o=e.cloneNode(!0);t.appendChild(e),t.appendChild(s),t.appendChild(o),this.arrowContainer=s,this.control=t,this.el.appendChild(t)}_getImages(){var t=this.el.querySelectorAll("img, ."+this.settings.prefix+"-label"),e=(this.el.innerHTML="",t.forEach(t=>{this.el.appendChild(t)}),[...t].filter(t=>"img"===t.nodeName.toLowerCase()));this.settings.verticalMode&&e.reverse();for(let t=0;t<=1;t++){var s,i=e[t];i.classList.add(this.settings.prefix+"-img"),i.classList.add(0===t?this.settings.prefix+"-img-a":this.settings.prefix+"-img-b"),1===t&&((s=document.createElement("div")).classList.add(this.settings.prefix+"-wrapper"),s.style.cssText=`
            width: ${100-this.settings.startingPoint}%; 
            height: ${this.settings.startingPoint}%;

            ${!("ontouchstart"in document.documentElement)&&this.settings.smoothing?`transition: ${this.settings.smoothingAmount}ms ease-out;`:""}
        `,s.appendChild(i),this.wrapper=s,this.el.appendChild(this.wrapper))}}}!function(s){"use strict";s(window).on("elementor/frontend/init",function(){var e=elementorModules.frontend.handlers.Base.extend({onInit:function(){elementorModules.frontend.handlers.Base.prototype.onInit.apply(this,arguments),this.run()},getDefaultSettings:function(){return{selectors:{wrapper:".etheme-image-comparison"}}},getDefaultElements:function(){var t=this.getSettings("selectors");return{$wrapper:this.$element.find(t.wrapper)}},run:function(){var t,e;this.elements.$wrapper.length&&(t=this.getElementSettings(),(e=new Map).set("controlLineColor",t.divider_color||"#2962FF"),"none"!=t.show_labels&&(e.set("showLabels",!0),e.set("labelOptions",{before:t.before_label,after:t.after_label,onHover:"on_hover"==t.show_labels})),e.set("addOverlay",!!t.add_overlay),e.set("startingPoint",t.start_point?.size?t.start_point.size:50),e.set("onHover",!!t.on_hover),e.set("smoothing",!1),new ImageCompare(s(this.elements.$wrapper)[0],Object.fromEntries(e)).mount())}});elementorFrontend.hooks.addAction("frontend/element_ready/etheme_image_comparison.default",function(t){elementorFrontend.elementsHandler.addHandler(e,{$element:t})})})}(jQuery);