wp_back/wp-content/plugins/visual-portfolio/build/assets/js/plugin-swiper.js
2024-05-20 15:37:46 +03:00

1 line
5.6 KiB
JavaScript

!function(){"use strict";var e={9924:function(e){e.exports=function(e){return"number"==typeof e?e-e==0:"string"==typeof e&&""!==e.trim()&&(Number.isFinite?Number.isFinite(+e):isFinite(+e))}}},t={};function i(s){var r=t[s];if(void 0!==r)return r.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,i),o.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e=i(9924),t=i.n(e),s=window.jQuery;const r=i.n(s)()(document),{screenSizes:o}=window.VPData;r.on("extendClass.vpf",((e,i)=>{"vpf"===e.namespace&&(i.prototype.initSwiper=function(e=!1){const i=this;if("slider"===i.options.layout&&void 0!==window.Swiper){const s=i.$items_wrap.parent();s.addClass("swiper"),i.$items_wrap.addClass("swiper-wrapper"),i.$items_wrap.children().addClass("swiper-slide");let r=i.options.sliderSlidesPerView||3;const n={};if("fade"===i.options.sliderEffect&&(r=1),t()(r)){let e=r,t=Math.min(o.length-1,e-1);for(;t>=0;t-=1)e>0&&void 0!==o[t]&&(n[o[t]+1]={slidesPerView:e}),e-=1;r=e||1}let a=!1,l=!1;0===(e=e||{speed:1e3*(parseFloat(i.options.sliderSpeed)||0),autoHeight:"auto"===i.options.sliderItemsHeight,effect:i.options.sliderEffect||"slide",fadeEffect:{crossFade:!0},spaceBetween:parseFloat(i.options.itemsGap)||0,centeredSlides:"true"===i.options.sliderCenteredSlides,freeMode:{enabled:"true"===i.options.sliderFreeMode,sticky:"true"===i.options.sliderFreeModeSticky},loop:"true"===i.options.sliderLoop,autoplay:parseFloat(i.options.sliderAutoplay)>0&&{delay:1e3*parseFloat(i.options.sliderAutoplay),disableOnInteraction:!1},navigation:"true"===i.options.sliderArrows&&{nextEl:".vp-portfolio__items-arrow-next",prevEl:".vp-portfolio__items-arrow-prev"},pagination:"true"===i.options.sliderBullets&&{el:".vp-portfolio__items-bullets",clickable:!0,dynamicBullets:"true"===i.options.sliderBulletsDynamic,renderBullet(e,t){return`<span class="${t}" data-bullet-index="${e}" data-bullet-number="${e+1}"></span>`}},mousewheel:"true"===i.options.sliderMousewheel,slidesPerView:r,breakpoints:n,keyboard:!0,grabCursor:!0,preloadImages:!1,touchEventsTarget:"container"}).speed&&(e.speed=1);let p=0;if(e.on={transitionEnd(){0===p?(p=1,this.setTransition(1),this.setTranslate(this.translate+.1)):1===p&&(p=2,this.slideReset())},touchStart(e,t){i.emitEvent("swiperTouchStart",[e,t])},touchMove(e,t){i.emitEvent("swiperTouchMove",[e,t])},touchEnd(e,t){i.emitEvent("swiperTouchEnd",[e,t])}},i.emitEvent("beforeInitSwiper",[e]),i.$slider_thumbnails_wrap.length){l=i.$slider_thumbnails_wrap.parent(),l.addClass("swiper"),i.$slider_thumbnails_wrap.addClass("swiper-wrapper"),i.$slider_thumbnails_wrap.children().addClass("swiper-slide");let e=i.options.sliderThumbnailsPerView||8;const s={};if(t()(e)){let t=e,i=Math.min(o.length-1,t-1);for(;i>=0;i-=1)t>0&&void 0!==o[i]&&(s[o[i]+1]={slidesPerView:t}),t-=1;e=t||1}a={autoHeight:"auto"===i.options.sliderThumbnailsHeight,effect:"slide",spaceBetween:parseFloat(i.options.sliderThumbnailsGap)||0,loop:!1,freeMode:{enabled:!0,sticky:!0},loopedSlides:5,slidesPerView:e,breakpoints:s,keyboard:!0,grabCursor:!0,watchSlidesVisibility:!0,watchSlidesProgress:!0,preloadImages:!1,touchEventsTarget:"container",on:{touchStart(e,t){i.emitEvent("swiperTouchStart",[e,t])},touchMove(e,t){i.emitEvent("swiperTouchMove",[e,t])},touchEnd(e,t){i.emitEvent("swiperTouchEnd",[e,t])}}}}if((()=>{const t=function(e){let t=8;return void 0===e.defaults.maxBackfaceHiddenSlides&&(t=7),void 0===e.defaults.rewind&&(t=6),void 0===e.defaults.loopPreventsSlide&&(t=5),t}(window.Swiper),i=a&&l&&l[0];t<7&&(s.addClass("swiper-container"),i&&l.addClass("swiper-container")),t<7&&(e.freeModeSticky=e.freeMode.sticky,e.freeMode=e.freeMode.enabled,i&&(a.freeModeSticky=a.freeMode.sticky,a.freeMode=a.freeMode.enabled)),t>=5&&(e.breakpointsInverse=!0,i&&(a.breakpointsInverse=!0))})(),a&&l&&l[0]){const t=new window.Swiper(l[0],a);e.thumbs={swiper:t}}const d=new window.Swiper(s[0],e);"true"===i.options.sliderAutoplayHoverPause&&parseFloat(i.options.sliderAutoplay)>0&&(i.$item.on(`mouseenter.vpf-uid-${i.uid}`,".swiper",(()=>{s[0].swiper.autoplay.stop()})),i.$item.on(`mouseleave.vpf-uid-${i.uid}`,".swiper",(()=>{s[0].swiper.autoplay.start()}))),i.emitEvent("initSwiper",[e,d])}},i.prototype.destroySwiper=function(){const e=this,t=e.$items_wrap.parent(),i=!!e.$slider_thumbnails_wrap.length&&e.$slider_thumbnails_wrap.parent(),s=t[0].swiper,r=!!i&&i[0].swiper;let o=!1;r&&(r.destroy(),i.removeClass("swiper"),e.$slider_thumbnails_wrap.removeClass("swiper-wrapper"),e.$slider_thumbnails_wrap.children().removeClass("swiper-slide"),o=!0),s&&(s.destroy(),t.removeClass("swiper"),e.$items_wrap.removeClass("swiper-wrapper"),e.$items_wrap.children().removeClass("swiper-slide"),t.find(".vp-portfolio__items-bullets").removeClass("swiper-pagination-clickable swiper-pagination-bullets-dynamic").removeAttr("style").html(""),o=!0),o&&e.emitEvent("destroySwiper")})})),r.on("addItems.vpf",((e,t,i,s,r)=>{if("vpf"!==e.namespace)return;const o=t.$items_wrap.parent()[0].swiper;if(!o)return;{s&&o.removeAllSlides();const e=[];i.addClass("swiper-slide").each((function(){e.push(this)})),o.appendSlide(e)}const n=!!t.$slider_thumbnails_wrap.length&&t.$slider_thumbnails_wrap.parent()[0].swiper;if(n){s&&n.removeAllSlides();const e=[];r.find(".vp-portfolio__thumbnails > .vp-portfolio__thumbnail-wrap").clone().addClass("swiper-slide").each((function(){e.push(this)})),n.appendSlide(e)}})),r.on("init.vpf",((e,t)=>{"vpf"===e.namespace&&t.initSwiper()})),r.on("destroy.vpf",((e,t)=>{"vpf"===e.namespace&&t.destroySwiper()}))}()}();