1 var farbtastic, pickColor;
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();
16 $('#clearcolor').show();
19 $(document).ready(function() {
21 defaultColor = $('#defaultcolor').val();
23 $('#pickcolor').click(function() {
24 $('#colorPickerDiv').show();
28 $('#clearcolor a').click( function(e) {
29 pickColor( defaultColor );
33 $('#background-color').keyup(function() {
34 var _hex = $('#background-color').val(), hex = _hex;
35 if ( hex.charAt(0) != '#' )
37 hex = hex.replace(/[^#a-fA-F0-9]+/, '');
39 $('#background-color').val(hex);
40 if ( hex.length == 4 || hex.length == 7 )
44 $('input[name="background-position-x"]').change(function() {
45 $('#custom-background-image').css('background-position', $(this).val() + ' top');
48 $('input[name="background-repeat"]').change(function() {
49 $('#custom-background-image').css('background-repeat', $(this).val());
52 farbtastic = $.farbtastic('#colorPickerDiv', function(color) {
55 pickColor($('#background-color').val());
57 $(document).mousedown(function(){
58 $('#colorPickerDiv').each(function(){
59 var display = $(this).css('display');
60 if ( display == 'block' )