| 1 |
/* $Id $ */
|
| 2 |
$(function() {
|
| 3 |
if (Drupal.jsEnabled) {
|
| 4 |
farbify($('#edit-background'), '#background-farb');
|
| 5 |
farbify($('#edit-foreground'), '#foreground-farb');
|
| 6 |
farbify($('#edit-shadow-color'), '#shadow-color-farb');
|
| 7 |
}
|
| 8 |
});
|
| 9 |
|
| 10 |
function updateColor(elt, farb) {
|
| 11 |
var text = elt.val();
|
| 12 |
if (text.length == 6)
|
| 13 |
farb.setColor('#' + text);
|
| 14 |
}
|
| 15 |
|
| 16 |
function farbify(elt, wrapper) {
|
| 17 |
var farb = $.farbtastic(wrapper);
|
| 18 |
farb.linkTo(function(color) {
|
| 19 |
elt
|
| 20 |
.css('background-color', color)
|
| 21 |
.css('color', this.hsl[2] > 0.5 ? '#000' : '#fff')
|
| 22 |
.val(color.substring(1));
|
| 23 |
});
|
| 24 |
farb.setColor('#' + elt.val());
|
| 25 |
elt.bind('keyup', function(){ updateColor(elt, farb); });
|
| 26 |
}
|