(function($, window) { var vendors = ['webkit', 'moz']; for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { var vp = vendors[i]; window.requestAnimationFrame = window[vp+'RequestAnimationFrame']; window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame'] || window[vp+'CancelRequestAnimationFrame']); } if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy || !window.requestAnimationFrame || !window.cancelAnimationFrame) { var lastTime = 0; window.requestAnimationFrame = function(callback) { var now = Date.now(); var nextTime = Math.max(lastTime + 16, now); return setTimeout(function() { callback(lastTime = nextTime); }, nextTime - now); }; window.cancelAnimationFrame = clearTimeout; } var ProfiTheme = window.ProfiTheme = window.ProfiTheme || {}; ProfiTheme.Global = function(){}; ProfiTheme.Global.initSettings = function(){ ProfiTheme.Global.uAgent = navigator.userAgent; ProfiTheme.Global.macOS = ProfiTheme.Global.uAgent.match(/(iPad|iPhone|iPod|Macintosh)/g) ? true : false; ProfiTheme.Global.mobileIE = ProfiTheme.Global.uAgent.indexOf('IEMobile') !== -1; ProfiTheme.Global.touch = ('ontouchstart' in window || 'onmsgesturechange' in window) ? true : false; ProfiTheme.Global.isNewerIe = ProfiTheme.Global.uAgent.match(/msie (9|([1-9][0-9]))/i), ProfiTheme.Global.isOlderIe = ProfiTheme.Global.uAgent.match(/msie/i) && !isNewerIe, ProfiTheme.Global.isAncientIe = ProfiTheme.Global.uAgent.match(/msie 6/i); ProfiTheme.Global.isIe = ProfiTheme.Global.isAncientIe || ProfiTheme.Global.isOlderIe || ProfiTheme.Global.isNewerIe; ProfiTheme.Global.latestKnownScrollY = $('html').scrollTop() || $('body').scrollTop(); this.setSizes(); } ProfiTheme.Global.setSizes = function() { ProfiTheme.Global.documentHeight = $(document).height(); ProfiTheme.Global.windowWidth = $(window).width(); ProfiTheme.Global.windowHeight = $(window).height(); } ProfiTheme.Global.getUniqueId = function() { return parseInt(Math.random() * (9000 - 1000) + 1000) + '-' + parseInt(Math.random() * (9999 - 1000) + 1000); } ProfiTheme.Global.fillTemplate = function( template, vars){ $.each(vars, function(name, value){ value = value || ''; template = template.replace(new RegExp('{{'+ name + '}}', 'g'), value); }); return template; } ProfiTheme.Global.initSettings(); $(window).on("scroll", function () { ProfiTheme.Global.latestKnownScrollY = $('html').scrollTop() || $('body').scrollTop(); }); $(document).ready(function(){ ProfiTheme.Global.setSizes(); }); $(window).on('load', function(){ ProfiTheme.Global.setSizes(); }); $(window).on("resize", function () { ProfiTheme.Global.setSizes(); }); })(jQuery, window);