<!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>[20290] trunk/wp-includes: Theme Customizer: Add 'choose image' functionality to image controls.</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/20290">20290</a></dd>
<dt>Author</dt> <dd>koopersmith</dd>
<dt>Date</dt> <dd>2012-03-25 21:18:32 +0000 (Sun, 25 Mar 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Theme Customizer: Add 'choose image' functionality to image controls. Rough first pass, using header images as an example. see <a href="http://core.trac.wordpress.org/ticket/19910">#19910</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasswpcustomizesettingphp">trunk/wp-includes/class-wp-customize-setting.php</a></li>
<li><a href="#trunkwpincludesclasswpcustomizephp">trunk/wp-includes/class-wp-customize.php</a></li>
<li><a href="#trunkwpincludescsscustomizecontrolsdevcss">trunk/wp-includes/css/customize-controls.dev.css</a></li>
<li><a href="#trunkwpincludesjscustomizecontrolsdevjs">trunk/wp-includes/js/customize-controls.dev.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesclasswpcustomizesettingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize-setting.php (20289 => 20290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize-setting.php        2012-03-25 13:02:01 UTC (rev 20289)
+++ trunk/wp-includes/class-wp-customize-setting.php        2012-03-25 21:18:32 UTC (rev 20290)
</span><span class="lines">@@ -437,8 +437,23 @@
</span><span class="cx">                                                 </div>
</span><span class="cx">                                                 <div class="actions">
</span><span class="cx">                                                         <a href="#" class="upload"><?php _e( 'Upload New' ); ?></a>
</span><ins>+                                                        <a href="#" class="change"><?php _e( 'Change Image' ); ?></a>
</ins><span class="cx">                                                         <a href="#" class="remove"><?php _e( 'Remove Image' ); ?></a>
</span><span class="cx">                                                 </div>
</span><ins>+                                                <div class="library">
+                                                        <ul>
+                                                                <?php foreach ( $this->control_params['tabs'] as $tab ): ?>
+                                                                        <li data-customize-tab='<?php echo esc_attr( $tab[0] ); ?>'>
+                                                                                <?php echo esc_html( $tab[1] ); ?>
+                                                                        </li>
+                                                                <?php endforeach; ?>
+                                                        </ul>
+                                                        <?php foreach ( $this->control_params['tabs'] as $tab ): ?>
+                                                                <div class="library-content" data-customize-tab='<?php echo esc_attr( $tab[0] ); ?>'>
+                                                                        <?php call_user_func( $tab[2] ); ?>
+                                                                </div>
+                                                        <?php endforeach; ?>
+                                                </div>
</ins><span class="cx">                                         </div>
</span><span class="cx">                                 </label>
</span><span class="cx">                                 <?php
</span></span></pre></div>
<a id="trunkwpincludesclasswpcustomizephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize.php (20289 => 20290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize.php        2012-03-25 13:02:01 UTC (rev 20289)
+++ trunk/wp-includes/class-wp-customize.php        2012-03-25 21:18:32 UTC (rev 20290)
</span><span class="lines">@@ -542,6 +542,10 @@
</span><span class="cx">                                 'context' => 'custom-header',
</span><span class="cx">                                 'removed' => 'remove-header',
</span><span class="cx">                                 'get_url' => 'get_header_image',
</span><ins>+                                'tabs' => array(
+                                        array( 'uploaded', __('Uploaded'), 'wp_customize_print_uploaded_headers' ),
+                                        array( 'included', __('Included'), 'wp_customize_print_included_headers' ),
+                                ),
</ins><span class="cx">                         ),
</span><span class="cx">                 ) );
</span><span class="cx">
</span><span class="lines">@@ -719,3 +723,24 @@
</span><span class="cx">
</span><span class="cx">         return $color;
</span><span class="cx"> }
</span><ins>+
+function wp_customize_print_uploaded_headers() {
+        $headers = get_uploaded_header_images();
+
+        foreach ( $headers as $header ) : ?>
+                <a href="<?php echo esc_url( $header['url'] ); ?>">
+                        <img src="<?php echo esc_url( $header['thumbnail_url'] ); ?>" />
+                </a>
+        <?php endforeach;
+}
+
+function wp_customize_print_included_headers() {
+        global $custom_image_header;
+        $custom_image_header->process_default_headers();
+
+        foreach ( $custom_image_header->default_headers as $header ) : ?>
+                <a href="<?php echo esc_url( $header['url'] ); ?>">
+                        <img src="<?php echo esc_url( $header['thumbnail_url'] ); ?>" />
+                </a>
+        <?php endforeach;
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludescsscustomizecontrolsdevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/customize-controls.dev.css (20289 => 20290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/customize-controls.dev.css        2012-03-25 13:02:01 UTC (rev 20289)
+++ trunk/wp-includes/css/customize-controls.dev.css        2012-03-25 21:18:32 UTC (rev 20290)
</span><span class="lines">@@ -104,7 +104,8 @@
</span><span class="cx">         padding-bottom: 60px;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#customize-theme-controls ul {
</del><ins>+#customize-theme-controls > ul,
+#customize-theme-controls .customize-section-content {
</ins><span class="cx">         margin: 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -327,4 +328,70 @@
</span><span class="cx"> }
</span><span class="cx"> .customize-section .customize-image-picker .actions a {
</span><span class="cx">         display: block;
</span><ins>+}
+.customize-section .customize-image-picker .library {
+        display: none;
+/*        float: left;*/
+}
+/*.customize-section .customize-image-picker .library label {
+        display: block;
+        position: relative;
+        float: left;
+        padding: 0 0 5px 20px;
+}
+.customize-section .customize-image-picker .library input {
+        display: block;
+        position: absolute;
+        top: 50%;
+        left: 0;
+        margin-top: -7px;
+}*/
+/*.customize-section .customize-image-picker .library .wp-tab-panel {
+        padding: 10px 10px 5px 8px;
+}*/
+.customize-section .customize-image-picker .library ul {
+        border-bottom: 1px solid #dfdfdf;
+        float: left;
+        width: 100%;
+        margin: 5px 0;
+}
+.customize-section .customize-image-picker .library li {
+        color: #999;
+        float: left;
+        padding: 4px 6px;
+        margin: 0;
+        border-style: solid;
+        border-color: transparent;
+        border-width: 1px 1px 0 1px;
+}
+.customize-section .customize-image-picker .library li.library-selected {
+        color: #777;
+        border-color: #dfdfdf;
+        background: #f5f5f5;
+        margin-bottom: -1px;
+        padding-bottom: 5px;
+}
+.customize-section .customize-image-picker .library div {
+        width: 100%;
+        float: left;
+}
+.customize-section .customize-image-picker .library a {
+        display: block;
+        max-width: 220px;
+        max-height: 80px;
+        margin: 5px auto;
+        padding: 4px;
+        background: #fff;
+        border: 1px solid #dfdfdf;
+}
+.customize-section .customize-image-picker .library a:hover {
+        border-color: #21759b;
+}
+.customize-section .customize-image-picker .library img {
+        display: block;
+        max-width: 220px;
+        max-height: 80px;
+}
+.customize-section .customize-image-picker .library-content {
+        display: none;
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjscustomizecontrolsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/customize-controls.dev.js (20289 => 20290)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/customize-controls.dev.js        2012-03-25 13:02:01 UTC (rev 20289)
+++ trunk/wp-includes/js/customize-controls.dev.js        2012-03-25 21:18:32 UTC (rev 20290)
</span><span class="lines">@@ -104,13 +104,45 @@
</span><span class="cx">
</span><span class="cx">         api.ImageControl = api.UploadControl.extend({
</span><span class="cx">                 initialize: function( id, value, options ) {
</span><ins>+                        var control = this;
+
</ins><span class="cx">                         api.UploadControl.prototype.initialize.call( this, id, value, options );
</span><span class="cx">
</span><span class="cx">                         this.thumbnail = this.container.find('.thumbnail img');
</span><span class="cx">                         this.bind( this.thumbnailSrc );
</span><ins>+
+                        this.library = this.container.find('.library');
+                        this.changer = this.container.find('.change');
+
+                        this.changer.click( function( event ) {
+                                control.library.toggle();
+                                event.preventDefault();
+                        });
+
+                        this.library.on( 'click', 'li', function( event ) {
+                                var tab = $(this),
+                                        id = tab.data('customizeTab');
+
+                                event.preventDefault();
+
+                                if ( tab.hasClass('library-selected') )
+                                        return;
+
+                                tab.siblings('.library-selected').removeClass('library-selected');
+                                tab.addClass('library-selected');
+
+                                control.library.find('div').hide().filter( function() {
+                                        return $(this).data('customizeTab') === id;
+                                }).show();
+                        });
+
+                        this.library.on( 'click', 'a', function( event ) {
+                                control.set( $(this).attr('href') );
+                                event.preventDefault();
+                        });
</ins><span class="cx">                 },
</span><span class="cx">                 thumbnailSrc: function( to ) {
</span><del>-                        if ( /^(http:\/\/|https:\/\/|\/\/)/.test( to ) )
</del><ins>+                        if ( /^(https?:)?\/\//.test( to ) )
</ins><span class="cx">                                 this.thumbnail.prop( 'src', to ).show();
</span><span class="cx">                         else
</span><span class="cx">                                 this.thumbnail.hide();
</span></span></pre>
</div>
</div>
</body>
</html>