Ticket #21206: iris-picker-5.diff
File iris-picker-5.diff, 17.8 KB (added by , 13 years ago) |
---|
-
wp-includes/class-wp-customize-control.php
351 351 * @since 3.4.0 352 352 */ 353 353 public function enqueue() { 354 wp_enqueue_script( ' farbtastic' );355 wp_enqueue_style( ' farbtastic' );354 wp_enqueue_script( 'wp-color-picker' ); 355 wp_enqueue_style( 'wp-color-picker' ); 356 356 } 357 357 358 358 /** … … 372 372 * @since 3.4.0 373 373 */ 374 374 public function render_content() { 375 $this_default = $this->setting->default; 376 if ( strpos( $this_default, '#' ) === false ) 377 $this_default = '#' . $this_default; 375 378 ?> 376 379 <label> 377 380 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> 378 381 <div class="customize-control-content"> 379 <div class="dropdown"> 380 <div class="dropdown-content"> 381 <div class="dropdown-status"></div> 382 </div> 383 <div class="dropdown-arrow"></div> 384 </div> 385 <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e('Hex Value'); ?>" /> 382 <input class="color-picker-hex" type="text" value="<?php echo esc_html( $this_default ); ?>" maxlength="7" placeholder="<?php esc_attr_e('Hex Value'); ?>" /> 386 383 </div> 387 <div class="farbtastic-placeholder"></div>388 384 </label> 389 385 <?php 390 386 } -
wp-includes/script-loader.php
402 402 403 403 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 404 404 405 $iris_deps = array( 'jquery-ui-draggable', 'jquery-ui-slider' ); 406 if ( wp_is_mobile() ) 407 $iris_deps[] = 'touch-punch'; 408 $scripts->add( 'iris', '/wp-admin/js/iris.min.js', $iris_deps, false, 1 ); 409 410 $scripts->add( 'wp-color-picker', "/wp-admin/js/wp-color-picker$suffix.js", array( 'iris' ), false, 1 ); 411 did_action( 'init' ) && $scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array( 412 'clear' => __( 'Clear' ), 413 'defaultString' => __( 'Default' ), 414 'pick' => __( 'Select Color' ) 415 )); 416 405 417 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 ); 406 418 407 419 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); … … 429 441 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.') 430 442 ) ); 431 443 432 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array(' farbtastic'), false, 1 );444 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('wp-color-picker'), false, 1 ); 433 445 $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 ); 434 446 } 435 447 } … … 482 494 $styles->add( 'install', "/wp-admin/css/install$suffix.css" ); 483 495 $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css' ); 484 496 $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u1' ); 497 $styles->add( 'wp-color-picker', '/wp-admin/css/wp-color-picker.css' ); 485 498 $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' ); 486 499 $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); 487 500 $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css" ); -
wp-content/themes/twentyeleven/inc/theme-options.php
17 17 */ 18 18 function twentyeleven_admin_enqueue_scripts( $hook_suffix ) { 19 19 wp_enqueue_style( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' ); 20 wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( ' farbtastic' ), '2011-06-10' );21 wp_enqueue_style( 'farbtastic' ); 20 wp_enqueue_script( 'twentyeleven-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( 'wp-color-picker' ), '2011-06-10' ); 21 wp_enqueue_style( 'wp-color-picker' ); 22 22 } 23 23 add_action( 'admin_print_styles-appearance_page_theme_options', 'twentyeleven_admin_enqueue_scripts' ); 24 24 … … 268 268 function twentyeleven_settings_field_link_color() { 269 269 $options = twentyeleven_get_theme_options(); 270 270 ?> 271 <input type="text" name="twentyeleven_theme_options[link_color]" id="link-color" value="<?php echo esc_attr( $options['link_color'] ); ?>" /> 272 <a href="#" class="pickcolor hide-if-no-js" id="link-color-example"></a> 273 <input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color', 'twentyeleven' ); ?>" /> 274 <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> 275 <br /> 276 <span><?php printf( __( 'Default color: %s', 'twentyeleven' ), '<span id="default-color">' . twentyeleven_get_default_link_color( $options['color_scheme'] ) . '</span>' ); ?></span> 271 <?php $default_color = 'data-default-color="' . twentyeleven_get_default_link_color( $options['color_scheme'] ) . '"'; ?> 272 <input type="text" name="twentyeleven_theme_options[link_color]" id="link-color" value="<?php echo esc_attr( $options['link_color'] ); ?>" <?php echo $default_color ?>/> 277 273 <?php 278 274 } 279 275 -
wp-content/themes/twentyeleven/inc/theme-options.js
1 var farbtastic;2 3 1 (function($){ 4 var pickColor = function(a) {5 farbtastic.setColor(a);6 $('#link-color').val(a);7 $('#link-color-example').css('background-color', a);8 };9 10 2 $(document).ready( function() { 11 $('#default-color').wrapInner('<a href="#" />'); 12 13 farbtastic = $.farbtastic('#colorPickerDiv', pickColor); 14 15 pickColor( $('#link-color').val() ); 16 17 $('.pickcolor').click( function(e) { 18 $('#colorPickerDiv').show(); 19 e.preventDefault(); 20 }); 21 22 $('#link-color').keyup( function() { 23 var a = $('#link-color').val(), 24 b = a; 25 26 a = a.replace(/[^a-fA-F0-9]/, ''); 27 if ( '#' + a !== b ) 28 $('#link-color').val(a); 29 if ( a.length === 3 || a.length === 6 ) 30 pickColor( '#' + a ); 31 }); 32 33 $(document).mousedown( function() { 34 $('#colorPickerDiv').hide(); 35 }); 36 37 $('#default-color a').click( function(e) { 38 pickColor( '#' + this.innerHTML.replace(/[^a-fA-F0-9]/, '') ); 39 e.preventDefault(); 40 }); 41 3 $('#link-color').wpColorPicker(); 42 4 $('.image-radio-option.color-scheme input:radio').change( function() { 43 var currentDefault = $('# default-color a'),5 var currentDefault = $('#link-color').attr('data-default-color'), 44 6 newDefault = $(this).next().val(); 45 46 if ( $('#link-color').val() == currentDefault.text() ) 47 pickColor( newDefault ); 48 49 currentDefault.text( newDefault ); 7 8 if ( $('#link-color').val() == currentDefault.toString() ) 9 $("#link-color").iris("option", "color", newDefault ) 50 10 }); 51 11 }); 52 12 })(jQuery); 13 No newline at end of file -
wp-admin/js/custom-background.js
1 var farbtastic, pickColor;2 3 1 (function($) { 4 2 5 var defaultColor = '';6 7 pickColor = function(color) {8 farbtastic.setColor(color);9 $('#background-color').val(color);10 $('#custom-background-image').css('background-color', color);11 // If we have a default color, and they match, then we need to hide the 'Default' link.12 // Otherwise, we hide the 'Clear' link when it is empty.13 if ( ( defaultColor && color === defaultColor ) || ( ! defaultColor && ( '' === color || '#' === color ) ) )14 $('#clearcolor').hide();15 else16 $('#clearcolor').show();17 }18 19 3 $(document).ready(function() { 4 var bgImage = $("#custom-background-image"); 20 5 21 defaultColor = $('#defaultcolor').val(); 22 23 $('#pickcolor').click(function() { 24 $('#colorPickerDiv').show(); 25 return false; 6 $('#background-color').wpColorPicker({ 7 change: function( event, ui ) { 8 bgImage.css('background-color', ui.color.toString()); 9 }, 10 clear: function() { 11 bgImage.css('background-color', ''); 12 } 26 13 }); 27 14 28 $('#clearcolor a').click( function(e) {29 pickColor( defaultColor );30 e.preventDefault();31 });32 33 $('#background-color').keyup(function() {34 var _hex = $('#background-color').val(), hex = _hex;35 if ( hex.charAt(0) != '#' )36 hex = '#' + hex;37 hex = hex.replace(/[^#a-fA-F0-9]+/, '');38 if ( hex != _hex )39 $('#background-color').val(hex);40 if ( hex.length == 4 || hex.length == 7 )41 pickColor( hex );42 });43 44 15 $('input[name="background-position-x"]').change(function() { 45 $('#custom-background-image').css('background-position', $(this).val() + ' top');16 bgImage.css('background-position', $(this).val() + ' top'); 46 17 }); 47 18 48 19 $('input[name="background-repeat"]').change(function() { 49 $('#custom-background-image').css('background-repeat', $(this).val());20 bgImage.css('background-repeat', $(this).val()); 50 21 }); 51 52 farbtastic = $.farbtastic('#colorPickerDiv', function(color) {53 pickColor(color);54 });55 pickColor($('#background-color').val());56 57 $(document).mousedown(function(){58 $('#colorPickerDiv').each(function(){59 var display = $(this).css('display');60 if ( display == 'block' )61 $(this).fadeOut(2);62 });63 });64 22 }); 65 23 66 24 })(jQuery); 67 No newline at end of file -
wp-admin/js/customize-controls.js
109 109 api.ColorControl = api.Control.extend({ 110 110 ready: function() { 111 111 var control = this, 112 rhex, spot, input, text, update;112 rhex, input; 113 113 114 114 rhex = /^#([A-Fa-f0-9]{3}){0,2}$/; 115 spot = this.container.find('.dropdown-content');116 115 input = new api.Element( this.container.find('.color-picker-hex') ); 117 update = function( color ) {118 spot.css( 'background', color );119 c ontrol.farbtastic.setColor( color );120 };121 122 this.farbtastic = $.farbtastic( this.container.find('.farbtastic-placeholder'), control.setting.set);123 116 117 this.container.find('.color-picker-hex').wpColorPicker({ 118 change: function( event, options ) { 119 control.setting.set( options.color.toCSS() ); 120 } 121 }); 122 124 123 // Only pass through values that are valid hexes/empty. 125 124 input.sync( this.setting ).validate = function( to ) { 126 125 return rhex.test( to ) ? to : null; 127 126 }; 128 129 this.setting.bind( update );130 update( this.setting() );131 132 this.dropdownInit();133 127 } 134 128 }); 135 129 -
wp-admin/custom-header.php
175 175 wp_enqueue_script( 'media-upload' ); 176 176 wp_enqueue_script( 'custom-header' ); 177 177 if ( current_theme_supports( 'custom-header', 'header-text' ) ) 178 wp_enqueue_script(' farbtastic');178 wp_enqueue_script('wp-color-picker'); 179 179 } elseif ( 2 == $step ) { 180 180 wp_enqueue_script('imgareaselect'); 181 181 } … … 190 190 $step = $this->step(); 191 191 192 192 if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) 193 wp_enqueue_style(' farbtastic');193 wp_enqueue_style('wp-color-picker'); 194 194 elseif ( 2 == $step ) 195 195 wp_enqueue_style('imgareaselect'); 196 196 } … … 332 332 function js_1() { ?> 333 333 <script type="text/javascript"> 334 334 /* <![CDATA[ */ 335 var farbtastic;336 335 (function($){ 337 336 var default_color = '#<?php echo get_theme_support( 'custom-header', 'default-text-color' ); ?>', 338 337 header_text_fields; … … 341 340 $('#name').css('color', color); 342 341 $('#desc').css('color', color); 343 342 $('#text-color').val(color); 344 farbtastic.setColor(color);345 343 } 346 344 347 345 function toggle_text() { … … 361 359 362 360 $(document).ready(function() { 363 361 header_text_fields = $('.displaying-header-text'); 364 $('#pickcolor').click(function(e) { 365 e.preventDefault(); 366 $('#color-picker').show(); 362 $('#text-color').wpColorPicker({ 363 change: function( event, ui ) { 364 pickColor( ui.color.toString() ); 365 } 367 366 }); 368 369 367 $('#display-header-text').click( toggle_text ); 370 371 $('#defaultcolor').click(function() { 372 pickColor(default_color); 373 $('#text-color').val(default_color); 368 $('#defaultcolor').click(function() { 369 pickColor( default_color ); 374 370 }); 375 376 $('#text-color').keyup(function() { 377 var _hex = $('#text-color').val(); 378 var hex = _hex; 379 if ( hex[0] != '#' ) 380 hex = '#' + hex; 381 hex = hex.replace(/[^#a-fA-F0-9]+/, ''); 382 if ( hex != _hex ) 383 $('#text-color').val(hex); 384 if ( hex.length == 4 || hex.length == 7 ) 385 pickColor( hex ); 386 }); 387 388 $(document).mousedown(function(){ 389 $('#color-picker').each( function() { 390 var display = $(this).css('display'); 391 if (display == 'block') 392 $(this).fadeOut(2); 393 }); 394 }); 395 396 farbtastic = $.farbtastic('#color-picker', function(color) { pickColor(color); }); 397 <?php if ( display_header_text() ) { ?> 398 pickColor('#<?php echo get_header_textcolor(); ?>'); 399 <?php } else { ?> 371 <?php if ( !display_header_text() ) { ?> 400 372 toggle_text(); 401 373 <?php } ?> 402 374 }); … … 646 618 <tr valign="top" class="displaying-header-text"> 647 619 <th scope="row"><?php _e( 'Text Color' ); ?></th> 648 620 <td> 649 <p> 650 <?php if ( display_header_text() ) : ?> 651 <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_header_textcolor() ); ?>" /> 652 <?php else : ?> 653 <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_support( 'custom-header', 'default-text-color' ) ); ?>" /> 654 <?php endif; ?> 655 <a href="#" class="hide-if-no-js" id="pickcolor"><?php _e( 'Select a Color' ); ?></a> 621 <p> 622 <?php $header_textcolor = ( display_header_text() ) ? esc_attr( get_header_textcolor() ) : esc_attr( get_theme_support( 'custom-header', 'default-text-color' ) ); ?> 623 <input type="text" name="text-color" id="text-color" value="#<?php echo $header_textcolor; ?>" /> 656 624 </p> 657 <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>658 625 </td> 659 626 </tr> 660 627 -
wp-admin/css/customize-controls-rtl.css
65 65 margin-left: 5px; 66 66 } 67 67 68 .customize-section input[type="text"].color-picker-hex, 69 .customize-control-color .farbtastic-placeholder { 68 .customize-section input[type="text"].color-picker-hex { 70 69 float: right; 71 70 } 72 71 -
wp-admin/css/customize-controls.css
314 314 /* 315 315 * Color Picker 316 316 */ 317 .customize-control-color .color-picker-hex, 318 .customize-control-color .farbtastic-placeholder { 317 .customize-control-color .color-picker-hex { 319 318 display: none; 320 319 } 321 320 322 .customize-control-color.open .color-picker-hex, 323 .customize-control-color.open .farbtastic-placeholder { 321 .customize-control-color.open .color-picker-hex { 324 322 display: block; 325 323 } 326 324 … … 339 337 } 340 338 341 339 .customize-section input[type="text"].color-picker-hex { 342 float: left;343 340 width: 85px; 344 341 font-family: monospace; 345 342 text-align: center; … … 353 350 color: #999; 354 351 } 355 352 356 .customize-control-color .farbtastic-placeholder {357 width: 100%;358 margin: 5px 0 10px;359 float: left;360 }361 362 .customize-control-color .farbtastic {363 margin: 0 auto;364 }365 366 353 /* 367 354 * Image Picker 368 355 */ -
wp-admin/custom-background.php
108 108 add_thickbox(); 109 109 wp_enqueue_script('media-upload'); 110 110 wp_enqueue_script('custom-background'); 111 wp_enqueue_style(' farbtastic');111 wp_enqueue_style('wp-color-picker'); 112 112 } 113 113 114 114 /** … … 327 327 <tr valign="top"> 328 328 <th scope="row"><?php _e( 'Background Color' ); ?></th> 329 329 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend> 330 <?php $show_clear = get_theme_mod('background_color') ? '' : ' style="display:none"'; ?> 331 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" /> 332 <a class="hide-if-no-js" href="#" id="pickcolor"><?php _e('Select a Color'); ?></a> <span<?php echo $show_clear; ?> class="hide-if-no-js" id="clearcolor"> (<a href="#"><?php current_theme_supports( 'custom-background', 'default-color' ) ? _e( 'Default' ) : _e( 'Clear' ); ?></a>)</span> 333 <input type="hidden" id="defaultcolor" value="<?php if ( current_theme_supports( 'custom-background', 'default-color' ) ) echo '#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ); ?>" /> 334 <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> 330 <?php $default_color = current_theme_supports( 'custom-background', 'default-color' ) ? 'data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '" ' : ''; ?> 331 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" <?php echo $default_color ?>/> 335 332 </fieldset></td> 336 333 </tr> 337 334 </tbody>