1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
(function ($) {
|
7
|
Drupal.color = {
|
8
|
callback: function(context, settings, form, farb, height, width) {
|
9
|
|
10
|
$('#preview', form).css('backgroundColor', $('#palette input[name="palette[base]"]', form).val());
|
11
|
|
12
|
|
13
|
$('#text', form).css('color', $('#palette input[name="palette[text]"]', form).val());
|
14
|
$('#text a, #text h2', form).css('color', $('#palette input[name="palette[link]"]', form).val());
|
15
|
|
16
|
|
17
|
var color_start, color_end;
|
18
|
for (i in settings.gradients) {
|
19
|
color_start = farb.unpack($('#palette input[name="palette[' + settings.gradients[i]['colors'][0] + ']"]', form).val());
|
20
|
color_end = farb.unpack($('#palette input[name="palette[' + settings.gradients[i]['colors'][1] + ']"]', form).val());
|
21
|
if (color_start && color_end) {
|
22
|
var delta = [];
|
23
|
for (j in color_start) {
|
24
|
delta[j] = (color_end[j] - color_start[j]) / (settings.gradients[i]['vertical'] ? height[i] : width[i]);
|
25
|
}
|
26
|
var accum = color_start;
|
27
|
|
28
|
$('#gradient-' + i + ' > div', form).each(function () {
|
29
|
for (j in accum) {
|
30
|
accum[j] += delta[j];
|
31
|
}
|
32
|
this.style.backgroundColor = farb.pack(accum);
|
33
|
});
|
34
|
}
|
35
|
}
|
36
|
}
|
37
|
};
|
38
|
})(jQuery);
|