1/*********************************************** 2 * VLThemes 3 ***********************************************/ 4 5'use strict'; 6 7/** 8 * Initialize main helper object 9 */ 10var VLTJS = { 11 window: jQuery(window), 12 document: jQuery(document), 13 html: jQuery('html'), 14 body: jQuery('body'), 15 is_safari: /^((?!chrome|android).)*safari/i.test(navigator.userAgent), 16 is_firefox: navigator.userAgent.toLowerCase().indexOf('firefox') > -1, 17 is_chrome: /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor), 18 is_ie10: navigator.appVersion.indexOf('MSIE 10') !== -1, 19 transitionEnd: 'transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', 20 animIteration: 'animationiteration webkitAnimationIteration oAnimationIteration MSAnimationIteration', 21 animationEnd: 'animationend webkitAnimationEnd' 22}; 23 24/** 25 * Detects whether user is viewing site from a mobile device 26 */ 27VLTJS.isMobile = { 28 Android: function () { 29 return navigator.userAgent.match(/Android/i); 30 }, 31 BlackBerry: function () { 32 return navigator.userAgent.match(/BlackBerry/i); 33 }, 34 iOS: function () { 35 return navigator.userAgent.match(/iPhone|iPad|iPod/i); 36 }, 37 Opera: function () { 38 return navigator.userAgent.match(/Opera Mini/i); 39 }, 40 Windows: function () { 41 return navigator.userAgent.match(/IEMobile/i); 42 }, 43 any: function () { 44 return (VLTJS.isMobile.Android() || VLTJS.isMobile.BlackBerry() || VLTJS.isMobile.iOS() || VLTJS.isMobile.Opera() || VLTJS.isMobile.Windows()); 45 } 46}; 47 48/** 49 * Debounce resize 50 */ 51var resizeArr = []; 52var resizeTimeout; 53VLTJS.window.on('load resize orientationchange', function(e) { 54 if (resizeArr.length) { 55 clearTimeout(resizeTimeout); 56 resizeTimeout = setTimeout(function() { 57 for (var i = 0; i < resizeArr.length; i++) { 58 resizeArr[i](e); 59 } 60 }, 250); 61 } 62}); 63 64VLTJS.debounceResize = function(callback) { 65 if (typeof callback === 'function') { 66 resizeArr.push(callback); 67 } else { 68 window.dispatchEvent(new Event('resize')); 69 } 70} 71 72VLTJS.addLedingZero = function (number) { 73 return ('0' + number).slice(-2); 74} 75 76/** 77 * Throttle scroll 78 */ 79var throttleArr = []; 80var didScroll; 81var delta = 5; 82var lastScrollTop = 0; 83 84VLTJS.window.on('load resize scroll orientationchange', function() { 85 if (throttleArr.length) { 86 didScroll = true; 87 } 88}); 89 90function hasScrolled() { 91 92 var scrollTop = VLTJS.window.scrollTop(), 93 windowHeight = VLTJS.window.height(), 94 documentHeight = VLTJS.document.height(), 95 scrollState = ''; 96 97 // Make sure they scroll more than delta 98 if (Math.abs(lastScrollTop - scrollTop) <= delta) { 99 return; 100 } 101 102 if (scrollTop > lastScrollTop) { 103 scrollState = 'down'; 104 } else if (scrollTop < lastScrollTop) { 105 scrollState = 'up'; 106 } else { 107 scrollState = 'none'; 108 } 109 110 if (scrollTop === 0) { 111 scrollState = 'start'; 112 } else if (scrollTop >= documentHeight - windowHeight) { 113 scrollState = 'end'; 114 } 115 116 for (var i in throttleArr) { 117 if (typeof throttleArr[i] === 'function') { 118 throttleArr[i](scrollState, scrollTop, lastScrollTop, VLTJS.window); 119 } 120 } 121 122 lastScrollTop = scrollTop; 123} 124 125setInterval(function() { 126 if (didScroll) { 127 didScroll = false; 128 window.requestAnimationFrame(hasScrolled); 129 } 130}, 250); 131 132VLTJS.throttleScroll = function(callback) { 133 if (typeof callback === 'function') { 134 throttleArr.push(callback); 135 } 136} 137 138/** 139 * VAR polyfill 140 */ 141if (typeof cssVars !== 'undefined') { 142 cssVars({ 143 onlyVars: true, 144 }); 145}
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.