1//CONTROL PAGE LOADING 2WPO.Utility = function($, window, document, WPO, navigator){ 3 var isMobilePlatform = null; 4 5 var _detectIE = function(){ 6 var ua = window.navigator.userAgent; 7 var msie = ua.indexOf("MSIE "); 8 9 if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) 10 { 11 $('body').addClass('ie'); 12 } 13 14 }; 15 16 var _GetRandomInteger = function(min,max){ 17 var rtn = Math.floor(Math.random() * Math.floor(max)) + min; 18 if(rtn > max){ 19 rtn = max - 1; 20 } 21 return rtn; 22 }; 23 var _Back = function () { 24 WPO.Utility.Log('back'); 25 history.go(-1); 26 }; 27 28 var _Log = function(message){ 29 if(WPO.Settings.getDebug()){ 30 console.log(message); 31 } 32 }; 33 34 35 var _createCookie = function(name,value,days) { 36 var expires = ""; 37 if (days) { 38 var date = new Date(); 39 date.setTime(date.getTime() + (days*24*60*60*1000)); 40 expires = "; expires=" + date.toUTCString(); 41 } 42 document.cookie = name + "=" + value + expires + "; path=/"; 43 }; 44 45 var _readCookie = function(name) { 46 var nameEQ = name + "="; 47 var ca = document.cookie.split(';'); 48 for(var i=0;i < ca.length;i++) { 49 var c = ca[i]; 50 while (c.charAt(0)===' ') c = c.substring(1,c.length); 51 if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length); 52 } 53 return null; 54 }; 55 56 var _eraseCookie = function(name) { 57 createCookie(name,"",-1); 58 }; 59 60 // RETURNS BOOLEAN BASED ON IF A MOBILE DEVICE 61 62 var _isMobile = function(){ 63 var tmpRetVal = false;
64 if(isMobilePlatform != null) tmpRetVal = isMobilePlatform; 65 else{ 66 isMobilePlatform = (navigator.userAgent.indexOf('iPad') !== -1 || 67 navigator.userAgent.indexOf('iPhone') !== -1 || 68 navigator.userAgent.indexOf('iPod') !== -1 || 69 navigator.userAgent.indexOf('Android') !== -1 || 70 navigator.userAgent.indexOf('BlackBerry') !== -1 || 71 navigator.userAgent.indexOf('webOS') !== -1); 72 73 tmpRetVal = isMobilePlatform; 74 } 75 return tmpRetVal; 76 }; 77 78 79 var _isUrl = function(s) { 80 var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ 81 return regexp.test(s); 82 }; 83 84 var _scrollToElm = function(elm,the_offset) 85 { 86 87 var $container = jQuery("html,body"); 88 var $scrollTo = jQuery(elm); 89 90 $container.animate({scrollTop: $scrollTo.offset().top - $container.offset().top - the_offset},300); 91 }; 92 93 // CSS3 TRANSITION 94 var _updateCSS3Transitions = function(el, x, y, speed, ease){ 95 jQuery(el).css({ 96 '-webkit-transform':'translate3d('+ x +'px, '+ y +'px, 0)','-webkit-transition':'-webkit-transform '+ speed +'ms ' + ease, 97 '-moz-transform':'translate3d('+ x +'px, '+ y +'px, 0)','-moz-transition':'-moz-transform '+ speed +'ms ' + ease, 98 '-ms-transform':'translate3d('+ x +'px, '+ y +'px, 0)','-ms-transition':'-ms-transform '+ speed +'ms ' + ease, 99 '-o-transform':'translate3d('+ x +'px, '+ y +'px, 0)','-o-transition':'-o-transform '+ speed +'ms ' + ease, 100 'transform':'translate3d('+ x +'px, '+ y +'px, 0)','transition':'transform '+ speed +'ms ' + ease 101 }); 102 }; 103 104 105 var _elementInViewport = function(el) { 106 var top = el.offsetTop; 107 var left = el.offsetLeft; 108 var width = el.offsetWidth; 109 var height = el.offsetHeight; 110 111 while(el.offsetParent) { 112 el = el.offsetParent; 113 top += el.offsetTop; 114 left += el.offsetLeft; 115 } 116 117 return ( 118 top < (window.pageYOffset + window.innerHeight) && 119 left < (window.pageXOffset + window.innerWidth) && 120 (top + height) > window.pageYOffset && 121 (left + width) > window.pageXOffset 122 ); 123 }; 124 125 //MOVE TO OWN FILE 126 // var _trackGA = function(category, action, opt_label, opt_value, opt_noninteraction){ 127 // utility.log('GA TRACK: ' + category + ', ' + action + ', ' + opt_label + ', ' + opt_value + ', ' + opt_noninteraction); 128 // if(typeof ga !== "undefined"){ 129 // ga('send', 'event', category,action,opt_value, { 130 // nonInteraction: opt_noninteraction 131 // }); 132 // } 133 // }; 134 var _getScrollPercent = function () { 135 var h = document.documentElement, 136 b = document.body; 137 return $(window).scrollTop() / ($(document).height() - $(window).height()); 138 }; 139 140 var _getParameterByName = function(name, url) { 141 if (!url) url = window.location.href; 142 name = name.replace(/[\[\]]/g, "\\$&"); 143 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 144 results = regex.exec(url); 145 if (!results) return null; 146 if (!results[2]) return ''; 147 return decodeURIComponent(results[2].replace(/\+/g, " ")); 148 } 149 150 return{ 151 GetRandomInteger:_GetRandomInteger, 152 detectIE:_detectIE, 153 createCookie:_createCookie, 154 readCookie:_readCookie, 155 eraseCookie:_eraseCookie, 156 isMobile:_isMobile, 157 scrollToElm:_scrollToElm, 158 updateCSS3Transitions:_updateCSS3Transitions, 159 elementInViewport:_elementInViewport, 160 isUrl:_isUrl, 161 getScrollPercent:_getScrollPercent, 162 Log:_Log, 163 Back:_Back, 164 getParameterByName:_getParameterByName, 165 }; 166 167}(jQuery, window, document, WPO, navigator);
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.