Theme Customizer: First pass at using postMessage for background color. Fix instance where preview.targetWindow would become inaccurate. Initialize setting values in customize-preview.js. see #19910.

git-svn-id: https://develop.svn.wordpress.org/trunk@20123 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith
2012-03-06 02:49:02 +00:00
parent 10124d291b
commit e11e5445e9
4 changed files with 35 additions and 13 deletions
+3 -5
View File
@@ -438,10 +438,11 @@ if ( typeof wp === 'undefined' )
api.Messenger = api.Class.extend({
add: api.ValueFactory(),
initialize: function( url, options ) {
initialize: function( url, targetWindow, options ) {
$.extend( this, options || {} );
this.add( 'url', url );
this.add( 'targetWindow', targetWindow || null );
this.add( 'origin' ).link( 'url', function( url ) {
return url().replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
});
@@ -453,8 +454,6 @@ if ( typeof wp === 'undefined' )
receive: function( event ) {
var message;
console.log( 'messenger receiveMessage', arguments );
// @todo: remove, this is done in the postMessage plugin.
// if ( this.origin && event.origin !== this.origin )
// return;
@@ -470,9 +469,8 @@ if ( typeof wp === 'undefined' )
if ( ! this.url() )
return;
console.log( 'sending message', id, data );
message = JSON.stringify({ id: id, data: data });
$.postMessage( message, this.url(), this.targetWindow || null );
$.postMessage( message, this.url(), this.targetWindow() );
},
bind: function( id, callback ) {
var topic = this.topics[ id ] || ( this.topics[ id ] = $.Callbacks() );