Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

better ender integration

  • Loading branch information...
commit 25ce2c89a58795b883a0c1041e9cffb233568d2d 1 parent 7cda758
@thomassturm thomassturm authored
Showing with 10 additions and 12 deletions.
  1. +9 −11 ender-postmessage.js
  2. +1 −1  ender-postmessage.min.js
View
20 ender-postmessage.js
@@ -20,7 +20,7 @@
// 0.5 - (9/11/2009) Improved cache-busting
// 0.4 - (8/25/2009) Initial release
-!function ($) {
+!function (window) {
// A few vars used in non-awesome browsers
var interval_id,
last_hash,
@@ -37,12 +37,10 @@
// Reused internal strings.
postMessage = 'postMessage',
addEventListener = 'addEventListener',
-
- p_receiveMessage,
- has_postMessage = window[postMessage];
+ has_postMessage = window[postMessage];
- $.ender({
+ fn = {};
// Method: ender.postMessage
//
@@ -72,7 +70,7 @@
//
// Nothing.
- postMessage: function( message, target_url, target ) {
+ fn.postMessage = function( message, target_url, target ) {
if ( !target_url ) { return; }
// Default to parent if unspecified.
@@ -90,7 +88,7 @@
// callback.
target.location = target_url.replace( /#.*$/, '' ) + '#' + (+new Date) + (cache_bust++) + '&' + message;
}
- },
+ };
// Method: ender.receiveMessage
//
@@ -139,7 +137,7 @@
//
// Nothing!
- receiveMessage: function( callback, source_origin, delay ) {
+ fn.receiveMessage = function( callback, source_origin, delay ) {
if ( has_postMessage ) {
// Since the browser supports window.postMessage, the callback will be
// bound to the actual event associated with window.postMessage.
@@ -196,6 +194,6 @@
}, delay );
}
}
- }
- });
-}(ender);
+ };
+ module.exports = {postMessage: fn.postMessage, receiveMessage: fn.receiveMessage};
+}(window);
View
2  ender-postmessage.min.js
@@ -17,4 +17,4 @@
// jQuery postMessage
// 0.5 - (9/11/2009) Improved cache-busting
// 0.4 - (8/25/2009) Initial release
-!function(a){var b,c,d,e=1,f,g=this,h=!1,i="postMessage",j="addEventListener",k,l=g[i];a.ender({postMessage:function(a,b,c){!b||(c=c||parent,l?c[i](a,b.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):b&&(c.location=b.replace(/#.*$/,"")+"#"+ +(new Date)+e++ +"&"+a))},receiveMessage:function(a,e,i){l?(a&&(f&&receiveMessage(),f=function(b){if(typeof e=="string"&&b.origin!==e||typeof e=="function"&&e(b.origin)===h)return h;a(b)}),g[j]?g[a?j:"removeEventListener"]("message",f,h):g[a?"attachEvent":"detachEvent"]("onmessage",f)):(b&&clearInterval(b),b=null,a&&(i=typeof e=="number"?e:typeof i=="number"?i:100,d=document.location.hash,b=setInterval(function(){var b=document.location.hash,e=/^#?\d+&/;b!==c&&b!==d&&e.test(b)&&(c=b,d?document.location.hash=d:document.location.hash="",a({data:b.replace(e,"")}))},i)))}})}(ender)
+!function(a){var b,c,d,e=1,f,a=this,g=!1,h="postMessage",i="addEventListener",j=a[h];fn={},fn.postMessage=function(a,b,c){!b||(c=c||parent,j?c[h](a,b.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):b&&(c.location=b.replace(/#.*$/,"")+"#"+ +(new Date)+e++ +"&"+a))},fn.receiveMessage=function(e,h,k){j?(e&&(f&&receiveMessage(),f=function(a){if(typeof h=="string"&&a.origin!==h||typeof h=="function"&&h(a.origin)===g)return g;e(a)}),a[i]?a[e?i:"removeEventListener"]("message",f,g):a[e?"attachEvent":"detachEvent"]("onmessage",f)):(b&&clearInterval(b),b=null,e&&(k=typeof h=="number"?h:typeof k=="number"?k:100,d=document.location.hash,b=setInterval(function(){var a=document.location.hash,b=/^#?\d+&/;a!==c&&a!==d&&b.test(a)&&(c=a,d?document.location.hash=d:document.location.hash="",e({data:a.replace(b,"")}))},k)))},module.exports={postMessage:fn.postMessage,receiveMessage:fn.receiveMessage}}(window)
Please sign in to comment.
Something went wrong with that request. Please try again.