1(function ($, window, undefined) { 2 function MadRootSlider() { 3 var self = this; 4 5 this._container = null; 6 this._navigationBlock = null; 7 this._slidesImagesBlock = null; 8 this._slidesContentBlock = null; 9 this._navigationNext = null; 10 this._navigationPrev = null; 11 12 this._slidesImagesList = []; 13 this._slidesContentList = []; 14 this._navigationItemsList = []; 15 this._navigationItemsList = []; 16 17 this._itemsCount = 0; 18 19 this._activeZIndex = 3; 20 this._lastActive = 0; 21 22 this.autoSlideEnabled = false; 23 24 function init() { 25 self._container = $(".js_root_slider"); 26 self._navigationBlock = self._container.find(".js_root_slider_navigation"); 27 self._slidesImagesBlock = self._container.find(".js_root_slider_images"); 28 self._slidesContentBlock = self._container.find(".js_root_slider_contents"); 29 self._slidesImagesList = self._slidesImagesBlock.find(".js_root_slider_item"); 30 self._slidesContentList = self._slidesContentBlock.find(".js_root_slider_item"); 31 self._navigationItemsList = self._navigationBlock.find(".js_root_slider_item"); 32 self._navigationNext = self._slidesContentList.find(".js_root_slider_next"); 33 self._navigationPrev = self._slidesContentList.find(".js_root_slider_prev"); 34 self._moreInfoButton = self._slidesContentList.find(".js_root_slider_more_info_button"); 35 self._itemsCount = self._navigationItemsList.length; 36 self._navigationItemsList.each(function (index) { 37 $(this).data("index", index); 38 }); 39 setEvents(); 40 startAutoSlide(); 41 } 42 43 function stopAutoSlide() { 44 self.autoSlideEnabled = false; 45 } 46 47 function startAutoSlide() { 48 self.autoSlideEnabled = true; 49 showNextAutoSlide(); 50 } 51 52 function showNextAutoSlide() { 53 setTimeout(function () { 54 if (self.autoSlideEnabled) { 55 switchToNext(); 56 showNextAutoSlide(); 57 } 58 }, 3000); 59 } 60 61 function setEvents() { 62 self._moreInfoButton.on("click.benefits_slider", function () { 63 stopAutoSlide(); 64 }); 65 self._navigationNext.on("click.benefits_slider", function () { 66 stopAutoSlide(); 67 switchToNext(); 68 }); 69 self._navigationPrev.on("click.benefits_slider", function () { 70 stopAutoSlide(); 71 switchToPrev(); 72 }); 73 self._navigationItemsList.on("click.benefits_slider", function () { 74 stopAutoSlide(); 75 switchTo($(this).data("index")); 76 }); 77 self._container.enableSlideManipulation(); 78 self._container.on("swipeleft.benefits_slider", function () { 79 stopAutoSlide(); 80 switchToNext(); 81 }); 82 self._container.on("swiperight.benefits_slider", function () { 83 stopAutoSlide(); 84 switchToPrev(); 85 }); 86 } 87 88 function switchToNext() { 89 var index = self._lastActive + 1; 90 if (index >= self._itemsCount) { 91 index = 0; 92 } 93 switchTo(index); 94 } 95 96 function switchToPrev() { 97 var index = self._lastActive - 1; 98 if (index < 0) { 99 index = self._itemsCount - 1; 100 } 101 switchTo(index); 102 } 103 104 function switchTo(index) { 105 if (index === self._lastActive) return; 106 self._lastActive = index; 107 self._navigationItemsList.removeClass("active"); 108 self._navigationItemsList.eq(index).addClass("active"); 109 self._slidesImagesList.removeClass("active"); 110 self._slidesContentList.removeClass("active"); 111 self._slidesImagesList.eq(index).css({zIndex: self._activeZIndex++}).addClass("active"); 112 self._slidesContentList.eq(index).css({zIndex: self._activeZIndex++}).addClass("active"); 113 } 114 115 this.init = init; 116 } 117 118 $.MadRootSlider = new MadRootSlider(); 119})(jQuery, window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.