mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-07 08:07:16 +00:00
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:
@@ -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() );
|
||||
|
||||
Reference in New Issue
Block a user