PageSourceSearch

https://www.funx.nl/scripts/iframeResizer.contentWindow.min.js

js funx.nl collected 2026-10-01 11:33:32 UTC 21,427 bytes, 655 lines download raw bytes

1/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v4.2.11 - 2020-06-02
2 *  Desc: Include this file in any page being loaded into an iframe
3 *        to force the iframe to resize to the content size.
4 *  Requires: iframeResizer.min.js on host page.
5 *  Copyright: (c) 2020 David J. Bradshaw - [email protected]
6 *  License: MIT
7 */
8
9!(function(d) {
10  if ('undefined' != typeof window) {
11    var n = !0,
12      o = 10,
13      i = '',
14      r = 0,
15      a = '',
16      t = null,
17      u = '',
18      c = !1,
19      s = { resize: 1, click: 1 },
20      l = 128,
21      f = !0,
22      m = 1,
23      h = 'bodyOffset',
24      g = h,
25      p = !0,
26      v = '',
27      y = {},
28      b = 32,
29      w = null,
30      T = !1,
31      E = '[iFrameSizer]',
32      O = E.length,
33      S = '',
34      M = { max: 1, min: 1, bodyScroll: 1, documentElementScroll: 1 },
35      I = 'child',
36      N = !0,
37      A = window.parent,
38      C = '*',
39      z = 0,
40      k = !1,
41      e = null,
42      R = 16,
43      x = 1,
44      L = 'scroll',
45      F = L,
46      P = window,
47      D = function() {
48        re('onMessage function not defined');
49      },
50      j = function() {},
51      q = function() {},
52      H = {
53        height: function() {
54          return re('Custom height calculation function not defined'), document.documentElement.offsetHeight;
55        },
56        width: function() {
57          return re('Custom width calculation function not defined'), document.body.scrollWidth;
58        },
59      },
60      W = {},
61      B = !1;
62    try {
63      var J = Object.create(
64        {},
65        {
66          passive: {
67            get: function() {
68              B = !0;
69            },
70          },
71        },
72      );
73      window.addEventListener('test', ee, J), window.removeEventListener('test', ee, J);
74    } catch (e) {}
75    var U,
76      V,
77      K,
78      Q,
79      X,
80      Y,
81      G =
82        Date.now ||
83        function() {
84          return new Date().getTime();
85        },
86      Z = {
87        bodyOffset: function() {
88          return document.body.offsetHeight + pe('marginTop') + pe('marginBottom');
89        },
90        offset: function() {
91          return Z.bodyOffset();
92        },
93        bodyScroll: function() {
94          return document.body.scrollHeight;
95        },
96        custom: function() {
97          return H.height();
98        },
99        documentElementOffset: function() {
100          return document.documentElement.offsetHeight;
101        },
102        documentElementScroll: function() {
103          return document.documentElement.scrollHeight;
104        },
105        max: function() {
106          return Math.max.apply(null, ye(Z));
107        },
108        min: function() {
109          return Math.min.apply(null, ye(Z));
110        },
111        grow: function() {
112          return Z.max();
113        },
114        lowestElement: function() {
115          return Math.max(Z.bodyOffset() || Z.documentElementOffset(), ve('bottom', we()));
116        },
117        taggedElement: function() {
118          return be('bottom', 'data-iframe-height');
119        },
120      },
121      $ = {
122        bodyScroll: function() {
123          return document.body.scrollWidth;
124        },
125        bodyOffset: function() {
126          return document.body.offsetWidth;
127        },
128        custom: function() {
129          return H.width();
130        },
131        documentElementScroll: function() {
132          return document.documentElement.scrollWidth;
133        },
134        documentElementOffset: function() {
135          return document.documentElement.offsetWidth;
136        },
137        scroll: function() {
138          return Math.max($.bodyScroll(), $.documentElementScroll());
139        },
140        max: function() {
141          return Math.max.apply(null, ye($));
142        },
143        min: function() {
144          return Math.min.apply(null, ye($));
145        },
146        rightMostElement: function() {
147          return ve('right', we());
148        },
149        taggedElement: function() {
150          return be('right', 'data-iframe-width');
151        },
152      },
153      _ =
154        ((U = Te),
155        (X = null),
156        (Y = 0),
157        function() {
158          var e = G(),
159            t = R - (e - (Y = Y || e));
160          return (
161            (V = this),
162            (K = arguments),
163            t <= 0 || R < t
164              ? (X && (clearTimeout(X), (X = null)), (Y = e), (Q = U.apply(V, K)), X || (V = K = null))
165              : (X = X || setTimeout(Ee, t)),
166            Q
167          );
168        });
169    te(window, 'message', function(t) {
170      var n = {
171        init: function() {
172          (v = t.data),
173            (A = t.source),
174            ae(),
175            (f = !1),
176            setTimeout(function() {
177              p = !1;
178            }, l);
179        },
180        reset: function() {
181          p ? ie('Page reset ignored by init') : (ie('Page size reset by host page'), Me('resetPage'));
182        },
183        resize: function() {
184          Oe('resizeParent', 'Parent window requested size check');
185        },
186        moveToAnchor: function() {
187          y.findTarget(i());
188        },
189        inPageLink: function() {
190          this.moveToAnchor();
191        },
192        pageInfo: function() {
193          var e = i();
194          ie('PageInfoFromParent called from parent: ' + e), q(JSON.parse(e)), ie(' --');
195        },
196        message: function() {
197          var e = i();
198          ie('onMessage called from parent: ' + e), D(JSON.parse(e)), ie(' --');
199        },
200      };
201      function o() {
202        return t.data.split(']')[1].split(':')[0];
203      }
204      function i() {
205        return t.data.substr(t.data.indexOf(':') + 1);
206      }
207      function r() {
208        return t.data.split(':')[2] in { true: 1, false: 1 };
209      }
210      function e() {
211        var e = o();
212        e in n
213          ? n[e]()
214          : (('undefined' == typeof module || !module.exports) && 'iFrameResize' in window) ||
215            ('jQuery' in window && 'iFrameResize' in window.jQuery.prototype) ||
216            r() ||
217            re('Unexpected message (' + t.data + ')');
218      }
219      E === ('' + t.data).substr(0, O) &&
220        (!1 === f
221          ? e()
222          : r()
223          ? n.init()
224          : ie('Ignored message of type "' + o() + '". Received before initialization.'));
225    }),
226      te(window, 'readystatechange', Ae),
227      Ae();
228  }
229  function ee() {}
230  function te(e, t, n, o) {
231    e.addEventListener(t, n, !!B && (o || {}));
232  }
233  function ne(e) {
234    return e.charAt(0).toUpperCase() + e.slice(1);
235  }
236  function oe(e) {
237    return E + '[' + S + '] ' + e;
238  }
239  function ie(e) {
240    T && 'object' == typeof window.console && console.log(oe(e));
241  }
242  function re(e) {
243    'object' == typeof window.console && console.warn(oe(e));
244  }
245  function ae() {
246    !(function() {
247      function e(e) {
248        return 'true' === e;
249      }
250      var t = v.substr(O).split(':');
251      (S = t[0]),
252        (r = d !== t[1] ? Number(t[1]) : r),
253        (c = d !== t[2] ? e(t[2]) : c),
254        (T = d !== t[3] ? e(t[3]) : T),
255        (b = d !== t[4] ? Number(t[4]) : b),
256        (n = d !== t[6] ? e(t[6]) : n),
257        (a = t[7]),
258        (g = d !== t[8] ? t[8] : g),
259        (i = t[9]),
260        (u = t[10]),
261        (z = d !== t[11] ? Number(t[11]) : z),
262        (y.enable = d !== t[12] && e(t[12])),
263        (I = d !== t[13] ? t[13] : I),
264        (F = d !== t[14] ? t[14] : F);
265    })(),
266      ie('Initialising iFrame (' + location.href + ')'),
267      (function() {
268        function e(e, t) {
269          return 'function' == typeof e && (ie('Setup custom ' + t + 'CalcMethod'), (H[t] = e), (e = 'custom')), e;
270        }
271        'iFrameResizer' in window &&
272          Object === window.iFrameResizer.constructor &&
273          ((function() {
274            var e = window.iFrameResizer;
275            ie('Reading data from page: ' + JSON.stringify(e)),
276              Object.keys(e).forEach(ue, e),
277              (D = 'onMessage' in e ? e.onMessage : D),
278              (j = 'onReady' in e ? e.onReady : j),
279              (C = 'targetOrigin' in e ? e.targetOrigin : C),
280              (g = 'heightCalculationMethod' in e ? e.heightCalculationMethod : g),
281              (F = 'widthCalculationMethod' in e ? e.widthCalculationMethod : F);
282          })(),
283          (g = e(g, 'height')),
284          (F = e(F, 'width')));
285        ie('TargetOrigin for parent set to: ' + C);
286      })(),
287      (function() {
288        d === a && (a = r + 'px');
289        ce(
290          'margin',
291          (function(e, t) {
292            -1 !== t.indexOf('-') && (re('Negative CSS value ignored for ' + e), (t = ''));
293            return t;
294          })('margin', a),
295        );
296      })(),
297      ce('background', i),
298      ce('padding', u),
299      (function() {
300        var e = document.createElement('div');
301        (e.style.clear = 'both'), (e.style.display = 'block'), (e.style.height = '0'), document.body.appendChild(e);
302      })(),
303      fe(),
304      me(),
305      (document.documentElement.style.height = ''),
306      (document.body.style.height = ''),
307      ie('HTML & body height set to "auto"'),
308      ie('Enable public methods'),
309      (P.parentIFrame = {
310        autoResize: function(e) {
311          return (
312            !0 === e && !1 === n
313              ? ((n = !0), he())
314              : !1 === e && !0 === n && ((n = !1), de('remove'), null !== t && t.disconnect(), clearInterval(w)),
315            Ne(0, 0, 'autoResize', JSON.stringify(n)),
316            n
317          );
318        },
319        close: function() {
320          Ne(0, 0, 'close');
321        },
322        getId: function() {
323          return S;
324        },
325        getPageInfo: function(e) {
326          'function' == typeof e ? ((q = e), Ne(0, 0, 'pageInfo')) : ((q = function() {}), Ne(0, 0, 'pageInfoStop'));
327        },
328        moveToAnchor: function(e) {
329          y.findTarget(e);
330        },
331        reset: function() {
332          Ie('parentIFrame.reset');
333        },
334        scrollTo: function(e, t) {
335          Ne(t, e, 'scrollTo');
336        },
337        scrollToOffset: function(e, t) {
338          Ne(t, e, 'scrollToOffset');
339        },
340        sendMessage: function(e, t) {
341          Ne(0, 0, 'message', JSON.stringify(e), t);
342        },
343        setHeightCalculationMethod: function(e) {
344          (g = e), fe();
345        },
346        setWidthCalculationMethod: function(e) {
347          (F = e), me();
348        },
349        setTargetOrigin: function(e) {
350          ie('Set targetOrigin: ' + e), (C = e);
351        },
352        size: function(e, t) {
353          Oe('size', 'parentIFrame.size(' + ((e || '') + (t ? ',' + t : '')) + ')', e, t);
354        },
355      }),
356      he(),
357      (y = (function() {
358        function r(e) {
359          var t = e.getBoundingClientRect(),
360            n = {
361              x: window.pageXOffset !== d ? window.pageXOffset : document.documentElement.scrollLeft,
362              y: window.pageYOffset !== d ? window.pageYOffset : document.documentElement.scrollTop,
363            };
364          return { x: parseInt(t.left, 10) + parseInt(n.x, 10), y: parseInt(t.top, 10) + parseInt(n.y, 10) };
365        }
366        function t(e) {
367          var t,
368            n = e.split('#')[1] || e,
369            o = decodeURIComponent(n),
370            i = document.getElementById(o) || document.getElementsByName(o)[
3700];
371          d !== i
372            ? ((t = r(i)),
373              ie('Moving to in page link (#' + n + ') at x: ' + t.x + ' y: ' + t.y),
374              Ne(t.y, t.x, 'scrollToOffset'))
375            : (ie('In page link (#' + n + ') not found in iFrame, so sending to parent'),
376              Ne(0, 0, 'inPageLink', '#' + n));
377        }
378        function e() {
379          '' !== location.hash && '#' !== location.hash && t(location.href);
380        }
381        function n() {
382          Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'), function(e) {
383            '#' !== e.getAttribute('href') &&
384              te(e, 'click', function(e) {
385                e.preventDefault(), t(this.getAttribute('href'));
386              });
387          });
388        }
389        y.enable
390          ? Array.prototype.forEach && document.querySelectorAll
391            ? (ie('Setting up location.hash handlers'), n(), te(window, 'hashchange', e), setTimeout(e, l))
392            : re('In page linking not fully supported in this browser! (See README.md for IE8 workaround)')
393          : ie('In page linking not enabled');
394        return { findTarget: t };
395      })()),
396      Oe('init', 'Init message from host page'),
397      j();
398  }
399  function ue(e) {
400    var t = e.split('Callback');
401    if (2 === t.length) {
402      var n = 'on' + t[0].charAt(0).toUpperCase() + t[0].slice(1);
403      (this[n] = this[e]),
404        delete this[e],
405        re(
406          "Deprecated: '" +
407            e +
408            "' has been renamed '" +
409            n +
410            "'. The old method will be removed in the next major version.",
411        );
412    }
413  }
414  function ce(e, t) {
415    d !== t && '' !== t && 'null' !== t && ie('Body ' + e + ' set to "' + (document.body.style[e] = t) + '"');
416  }
417  function se(n) {
418    var e = {
419      add: function(e) {
420        function t() {
421          Oe(n.eventName, n.eventType);
422        }
423        (W[e] = t), te(window, e, t, { passive: !0 });
424      },
425      remove: function(e) {
426        var t = W[e];
427        delete W[e],
428          (function(e, t, n) {
429            e.removeEventListener(t, n, !1);
430          })(window, e, t);
431      },
432    };
433    n.eventNames && Array.prototype.map
434      ? ((n.eventName = n.eventNames[0]), n.eventNames.map(e[n.method]))
435      : e[n.method](n.eventName),
436      ie(ne(n.method) + ' event listener: ' + n.eventType);
437  }
438  function de(e) {
439    se({ method: e, eventType: 'Animation Start', eventNames: ['animationstart', 'webkitAnimationStart'] }),
440      se({
441        method: e,
442        eventType: 'Animation Iteration',
443        eventNames: ['animationiteration', 'webkitAnimationIteration'],
444      }),
445      se({ method: e, eventType: 'Animation End', eventNames: ['animationend', 'webkitAnimationEnd'] }),
446      se({ method: e, eventType: 'Input', eventName: 'input' }),
447      se({ method: e, eventType: 'Mouse Up', eventName: 'mouseup' }),
448      se({ method: e, eventType: 'Mouse Down', eventName: 'mousedown' }),
449      se({ method: e, eventType: 'Orientation Change', eventName: 'orientationchange' }),
450      se({ method: e, eventType: 'Print', eventName: ['afterprint', 'beforeprint'] }),
451      se({ method: e, eventType: 'Ready State Change', eventName: 'readystatechange' }),
452      se({ method: e, eventType: 'Touch Start', eventName: 'touchstart' }),
453      se({ method: e, eventType: 'Touch End', eventName: 'touchend' }),
454      se({ method: e, eventType: 'Touch Cancel', eventName: 'touchcancel' }),
455      se({
456        method: e,
457        eventType: 'Transition Start',
458        eventNames: [
459          'transitionstart',
460          'webkitTransitionStart',
461          'MSTransitionStart',
462          'oTransitionStart',
463          'otransitionstart',
464        ],
465      }),
466      se({
467        method: e,
468        eventType: 'Transition Iteration',
469        eventNames: [
470          'transitioniteration',
471          'webkitTransitionIteration',
472          'MSTransitionIteration',
473          'oTransitionIteration',
474          'otransitioniteration',
475        ],
476      }),
477      se({
478        method: e,
479        eventType: 'Transition End',
480        eventNames: ['transitionend', 'webkitTransitionEnd', 'MSTransitionEnd', 'oTransitionEnd', 'otransitionend'],
481      }),
482      'child' === I && se({ method: e, eventType: 'IFrame Resized', eventName: 'resize' });
483  }
484  function le(e, t, n, o) {
485    return (
486      t !== e &&
487        (e in n || (re(e + ' is not a valid option for ' + o + 'CalculationMethod.'), (e = t)),
488        ie(o + ' calculation method set to "' + e + '"')),
489      e
490    );
491  }
492  function fe() {
493    g = le(g, h, Z, 'height');
494  }
495  function me() {
496    F = le(F, L, $, 'width');
497  }
498  function he() {
499    !0 === n
500      ? (de('add'),
501        (function() {
502          var e = b < 0;
503          window.MutationObserver || window.WebKitMutationObserver
504            ? e
505              ? ge()
506              : (t = (function() {
507                  function t(e) {
508                    function t(e) {
509                      !1 === e.complete &&
510                        (ie('Attach listeners to ' + e.src),
511                        e.addEventListener('load', i, !1),
512                        e.addEventListener('error', r, !1),
513                        u.push(e));
514                    }
515                    'attributes' === e.type && 'src' === e.attributeName
516                      ? t(e.target)
517                      : 'childList' === e.type && Array.prototype.forEach.call(e.target.querySelectorAll('img'), t);
518                  }
519                  function o(e) {
520                    ie('Remove listeners from ' + e.src),
521                      e.removeEventListener('load', i, !1),
522                      e.removeEventListener('error', r, !1),
523                      (function(e) {
524                        u.splice(u.indexOf(e), 1);
525                      })(e);
526                  }
527                  function n(e, t, n) {
528                    o(e.target), Oe(t, n + ': ' + e.target.src, d, d);
529                  }
530                  function i(e) {
531                    n(e, 'imageLoad', 'Image loaded');
532                  }
533                  function r(e) {
534                    n(e, 'imageLoadFailed', 'Image load failed');
535                  }
536                  function a(e) {
537                    Oe('mutationObserver', 'mutationObserver: ' + e[0].target + ' ' + e[0].type), e.forEach(t);
538                  }
539                  var u = [],
540                    c = window.MutationObserver || window.WebKitMutationObserver,
541                    s = (function() {
542                      var e = document.querySelector('body');
543                      return (
544                        (s = new c(a)),
545                        ie('Create body MutationObserver'),
546                        s.observe(e, {
547                          attributes: !0,
548                          attributeOldValue: !1,
549                          characterData: !0,
550                          characterDataOldValue: !1,
551                          childList: !0,
552                          subtree: !0,
553                        }),
554                        s
555                      );
556                    })();
557                  return {
558                    disconnect: function() {
559                      'disconnect' in s && (ie('Disconnect body MutationObserver'), s.disconnect(), u.forEach(o));
560                    },
561                  };
562                })())
563            : (ie('MutationObserver not supported in this browser!'), ge());
564        })())
565      : ie('Auto Resize disabled');
566  }
567  function ge() {
568    0 !== b &&
569      (ie('setInterval: ' + b + 'ms'),
570      (w = setInterval(function() {
571        Oe('interval', 'setInterval: ' + b);
572      }, Math.abs(b))));
573  }
574  function pe(e, t) {
575    var n = 0;
576    return (
577      (t = t || document.body),
578      (n = null !== (n = document.defaultView.getComputedStyle(t, null)) ? n[e] : 0),
579      parseInt(n, o)
580    );
581  }
582  function ve(e, t) {
583    for (var n = t.length, o = 0, i = 0, r = ne(e), a = G(), u = 0; u < n; u++)
584      i < (o = t[u].getBoundingClientRect()[e] + pe('margin' + r, t[u])) && (i = o);
585    return (
586      (a = G() - a),
587      ie('Parsed ' + n + ' HTML elements'),
588      ie('Element position calculated in ' + a + 'ms'),
589      (function(e) {
590        R / 2 < e && ie('Event throttle increased to ' + (R = 2 * e) + 'ms');
591      })(a),
592      i
593    );
594  }
595  function ye(e) {
596    return [e.bodyOffset(), e.bodyScroll(), e.documentElementOffset(), e.documentElementScroll()];
597  }
598  function be(e, t) {
599    var n = document.querySelectorAll('[' + t + ']');
600    return (
601      0 === n.length && (re('No tagged elements (' + t + ') found on page'), document.querySelectorAll('body *')),
602      ve(e, n)
603    );
604  }
605  function we() {
606    return document.querySelectorAll('body *');
607  }
608  function Te(e, t, n, o) {
609    var i, r;
610    function a(e, t) {
611      return !(Math.abs(e - t) <= z);
612    }
613    (i = d !== n ? n : Z[g]()),
614      (r = d !== o ? o : $[F]()),
615      a(m, i) || (c && a(x, r)) || 'init' === e
616        ? (Se(), Ne((m = i), (x = r), e))
617        : e in { init: 1, interval: 1, size: 1 } || !(g in M || (c && F in M))
618        ? e in { interval: 1 } || ie('No change in size detected')
619        : Ie(t);
620  }
621  function Ee() {
622    (Y = G()), (X = null), (Q = U.apply(V, K)), X || (V = K = null);
623  }
624  function Oe(e, t, n, o) {
625    k && e in s
626      ? ie('Trigger event cancelled: ' + e)
627      : (e in { reset: 1, resetPage: 1, init: 1 } || ie('Trigger event: ' + t),
628        'init' === e ? Te(e, t, n, o) : _(e, t, n, o));
629  }
630  function Se() {
631    k || ((k = !0), ie('Trigger event lock on')),
632      clearTimeout(e),
633      (e = setTimeout(function() {
634        (k = !1), ie('Trigger event lock off'), ie('--');
635      }, l));
636  }
637  function Me(e) {
638    (m = Z[g]()), (x = $[F]()), Ne(m, x, e);
639  }
640  function Ie(e) {
641    var t = g;
642    (g = h), ie('Reset trigger event: ' + e), Se(), Me('reset'), (g = t);
643  }
644  function Ne(e, t, n, o, i) {
645    var r;
646    !0 === N &&
647      (d === i ? (i = C) : ie('Message targetOrigin: ' + i),
648      ie('Sending message to host page (' + (r = S + ':' + (e + ':' + t) + ':' + n + (d !== o ? ':' + o : '')) + ')'),
649      A.postMessage(E + r, i));
650  }
651  function Ae() {
652    'loading' !== document.readyState && window.parent.postMessage('[iFrameResizerChild]Ready', '*');
653  }
654})();
655//# sourceMappingURL=iframeResizer.contentWindow.map

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.