<!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>[29048] trunk/src/wp-admin/js: Customizer: Export Previewer instance to wp.customize.previewer, and utilize for Widget Customizer.</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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/29048">29048</a></dd>
<dt>Author</dt> <dd>SergeyBiryukov</dd>
<dt>Date</dt> <dd>2014-07-09 20:57:58 +0000 (Wed, 09 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Customizer: Export Previewer instance to wp.customize.previewer, and utilize for Widget Customizer.

props westonruter.
fixes <a href="http://core.trac.wordpress.org/ticket/27666">#27666</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjscustomizecontrolsjs">trunk/src/wp-admin/js/customize-controls.js</a></li>
<li><a href="#trunksrcwpadminjscustomizewidgetsjs">trunk/src/wp-admin/js/customize-widgets.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjscustomizecontrolsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/customize-controls.js (29047 => 29048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/customize-controls.js      2014-07-09 20:01:35 UTC (rev 29047)
+++ trunk/src/wp-admin/js/customize-controls.js 2014-07-09 20:57:58 UTC (rev 29048)
</span><span class="lines">@@ -913,7 +913,7 @@
</span><span class="cx">          if ( ! $.support.postMessage || ( ! $.support.cors && api.settings.isCrossDomain ) )
</span><span class="cx">                  return window.location = api.settings.url.fallback;
</span><span class="cx"> 
</span><del>-               var previewer, parent, topFocus,
</del><ins>+                var parent, topFocus,
</ins><span class="cx">                   body = $( document.body ),
</span><span class="cx">                  overlay = body.children( '.wp-full-overlay' ),
</span><span class="cx">                  title = $( '#customize-info .theme-name.site-title' ),
</span><span class="lines">@@ -931,7 +931,7 @@
</span><span class="cx">          });
</span><span class="cx"> 
</span><span class="cx">          // Initialize Previewer
</span><del>-               previewer = new api.Previewer({
</del><ins>+                api.previewer = new api.Previewer({
</ins><span class="cx">                   container:   '#customize-preview',
</span><span class="cx">                  form:        '#customize-controls',
</span><span class="cx">                  previewUrl:  api.settings.url.preview,
</span><span class="lines">@@ -1008,14 +1008,14 @@
</span><span class="cx">          });
</span><span class="cx"> 
</span><span class="cx">          // Refresh the nonces if the preview sends updated nonces over.
</span><del>-               previewer.bind( 'nonce', function( nonce ) {
</del><ins>+                api.previewer.bind( 'nonce', function( nonce ) {
</ins><span class="cx">                   $.extend( this.nonce, nonce );
</span><span class="cx">          });
</span><span class="cx"> 
</span><span class="cx">          $.each( api.settings.settings, function( id, data ) {
</span><span class="cx">                  api.create( id, id, data.value, {
</span><span class="cx">                          transport: data.transport,
</span><del>-                               previewer: previewer
</del><ins>+                                previewer: api.previewer
</ins><span class="cx">                   } );
</span><span class="cx">          });
</span><span class="cx"> 
</span><span class="lines">@@ -1025,15 +1025,16 @@
</span><span class="cx"> 
</span><span class="cx">                  control = api.control.add( id, new constructor( id, {
</span><span class="cx">                          params: data,
</span><del>-                               previewer: previewer
</del><ins>+                                previewer: api.previewer
</ins><span class="cx">                   } ) );
</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.previewUrl() )
-                       previewer.refresh();
-               else
-                       previewer.previewUrl( api.settings.url.home );
</del><ins>+                if ( api.previewer.previewUrl() ) {
+                       api.previewer.refresh();
+               } else {
+                       api.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 class="lines">@@ -1082,13 +1083,13 @@
</span><span class="cx"> 
</span><span class="cx">          // Button bindings.
</span><span class="cx">          saveBtn.click( function( event ) {
</span><del>-                       previewer.save();
</del><ins>+                        api.previewer.save();
</ins><span class="cx">                   event.preventDefault();
</span><span class="cx">          }).keydown( function( event ) {
</span><span class="cx">                  if ( 9 === event.which ) // tab
</span><span class="cx">                          return;
</span><span class="cx">                  if ( 13 === event.which ) // enter
</span><del>-                               previewer.save();
</del><ins>+                                api.previewer.save();
</ins><span class="cx">                   event.preventDefault();
</span><span class="cx">          });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpadminjscustomizewidgetsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/customize-widgets.js (29047 => 29048)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/customize-widgets.js       2014-07-09 20:01:35 UTC (rev 29047)
+++ trunk/src/wp-admin/js/customize-widgets.js  2014-07-09 20:57:58 UTC (rev 29048)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> 
</span><span class="cx">  // Set up our namespace...
</span><span class="cx">  var api = wp.customize,
</span><del>-               l10n, OldPreviewer;
</del><ins>+                l10n;
</ins><span class="cx"> 
</span><span class="cx">  api.Widgets = api.Widgets || {};
</span><span class="cx"> 
</span><span class="lines">@@ -185,7 +185,7 @@
</span><span class="cx">                  } );
</span><span class="cx"> 
</span><span class="cx">                  // Close the panel if the URL in the preview changes
</span><del>-                       api.Widgets.Previewer.bind( 'url', this.close );
</del><ins>+                        api.previewer.bind( 'url', this.close );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          // Performs a search and handles selected widget
</span><span class="lines">@@ -745,14 +745,14 @@
</span><span class="cx">                          self.container.removeClass( 'previewer-loading' );
</span><span class="cx">                  } );
</span><span class="cx"> 
</span><del>-                       api.Widgets.Previewer.bind( 'widget-updated', function( updatedWidgetId ) {
</del><ins>+                        api.previewer.bind( 'widget-updated', function( updatedWidgetId ) {
</ins><span class="cx">                           if ( updatedWidgetId === self.params.widget_id ) {
</span><span class="cx">                                  self.container.removeClass( 'previewer-loading' );
</span><span class="cx">                          }
</span><span class="cx">                  } );
</span><span class="cx"> 
</span><span class="cx">                  // Update widget control to indicate whether it is currently rendered
</span><del>-                       api.Widgets.Previewer.bind( 'rendered-widgets', function( renderedWidgets ) {
</del><ins>+                        api.previewer.bind( 'rendered-widgets', function( renderedWidgets ) {
</ins><span class="cx">                           var isRendered = !! renderedWidgets[self.params.widget_id];
</span><span class="cx"> 
</span><span class="cx">                          self.container.toggleClass( 'widget-rendered', isRendered );
</span><span class="lines">@@ -971,17 +971,17 @@
</span><span class="cx"> 
</span><span class="cx">                          // Check if the user is logged out.
</span><span class="cx">                          if ( '0' === r ) {
</span><del>-                                       api.Widgets.Previewer.preview.iframe.hide();
-                                       api.Widgets.Previewer.login().done( function() {
</del><ins>+                                        api.previewer.preview.iframe.hide();
+                                       api.previewer.login().done( function() {
</ins><span class="cx">                                           self.updateWidget( args );
</span><del>-                                               api.Widgets.Previewer.preview.iframe.show();
</del><ins>+                                                api.previewer.preview.iframe.show();
</ins><span class="cx">                                   } );
</span><span class="cx">                                  return;
</span><span class="cx">                          }
</span><span class="cx"> 
</span><span class="cx">                          // Check for cheaters.
</span><span class="cx">                          if ( '-1' === r ) {
</span><del>-                                       api.Widgets.Previewer.cheatin();
</del><ins>+                                        api.previewer.cheatin();
</ins><span class="cx">                                   return;
</span><span class="cx">                          }
</span><span class="cx"> 
</span><span class="lines">@@ -1418,7 +1418,7 @@
</span><span class="cx">                  } );
</span><span class="cx"> 
</span><span class="cx">                  // Update the model with whether or not the sidebar is rendered
</span><del>-                       api.Widgets.Previewer.bind( 'rendered-sidebars', function( renderedSidebars ) {
</del><ins>+                        api.previewer.bind( 'rendered-sidebars', function( renderedSidebars ) {
</ins><span class="cx">                           var isRendered = !! renderedSidebars[self.params.sidebar_id];
</span><span class="cx"> 
</span><span class="cx">                          registeredSidebar.set( 'is_rendered', isRendered );
</span><span class="lines">@@ -1739,18 +1739,6 @@
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Capture the instance of the Previewer since it is private
-        */
-       OldPreviewer = api.Previewer;
-       api.Previewer = OldPreviewer.extend({
-               initialize: function( params, options ) {
-                       api.Widgets.Previewer = this;
-                       OldPreviewer.prototype.initialize.call( this, params, options );
-                       this.bind( 'refresh', this.refresh );
-               }
-       } );
-
-       /**
</del><span class="cx">    * Init Customizer for widgets.
</span><span class="cx">   */
</span><span class="cx">  api.bind( 'ready', function() {
</span><span class="lines">@@ -1760,10 +1748,10 @@
</span><span class="cx">          });
</span><span class="cx"> 
</span><span class="cx">          // Highlight widget control
</span><del>-               api.Widgets.Previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl );
</del><ins>+                api.previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl );
</ins><span class="cx"> 
</span><span class="cx">          // Open and focus widget control
</span><del>-               api.Widgets.Previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl );
</del><ins>+                api.previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl );
</ins><span class="cx">   } );
</span><span class="cx"> 
</span><span class="cx">  /**
</span></span></pre>
</div>
</div>

</body>
</html>