From f826e49a72860d926e5f8df91c8db13020ac27a2 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 8 Jun 2012 18:52:44 +0000 Subject: [PATCH] Customizer: fix stuck urls and preview white screens after repeated save and activates. Props koopersmith. fixes #20868 git-svn-id: http://core.svn.wordpress.org/trunk@21029 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/customize-controls.dev.js | 20 +++++++++++--------- wp-includes/js/customize-base.dev.js | 2 +- wp-includes/js/customize-loader.dev.js | 5 +++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/wp-admin/js/customize-controls.dev.js b/wp-admin/js/customize-controls.dev.js index 24d647011f..4e54c1866c 100644 --- a/wp-admin/js/customize-controls.dev.js +++ b/wp-admin/js/customize-controls.dev.js @@ -694,11 +694,6 @@ api.state = state; }()); - api.bind( 'activated', function() { - if ( api.settings.url.activated ) - window.location = api.settings.url.activated; - }); - // Temporary accordion code. $('.customize-section-title').click( function( event ) { var clicked = $( this ).parents( '.customize-section' ); @@ -738,10 +733,17 @@ }); // Pass events through to the parent. - $.each([ 'saved', 'activated' ], function( i, id ) { - api.bind( id, function() { - parent.send( id ); - }); + api.bind( 'saved', function() { + parent.send( 'saved' ); + }); + + // When activated, let the loader handle redirecting the page. + // If no loader exists, redirect the page ourselves (if a url exists). + api.bind( 'activated', function() { + if ( parent.targetWindow() ) + parent.send( 'activated', api.settings.url.activated ); + else if ( api.settings.url.activated ) + window.location = api.settings.url.activated; }); // Initialize the connection with the parent frame. diff --git a/wp-includes/js/customize-base.dev.js b/wp-includes/js/customize-base.dev.js index 588efafc15..d643f65066 100644 --- a/wp-includes/js/customize-base.dev.js +++ b/wp-includes/js/customize-base.dev.js @@ -547,7 +547,7 @@ if ( typeof wp === 'undefined' ) send: function( id, data ) { var message; - data = typeof data === 'undefined' ? {} : data; + data = typeof data === 'undefined' ? null : data; if ( ! this.url() || ! this.targetWindow() ) return; diff --git a/wp-includes/js/customize-loader.dev.js b/wp-includes/js/customize-loader.dev.js index 403708fc68..01cec6aca3 100644 --- a/wp-includes/js/customize-loader.dev.js +++ b/wp-includes/js/customize-loader.dev.js @@ -98,6 +98,11 @@ if ( typeof wp === 'undefined' ) Loader.close(); }); + this.messenger.bind( 'activated', function( location ) { + if ( location ) + window.location = location; + }); + hash = src.split('?')[1]; // Ensure we don't call pushState if the user hit the forward button.