1function TagsCustom(areaId) { 2 this.areaId = areaId; 3 4 $($.proxy(this, "init")); 5} 6 7TagsCustom.prototype = { 8 init: function() { 9 this.el = $("#" + this.areaId); 10 this.sliderInited = false; 11 this.sliderOptions = { 12 slideMargin: 10, 13 touchEnabled: BX.Browser.isMobile(), 14 infiniteLoop: false, 15 hideControlOnEnd: true, 16 pager: false, 17 controls: true, 18 nextText: "<i class='fa fa-chevron-right'></i>", 19 prevText: "<i class='fa fa-chevron-left'></i>", 20 moveSlides: 1, 21 }; 22 this.resizeTimeout = null; 23 24 this.initSlider(); 25 this.bindEvents(); 26 }, 27 28 bindEvents: function() { 29 this.el.find(".s-tags__toggle").on("click", $.proxy(this, "toggleSlider")); 30 $(window).on("resize", $.proxy(this, "onWindowResize")); 31 }, 32 33 initSlider: function() { 34 this.recalcSliderOptions(); 35 this.el.removeClass("s-tags_mode_list s-tags_mode_initial").addClass("s-tags_mode_slider"); 36 this.slider = this.el.find(".s-tags__items").bxSlider(this.sliderOptions); 37 this.sliderInited = true; 38 }, 39 40 destroySlider: function() { 41 this.slider.destroySlider(); 42 this.el.removeClass("s-tags_mode_slider").addClass("s-tags_mode_list"); 43 this.sliderInited = false; 44 }, 45 46 toggleSlider: function() { 47 if(this.sliderInited) { 48 this.destroySlider(); 49 } else { 50 this.initSlider(); 51 } 52 }, 53 54 onWindowResize: function() { 55 if(this.sliderInited) { 56 clearTimeout(this.resizeTimeout); 57 this.resizeTimeout = setTimeout($.proxy(function() { 58 if(this.recalcSliderOptions()) { 59 this.slider.reloadSlider(this.sliderOptions); 60 } 61 }, this), 100) 62 } 63 }, 64 65 recalcSliderOptions: function() { 66 let slidesCount, 67 slideWidth, 68 hasChanges = false; 69 70 if(window.matchMedia("(min-width: 768px)").matches) { 71 slidesCount = 4; 72 } else if(window.matchMedia("(min-width: 576px)").matches) { 73 slidesCount = 2; 74 } else { 75 slidesCount = 1; 76 } 77 if(this.sliderOptions.minSlides !== slidesCount || this.sliderOptions.maxSlides !== slidesCount) { 78 this.sliderOptions.minSlides = slidesCount; 79 this.sliderOptions.maxSlides = slidesCount; 80 hasChanges = true; 81 } 82 83 slideWidth = this.el.find(".s-tags__inner").outerWidth() / slidesCount; 84 if(this.sliderOptions.slideWidth !== slideWidth) { 85 this.sliderOptions.slideWidth = slideWidth; 86 hasChanges = true; 87 } 88 89 return hasChanges; 90 }, 91};
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.