WordPress/wp-content/themes/twentyeleven/inc/theme-options.js
lancewillett a87ba1d261 Twenty Eleven: theme options - see #17198
* Make color swatch clickable to open palette
 * Change color picker link to a submit button to match existing UI

git-svn-id: http://svn.automattic.com/wordpress/trunk@17754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-04-28 19:01:51 +00:00

35 lines
754 B
JavaScript

var farbtastic;
(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();
});
$('#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();
});
});
})(jQuery);