PageSourceSearch

https://www.topeleven.com/community/wp-content/themes/Nordeus/fram…iewport-units-buggyfill.hacks.js?ver=4.7.24

js topeleven.com collected 2026-09-24 09:08:23 UTC 3,441 bytes, 118 lines download raw bytes

1/*!
2 * viewport-units-buggyfill.hacks v0.5.5
3 * @web: https://github.com/rodneyrehm/viewport-units-buggyfill/
4 * @author: Zoltan Hawryluk - http://www.useragentman.com/
5 */
6
7(function (root, factory) {
8  'use strict';
9  if (typeof define === 'function' && define.amd) {
10    // AMD. Register as an anonymous module.
11    define([], factory);
12  } else if (typeof exports === 'object') {
13    // Node. Does not work with strict CommonJS, but
14    // only CommonJS-like enviroments that support module.exports,
15    // like Node.
16    module.exports = factory();
17  } else {
18    // Browser globals (root is window)
19    root.viewportUnitsBuggyfillHacks = factory();
20  }
21}(this, function () {
22  'use strict';
23
24  var options;
25  var calcExpression = /calc\(/g;
26  var quoteExpression = /[\"\']/g;
27  var urlExpression = /url\([^\)]*\)/g;
28  var userAgent = window.navigator.userAgent;
29  var isBuggyIE = /MSIE [0-9]\./i.test(userAgent);
30  var isOldIE = /MSIE [0-8]\./i.test(userAgent);
31  var supportsVminmax = true;
32  var supportsVminmaxCalc = true;
33
34  if (isBuggyIE === true) {
35    supportsVminmaxCalc = false;
36    supportsVminmax = false;
37  }
38
39  // iOS SAFARI, IE9, or Stock Android: abuse "content" if "viewport-units-buggyfill" specified
40  function checkHacks(declarations, rule, name, value) {
41    var needsHack = name === 'content' && value.indexOf('viewport-units-buggyfill') > -1;
42    if (!needsHack) {
43      return;
44    }
45
46    var fakeRules = value.replace(quoteExpression, '');
47    fakeRules.split(';').forEach(function(fakeRuleElement) {
48      var fakeRule = fakeRuleElement.split(':');
49      if (fakeRule.length !== 2) {
50        return;
51      }
52
53      var name = fakeRule[0].trim();
54      if (name === 'viewport-units-buggyfill') {
55        return;
56      }
57
58      var value = fakeRule[1].trim();
59      declarations.push([rule, name, value]);
60      if (calcExpression.test(value)) {
61        var webkitValue = value.replace(calcExpression, '-webkit-calc(');
62        declarations.push([rule, name, webkitValue]);
63      }
64    });
65  }
66
67  return {
68    required: function(options) {
69      return options.isMobileSafari || isBuggyIE;
70    },
71
72    initialize: function(initOptions) {
73      options = initOptions;
74
75      // Test viewport units support in calc() expressions
76      var div = document.createElement('div');
77      div.style.width = '1vmax';
78      supportsVminmax = div.style.width !== '';
79
80      // there is no accurate way to detect this programmatically.
81      if (options.isMobileSafari || options.isBadStockAndroid) {
82        supportsVminmaxCalc = false;
83      }
84
85    },
86
87    initializeEvents: function(options, refresh, _refresh) {
88      if (options.force) {
89        return;
90      }
91
92      if (isBuggyIE && !options._listeningToResize) {
93        window.addEventListener('resize', _refresh, true);
94        options._listeningToResize = true;
95      }
96    },
97
98    findDeclarations: function(declarations, rule, name, value) {
99      if (name === null) {
100        // KeyframesRule does not have a CSS-PropertyName
101        return;
102      }
103
104      checkHacks(declarations, rule, name, value);
105    },
106
107    overwriteDeclaration: function(rule, name, _value) {
108      if (isBuggyIE && name === 'filter') {
109        // remove unit "px" from complex value, e.g.:
110        // filter: progid:DXImageTransform.Microsoft.DropShadow(OffX=5.4px, OffY=3.9px, Color=#000000);
111        _value = _value.replace(/px/g, '');
112      }
113
114      return _value;
115    }
116  };
117
118}));

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.