whoami7 - Manager
:
/
home
/
dataiclx
/
vielorbe.com
/
wp-content
/
themes
/
botiga
/
assets
/
js
/
Upload File:
files >> //home/dataiclx/vielorbe.com/wp-content/themes/botiga/assets/js/botiga-carousel.min.js
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),e}var Siema=function(){function i(e){var t=this;if(_classCallCheck(this,i),this.config=i.mergeSettings(e),this.parentSelector="string"==typeof this.config.parentSelector?document.querySelector(this.config.parentSelector):this.config.parentSelector,this.selector="string"==typeof this.config.selector?document.querySelector(this.config.selector):this.config.selector,this.parentSelector&&(this.selector=this.parentSelector.querySelector(".botiga-carousel-stage")),null===this.selector)throw new Error("Something wrong with your selector ðŸ˜");if("true"===this.parentSelector.getAttribute("data-initialized"))return!1;this.resolveSlidesNumber(),this.selectorWidth=this.selector.offsetWidth,this.innerElements=[].slice.call(this.selector.children),this.currentSlide=this.config.loop?this.config.startIndex%this.innerElements.length:Math.max(0,Math.min(this.config.startIndex,this.innerElements.length-this.perPage)),this.transformProperty=i.webkitOrNot(),["resizeHandler","touchstartHandler","touchendHandler","touchmoveHandler","mousedownHandler","mouseupHandler","mouseleaveHandler","mousemoveHandler","clickHandler","navNextHandler","navPrevHandler"].forEach(function(e){t[e]=t[e].bind(t)}),this.init()}return _createClass(i,[{key:"attachEvents",value:function(){window.addEventListener("resize",this.resizeHandler),this.config.draggable&&(this.pointerDown=!1,this.drag={startX:0,endX:0,startY:0,letItGo:null,preventClick:!1},this.selector.addEventListener("touchstart",this.touchstartHandler),this.selector.addEventListener("touchend",this.touchendHandler),this.selector.addEventListener("touchmove",this.touchmoveHandler),this.selector.addEventListener("mousedown",this.mousedownHandler),this.selector.addEventListener("mouseup",this.mouseupHandler),this.selector.addEventListener("mouseleave",this.mouseleaveHandler),this.selector.addEventListener("mousemove",this.mousemoveHandler),this.selector.addEventListener("click",this.clickHandler),this.parentSelector.querySelector(".botiga-carousel-nav-next").addEventListener("click",this.navNextHandler),this.parentSelector.querySelector(".botiga-carousel-nav-prev").addEventListener("click",this.navPrevHandler))}},{key:"detachEvents",value:function(){window.removeEventListener("resize",this.resizeHandler),this.selector.removeEventListener("touchstart",this.touchstartHandler),this.selector.removeEventListener("touchend",this.touchendHandler),this.selector.removeEventListener("touchmove",this.touchmoveHandler),this.selector.removeEventListener("mousedown",this.mousedownHandler),this.selector.removeEventListener("mouseup",this.mouseupHandler),this.selector.removeEventListener("mouseleave",this.mouseleaveHandler),this.selector.removeEventListener("mousemove",this.mousemoveHandler),this.selector.removeEventListener("click",this.clickHandler),this.parentSelector.querySelector(".botiga-carousel-nav-next").removeEventListener("click",this.navNextHandler),this.parentSelector.querySelector(".botiga-carousel-nav-prev").removeEventListener("click",this.navPrevHandler)}},{key:"init",value:function(){this.buildNavigation(),this.attachEvents(),this.selector.style.overflow="hidden",this.selector.style.direction=this.config.rtl?"rtl":"ltr",this.buildSliderFrame(),this.config.onInit.call(this),this.parentSelector.querySelector(".botiga-carousel-stage").classList.add("show"),null!==this.parentSelector&&this.parentSelector.setAttribute("data-initialized",!0)}},{key:"buildNavigation",value:function(){var e=document.createElement("a"),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),i=document.createElement("a"),r=document.createElementNS("http://www.w3.org/2000/svg","svg");e.role="button",e.href="#",e.className="botiga-carousel-nav botiga-carousel-nav-next",t.setAttribute("width",18),t.setAttribute("height",18),t.setAttribute("viewBox","0 0 10 16"),t.setAttribute("fill","none"),t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("class","stroke-based"),t.innerHTML='<path d="M1.5 14.667L8.16667 8.00033L1.5 1.33366" stroke="#242021" stroke-width="1.5"></path>',e.append(t),this.parentSelector.querySelector(".botiga-carousel-wrapper").append(e),i.role="button",i.href="#",i.className="botiga-carousel-nav botiga-carousel-nav-prev",r.setAttribute("width",18),r.setAttribute("height",18),r.setAttribute("viewBox","0 0 10 16"),r.setAttribute("fill","none"),r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("class","stroke-based"),r.innerHTML='<path d="M8.5 1.33301L1.83333 7.99967L8.5 14.6663" stroke="#242021" stroke-width="1.5"></path>',i.append(r),this.parentSelector.querySelector(".botiga-carousel-wrapper").append(i)}},{key:"buildSliderFrame",value:function(){if(null!==this.parentSelector.querySelector(".botiga-carousel-nav-next")&&this.innerElements.length<=this.perPage)return this.parentSelector.querySelector(".botiga-carousel-nav-next").remove(),this.parentSelector.querySelector(".botiga-carousel-nav-prev").remove(),!1;var e=(this.selectorWidth+this.config.margin)/this.perPage,t=this.config.loop?this.innerElements.length+2*this.perPage:this.innerElements.length;this.sliderFrame=document.createElement("div"),this.sliderFrame.style.width=e*t+"px",this.enableTransition(),this.config.draggable&&(this.selector.style.cursor="-webkit-grab");var i=document.createDocumentFragment();if(this.config.loop)for(var r=this.innerElements.length-this.perPage;r<this.innerElements.length;r++){var n=this.buildSliderFrameItem(this.innerElements[r].cloneNode(!0));i.appendChild(n)}for(var s=0;s<this.innerElements.length;s++){n=this.buildSliderFrameItem(this.innerElements[s]);i.appendChild(n)}if(this.config.loop)for(var a=0;a<this.perPage;a++){n=this.buildSliderFrameItem(this.innerElements[a].cloneNode(!0));i.appendChild(n)}this.sliderFrame.appendChild(i),this.selector.innerHTML="",this.selector.appendChild(this.sliderFrame),this.slideToCurrent()}},{key:"buildSliderFrameItem",value:function(e){var t=document.createElement("div");return t.style.cssFloat=this.config.rtl?"right":"left",t.style.float=this.config.rtl?"right":"left",t.style.width=(this.config.loop?100/(this.innerElements.length+2*this.perPage):100/this.innerElements.length)+"%",t.style.marginRight=this.config.margin+"px",t.appendChild(e),t}},{key:"resolveSlidesNumber",value:function(){if("number"==typeof this.config.perPage)this.perPage=this.config.perPage;else if("object"===_typeof(this.config.perPage))for(var e in this.perPage=1,this.config.perPage)window.innerWidth>=e&&(this.perPage=this.config.perPage[e])}},{key:"prev",value:function(){var e,t,i,r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,s=1<arguments.length?arguments[1]:void 0;this.innerElements.length<=this.perPage||(e=this.currentSlide,this.config.loop?this.currentSlide-n<0?(this.disableTransition(),t=this.currentSlide+this.innerElements.length,r=this.perPage,i=(this.config.rtl?1:-1)*(t+r)*(this.selectorWidth/this.perPage),r=this.config.draggable?this.drag.endX-this.drag.startX:0,this.sliderFrame.style[this.transformProperty]="translate3d(".concat(i+r,"px, 0, 0)"),this.currentSlide=t-n):this.currentSlide=this.currentSlide-n:this.currentSlide=Math.max(this.currentSlide-n,0),e!==this.currentSlide&&(this.slideToCurrent(this.config.loop),this.config.onChange.call(this),s&&s.call(this)))}},{key:"next",value:function(){var e,t,i,r,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,s=1<arguments.length?arguments[1]:void 0;this.innerElements.length<=this.perPage||(e=this.currentSlide,this.config.loop?this.currentSlide+n>this.innerElements.length-this.perPage?(this.disableTransition(),t=this.currentSlide-this.innerElements.length,r=this.perPage,i=(this.config.rtl?1:-1)*(t+r)*(this.selectorWidth/this.perPage),r=this.config.draggable?this.drag.endX-this.drag.startX:0,this.sliderFrame.style[this.transformProperty]="translate3d(".concat(i+r,"px, 0, 0)"),this.currentSlide=t+n):this.currentSlide=this.currentSlide+n:this.currentSlide=Math.min(this.currentSlide+n,this.innerElements.length-this.perPage),e!==this.currentSlide&&(this.slideToCurrent(this.config.loop),this.config.onChange.call(this),s&&s.call(this)))}},{key:"disableTransition",value:function(){this.sliderFrame.style.webkitTransition="all 0ms ".concat(this.config.easing),this.sliderFrame.style.transition="all 0ms ".concat(this.config.easing)}},{key:"enableTransition",value:function(){if(void 0===this.sliderFrame)return!1;this.sliderFrame.style.webkitTransition="all ".concat(this.config.duration,"ms ").concat(this.config.easing),this.sliderFrame.style.transition="all ".concat(this.config.duration,"ms ").concat(this.config.easing)}},{key:"goTo",value:function(e,t){var i;this.innerElements.length<=this.perPage||(i=this.currentSlide,this.currentSlide=this.config.loop?e%this.innerElements.length:Math.min(Math.max(e,0),this.innerElements.length-this.perPage),i!==this.currentSlide&&(this.slideToCurrent(),this.config.onChange.call(this),t&&t.call(this)))}},{key:"slideToCurrent",value:function(e){var t=this,i=this.config.loop?this.currentSlide+this.perPage:this.currentSlide,r=(this.config.rtl?1:-1)*i*((this.selectorWidth+this.config.margin)/this.perPage);if(void 0===this.sliderFrame)return!1;e?requestAnimationFrame(function(){requestAnimationFrame(function(){t.enableTransition(),t.sliderFrame.style[t.transformProperty]="translate3d("+r+"px, 0, 0)"})}):(this.enableTransition(),this.sliderFrame.style[this.transformProperty]="translate3d("+r+"px, 0, 0)")}},{key:"updateAfterDrag",value:function(){var e=(this.config.rtl?-1:1)*(this.drag.endX-this.drag.startX),t=Math.abs(e),i=this.config.multipleDrag?Math.ceil(t/(this.selectorWidth/this.perPage)):1,r=0<e&&this.currentSlide-i<0,n=e<0&&this.currentSlide+i>this.innerElements.length-this.perPage;0<e&&t>this.config.threshold&&this.innerElements.length>this.perPage?this.prev(i):e<0&&t>this.config.threshold&&this.innerElements.length>this.perPage&&this.next(i),this.slideToCurrent(r||n)}},{key:"resizeHandler",value:function(){this.resolveSlidesNumber(),this.currentSlide+this.perPage>this.innerElements.length&&(this.currentSlide=this.innerElements.length<=this.perPage?0:this.innerElements.length-this.perPage),this.selectorWidth=this.selector.offsetWidth,this.buildSliderFrame()}},{key:"clearDrag",value:function(){this.drag={startX:0,endX:0,startY:0,letItGo:null,preventClick:this.drag.preventClick}}},{key:"touchstartHandler",value:function(e){-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.target.nodeName)||(e.stopPropagation(),this.pointerDown=!0,this.drag.startX=e.touches[0].pageX,this.drag.startY=e.touches[0].pageY)}},{key:"touchendHandler",value:function(e){e.stopPropagation(),this.pointerDown=!1,this.enableTransition(),this.drag.endX&&this.updateAfterDrag(),this.clearDrag()}},{key:"touchmoveHandler",value:function(e){var t;e.stopPropagation(),null===this.drag.letItGo&&(this.drag.letItGo=Math.abs(this.drag.startY-e.touches[0].pageY)<Math.abs(this.drag.startX-e.touches[0].pageX)),this.pointerDown&&this.drag.letItGo&&(e.preventDefault(),this.drag.endX=e.touches[0].pageX,this.sliderFrame.style.webkitTransition="all 0ms ".concat(this.config.easing),this.sliderFrame.style.transition="all 0ms ".concat(this.config.easing),t=(this.config.loop?this.currentSlide+this.perPage:this.currentSlide)*((this.selectorWidth+this.config.margin)/this.perPage),e=this.drag.endX-this.drag.startX,e=this.config.rtl?t+e:t-e,this.sliderFrame.style[this.transformProperty]="translate3d(".concat((this.config.rtl?1:-1)*e,"px, 0, 0)"))}},{key:"mousedownHandler",value:function(e){-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.target.nodeName)||(e.preventDefault(),e.stopPropagation(),this.pointerDown=!0,this.drag.startX=e.pageX)}},{key:"mouseupHandler",value:function(e){e.stopPropagation(),this.pointerDown=!1,this.selector.style.cursor="-webkit-grab",this.enableTransition(),this.drag.endX&&this.updateAfterDrag(),this.clearDrag()}},{key:"mousemoveHandler",value:function(e){if(e.preventDefault(),this.pointerDown){if("null"!=typeof e.target.closest("a")&&(this.drag.preventClick=!0),void 0===this.sliderFrame)return!1;this.drag.endX=e.pageX,this.selector.style.cursor="-webkit-grabbing",this.sliderFrame.style.webkitTransition="all 0ms ".concat(this.config.easing),this.sliderFrame.style.transition="all 0ms ".concat(this.config.easing);var t=(this.config.loop?this.currentSlide+this.perPage:this.currentSlide)*((this.selectorWidth+this.config.margin)/this.perPage),e=this.drag.endX-this.drag.startX,e=this.config.rtl?t+e:t-e;this.sliderFrame.style[this.transformProperty]="translate3d(".concat((this.config.rtl?1:-1)*e,"px, 0, 0)")}}},{key:"mouseleaveHandler",value:function(e){this.pointerDown&&(this.pointerDown=!1,this.selector.style.cursor="-webkit-grab",this.drag.endX=e.pageX,this.drag.preventClick=!1,this.enableTransition(),this.updateAfterDrag(),this.clearDrag())}},{key:"clickHandler",value:function(e){this.drag.preventClick&&e.preventDefault(),this.drag.preventClick=!1}},{key:"navNextHandler",value:function(e){e.preventDefault(),this.next(1)}},{key:"navPrevHandler",value:function(e){e.preventDefault(),this.prev(1)}},{key:"remove",value:function(e,t){if(e<0||e>=this.innerElements.length)throw new Error("Item to remove doesn't exist ðŸ˜");var i=e<this.currentSlide,r=this.currentSlide+this.perPage-1===e;(i||r)&&this.currentSlide--,this.innerElements.splice(e,1),this.buildSliderFrame(),t&&t.call(this)}},{key:"insert",value:function(e,t,i){if(t<0||t>this.innerElements.length+1)throw new Error("Unable to inset it at this index ðŸ˜");if(-1!==this.innerElements.indexOf(e))throw new Error("The same item in a carousel? Really? Nope ðŸ˜");var r=0<(t<=this.currentSlide)&&this.innerElements.length;this.currentSlide=r?this.currentSlide+1:this.currentSlide,this.innerElements.splice(t,0,e),this.buildSliderFrame(),i&&i.call(this)}},{key:"prepend",value:function(e,t){this.insert(e,0),t&&t.call(this)}},{key:"append",value:function(e,t){this.insert(e,this.innerElements.length+1),t&&t.call(this)}},{key:"destroy",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=1<arguments.length?arguments[1]:void 0;if(this.detachEvents(),this.selector.style.cursor="auto",e){for(var i=document.createDocumentFragment(),r=0;r<this.innerElements.length;r++)i.appendChild(this.innerElements[r]);this.selector.innerHTML="",this.selector.appendChild(i),this.selector.removeAttribute("style")}t&&t.call(this)}}],[{key:"mergeSettings",value:function(e){var t,i={selector:".siema",duration:200,easing:"ease-out",perPage:1,startIndex:0,draggable:!0,multipleDrag:!0,threshold:20,loop:!1,rtl:!1,onInit:function(){},onChange:function(){}},r=e;for(t in r)i[t]=r[t];return i}},{key:"webkitOrNot",value:function(){return"string"==typeof document.documentElement.style.transform?"transform":"WebkitTransform"}}]),i}();
Copyright ©2021 || Defacer Indonesia