Add instant background-color feedback to Custom Backgrounds. Add input validation to user-entered colour data. See #12186
git-svn-id: https://develop.svn.wordpress.org/trunk@13764 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
12c0c3d475
commit
06c835eba5
@ -179,12 +179,24 @@ class Custom_Background {
|
||||
function pickColor(color) {
|
||||
jQuery('#background-color').val(color);
|
||||
farbtastic.setColor(color);
|
||||
jQuery('#custom-background-image').css('background-color', color);
|
||||
}
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#pickcolor').click(function() {
|
||||
jQuery('#colorPickerDiv').show();
|
||||
});
|
||||
jQuery('#background-color').keyup(function() {
|
||||
var _hex = jQuery('#background-color').val();
|
||||
var hex = _hex;
|
||||
if ( hex[0] != '#' )
|
||||
hex = '#' + hex;
|
||||
hex = hex.replace(/[^#a-fA-F0-9]+/, '');
|
||||
if ( hex != _hex )
|
||||
jQuery('#background-color').val(hex);
|
||||
if ( hex.length == 4 || hex.length == 7 )
|
||||
pickColor( hex );
|
||||
});
|
||||
|
||||
farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { pickColor(color); });
|
||||
pickColor('#<?php background_color(); ?>');
|
||||
|
Loading…
Reference in New Issue
Block a user