Giter Club home page Giter Club logo

postit's Introduction

PostIt

An elegant wrapper for postMessage.

Unit Test Coverage

Getting Started

PostIt requires git and Node.js, before proceeding.

# Install postit
$ npm install --save git+ssh://[email protected]/outbrain/postit.git

Run PostIt in a Browser

HTML Script Element

path/to/postit.js

<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 new PostIt instance.

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

.remove(id) => object

Removes an explicit PostIt instance.

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 an explicit PostIt instance.

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

.getAll() => object

Gets all PostIt instances.

PostIt.getAll();

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

Registers .postMessage event listeners.

Param Type
id string
event string
listener function
PostIt.on('baz', 'bar', function (event) {
	//
});

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

Unregisters (all | explicit) .postMessage event listeners.

Param Type
id string
event string
listener function
// Unregister all listeners of a given `event`:
PostIt.off('baz', 'bar');

function bazBar() {}

// Unregister an explicit listener of a given `event`:
PostIt.off('baz', 'bar', bazBar);

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

Emits explicit message events, using the client's .postMessage emitter.

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(options) => object

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

Param Type
options.url string
options.title string
options.width number
options.height number
options.top number
options.left number

See: window.open for more options.

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

Example

Example

Contributing to PostIt

Contributor Docs

Changelog

Changelog

Versioning

Releases will be numbered using the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major while resetting minor and patch.
  • New additions without breaking backward compatibility bumps the minor while resetting the patch.
  • Bug fixes and misc. changes bumps only the patch.

For more information on SemVer, please visit http://semver.org/.

License

MIT License

postit's People

Watchers

 avatar  avatar

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.