<!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>[21033] trunk: Theme Customizer: Separate message url from preview url in customizer JS Previewer and PreviewFrame objects.</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/21033">21033</a></dd>
<dt>Author</dt> <dd>koopersmith</dd>
<dt>Date</dt> <dd>2012-06-08 22:59:48 +0000 (Fri, 08 Jun 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Theme Customizer: Separate message url from preview url in customizer JS Previewer and PreviewFrame objects. fixes <a href="http://core.trac.wordpress.org/ticket/20892">#20892</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjscustomizecontrolsdevjs">trunk/wp-admin/js/customize-controls.dev.js</a></li>
<li><a href="#trunkwpincludesjscustomizebasedevjs">trunk/wp-includes/js/customize-base.dev.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjscustomizecontrolsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/customize-controls.dev.js (21032 => 21033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/customize-controls.dev.js        2012-06-08 19:40:31 UTC (rev 21032)
+++ trunk/wp-admin/js/customize-controls.dev.js        2012-06-08 22:59:48 UTC (rev 21033)
</span><span class="lines">@@ -301,6 +301,8 @@
</span><span class="cx">
</span><span class="cx">                         api.Messenger.prototype.initialize.call( this, params, options );
</span><span class="cx">
</span><ins>+                        this.add( 'previewUrl', params.previewUrl );
+
</ins><span class="cx">                         this.bind( 'ready', function() {
</span><span class="cx">                                 ready = true;
</span><span class="cx">
</span><span class="lines">@@ -310,7 +312,7 @@
</span><span class="cx">
</span><span class="cx">                         params.query = $.extend( params.query || {}, { customize_messenger_channel: this.channel() });
</span><span class="cx">
</span><del>-                        this.request = $.ajax( this.url(), {
</del><ins>+                        this.request = $.ajax( this.previewUrl(), {
</ins><span class="cx">                                 type: 'POST',
</span><span class="cx">                                 data: params.query,
</span><span class="cx">                                 xhrFields: {
</span><span class="lines">@@ -329,7 +331,7 @@
</span><span class="cx">
</span><span class="cx">                                 // Check if the location response header differs from the current URL.
</span><span class="cx">                                 // If so, the request was redirected; try loading the requested page.
</span><del>-                                if ( location && location != self.url() ) {
</del><ins>+                                if ( location && location != self.previewUrl() ) {
</ins><span class="cx">                                         deferred.rejectWith( self, [ 'redirect', location ] );
</span><span class="cx">                                         return;
</span><span class="cx">                                 }
</span><span class="lines">@@ -410,8 +412,8 @@
</span><span class="cx">
</span><span class="cx">                 /**
</span><span class="cx">                  * Requires params:
</span><del>-                 * - container - a selector or jQuery element
-                 * - url - the URL of preview frame
</del><ins>+                 * - container - a selector or jQuery element
+                 * - previewUrl - the URL of preview frame
</ins><span class="cx">                  */
</span><span class="cx">                 initialize: function( params, options ) {
</span><span class="cx">                         var self = this,
</span><span class="lines">@@ -457,15 +459,10 @@
</span><span class="cx">                         this.container = api.ensure( params.container );
</span><span class="cx">                         this.allowedUrls = params.allowedUrls;
</span><span class="cx">
</span><del>-                        url = params.url;
-                        delete params.url;
</del><ins>+                        params.url = window.location.href;
</ins><span class="cx">
</span><span class="cx">                         api.Messenger.prototype.initialize.call( this, params );
</span><span class="cx">
</span><del>-                        // We're dynamically generating the iframe, so the origin is set
-                        // to the current window's location, not the url's.
-                        this.origin.unlink( this.url ).set( window.location.href );
-
</del><span class="cx">                         this.add( 'scheme', this.origin() ).link( this.origin ).setter( function( to ) {
</span><span class="cx">                                 var match = to.match( rscheme );
</span><span class="cx">                                 return match ? match[0] : '';
</span><span class="lines">@@ -479,7 +476,7 @@
</span><span class="cx">                         // are on different domains to avoid the case where the frontend doesn't have
</span><span class="cx">                         // ssl certs.
</span><span class="cx">
</span><del>-                        this.url.setter( function( to ) {
</del><ins>+                        this.add( 'previewUrl', params.previewUrl ).setter( function( to ) {
</ins><span class="cx">                                 var result;
</span><span class="cx">
</span><span class="cx">                                 // Check for URLs that include "/wp-admin/" or end in "/wp-admin".
</span><span class="lines">@@ -504,11 +501,8 @@
</span><span class="cx">                                 return result ? result : null;
</span><span class="cx">                         });
</span><span class="cx">
</span><del>-                        // Set the url.
-                        this.url( url );
-
</del><span class="cx">                         // Refresh the preview when the URL is changed (but not yet).
</span><del>-                        this.url.bind( this.refresh );
</del><ins>+                        this.previewUrl.bind( this.refresh );
</ins><span class="cx">
</span><span class="cx">                         this.scroll = 0;
</span><span class="cx">                         this.bind( 'scroll', function( distance ) {
</span><span class="lines">@@ -516,7 +510,7 @@
</span><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         // Update the URL when the iframe sends a URL message.
</span><del>-                        this.bind( 'url', this.url );
</del><ins>+                        this.bind( 'url', this.previewUrl );
</ins><span class="cx">                 },
</span><span class="cx">
</span><span class="cx">                 query: function() {},
</span><span class="lines">@@ -534,17 +528,18 @@
</span><span class="cx">                         this.abort();
</span><span class="cx">
</span><span class="cx">                         this.loading = new api.PreviewFrame({
</span><del>-                                url: this.url(),
-                                query: this.query() || {},
-                                previewer: this
</del><ins>+                                url: this.url(),
+                                previewUrl: this.previewUrl(),
+                                query: this.query() || {},
+                                previewer: this
</ins><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         this.loading.done( function() {
</span><span class="cx">                                 // 'this' is the loading frame
</span><span class="cx">                                 this.bind( 'synced', function() {
</span><del>-                                        if ( self.iframe )
-                                                self.iframe.destroy();
-                                        self.iframe = this;
</del><ins>+                                        if ( self.preview )
+                                                self.preview.destroy();
+                                        self.preview = this;
</ins><span class="cx">                                         delete self.loading;
</span><span class="cx">
</span><span class="cx">                                         self.targetWindow( this.targetWindow() );
</span><span class="lines">@@ -559,12 +554,12 @@
</span><span class="cx">
</span><span class="cx">                         this.loading.fail( function( reason, location ) {
</span><span class="cx">                                 if ( 'redirect' === reason && location )
</span><del>-                                        self.url( location );
</del><ins>+                                        self.previewUrl( location );
</ins><span class="cx">
</span><span class="cx">                                 if ( 'logged out' === reason ) {
</span><del>-                                        if ( self.iframe ) {
-                                                self.iframe.destroy();
-                                                delete self.iframe;
</del><ins>+                                        if ( self.preview ) {
+                                                self.preview.destroy();
+                                                delete self.preview;
</ins><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         self.login().done( self.refresh );
</span><span class="lines">@@ -648,7 +643,7 @@
</span><span class="cx">                 previewer = new api.Previewer({
</span><span class="cx">                         container: '#customize-preview',
</span><span class="cx">                         form: '#customize-controls',
</span><del>-                        url: api.settings.url.preview,
</del><ins>+                        previewUrl: api.settings.url.preview,
</ins><span class="cx">                         allowedUrls: api.settings.url.allowed
</span><span class="cx">                 }, {
</span><span class="cx">                         query: function() {
</span><span class="lines">@@ -680,10 +675,10 @@
</span><span class="cx">                                 request.done( function( response ) {
</span><span class="cx">                                         // Check if the user is logged out.
</span><span class="cx">                                         if ( '0' === response ) {
</span><del>-                                                self.iframe.iframe.hide();
</del><ins>+                                                self.preview.iframe.hide();
</ins><span class="cx">                                                 self.login().done( function() {
</span><span class="cx">                                                         self.save();
</span><del>-                                                        self.iframe.iframe.show();
</del><ins>+                                                        self.preview.iframe.show();
</ins><span class="cx">                                                 });
</span><span class="cx">                                                 return;
</span><span class="cx">                                         }
</span><span class="lines">@@ -717,10 +712,10 @@
</span><span class="cx">                 });
</span><span class="cx">
</span><span class="cx">                 // Check if preview url is valid and load the preview frame.
</span><del>-                if ( previewer.url() )
</del><ins>+                if ( previewer.previewUrl() )
</ins><span class="cx">                         previewer.refresh();
</span><span class="cx">                 else
</span><del>-                        previewer.url( api.settings.url.home );
</del><ins>+                        previewer.previewUrl( api.settings.url.home );
</ins><span class="cx">
</span><span class="cx">                 // Save and activated states
</span><span class="cx">                 (function() {
</span></span></pre></div>
<a id="trunkwpincludesjscustomizebasedevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-base.dev.js (21032 => 21033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-base.dev.js        2012-06-08 19:40:31 UTC (rev 21032)
+++ trunk/wp-includes/js/customize-base.dev.js        2012-06-08 22:59:48 UTC (rev 21033)
</span><span class="lines">@@ -192,8 +192,11 @@
</span><span class="cx">                 },
</span><span class="cx">
</span><span class="cx">                 setter: function( callback ) {
</span><ins>+                        var from = this.get();
</ins><span class="cx">                         this._setter = callback;
</span><del>-                        this.set( this.get() );
</del><ins>+                        // Temporarily clear value so setter can decide if it's valid.
+                        this._value = null;
+                        this.set( from );
</ins><span class="cx">                         return this;
</span><span class="cx">                 },
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>