/*! * viewport-units-buggyfill v0.4.1 * @web: https://github.com/rodneyrehm/viewport-units-buggyfill/ * @author: Rodney Rehm - http://rodneyrehm.de/en/ */ (function (root, factory) { 'use strict'; if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define([], factory); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but // only CommonJS-like enviroments that support module.exports, // like Node. module.exports = factory(); } else { // Browser globals (root is window) root.viewportUnitsBuggyfill = factory(); } }(this, function () { 'use strict'; /*global document, window, location, XMLHttpRequest, XDomainRequest*/ var initialized = false; var options; var isMobileSafari = /(iPhone|iPod|iPad).+AppleWebKit/i.test(window.navigator.userAgent); var viewportUnitExpression = /([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g; var forEach = [].forEach; var dimensions; var declarations; var styleNode; var isOldInternetExplorer = false; // Do not remove the following comment! // It is a conditional comment used to // identify old Internet Explorer versions /*@cc_on @if (@_jscript_version <= 10) isOldInternetExplorer = true; @end @*/ function debounce(func, wait) { var timeout; return function() { var context = this; var args = arguments; var callback = function() { func.apply(context, args); }; clearTimeout(timeout); timeout = setTimeout(callback, wait); }; } // from http://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t function inIframe() { try { return window.self !== window.top; } catch (e) { return true; } } function initialize(initOptions) { if (initialized) { return; } if (initOptions === true) { initOptions = { force: true }; } options = initOptions || {}; options.isMobileSafari = isMobileSafari; if (!options.force && !isMobileSafari && !isOldInternetExplorer && (!options.hacks || !options.hacks.required(options))) { // this buggyfill only applies to mobile safari return; } options.hacks && options.hacks.initialize(options); initialized = true; styleNode = document.createElement('style'); styleNode.id = 'patched-viewport'; document.head.appendChild(styleNode); // Issue #6: Cross Origin Stylesheets are not accessible through CSSOM, // therefore download and inject them as