function theme_imagecacheactions_rgb_form in ImageCache Actions 6
Same name and namespace in other branches
- 6.2 utility-color.inc \theme_imagecacheactions_rgb_form()
Render the subform in a table
1 theme call to theme_imagecacheactions_rgb_form()
- imagecache_rgb_form in ./
utility.inc - Prepare a subform for displaying RGB fields
File
- ./
utility.inc, line 83 - Utility form, conversion and rendering functions for image processes
Code
function theme_imagecacheactions_rgb_form(&$form) {
// Add a farb element
drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
drupal_add_js('misc/farbtastic/farbtastic.js');
// drupal_add_js(drupal_get_path('module', 'imagecache_coloractions') . '/color.js');
$hex_id = $form['HEX']['#id'];
$form['farb'] = array(
'#value' => "<div id=\"{$hex_id}-farb\" style=\"float:right\"></div>",
'#weight' => -1,
);
// Adds the JS that binds the textarea with the farb element
$js = "\n \$(document).ready(function() {\n farbify(\$('#{$hex_id}'), '#{$hex_id}-farb');\n });\n\n function farbify(elt, wrapper) {\n var farb = \$.farbtastic(wrapper);\n farb.linkTo(function(color) {\n elt\n .css('background-color', color)\n .css('color', this.hsl[2] > 0.5 ? '#000' : '#fff')\n .val(color.substring(1));\n });\n farb.setColor('#' + elt.val());\n elt.bind('keyup', function(){ updateColor(elt, farb); });\n }\n function updateColor(elt, farb) {\n var text = elt.val();\n if (text.length == 6)\n farb.setColor('#' + text);\n }\n\n ";
drupal_add_js($js, 'inline');
$output = drupal_render($form);
return $output;
}