iframe-resizer 4.4.5 → 5.2.3

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.
@@ -1,1488 +1,20 @@
1
- /*
2
- * File: iframeResizer.js
3
- * Desc: Force iframes to size to content.
4
- * Requires: iframeResizer.contentWindow.js to be loaded into the target frame.
5
- * Doc: https://iframe-resizer.com
6
- * Author: David J. Bradshaw - info@iframe-resizer.com
1
+ /*!
2
+ * @preserve
3
+ *
4
+ * @module iframe-resizer/legacy (parent) 5.2.3 (umd) - 2024-08-05
5
+ *
6
+ * @license GPL-3.0 for non-commercial use only.
7
+ * For commercial use, you must purchase a license from
8
+ * https://iframe-resizer.com/pricing
9
+ *
10
+ * @description Keep same and cross domain iFrames sized to their content
11
+ *
12
+ * @author David J. Bradshaw <info@iframe-resizer.com>
13
+ *
14
+ * @see {@link https://iframe-resizer.com}
15
+ *
16
+ * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.
7
17
  */
8
18
 
9
- console.info(`
10
- IFRAME-RESIZER
11
19
 
12
- Iframe-Resizer 5 is now available via the following two packages:
13
-
14
- * @iframe-resizer/parent
15
- * @iframe-resizer/child
16
-
17
- Additionally their are also new versions of iframe-resizer for React, Vue, and jQuery.
18
-
19
- Version 5 of iframe-resizer has been extensively rewritten to use modern browser APIs, which has enabled significantly better performance and greater accuracy in the detection of content resizing events.
20
-
21
- Please see https://iframe-resizer.com/upgrade for more details.
22
- `)
23
-
24
- // eslint-disable-next-line sonarjs/cognitive-complexity, no-shadow-restricted-names
25
- ;(function (undefined) {
26
- if (typeof window === 'undefined') return // don't run for server side render
27
-
28
- // var VERSION = '4.3.11'
29
-
30
- var count = 0,
31
- destroyObserver,
32
- logEnabled = false,
33
- hiddenCheckEnabled = false,
34
- msgHeader = 'message',
35
- msgHeaderLen = msgHeader.length,
36
- msgId = '[iFrameSizer]', // Must match iframe msg ID
37
- msgIdLen = msgId.length,
38
- pagePosition = null,
39
- requestAnimationFrame = window.requestAnimationFrame,
40
- resetRequiredMethods = Object.freeze({
41
- max: 1,
42
- scroll: 1,
43
- bodyScroll: 1,
44
- documentElementScroll: 1
45
- }),
46
- settings = {},
47
- timer = null,
48
- defaults = Object.freeze({
49
- autoResize: true,
50
- bodyBackground: null,
51
- bodyMargin: null,
52
- bodyMarginV1: 8,
53
- bodyPadding: null,
54
- checkOrigin: true,
55
- inPageLinks: false,
56
- enablePublicMethods: true,
57
- heightCalculationMethod: 'bodyOffset',
58
- id: 'iFrameResizer',
59
- interval: 32,
60
- license: '1jqr0si6pnt',
61
- log: false,
62
- maxHeight: Infinity,
63
- maxWidth: Infinity,
64
- minHeight: 0,
65
- minWidth: 0,
66
- mouseEvents: true,
67
- resizeFrom: 'parent',
68
- scrolling: false,
69
- sizeHeight: true,
70
- sizeWidth: false,
71
- warningTimeout: 5000,
72
- tolerance: 0,
73
- widthCalculationMethod: 'scroll',
74
- onClose: function () {
75
- return true
76
- },
77
- onClosed: function () {},
78
- onInit: function () {},
79
- onMessage: function () {
80
- warn('onMessage function not defined')
81
- },
82
- onMouseEnter: function () {},
83
- onMouseLeave: function () {},
84
- onResized: function () {},
85
- onScroll: function () {
86
- return true
87
- }
88
- })
89
-
90
- function getMutationObserver() {
91
- return (
92
- window.MutationObserver ||
93
- window.WebKitMutationObserver ||
94
- window.MozMutationObserver
95
- )
96
- }
97
-
98
- function addEventListener(el, evt, func) {
99
- el.addEventListener(evt, func, false)
100
- }
101
-
102
- function removeEventListener(el, evt, func) {
103
- el.removeEventListener(evt, func, false)
104
- }
105
-
106
- function setupRequestAnimationFrame() {
107
- var vendors = ['moz', 'webkit', 'o', 'ms']
108
- var x
109
-
110
- // Remove vendor prefixing if prefixed and break early if not
111
- for (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) {
112
- requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']
113
- }
114
-
115
- if (requestAnimationFrame) {
116
- // Firefox extension content-scripts have a globalThis object that is not the same as window.
117
- // Binding `requestAnimationFrame` to window allows the function to work and prevents errors
118
- // being thrown when run in that context, and should be a no-op in every other context.
119
- requestAnimationFrame = requestAnimationFrame.bind(window)
120
- } else {
121
- log('setup', 'RequestAnimationFrame not supported')
122
- }
123
- }
124
-
125
- function getMyID(iframeId) {
126
- var retStr = 'Host page: ' + iframeId
127
-
128
- if (window.top !== window.self) {
129
- retStr =
130
- window.parentIFrame && window.parentIFrame.getId
131
- ? window.parentIFrame.getId() + ': ' + iframeId
132
- : 'Nested host page: ' + iframeId
133
- }
134
-
135
- return retStr
136
- }
137
-
138
- function formatLogHeader(iframeId) {
139
- return msgId + '[' + getMyID(iframeId) + ']'
140
- }
141
-
142
- function isLogEnabled(iframeId) {
143
- return settings[iframeId] ? settings[iframeId].log : logEnabled
144
- }
145
-
146
- function log(iframeId, msg) {
147
- output('log', iframeId, msg, isLogEnabled(iframeId))
148
- }
149
-
150
- function info(iframeId, msg) {
151
- output('info', iframeId, msg, isLogEnabled(iframeId))
152
- }
153
-
154
- function warn(iframeId, msg) {
155
- output('warn', iframeId, msg, true)
156
- }
157
-
158
- function output(type, iframeId, msg, enabled) {
159
- if (true === enabled && 'object' === typeof window.console) {
160
- // eslint-disable-next-line no-console
161
- console[type](formatLogHeader(iframeId), msg)
162
- }
163
- }
164
-
165
- function iFrameListener(event) {
166
- function resizeIFrame() {
167
- function resize() {
168
- setSize(messageData)
169
- setPagePosition(iframeId)
170
- on('onResized', messageData)
171
- }
172
-
173
- ensureInRange('Height')
174
- ensureInRange('Width')
175
-
176
- syncResize(resize, messageData, 'init')
177
- }
178
-
179
- function processMsg() {
180
- var data = msg.slice(msgIdLen).split(':')
181
- var height = data[1] ? parseInt(data[1], 10) : 0
182
- var iframe = settings[data[0]] && settings[data[0]].iframe
183
- var compStyle = getComputedStyle(iframe)
184
-
185
- return {
186
- iframe: iframe,
187
- id: data[0],
188
- height: height + getPaddingEnds(compStyle) + getBorderEnds(compStyle),
189
- width: data[2],
190
- type: data[3]
191
- }
192
- }
193
-
194
- function getPaddingEnds(compStyle) {
195
- if (compStyle.boxSizing !== 'border-box') {
196
- return 0
197
- }
198
- var top = compStyle.paddingTop ? parseInt(compStyle.paddingTop, 10) : 0
199
- var bot = compStyle.paddingBottom
200
- ? parseInt(compStyle.paddingBottom, 10)
201
- : 0
202
- return top + bot
203
- }
204
-
205
- function getBorderEnds(compStyle) {
206
- if (compStyle.boxSizing !== 'border-box') {
207
- return 0
208
- }
209
- var top = compStyle.borderTopWidth
210
- ? parseInt(compStyle.borderTopWidth, 10)
211
- : 0
212
- var bot = compStyle.borderBottomWidth
213
- ? parseInt(compStyle.borderBottomWidth, 10)
214
- : 0
215
- return top + bot
216
- }
217
-
218
- function ensureInRange(Dimension) {
219
- var max = Number(settings[iframeId]['max' + Dimension]),
220
- min = Number(settings[iframeId]['min' + Dimension]),
221
- dimension = Dimension.toLowerCase(),
222
- size = Number(messageData[dimension])
223
-
224
- log(iframeId, 'Checking ' + dimension + ' is in range ' + min + '-' + max)
225
-
226
- if (size < min) {
227
- size = min
228
- log(iframeId, 'Set ' + dimension + ' to min value')
229
- }
230
-
231
- if (size > max) {
232
- size = max
233
- log(iframeId, 'Set ' + dimension + ' to max value')
234
- }
235
-
236
- messageData[dimension] = '' + size
237
- }
238
-
239
- function isMessageFromIFrame() {
240
- function checkAllowedOrigin() {
241
- function checkList() {
242
- var i = 0,
243
- retCode = false
244
-
245
- log(
246
- iframeId,
247
- 'Checking connection is from allowed list of origins: ' +
248
- checkOrigin
249
- )
250
-
251
- for (; i < checkOrigin.length; i++) {
252
- if (checkOrigin[i] === origin) {
253
- retCode = true
254
- break
255
- }
256
- }
257
- return retCode
258
- }
259
-
260
- function checkSingle() {
261
- var remoteHost = settings[iframeId] && settings[iframeId].remoteHost
262
- log(iframeId, 'Checking connection is from: ' + remoteHost)
263
- return origin === remoteHost
264
- }
265
-
266
- return checkOrigin.constructor === Array ? checkList() : checkSingle()
267
- }
268
-
269
- var origin = event.origin,
270
- checkOrigin = settings[iframeId] && settings[iframeId].checkOrigin
271
-
272
- if (checkOrigin && '' + origin !== 'null' && !checkAllowedOrigin()) {
273
- throw new Error(
274
- 'Unexpected message received from: ' +
275
- origin +
276
- ' for ' +
277
- messageData.iframe.id +
278
- '. Message was: ' +
279
- event.data +
280
- '. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.'
281
- )
282
- }
283
-
284
- return true
285
- }
286
-
287
- function isMessageForUs() {
288
- return (
289
- msgId === ('' + msg).slice(0, msgIdLen) &&
290
- msg.slice(msgIdLen).split(':')[0] in settings
291
- ) // ''+Protects against non-string msg
292
- }
293
-
294
- function isMessageFromMetaParent() {
295
- // Test if this message is from a parent above us. This is an ugly test, however, updating
296
- // the message format would break backwards compatibility.
297
- var retCode = messageData.type in { true: 1, false: 1, undefined: 1 }
298
-
299
- if (retCode) {
300
- log(iframeId, 'Ignoring init message from meta parent page')
301
- }
302
-
303
- return retCode
304
- }
305
-
306
- function getMsgBody(offset) {
307
- return msg.slice(msg.indexOf(':') + msgHeaderLen + offset)
308
- }
309
-
310
- function forwardMsgFromIFrame(msgBody) {
311
- log(
312
- iframeId,
313
- 'onMessage passed: {iframe: ' +
314
- messageData.iframe.id +
315
- ', message: ' +
316
- msgBody +
317
- '}'
318
- )
319
-
320
- on('onMessage', {
321
- iframe: messageData.iframe,
322
- message: JSON.parse(msgBody)
323
- })
324
-
325
- log(iframeId, '--')
326
- }
327
-
328
- function getPageInfo() {
329
- var bodyPosition = document.body.getBoundingClientRect(),
330
- iFramePosition = messageData.iframe.getBoundingClientRect()
331
-
332
- return JSON.stringify({
333
- iframeHeight: iFramePosition.height,
334
- iframeWidth: iFramePosition.width,
335
- clientHeight: Math.max(
336
- document.documentElement.clientHeight,
337
- window.innerHeight || 0
338
- ),
339
- clientWidth: Math.max(
340
- document.documentElement.clientWidth,
341
- window.innerWidth || 0
342
- ),
343
- offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
344
- offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),
345
- scrollTop: window.pageYOffset,
346
- scrollLeft: window.pageXOffset,
347
- documentHeight: document.documentElement.clientHeight,
348
- documentWidth: document.documentElement.clientWidth,
349
- windowHeight: window.innerHeight,
350
- windowWidth: window.innerWidth
351
- })
352
- }
353
-
354
- function sendPageInfoToIframe(iframe, iframeId) {
355
- function debouncedTrigger() {
356
- trigger('Send Page Info', 'pageInfo:' + getPageInfo(), iframe, iframeId)
357
- }
358
- debounceFrameEvents(debouncedTrigger, 32, iframeId)
359
- }
360
-
361
- function startPageInfoMonitor() {
362
- function setListener(type, func) {
363
- function sendPageInfo() {
364
- if (settings[id]) {
365
- sendPageInfoToIframe(settings[id].iframe, id)
366
- } else {
367
- stop()
368
- }
369
- }
370
-
371
- ;['scroll', 'resize'].forEach(function (evt) {
372
- log(id, type + evt + ' listener for sendPageInfo')
373
- func(window, evt, sendPageInfo)
374
- })
375
- }
376
-
377
- function stop() {
378
- setListener('Remove ', removeEventListener)
379
- }
380
-
381
- function start() {
382
- setListener('Add ', addEventListener)
383
- }
384
-
385
- var id = iframeId // Create locally scoped copy of iFrame ID
386
-
387
- start()
388
-
389
- if (settings[id]) {
390
- settings[id].stopPageInfo = stop
391
- }
392
- }
393
-
394
- function stopPageInfoMonitor() {
395
- if (settings[iframeId] && settings[iframeId].stopPageInfo) {
396
- settings[iframeId].stopPageInfo()
397
- delete settings[iframeId].stopPageInfo
398
- }
399
- }
400
-
401
- function checkIFrameExists() {
402
- var retBool = true
403
-
404
- if (null === messageData.iframe) {
405
- warn(iframeId, 'IFrame (' + messageData.id + ') not found')
406
- retBool = false
407
- }
408
- return retBool
409
- }
410
-
411
- function getElementPosition(target) {
412
- var iFramePosition = target.getBoundingClientRect()
413
-
414
- getPagePosition(iframeId)
415
-
416
- return {
417
- x: Math.floor(Number(iFramePosition.left) + Number(pagePosition.x)),
418
- y: Math.floor(Number(iFramePosition.top) + Number(pagePosition.y))
419
- }
420
- }
421
-
422
- function scrollRequestFromChild(addOffset) {
423
- /* istanbul ignore next */ // Not testable in Karma
424
- function reposition() {
425
- pagePosition = newPosition
426
- scrollTo()
427
- log(iframeId, '--')
428
- }
429
-
430
- function calcOffset() {
431
- return {
432
- x: Number(messageData.width) + offset.x,
433
- y: Number(messageData.height) + offset.y
434
- }
435
- }
436
-
437
- function scrollParent() {
438
- if (window.parentIFrame) {
439
- window.parentIFrame['scrollTo' + (addOffset ? 'Offset' : '')](
440
- newPosition.x,
441
- newPosition.y
442
- )
443
- } else {
444
- warn(
445
- iframeId,
446
- 'Unable to scroll to requested position, window.parentIFrame not found'
447
- )
448
- }
449
- }
450
-
451
- var offset = addOffset
452
- ? getElementPosition(messageData.iframe)
453
- : { x: 0, y: 0 },
454
- newPosition = calcOffset()
455
-
456
- log(
457
- iframeId,
458
- 'Reposition requested from iFrame (offset x:' +
459
- offset.x +
460
- ' y:' +
461
- offset.y +
462
- ')'
463
- )
464
-
465
- if (window.top === window.self) {
466
- reposition()
467
- } else {
468
- scrollParent()
469
- }
470
- }
471
-
472
- function scrollTo() {
473
- if (false === on('onScroll', pagePosition)) {
474
- unsetPagePosition()
475
- } else {
476
- setPagePosition(iframeId)
477
- }
478
- }
479
-
480
- function findTarget(location) {
481
- function jumpToTarget() {
482
- var jumpPosition = getElementPosition(target)
483
-
484
- log(
485
- iframeId,
486
- 'Moving to in page link (#' +
487
- hash +
488
- ') at x: ' +
489
- jumpPosition.x +
490
- ' y: ' +
491
- jumpPosition.y
492
- )
493
- pagePosition = {
494
- x: jumpPosition.x,
495
- y: jumpPosition.y
496
- }
497
-
498
- scrollTo()
499
- log(iframeId, '--')
500
- }
501
-
502
- function jumpToParent() {
503
- if (window.parentIFrame) {
504
- window.parentIFrame.moveToAnchor(hash)
505
- } else {
506
- log(
507
- iframeId,
508
- 'In page link #' +
509
- hash +
510
- ' not found and window.parentIFrame not found'
511
- )
512
- }
513
- }
514
-
515
- var hash = location.split('#')[1] || '',
516
- hashData = decodeURIComponent(hash),
517
- target =
518
- document.getElementById(hashData) ||
519
- document.getElementsByName(hashData)[0]
520
-
521
- if (target) {
522
- jumpToTarget()
523
- } else if (window.top === window.self) {
524
- log(iframeId, 'In page link #' + hash + ' not found')
525
- } else {
526
- jumpToParent()
527
- }
528
- }
529
-
530
- function onMouse(event) {
531
- var mousePos = {}
532
-
533
- if (Number(messageData.width) === 0 && Number(messageData.height) === 0) {
534
- var data = getMsgBody(9).split(':')
535
- mousePos = {
536
- x: data[1],
537
- y: data[0]
538
- }
539
- } else {
540
- mousePos = {
541
- x: messageData.width,
542
- y: messageData.height
543
- }
544
- }
545
-
546
- on(event, {
547
- iframe: messageData.iframe,
548
- screenX: Number(mousePos.x),
549
- screenY: Number(mousePos.y),
550
- type: messageData.type
551
- })
552
- }
553
-
554
- function on(funcName, val) {
555
- return chkEvent(iframeId, funcName, val)
556
- }
557
-
558
- function actionMsg() {
559
- if (settings[iframeId] && settings[iframeId].firstRun) firstRun()
560
-
561
- switch (messageData.type) {
562
- case 'close': {
563
- closeIFrame(messageData.iframe)
564
- break
565
- }
566
-
567
- case 'message': {
568
- forwardMsgFromIFrame(getMsgBody(6))
569
- break
570
- }
571
-
572
- case 'mouseenter': {
573
- onMouse('onMouseEnter')
574
- break
575
- }
576
-
577
- case 'mouseleave': {
578
- onMouse('onMouseLeave')
579
- break
580
- }
581
-
582
- case 'autoResize': {
583
- settings[iframeId].autoResize = JSON.parse(getMsgBody(9))
584
- break
585
- }
586
-
587
- case 'scrollTo': {
588
- scrollRequestFromChild(false)
589
- break
590
- }
591
-
592
- case 'scrollToOffset': {
593
- scrollRequestFromChild(true)
594
- break
595
- }
596
-
597
- case 'pageInfo': {
598
- sendPageInfoToIframe(
599
- settings[iframeId] && settings[iframeId].iframe,
600
- iframeId
601
- )
602
- startPageInfoMonitor()
603
- break
604
- }
605
-
606
- case 'pageInfoStop': {
607
- stopPageInfoMonitor()
608
- break
609
- }
610
-
611
- case 'inPageLink': {
612
- findTarget(getMsgBody(9))
613
- break
614
- }
615
-
616
- case 'reset': {
617
- resetIFrame(messageData)
618
- break
619
- }
620
-
621
- case 'init': {
622
- resizeIFrame()
623
- on('onInit', messageData.iframe)
624
- break
625
- }
626
-
627
- default: {
628
- if (
629
- Number(messageData.width) === 0 &&
630
- Number(messageData.height) === 0
631
- ) {
632
- warn(
633
- 'Unsupported message received (' +
634
- messageData.type +
635
- '), this is likely due to the iframe containing a later ' +
636
- 'version of iframe-resizer than the parent page'
637
- )
638
- } else {
639
- resizeIFrame()
640
- }
641
- }
642
- }
643
- }
644
-
645
- function hasSettings(iframeId) {
646
- var retBool = true
647
-
648
- if (!settings[iframeId]) {
649
- retBool = false
650
- warn(
651
- messageData.type +
652
- ' No settings for ' +
653
- iframeId +
654
- '. Message was: ' +
655
- msg
656
- )
657
- }
658
-
659
- return retBool
660
- }
661
-
662
- function iFrameReadyMsgReceived() {
663
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
664
- for (var iframeId in settings) {
665
- trigger(
666
- 'iFrame requested init',
667
- createOutgoingMsg(iframeId),
668
- settings[iframeId].iframe,
669
- iframeId
670
- )
671
- }
672
- }
673
-
674
- function firstRun() {
675
- if (settings[iframeId]) {
676
- settings[iframeId].firstRun = false
677
- }
678
- }
679
-
680
- var msg = event.data,
681
- messageData = {},
682
- iframeId = null
683
-
684
- if ('[iFrameResizerChild]Ready' === msg) {
685
- iFrameReadyMsgReceived()
686
- } else if (isMessageForUs()) {
687
- messageData = processMsg()
688
- iframeId = messageData.id
689
- if (settings[iframeId]) {
690
- settings[iframeId].loaded = true
691
- }
692
-
693
- if (!isMessageFromMetaParent() && hasSettings(iframeId)) {
694
- log(iframeId, 'Received: ' + msg)
695
-
696
- if (checkIFrameExists() && isMessageFromIFrame()) {
697
- actionMsg()
698
- }
699
- }
700
- } else {
701
- info(iframeId, 'Ignored: ' + msg)
702
- }
703
- }
704
-
705
- function chkEvent(iframeId, funcName, val) {
706
- var func = null,
707
- retVal = null
708
-
709
- if (settings[iframeId]) {
710
- func = settings[iframeId][funcName]
711
-
712
- if ('function' === typeof func) {
713
- retVal = func(val)
714
- } else {
715
- throw new TypeError(
716
- funcName + ' on iFrame[' + iframeId + '] is not a function'
717
- )
718
- }
719
- }
720
-
721
- return retVal
722
- }
723
-
724
- function removeIframeListeners(iframe) {
725
- var iframeId = iframe.id
726
- delete settings[iframeId]
727
- }
728
-
729
- function closeIFrame(iframe) {
730
- var iframeId = iframe.id
731
- if (chkEvent(iframeId, 'onClose', iframeId) === false) {
732
- log(iframeId, 'Close iframe cancelled by onClose event')
733
- return
734
- }
735
- log(iframeId, 'Removing iFrame: ' + iframeId)
736
-
737
- try {
738
- // Catch race condition error with React
739
- if (iframe.parentNode) {
740
- iframe.parentNode.removeChild(iframe)
741
- }
742
- } catch (error) {
743
- warn(error)
744
- }
745
-
746
- chkEvent(iframeId, 'onClosed', iframeId)
747
- log(iframeId, '--')
748
- removeIframeListeners(iframe)
749
- if (destroyObserver) {
750
- destroyObserver.disconnect()
751
- destroyObserver = null
752
- }
753
- }
754
-
755
- function getPagePosition(iframeId) {
756
- if (null === pagePosition) {
757
- pagePosition = {
758
- x:
759
- window.pageXOffset === undefined
760
- ? document.documentElement.scrollLeft
761
- : window.pageXOffset,
762
- y:
763
- window.pageYOffset === undefined
764
- ? document.documentElement.scrollTop
765
- : window.pageYOffset
766
- }
767
- log(
768
- iframeId,
769
- 'Get page position: ' + pagePosition.x + ',' + pagePosition.y
770
- )
771
- }
772
- }
773
-
774
- function setPagePosition(iframeId) {
775
- if (null !== pagePosition) {
776
- window.scrollTo(pagePosition.x, pagePosition.y)
777
- log(
778
- iframeId,
779
- 'Set page position: ' + pagePosition.x + ',' + pagePosition.y
780
- )
781
- unsetPagePosition()
782
- }
783
- }
784
-
785
- function unsetPagePosition() {
786
- pagePosition = null
787
- }
788
-
789
- function resetIFrame(messageData) {
790
- function reset() {
791
- setSize(messageData)
792
- trigger('reset', 'reset', messageData.iframe, messageData.id)
793
- }
794
-
795
- log(
796
- messageData.id,
797
- 'Size reset requested by ' +
798
- ('init' === messageData.type ? 'host page' : 'iFrame')
799
- )
800
- getPagePosition(messageData.id)
801
- syncResize(reset, messageData, 'reset')
802
- }
803
-
804
- function setSize(messageData) {
805
- function setDimension(dimension) {
806
- if (!messageData.id) {
807
- log('undefined', 'messageData id not set')
808
- return
809
- }
810
- messageData.iframe.style[dimension] = messageData[dimension] + 'px'
811
- log(
812
- messageData.id,
813
- 'IFrame (' +
814
- iframeId +
815
- ') ' +
816
- dimension +
817
- ' set to ' +
818
- messageData[dimension] +
819
- 'px'
820
- )
821
- }
822
-
823
- function chkZero(dimension) {
824
- // FireFox sets dimension of hidden iFrames to zero.
825
- // So if we detect that set up an event to check for
826
- // when iFrame becomes visible.
827
-
828
- /* istanbul ignore next */ // Not testable in PhantomJS
829
- if (!hiddenCheckEnabled && '0' === messageData[dimension]) {
830
- hiddenCheckEnabled = true
831
- log(iframeId, 'Hidden iFrame detected, creating visibility listener')
832
- fixHiddenIFrames()
833
- }
834
- }
835
-
836
- function processDimension(dimension) {
837
- setDimension(dimension)
838
- chkZero(dimension)
839
- }
840
-
841
- var iframeId = messageData.iframe.id
842
-
843
- if (settings[iframeId]) {
844
- if (settings[iframeId].sizeHeight) {
845
- processDimension('height')
846
- }
847
- if (settings[iframeId].sizeWidth) {
848
- processDimension('width')
849
- }
850
- }
851
- }
852
-
853
- function syncResize(func, messageData, doNotSync) {
854
- /* istanbul ignore if */ // Not testable in PhantomJS
855
- if (
856
- doNotSync !== messageData.type &&
857
- requestAnimationFrame &&
858
- // including check for jasmine because had trouble getting spy to work in unit test using requestAnimationFrame
859
- !window.jasmine
860
- ) {
861
- log(messageData.id, 'Requesting animation frame')
862
- requestAnimationFrame(func)
863
- } else {
864
- func()
865
- }
866
- }
867
-
868
- function trigger(calleeMsg, msg, iframe, id, noResponseWarning) {
869
- function postMessageToIFrame() {
870
- var target = settings[id] && settings[id].targetOrigin
871
- log(
872
- id,
873
- '[' +
874
- calleeMsg +
875
- '] Sending msg to iframe[' +
876
- id +
877
- '] (' +
878
- msg +
879
- ') targetOrigin: ' +
880
- target
881
- )
882
- iframe.contentWindow.postMessage(msgId + msg, target)
883
- }
884
-
885
- function iFrameNotFound() {
886
- warn(id, '[' + calleeMsg + '] IFrame(' + id + ') not found')
887
- }
888
-
889
- function chkAndSend() {
890
- if (
891
- iframe &&
892
- 'contentWindow' in iframe &&
893
- null !== iframe.contentWindow
894
- ) {
895
- // Null test for PhantomJS
896
- postMessageToIFrame()
897
- } else {
898
- iFrameNotFound()
899
- }
900
- }
901
-
902
- function warnOnNoResponse() {
903
- function warning() {
904
- if (settings[id] && !settings[id].loaded && !errorShown) {
905
- errorShown = true
906
- warn(
907
- id,
908
- 'IFrame has not responded within ' +
909
- settings[id].warningTimeout / 1000 +
910
- ' seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.'
911
- )
912
- }
913
- }
914
-
915
- if (
916
- !!noResponseWarning &&
917
- settings[id] &&
918
- !!settings[id].warningTimeout
919
- ) {
920
- settings[id].msgTimeout = setTimeout(
921
- warning,
922
- settings[id].warningTimeout
923
- )
924
- }
925
- }
926
-
927
- var errorShown = false
928
-
929
- id = id || iframe.id
930
-
931
- if (settings[id]) {
932
- chkAndSend()
933
- warnOnNoResponse()
934
- }
935
- }
936
-
937
- function createOutgoingMsg(iframeId) {
938
- return (
939
- iframeId +
940
- ':' +
941
- settings[iframeId].bodyMarginV1 +
942
- ':' +
943
- settings[iframeId].sizeWidth +
944
- ':' +
945
- settings[iframeId].log +
946
- ':' +
947
- settings[iframeId].interval +
948
- ':' +
949
- settings[iframeId].enablePublicMethods +
950
- ':' +
951
- settings[iframeId].autoResize +
952
- ':' +
953
- settings[iframeId].bodyMargin +
954
- ':' +
955
- settings[iframeId].heightCalculationMethod +
956
- ':' +
957
- settings[iframeId].bodyBackground +
958
- ':' +
959
- settings[iframeId].bodyPadding +
960
- ':' +
961
- settings[iframeId].tolerance +
962
- ':' +
963
- settings[iframeId].inPageLinks +
964
- ':' +
965
- settings[iframeId].resizeFrom +
966
- ':' +
967
- settings[iframeId].widthCalculationMethod +
968
- ':' +
969
- settings[iframeId].mouseEvents
970
- )
971
- }
972
-
973
- function isNumber(value) {
974
- return typeof value === 'number'
975
- }
976
-
977
- function setupIFrame(iframe, options) {
978
- function setLimits() {
979
- function addStyle(style) {
980
- var styleValue = settings[iframeId][style]
981
- if (Infinity !== styleValue && 0 !== styleValue) {
982
- iframe.style[style] = isNumber(styleValue)
983
- ? styleValue + 'px'
984
- : styleValue
985
- log(iframeId, 'Set ' + style + ' = ' + iframe.style[style])
986
- }
987
- }
988
-
989
- function chkMinMax(dimension) {
990
- if (
991
- settings[iframeId]['min' + dimension] >
992
- settings[iframeId]['max' + dimension]
993
- ) {
994
- throw new Error(
995
- 'Value for min' +
996
- dimension +
997
- ' can not be greater than max' +
998
- dimension
999
- )
1000
- }
1001
- }
1002
-
1003
- chkMinMax('Height')
1004
- chkMinMax('Width')
1005
-
1006
- addStyle('maxHeight')
1007
- addStyle('minHeight')
1008
- addStyle('maxWidth')
1009
- addStyle('minWidth')
1010
- }
1011
-
1012
- function newId() {
1013
- var id = (options && options.id) || defaults.id + count++
1014
- if (null !== document.getElementById(id)) {
1015
- id += count++
1016
- }
1017
- return id
1018
- }
1019
-
1020
- function ensureHasId(iframeId) {
1021
- if (typeof iframeId !== 'string') {
1022
- throw new TypeError('Invaild id for iFrame. Expected String')
1023
- }
1024
-
1025
- if ('' === iframeId) {
1026
- // eslint-disable-next-line no-multi-assign
1027
- iframe.id = iframeId = newId()
1028
- logEnabled = (options || {}).log
1029
- log(
1030
- iframeId,
1031
- 'Added missing iframe ID: ' + iframeId + ' (' + iframe.src + ')'
1032
- )
1033
- }
1034
-
1035
- return iframeId
1036
- }
1037
-
1038
- function setScrolling() {
1039
- log(
1040
- iframeId,
1041
- 'IFrame scrolling ' +
1042
- (settings[iframeId] && settings[iframeId].scrolling
1043
- ? 'enabled'
1044
- : 'disabled') +
1045
- ' for ' +
1046
- iframeId
1047
- )
1048
- iframe.style.overflow =
1049
- false === (settings[iframeId] && settings[iframeId].scrolling)
1050
- ? 'hidden'
1051
- : 'auto'
1052
- switch (settings[iframeId] && settings[iframeId].scrolling) {
1053
- case 'omit': {
1054
- break
1055
- }
1056
-
1057
- case true: {
1058
- iframe.scrolling = 'yes'
1059
- break
1060
- }
1061
-
1062
- case false: {
1063
- iframe.scrolling = 'no'
1064
- break
1065
- }
1066
-
1067
- default: {
1068
- iframe.scrolling = settings[iframeId]
1069
- ? settings[iframeId].scrolling
1070
- : 'no'
1071
- }
1072
- }
1073
- }
1074
-
1075
- // The V1 iFrame script expects an int, where as in V2 expects a CSS
1076
- // string value such as '1px 3em', so if we have an int for V2, set V1=V2
1077
- // and then convert V2 to a string PX value.
1078
- function setupBodyMarginValues() {
1079
- if (
1080
- 'number' ===
1081
- typeof (settings[iframeId] && settings[iframeId].bodyMargin) ||
1082
- '0' === (settings[iframeId] && settings[iframeId].bodyMargin)
1083
- ) {
1084
- settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin
1085
- settings[iframeId].bodyMargin =
1086
- '' + settings[iframeId].bodyMargin + 'px'
1087
- }
1088
- }
1089
-
1090
- function checkReset() {
1091
- // Reduce scope of firstRun to function, because IE8's JS execution
1092
- // context stack is borked and this value gets externally
1093
- // changed midway through running this function!!!
1094
- var firstRun = settings[iframeId] && settings[iframeId].firstRun,
1095
- resetRequertMethod =
1096
- settings[iframeId] &&
1097
- settings[iframeId].heightCalculationMethod in resetRequiredMethods
1098
-
1099
- if (!firstRun && resetRequertMethod) {
1100
- resetIFrame({ iframe: iframe, height: 0, width: 0, type: 'init' })
1101
- }
1102
- }
1103
-
1104
- function setupIFrameObject() {
1105
- if (settings[iframeId]) {
1106
- settings[iframeId].iframe.iFrameResizer = {
1107
- close: closeIFrame.bind(null, settings[iframeId].iframe),
1108
-
1109
- removeListeners: removeIframeListeners.bind(
1110
- null,
1111
- settings[iframeId].iframe
1112
- ),
1113
-
1114
- resize: trigger.bind(
1115
- null,
1116
- 'Window resize',
1117
- 'resize',
1118
- settings[iframeId].iframe
1119
- ),
1120
-
1121
- moveToAnchor: function (anchor) {
1122
- trigger(
1123
- 'Move to anchor',
1124
- 'moveToAnchor:' + anchor,
1125
- settings[iframeId].iframe,
1126
- iframeId
1127
- )
1128
- },
1129
-
1130
- sendMessage: function (message) {
1131
- message = JSON.stringify(message)
1132
- trigger(
1133
- 'Send Message',
1134
- 'message:' + message,
1135
- settings[iframeId].iframe,
1136
- iframeId
1137
- )
1138
- }
1139
- }
1140
- }
1141
- }
1142
-
1143
- // We have to call trigger twice, as we can not be sure if all
1144
- // iframes have completed loading when this code runs. The
1145
- // event listener also catches the page changing in the iFrame.
1146
- function init(msg) {
1147
- function iFrameLoaded() {
1148
- trigger('iFrame.onload', msg, iframe, undefined, true)
1149
- checkReset()
1150
- }
1151
-
1152
- function createDestroyObserver(MutationObserver) {
1153
- if (!iframe.parentNode) {
1154
- return null
1155
- }
1156
-
1157
- var destroyObserver = new MutationObserver(function (mutations) {
1158
- mutations.forEach(function (mutation) {
1159
- var removedNodes = Array.prototype.slice.call(mutation.removedNodes) // Transform NodeList into an Array
1160
- removedNodes.forEach(function (removedNode) {
1161
- if (removedNode === iframe) {
1162
- closeIFrame(iframe)
1163
- }
1164
- })
1165
- })
1166
- })
1167
- destroyObserver.observe(iframe.parentNode, {
1168
- childList: true
1169
- })
1170
- return destroyObserver
1171
- }
1172
-
1173
- var MutationObserver = getMutationObserver()
1174
- if (MutationObserver) {
1175
- destroyObserver = createDestroyObserver(MutationObserver)
1176
- }
1177
-
1178
- addEventListener(iframe, 'load', iFrameLoaded)
1179
- trigger('init', msg, iframe, undefined, true)
1180
- }
1181
-
1182
- function checkOptions(options) {
1183
- if ('object' !== typeof options) {
1184
- throw new TypeError('Options is not an object')
1185
- }
1186
- }
1187
-
1188
- function copyOptions(options) {
1189
- // eslint-disable-next-line no-restricted-syntax
1190
- for (var option in defaults) {
1191
- if (Object.prototype.hasOwnProperty.call(defaults, option)) {
1192
- settings[iframeId][option] = Object.prototype.hasOwnProperty.call(
1193
- options,
1194
- option
1195
- )
1196
- ? options[option]
1197
- : defaults[option]
1198
- }
1199
- }
1200
- }
1201
-
1202
- function getTargetOrigin(remoteHost) {
1203
- return '' === remoteHost ||
1204
- null !== remoteHost.match(/^(about:blank|javascript:|file:\/\/)/)
1205
- ? '*'
1206
- : remoteHost
1207
- }
1208
-
1209
- function depricate(key) {
1210
- var splitName = key.split('Callback')
1211
-
1212
- if (splitName.length === 2) {
1213
- var name =
1214
- 'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1)
1215
- this[name] = this[key]
1216
- delete this[key]
1217
- warn(
1218
- iframeId,
1219
- "Deprecated: '" +
1220
- key +
1221
- "' has been renamed '" +
1222
- name +
1223
- "'. The old method will be removed in the next major version."
1224
- )
1225
- }
1226
- }
1227
-
1228
- function processOptions(options) {
1229
- options = options || {}
1230
-
1231
- settings[iframeId] = Object.create(null) // Protect against prototype attacks
1232
- settings[iframeId].iframe = iframe
1233
- settings[iframeId].firstRun = true
1234
- settings[iframeId].remoteHost =
1235
- iframe.src && iframe.src.split('/').slice(0, 3).join('/')
1236
-
1237
- checkOptions(options)
1238
- Object.keys(options).forEach(depricate, options)
1239
- copyOptions(options)
1240
-
1241
- if (settings[iframeId]) {
1242
- settings[iframeId].targetOrigin =
1243
- true === settings[iframeId].checkOrigin
1244
- ? getTargetOrigin(settings[iframeId].remoteHost)
1245
- : '*'
1246
- }
1247
- }
1248
-
1249
- function beenHere() {
1250
- return iframeId in settings && 'iFrameResizer' in iframe
1251
- }
1252
-
1253
- var iframeId = ensureHasId(iframe.id)
1254
-
1255
- if (beenHere()) {
1256
- warn(iframeId, 'Ignored iFrame, already setup.')
1257
- } else {
1258
- processOptions(options)
1259
- setScrolling()
1260
- setLimits()
1261
- setupBodyMarginValues()
1262
- init(createOutgoingMsg(iframeId))
1263
- setupIFrameObject()
1264
- }
1265
- }
1266
-
1267
- function debouce(fn, time) {
1268
- if (null === timer) {
1269
- timer = setTimeout(function () {
1270
- timer = null
1271
- fn()
1272
- }, time)
1273
- }
1274
- }
1275
-
1276
- var frameTimer = {}
1277
- function debounceFrameEvents(fn, time, frameId) {
1278
- if (!frameTimer[frameId]) {
1279
- frameTimer[frameId] = setTimeout(function () {
1280
- frameTimer[frameId] = null
1281
- fn()
1282
- }, time)
1283
- }
1284
- }
1285
-
1286
- // Not testable in PhantomJS
1287
- /* istanbul ignore next */
1288
-
1289
- function fixHiddenIFrames() {
1290
- function checkIFrames() {
1291
- function checkIFrame(settingId) {
1292
- function chkDimension(dimension) {
1293
- return (
1294
- '0px' ===
1295
- (settings[settingId] && settings[settingId].iframe.style[dimension])
1296
- )
1297
- }
1298
-
1299
- function isVisible(el) {
1300
- return null !== el.offsetParent
1301
- }
1302
-
1303
- if (
1304
- settings[settingId] &&
1305
- isVisible(settings[settingId].iframe) &&
1306
- (chkDimension('height') || chkDimension('width'))
1307
- ) {
1308
- trigger(
1309
- 'Visibility change',
1310
- 'resize',
1311
- settings[settingId].iframe,
1312
- settingId
1313
- )
1314
- }
1315
- }
1316
-
1317
- Object.keys(settings).forEach(function (key) {
1318
- checkIFrame(key)
1319
- })
1320
- }
1321
-
1322
- function mutationObserved(mutations) {
1323
- log(
1324
- 'window',
1325
- 'Mutation observed: ' + mutations[0].target + ' ' + mutations[0].type
1326
- )
1327
- debouce(checkIFrames, 16)
1328
- }
1329
-
1330
- function createMutationObserver() {
1331
- var target = document.querySelector('body'),
1332
- config = {
1333
- attributes: true,
1334
- attributeOldValue: false,
1335
- characterData: true,
1336
- characterDataOldValue: false,
1337
- childList: true,
1338
- subtree: true
1339
- },
1340
- observer = new MutationObserver(mutationObserved)
1341
-
1342
- observer.observe(target, config)
1343
- }
1344
-
1345
- var MutationObserver = getMutationObserver()
1346
- if (MutationObserver) {
1347
- createMutationObserver()
1348
- }
1349
- }
1350
-
1351
- function resizeIFrames(event) {
1352
- function resize() {
1353
- sendTriggerMsg('Window ' + event, 'resize')
1354
- }
1355
-
1356
- log('window', 'Trigger event: ' + event)
1357
- debouce(resize, 16)
1358
- }
1359
-
1360
- // Not testable in PhantomJS
1361
- /* istanbul ignore next */
1362
- function tabVisible() {
1363
- function resize() {
1364
- sendTriggerMsg('Tab Visible', 'resize')
1365
- }
1366
-
1367
- if ('hidden' !== document.visibilityState) {
1368
- log('document', 'Trigger event: Visibility change')
1369
- debouce(resize, 16)
1370
- }
1371
- }
1372
-
1373
- function sendTriggerMsg(eventName, event) {
1374
- function isIFrameResizeEnabled(iframeId) {
1375
- return (
1376
- settings[iframeId] &&
1377
- 'parent' === settings[iframeId].resizeFrom &&
1378
- settings[iframeId].autoResize &&
1379
- !settings[iframeId].firstRun
1380
- )
1381
- }
1382
-
1383
- Object.keys(settings).forEach(function (iframeId) {
1384
- if (isIFrameResizeEnabled(iframeId)) {
1385
- trigger(eventName, event, settings[iframeId].iframe, iframeId)
1386
- }
1387
- })
1388
- }
1389
-
1390
- function setupEventListeners() {
1391
- addEventListener(window, 'message', iFrameListener)
1392
-
1393
- addEventListener(window, 'resize', function () {
1394
- resizeIFrames('resize')
1395
- })
1396
-
1397
- addEventListener(document, 'visibilitychange', tabVisible)
1398
-
1399
- addEventListener(document, '-webkit-visibilitychange', tabVisible)
1400
- }
1401
-
1402
- function factory() {
1403
- function init(options, element) {
1404
- function chkType() {
1405
- if (!element.tagName) {
1406
- throw new TypeError('Object is not a valid DOM element')
1407
- } else if ('IFRAME' !== element.tagName.toUpperCase()) {
1408
- throw new TypeError(
1409
- 'Expected <IFRAME> tag, found <' + element.tagName + '>'
1410
- )
1411
- }
1412
- }
1413
-
1414
- if (element) {
1415
- chkType()
1416
- setupIFrame(element, options)
1417
- iFrames.push(element)
1418
- }
1419
- }
1420
-
1421
- function warnDeprecatedOptions(options) {
1422
- if (options && options.enablePublicMethods) {
1423
- warn(
1424
- 'enablePublicMethods option has been removed, public methods are now always available in the iFrame'
1425
- )
1426
- }
1427
- }
1428
-
1429
- var iFrames
1430
-
1431
- setupRequestAnimationFrame()
1432
- setupEventListeners()
1433
-
1434
- return function iFrameResizeF(options, target) {
1435
- iFrames = [] // Only return iFrames past in on this call
1436
-
1437
- warnDeprecatedOptions(options)
1438
-
1439
- switch (typeof target) {
1440
- case 'undefined':
1441
- case 'string': {
1442
- Array.prototype.forEach.call(
1443
- document.querySelectorAll(target || 'iframe'),
1444
- init.bind(undefined, options)
1445
- )
1446
- break
1447
- }
1448
-
1449
- case 'object': {
1450
- init(options, target)
1451
- break
1452
- }
1453
-
1454
- default: {
1455
- throw new TypeError('Unexpected data type (' + typeof target + ')')
1456
- }
1457
- }
1458
-
1459
- return iFrames
1460
- }
1461
- }
1462
-
1463
- function createJQueryPublicMethod($) {
1464
- if (!$.fn) {
1465
- info('', 'Unable to bind to jQuery, it is not fully loaded.')
1466
- } else if (!$.fn.iFrameResize) {
1467
- $.fn.iFrameResize = function $iFrameResizeF(options) {
1468
- function init(index, element) {
1469
- setupIFrame(element, options)
1470
- }
1471
-
1472
- return this.filter('iframe').each(init).end()
1473
- }
1474
- }
1475
- }
1476
-
1477
- if (window.jQuery !== undefined) {
1478
- createJQueryPublicMethod(window.jQuery)
1479
- }
1480
-
1481
- if (typeof define === 'function' && define.amd) {
1482
- define([], factory)
1483
- } else if (typeof module === 'object' && typeof module.exports === 'object') {
1484
- // Node for browserfy
1485
- module.exports = factory()
1486
- }
1487
- window.iFrameResize = window.iFrameResize || factory()
1488
- })()
20
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=t()}(this,(function(){"use strict";console.info("IFRAME-RESIZER 5\n\nThis package has been split into separate packages for Parent and Child pages. Along with new packages for jQuery, React and Vue.\n\nGoing forward you are advised to use the new separate packages for Parent and Child pages, rather than this combined package.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n");const e="[iframe-resizer]";const t=t=>`${e}[${function(e){return window.top===window.self?`Parent page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested parent page: ${e}`}(t)}]`,i=(e,i,...n)=>window?.console[e](t(i),...n),n=(e,...t)=>i("warn",e,...t),o=(t,i)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(t.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))((t=>(...i)=>[`${e}[${t}]`,...i].join(" "))(t))(i)),r="5.2.3",a="[iFrameSizer]",s=a.length,l=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),c=(e,t,i,n)=>e.addEventListener(t,i,n||!1),d=(e,t,i)=>e.removeEventListener(t,i,!1),u=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),t=Math.imul(t^n,2246822519),i=Math.imul(i^n,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},f=e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))),p=["<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</>."],h=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],m=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)]))),y=e=>f(p[e]),g=e=>{const t=e[f("spjluzl")];if(!t)return-1;const i=t.split("-");let n=function(e=""){let t=-2;const i=u(f(e));return i in m&&(t=m[i]),t}(i[0]);return 0===n||(e=>e[2]===u(e[0]+e[1]))(i)||(n=-2),n},w={},b=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,waitForLoad:!1,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof w[e.id].onInit&&(o(e.id,"\nDeprecated Option\n\nThe onInit() function is deprecated and has been replaced with onReady(). It will be removed in a future version of iFrame Resizer.\n "),w[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),v={position:null,version:r};function z(e){function t(){S(P),I(),L("onResized",P)}function i(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function u(e){return O.slice(O.indexOf(":")+7+e)}const f=(e,t)=>(i,n)=>{const o={};var r,a;r=function(){x(`Send ${e} (${i})`,`${e}:${t()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},p=(e,t)=>()=>{const i=t=>()=>{w[r]?e(t,r):o()};function n(e,t){t(window,"scroll",i("scroll")),t(window,"resize",i("resize window"))}function o(){n(0,d),a.disconnect(),s.disconnect()}const r=H,a=new ResizeObserver(i("page observed")),s=new ResizeObserver(i("iframe observed"));n(0,c),a.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),s.observe(w[r].iframe,{attributes:!0,childList:!1,subtree:!1}),w[r]&&(w[r][`stop${t}`]=o)},h=e=>()=>{e in w[H]&&(w[H][e](),delete w[H][e])},m=f("pageInfo",(function(){const e=document.body.getBoundingClientRect(),t=P.iframe.getBoundingClientRect(),{scrollY:i,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),y=f("parentInfo",(function(){const{iframe:e}=P,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})})),g=p(m,"PageInfo"),b=p(y,"ParentInfo"),z=h("stopPageInfo"),k=h("stopParentInfo");function F(e){const t=e.getBoundingClientRect();return R(),{x:Number(t.left)+Number(v.position.x),y:Number(t.top)+Number(v.position.y)}}function N(e){const t=e?F(P.iframe):{x:0,y:0};let i=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(P,t);window.top===window.self?(v.position=i,A(H)):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):n(H,"Unable to scroll to requested position, window.parentIFrame not found")}function A(e){const{x:t,y:i}=v.position,n=w[e]?.iframe;!1!==L("onScroll",{iframe:n,top:i,left:t,x:t,y:i})?I():$()}function C(e){let t={};if(0===P.width&&0===P.height){const e=u(9).split(":");t={x:e[1],y:e[0]}}else t={x:P.width,y:P.height};L(e,{iframe:P.iframe,screenX:Number(t.x),screenY:Number(t.y),type:P.type})}const L=(e,t)=>j(H,e,t);let O=e.data,P={},H=null;"[iFrameResizerChild]Ready"!==O?a===`${O}`.slice(0,s)&&O.slice(s).split(":")[0]in w&&(P=function(){const e=O.slice(s).split(":"),t=e[1]?Number(e[1]):0,n=w[e[0]]?.iframe,o=getComputedStyle(n);return{iframe:n,id:e[0],height:t+i(o)+l(o),width:Number(e[2]),type:e[3],msg:e[4]}}(),H=P.id,H?(function(e){if(!w[e])throw new Error(`${P.type} No settings for ${e}. Message was: ${O}`)}(H),P.type in{true:1,false:1,undefined:1}||(w[H].loaded=!0,function(){let e=!0;return null===P.iframe&&(n(H,`The iframe (${P.id}) was not found.`),e=!1),e}()&&function(){const{origin:t,sameDomain:i}=e;if(i)return!0;let n=w[H]?.checkOrigin;if(n&&"null"!=`${t}`&&!(n.constructor===Array?function(){let e=0,i=!1;for(;e<n.length;e++)if(n[e]===t){i=!0;break}return i}():function(){const e=w[H]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${P.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&function(){switch(w[H]?.firstRun&&w[H]&&(w[H].firstRun=!1),P.type){case"close":T(P.iframe);break;case"message":i=u(6),L("onMessage",{iframe:P.iframe,message:JSON.parse(i)});break;case"mouseenter":C("onMouseEnter");break;case"mouseleave":C("onMouseLeave");break;case"autoResize":w[H].autoResize=JSON.parse(u(9));break;case"scrollBy":!function(){const e=P.width,t=P.height;(window.parentIframe||window).scrollBy(e,t)}();break;case"scrollTo":N(!1);break;case"scrollToOffset":N(!0);break;case"pageInfo":m("start",H),g();break;case"parentInfo":y("start",H),b();break;case"pageInfoStop":z();break;case"parentInfoStop":k();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",i=decodeURIComponent(t);let n=document.getElementById(i)||document.getElementsByName(i)[0];n?function(){const e=F(n);v.position={x:e.x,y:e.y},A(H),window.location.hash=t}():window.top!==window.self&&window.parentIFrame&&window.parentIFrame.moveToAnchor(t)}(u(9));break;case"title":!function(e,t){w[t]?.syncTitle&&(w[t].iframe.title=e)}(P.msg,H);break;case"reset":M(P);break;case"init":t(),function(e){try{w[e].sameDomain=!!w[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){w[e].sameDomain=!1}}(H),(e=P.msg)!==r&&(void 0!==e||o(H,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n")),W=!0,L("onReady",P.iframe);break;default:if(0===P.width&&0===P.height)return void n(`Unsupported message received (${P.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===P.width||0===P.height)return;if(document.hidden)return;t()}var e,i}())):n("iframeResizer received messageData without id, message was: ",O)):Object.keys(w).forEach((e=>{w[e].mode>=0&&x("iFrame requested init",E(e),e)}))}function j(e,t,i){let n=null,o=null;if(w[e]){if(n=w[e][t],"function"!=typeof n)throw new TypeError(`${t} on iFrame[${e}] is not a function`);o=n(i)}return o}function k(e){const t=e.id;delete w[t]}function T(e){const t=e.id;if(!1!==j(t,"onClose",t)){try{e.parentNode&&e.remove()}catch(e){n(e)}j(t,"onClosed",t),k(e)}}function R(e){null===v.position&&(v.position={x:window.scrollX,y:window.scrollY})}function $(){v.position=null}function I(e){null!==v.position&&(window.scrollTo(v.position.x,v.position.y),$())}function M(e){R(e.id),S(e),x("reset","reset",e.id)}function S(e){const t=e.id;function i(t){const i=`${e[t]}px`;e.iframe.style[t]=i}w[t].sizeHeight&&i("height"),w[t].sizeWidth&&i("width")}function x(e,t,i,r){w[i]&&(w[i]?.postMessageTarget?function(){const{postMessageTarget:e,targetOrigin:n}=w[i];if(w[i].sameDomain)try{return void w[i].iframe.contentWindow.iframeChildListener(a+t)}catch(e){}e.postMessage(a+t,n)}():n(i,`[${e}] IFrame(${i}) not found`),r&&w[i]?.warningTimeout&&(w[i].msgTimeout=setTimeout((function(){if(void 0===w[i])return;const{waitForLoad:e}=w[i];w[i].loaded||w[i].loadErrorShown||(w[i].loadErrorShown=!0,o(i,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${i}</>) has not responded within ${w[i].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${e?"\nThe <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>. \n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`))}),w[i].warningTimeout)))}function E(e){const t=w[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,v.version,t.mode].join(":")}let F=0,W=!1,N=!1;const A=e=>t=>{function a(e){if(!e)return{};if("object"!=typeof e)throw new TypeError("Options is not an object");return("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&o(d,'<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.\n'),e}function s(e){const t=w[e]?.iframe?.title;return""===t||void 0===t}const d=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(t.id=i=function(){let t=e?.id||b.id+F++;return null!==document.getElementById(t)&&(t+=F++),t}(),(e||{}).log),i}(t.id);return d in w&&"iFrameResizer"in t?n(d,"Ignored iFrame, already setup."):(function(e){var i,n;w[d]={iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...b,...a(e),mode:g(e),syncTitle:s(d)},function(){if("horizontal"===w[d].direction)return w[d].sizeWidth=!0,void(w[d].sizeHeight=!1);if("none"===w[d].direction)return w[d].sizeWidth=!1,w[d].sizeHeight=!1,void(w[d].autoResize=!1);if("vertical"!==w[d].direction)throw new TypeError(d,`Direction value of "${w[d].direction}" is not valid`)}(),(i=e?.offsetSize||e?.offset)&&("vertical"===w[d].direction?w[d].offsetHeight=i:w[d].offsetWidth=i),e?.offset&&o(d,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>."),null===w[d].postMessageTarget&&(w[d].postMessageTarget=t.contentWindow),w[d].targetOrigin=!0===w[d].checkOrigin?""===(n=w[d].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(e),function(){const{mode:e}=w[d];e<0&&o("Parent",`${y(e+2)}${y(2)}`),N||e<0||(N=!0,((e,...t)=>{i("info",e,...t)})(`v${r} (${(e=>f(h[e]))(e)})`),e<1&&o("Parent",y(3)))}(),L(),function(){switch(t.style.overflow=!1===w[d]?.scrolling?"hidden":"auto",w[d]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=w[d]?w[d].scrolling:"no"}}(),function(){const{bodyMargin:e}=w[d];"number"!=typeof e&&"0"!==e||(w[d].bodyMargin=`${e}px`)}(),function(e){const{id:i}=t;-1!==w[i].mode&&-2!==w[i].mode&&(c(t,"load",(function(){x("iFrame.onload",`${e}:${W}`,i,!0),function(){const e=w[d]?.firstRun,i=w[d]?.heightCalculationMethod in l;!e&&i&&M({iframe:t,height:0,width:0,type:"init"})}()})),!1===w[i].waitForLoad&&x("init",`${e}:${W}`,i,!0))}(E(d)),function(){if(w[d]){const e={close:T.bind(null,w[d].iframe),disconnect:k.bind(null,w[d].iframe),removeListeners(){o(d,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:x.bind(null,"Window resize","resize",d),moveToAnchor(e){x("Move to anchor",`moveToAnchor:${e}`,d)},sendMessage(e){x("Send Message",`message:${e=JSON.stringify(e)}`,d)}};w[d].iframe.iframeResizer=e,w[d].iframe.iFrameResizer=e}}()),t?.iFrameResizer};function C(){!1===document.hidden&&function(e,t){const i=e=>w[e]?.autoResize&&!w[e]?.firstRun;Object.keys(w).forEach((function(n){i(n)&&x(e,t,n)}))}("Tab Visible","resize")}const L=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})((()=>{c(window,"message",z),c(document,"visibilitychange",C),window.iframeParentListener=e=>z({data:e,sameDomain:!0})})),O="[iframeResizer] ";const P=function(){function e(e){switch(!0){case!e:throw new TypeError(`${O}iframe is not defined`);case!e.tagName:throw new TypeError(`${O}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${O}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),i.push(e)}}let t,i;return function(n,o){if("undefined"==typeof window)return[];switch(t=A(n),i=[],typeof o){case"undefined":case"string":document.querySelectorAll(o||"iframe").forEach(e);break;case"object":e(o);break;default:throw new TypeError(`${O}Unexpected data type (${typeof o})`)}return Object.freeze(i)}}();return"undefined"!=typeof window&&(window.iFrameResize=window.iFrameResize||function(...e){o("","Deprecated: iFrameResize(), please use iframeResize()"),P(...e)}),P}));