1 2; /* Start:"a:4:{s:4:"full";s:88:"/bitrix/templates/mh_bootstrap/components/bitrix/news.list/flat/script.js?17139578854815";s:6:"source";s:73:"/bitrix/templates/mh_bootstrap/components/bitrix/news.list/flat/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 3(function (window) 4{ 5 if (!!window.JCNewsSlider) 6 { 7 return; 8 } 9 10 window.JCNewsSlider = function (containerId, options) 11 { 12 if (containerId && options) 13 { 14 var container = BX(containerId); 15 if (container) 16 { 17 var sliderImages = BX.findChildByClassName(container, options.imagesContainerClassName, true); 18 var sliderLeft = BX.findChildByClassName(container, options.leftArrowClassName, true); 19 var sliderRight = BX.findChildByClassName(container, options.rightArrowClassName, true); 20 var sliderControl = BX.findChildByClassName(container, options.controlContainerClassName, true); 21 if (sliderImages && sliderLeft && sliderRight && sliderControl) 22 { 23 var slider = new JCNewsSlider; 24 slider.Init(sliderImages, sliderControl, sliderLeft, sliderRight); 25 } 26 } 27 } 28 }; 29 30 window.JCNewsSlider.prototype.Init = function(sliderImages, sliderControl, sliderLeft, sliderRight) 31 { 32 this.time = 0.5; 33 this.type = 'accelerated'; 34 //swipe 35 this.threshold = 50; 36 this.allowedTime = 500; 37 this.startX = 0; 38 this.startY = 0; 39 this.startTime = 0; 40 41 this.sliderImages = sliderImages; 42 BX.bind(sliderImages, 'touchstart', BX.delegate(this.touchStart, this)); 43 BX.bind(sliderImages, 'touchend', BX.delegate(this.touchEnd, this)); 44 45 this.sliderControls = BX.findChildren(sliderControl, {tagName: 'LI'}, true); 46 var proxy = function(j, func) 47 { 48 return function() 49 { 50 return func(j); 51 } 52 } 53 for (var j = 0; j < this.sliderControls.length; j++) 54 { 55 BX.bind(this.sliderControls[j], 'click', proxy(j, BX.delegate(this.slideTo, this))); 56 } 57 58 this.sliderLeft = sliderLeft; 59 BX.bind(sliderLeft, 'click', BX.delegate(this.slideLeft, this)); 60 61 this.sliderRight = sliderRight; 62 BX.bind(sliderRight, 'click', BX.delegate(this.slideRight, this)); 63 }; 64 65 window.JCNewsSlider.prototype.slideRight = function() 66 { 67 if (this.animation) 68 return; 69 this.animation = true; 70 71 var p = parseInt(this.sliderImages.style.left, 10); 72 if (p <= -100 * (this.sliderControls.length-1)) 73 { 74 this.animation = false; 75 return; 76 } 77 78 var _this = this; 79 (new BX.fx({ 80 start: p, 81 finish: p - 100, 82 time: this.time, 83 type: this.type, 84 callback: function(res){ 85 _this.sliderImages.style.left = res + '%'; 86 }, 87 callback_start: function(){ 88 _this.sliderImages.style.left = p + '%'; 89 }, 90 callback_complete: function(){ 91 _this.sliderImages.style.left = (p - 100) + '%'; 92 _this.adjustSliderControls(-(p - 100) / 100); 93 _this.animation = false; 94 } 95 })).start(); 96 }; 97 98 window.JCNewsSlider.prototype.slideLeft = function() 99 { 100 if (this.animation) 101 return; 102 this.animation = true; 103 104 var p = parseInt(this.sliderImages.style.left, 10); 105 if (p >= 0) 106 { 107 this.animation = false; 108 return; 109 } 110 111 var _this = this; 112 (new BX.fx({ 113 start: p, 114 finish: p + 100, 115 time: this.time, 116 type: this.type, 117 callback: function(res){ 118 _this.sliderImages.style.left = res + '%'; 119 }, 120 callback_start: function(){ 121 _this.sliderImages.style.left = p + '%'; 122 }, 123 callback_complete: function(){ 124 _this.sliderImages.style.left = (p + 100) + '%'; 125 _this.adjustSliderControls(-(p + 100) / 100); 126 _this.animation = false; 127 } 128 })).start(); 129 }; 130 131 window.JCNewsSlider.prototype.slideTo = function(j) 132 { 133 if (this.animation) 134 return; 135 this.animation = true; 136 137 var p = parseInt(this.sliderImages.style.left, 10); 138 if (p == (-j * 100)) 139 { 140 this.animation = false; 141 return; 142 } 143 144 var _this = this; 145 (new BX.fx({ 146 start: p, 147 finish: -j * 100, 148 time: this.time, 149 type: this.type, 150 callback: function(res){ 151 _this.sliderImages.style.left = res + '%'; 152 }, 153 callback_start: function(){ 154 _this.sliderImages.style.left = p + '%'; 155 _this.adjustSliderControls(j); 156 }, 157 callback_complete: function(){ 158 _this.sliderImages.style.left = (-j * 100) + '%'; 159 _this.animation = false;
160 } 161 })).start(); 162 }; 163 164 window.JCNewsSlider.prototype.adjustSliderControls = function(i) 165 { 166 for (var j = 0; j < this.sliderControls.length; j++) 167 { 168 if (i == j) 169 BX.addClass(this.sliderControls[j], 'current'); 170 else 171 BX.removeClass(this.sliderControls[j], 'current'); 172 } 173 }; 174 175 window.JCNewsSlider.prototype.touchStart = function(e) 176 { 177 var touchObject = e.changedTouches[0]; 178 this.startX = touchObject.pageX; 179 this.startY = touchObject.pageY; 180 this.startTime = new Date().getTime(); 181 e.preventDefault(); 182 }; 183 184 window.JCNewsSlider.prototype.touchEnd = function(e) 185 { 186 var touchObject = e.changedTouches[0]; 187 var distance = touchObject.pageX - this.startX; 188 var elapsedTime = new Date().getTime() - this.startTime; 189 190 if (elapsedTime <= this.allowedTime) 191 { 192 if (distance > this.threshold) 193 this.slideLeft(); 194 else if (distance < -this.threshold) 195 this.slideRight(); 196 } 197 e.preventDefault() 198 }; 199} 200)(window); 201/* End */ 202;; /* /bitrix/templates/mh_bootstrap/components/bitrix/news.list/flat/script.js?17139578854815*/
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.