Skip to content

Commit

Permalink
Merge pull request #46 from lutangar/features/npm
Browse files Browse the repository at this point in the history
Add package.json for npm support. Thanks @lutangar
  • Loading branch information
georges authored Aug 11, 2016
2 parents 2d4e337 + 04e9482 commit d3dcc86
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 35 deletions.
20 changes: 9 additions & 11 deletions example/abc.com/js/porthole.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
(function(window){
'use strict';
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;

// The base Class implementation (does nothing)
this.PortholeClass = function(){};
var PortholeClass = function(){};

// Create a new Class that inherits from this class
PortholeClass.extend = function(prop) {
Expand Down Expand Up @@ -97,14 +98,10 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
Class.prototype.constructor = Class;

// And make this class extendable
Class.extend = arguments.callee;
Class.extend = PortholeClass.extend;

return Class;
};
})();

(function (window) {
'use strict';

/**
* @overview Porthole, JavaScript Library for Secure Cross Domain iFrame Communication.
Expand Down Expand Up @@ -132,7 +129,7 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
* @private
*/
error: function(s) {
if (window.console !== undefined) {
if (typeof window.console !== undefined && typeof window.console.error === 'function') {
window.console.error('Porthole: ' + s);
}
}
Expand Down Expand Up @@ -231,6 +228,7 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
try {
this.eventListeners[i](event);
} catch(e) {
Porthole.error(e);
}
}
}
Expand Down Expand Up @@ -508,9 +506,9 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
};

// Support testing in node.js:
if (typeof window.exports !== 'undefined') {
window.exports.Porthole = Porthole;
if (typeof exports !== 'undefined') {
module.exports = Porthole;
} else {
window.Porthole = Porthole;
}
})(this);
})(typeof window !== "undefined" ? window : this);
2 changes: 1 addition & 1 deletion example/abc.com/js/porthole.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions example/sandbox.ternarylabs.com/porthole/js/porthole.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
(function(window){
'use strict';
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;

// The base Class implementation (does nothing)
this.PortholeClass = function(){};
var PortholeClass = function(){};

// Create a new Class that inherits from this class
PortholeClass.extend = function(prop) {
Expand Down Expand Up @@ -97,14 +98,10 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
Class.prototype.constructor = Class;

// And make this class extendable
Class.extend = arguments.callee;
Class.extend = PortholeClass.extend;

return Class;
};
})();

(function (window) {
'use strict';

/**
* @overview Porthole, JavaScript Library for Secure Cross Domain iFrame Communication.
Expand Down Expand Up @@ -132,7 +129,7 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
* @private
*/
error: function(s) {
if (window.console !== undefined) {
if (typeof window.console !== undefined && typeof window.console.error === 'function') {
window.console.error('Porthole: ' + s);
}
}
Expand Down Expand Up @@ -231,6 +228,7 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
try {
this.eventListeners[i](event);
} catch(e) {
Porthole.error(e);
}
}
}
Expand Down Expand Up @@ -508,9 +506,9 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
};

// Support testing in node.js:
if (typeof window.exports !== 'undefined') {
window.exports.Porthole = Porthole;
if (typeof exports !== 'undefined') {
module.exports = Porthole;
} else {
window.Porthole = Porthole;
}
})(this);
})(typeof window !== "undefined" ? window : this);
Loading

0 comments on commit d3dcc86

Please sign in to comment.