<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[17737] trunk/wp-content/themes/twentyeleven/inc: Twenty Eleven:
  Fix up the color picker JS.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17737">17737</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2011-04-28 09:32:34 +0000 (Thu, 28 Apr 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Twenty Eleven: Fix up the color picker JS. Use a separate color swatch rather than the input background. While cool, it doesn't have suffficient contrast. Also set farbtastic as a JS dependency. see <a href="http://trac.wordpress.org/ticket/17198">#17198</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionscss">trunk/wp-content/themes/twentyeleven/inc/theme-options.css</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsjs">trunk/wp-content/themes/twentyeleven/inc/theme-options.js</a></li>
<li><a href="#trunkwpcontentthemestwentyelevenincthemeoptionsphp">trunk/wp-content/themes/twentyeleven/inc/theme-options.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionscss"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/inc/theme-options.css (17736 => 17737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options.css        2011-04-28 09:08:39 UTC (rev 17736)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options.css        2011-04-28 09:32:34 UTC (rev 17737)
</span><span class="lines">@@ -19,4 +19,13 @@
</span><span class="cx"> }
</span><span class="cx"> .image-radio-option img {
</span><span class="cx">         margin: 0 0 0 -2px;
</span><ins>+}
+#link-color-example {
+        padding: 4px 14px;
+        margin: 0 7px 0 3px;
+        -moz-border-radius: 4px;
+        -khtml-border-radius: 4px;
+        -webkit-border-radius: 4px;
+        border-radius: 4px;
+        border: 1px solid #dfdfdf;
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/inc/theme-options.js (17736 => 17737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options.js        2011-04-28 09:08:39 UTC (rev 17736)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options.js        2011-04-28 09:32:34 UTC (rev 17737)
</span><span class="lines">@@ -1,39 +1,35 @@
</span><span class="cx"> var farbtastic;
</span><del>-function pickColor(a) {
-        farbtastic.setColor(a);
-        jQuery(&quot;#link-color&quot;).val(a);
-        jQuery(&quot;#link-color&quot;).css(&quot;background-color&quot;, a);
-}
-jQuery(document).ready(function() {
-        jQuery(&quot;#pickcolor&quot;).click(function() {
-                jQuery(&quot;#colorPickerDiv&quot;).show();
-                return false;
-        });
-        jQuery(&quot;#link-color&quot;).keyup(function() {
-                var b = jQuery(&quot;#link-color&quot;).val(),
-                a = b;
-                if (a.charAt(0) != &quot;#&quot;) {
-                        a = &quot;#&quot; + a;
-                }
-                a = a.replace(/[^#a-fA-F0-9]+/, &quot;&quot;);
-                if (a != b) {
-                        jQuery(&quot;#link-color&quot;).val(a);
-                }
-                if (a.length == 4 || a.length == 7) {
-                        pickColor(a);
-                }
-        });
-        farbtastic = jQuery.farbtastic(&quot;#colorPickerDiv&quot;,
-        function(a) {
-                pickColor(a);
-        });
-        pickColor(jQuery(&quot;#link-color&quot;).val());
-        jQuery(document).mousedown(function() {
-                jQuery(&quot;#colorPickerDiv&quot;).each(function() {
-                        var a = jQuery(this).css(&quot;display&quot;);
-                        if (a == &quot;block&quot;) {
-                                jQuery(this).fadeOut(2);
-                        }
</del><ins>+
+(function($){
+        var pickColor = function(a) {
+                farbtastic.setColor(a);
+                $('#link-color').val(a);
+                $('#link-color-example').css('background-color', a);
+        }
+
+        $(document).ready( function() {
+                farbtastic = $.farbtastic('#colorPickerDiv', pickColor);
+
+                pickColor( $('#link-color').val() );
+
+                $('#pickcolor').click( function(e) {
+                        $('#colorPickerDiv').show();
+                        e.preventDefault();
</ins><span class="cx">                 });
</span><ins>+
+                $('#link-color').keyup( function() {
+                        var a = $('#link-color').val(),
+                                b = a;
+
+                        a = a.replace(/[^a-fA-F0-9]/, '');
+                        if ( '#' + a !== b )
+                                $('#link-color').val(a);
+                        if ( a.length === 3 || a.length === 6 )
+                                pickColor( '#' + a );
+                });
+
+                $(document).mousedown( function() {
+                        $('#colorPickerDiv').hide();
+                });
</ins><span class="cx">         });
</span><del>-});
</del><span class="cx">\ No newline at end of file
</span><ins>+})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpcontentthemestwentyelevenincthemeoptionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/themes/twentyeleven/inc/theme-options.php (17736 => 17737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/themes/twentyeleven/inc/theme-options.php        2011-04-28 09:08:39 UTC (rev 17736)
+++ trunk/wp-content/themes/twentyeleven/inc/theme-options.php        2011-04-28 09:32:34 UTC (rev 17737)
</span><span class="lines">@@ -21,10 +21,9 @@
</span><span class="cx">         if ( $hook_suffix != 'appearance_page_theme_options' )
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><del>-        wp_enqueue_style(  'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', '', '0.1' );
-        wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js' );
</del><ins>+        wp_enqueue_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' );
+        wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( 'farbtastic' ), '2011-04-28' );
</ins><span class="cx">         wp_enqueue_style( 'farbtastic' );
</span><del>-        wp_enqueue_script( 'farbtastic' );
</del><span class="cx"> }
</span><span class="cx"> add_action( 'admin_enqueue_scripts', 'twentyeleven_admin_enqueue_scripts' );
</span><span class="cx"> 
</span><span class="lines">@@ -193,7 +192,7 @@
</span><span class="cx">                                         &lt;td&gt;
</span><span class="cx">                                                 &lt;fieldset&gt;&lt;legend class=&quot;screen-reader-text&quot;&gt;&lt;span&gt;&lt;?php _e( 'Link Color', 'twentyeleven' ); ?&gt;&lt;/span&gt;&lt;/legend&gt;
</span><span class="cx">                                                         &lt;input type=&quot;text&quot; name=&quot;twentyeleven_theme_options[link_color]&quot; id=&quot;link-color&quot; value=&quot;&lt;?php echo esc_attr( $options['link_color'] ); ?&gt;&quot; /&gt;
</span><del>-                                                        &lt;a class=&quot;hide-if-no-js&quot; href=&quot;#&quot; id=&quot;pickcolor&quot;&gt;&lt;?php _e( 'Select a Color', 'twentyeleven' ); ?&gt;&lt;/a&gt;
</del><ins>+                                                        &lt;span id=&quot;link-color-example&quot;&gt;&lt;/span&gt; &lt;a class=&quot;hide-if-no-js&quot; href=&quot;#&quot; id=&quot;pickcolor&quot;&gt;&lt;?php _e( 'Select a Color', 'twentyeleven' ); ?&gt;&lt;/a&gt;
</ins><span class="cx">                                                         &lt;div id=&quot;colorPickerDiv&quot; style=&quot;z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;&quot;&gt;&lt;/div&gt;
</span><span class="cx">                                                         &lt;br /&gt;
</span><span class="cx">                                                         &lt;small class=&quot;description&quot;&gt;&lt;?php printf( __( 'Default color: %s', 'twentyeleven' ), $default_options['link_color'] ); ?&gt;&lt;/small&gt;
</span></span></pre>
</div>
</div>

</body>
</html>