<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[19992] trunk/wp-includes: Add jQuery postMessage v 0.2.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/19992">19992</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-02-25 02:04:17 +0000 (Sat, 25 Feb 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add jQuery postMessage v 0.2. Dual licensed MIT/GPL. see <a href="http://core.trac.wordpress.org/ticket/19910">#19910</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludesjsjqueryjquerypostmessagedevjs">trunk/wp-includes/js/jquery/jquery.postmessage.dev.js</a></li>
<li><a href="#trunkwpincludesjsjqueryjquerypostmessagejs">trunk/wp-includes/js/jquery/jquery.postmessage.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesjsjqueryjquerypostmessagedevjs"></a>
<div class="addfile"><h4>Added: trunk/wp-includes/js/jquery/jquery.postmessage.dev.js (0 => 19992)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/jquery/jquery.postmessage.dev.js                                (rev 0)
+++ trunk/wp-includes/js/jquery/jquery.postmessage.dev.js        2012-02-25 02:04:17 UTC (rev 19992)
</span><span class="lines">@@ -0,0 +1,222 @@
</span><ins>+/*!
+ * jQuery postMessage - v0.5 - 9/11/2009
+ * http://benalman.com/projects/jquery-postmessage-plugin/
+ *
+ * Copyright (c) 2009 &quot;Cowboy&quot; Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+
+// Script: jQuery postMessage: Cross-domain scripting goodness
+//
+// *Version: 0.5, Last updated: 9/11/2009*
+//
+// Project Home - http://benalman.com/projects/jquery-postmessage-plugin/
+// GitHub       - http://github.com/cowboy/jquery-postmessage/
+// Source       - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.js
+// (Minified)   - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.min.js (0.9kb)
+//
+// About: License
+//
+// Copyright (c) 2009 &quot;Cowboy&quot; Ben Alman,
+// Dual licensed under the MIT and GPL licenses.
+// http://benalman.com/about/license/
+//
+// About: Examples
+//
+// This working example, complete with fully commented code, illustrates one
+// way in which this plugin can be used.
+//
+// Iframe resizing - http://benalman.com/code/projects/jquery-postmessage/examples/iframe/
+//
+// About: Support and Testing
+//
+// Information about what version or versions of jQuery this plugin has been
+// tested with and what browsers it has been tested in.
+//
+// jQuery Versions - 1.3.2
+// Browsers Tested - Internet Explorer 6-8, Firefox 3, Safari 3-4, Chrome, Opera 9.
+//
+// About: Release History
+//
+// 0.5 - (9/11/2009) Improved cache-busting
+// 0.4 - (8/25/2009) Initial release
+
+(function($){
+  '$:nomunge'; // Used by YUI compressor.
+
+  // A few vars used in non-awesome browsers.
+  var interval_id,
+    last_hash,
+    cache_bust = 1,
+
+    // A var used in awesome browsers.
+    rm_callback,
+
+    // A few convenient shortcuts.
+    window = this,
+    FALSE = !1,
+
+    // Reused internal strings.
+    postMessage = 'postMessage',
+    addEventListener = 'addEventListener',
+
+    p_receiveMessage,
+
+    // I couldn't get window.postMessage to actually work in Opera 9.64!
+    has_postMessage = window[postMessage] &amp;&amp; !$.browser.opera;
+
+  // Method: jQuery.postMessage
+  //
+  // This method will call window.postMessage if available, setting the
+  // targetOrigin parameter to the base of the target_url parameter for maximum
+  // security in browsers that support it. If window.postMessage is not available,
+  // the target window's location.hash will be used to pass the message. If an
+  // object is passed as the message param, it will be serialized into a string
+  // using the jQuery.param method.
+  //
+  // Usage:
+  //
+  // &gt; jQuery.postMessage( message, target_url [, target ] );
+  //
+  // Arguments:
+  //
+  //  message - (String) A message to be passed to the other frame.
+  //  message - (Object) An object to be serialized into a params string, using
+  //    the jQuery.param method.
+  //  target_url - (String) The URL of the other frame this window is
+  //    attempting to communicate with. This must be the exact URL (including
+  //    any query string) of the other window for this script to work in
+  //    browsers that don't support window.postMessage.
+  //  target - (Object) A reference to the other frame this window is
+  //    attempting to communicate with. If omitted, defaults to `parent`.
+  //
+  // Returns:
+  //
+  //  Nothing.
+
+  $[postMessage] = function( message, target_url, target ) {
+    if ( !target_url ) { return; }
+
+    // Serialize the message if not a string. Note that this is the only real
+    // jQuery dependency for this script. If removed, this script could be
+    // written as very basic JavaScript.
+    message = typeof message === 'string' ? message : $.param( message );
+
+    // Default to parent if unspecified.
+    target = target || parent;
+
+    if ( has_postMessage ) {
+      // The browser supports window.postMessage, so call it with a targetOrigin
+      // set appropriately, based on the target_url parameter.
+      target[postMessage]( message, target_url.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
+
+    } else if ( target_url ) {
+      // The browser does not support window.postMessage, so set the location
+      // of the target to target_url#message. A bit ugly, but it works! A cache
+      // bust parameter is added to ensure that repeat messages trigger the
+      // callback.
+      target.location = target_url.replace( /#.*$/, '' ) + '#' + (+new Date) + (cache_bust++) + '&amp;' + message;
+    }
+  };
+
+  // Method: jQuery.receiveMessage
+  //
+  // Register a single callback for either a window.postMessage call, if
+  // supported, or if unsupported, for any change in the current window
+  // location.hash. If window.postMessage is supported and source_origin is
+  // specified, the source window will be checked against this for maximum
+  // security. If window.postMessage is unsupported, a polling loop will be
+  // started to watch for changes to the location.hash.
+  //
+  // Note that for simplicity's sake, only a single callback can be registered
+  // at one time. Passing no params will unbind this event (or stop the polling
+  // loop), and calling this method a second time with another callback will
+  // unbind the event (or stop the polling loop) first, before binding the new
+  // callback.
+  //
+  // Also note that if window.postMessage is available, the optional
+  // source_origin param will be used to test the event.origin property. From
+  // the MDC window.postMessage docs: This string is the concatenation of the
+  // protocol and &quot;://&quot;, the host name if one exists, and &quot;:&quot; followed by a port
+  // number if a port is present and differs from the default port for the given
+  // protocol. Examples of typical origins are https://example.org (implying
+  // port 443), http://example.net (implying port 80), and http://example.com:8080.
+  //
+  // Usage:
+  //
+  // &gt; jQuery.receiveMessage( callback [, source_origin ] [, delay ] );
+  //
+  // Arguments:
+  //
+  //  callback - (Function) This callback will execute whenever a &lt;jQuery.postMessage&gt;
+  //    message is received, provided the source_origin matches. If callback is
+  //    omitted, any existing receiveMessage event bind or polling loop will be
+  //    canceled.
+  //  source_origin - (String) If window.postMessage is available and this value
+  //    is not equal to the event.origin property, the callback will not be
+  //    called.
+  //  source_origin - (Function) If window.postMessage is available and this
+  //    function returns false when passed the event.origin property, the
+  //    callback will not be called.
+  //  delay - (Number) An optional zero-or-greater delay in milliseconds at
+  //    which the polling loop will execute (for browser that don't support
+  //    window.postMessage). If omitted, defaults to 100.
+  //
+  // Returns:
+  //
+  //  Nothing!
+
+  $.receiveMessage = p_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.
+
+      if ( callback ) {
+        // Unbind an existing callback if it exists.
+        rm_callback &amp;&amp; p_receiveMessage();
+
+        // Bind the callback. A reference to the callback is stored for ease of
+        // unbinding.
+        rm_callback = function(e) {
+          if ( ( typeof source_origin === 'string' &amp;&amp; e.origin !== source_origin )
+            || ( $.isFunction( source_origin ) &amp;&amp; source_origin( e.origin ) === FALSE ) ) {
+            return FALSE;
+          }
+          callback( e );
+        };
+      }
+
+      if ( window[addEventListener] ) {
+        window[ callback ? addEventListener : 'removeEventListener' ]( 'message', rm_callback, FALSE );
+      } else {
+        window[ callback ? 'attachEvent' : 'detachEvent' ]( 'onmessage', rm_callback );
+      }
+
+    } else {
+      // Since the browser sucks, a polling loop will be started, and the
+      // callback will be called whenever the location.hash changes.
+
+      interval_id &amp;&amp; clearInterval( interval_id );
+      interval_id = null;
+
+      if ( callback ) {
+        delay = typeof source_origin === 'number'
+          ? source_origin
+          : typeof delay === 'number'
+            ? delay
+            : 100;
+
+        interval_id = setInterval(function(){
+          var hash = document.location.hash,
+            re = /^#?\d+&amp;/;
+          if ( hash !== last_hash &amp;&amp; re.test( hash ) ) {
+            last_hash = hash;
+            callback({ data: hash.replace( re, '' ) });
+          }
+        }, delay );
+      }
+    }
+  };
+
+})(jQuery);
</ins></span></pre></div>
<a id="trunkwpincludesjsjqueryjquerypostmessagejs"></a>
<div class="addfile"><h4>Added: trunk/wp-includes/js/jquery/jquery.postmessage.js (0 => 19992)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/jquery/jquery.postmessage.js                                (rev 0)
+++ trunk/wp-includes/js/jquery/jquery.postmessage.js        2012-02-25 02:04:17 UTC (rev 19992)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+
</ins></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (19991 => 19992)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2012-02-25 00:01:02 UTC (rev 19991)
+++ trunk/wp-includes/script-loader.php        2012-02-25 02:04:17 UTC (rev 19992)
</span><span class="lines">@@ -164,6 +164,7 @@
</span><span class="cx">         $scripts-&gt;add( 'jquery-serialize-object', &quot;/wp-includes/js/jquery/jquery.serialize-object.js&quot;, array('jquery'), '0.2', 1 );
</span><span class="cx">         $scripts-&gt;add( 'jquery-hotkeys', &quot;/wp-includes/js/jquery/jquery.hotkeys$suffix.js&quot;, array('jquery'), '0.0.2m', 1 );
</span><span class="cx">         $scripts-&gt;add( 'jquery-table-hotkeys', &quot;/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js&quot;, array('jquery', 'jquery-hotkeys'), false, 1 );
</span><ins>+        $scripts-&gt;add( 'jquery-postmessage', &quot;/wp-includes/js/jquery/jquery.postmessage$suffix.js&quot;, array('jquery'), '0.5', 1 );
</ins><span class="cx"> 
</span><span class="cx">         $scripts-&gt;add( 'thickbox', &quot;/wp-includes/js/thickbox/thickbox.js&quot;, array('jquery'), '3.1-20111117', 1 );
</span><span class="cx">         $scripts-&gt;localize( 'thickbox', 'thickboxL10n', array(
</span></span></pre>
</div>
</div>

</body>
</html>