1.1.7 • Published 8 years ago

postit-js v1.1.7

Weekly downloads
3
License
MIT
Repository
-
Last release
8 years ago

PostIt

An elegant wrapper for postMessage.

Unit Test Coverage Known Vulnerabilities

Installation

Install postit-js as a dependency.

$ npm install --save postit-js

Run PostIt in a Browser

HTML Script Element

<script src="path/to/postit.js"></script>

CommonJS Browser Shimming (Browserify and Other Flavors)

var PostIt = require('postit');

API Documentation

.add(id) => object

Creates and manages a PostIt instance (id).

ParamType
idstring
PostIt.add('baz');

.remove(id) => object

Removes a PostIt instance (id).

ParamType
idstring
PostIt.remove('baz');

.removeAll() => object

Removes all PostIt instances.

PostIt.removeAll();

.size() => number

Returns the length of all PostIt instances.

PostIt.size();

.get(id) => object | void

Gets a PostIt instance (id).

ParamType
idstring
PostIt.get('baz');

.getAll() => object

Gets all PostIt instances.

PostIt.getAll();

.on(id, event, listener) => object

Registers a listener to a PostIt instance (id), for a given event.

ParamType
idstring
eventstring
listenerfunction
PostIt.on('baz', 'bar', function(event) {
	// ...
});

.off(id, event, listener) => object

  • If a listener is not provided, then unregister all listeners from a PostIt instance (id), for a given event.
  • If a listener is provided, then unregister a listener from a PostIt instance (id), for a given event.
ParamType
idstring
eventstring
listenerfunction
PostIt.off('baz', 'bar');

function bazBar() {}

PostIt.off('baz', 'bar', bazBar);

.emit(id, event, target, message, origin) => object

  • If event is an asterisk (*), then emit an event to all listeners registered to a PostIt instance (id), for all given events.
  • If event is not an asterisk (*), then emit an event to all listeners registered to a PostIt instance (id), for a given event.
ParamType
idstring
eventstring
targetobject
messagestring array object
originstring
PostIt.emit('baz', 'bar', window.parent.opener, { baz: 'bar' }, 'http://www.baz.com');

.openWindow(url, name, options) => object

Loads a resource into a new browsing context (window).

ParamType
urlstring
namestring
optionsobject
options.widthnumber
options.heightnumber

See: window.open for more options.

PostIt.openWindow('http://www.foo.com', 'foo', {
	width: 700,
	height: 500
});

Example

Example

Contributing

Contributing

Changelog

Changelog

License

MIT License

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago