1.2.1 • Published 7 years ago

popperupper v1.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

popperupper

This is a small project to add a button to any page that launches an app in a modal iframe.

Development

Run npm install and npm run build before using the code from source.

Usage

<html>
  <body>
    <h1>Example page</h1>
    <p>Some content appearing before the button</p>
    <script async src="./popperupper.js" data-url="http://url-of.app/?andany=parameters"></script>
    <p>Some content appearing after the button</p>
  </body>
</html>

Options

Options can be specified as data attributes on the script element.

AttributeDescriptionDefault
data-urlURL of the app to load in the iframe''
data-labelLabel of the button'Launch external application'
data-classSpace separated classes to be applied to the button''

Controlling the modal with the app

From the application mounted within the modal, the modal itself can be resized or closed. To do this and remain cross-origin safe, it uses iframe-resizer. Once you have this dependency installed, instatiate it using the code below (some linting rules may need to be disabled).

import { iframeResizerContentWindow } from 'iframe-resizer';

// This needs to be referenced so it isn't tree-shaken.
iframeResizerContentWindow;

The resize logic will look for an element with the tag [data-iframe-height] and use its height to resize the modal window.

You can close the modal window from the application by dispatching the following message

window.parentIFrame.sendMessage('POPPERUPPER_CLOSE');

In TypeScript you may need to replace window with (<any>window) for it to allow parentIFrame.

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago