Restore keyboard accessibility to the color picker. Props lessbloat. see #21206

git-svn-id: http://core.svn.wordpress.org/trunk@22385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-11-05 23:00:15 +00:00
parent c94990017b
commit 1fc0104667
4 changed files with 40 additions and 36 deletions

View File

@ -6,19 +6,12 @@
}
.wp-color-result {
background-color: #f9f9f9;
border: 1px solid #c4c4c4;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
box-shadow: inset 1px 1px 0 rgba(0,0,0,.05);
-moz-box-shadow: inset 1px 1px 0 rgba(0,0,0,.05);
-ms-box-shadow: inset 1px 1px 0 rgba(0,0,0,.05);
-o-box-shadow: inset 1px 1px 0 rgba(0,0,0,.05);
-webkit-box-shadow: inset 1px 1px 0 rgba(0,0,0,.05);
border: 1px solid #bbb;
border-radius: 2px;
cursor: pointer;
display: inline-block;
height: 21px;
margin: 0 6px 1px 0px;
height: 22px;
margin: 0 6px 6px 0px;
position: relative;
top: 1px;
user-select: none;
@ -29,24 +22,21 @@
display: inline-block;
padding-left: 30px;
}
.wp-color-result::after {
background-color: #f9f9f9;
background-image: -moz-linear-gradient(top, #fff 0%, #eee 100%);
background-image: -webkit-linear-gradient(top, #fff 0%, #eee 100%);
background-image: -ms-linear-gradient(top, #fff 0%, #eee 100%);
background-image: -o-linear-gradient(top, #fff 0%, #eee 100%);
background-image: linear-gradient(top, #fff 0%, #eee 100%);
-moz-border-radius-bottomright: 3px;
-moz-border-radius-topright: 3px;
-webkit-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
border-bottom-right-radius: 3px;
border-left: 1px solid #c4c4c4;
.wp-color-result:after {
background: #f3f3f3;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#f4f4f4));
background-image: -webkit-linear-gradient(top, #fefefe, #f4f4f4);
background-image: -moz-linear-gradient(top, #fefefe, #f4f4f4);
background-image: -o-linear-gradient(top, #fefefe, #f4f4f4);
background-image: linear-gradient(to bottom, #fefefe, #f4f4f4);
color: #333;
text-shadow: 0 1px 0 #fff;
border-radius: 0 1px 1px 0;
border-left: 1px solid #bbb;
content: attr( title );
color: #555;
display: block;
font-size: 11px;
line-height: 21px;
line-height: 22px;
padding: 0 6px;
position: relative;
right: 0px;
@ -68,7 +58,6 @@
}
.wp-color-result.wp-picker-open {
top: 0;
/*width: 5px;*/
}
.wp-color-result.wp-picker-open:after {
content: attr( data-current );
@ -88,6 +77,10 @@
.wp-color-result:focus:after {
border-color: #888;
}
.wp-picker-open + .wp-picker-input-wrap {
display: inline-block;
vertical-align: top;
}
.wp-picker-container .button {
margin-left: 6px;
}

View File

@ -338,6 +338,7 @@ body {
width: 65px;
font-family: monospace;
text-align: center;
line-height: 16px;
}
/* The centered cursor overlaps the placeholder in webkit. Hide it when selected. */

View File

@ -1,10 +1,10 @@
( function( $, undef ){
// html stuff
var _before = '<a tabindex="0" class="wp-color-result" />';
var _after = '<div class="wp-picker-holder" />';
var _wrap = '<div class="wp-picker-container" />';
var _button = '<input type="button" class="button button-tiny hidden" />';
var _before = '<a tabindex="0" class="wp-color-result" />',
_after = '<div class="wp-picker-holder" />',
_wrap = '<div class="wp-picker-container" />',
_button = '<input type="button" class="button button-small hidden" />';
// jQuery UI Widget constructor
var ColorPicker = {
@ -36,11 +36,13 @@
else
self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
self.button.insertAfter( el );
el.wrap('<span class="wp-picker-input-wrap" />').after(self.button);
el.iris( {
target: self.pickerContainer,
hide: true,
width: 255,
mode: 'hsv',
change: function( event, ui ) {
self.toggler.css( { backgroundColor: ui.color.toString() } );
// check for a custom cb
@ -82,8 +84,8 @@
});
// open a keyboard-focused closed picker with space or enter
$( document ).keydown( function( e ) {
if ( self.toggler.is( ':focus' ) && ( e.keyCode === 13 || e.keyCode === 32 ) ) {
self.toggler.on('keyup', function( e ) {
if ( e.keyCode === 13 || e.keyCode === 32 ) {
e.preventDefault();
self.toggler.trigger('click').next().focus();
}
@ -112,6 +114,14 @@
return this.element.iris( "option", "color" );
this.element.iris( "option", "color", newColor );
},
//$("#input").wpColorPicker('default_color') returns the current default color
//$("#input").wpColorPicker('default_color', newDefaultColor) to set
default_color: function( newDefaultColor ) {
if ( newDefaultColor === undef )
return this.options.defaultColor;
this.options.defaultColor = newDefaultColor;
}
}

File diff suppressed because one or more lines are too long