<!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>[20476] trunk: Theme Customizer: Allow the customize iframe to be accessed directly (with full feature support).</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/20476">20476</a></dd>
<dt>Author</dt> <dd>koopersmith</dd>
<dt>Date</dt> <dd>2012-04-16 14:02:28 +0000 (Mon, 16 Apr 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Theme Customizer: Allow the customize iframe to be accessed directly (with full feature support). see <a href="http://core.trac.wordpress.org/ticket/19910">#19910</a>.
* Move the 'Return to Manage Themes' and 'Collapse Sidebar' actions from themes.php to customize-controls.php.
* Create a postMessage connection between themes.php and customize-controls.php.
* Allow the theme customizer to be accessed directly (independent of themes.php and the customize loader).
* Add wp_customize_href() and wp_customize_url().
* Remove wp_customize_loader(). To include the loader, use wp_enqueue_script( 'customize-loader' ).
* The theme customizer now requires postMessage browser support.
* Add .hide-if-customize and .hide-if-no-customize CSS classes.
* Clean up customize-preview.js.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadmindevcss">trunk/wp-admin/css/wp-admin.dev.css</a></li>
<li><a href="#trunkwpadminincludesclasswpthemeslisttablephp">trunk/wp-admin/includes/class-wp-themes-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpupgraderphp">trunk/wp-admin/includes/class-wp-upgrader.php</a></li>
<li><a href="#trunkwpadminthemesphp">trunk/wp-admin/themes.php</a></li>
<li><a href="#trunkwpadminupdatephp">trunk/wp-admin/update.php</a></li>
<li><a href="#trunkwpincludescsscustomizecontrolsdevcss">trunk/wp-includes/css/customize-controls.dev.css</a></li>
<li><a href="#trunkwpincludescustomizecontrolsphp">trunk/wp-includes/customize-controls.php</a></li>
<li><a href="#trunkwpincludesjscustomizebasedevjs">trunk/wp-includes/js/customize-base.dev.js</a></li>
<li><a href="#trunkwpincludesjscustomizecontrolsdevjs">trunk/wp-includes/js/customize-controls.dev.js</a></li>
<li><a href="#trunkwpincludesjscustomizeloaderdevjs">trunk/wp-includes/js/customize-loader.dev.js</a></li>
<li><a href="#trunkwpincludesjscustomizepreviewdevjs">trunk/wp-includes/js/customize-preview.dev.js</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadmindevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.dev.css (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.dev.css        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-admin/css/wp-admin.dev.css        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -5313,6 +5313,16 @@
</span><span class="cx"> 24.0 - Customize Loader
</span><span class="cx"> ------------------------------------------------------------------------------*/
</span><span class="cx">
</span><ins>+.hide-if-no-customize,
+.customize-support .hide-if-customize {
+        display: none !important;
+}
+
+.hide-if-customize,
+.customize-support .hide-if-no-customize {
+        display: block !important;
+}
+
</ins><span class="cx"> #customize-container {
</span><span class="cx">         display: none;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpthemeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-themes-list-table.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-themes-list-table.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-admin/includes/class-wp-themes-list-table.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -131,15 +131,13 @@
</span><span class="cx">                                 array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ),
</span><span class="cx">                                 home_url( '/' ) ) );
</span><span class="cx">
</span><del>-                        $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $title ) ) . '"
-                                . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
-
</del><span class="cx">                         $actions = array();
</span><span class="cx">                         $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="'
</span><span class="cx">                                 . esc_attr( sprintf( __( 'Activate &#8220;%s&#8221;' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
</span><del>-                        $actions[] = '<a href="' . $preview_link . '" class="hide-if-js" title="'
</del><ins>+                        $actions[] = '<a href="' . $preview_link . '" class="hide-if-customize" title="'
</ins><span class="cx">                                 . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '">' . __( 'Preview' ) . '</a>'
</span><del>-                                . '<a href="#" class="load-customize hide-if-no-js" ' . $customize_attributes . '>' . __( 'Customize' ) . '</a>';
</del><ins>+                                . '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="load-customize hide-if-no-customize">'
+                                . __( 'Customize' ) . '</a>';
</ins><span class="cx">                         if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
</span><span class="cx">                                 $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&amp;template=$stylesheet", 'delete-theme_' . $stylesheet )
</span><span class="cx">                                         . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) )
</span><span class="lines">@@ -150,11 +148,18 @@
</span><span class="cx">                         unset( $actions['delete'] );
</span><span class="cx">
</span><span class="cx">                         ?>
</span><del>-                        <a href="<?php echo $preview_link; ?>" class="load-customize screenshot" <?php echo $customize_attributes; ?>>
-                        <?php if ( $screenshot = $theme->get_screenshot() ) : ?>
-                                <img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
-                        <?php endif; ?>
</del><ins>+
+                        <a href="<?php echo $preview_link; ?>" class="screenshot hide-if-customize">
+                                <?php if ( $screenshot = $theme->get_screenshot() ) : ?>
+                                        <img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
+                                <?php endif; ?>
</ins><span class="cx">                         </a>
</span><ins>+                        <a <?php echo wp_customize_href( $template, $stylesheet ); ?> class="screenshot load-customize hide-if-no-customize">
+                                <?php if ( $screenshot = $theme->get_screenshot() ) : ?>
+                                        <img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
+                                <?php endif; ?>
+                        </a>
+
</ins><span class="cx">                         <h3><?php echo $title; ?></h3>
</span><span class="cx">                         <div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
</span><span class="cx">                         <div class="action-links">
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpupgraderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-upgrader.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-upgrader.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-admin/includes/class-wp-upgrader.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -1507,9 +1507,6 @@
</span><span class="cx">                         'stylesheet' => $stylesheet,
</span><span class="cx">                 ), trailingslashit( get_home_url() ) );
</span><span class="cx">
</span><del>-                $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $name ) ) . '"
-                        . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
-
</del><span class="cx">                 $activate_link = add_query_arg( array(
</span><span class="cx">                         'action' => 'activate',
</span><span class="cx">                         'template' => $template,
</span><span class="lines">@@ -1518,8 +1515,8 @@
</span><span class="cx">                 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $template );
</span><span class="cx">
</span><span class="cx">                 $install_actions = array();
</span><del>-                $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-js" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
-                $install_actions['preview'] .= '<a href="#" class="hide-if-no-js load-customize" ' . $customize_attributes . '>' . __('Customize') . '</a>';
</del><ins>+                $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
+                $install_actions['preview'] .= '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="hide-if-no-customize load-customize>' . __('Customize') . '</a>';
</ins><span class="cx">                 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
</span><span class="cx">
</span><span class="cx">                 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
</span><span class="lines">@@ -1574,9 +1571,6 @@
</span><span class="cx">                                 'stylesheet' => $stylesheet,
</span><span class="cx">                         ), trailingslashit( get_home_url() ) );
</span><span class="cx">
</span><del>-                        $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $name ) ) . '"
-                                . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
-
</del><span class="cx">                         $activate_link = add_query_arg( array(
</span><span class="cx">                                 'action' => 'activate',
</span><span class="cx">                                 'template' => $template,
</span><span class="lines">@@ -1584,8 +1578,8 @@
</span><span class="cx">                         ), admin_url('themes.php') );
</span><span class="cx">                         $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $template );
</span><span class="cx">
</span><del>-                        $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-js" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
-                        $update_actions['preview'] .= '<a href="#" class="hide-if-no-js load-customize" ' . $customize_attributes . '>' . __('Customize') . '</a>';
</del><ins>+                        $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
+                        $update_actions['preview'] .= '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="hide-if-no-customize load-customize">' . __('Customize') . '</a>';
</ins><span class="cx">                         $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
</span><span class="cx">
</span><span class="cx">                         if ( ( ! $this->result || is_wp_error( $this->result ) ) || $stylesheet == get_stylesheet() )
</span></span></pre></div>
<a id="trunkwpadminthemesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/themes.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/themes.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-admin/themes.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> wp_enqueue_script( 'theme' );
</span><del>-wp_customize_loader();
</del><ins>+wp_enqueue_script( 'customize-loader' );
</ins><span class="cx">
</span><span class="cx"> endif;
</span><span class="cx">
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">         </div>
</span><span class="cx">
</span><span class="cx"> <div class="theme-options">
</span><del>-        <a href="#" class="load-customize hide-if-no-js" data-customize-template="<?php echo esc_attr( $ct->get_template() ); ?>" data-customize-stylesheet="<?php echo esc_attr( $ct->get_stylesheet() ); ?>" title="<?php echo esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $ct->get('Name') ) ); ?>"><?php _e( 'Customize' )?></a>
</del><ins>+        <a <?php echo wp_customize_href( $ct->get_template(), $ct->get_stylesheet() ); ?> class="load-customize hide-if-no-customize" title="<?php echo esc_attr( sprintf( __( 'Customize &#8220;%s&#8221;' ), $ct->get('Name') ) ); ?>"><?php _e( 'Customize' )?></a>
</ins><span class="cx">         <span><?php _e( 'Options:' )?></span>
</span><span class="cx">         <?php
</span><span class="cx">         // Pretend you didn't see this.
</span></span></pre></div>
<a id="trunkwpadminupdatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/update.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/update.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-admin/update.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">
</span><span class="cx">                 check_admin_referer('upgrade-theme_' . $theme);
</span><span class="cx">
</span><del>-                wp_customize_loader();
</del><ins>+                wp_enqueue_script( 'customize-loader' );
</ins><span class="cx">
</span><span class="cx">                 $title = __('Update Theme');
</span><span class="cx">                 $parent_file = 'themes.php';
</span><span class="lines">@@ -204,7 +204,7 @@
</span><span class="cx">                 if ( is_wp_error($api) )
</span><span class="cx">                          wp_die($api);
</span><span class="cx">
</span><del>-                 wp_customize_loader();
</del><ins>+                wp_enqueue_script( 'customize-loader' );
</ins><span class="cx">
</span><span class="cx">                 $title = __('Install Themes');
</span><span class="cx">                 $parent_file = 'themes.php';
</span><span class="lines">@@ -230,7 +230,7 @@
</span><span class="cx">
</span><span class="cx">                 $file_upload = new File_Upload_Upgrader('themezip', 'package');
</span><span class="cx">
</span><del>-                wp_customize_loader();
</del><ins>+                wp_enqueue_script( 'customize-loader' );
</ins><span class="cx">
</span><span class="cx">                 $title = __('Upload Theme');
</span><span class="cx">                 $parent_file = 'themes.php';
</span></span></pre></div>
<a id="trunkwpincludescsscustomizecontrolsdevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/customize-controls.dev.css (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/customize-controls.dev.css        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/css/customize-controls.dev.css        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -182,14 +182,6 @@
</span><span class="cx">         margin-right: 5px;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#customize-preview {
-        position: fixed;
-        left: 300px;
-        right: 0;
-        top: 0;
-        bottom: 0;
-}
-
</del><span class="cx"> #customize-preview iframe {
</span><span class="cx">         width: 100%;
</span><span class="cx">         height: 100%;
</span></span></pre></div>
<a id="trunkwpincludescustomizecontrolsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/customize-controls.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/customize-controls.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/customize-controls.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -50,7 +50,11 @@
</span><span class="cx">                 <input type="hidden" id="customize-template" name="template" value="<?php echo esc_attr( $theme['Template'] ); ?>" />
</span><span class="cx">                 <input type="hidden" id="customize-stylesheet" name="stylesheet" value="<?php echo esc_attr( $theme['Stylesheet'] ); ?>" />
</span><span class="cx">
</span><del>-                <div id="customize-header-actions" class="customize-section wp-full-overlay-header">&nbsp;</div>
</del><ins>+                <div id="customize-header-actions" class="customize-section wp-full-overlay-header">
+                        <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
+                                <?php printf( __( '&larr; Return to %s' ), __('Manage Themes') ); ?>
+                        </a>
+                </div>
</ins><span class="cx">
</span><span class="cx">                 <div id="customize-info" class="customize-section">
</span><span class="cx">                         <div class="customize-section-title">
</span><span class="lines">@@ -79,6 +83,10 @@
</span><span class="cx">                         <?php
</span><span class="cx">                         submit_button( __( 'Save' ), 'primary', 'save', false );
</span><span class="cx">                         ?>
</span><ins>+                        <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
+                                <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
+                                <span class="collapse-sidebar-arrow"></span>
+                        </a>
</ins><span class="cx">                 </div>
</span><span class="cx">         </form>
</span><span class="cx">         <div id="customize-preview" class="wp-full-overlay-main">
</span><span class="lines">@@ -95,6 +103,7 @@
</span><span class="cx">                 'settings' => array(),
</span><span class="cx">                 'controls' => array(),
</span><span class="cx">                 'prefix' => WP_Customize_Setting::name_prefix,
</span><ins>+                'parent' => esc_url( admin_url() ),
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         foreach ( $this->settings as $id => $setting ) {
</span></span></pre></div>
<a id="trunkwpincludesjscustomizebasedevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-base.dev.js (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-base.dev.js        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/js/customize-base.dev.js        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -457,6 +457,8 @@
</span><span class="cx">                 send: function( id, data ) {
</span><span class="cx">                         var message;
</span><span class="cx">
</span><ins>+                        data = data || {};
+
</ins><span class="cx">                         if ( ! this.url() )
</span><span class="cx">                                 return;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesjscustomizecontrolsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-controls.dev.js (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-controls.dev.js        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/js/customize-controls.dev.js        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -216,6 +216,8 @@
</span><span class="cx">                  * - url - the URL of preview frame
</span><span class="cx">                  */
</span><span class="cx">                 initialize: function( params, options ) {
</span><ins>+                        var self = this;
+
</ins><span class="cx">                         $.extend( this, options || {} );
</span><span class="cx">
</span><span class="cx">                         this.loaded = $.proxy( this.loaded, this );
</span><span class="lines">@@ -287,6 +289,21 @@
</span><span class="cx">                                 if ( 13 === e.which ) // Enter
</span><span class="cx">                                         e.preventDefault();
</span><span class="cx">                         });
</span><ins>+
+                        // Create a potential postMessage connection with the parent frame.
+                        this.parent = new api.Messenger( api.settings.parent );
+
+                        // If we receive a 'back' event, we're inside an iframe.
+                        // Send any clicks to the 'Return' link to the parent page.
+                        this.parent.bind( 'back', function( text ) {
+                                self.form.find('.back').text( text ).click( function( event ) {
+                                        event.preventDefault();
+                                        self.parent.send( 'close' );
+                                });
+                        });
+
+                        // Initialize the connection with the parent frame.
+                        this.parent.send( 'ready' );
</ins><span class="cx">                 },
</span><span class="cx">                 loader: function() {
</span><span class="cx">                         if ( this.loading )
</span><span class="lines">@@ -337,11 +354,12 @@
</span><span class="cx">                         return;
</span><span class="cx">
</span><span class="cx">                 // Initialize Previewer
</span><del>-                var previewer = new api.Previewer({
-                        iframe: '#customize-preview iframe',
-                        form: '#customize-controls',
-                        url: api.settings.preview
-                });
</del><ins>+                var body = $( document.body ),
+                        previewer = new api.Previewer({
+                                iframe: '#customize-preview iframe',
+                                form: '#customize-controls',
+                                url: api.settings.preview
+                        });
</ins><span class="cx">
</span><span class="cx">                 $.each( api.settings.settings, function( id, data ) {
</span><span class="cx">                         api.set( id, id, data.value, {
</span><span class="lines">@@ -380,11 +398,16 @@
</span><span class="cx">                 });
</span><span class="cx">
</span><span class="cx">                 // Button bindings.
</span><del>-                $('#save').click( function() {
</del><ins>+                $('#save').click( function( event ) {
</ins><span class="cx">                         previewer.submit();
</span><del>-                        return false;
</del><ins>+                        event.preventDefault();
</ins><span class="cx">                 });
</span><span class="cx">
</span><ins>+                $('.collapse-sidebar').click( function( event ) {
+                        body.toggleClass( 'collapsed' );
+                        event.preventDefault();
+                });
+
</ins><span class="cx">                 // Background color uses postMessage by default
</span><span class="cx">                 api( 'background_color', function( setting ) {
</span><span class="cx">                         setting.method = 'postMessage';
</span></span></pre></div>
<a id="trunkwpincludesjscustomizeloaderdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-loader.dev.js (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-loader.dev.js        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/js/customize-loader.dev.js        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -2,29 +2,36 @@
</span><span class="cx">         var wp = {};
</span><span class="cx">
</span><span class="cx"> (function( exports, $ ){
</span><del>-        var Loader = {
</del><ins>+        var api = wp.customize,
+                Loader;
+
+        Loader = {
</ins><span class="cx">                 initialize: function() {
</span><del>-                        this.body = $( document.body );
-                        this.element = $( '#customize-container' );
-                        this.base = $( '.admin-url', this.element ).val();
</del><ins>+                        this.body = $( document.body ).addClass('customize-support');
+                        this.element = $( '<div id="customize-container" class="wp-full-overlay" />' ).appendTo( this.body );
</ins><span class="cx">
</span><del>-                        this.element.on( 'click', '.close-full-overlay', function() {
-                                Loader.close();
-                                return false;
-                        });
</del><ins>+                        $('#wpbody').on( 'click', '.load-customize', function( event ) {
+                                event.preventDefault();
</ins><span class="cx">
</span><del>-                        this.element.on( 'click', '.collapse-sidebar', function() {
-                                Loader.element.toggleClass('collapsed');
-                                return false;
</del><ins>+                                // Load the theme.
+                                Loader.open( $(this).attr('href') );
</ins><span class="cx">                         });
</span><span class="cx">                 },
</span><del>-                open: function( params ) {
-                        params.customize = 'on';
</del><ins>+                open: function( src ) {
+                        this.iframe = $( '<iframe />', { src: src }).appendTo( this.element );
</ins><span class="cx">
</span><del>-                        this.iframe = $( '<iframe />', {
-                                src: this.base + '?' + jQuery.param( params )
-                        }).appendTo( this.element );
</del><ins>+                        // Create a postMessage connection with the iframe.
+                        this.messenger = new api.Messenger( src, this.iframe[0].contentWindow );
</ins><span class="cx">
</span><ins>+                        // Wait for the connection from the iframe before sending any postMessage events.
+                        this.messenger.bind( 'ready', function() {
+                                Loader.messenger.send( 'back', wpCustomizeLoaderL10n.back );
+                        });
+
+                        this.messenger.bind( 'close', function() {
+                                Loader.close();
+                        });
+
</ins><span class="cx">                         this.element.fadeIn( 200, function() {
</span><span class="cx">                                 Loader.body.addClass( 'customize-active full-overlay-active' );
</span><span class="cx">                         });
</span><span class="lines">@@ -32,28 +39,18 @@
</span><span class="cx">                 close: function() {
</span><span class="cx">                         this.element.fadeOut( 200, function() {
</span><span class="cx">                                 Loader.iframe.remove();
</span><del>-                                Loader.iframe = null;
</del><ins>+                                Loader.iframe = null;
+                                Loader.messenger = null;
</ins><span class="cx">                                 Loader.body.removeClass( 'customize-active full-overlay-active' );
</span><span class="cx">                         });
</span><span class="cx">                 }
</span><span class="cx">         };
</span><span class="cx">
</span><span class="cx">         $( function() {
</span><del>-                Loader.initialize();
-
-                $('#wpbody').on( 'click', '.load-customize', function( event ) {
-                        var load = $(this);
-
-                        event.preventDefault();
-
-                        // Load the theme.
-                        Loader.open({
-                                template: load.data('customizeTemplate'),
-                                stylesheet: load.data('customizeStylesheet')
-                        });
-                });
</del><ins>+                if ( !! window.postMessage )
+                        Loader.initialize();
</ins><span class="cx">         });
</span><span class="cx">
</span><span class="cx">         // Expose the API to the world.
</span><del>-        exports.CustomizeLoader = Loader;
</del><ins>+        api.Loader = Loader;
</ins><span class="cx"> })( wp, jQuery );
</span></span></pre></div>
<a id="trunkwpincludesjscustomizepreviewdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-preview.dev.js (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-preview.dev.js        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/js/customize-preview.dev.js        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -13,10 +13,8 @@
</span><span class="cx">                 initialize: function( url, options ) {
</span><span class="cx">                         var self = this;
</span><span class="cx">
</span><del>-                        $.extend( this, options || {} );
</del><ins>+                        api.Messenger.prototype.initialize.call( this, url, null, options );
</ins><span class="cx">
</span><del>-                        api.Messenger.prototype.initialize.call( this, url );
-
</del><span class="cx">                         this.body = $( document.body );
</span><span class="cx">                         this.body.on( 'click.preview', 'a', function( event ) {
</span><span class="cx">                                 event.preventDefault();
</span><span class="lines">@@ -29,24 +27,6 @@
</span><span class="cx">                         this.body.on( 'submit.preview', 'form', function( event ) {
</span><span class="cx">                                 event.preventDefault();
</span><span class="cx">                         });
</span><del>-
-                        this.bind( 'url', function( url ) {
-                                this.url( url );
-                                this.refresh();
-                        });
-                },
-                refresh: function() {
-                        this.submit({
-                                target: this.iframe.prop('name'),
-                                action: this.url()
-                        });
-                },
-                submit: function( props ) {
-                        if ( props )
-                                this.form.prop( props );
-                        this.form.submit();
-                        if ( props )
-                                this.form.prop( this._formOriginalProps );
</del><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/script-loader.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -298,10 +298,10 @@
</span><span class="cx">
</span><span class="cx">         $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r6', 1 );
</span><span class="cx">
</span><del>-        $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'jquery' ), false, 1 );
-        $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery-postmessage', 'json2' ), false, 1 );
</del><ins>+        $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery-postmessage', 'json2' ), false, 1 );
+        $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
</ins><span class="cx">         $scripts->add( 'customize-controls', "/wp-includes/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 );
</span><del>-        $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 );
</del><ins>+        $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 );
</ins><span class="cx">
</span><span class="cx">         if ( is_admin() ) {
</span><span class="cx">                 $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ) );
</span></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (20475 => 20476)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2012-04-15 21:17:55 UTC (rev 20475)
+++ trunk/wp-includes/theme.php        2012-04-16 14:02:28 UTC (rev 20476)
</span><span class="lines">@@ -1583,30 +1583,33 @@
</span><span class="cx"> add_action( 'plugins_loaded', '_wp_customize_include' );
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Includes the loading scripts for the theme customizer and
- * adds the action to print the customize container template.
</del><ins>+ * Localizes the customize-loader script.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.4.0
</span><span class="cx"> */
</span><del>-function wp_customize_loader() {
-        wp_enqueue_script( 'customize-loader' );
-        add_action( 'admin_footer', '_wp_customize_loader_template' );
</del><ins>+function _wp_customize_loader_localize() {
+        wp_localize_script( 'customize-loader', 'wpCustomizeLoaderL10n', array(
+                'back' => sprintf( __( '&larr; Return to %s' ), get_admin_page_title() ),
+        ) );
</ins><span class="cx"> }
</span><ins>+add_action( 'admin_enqueue_scripts', '_wp_customize_loader_localize' );
</ins><span class="cx">
</span><span class="cx"> /**
</span><del>- * Print the customize container template.
</del><ins>+ * Returns a URL to load the theme customizer.
</ins><span class="cx"> *
</span><span class="cx"> * @since 3.4.0
</span><span class="cx"> */
</span><del>-function _wp_customize_loader_template() {
-        ?>
-        <div id="customize-container" class="wp-full-overlay">
-                <input type="hidden" class="admin-url" value="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" />
-                <a href="#" class="close-full-overlay"><?php printf( __( '&larr; Return to %s' ), get_admin_page_title() ); ?></a>
-                <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
-                        <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
-                        <span class="collapse-sidebar-arrow"></span>
-                </a>
-        </div>
-        <?php
</del><ins>+function wp_customize_url( $template, $stylesheet = null ) {
+        $stylesheet = isset( $stylesheet ) ? $stylesheet : $template;
+        return admin_url( 'admin.php' ) . '?customize=on&template=' . $template . '&stylesheet=' . $stylesheet;
+}
+
+/**
+ * Prints an href attribute to load the theme customizer.
+ *
+ * @since 3.4.0
+ */
+function wp_customize_href( $template, $stylesheet = null ) {
+        $link = wp_customize_url( $template, $stylesheet );
+        return 'href="' . esc_url( $link ) . '"';
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>