Coder Social home page Coder Social logo

postit-1's Introduction

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).

Param Type
id string
PostIt.add('baz');

.remove(id) => object

Removes a PostIt instance (id).

Param Type
id string
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).

Param Type
id string
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.

Param Type
id string
event string
listener function
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.
Param Type
id string
event string
[listener] function
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.
Param Type
id string
event string
target object
message string array object
origin string
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).

Param Type
url string
name string
options object
options.width number
options.height number

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

postit-1's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.