PostIt
An elegant wrapper for postMessage
.
Installation
Install postit-js
as a dependency.
$ npm install --save postit-js
Run PostIt in a Browser
HTML Script Element
CommonJS Browser Shimming (Browserify and Other Flavors)
var PostIt = ;
API Documentation
object
.add(id) => Creates and manages a PostIt
instance (id
).
Param | Type |
---|---|
id | string |
PostIt;
object
.remove(id) => Removes a PostIt
instance (id
).
Param | Type |
---|---|
id | string |
PostIt;
object
.removeAll() => Removes all PostIt
instances.
PostIt;
number
.size() => Returns the length of all PostIt
instances.
PostItsize;
object
| void
.get(id) => Gets a PostIt
instance (id
).
Param | Type |
---|---|
id | string |
PostIt;
object
.getAll() => Gets all PostIt
instances.
PostIt;
object
.on(id, event, listener) => Registers a listener
to a PostIt
instance (id
), for a given event
.
Param | Type |
---|---|
id | string |
event | string |
listener | function |
PostIt;
object
.off(id, event[, listener]) => - If a
listener
is not provided, then unregister all listeners from aPostIt
instance (id
), for a givenevent
. - If a
listener
is provided, then unregister alistener
from aPostIt
instance (id
), for a givenevent
.
Param | Type |
---|---|
id | string |
event | string |
[listener] | function |
PostIt; {} PostIt;
object
.emit(id, event, target, message, origin) => - If
event
is an asterisk (*), then emit anevent
to all listeners registered to aPostIt
instance (id
), for all givenevent
s. - If
event
is not an asterisk (*), then emit anevent
to all listeners registered to aPostIt
instance (id
), for a givenevent
.
Param | Type |
---|---|
id | string |
event | string |
target | object |
message | string array object |
origin | string |
PostIt;
object
.openWindow(url, name, options) => Loads a resource into a new browsing context (window
).
Param | Type |
---|---|
url | string |
name | string |
options | object |
options.width | number |
options.height | number |
See: window.open for more options.
PostIt;