@iframe-resizer/child 5.0.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/iframe-resizer.child.d.ts +7 -2
- package/index.cjs.js +2 -1288
- package/index.esm.js +2 -1286
- package/index.umd.js +2 -1293
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/child 5.0
|
|
4
|
+
* @module iframe-resizer/child 5.1.0 (cjs) - 2024-06-18
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,1290 +17,4 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
'use strict';
|
|
21
|
-
|
|
22
|
-
const VERSION = '5.0.2';
|
|
23
|
-
|
|
24
|
-
const BASE = 10;
|
|
25
|
-
const SIZE_ATTR = 'data-iframe-size';
|
|
26
|
-
|
|
27
|
-
const encode = (s) =>
|
|
28
|
-
s
|
|
29
|
-
.replaceAll('<br>', '\n')
|
|
30
|
-
.replaceAll('<rb>', '\u001B[31;1m')
|
|
31
|
-
.replaceAll('</>', '\u001B[m')
|
|
32
|
-
.replaceAll('<b>', '\u001B[1m')
|
|
33
|
-
.replaceAll('<i>', '\u001B[3m')
|
|
34
|
-
.replaceAll('<u>', '\u001B[4m');
|
|
35
|
-
|
|
36
|
-
const remove = (s) => s.replaceAll('<br>', '\n').replaceAll(/<[/a-z]+>/gi, '');
|
|
37
|
-
|
|
38
|
-
const formatAdvise = (formatLogMsg) => (msg) =>
|
|
39
|
-
window.chrome // Only show formatting in Chrome as not supported in other browsers
|
|
40
|
-
? formatLogMsg(encode(msg))
|
|
41
|
-
: formatLogMsg(remove(msg));
|
|
42
|
-
|
|
43
|
-
const addEventListener = (el, evt, func, options) =>
|
|
44
|
-
el.addEventListener(evt, func, options || false);
|
|
45
|
-
|
|
46
|
-
const removeEventListener = (el, evt, func) =>
|
|
47
|
-
el.removeEventListener(evt, func, false);
|
|
48
|
-
|
|
49
|
-
const p = (l) =>
|
|
50
|
-
l.replaceAll(/[A-Za-z]/g, (l) =>
|
|
51
|
-
String.fromCodePoint(
|
|
52
|
-
(l <= 'Z' ? 90 : 122) >= (l = l.codePointAt(0) + 19) ? l : l - 26,
|
|
53
|
-
),
|
|
54
|
-
),
|
|
55
|
-
y = [
|
|
56
|
-
'<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>',
|
|
57
|
-
'<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>',
|
|
58
|
-
'Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>',
|
|
59
|
-
'<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.',
|
|
60
|
-
];
|
|
61
|
-
Object.fromEntries(
|
|
62
|
-
[
|
|
63
|
-
'2cgs7fdf4xb',
|
|
64
|
-
'1c9ctcccr4z',
|
|
65
|
-
'1q2pc4eebgb',
|
|
66
|
-
'ueokt0969w',
|
|
67
|
-
'w2zxchhgqz',
|
|
68
|
-
'1umuxblj2e5',
|
|
69
|
-
].map((l, p) => [l, Math.max(0, p - 1)]),
|
|
70
|
-
);
|
|
71
|
-
const getModeData = (l) => p(y[l]);
|
|
72
|
-
|
|
73
|
-
const checkVisibilityOptions = {
|
|
74
|
-
contentVisibilityAuto: true,
|
|
75
|
-
opacityProperty: true,
|
|
76
|
-
visibilityProperty: true,
|
|
77
|
-
};
|
|
78
|
-
const customCalcMethods = {
|
|
79
|
-
height: () => {
|
|
80
|
-
warn('Custom height calculation function not defined');
|
|
81
|
-
return getHeight.auto()
|
|
82
|
-
},
|
|
83
|
-
width: () => {
|
|
84
|
-
warn('Custom width calculation function not defined');
|
|
85
|
-
return getWidth.auto()
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
const deprecatedResizeMethods = {
|
|
89
|
-
bodyOffset: 1,
|
|
90
|
-
bodyScroll: 1,
|
|
91
|
-
offset: 1,
|
|
92
|
-
documentElementOffset: 1,
|
|
93
|
-
documentElementScroll: 1,
|
|
94
|
-
documentElementBoundingClientRect: 1,
|
|
95
|
-
max: 1,
|
|
96
|
-
min: 1,
|
|
97
|
-
grow: 1,
|
|
98
|
-
lowestElement: 1,
|
|
99
|
-
};
|
|
100
|
-
const eventCancelTimer = 128;
|
|
101
|
-
const eventHandlersByName = {};
|
|
102
|
-
const hasCheckVisibility = 'checkVisibility' in window;
|
|
103
|
-
const heightCalcModeDefault = 'auto';
|
|
104
|
-
const msgID = '[iFrameSizer]'; // Must match host page msg ID
|
|
105
|
-
const msgIdLen = msgID.length;
|
|
106
|
-
const resetRequiredMethods = {
|
|
107
|
-
max: 1,
|
|
108
|
-
min: 1,
|
|
109
|
-
bodyScroll: 1,
|
|
110
|
-
documentElementScroll: 1,
|
|
111
|
-
};
|
|
112
|
-
const resizeObserveTargets = ['body'];
|
|
113
|
-
const widthCalcModeDefault = 'scroll';
|
|
114
|
-
|
|
115
|
-
let autoResize = true;
|
|
116
|
-
let bodyBackground = '';
|
|
117
|
-
let bodyMargin = 0;
|
|
118
|
-
let bodyMarginStr = '';
|
|
119
|
-
let bodyObserver = null;
|
|
120
|
-
let bodyPadding = '';
|
|
121
|
-
let calculateHeight = true;
|
|
122
|
-
let calculateWidth = false;
|
|
123
|
-
let calcElements = null;
|
|
124
|
-
let firstRun = true;
|
|
125
|
-
let hasTags = false;
|
|
126
|
-
let height = 1;
|
|
127
|
-
let heightCalcMode = heightCalcModeDefault; // only applys if not provided by host page (V1 compatibility)
|
|
128
|
-
let initLock = true;
|
|
129
|
-
let initMsg = '';
|
|
130
|
-
let inPageLinks = {};
|
|
131
|
-
let isInit = true;
|
|
132
|
-
let logging = false;
|
|
133
|
-
let mode = 0;
|
|
134
|
-
let mouseEvents = false;
|
|
135
|
-
let myID = '';
|
|
136
|
-
let offsetHeight;
|
|
137
|
-
let offsetWidth;
|
|
138
|
-
let resizeFrom = 'child';
|
|
139
|
-
let resizeObserver = null;
|
|
140
|
-
let sameDomain = false;
|
|
141
|
-
let target = window.parent;
|
|
142
|
-
let targetOriginDefault = '*';
|
|
143
|
-
let tolerance = 0;
|
|
144
|
-
let triggerLocked = false;
|
|
145
|
-
let version = '';
|
|
146
|
-
let width = 1;
|
|
147
|
-
let widthCalcMode = widthCalcModeDefault;
|
|
148
|
-
let win = window;
|
|
149
|
-
|
|
150
|
-
let onMessage = () => {
|
|
151
|
-
warn('onMessage function not defined');
|
|
152
|
-
};
|
|
153
|
-
let onReady = () => {};
|
|
154
|
-
let onPageInfo = null;
|
|
155
|
-
let onParentInfo = null;
|
|
156
|
-
|
|
157
|
-
const capitalizeFirstLetter = (string) =>
|
|
158
|
-
string.charAt(0).toUpperCase() + string.slice(1);
|
|
159
|
-
|
|
160
|
-
const isDef = (value) => `${value}` !== '' && value !== undefined;
|
|
161
|
-
|
|
162
|
-
function getElementName(el) {
|
|
163
|
-
switch (true) {
|
|
164
|
-
case !isDef(el):
|
|
165
|
-
return ''
|
|
166
|
-
|
|
167
|
-
case isDef(el.id):
|
|
168
|
-
return `${el.nodeName.toUpperCase()}#${el.id}`
|
|
169
|
-
|
|
170
|
-
case isDef(el.name):
|
|
171
|
-
return `${el.nodeName.toUpperCase()} (${el.name})`
|
|
172
|
-
|
|
173
|
-
default:
|
|
174
|
-
return (
|
|
175
|
-
el.nodeName.toUpperCase() +
|
|
176
|
-
(isDef(el.className) ? `.${el.className}` : '')
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function elementSnippet(el) {
|
|
182
|
-
const outer = el?.outerHTML?.toString();
|
|
183
|
-
|
|
184
|
-
if (!outer) return el
|
|
185
|
-
|
|
186
|
-
return outer.length < 30
|
|
187
|
-
? outer
|
|
188
|
-
: `${outer.slice(0, 30).replaceAll('\n', ' ')}...`
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// TODO: remove .join(' '), requires major test updates
|
|
192
|
-
const formatLogMsg = (...msg) => [`[iframe-resizer][${myID}]`, ...msg].join(' ');
|
|
193
|
-
|
|
194
|
-
// const info = (...msg) =>
|
|
195
|
-
// // eslint-disable-next-line no-console
|
|
196
|
-
// console?.info(formatAdvise(...msg))
|
|
197
|
-
|
|
198
|
-
const warn = (...msg) =>
|
|
199
|
-
// eslint-disable-next-line no-console
|
|
200
|
-
console?.warn(formatLogMsg(...msg));
|
|
201
|
-
|
|
202
|
-
const advise = (...msg) =>
|
|
203
|
-
// eslint-disable-next-line no-console
|
|
204
|
-
console?.warn(formatAdvise(formatLogMsg)(...msg));
|
|
205
|
-
|
|
206
|
-
const adviser = (msg) => advise(msg);
|
|
207
|
-
|
|
208
|
-
function init() {
|
|
209
|
-
checkCrossDomain();
|
|
210
|
-
readDataFromParent();
|
|
211
|
-
readDataFromPage();
|
|
212
|
-
setMargin();
|
|
213
|
-
setBodyStyle('background', bodyBackground);
|
|
214
|
-
setBodyStyle('padding', bodyPadding);
|
|
215
|
-
injectClearFixIntoBodyElement();
|
|
216
|
-
stopInfiniteResizingOfIFrame();
|
|
217
|
-
checkMode();
|
|
218
|
-
checkVersion();
|
|
219
|
-
checkHeightMode();
|
|
220
|
-
checkWidthMode();
|
|
221
|
-
checkDeprecatedAttrs();
|
|
222
|
-
checkHasDataSizeAttributes();
|
|
223
|
-
setupCalcElements();
|
|
224
|
-
setupPublicMethods();
|
|
225
|
-
setupMouseEvents();
|
|
226
|
-
startEventListeners();
|
|
227
|
-
inPageLinks = setupInPageLinks();
|
|
228
|
-
sendSize('init', 'Init message from host page', undefined, undefined, VERSION);
|
|
229
|
-
onReady();
|
|
230
|
-
isInit = false;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function checkVersion() {
|
|
234
|
-
if (!version || version === '' || version === 'false') {
|
|
235
|
-
advise(
|
|
236
|
-
`<rb>Legacy version detected on parent page</>
|
|
237
|
-
|
|
238
|
-
Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
|
|
239
|
-
|
|
240
|
-
See <u>https://iframe-resizer.com/setup/<u> for more details.
|
|
241
|
-
`,
|
|
242
|
-
);
|
|
243
|
-
return
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (version !== VERSION) {
|
|
247
|
-
advise(
|
|
248
|
-
`<rb>Version mismatch</>
|
|
249
|
-
|
|
250
|
-
The parent and child pages are running different versions of <i>iframe resizer</>.
|
|
251
|
-
|
|
252
|
-
Parent page: ${version} - Child page: ${VERSION}.
|
|
253
|
-
`,
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function checkCrossDomain() {
|
|
259
|
-
try {
|
|
260
|
-
sameDomain = 'iframeParentListener' in window.parent;
|
|
261
|
-
} catch (error) {
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function readDataFromParent() {
|
|
266
|
-
const strBool = (str) => str === 'true';
|
|
267
|
-
const data = initMsg.slice(msgIdLen).split(':');
|
|
268
|
-
|
|
269
|
-
myID = data[0]; // eslint-disable-line prefer-destructuring
|
|
270
|
-
bodyMargin = undefined === data[1] ? bodyMargin : Number(data[1]); // For V1 compatibility
|
|
271
|
-
calculateWidth = undefined === data[2] ? calculateWidth : strBool(data[2]);
|
|
272
|
-
logging = undefined === data[3] ? logging : strBool(data[3]);
|
|
273
|
-
// data[4] no longer used (was intervalTimer)
|
|
274
|
-
autoResize = undefined === data[6] ? autoResize : strBool(data[6]);
|
|
275
|
-
bodyMarginStr = data[7]; // eslint-disable-line prefer-destructuring
|
|
276
|
-
heightCalcMode = undefined === data[8] ? heightCalcMode : data[8];
|
|
277
|
-
bodyBackground = data[9]; // eslint-disable-line prefer-destructuring
|
|
278
|
-
bodyPadding = data[10]; // eslint-disable-line prefer-destructuring
|
|
279
|
-
tolerance = undefined === data[11] ? tolerance : Number(data[11]);
|
|
280
|
-
inPageLinks.enable = undefined === data[12] ? false : strBool(data[12]);
|
|
281
|
-
resizeFrom = undefined === data[13] ? resizeFrom : data[13];
|
|
282
|
-
widthCalcMode = undefined === data[14] ? widthCalcMode : data[14];
|
|
283
|
-
mouseEvents = undefined === data[15] ? mouseEvents : strBool(data[15]);
|
|
284
|
-
offsetHeight = undefined === data[16] ? offsetHeight : Number(data[16]);
|
|
285
|
-
offsetWidth = undefined === data[17] ? offsetWidth : Number(data[17]);
|
|
286
|
-
calculateHeight = undefined === data[18] ? calculateHeight : strBool(data[18]);
|
|
287
|
-
data[19]; // eslint-disable-line prefer-destructuring
|
|
288
|
-
version = data[20] || version;
|
|
289
|
-
mode = undefined === data[21] ? mode : Number(data[21]);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function readDataFromPage() {
|
|
293
|
-
function readData() {
|
|
294
|
-
const data = window.iframeResizer || window.iFrameResizer;
|
|
295
|
-
|
|
296
|
-
onMessage = data?.onMessage || onMessage;
|
|
297
|
-
onReady = data?.onReady || onReady;
|
|
298
|
-
|
|
299
|
-
if (typeof data?.offset === 'number') {
|
|
300
|
-
if (calculateHeight) offsetHeight = data?.offset;
|
|
301
|
-
if (calculateWidth) offsetWidth = data?.offset;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
targetOriginDefault = data?.targetOrigin || targetOriginDefault;
|
|
305
|
-
heightCalcMode = data?.heightCalculationMethod || heightCalcMode;
|
|
306
|
-
widthCalcMode = data?.widthCalculationMethod || widthCalcMode;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function setupCustomCalcMethods(calcMode, calcFunc) {
|
|
310
|
-
if (typeof calcMode === 'function') {
|
|
311
|
-
customCalcMethods[calcFunc] = calcMode;
|
|
312
|
-
calcMode = 'custom';
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return calcMode
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (mode === 1) return
|
|
319
|
-
|
|
320
|
-
if (
|
|
321
|
-
'iFrameResizer' in window &&
|
|
322
|
-
Object === window.iFrameResizer.constructor
|
|
323
|
-
) {
|
|
324
|
-
readData();
|
|
325
|
-
heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height');
|
|
326
|
-
widthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width');
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
function chkCSS(attr, value) {
|
|
331
|
-
if (value.includes('-')) {
|
|
332
|
-
warn(`Negative CSS value ignored for ${attr}`);
|
|
333
|
-
value = '';
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return value
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function setBodyStyle(attr, value) {
|
|
340
|
-
if (undefined !== value && value !== '' && value !== 'null') {
|
|
341
|
-
document.body.style.setProperty(attr, value);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function setMargin() {
|
|
346
|
-
// If called via V1 script, convert bodyMargin from int to str
|
|
347
|
-
if (undefined === bodyMarginStr) {
|
|
348
|
-
bodyMarginStr = `${bodyMargin}px`;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
setBodyStyle('margin', chkCSS('margin', bodyMarginStr));
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function stopInfiniteResizingOfIFrame() {
|
|
355
|
-
const setAutoHeight = (el) =>
|
|
356
|
-
el.style.setProperty('height', 'auto', 'important');
|
|
357
|
-
|
|
358
|
-
setAutoHeight(document.documentElement);
|
|
359
|
-
setAutoHeight(document.body);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function manageTriggerEvent(options) {
|
|
363
|
-
const listener = {
|
|
364
|
-
add(eventName) {
|
|
365
|
-
function handleEvent() {
|
|
366
|
-
sendSize(options.eventName, options.eventType);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
eventHandlersByName[eventName] = handleEvent;
|
|
370
|
-
|
|
371
|
-
addEventListener(window, eventName, handleEvent, { passive: true });
|
|
372
|
-
},
|
|
373
|
-
remove(eventName) {
|
|
374
|
-
const handleEvent = eventHandlersByName[eventName];
|
|
375
|
-
delete eventHandlersByName[eventName];
|
|
376
|
-
|
|
377
|
-
removeEventListener(window, eventName, handleEvent);
|
|
378
|
-
},
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
listener[options.method](options.eventName);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function manageEventListeners(method) {
|
|
385
|
-
manageTriggerEvent({
|
|
386
|
-
method,
|
|
387
|
-
eventType: 'After Print',
|
|
388
|
-
eventName: 'afterprint',
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
manageTriggerEvent({
|
|
392
|
-
method,
|
|
393
|
-
eventType: 'Before Print',
|
|
394
|
-
eventName: 'beforeprint',
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
manageTriggerEvent({
|
|
398
|
-
method,
|
|
399
|
-
eventType: 'Ready State Change',
|
|
400
|
-
eventName: 'readystatechange',
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
// manageTriggerEvent({
|
|
404
|
-
// method: method,
|
|
405
|
-
// eventType: 'Orientation Change',
|
|
406
|
-
// eventName: 'orientationchange'
|
|
407
|
-
// })
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
function checkDeprecatedAttrs() {
|
|
411
|
-
let found = false;
|
|
412
|
-
|
|
413
|
-
const checkAttrs = (attr) =>
|
|
414
|
-
document.querySelectorAll(`[${attr}]`).forEach((el) => {
|
|
415
|
-
found = true;
|
|
416
|
-
el.removeAttribute(attr);
|
|
417
|
-
el.setAttribute(SIZE_ATTR, null);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
checkAttrs('data-iframe-height');
|
|
421
|
-
checkAttrs('data-iframe-width');
|
|
422
|
-
|
|
423
|
-
if (found) {
|
|
424
|
-
advise(
|
|
425
|
-
`<rb>Deprecated Attributes</>
|
|
426
|
-
|
|
427
|
-
The <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.`,
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
function checkHasDataSizeAttributes() {
|
|
433
|
-
if (document.querySelectorAll(`[${SIZE_ATTR}]`).length > 0) {
|
|
434
|
-
if (heightCalcMode === 'auto') {
|
|
435
|
-
heightCalcMode = 'autoOverflow';
|
|
436
|
-
}
|
|
437
|
-
if (widthCalcMode === 'auto') {
|
|
438
|
-
widthCalcMode = 'autoOverflow';
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function setupCalcElements() {
|
|
444
|
-
const taggedElements = document.querySelectorAll(`[${SIZE_ATTR}]`);
|
|
445
|
-
hasTags = taggedElements.length > 0;
|
|
446
|
-
calcElements = hasTags ? taggedElements : getAllElements(document)();
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function checkCalcMode(calcMode, calcModeDefault, modes, type) {
|
|
450
|
-
if (calcModeDefault !== calcMode) {
|
|
451
|
-
if (!(calcMode in modes)) {
|
|
452
|
-
warn(`${calcMode} is not a valid option for ${type}CalculationMethod.`);
|
|
453
|
-
calcMode = calcModeDefault;
|
|
454
|
-
}
|
|
455
|
-
if (calcMode in deprecatedResizeMethods) {
|
|
456
|
-
advise(
|
|
457
|
-
`<rb>Deprecated ${type}CalculationMethod (${calcMode})</>
|
|
458
|
-
|
|
459
|
-
This version of <i>iframe-resizer</> can auto detect the most suitable ${type} calculation method. It is recommended that you remove this option.`,
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
return calcMode
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
function checkHeightMode() {
|
|
468
|
-
heightCalcMode = checkCalcMode(
|
|
469
|
-
heightCalcMode,
|
|
470
|
-
heightCalcModeDefault,
|
|
471
|
-
getHeight,
|
|
472
|
-
'height',
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
function checkWidthMode() {
|
|
477
|
-
widthCalcMode = checkCalcMode(
|
|
478
|
-
widthCalcMode,
|
|
479
|
-
widthCalcModeDefault,
|
|
480
|
-
getWidth,
|
|
481
|
-
'width',
|
|
482
|
-
);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
function checkMode() {
|
|
486
|
-
if (mode < 0) return adviser(`${getModeData(mode + 2)}${getModeData(2)}`)
|
|
487
|
-
if (version.codePointAt(0) > 4) return mode
|
|
488
|
-
if (mode < 2) return adviser(getModeData(3))
|
|
489
|
-
return mode
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function startEventListeners() {
|
|
493
|
-
if (autoResize !== true) {
|
|
494
|
-
return
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
manageEventListeners('add');
|
|
498
|
-
setupMutationObserver();
|
|
499
|
-
setupResizeObserver();
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function stopEventListeners() {
|
|
503
|
-
manageEventListeners('remove');
|
|
504
|
-
resizeObserver?.disconnect();
|
|
505
|
-
bodyObserver?.disconnect();
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function injectClearFixIntoBodyElement() {
|
|
509
|
-
const clearFix = document.createElement('div');
|
|
510
|
-
|
|
511
|
-
clearFix.style.clear = 'both';
|
|
512
|
-
// Guard against the following having been globally redefined in CSS.
|
|
513
|
-
clearFix.style.display = 'block';
|
|
514
|
-
clearFix.style.height = '0';
|
|
515
|
-
document.body.append(clearFix);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function setupInPageLinks() {
|
|
519
|
-
const getPagePosition = () => ({
|
|
520
|
-
x: document.documentElement.scrollLeft,
|
|
521
|
-
y: document.documentElement.scrollTop,
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
function getElementPosition(el) {
|
|
525
|
-
const elPosition = el.getBoundingClientRect();
|
|
526
|
-
const pagePosition = getPagePosition();
|
|
527
|
-
|
|
528
|
-
return {
|
|
529
|
-
x: parseInt(elPosition.left, BASE) + parseInt(pagePosition.x, BASE),
|
|
530
|
-
y: parseInt(elPosition.top, BASE) + parseInt(pagePosition.y, BASE),
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
function findTarget(location) {
|
|
535
|
-
function jumpToTarget(target) {
|
|
536
|
-
const jumpPosition = getElementPosition(target);
|
|
537
|
-
|
|
538
|
-
sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
const hash = location.split('#')[1] || location; // Remove # if present
|
|
542
|
-
const hashData = decodeURIComponent(hash);
|
|
543
|
-
const target =
|
|
544
|
-
document.getElementById(hashData) ||
|
|
545
|
-
document.getElementsByName(hashData)[0];
|
|
546
|
-
|
|
547
|
-
if (target !== undefined) {
|
|
548
|
-
jumpToTarget(target);
|
|
549
|
-
return
|
|
550
|
-
}
|
|
551
|
-
sendMsg(0, 0, 'inPageLink', `#${hash}`);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function checkLocationHash() {
|
|
555
|
-
const { hash, href } = window.location;
|
|
556
|
-
|
|
557
|
-
if (hash !== '' && hash !== '#') {
|
|
558
|
-
findTarget(href);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
function bindAnchors() {
|
|
563
|
-
function setupLink(el) {
|
|
564
|
-
function linkClicked(e) {
|
|
565
|
-
e.preventDefault();
|
|
566
|
-
|
|
567
|
-
findTarget(this.getAttribute('href'));
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (el.getAttribute('href') !== '#') {
|
|
571
|
-
addEventListener(el, 'click', linkClicked);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
document.querySelectorAll('a[href^="#"]').forEach(setupLink);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
function bindLocationHash() {
|
|
579
|
-
addEventListener(window, 'hashchange', checkLocationHash);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
function initCheck() {
|
|
583
|
-
// Check if page loaded with location hash after init resize
|
|
584
|
-
setTimeout(checkLocationHash, eventCancelTimer);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
function enableInPageLinks() {
|
|
588
|
-
bindAnchors();
|
|
589
|
-
bindLocationHash();
|
|
590
|
-
initCheck();
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if (inPageLinks.enable) {
|
|
594
|
-
if (mode === 1) {
|
|
595
|
-
advise(
|
|
596
|
-
`In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details.`,
|
|
597
|
-
);
|
|
598
|
-
} else {
|
|
599
|
-
enableInPageLinks();
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
return {
|
|
604
|
-
findTarget,
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function setupMouseEvents() {
|
|
609
|
-
if (mouseEvents !== true) return
|
|
610
|
-
|
|
611
|
-
function sendMouse(e) {
|
|
612
|
-
sendMsg(0, 0, e.type, `${e.screenY}:${e.screenX}`);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
function addMouseListener(evt, name) {
|
|
616
|
-
addEventListener(window.document, evt, sendMouse);
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
addMouseListener('mouseenter');
|
|
620
|
-
addMouseListener('mouseleave');
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
function setupPublicMethods() {
|
|
624
|
-
if (mode === 1) return
|
|
625
|
-
|
|
626
|
-
win.parentIframe = Object.freeze({
|
|
627
|
-
autoResize: (resize) => {
|
|
628
|
-
if (resize === true && autoResize === false) {
|
|
629
|
-
autoResize = true;
|
|
630
|
-
startEventListeners();
|
|
631
|
-
} else if (resize === false && autoResize === true) {
|
|
632
|
-
autoResize = false;
|
|
633
|
-
stopEventListeners();
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
sendMsg(0, 0, 'autoResize', JSON.stringify(autoResize));
|
|
637
|
-
|
|
638
|
-
return autoResize
|
|
639
|
-
},
|
|
640
|
-
|
|
641
|
-
close() {
|
|
642
|
-
sendMsg(0, 0, 'close');
|
|
643
|
-
},
|
|
644
|
-
|
|
645
|
-
getId: () => myID,
|
|
646
|
-
|
|
647
|
-
getPageInfo(callback) {
|
|
648
|
-
if (typeof callback === 'function') {
|
|
649
|
-
onPageInfo = callback;
|
|
650
|
-
sendMsg(0, 0, 'pageInfo');
|
|
651
|
-
advise(
|
|
652
|
-
`<rb>Deprecated Method</>
|
|
653
|
-
|
|
654
|
-
The <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProperties()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.
|
|
655
|
-
`,
|
|
656
|
-
);
|
|
657
|
-
return
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
onPageInfo = null;
|
|
661
|
-
sendMsg(0, 0, 'pageInfoStop');
|
|
662
|
-
},
|
|
663
|
-
|
|
664
|
-
getParentProperties(callback) {
|
|
665
|
-
if (typeof callback !== 'function') {
|
|
666
|
-
throw new TypeError(
|
|
667
|
-
'parentIFrame.getParentProperties(callback) callback not a function',
|
|
668
|
-
)
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
onParentInfo = callback;
|
|
672
|
-
sendMsg(0, 0, 'parentInfo');
|
|
673
|
-
|
|
674
|
-
return () => {
|
|
675
|
-
onParentInfo = null;
|
|
676
|
-
sendMsg(0, 0, 'parentInfoStop');
|
|
677
|
-
}
|
|
678
|
-
},
|
|
679
|
-
|
|
680
|
-
moveToAnchor(hash) {
|
|
681
|
-
inPageLinks.findTarget(hash);
|
|
682
|
-
},
|
|
683
|
-
|
|
684
|
-
reset() {
|
|
685
|
-
resetIFrame();
|
|
686
|
-
},
|
|
687
|
-
|
|
688
|
-
scrollTo(x, y) {
|
|
689
|
-
sendMsg(y, x, 'scrollTo'); // X&Y reversed at sendMsg uses height/width
|
|
690
|
-
},
|
|
691
|
-
|
|
692
|
-
scrollToOffset(x, y) {
|
|
693
|
-
sendMsg(y, x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width
|
|
694
|
-
},
|
|
695
|
-
|
|
696
|
-
sendMessage(msg, targetOrigin) {
|
|
697
|
-
sendMsg(0, 0, 'message', JSON.stringify(msg), targetOrigin);
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
setHeightCalculationMethod(heightCalculationMethod) {
|
|
701
|
-
heightCalcMode = heightCalculationMethod;
|
|
702
|
-
checkHeightMode();
|
|
703
|
-
},
|
|
704
|
-
|
|
705
|
-
setWidthCalculationMethod(widthCalculationMethod) {
|
|
706
|
-
widthCalcMode = widthCalculationMethod;
|
|
707
|
-
checkWidthMode();
|
|
708
|
-
},
|
|
709
|
-
|
|
710
|
-
setTargetOrigin(targetOrigin) {
|
|
711
|
-
targetOriginDefault = targetOrigin;
|
|
712
|
-
},
|
|
713
|
-
|
|
714
|
-
resize(customHeight, customWidth) {
|
|
715
|
-
const valString = `${customHeight || ''}${customWidth ? `,${customWidth}` : ''}`;
|
|
716
|
-
|
|
717
|
-
sendSize(
|
|
718
|
-
'size',
|
|
719
|
-
`parentIFrame.size(${valString})`,
|
|
720
|
-
customHeight,
|
|
721
|
-
customWidth,
|
|
722
|
-
);
|
|
723
|
-
},
|
|
724
|
-
|
|
725
|
-
size(customHeight, customWidth) {
|
|
726
|
-
advise(
|
|
727
|
-
`<rb>Deprecated Method</>
|
|
728
|
-
|
|
729
|
-
The <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.
|
|
730
|
-
`,
|
|
731
|
-
);
|
|
732
|
-
this.resize(customHeight, customWidth);
|
|
733
|
-
},
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
win.parentIFrame = win.parentIframe;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
let dispatchResized;
|
|
740
|
-
|
|
741
|
-
function resizeObserved(entries) {
|
|
742
|
-
if (!Array.isArray(entries) || entries.length === 0) return
|
|
743
|
-
|
|
744
|
-
const el = entries[0].target;
|
|
745
|
-
|
|
746
|
-
dispatchResized = () =>
|
|
747
|
-
sendSize('resizeObserver', `Resize Observed: ${getElementName(el)}`);
|
|
748
|
-
|
|
749
|
-
// Throttle event to once per current call stack (Safari issue)
|
|
750
|
-
setTimeout(() => {
|
|
751
|
-
if (dispatchResized) dispatchResized();
|
|
752
|
-
dispatchResized = undefined;
|
|
753
|
-
}, 0);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
const checkPositionType = (element) => {
|
|
757
|
-
const style = getComputedStyle(element);
|
|
758
|
-
return style?.position !== '' && style?.position !== 'static'
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
const getAllNonStaticElements = () =>
|
|
762
|
-
[...getAllElements(document)()].filter(checkPositionType);
|
|
763
|
-
|
|
764
|
-
function setupResizeObservers(el) {
|
|
765
|
-
if (!el) return
|
|
766
|
-
resizeObserver.observe(el);
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
function createResizeObservers(el) {
|
|
770
|
-
[
|
|
771
|
-
...getAllNonStaticElements(),
|
|
772
|
-
...resizeObserveTargets.flatMap((target) => el.querySelector(target)),
|
|
773
|
-
].forEach(setupResizeObservers);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
function addResizeObservers(mutation) {
|
|
777
|
-
if (mutation.type === 'childList') {
|
|
778
|
-
createResizeObservers(mutation.target);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
function setupResizeObserver() {
|
|
783
|
-
resizeObserver = new ResizeObserver(resizeObserved);
|
|
784
|
-
createResizeObservers(window.document);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
function setupBodyMutationObserver() {
|
|
788
|
-
function mutationObserved(mutations) {
|
|
789
|
-
// Look for injected elements that need ResizeObservers
|
|
790
|
-
mutations.forEach(addResizeObservers);
|
|
791
|
-
|
|
792
|
-
// Rebuild elements list for size calculation
|
|
793
|
-
setupCalcElements();
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
function createMutationObserver() {
|
|
797
|
-
const observer = new window.MutationObserver(mutationObserved);
|
|
798
|
-
const target = document.querySelector('body');
|
|
799
|
-
const config = {
|
|
800
|
-
// attributes: true,
|
|
801
|
-
attributes: false,
|
|
802
|
-
attributeOldValue: false,
|
|
803
|
-
// characterData: true,
|
|
804
|
-
characterData: false,
|
|
805
|
-
characterDataOldValue: false,
|
|
806
|
-
childList: true,
|
|
807
|
-
subtree: true,
|
|
808
|
-
};
|
|
809
|
-
observer.observe(target, config);
|
|
810
|
-
|
|
811
|
-
return observer
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
const observer = createMutationObserver();
|
|
815
|
-
|
|
816
|
-
return {
|
|
817
|
-
disconnect() {
|
|
818
|
-
observer.disconnect();
|
|
819
|
-
},
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
function setupMutationObserver() {
|
|
824
|
-
bodyObserver = setupBodyMutationObserver();
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
function getMaxElement(side) {
|
|
828
|
-
const Side = capitalizeFirstLetter(side);
|
|
829
|
-
|
|
830
|
-
let elVal = 0;
|
|
831
|
-
let len = calcElements.length;
|
|
832
|
-
let maxEl;
|
|
833
|
-
let maxVal = 0;
|
|
834
|
-
let timer = performance.now();
|
|
835
|
-
|
|
836
|
-
calcElements.forEach((element) => {
|
|
837
|
-
if (
|
|
838
|
-
!hasTags &&
|
|
839
|
-
hasCheckVisibility &&
|
|
840
|
-
!element.checkVisibility(checkVisibilityOptions)
|
|
841
|
-
) {
|
|
842
|
-
len -= 1;
|
|
843
|
-
return
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
elVal =
|
|
847
|
-
element.getBoundingClientRect()[side] +
|
|
848
|
-
parseFloat(getComputedStyle(element).getPropertyValue(`margin-${side}`));
|
|
849
|
-
|
|
850
|
-
if (elVal > maxVal) {
|
|
851
|
-
maxVal = elVal;
|
|
852
|
-
maxEl = element;
|
|
853
|
-
}
|
|
854
|
-
});
|
|
855
|
-
|
|
856
|
-
timer = performance.now() - timer;
|
|
857
|
-
|
|
858
|
-
const logMsg = `
|
|
859
|
-
Parsed ${len} element${(len = '' )} in ${timer.toPrecision(3)}ms
|
|
860
|
-
${Side} ${hasTags ? 'tagged ' : ''}element found at: ${maxVal}px
|
|
861
|
-
Position calculated from HTML element: ${elementSnippet(maxEl)}`;
|
|
862
|
-
|
|
863
|
-
if (timer < 1.1 || isInit || hasTags) ; else {
|
|
864
|
-
advise(
|
|
865
|
-
`<rb>Performance Warning</>
|
|
866
|
-
|
|
867
|
-
Calculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${side} most element on the page.
|
|
868
|
-
${logMsg}`,
|
|
869
|
-
);
|
|
870
|
-
}
|
|
871
|
-
return maxVal
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
const getAllMeasurements = (dimension) => [
|
|
875
|
-
dimension.bodyOffset(),
|
|
876
|
-
dimension.bodyScroll(),
|
|
877
|
-
dimension.documentElementOffset(),
|
|
878
|
-
dimension.documentElementScroll(),
|
|
879
|
-
dimension.documentElementBoundingClientRect(),
|
|
880
|
-
];
|
|
881
|
-
|
|
882
|
-
const getAllElements = (element) => () =>
|
|
883
|
-
element.querySelectorAll(
|
|
884
|
-
'* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)',
|
|
885
|
-
);
|
|
886
|
-
|
|
887
|
-
let switchChecked = false;
|
|
888
|
-
|
|
889
|
-
function switchToAutoOverflow({
|
|
890
|
-
ceilBoundingSize,
|
|
891
|
-
dimension,
|
|
892
|
-
getDimension,
|
|
893
|
-
isHeight,
|
|
894
|
-
scrollSize,
|
|
895
|
-
}) {
|
|
896
|
-
if (!switchChecked) {
|
|
897
|
-
// If this just happens once, then it is likely we just came from a large page.
|
|
898
|
-
switchChecked = true;
|
|
899
|
-
return getDimension.taggedElement()
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
const furthest = isHeight ? 'lowest' : 'right most';
|
|
903
|
-
const side = isHeight ? 'bottom' : 'right';
|
|
904
|
-
const overflowDetectedMessage = `<rb>Detected content overflowing html element</>
|
|
905
|
-
|
|
906
|
-
This causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${side} margin, and position of every visible HTML element will have a performance impact on more complex pages.
|
|
907
|
-
|
|
908
|
-
To fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe.
|
|
909
|
-
|
|
910
|
-
When present the <i>${side} margin of the ${furthest} element</> with a <b>data-iframe-size</> attribute will be used to set the ${dimension} of the iframe.
|
|
911
|
-
|
|
912
|
-
(Page size: ${scrollSize} > document size: ${ceilBoundingSize})`;
|
|
913
|
-
|
|
914
|
-
advise(overflowDetectedMessage);
|
|
915
|
-
|
|
916
|
-
if (isHeight) {
|
|
917
|
-
heightCalcMode = 'autoOverflow';
|
|
918
|
-
} else {
|
|
919
|
-
widthCalcMode = 'autoOverflow';
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
return getDimension.taggedElement()
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
const prevScrollSize = {
|
|
926
|
-
height: 0,
|
|
927
|
-
width: 0,
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
const prevBoundingSize = {
|
|
931
|
-
height: 0,
|
|
932
|
-
width: 0,
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
const getAdjustedScroll = (getDimension) =>
|
|
936
|
-
getDimension.documentElementScroll() + Math.max(0, getDimension.getOffset());
|
|
937
|
-
|
|
938
|
-
function getAutoSize(getDimension, autoOverflow) {
|
|
939
|
-
function returnBoundingClientRect() {
|
|
940
|
-
prevBoundingSize[dimension] = boundingSize;
|
|
941
|
-
prevScrollSize[dimension] = scrollSize;
|
|
942
|
-
return boundingSize
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
const isHeight = getDimension === getHeight;
|
|
946
|
-
const dimension = isHeight ? 'height' : 'width';
|
|
947
|
-
const boundingSize = getDimension.documentElementBoundingClientRect();
|
|
948
|
-
const ceilBoundingSize = Math.ceil(boundingSize);
|
|
949
|
-
const floorBoundingSize = Math.floor(boundingSize);
|
|
950
|
-
const scrollSize = getAdjustedScroll(getDimension);
|
|
951
|
-
|
|
952
|
-
switch (true) {
|
|
953
|
-
case !getDimension.enabled():
|
|
954
|
-
return scrollSize
|
|
955
|
-
|
|
956
|
-
case !autoOverflow &&
|
|
957
|
-
prevBoundingSize[dimension] === 0 &&
|
|
958
|
-
prevScrollSize[dimension] === 0:
|
|
959
|
-
if (getDimension.taggedElement(true) <= ceilBoundingSize) {
|
|
960
|
-
return returnBoundingClientRect()
|
|
961
|
-
}
|
|
962
|
-
break
|
|
963
|
-
|
|
964
|
-
case triggerLocked &&
|
|
965
|
-
boundingSize === prevBoundingSize[dimension] &&
|
|
966
|
-
scrollSize === prevScrollSize[dimension]:
|
|
967
|
-
return Math.max(boundingSize, scrollSize)
|
|
968
|
-
|
|
969
|
-
case boundingSize === 0:
|
|
970
|
-
return scrollSize
|
|
971
|
-
|
|
972
|
-
case !autoOverflow &&
|
|
973
|
-
boundingSize !== prevBoundingSize[dimension] &&
|
|
974
|
-
scrollSize <= prevScrollSize[dimension]:
|
|
975
|
-
return returnBoundingClientRect()
|
|
976
|
-
|
|
977
|
-
case !isHeight:
|
|
978
|
-
return autoOverflow
|
|
979
|
-
? getDimension.taggedElement()
|
|
980
|
-
: switchToAutoOverflow({
|
|
981
|
-
ceilBoundingSize,
|
|
982
|
-
dimension,
|
|
983
|
-
getDimension,
|
|
984
|
-
isHeight,
|
|
985
|
-
scrollSize,
|
|
986
|
-
})
|
|
987
|
-
|
|
988
|
-
case !autoOverflow && boundingSize < prevBoundingSize[dimension]:
|
|
989
|
-
return returnBoundingClientRect()
|
|
990
|
-
|
|
991
|
-
case scrollSize === floorBoundingSize || scrollSize === ceilBoundingSize:
|
|
992
|
-
return returnBoundingClientRect()
|
|
993
|
-
|
|
994
|
-
case boundingSize > scrollSize:
|
|
995
|
-
return returnBoundingClientRect()
|
|
996
|
-
|
|
997
|
-
case !autoOverflow:
|
|
998
|
-
return switchToAutoOverflow({
|
|
999
|
-
ceilBoundingSize,
|
|
1000
|
-
dimension,
|
|
1001
|
-
getDimension,
|
|
1002
|
-
isHeight,
|
|
1003
|
-
scrollSize,
|
|
1004
|
-
})
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
return Math.max(getDimension.taggedElement(), returnBoundingClientRect())
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
const getBodyOffset = () => {
|
|
1011
|
-
const { body } = document;
|
|
1012
|
-
const style = getComputedStyle(body);
|
|
1013
|
-
|
|
1014
|
-
return (
|
|
1015
|
-
body.offsetHeight +
|
|
1016
|
-
parseInt(style.marginTop, BASE) +
|
|
1017
|
-
parseInt(style.marginBottom, BASE)
|
|
1018
|
-
)
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
const getHeight = {
|
|
1022
|
-
enabled: () => calculateHeight,
|
|
1023
|
-
getOffset: () => offsetHeight,
|
|
1024
|
-
type: 'height',
|
|
1025
|
-
auto: () => getAutoSize(getHeight, false),
|
|
1026
|
-
autoOverflow: () => getAutoSize(getHeight, true),
|
|
1027
|
-
bodyOffset: getBodyOffset,
|
|
1028
|
-
bodyScroll: () => document.body.scrollHeight,
|
|
1029
|
-
offset: () => getHeight.bodyOffset(), // Backwards compatibility
|
|
1030
|
-
custom: () => customCalcMethods.height(),
|
|
1031
|
-
documentElementOffset: () => document.documentElement.offsetHeight,
|
|
1032
|
-
documentElementScroll: () => document.documentElement.scrollHeight,
|
|
1033
|
-
documentElementBoundingClientRect: () =>
|
|
1034
|
-
document.documentElement.getBoundingClientRect().bottom,
|
|
1035
|
-
max: () => Math.max(...getAllMeasurements(getHeight)),
|
|
1036
|
-
min: () => Math.min(...getAllMeasurements(getHeight)),
|
|
1037
|
-
grow: () => getHeight.max(),
|
|
1038
|
-
lowestElement: () => getMaxElement('bottom'),
|
|
1039
|
-
taggedElement: () => getMaxElement('bottom'),
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
const getWidth = {
|
|
1043
|
-
enabled: () => calculateWidth,
|
|
1044
|
-
getOffset: () => offsetWidth,
|
|
1045
|
-
type: 'width',
|
|
1046
|
-
auto: () => getAutoSize(getWidth, false),
|
|
1047
|
-
autoOverflow: () => getAutoSize(getWidth, true),
|
|
1048
|
-
bodyScroll: () => document.body.scrollWidth,
|
|
1049
|
-
bodyOffset: () => document.body.offsetWidth,
|
|
1050
|
-
custom: () => customCalcMethods.width(),
|
|
1051
|
-
documentElementScroll: () => document.documentElement.scrollWidth,
|
|
1052
|
-
documentElementOffset: () => document.documentElement.offsetWidth,
|
|
1053
|
-
documentElementBoundingClientRect: () =>
|
|
1054
|
-
document.documentElement.getBoundingClientRect().right,
|
|
1055
|
-
max: () => Math.max(...getAllMeasurements(getWidth)),
|
|
1056
|
-
min: () => Math.min(...getAllMeasurements(getWidth)),
|
|
1057
|
-
rightMostElement: () => getMaxElement('right'),
|
|
1058
|
-
scroll: () =>
|
|
1059
|
-
Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll()),
|
|
1060
|
-
taggedElement: () => getMaxElement('right'),
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
|
-
function sizeIFrame(
|
|
1064
|
-
triggerEvent,
|
|
1065
|
-
triggerEventDesc,
|
|
1066
|
-
customHeight,
|
|
1067
|
-
customWidth,
|
|
1068
|
-
msg,
|
|
1069
|
-
) {
|
|
1070
|
-
function resizeIFrame() {
|
|
1071
|
-
height = currentHeight;
|
|
1072
|
-
width = currentWidth;
|
|
1073
|
-
sendMsg(height, width, triggerEvent, msg);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function isSizeChangeDetected() {
|
|
1077
|
-
const checkTolerance = (a, b) => !(Math.abs(a - b) <= tolerance);
|
|
1078
|
-
|
|
1079
|
-
// currentHeight = Math.ceil(
|
|
1080
|
-
// undefined === customHeight ? getHeight[heightCalcMode]() : customHeight,
|
|
1081
|
-
// )
|
|
1082
|
-
|
|
1083
|
-
// currentWidth = Math.ceil(
|
|
1084
|
-
// undefined === customWidth ? getWidth[widthCalcMode]() : customWidth,
|
|
1085
|
-
// )
|
|
1086
|
-
|
|
1087
|
-
currentHeight =
|
|
1088
|
-
undefined === customHeight ? getHeight[heightCalcMode]() : customHeight;
|
|
1089
|
-
currentWidth =
|
|
1090
|
-
undefined === customWidth ? getWidth[widthCalcMode]() : customWidth;
|
|
1091
|
-
|
|
1092
|
-
return (
|
|
1093
|
-
(calculateHeight && checkTolerance(height, currentHeight)) ||
|
|
1094
|
-
(calculateWidth && checkTolerance(width, currentWidth))
|
|
1095
|
-
)
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
const isForceResizableEvent = () => !(triggerEvent in { init: 1, size: 1 });
|
|
1099
|
-
|
|
1100
|
-
const isForceResizableCalcMode = () =>
|
|
1101
|
-
(calculateHeight && heightCalcMode in resetRequiredMethods) ||
|
|
1102
|
-
(calculateWidth && widthCalcMode in resetRequiredMethods);
|
|
1103
|
-
|
|
1104
|
-
function checkDownSizing() {
|
|
1105
|
-
if (isForceResizableEvent() && isForceResizableCalcMode()) {
|
|
1106
|
-
resetIFrame();
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
let currentHeight;
|
|
1111
|
-
let currentWidth;
|
|
1112
|
-
|
|
1113
|
-
if (isSizeChangeDetected() || triggerEvent === 'init') {
|
|
1114
|
-
lockTrigger();
|
|
1115
|
-
resizeIFrame();
|
|
1116
|
-
} else {
|
|
1117
|
-
checkDownSizing();
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
function sendSize(
|
|
1122
|
-
triggerEvent,
|
|
1123
|
-
triggerEventDesc,
|
|
1124
|
-
customHeight,
|
|
1125
|
-
customWidth,
|
|
1126
|
-
msg,
|
|
1127
|
-
) {
|
|
1128
|
-
if (document.hidden) {
|
|
1129
|
-
// Currently only correctly supported in firefox
|
|
1130
|
-
// This is checked again on the parent page
|
|
1131
|
-
return
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth, msg);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
function lockTrigger() {
|
|
1138
|
-
if (triggerLocked) return
|
|
1139
|
-
|
|
1140
|
-
triggerLocked = true;
|
|
1141
|
-
|
|
1142
|
-
requestAnimationFrame(() => {
|
|
1143
|
-
triggerLocked = false;
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
function triggerReset(triggerEvent) {
|
|
1148
|
-
height = getHeight[heightCalcMode]();
|
|
1149
|
-
width = getWidth[widthCalcMode]();
|
|
1150
|
-
|
|
1151
|
-
sendMsg(height, width, triggerEvent);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
function resetIFrame(triggerEventDesc) {
|
|
1155
|
-
const hcm = heightCalcMode;
|
|
1156
|
-
heightCalcMode = heightCalcModeDefault;
|
|
1157
|
-
lockTrigger();
|
|
1158
|
-
triggerReset('reset');
|
|
1159
|
-
|
|
1160
|
-
heightCalcMode = hcm;
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
function sendMsg(height, width, triggerEvent, msg, targetOrigin) {
|
|
1164
|
-
if (mode < 0) return
|
|
1165
|
-
|
|
1166
|
-
function setTargetOrigin() {
|
|
1167
|
-
if (undefined === targetOrigin) {
|
|
1168
|
-
targetOrigin = targetOriginDefault;
|
|
1169
|
-
return
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
function sendToParent() {
|
|
1174
|
-
const size = `${height + (offsetHeight || 0)}:${width + (offsetWidth || 0)}`;
|
|
1175
|
-
const message = `${myID}:${size}:${triggerEvent}${undefined === msg ? '' : `:${msg}`}`;
|
|
1176
|
-
|
|
1177
|
-
if (sameDomain) {
|
|
1178
|
-
window.parent.iframeParentListener(msgID + message);
|
|
1179
|
-
return
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
target.postMessage(msgID + message, targetOrigin);
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
setTargetOrigin();
|
|
1186
|
-
sendToParent();
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
function receiver(event) {
|
|
1190
|
-
const processRequestFromParent = {
|
|
1191
|
-
init: function initFromParent() {
|
|
1192
|
-
initMsg = event.data;
|
|
1193
|
-
target = event.source;
|
|
1194
|
-
|
|
1195
|
-
init();
|
|
1196
|
-
firstRun = false;
|
|
1197
|
-
setTimeout(() => {
|
|
1198
|
-
initLock = false;
|
|
1199
|
-
}, eventCancelTimer);
|
|
1200
|
-
},
|
|
1201
|
-
|
|
1202
|
-
reset() {
|
|
1203
|
-
if (initLock) {
|
|
1204
|
-
return
|
|
1205
|
-
}
|
|
1206
|
-
triggerReset('resetPage');
|
|
1207
|
-
},
|
|
1208
|
-
|
|
1209
|
-
resize() {
|
|
1210
|
-
sendSize('resizeParent', 'Parent window requested size check');
|
|
1211
|
-
},
|
|
1212
|
-
|
|
1213
|
-
moveToAnchor() {
|
|
1214
|
-
inPageLinks.findTarget(getData());
|
|
1215
|
-
},
|
|
1216
|
-
|
|
1217
|
-
inPageLink() {
|
|
1218
|
-
this.moveToAnchor();
|
|
1219
|
-
}, // Backward compatibility
|
|
1220
|
-
|
|
1221
|
-
pageInfo() {
|
|
1222
|
-
const msgBody = getData();
|
|
1223
|
-
if (onPageInfo) {
|
|
1224
|
-
onPageInfo(JSON.parse(msgBody));
|
|
1225
|
-
} else {
|
|
1226
|
-
// not expected, so cancel more messages
|
|
1227
|
-
sendMsg(0, 0, 'pageInfoStop');
|
|
1228
|
-
}
|
|
1229
|
-
},
|
|
1230
|
-
|
|
1231
|
-
parentInfo() {
|
|
1232
|
-
const msgBody = getData();
|
|
1233
|
-
if (onParentInfo) {
|
|
1234
|
-
onParentInfo(Object.freeze(JSON.parse(msgBody)));
|
|
1235
|
-
} else {
|
|
1236
|
-
// not expected, so cancel more messages
|
|
1237
|
-
sendMsg(0, 0, 'parentInfoStop');
|
|
1238
|
-
}
|
|
1239
|
-
},
|
|
1240
|
-
|
|
1241
|
-
message() {
|
|
1242
|
-
const msgBody = getData();
|
|
1243
|
-
// eslint-disable-next-line sonarjs/no-extra-arguments
|
|
1244
|
-
onMessage(JSON.parse(msgBody));
|
|
1245
|
-
},
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
const isMessageForUs = () => msgID === `${event.data}`.slice(0, msgIdLen);
|
|
1249
|
-
|
|
1250
|
-
const getMessageType = () => event.data.split(']')[1].split(':')[0];
|
|
1251
|
-
|
|
1252
|
-
const getData = () => event.data.slice(event.data.indexOf(':') + 1);
|
|
1253
|
-
|
|
1254
|
-
const isMiddleTier = () =>
|
|
1255
|
-
'iframeResize' in window ||
|
|
1256
|
-
(window.jQuery !== undefined && '' in window.jQuery.prototype);
|
|
1257
|
-
|
|
1258
|
-
// Test if this message is from a child below us. This is an ugly test, however, updating
|
|
1259
|
-
// the message format would break backwards compatibility.
|
|
1260
|
-
const isInitMsg = () => event.data.split(':')[2] in { true: 1, false: 1 };
|
|
1261
|
-
|
|
1262
|
-
function callFromParent() {
|
|
1263
|
-
const messageType = getMessageType();
|
|
1264
|
-
|
|
1265
|
-
if (messageType in processRequestFromParent) {
|
|
1266
|
-
processRequestFromParent[messageType]();
|
|
1267
|
-
return
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
if (!isMiddleTier() && !isInitMsg()) {
|
|
1271
|
-
warn(`Unexpected message (${event.data})`);
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
function processMessage() {
|
|
1276
|
-
if (firstRun === false) {
|
|
1277
|
-
callFromParent();
|
|
1278
|
-
return
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
if (isInitMsg()) {
|
|
1282
|
-
processRequestFromParent.init();
|
|
1283
|
-
return
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
if (isMessageForUs()) {
|
|
1288
|
-
processMessage();
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
// Normally the parent kicks things off when it detects the iFrame has loaded.
|
|
1293
|
-
// If this script is async-loaded, then tell parent page to retry init.
|
|
1294
|
-
function chkLateLoaded() {
|
|
1295
|
-
if (document.readyState !== 'loading') {
|
|
1296
|
-
window.parent.postMessage('[iFrameResizerChild]Ready', '*');
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
// Don't run for server side render
|
|
1301
|
-
if (typeof window !== 'undefined') {
|
|
1302
|
-
window.iframeChildListener = (data) => receiver({ data, sameDomain: true });
|
|
1303
|
-
addEventListener(window, 'message', receiver);
|
|
1304
|
-
addEventListener(window, 'readystatechange', chkLateLoaded);
|
|
1305
|
-
chkLateLoaded();
|
|
1306
|
-
}
|
|
20
|
+
"use strict";const e="5.1.0",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(ae("Custom height calculation function not defined"),Ne.auto()),width:()=>(ae("Custom width calculation function not defined"),ke.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,A=!1,M=null,T=!0,C=!1,I=1,x=f,N=!0,k="",R={},B=!0,q=!1,L=0,D=!1,H="",W="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{ae("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e;const re=(...e)=>[`[iframe-resizer][${H}]`,...e].join(" "),ae=(...e)=>console?.warn(re(...e)),le=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e(t.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(re)(...e)),ce=e=>le(e);function se(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=k.slice(h).split(":");H=t[0],$=void 0===t[1]?$:Number(t[1]),A=void 0===t[2]?A:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],x=void 0===t[8]?x:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),W=void 0===t[13]?W:t[13],K=void 0===t[14]?K:t[14],D=void 0===t[15]?D:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),A&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,x=e?.heightCalculationMethod||x,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),x=t(x,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);ue("margin",function(e,t){t.includes("-")&&(ae(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),ue("background",S),ue("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),de(),L<-1?ce(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&ce(a(3)),function(){if(!Y||""===Y||"false"===Y)return void le("<rb>Legacy version detected on parent page</>\n\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\n\nSee <u>https://iframe-resizer.com/setup/<u> for more details.\n");Y!==e&&le(`<rb>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${Y} - Child page: ${e}.\n`)}(),ye(),ge(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&le("<rb>Deprecated Attributes</>\n \nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===x&&(x="autoOverflow"),"auto"===K&&(K="autoOverflow")),pe(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,ve()):!1===e&&!0===z&&(z=!1,fe("remove"),U?.disconnect(),E?.disconnect()),He(0,0,"autoResize",JSON.stringify(z)),z),close(){He(0,0,"close")},getId:()=>H,getPageInfo(e){if("function"==typeof e)return ne=e,He(0,0,"pageInfo"),void le("<rb>Deprecated Method</>\n \nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\n");ne=null,He(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,He(0,0,"parentInfo"),()=>{oe=null,He(0,0,"parentInfoStop")}},getParentProperties(e){le("<rb>Renamed Method</>\n \nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){De()},scrollBy(e,t){He(t,e,"scrollBy")},scrollTo(e,t){He(t,e,"scrollTo")},scrollToOffset(e,t){He(t,e,"scrollToOffset")},sendMessage(e,t){He(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){x=e,ye()},setWidthCalculationMethod(e){K=e,ge()},setTargetOrigin(e){Z=e},resize(e,t){Be("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){le("<rb>Deprecated Method</>\n \nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==D)return;function e(e){He(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),ve(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);He(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?He(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll('a[href^="#"]').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?le("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),Be("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&He(0,0,"title",document.title),te(),B=!1}function ue(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function de(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function me(e){({add(t){function n(){Be(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function fe(e){me({method:e,eventType:"After Print",eventName:"afterprint"}),me({method:e,eventType:"Before Print",eventName:"beforeprint"}),me({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function pe(){const e=document.querySelectorAll(`[${n}]`);C=e.length>0,M=C?e:Ae(document)()}function he(e,t,n,o){return t!==e&&(e in n||(ae(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&le(`<rb>Deprecated ${o}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ye(){x=he(x,f,Ne,"height")}function ge(){K=he(K,v,ke,"width")}function ve(){!0===z&&(fe("add"),E=function(){function e(e){e.forEach(Ee),de(),pe()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(we),je(window.document))}let be;function we(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;be=()=>Be("resizeObserver",`Resize Observed: ${function(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}(t)}`),setTimeout((()=>{be&&be(),be=void 0}),0)}const ze=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Se=()=>[...Ae(document)()].filter(ze);function $e(e){e&&U.observe(e)}function je(e){[...Se(),...g.flatMap((t=>e.querySelector(t)))].forEach($e)}function Ee(e){"childList"===e.type&&je(e.target)}function Pe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o,i=0,r=M.length,a=0,c=performance.now();M.forEach((t=>{C||!m||t.checkVisibility(l)?(i=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),i>a&&(a=i,o=t)):r-=1})),c=performance.now()-c;const s=`\nParsed ${r} element${r=""} in ${c.toPrecision(3)}ms\n${t} ${C?"tagged ":""}element found at: ${a}px\nPosition calculated from HTML element: ${function(e){const t=e?.outerHTML?.toString();return t?t.length<30?t:`${t.slice(0,30).replaceAll("\n"," ")}...`:e}(o)}`;return c<1.1||B||C||le(`<rb>Performance Warning</>\n\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\n${s}`),a}const Oe=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Ae=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Me=!1;function Te({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Me)return Me=!0,n.taggedElement();const r=o?"bottom":"right";return le(`<rb>Detected content overflowing html element</>\n \nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \n\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \n \nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\n \n(Page size: ${i} > document size: ${e})`),o?x="autoOverflow":K="autoOverflow",n.taggedElement()}const Ce={height:0,width:0},Ie={height:0,width:0};function xe(e,t){function n(){return Ie[i]=r,Ce[i]=c,r}const o=e===Ne,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===Ie[i]&&0===Ce[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===Ie[i]&&c===Ce[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==Ie[i]&&c<=Ce[i]:return n();case!o:return t?e.taggedElement():Te({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<Ie[i]:case c===l||c===a:case r>c:return n();case!t:return Te({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const Ne={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>xe(Ne,!1),autoOverflow:()=>xe(Ne,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Ne.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Oe(Ne)),min:()=>Math.min(...Oe(Ne)),grow:()=>Ne.max(),lowestElement:()=>Pe("bottom"),taggedElement:()=>Pe("bottom")},ke={enabled:()=>A,getOffset:()=>w,type:"width",auto:()=>xe(ke,!1),autoOverflow:()=>xe(ke,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Oe(ke)),min:()=>Math.min(...Oe(ke)),rightMostElement:()=>Pe("right"),scroll:()=>Math.max(ke.bodyScroll(),ke.documentElementScroll()),taggedElement:()=>Pe("right")};function Re(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?Ne[x]():n,a=void 0===o?ke[K]():o,O&&e(I,r)||A&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&x in y||A&&K in y)&&De():(qe(),I=r,G=a,He(I,G,e,i))}function Be(e,t,n,o,i){document.hidden||Re(e,0,n,o,i)}function qe(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Le(e){I=Ne[x](),G=ke[K](),He(I,G,e)}function De(e){const t=x;x=f,qe(),Le("reset"),x=t}function He(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${H}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function We(e){const t={init:function(){k=e.data,J=e.source,se(),T=!1,setTimeout((()=>{N=!1}),u)},reset(){N||Le("resetPage")},resize(){Be("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):He(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):He(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==T?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||ae(`Unexpected message (${e.data})`)}())}function Ue(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>We({data:e,sameDomain:!0}),o(window,"message",We),o(window,"readystatechange",Ue),Ue());
|