"use strict"; function Plugin(i) { (this.element = $(i)), this.initWidget(); } var win = $(window), pluginName = "cslider", timeResize, resize = "onorientationchange" in window ? "orientationchange.resize" + pluginName : "resize.resize" + pluginName, TypeSliders = { NORMAL: "normal", SYNCING: "syncing" }; (Plugin.prototype = { initWidget: function () { var i = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = this; (this.options = $.extend({}, $.fn[pluginName].defaults, JSON.parse(this.element.attr("data-".concat(pluginName))), i)), (this.handle = this.element.find(this.options.handle)), this.handle.is(":visible") && (this.options.initUnder ? win.width() < this.options.initUnder ? (this.element.removeClass("wrap-no-slide"), this.handle.removeClass("no-slide"), this.initSlider()) : (this.element.addClass("wrap-no-slide"), this.handle.addClass("no-slide")) : this.initSlider(), win.off(resize).on(resize, function () { timeResize && clearTimeout(timeResize), (timeResize = setTimeout(t.reRenderSlide, 600)); }), this.listener()); }, listener: function () { this.zoomInEvent(); }, zoomInEvent: function () { var i = this.element.find(".zoomin"); if (0 !== i.length && this.element.closest(".widget-slider").attr("popup-class")) { var t = "." + this.element.closest(".widget-slider").attr("popup-class"); i.off("click.zoomIn").on("click.zoomIn", function () { var e = $(i).index($(this)); $(t).find(".ctrwow-modal").addClass("show"), $(t).find(".widget-slider").show(), $(t).find(".ctrwow-modal").css("pointer-events", "none"), $(t).find(".ctrwow-modal-content").css("pointer-events", "auto"), $(t).find("[data-cslider]")[pluginName]("initWidget", { initialSlide: e }), $(t).addClass("show-popup-slide"); }); $(t) .find(".zoomout") .off("click.zoomOut") .on("click.zoomOut", function () { $(t).find("[data-cslider]")[pluginName]("destroy"), $(t).find(".widget-slider").hide(), $(t).find(".ctrwow-modal").removeClass("show"), $(t).removeClass("show-popup-slide"); }), $(t) .off("click.zoomOutPopup") .on("click.zoomOutPopup", function (i) { $(i.target).hasClass("popup-slide") && ($(t).find("[data-cslider]")[pluginName]("destroy"), $(t).find(".widget-slider").hide(), $(t).find(".ctrwow-modal").removeClass("show"), $(t).removeClass("show-popup-slide")); }); } }, reRenderSlide: function () { $("[data-" + pluginName + "]").each(function () { $(".slick", this).is(":visible") && ($(this).find(".slick-track > .slick-list").remove(), $(this).data()[pluginName].options.initUnder ? win.width() < $(this).data()[pluginName].options.initUnder ? ($(".slick", this).removeClass("no-slide"), $(this).removeClass("wrap-no-slide"), $(".slick", this).hasClass("slick-initialized") ? $(this)[pluginName]("setPositionArrows") : $(this)[pluginName]("initWidget")) : $(".slick", this).hasClass("slick-initialized") && ($(".slick", this).addClass("no-slide"), $(this).addClass("wrap-no-slide"), $(this)[pluginName]("destroy")) : window.ctrwowUtils.isBuilderMode() ? ($(this)[pluginName]("destroy"), $(this)[pluginName]("initWidget")) : ($(this)[pluginName]("setPositionArrows"), $(this)[pluginName]("slickNoSlide"), $(".slick", this).hasClass("no-slide") && ($(this)[pluginName]("destroy"), $(this)[pluginName]("initWidget")))); }); }, updateSetting: function () { var i = {}, t = []; if ( (void 0 !== this.options.desktopItems && (i = $.extend(i, { slidesToShow: this.options.desktopItems, rows: this.options.dkRows || 1, slidesToScroll: this.options.dkScrollItems || 1 })), void 0 !== this.options.tabletItems || void 0 !== this.options.mobileItems) ) { if (void 0 !== this.options.tabletItems) { var e = { breakpoint: 1025, settings: { slidesToShow: this.options.tabletItems, rows: this.options.tbRows || 1, slidesToScroll: this.options.tbScrollItems || 1 } }; t.push(e); } if (void 0 !== this.options.mobileItems) { var s = { breakpoint: 768, settings: { centerPadding: this.options.centerPaddingMobile ? this.options.centerPaddingMobile : 0, slidesToShow: this.options.mobileItems, rows: this.options.mbRows || 1, slidesToScroll: this.options.mbScrollItems || 1, variableWidth: !1, }, }; window.location.pathname.indexOf("warranty") > -1 && !this.options.hasOwnProperty("centerPaddingMobile") && (s.settings.centerPadding = this.options.centerPadding), t.push(s); } i = $.extend(i, { responsive: t }); } return i; }, initSlider: function () { var i, t, e = this, s = {}, elmIDVideo; switch (this.options.type) { case TypeSliders.NORMAL: i = $.extend({}, this.options.normal, this.updateSetting()); break; case TypeSliders.SYNCING: (s.asNavFor = this.options.navFor), (i = this.options.view ? $.extend({}, this.options.normal, s) : $.extend({}, this.options.normal, s, this.updateSetting())); break; default: i = this.options.normal; } if ( ((i = $.extend(i, { dots: this.options.dots, arrows: this.options.arrows, fade: this.options.fade, infinite: this.options.infinite, adaptiveHeight: this.options.adaptiveHeight, variableWidth: this.options.variableWidth || !1, prevArrow: this.options.prevArrow, nextArrow: this.options.nextArrow, arrowWrapper: this.options.arrowWrapper, appendDots: this.options.dotWrapper, initialSlide: this.options.initialSlide, rtl: "rtl" === $("html").attr("dir") || "rtl" === this.options.dir, speed: this.options.slideSpeed, })), this.options.autoplay && (i = $.extend(i, { autoplay: !0, pauseOnHover: !0, cssEase: 0 === this.options.autoplaySpeed ? "linear" : "ease", autoplaySpeed: this.options.hasOwnProperty("autoplaySpeed") ? this.options.autoplaySpeed : 3e3 })), "verticalmode" === this.options.sliderMode) ) { var n = { vertical: !0, verticalSwiping: !0 }; i = $.extend(i, n); } if ("centermode" === this.options.sliderMode) { var o = { centerMode: !0, centerPadding: this.options.centerPadding ? this.options.centerPadding : 0 }; i = $.extend(i, o); } (window._wq = window._wq || []), this.handle.on("init", function () { window.ctrwowUtils.events.emit("onInitSlider_" + e.element.attr("id")), window.CTR_IMG_LAZY_LOADER && window.CTR_IMG_LAZY_LOADER.revalidate(), e.handle.find(".slick-track > .slick-list").remove(); var i = $(".slick-current", e.element).find(".w_wistia"); if (i.length && !window.ctrwowUtils.isBuilderMode()) { window._wq.push({ id: i.data("videoid"), onReady: function () { $(".slick", e.element)[0].slick.animateHeight(), e.setPositionArrows(); }, }); try { var s = $(".slick-current", e.element).find(".wistia_embed"), n = s.attr("id"), o = s.attr("class"); n && (o.indexOf("autoPlay=true") > -1 || o.indexOf("autoPlay=1") > -1) && ((t = window.Wistia && window.Wistia.api(n)), setTimeout(function () { t && t.play(); }, 100)); } catch (i) { console.log(i); } } else e.setPositionArrows(); }), this.handle.slick(i), this.handle.on("beforeChange." + pluginName, function () { try { var i = $(".slick-current", e.element).find(".wistia_embed").attr("id"); i && (t = window.Wistia && window.Wistia.api(i)) /*&& t.pause()*/; this.elmIDVideo = i; } catch (i) { console.log(i); } }), this.handle.on("afterChange." + pluginName, function () { window.CTR_IMG_LAZY_LOADER && window.CTR_IMG_LAZY_LOADER.revalidate(); try { //t && t && t.pause(); if ($(".slick-current", e.element).find(".w_wistia").length && !window.ctrwowUtils.isBuilderMode()) { var i = $(".slick-current", e.element).find(".wistia_embed"), s = i.attr("id"), n = i.attr("class"); this.elmIDVideo !== s && t && t && t.pause(); s && this.elmIDVideo !== s && (n.indexOf("autoPlay=true") > -1 || n.indexOf("autoPlay=1") > -1) && (t = window.Wistia && window.Wistia.api(s)) && t.play(); }else{ t && t && t.pause(); } } catch (i) { console.log(i); } e.setPositionArrows(); }), this.slickNoSlide(); }, setPositionArrows: function () { var i = this.element.find(".slick-arrow"), t = this.handle.find('[aria-hidden="false"] .img-view').length ? this.handle.find('[aria-hidden="false"] .img-view') : this.handle.find('[aria-hidden="true"] .img-view'), e = 0, s = 0; i.length && t.length && this.options.setPositionArrows && ($(t).each(function () { e = Math.max($(this).outerHeight(), e); }), (s = e / 2), i.animate({ top: s }, 300)); }, slickNoSlide: function () { var i = this.handle.slick("getSlick"); i.slideCount && i.slideCount <= i.options.slidesToShow ? (this.element.addClass("wrap-no-slide"), this.handle.addClass("no-slide")) : (this.element.removeClass("wrap-no-slide"), this.handle.removeClass("no-slide")); }, destroy: function () { this.handle.hasClass("slick-initialized") && (this.handle .slick("unslick") .off("beforeChange." + pluginName) .off("afterChange." + pluginName), this.element.find(".slick-track, .slick-list, .slick-dots").remove()); }, }), ($.fn[pluginName] = function (i, t) { return this.each(function () { var e = $.data(this, pluginName); e ? e[i] && e[i](t) : $.data(this, pluginName, new Plugin(this, i)); }); }), ($.fn[pluginName].defaults = { handle: ".slick", normal: { infinite: !1, speed: 600, slidesToShow: 1, slidesToScroll: 1, zIndex: 5, focusOnSelect: !0, accessibility: !1 } });