├── index.js ├── .ncurc.json ├── spec ├── resources │ ├── djb.jpg │ ├── frame.lateload.html │ ├── frame.nested.html │ └── frame.content.html ├── javascripts │ └── fixtures │ │ ├── iframe.html │ │ ├── iframe600.html │ │ ├── iframe600WithId.html │ │ └── twoIFrame600WithId.html ├── support │ └── jasmine.json ├── initJQuerySpec.js ├── initUndefinedDomSpec.js ├── initDomSpec.js ├── initDoubleCallSpec.js ├── initCssSpec.js ├── closeSpecSpec.js ├── scrollSpec.js ├── anchorSpec.js ├── lib │ └── common.js ├── sendMessageSpec.js ├── initErrorSpec.js ├── _initSpec.js ├── getPageInfoSpec.js └── parentSpec.js ├── test ├── resources │ ├── djb.jpg │ ├── testLib.js │ ├── frame.lateload.html │ ├── frame.nested.html │ ├── qunit.css │ └── frame.content.html ├── close.html ├── _init.html ├── nested.html ├── jqueryNoConflict.html ├── background.html ├── setHeightCalculationMethod.html ├── getId.html ├── resize.contentWidth.html ├── changePage.html ├── _init_once.html ├── interval.html ├── margin.html ├── sendMessage.html ├── mutationObserver.html ├── noMessageForBlackListedOrigins.html ├── _init_once_async.html ├── size.html ├── resize.width.html ├── lateImageLoad.html ├── removeIFrame.html ├── scrolling.html └── v1.html ├── .travis.yml ├── docs ├── use_with │ ├── jquery.md │ └── vue.md ├── upgrade.md ├── iframed_page │ ├── events.md │ ├── options.md │ └── methods.md ├── parent_page │ ├── methods.md │ ├── events.md │ └── options.md ├── readme.md ├── getting_started.md └── troubleshooting.md ├── .gitignore ├── README.md ├── js ├── index.js ├── iframeResizer.min.js └── iframeResizer.contentWindow.min.js ├── .npmignore ├── .prettierrc ├── FUNDING.md ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── FUNDING.yml ├── bower.json ├── LICENSE ├── .eslintrc ├── test-main.js ├── example ├── frame.textarea.html ├── frame.hover.html ├── index.html ├── two.html ├── frame.nested.html ├── frame.tolerance.html ├── frame.absolute.html └── frame.content.html ├── karma.conf.js ├── CONTRIBUTING.md ├── package.json └── gruntfile.js /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./js') 2 | -------------------------------------------------------------------------------- /.ncurc.json: -------------------------------------------------------------------------------- 1 | { 2 | "reject": ["grunt-contrib-qunit"] 3 | } 4 | -------------------------------------------------------------------------------- /spec/resources/djb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vote/clean-iframe-resizer/clean/spec/resources/djb.jpg -------------------------------------------------------------------------------- /test/resources/djb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vote/clean-iframe-resizer/clean/test/resources/djb.jpg -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "11.0" 4 | before_script: 5 | - npm install -g grunt-cli 6 | sudo: false 7 | -------------------------------------------------------------------------------- /spec/javascripts/fixtures/iframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "spec_files": ["**/*[sS]pec.js"], 4 | "helpers": ["helpers/**/*.js"] 5 | } 6 | -------------------------------------------------------------------------------- /docs/use_with/jquery.md: -------------------------------------------------------------------------------- 1 | ## jQuery 2 | 3 | This library also provides a simple jQuery interface 4 | 5 | ```js 6 | $('iframe').iFrameResize([{ options }]) 7 | ``` 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .coveralls.yml 3 | node_modules 4 | bin 5 | example/test.html 6 | test/*.off 7 | npm-debug.log 8 | bower_components 9 | coverage* 10 | .idea 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clean iFrame resizer 2 | 3 | Clean iFrame Resizer is a fork of [iFrame Resizer](https://github.com/davidjbradshaw/iframe-resizer) that does not pollute `window` or try to add a plugin to `jquery` 4 | -------------------------------------------------------------------------------- /spec/javascripts/fixtures/iframe600.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
6 |
--------------------------------------------------------------------------------
/docs/iframed_page/events.md:
--------------------------------------------------------------------------------
1 | ## IFrame Page Events
2 |
3 | The following events can be included in the [options](options.md) object attached to the iframed page.
4 |
5 | ### onMessage
6 |
7 | type: function (message)
8 |
9 | Receive message posted from the parent page with the `iframe.iFrameResizer.sendMessage()` method.
10 |
11 | ### onReady
12 |
13 | type: function()
14 |
15 | This function is called once iFrame-Resizer has been initialized after receiving a call from the parent page. If you need to call any of the parentIFrame methods (See below) during page load, then they should be called from this event handler.
16 |
--------------------------------------------------------------------------------
/spec/initJQuerySpec.js:
--------------------------------------------------------------------------------
1 | /* jshint undef: false, unused: true */
2 |
3 | 'use strict'
4 |
5 | define(['iframeResizer', 'jquery'], function(iFrameResize, $) {
6 | describe('iFrame init(jQuery)', function() {
7 | var iframe
8 |
9 | beforeAll(function() {
10 | loadIFrame('iframe600.html')
11 |
12 | var $iframes = $('iframe').iFrameResize()
13 |
14 | iframe = $iframes.get(0)
15 | })
16 |
17 | afterAll(function() {
18 | tearDown(iframe)
19 | })
20 |
21 | it('should create iFrameResizer object', function() {
22 | expect(iframe.iFrameResizer).toBeDefined()
23 | })
24 | })
25 | })
26 |
--------------------------------------------------------------------------------
/spec/initUndefinedDomSpec.js:
--------------------------------------------------------------------------------
1 | /* jshint undef: false, unused: true */
2 |
3 | 'use strict'
4 |
5 | define(['iframeResizer'], function(iFrameResize) {
6 | describe('iFrame init(DOM Object)', function() {
7 | var iframe
8 |
9 | beforeAll(function() {
10 | loadIFrame('iframe600.html')
11 |
12 | iframe = iFrameResize(
13 | undefined,
14 | document.getElementsByTagName('iframe')[0]
15 | )[0]
16 | })
17 |
18 | afterAll(function() {
19 | tearDown(iframe)
20 | })
21 |
22 | it('should create iFrameResizer object', function() {
23 | expect(iframe.iFrameResizer).toBeDefined()
24 | })
25 | })
26 | })
27 |
--------------------------------------------------------------------------------
/spec/initDomSpec.js:
--------------------------------------------------------------------------------
1 | /* jshint undef: false, unused: true */
2 |
3 | 'use strict'
4 |
5 | define(['iframeResizer'], function(iFrameResize) {
6 | describe('iFrame init(DOM Object)', function() {
7 | var iframe
8 |
9 | beforeAll(function() {
10 | loadIFrame('iframe600.html')
11 |
12 | iframe = iFrameResize(
13 | {
14 | log: LOG
15 | },
16 | document.getElementsByTagName('iframe')[0]
17 | )[0]
18 | })
19 |
20 | afterAll(function() {
21 | tearDown(iframe)
22 | })
23 |
24 | it('should create iFrameResizer object', function() {
25 | expect(iframe.iFrameResizer).toBeDefined()
26 | })
27 | })
28 | })
29 |
--------------------------------------------------------------------------------
/docs/use_with/vue.md:
--------------------------------------------------------------------------------
1 | ## Vue
2 |
3 | Create the following Vue directive
4 |
5 | ```js
6 | import Vue from 'vue'
7 | import iFrameResize from 'iframe-resizer/js/iframeResizer'
8 |
9 | Vue.directive('resize', {
10 | bind: function(el, { value = {} }) {
11 | el.addEventListener('load', () => iFrameResize(value, el))
12 | }
13 | })
14 | ```
15 |
16 | and then include it on you page as follows.
17 |
18 | ```html
19 |
25 | ```
26 |
27 | - Thanks to [Aldebaran Desombergh](https://github.com/davidjbradshaw/iframe-resizer/issues/513#issuecomment-538333854) for this example
28 |
--------------------------------------------------------------------------------
/docs/parent_page/methods.md:
--------------------------------------------------------------------------------
1 | ## IFrame Object Methods
2 |
3 | Once the iFrame has been initialized, an `iFrameResizer` object is bound to it. This has the following methods available.
4 |
5 | ### close()
6 |
7 | Remove the iFrame from the page.
8 |
9 | ### moveToAnchor(anchor)
10 |
11 | Move to anchor in iFrame.
12 |
13 | ### removeListeners()
14 |
15 | Detach event listeners from iFrame. This is option allows Virtual DOMs to remove an iFrame tag. It should not normally be required.
16 |
17 | ### resize()
18 |
19 | Tell the iFrame to resize itself.
20 |
21 | ### sendMessage(message, [targetOrigin])
22 |
23 | Send data to the containing page, `message` can be any data type that can be serialized into JSON. The `targetOrigin` option is used to restrict where the message is sent to, in case your iFrame navigates away to another domain.
24 |
--------------------------------------------------------------------------------
/docs/readme.md:
--------------------------------------------------------------------------------
1 | # iFrame-Resizer Documentation
2 |
3 | - [Getting Started](getting_started.md)
4 | - **Parent Page API**
5 | - [Options](parent_page/options.md)
6 | - [Events](parent_page/events.md)
7 | - [Methods](parent_page/methods.md)
8 | - **IFramed Page API**
9 | - [Options](iframed_page/options.md)
10 | - [Events](iframed_page/events.md)
11 | - [Methods](iframed_page/methods.md)
12 | - **Use with Libraries and Frameworks**
13 | - [React](https://github.com/zeroasterisk/react-iframe-resizer-super)
14 | - [Vue](https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/use_with/vue.md)
15 | - [Angular](https://github.com/davidjbradshaw/iframe-resizer/issues/478#issuecomment-347958630)
16 | - [jQuery](use_with/jquery.md)
17 | - [Troubleshooting](troubleshooting.md)
18 | - [Upgrade from version 3](upgrade.md)
19 | - [Version history](../CHANGELOG.md)
20 |
--------------------------------------------------------------------------------
/spec/initDoubleCallSpec.js:
--------------------------------------------------------------------------------
1 | /* jshint undef: false, unused: true */
2 |
3 | 'use strict'
4 |
5 | define(['iframeResizer'], function(iFrameResize) {
6 | describe('iFrame init(Double)', function() {
7 | var iframe
8 |
9 | beforeAll(function() {
10 | loadIFrame('iframe600WithId.html')
11 | //spyOn(console,'warn');
12 | })
13 |
14 | afterAll(function() {
15 | tearDown(iframe)
16 | })
17 |
18 | it('should create iFrameResizer object', function() {
19 | window.parentIFrame = {
20 | getId: function() {
21 | return 'getIdTest'
22 | }
23 | }
24 | iframe = iFrameResize({ log: LOG }, '#doubleTest')[0]
25 | iFrameResize({ log: LOG }, '#doubleTest')
26 | expect(iframe.iFrameResizer).toBeDefined()
27 | expect(console.warn).toHaveBeenCalled()
28 | delete window.parentIFrame
29 | })
30 | })
31 | })
32 |
--------------------------------------------------------------------------------
/spec/initCssSpec.js:
--------------------------------------------------------------------------------
1 | /* jshint undef: false, unused: true */
2 |
3 | 'use strict'
4 |
5 | define(['iframeResizer'], function(iFrameResize) {
6 | describe('iFrame init(CSS Selector)', function() {
7 | var iframe
8 |
9 | beforeAll(function(done) {
10 | loadIFrame('iframe600.html')
11 |
12 | iframe = iFrameResize(
13 | {
14 | log: LOG,
15 | minHeight: 99999,
16 | onResized: done,
17 | checkOrigin: [
18 | 'http://localhost',
19 | 'https://localhost',
20 | location.href
21 | .split('/')
22 | .slice(0, 3)
23 | .join('/')
24 | ]
25 | },
26 | 'iframe'
27 | )[0]
28 | })
29 |
30 | afterAll(function() {
31 | tearDown(iframe)
32 | })
33 |
34 | it('should create iFrameResizer object', function() {
35 | expect(iframe.iFrameResizer).toBeDefined()
36 | })
37 | })
38 | })
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/spec/closeSpecSpec.js:
--------------------------------------------------------------------------------
1 | define(['iframeResizer'], function(iFrameResize) {
2 | describe('Close iFrame', function() {
3 | var iframe
4 |
5 | beforeEach(function() {
6 | loadIFrame('iframe600.html')
7 | })
8 |
9 | it('closes from parent', function(done) {
10 | var evtCounter = 0
11 |
12 | iframe = iFrameResize({
13 | log: LOG,
14 | id: 'close1',
15 | onClosed: function() {
16 | setTimeout(done, 0)
17 | }
18 | })[0]
19 |
20 | setTimeout(iframe.iFrameResizer.close, 1)
21 | })
22 |
23 | it('closes from iframe', function(done) {
24 | var evtCounter = 0
25 |
26 | iframe = iFrameResize({
27 | log: LOG,
28 | id: 'close2',
29 | onClosed: function() {
30 | setTimeout(done, 0)
31 | },
32 | onInit: function(iframe) {
33 | iframe.iFrameResizer.sendMessage('close')
34 | }
35 | })[0]
36 |
37 | mockMsgFromIFrame(iframe, 'close')
38 | })
39 | })
40 | })
41 |
--------------------------------------------------------------------------------
/test/resources/frame.lateload.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Load JS with require after load event has fired.
31 |Load JS with require after load event has fired.
32 |21 | Resize the textarea below. 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/_init.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Resize window or click one of the links in the nested iFrame to watch it resize.
20 |24 |
25 | 26 | 27 | 28 | 29 | 30 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /test/background.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Resize window or click one of the links in the nested iFrame to watch it resize.
22 |26 |
27 | 28 | 29 | 30 | 31 | 32 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/resize.contentWidth.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |