1InitTabsScroll = function(){ 2 $('.arrow_scroll:not(.arrow_scroll_init)').scrollTab(); 3} 4 5ResizeScrollTabs = function() { 6 var scrollTabs = $('.arrow_scroll_init'); 7 8 if(scrollTabs.length) { 9 scrollTabs.each(function(i, scrollTab){ 10 var _scrollTab = $(scrollTab); 11 _scrollTab.data('scrollTabOptions').resize(); 12 }); 13 } 14} 15 16$(document).ready(function(){ 17 InitTabsScroll(); 18}); 19 20$(window).on('resize', function(){ 21 if(window.scrollTabsTimeout !== undefined) { 22 clearTimeout(window.scrollTabsTimeout); 23 } 24 25 window.scrollTabsTimeout = setTimeout( 26 ResizeScrollTabs, 27 20 28 ); 29}); 30 31$.fn.scrollTab = function( options ){ 32 function _scrollTab(element, options) { 33 var _scrollTab = $(element); 34 var tabs_wrapper = _scrollTab.find(options.tabs_wrapper); 35 if( tabs_wrapper === undefined || !tabs_wrapper.length ) 36 return false; 37 38 var tabs = tabs_wrapper.find('> li'); 39 if(!tabs.length) 40 return false; 41 42 var arrow_svg = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8">'+ 43 '<rect width="12" height="8" fill="#333" fill-opacity="0" />'+ 44 '<path d="M1015.69,507.693a0.986,0.986,0,0,1-1.4,0l-4.31-4.316-4.3,4.316a0.993,0.993,0,0,1-1.4-1.408l4.99-5.009a1.026,1.026,0,0,1,1.43,0l4.99,5.009A0.993,0.993,0,0,1,1015.69,507.693Z" fill="#333" transform="translate(-1004 -501)"/>'+ 45 '</svg>'; 46 var arrows_wrapper = '<div class="arrows_wrapper">'+ 47 '<div class="arrow arrow_left colored_theme_hover_text">'+arrow_svg+'</div>'+ 48 '<div class="arrow arrow_right colored_theme_hover_text">'+arrow_svg+'</div>'+ 49 '</div>'; 50 51 var arrows = $(arrows_wrapper).insertBefore(tabs_wrapper); 52 var arrow_left = arrows.find('.arrow_left'); 53 var arrow_right = arrows.find('.arrow_right'); 54 55 var thisOoptions = $.extend({}, options); 56 var isTouch = ('ontouchstart' in document.documentElement); 57 58 thisOoptions.scrollTab = _scrollTab; 59 thisOoptions.wrapper = tabs_wrapper; 60 thisOoptions.tabs = tabs; 61 thisOoptions.arrows = {}; 62 thisOoptions.arrows.wrapper = arrows; 63 thisOoptions.arrows.arrow_left = arrow_left; 64 thisOoptions.arrows.arrow_right = arrow_right; 65 66 if(thisOoptions.linked_tabs !== undefined && thisOoptions.linked_tabs.length && thisOoptions.linked_tabs.data('scrollTabOptions') !== undefined) { 67 thisOoptions.linked_options = thisOoptions.linked_tabs.data('scrollTabOptions'); 68 thisOoptions.linked_options.linked_options = thisOoptions; 69 } 70 71 if(options.arrows_css) { 72 thisOoptions.arrows.arrow_left.css(options.arrows_css); 73 thisOoptions.arrows.arrow_right.css(options.arrows_css); 74 } 75 76 thisOoptions.initTabs = function(){ 77 thisOoptions.wrapperBounds = thisOoptions.wrapper[0].getBoundingClientRect(); 78 thisOoptions.scrollBounds = thisOoptions.scrollTab[0].getBoundingClientRect(); 79 elements = $(thisOoptions.tabs); 80 if(elements.length) { 81 thisOoptions.firstTabBound = elements[0].getBoundingClientRect().left; 82 thisOoptions.lastTabBound = elements[ elements.length - 1 ].getBoundingClientRect().right; 83 } 84 thisOoptions.minTranslate = (thisOoptions.wrapperBounds.right < thisOoptions.lastTabBound ? thisOoptions.wrapperBounds.right - thisOoptions.lastTabBound - 2 : 0); 85 thisOoptions.disabled = ( thisOoptions.lastTabBound - thisOoptions.wrapperBounds.left ) <= thisOoptions.scrollBounds.width; 86 } 87 88 thisOoptions.wrapper.css({ 89 'white-space': 'nowrap', 90 'min-width': 'auto', 91 'overflow': 'visible', 92 'z-index': '1', 93 }); 94 thisOoptions.scrollTab.css({ 95 'overflow': 'hidden', 96 'position': 'relative', 97 }); 98 99 thisOoptions.checkArrows = function(translate){ 100 if(translate === undefined) { 101 translate = thisOoptions.translate; 102 } 103 104 if( thisOoptions.disabled ) { 105 thisOoptions.arrows.arrow_left.addClass('disabled'); 106 thisOoptions.arrows.arrow_right.addClass('disabled'); 107 } else { 108 if(translate >= thisOoptions.maxTranslate) { 109 thisOoptions.arrows.arrow_left.addClass('disabled'); 110 thisOoptions.arrows.arrow_right.removeClass('disabled'); 111 } else if(translate <= thisOoptions.minTranslate) { 112 thisOoptions.arrows.arrow_right.addClass('disabled'); 113 thisOoptions.arrows.arrow_left.removeClass('disabled'); 114 } else { 115 thisOoptions.arrows.arrow_left.removeClass('disabled'); 116 thisOoptions.arrows.arrow_right.removeClass('disabled'); 117 } 118 } 119 120 } 121 122 thisOoptions.directScroll = function(distance, delay, step){ 123 if(delay === undefined) {
124 delay = 5; 125 } 126 clearInterval(thisOoptions.timerMoveDirect); 127 var newTranslate = thisOoptions.translate + distance; 128 129 if(newTranslate > thisOoptions.maxTranslate) { 130 newTranslate = thisOoptions.maxTranslate; 131 } else if(newTranslate < thisOoptions.minTranslate) { 132 newTranslate = thisOoptions.minTranslate; 133 } 134 var tmpTranslate = thisOoptions.translate; 135 thisOoptions.translate = newTranslate; 136 137 if(delay == 0) { 138 thisOoptions.translate = newTranslate; 139 thisOoptions.wrapper.css({ 140 'transform': 'translateX('+thisOoptions.translate+'px)', 141 }); 142 } else { 143 if(step === undefined) { 144 step = 1; 145 } 146 thisOoptions.timerMoveDirect = setInterval( 147 function() { 148 thisOoptions.wrapper.css({ 149 'transform': 'translateX('+tmpTranslate+'px)', 150 }); 151 152 if( (distance < 0 && tmpTranslate <= newTranslate) || (distance > 0 && tmpTranslate >= newTranslate) ) { 153 thisOoptions.initTabs(); 154 clearInterval(thisOoptions.timerMoveDirect); 155 } 156 157 if(tmpTranslate < newTranslate) { 158 tmpTranslate += step; 159 } else { 160 tmpTranslate -= step; 161 } 162 }, 163 delay 164 ); 165 } 166 167 thisOoptions.checkArrows(newTranslate); 168 }; 169 170 thisOoptions.addArrowsEvents = function() { 171 if (!isTouch) { 172 thisOoptions.arrows.arrow_right.on('mouseenter', function () { 173 thisOoptions.arrows.arrow_left.removeClass('disabled'); 174 thisOoptions.timerMoveLeft = setInterval( 175 function () { 176 if (thisOoptions.translate < thisOoptions.minTranslate) { 177 clearInterval(thisOoptions.timerMoveLeft); 178 thisOoptions.arrows.arrow_right.addClass('disabled'); 179 } else { 180 thisOoptions.translate -= thisOoptions.translateSpeed; 181 thisOoptions.wrapper.css({ 182 'transform': 'translateX(' + thisOoptions.translate + 'px)', 183 }); 184 } 185 }, 186 10 187 ); 188 }); 189 190 thisOoptions.arrows.arrow_right.on('mouseleave', function () { 191 clearInterval(thisOoptions.timerMoveLeft); 192 }); 193 194 thisOoptions.arrows.arrow_left.on('mouseenter', function () { 195 thisOoptions.arrows.arrow_right.removeClass('disabled'); 196 thisOoptions.timerMoveRight = setInterval( 197 function () { 198 if (thisOoptions.translate >= thisOoptions.maxTranslate) { 199 clearInterval(thisOoptions.timerMoveRight); 200 thisOoptions.arrows.arrow_left.addClass('disabled'); 201 } else { 202 thisOoptions.translate += thisOoptions.translateSpeed; 203 thisOoptions.wrapper.css({ 204 'transform': 'translateX(' + thisOoptions.translate + 'px)', 205 }); 206 } 207 }, 208 10 209 ); 210 }); 211 212 thisOoptions.arrows.arrow_left.on('mouseleave', function() { 213 clearInterval(thisOoptions.timerMoveRight); 214 }); 215 } 216 217 thisOoptions.arrows.arrow_right.on('click', function() { 218 thisOoptions.directScroll(-thisOoptions.directTranslate); 219 thisOoptions.arrows.arrow_left.removeClass('disabled'); 220 }); 221 222 thisOoptions.arrows.arrow_right.on('touchend', function() { 223 setTimeout(function() { 224 clearInterval(thisOoptions.timerMoveLeft); 225 }, 1); 226 }); 227 228 thisOoptions.arrows.arrow_left.on('click', function() { 229 thisOoptions.directScroll(thisOoptions.directTranslate); 230 thisOoptions.arrows.arrow_right.removeClass('disabled'); 231 }); 232 233 thisOoptions.arrows.arrow_left.on('touchend', function() { 234 setTimeout(function() { 235 clearInterval(thisOoptions.timerMoveRight); 236 }, 1); 237 }); 238 }; 239 240 thisOoptions.addTabsEvents = function() { 241 thisOoptions.tabs.on('click', function() { 242 var leftScrollBound = thisOoptions.scrollBounds.left; 243 var rightScrollBound = thisOoptions.scrollBounds.right; 244 245 var tabBounds = this.getBoundingClientRect(); 246 var leftTabScrollBound = tabBounds.left - thisOoptions.arrows.arrow_width; 247 var rightTabScrollBound = tabBounds.right + thisOoptions.arrows.arrow_width; 248 249 if(leftTabScrollBound < leftScrollBound) { 250 thisOoptions.directScroll(leftScrollBound - leftTabScrollBound, 1, 2); 251 } else if(rightTabScrollBound > rightScrollBound) { 252 thisOoptions.directScroll(rightScrollBound - rightTabScrollBound, 1, 2); 253 } 254 255 thisOoptions.activeTab = $(this); 256 257 if(thisOoptions.linked_options !== undefined) { 258 var this_index = $(this).index(); 259 var linked_tab = $(thisOoptions.linked_options.tabs[this_index]); 260 var linked_tabs = { 261 leftScrollBound: thisOoptions.linked_options.scrollBounds.left, 262 rightScrollBound: thisOoptions.linked_options.scrollBounds.right, 263 tabBounds: linked_tab[0].getBoundingClientRect(), 264 }; 265 if(linked_tabs.tabBounds.left < linked_tabs.leftScrollBound) { 266 thisOoptions.linked_options.directScroll(linked_tabs.leftScrollBound - linked_tabs.tabBounds.left + thisOoptions.linked_options.arrows.arrow_width + 1, 0); 267 } else if(linked_tabs.tabBounds.right > linked_tabs.rightScrollBound) { 268 thisOoptions.linked_options.directScroll(linked_tabs.rightScrollBound - linked_tabs.tabBounds.right - thisOoptions.linked_options.arrows.arrow_width - 1, 0); 269 } 270 271 thisOoptions.linked_options.activeTab = linked_tab; 272 } 273 274 275 }); 276 }; 277 278 thisOoptions.addWrapperEvents = function() { 279 thisOoptions.wrapper.on('touchstart', function(event) { 280 thisOoptions.touch.posPrev = event.originalEvent.changedTouches[0].pageX; 281 clearInterval(thisOoptions.timerMoveRight); 282 clearInterval(thisOoptions.timerMoveLeft); 283 clearInterval(thisOoptions.timerMoveDirect); 284 }); 285 286 thisOoptions.wrapper.on('touchmove', function(event) { 287 thisOoptions.touch.posCurrent = event.originalEvent.changedTouches[0].pageX - thisOoptions.touch.posPrev; 288 thisOoptions.directScroll(thisOoptions.touch.posCurrent, 0); 289 thisOoptions.touch.posPrev = event.originalEvent.changedTouches[0].pageX; 290 }); 291 }; 292 293 thisOoptions.resize = function(){ 294 if(thisOoptions.onBeforeResize && typeof(thisOoptions.onBeforeResize) == 'function') { 295 thisOoptions.onBeforeResize(thisOoptions); 296 } 297 298 if(thisOoptions.onResize && typeof(thisOoptions.onResize) == 'function') { 299 thisOoptions.onResize(thisOoptions); 300 } 301 302 if(thisOoptions.translate < thisOoptions.minTranslate) { 303 thisOoptions.directScroll(thisOoptions.minTranslate - thisOoptions.translate); 304 } else if(thisOoptions.translate > thisOoptions.maxTranslate) { 305 thisOoptions.directScroll(thisOoptions.maxTranslate - thisOoptions.translate); 306 } 307 308 if( thisOoptions.activeTab !== undefined && thisOoptions.activeTab.length ) { 309 var activeTabBounds = thisOoptions.activeTab[0].getBoundingClientRect(); 310 if(activeTabBounds.left < thisOoptions.scrollBounds.left) { 311 thisOoptions.directScroll(thisOoptions.scrollBounds.left - activeTabBounds.left); 312 } else if(activeTabBounds.right > thisOoptions.scrollBounds.right) { 313 thisOoptions.directScroll(thisOoptions.scrollBounds.right - activeTabBounds.right); 314 } 315 } 316 317 thisOoptions.initTabs(); 318 thisOoptions.checkArrows(); 319 320 if(thisOoptions.onAfterResize && typeof(thisOoptions.onAfterResize) == 'function') { 321 thisOoptions.onAfterResize(thisOoptions); 322 } 323 }; 324 325 326 _scrollTab.data('scrollTabOptions', thisOoptions ); 327 _scrollTab.data('scrollTabOptions').addArrowsEvents(); 328 _scrollTab.data('scrollTabOptions').addTabsEvents(); 329 _scrollTab.data('scrollTabOptions').addWrapperEvents(); 330 _scrollTab.addClass('arrow_scroll_init').addClass('swipeignore'); 331 if (arrow_right !== undefined && arrow_right.length) { 332 thisOoptions.arrows.arrow_width = thisOoptions.arrows.arrow_right[0].getBoundingClientRect().width; 333 } 334 _scrollTab.data('scrollTabOptions').resize(); 335 delete thisOoptions; 336 } 337 338 var options = $.extend({ 339 translate: 1, 340 translateSpeed: 2, 341 directTranslate: 150, 342 maxTranslate: 1, 343 touch: {}, 344 arrows_css: false, 345 tabs_wrapper: '.nav-tabs', 346 onResize: false, 347 width_grow: 9, 348 }, options); 349 350 var el = $(this); 351 352 if(el.hasClass('arrow_scroll_init')) 353 return false;
354 355 el.each(function(i, scrollTab){ 356 _scrollTab(scrollTab, options); 357 }); 358}
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.