Skip to content

Commit 7b385f4

Browse files
committed
initial commit with browserify
1 parent c578708 commit 7b385f4

14 files changed

+819
-29
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+2-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,2 @@
1-
# Logs
2-
logs
3-
*.log
4-
5-
# Runtime data
6-
pids
7-
*.pid
8-
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17-
.grunt
18-
19-
# node-waf configuration
20-
.lock-wscript
21-
22-
# Compiled binary addons (http://nodejs.org/api/addons.html)
23-
build/Release
24-
25-
# Dependency directory
26-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27-
node_modules
1+
/node_modules/
2+
npm-debug.log

.jscsrc

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"disallowSpacesInNamedFunctionExpression": {
3+
"beforeOpeningRoundBrace": true
4+
},
5+
"disallowSpacesInFunctionExpression": {
6+
"beforeOpeningRoundBrace": true
7+
},
8+
"disallowSpacesInAnonymousFunctionExpression": {
9+
"beforeOpeningRoundBrace": true
10+
},
11+
"disallowSpacesInFunctionDeclaration": {
12+
"beforeOpeningRoundBrace": true
13+
},
14+
"disallowEmptyBlocks": true,
15+
"disallowSpacesInsideArrayBrackets": true,
16+
"disallowSpacesInsideParentheses": true,
17+
"disallowSpaceAfterObjectKeys": true,
18+
"disallowSpaceAfterPrefixUnaryOperators": true,
19+
"disallowSpaceBeforePostfixUnaryOperators": true,
20+
"disallowSpaceBeforeBinaryOperators": [
21+
","
22+
],
23+
"disallowMixedSpacesAndTabs": true,
24+
"disallowTrailingWhitespace": true,
25+
"disallowTrailingComma": true,
26+
"disallowYodaConditions": true,
27+
"disallowKeywords": [ "with" ],
28+
"requireSpaceBeforeBlockStatements": true,
29+
"requireParenthesesAroundIIFE": true,
30+
"requireSpacesInConditionalExpression": true,
31+
"requireBlocksOnNewline": 1,
32+
"requireCommaBeforeLineBreak": true,
33+
"requireSpaceBeforeBinaryOperators": true,
34+
"requireSpaceAfterBinaryOperators": true,
35+
"requireLineFeedAtFileEnd": true,
36+
"requireCapitalizedConstructors": true,
37+
"requireDotNotation": true,
38+
"requireCurlyBraces": [
39+
"do"
40+
],
41+
"requireSpaceAfterKeywords": [
42+
"if",
43+
"else",
44+
"for",
45+
"while",
46+
"do",
47+
"switch",
48+
"case",
49+
"return",
50+
"try",
51+
"catch",
52+
"typeof"
53+
],
54+
"safeContextKeyword": "_this",
55+
"validateLineBreaks": "LF",
56+
"validateQuoteMarks": "'",
57+
"validateIndentation": 2
58+
}

.jshintrc

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"globals": {
3+
},
4+
5+
"browser": true,
6+
"devel": true,
7+
"node" : false,
8+
"browserify": true,
9+
10+
"eqeqeq": true, // Require triple equals
11+
"eqnull": true, // Tolerate use of `== null`
12+
13+
"curly": true, // Require {} for every new block or scope
14+
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
15+
"laxcomma": true, // Suppress warnings about comma-first coding style.
16+
"newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
17+
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
18+
"noempty": true, // Prohibit use of empty blocks.
19+
"sub": true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
20+
"undef": true, // Require all non-global variables be declared before they are used.
21+
"latedef": true, // Prohibit variable use before definition.
22+
"strict": true, // Require `use strict` pragma in every file.
23+
"globalstrict": true, // Allow global use strict, wrapped by browserify
24+
"trailing": true, // Prohibit trailing whitespaces.
25+
"unused": "var", // Prohibit unused variable definitions but allow unused function parameters
26+
27+
"laxbreak": false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
28+
"debug": false, // Allow debugger statements
29+
"boss" : false, // Tolerate assignments in conditionals
30+
"evil": false, // Tolerate use of eval
31+
"forin": false, // Tolerate `for in` loops without `hasOwnProperty`
32+
"nonew": false, // Prohibit use of constructors for side-effects. `new Blah()` without storing value
33+
"plusplus": false, // Prohibit `++` & `--`
34+
35+
"regexp": false,
36+
"white": false,
37+
38+
39+
"quotmark": "single", // Enforce use of single quotation marks for strings
40+
"indent": 2
41+
}

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- 'iojs'
5+
- '0.12'
6+
- '0.10'

README.md

+77-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,77 @@
1-
# hermes
2-
Small wrapper on top of Cross Origin postMessage
1+
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
2+
3+
> Small wrapper on top of Cross Origin postMessage
4+
5+
6+
## Install
7+
8+
### Bower
9+
```sh
10+
$ bower install --save hermes-messenger
11+
```
12+
13+
### Browserify
14+
```sh
15+
$ npm install --save hermes-messenger
16+
```
17+
18+
## Usage
19+
20+
```js
21+
var Hermes = require('hermes-messenger');
22+
23+
var hermes = new Hermes(document.querySelector('iframe'), '*');
24+
25+
// Send a message to an iframe
26+
hermes.send({ message: 'Testing Rainbows!' });
27+
28+
// Send a message and get a response
29+
hermes.send({
30+
message: 'How many rainbows?!',
31+
callback: function(err, data) {
32+
}
33+
});
34+
35+
// Listen for messages
36+
hermes.on('message', function(data) {
37+
38+
});
39+
40+
// Listen for messages and respond
41+
hermes.on('message', function(data, cb) {
42+
var err = false;
43+
44+
if (cb) {
45+
if (err) {
46+
cb('Error getting data'); // Send error
47+
} else {
48+
cb(null, 'All of the rainbows');
49+
}
50+
}
51+
});
52+
```
53+
54+
## Browser Compatibility
55+
56+
[Cross-document message](http://caniuse.com/#feat=x-doc-messaging)
57+
58+
For all versions of IE, the window must be either a Frame or Iframe. Popups won't work.
59+
60+
## Building
61+
62+
```sh
63+
# creates browser files
64+
$ gulp
65+
```
66+
67+
## License
68+
69+
MIT © [JobHero](gojobhero.com)
70+
71+
72+
[npm-image]: https://badge.fury.io/js/hermes-messenger.svg
73+
[npm-url]: https://npmjs.org/package/hermes-messenger
74+
[travis-image]: https://travis-ci.org/JetFault/hermes-messenger.svg?branch=master
75+
[travis-url]: https://travis-ci.org/JetFault/hermes-messenger
76+
[daviddm-image]: https://david-dm.org/JetFault/hermes-messenger.svg?theme=shields.io
77+
[daviddm-url]: https://david-dm.org/JetFault/hermes-messenger

bower.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "hermes-messenger",
3+
"main": "dist/hermes-messenger.min.js",
4+
"version": "0.0.0",
5+
"homepage": "https://github.com/JobHero/hermes-messenger",
6+
"authors": [
7+
"Jerry Reptak <[email protected]>"
8+
],
9+
"description": "Small wrapper on top of Cross Origin postMessage",
10+
"keywords": [
11+
"hermes-messenger",
12+
"postmessage"
13+
],
14+
"license": "MIT",
15+
"ignore": [
16+
"**/.*",
17+
"node_modules",
18+
"test",
19+
"gulpfile.js"
20+
]
21+
}

0 commit comments

Comments
 (0)