Ticket #39662: 39662.diff
| File 39662.diff, 9.2 KB (added by , 9 years ago) |
|---|
-
src/wp-admin/css/color-picker.css
6 6 display: none; 7 7 } 8 8 9 .wp-color-result { 10 background-color: #f7f7f7; 11 border: 1px solid #ccc; 12 -webkit-border-radius: 3px; 13 border-radius: 3px; 14 cursor: pointer; 15 display: inline-block; 16 height: 22px; 9 /* Needs higher specificiity. */ 10 .wp-picker-container .wp-color-result { 11 height: 24px; 17 12 margin: 0 6px 6px 0px; 18 position: relative; 19 top: 1px; 20 -webkit-user-select: none; 21 -moz-user-select: none; 22 -ms-user-select: none; 23 user-select: none; 24 vertical-align: bottom; 25 display: inline-block; 26 padding-left: 30px; 27 -webkit-box-shadow: 0 1px 0 #ccc; 28 box-shadow: 0 1px 0 #ccc; 13 padding: 0 0 0 30px; 29 14 } 30 15 31 .wp-color-result :after{16 .wp-color-result-text { 32 17 background: #f7f7f7; 33 18 -webkit-border-radius: 0 2px 2px 0; 34 19 border-radius: 0 2px 2px 0; 35 20 border-left: 1px solid #ccc; 36 21 color: #555; 37 content: attr( title );38 22 display: block; 39 23 font-size: 11px; 40 24 line-height: 22px; 41 25 padding: 0 6px; 42 position: relative;43 right: 0;44 26 text-align: center; 45 top: 0;46 27 } 47 28 48 29 .wp-color-result:hover, … … 59 40 border-left: 1px solid #999; 60 41 } 61 42 62 .wp-color-result {63 top: 0;64 }65 66 .wp-color-result.wp-picker-open:after {67 content: attr( data-current );68 }69 70 43 .wp-picker-container, .wp-picker-container:active { 71 44 display: inline-block; 72 45 outline: 0; … … 83 56 vertical-align: top; 84 57 } 85 58 86 .wp-picker-container . button{87 margin-left: 6px;59 .wp-picker-container .wp-picker-clear { 60 margin-left: 2px; 88 61 } 89 62 90 63 .wp-picker-container .iris-square-slider .ui-slider-handle:focus { … … 133 106 box-shadow: 134 107 0 0 0 1px #5b9dd9, 135 108 0 0 2px 1px rgba(30, 140, 190, .8); 136 } 137 No newline at end of file 109 } -
src/wp-admin/css/customize-controls.css
893 893 max-width: 112px; 894 894 } 895 895 896 /* Color Picker */897 .customize-control-color .color-picker-hex {898 display: none;899 }900 901 .customize-control-color.open .color-picker-hex {902 display: block;903 }904 905 896 .customize-control-color .dropdown { 906 897 margin-right: 5px; 907 898 margin-bottom: 5px; -
src/wp-admin/js/color-picker.js
3 3 4 4 var ColorPicker, 5 5 // html stuff 6 _before = '< a tabindex="0" class="wp-color-result" />',6 _before = '<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>', 7 7 _after = '<div class="wp-picker-holder" />', 8 8 _wrap = '<div class="wp-picker-container" />', 9 _button = '<input type="button" class="button button-small hidden" />';9 _button = '<input type="button" class="button button-small" />'; 10 10 11 11 // jQuery UI Widget constructor 12 12 ColorPicker = { … … 66 66 67 67 self.initialValue = el.val(); 68 68 69 // Set up HTML structure, hide things 70 el.addClass( 'wp-color-picker' ).hide().wrap( _wrap ); 71 self.wrap = el.parent(); 72 self.toggler = $( _before ).insertBefore( el ).css( { backgroundColor: self.initialValue } ).attr( 'title', wpColorPickerL10n.pick ).attr( 'data-current', wpColorPickerL10n.current ); 73 self.pickerContainer = $( _after ).insertAfter( el ); 69 // Add CSS class to the input field. 70 el.addClass( 'wp-color-picker' ); 71 // Find the input field wrapper element and store it. 72 self.inputWrapper = el.closest( '.wp-picker-input-wrap' ); 73 // Wrap the input field wrapper in the container _wrap element. 74 self.inputWrapper.wrap( _wrap ); 75 // Store the container _wrap element. 76 self.wrap = el.closest( '.wp-picker-container' ); 77 // Set up the toggle button and insert it at the beginning of the container _wrap element. 78 self.toggler = $( _before ).prependTo( self.wrap ).css( { backgroundColor: self.initialValue } ) 79 // Set up the toggle button text. 80 self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick ); 81 // Insert the color picker holder at the end of the container _wrap element. 82 self.pickerContainer = $( _after ).appendTo( self.wrap ); 83 // Store the Default/Clear button. 74 84 self.button = $( _button ); 75 85 86 // Set up the Default/Clear button. 76 87 if ( self.options.defaultColor ) { 77 self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString ); 88 self.button 89 .addClass( 'wp-picker-default' ) 90 .val( wpColorPickerL10n.defaultString ) 91 .attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel ); 78 92 } else { 79 self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear ); 93 self.button 94 .addClass( 'wp-picker-clear' ) 95 .val( wpColorPickerL10n.clear ) 96 .attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );; 80 97 } 81 98 82 el.wrap( '<span class="wp-picker-input-wrap" />' ).after(self.button); 99 // Append the Default/Clear button to the input field wrapper element. 100 self.inputWrapper.append( self.button ); 83 101 84 102 el.iris( { 85 103 target: self.pickerContainer, … … 131 149 } 132 150 }); 133 151 134 // open a keyboard-focused closed picker with space or enter135 self.toggler.on( 'keyup', function( event ) {136 if ( event.keyCode === 13 || event.keyCode === 32 ) {137 event.preventDefault();138 self.toggler.trigger( 'click' ).next().focus();139 }140 });141 142 152 self.button.click( function( event ) { 143 153 var me = $( this ); 144 154 if ( me.hasClass( 'wp-picker-clear' ) ) { … … 153 163 }); 154 164 }, 155 165 open: function() { 156 this.element. show().iris( 'toggle' ).focus();157 this. button.removeClass( 'hidden' );166 this.element.iris( 'toggle' ); 167 this.inputWrapper.removeClass( 'hidden' ); 158 168 this.wrap.addClass( 'wp-picker-active' ); 159 this.toggler.addClass( 'wp-picker-open' ); 169 this.toggler 170 .addClass( 'wp-picker-open' ) 171 .attr( 'aria-expanded', 'true' ); 160 172 $( 'body' ).trigger( 'click.wpcolorpicker' ).on( 'click.wpcolorpicker', this.close ); 161 173 }, 162 174 close: function() { 163 this.element. hide().iris( 'toggle' );164 this. button.addClass( 'hidden' );175 this.element.iris( 'toggle' ); 176 this.inputWrapper.addClass( 'hidden' ); 165 177 this.wrap.removeClass( 'wp-picker-active' ); 166 this.toggler.removeClass( 'wp-picker-open' ); 178 this.toggler 179 .removeClass( 'wp-picker-open' ) 180 .attr( 'aria-expanded', 'false' ); 167 181 $( 'body' ).off( 'click.wpcolorpicker', this.close ); 168 182 }, 169 183 // $("#input").wpColorPicker('color') returns the current color -
src/wp-includes/customize/class-wp-customize-color-control.php
103 103 } 104 104 defaultValue = ' data-default-color=' + defaultValue; // Quotes added automatically. 105 105 } #> 106 <label> 107 <# if ( data.label ) { #> 108 <span class="customize-control-title">{{{ data.label }}}</span> 109 <# } #> 110 <# if ( data.description ) { #> 111 <span class="description customize-control-description">{{{ data.description }}}</span> 112 <# } #> 113 <div class="customize-control-content"> 106 <# if ( data.label ) { #> 107 <span class="customize-control-title">{{{ data.label }}}</span> 108 <# } #> 109 <# if ( data.description ) { #> 110 <span class="description customize-control-description">{{{ data.description }}}</span> 111 <# } #> 112 <div class="customize-control-content"> 113 <div class="wp-picker-input-wrap hidden"> 114 <label><span class="screen-reader-text">{{{ data.label }}}</span> 114 115 <# if ( isHueSlider ) { #> 115 116 <input class="color-picker-hue" type="text" data-type="hue" /> 116 117 <# } else { #> 117 118 <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} /> 118 119 <# } #> 120 </label> 119 121 </div> 120 </ label>122 </div> 121 123 <?php 122 124 } 123 125 } -
src/wp-includes/script-loader.php
715 715 $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 ); 716 716 $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); 717 717 did_action( 'init' ) && $scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array( 718 'clear' => __( 'Clear' ), 719 'defaultString' => __( 'Default' ), 720 'pick' => __( 'Select Color' ), 721 'current' => __( 'Current Color' ), 718 'clear' => __( 'Clear' ), 719 'clearAriaLabel' => __( 'Clear color' ), 720 'defaultString' => __( 'Default' ), 721 'defaultAriaLabel' => __( 'Select default color' ), 722 'pick' => __( 'Select Color' ), 722 723 ) ); 723 724 724 725 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );