Skip to content

Instantly share code, notes, and snippets.

@johnrobertwilson
Created July 13, 2011 15:07
Show Gist options
  • Save johnrobertwilson/1080486 to your computer and use it in GitHub Desktop.
Save johnrobertwilson/1080486 to your computer and use it in GitHub Desktop.
Farbtastic
$theme = 'energy';
$info = color_get_info($theme);
$info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
$color_sets = array();
$schemes = array();
foreach ($info['schemes'] as $key => $scheme) {
$color_sets[$key] = $scheme['title'];
$schemes[$key] = $scheme['colors'];
$schemes[$key] += $info['schemes']['default']['colors'];
}
$form['chart_options']['plot']['background_color'] = array(
'#type' => 'select',
'#title' => t('Color set'),
'#options' => '',
'#default_value' => '',
'#attached' => array(
// Add Farbtastic color picker.
'library' => array(
array('system', 'farbtastic'),
),
// Add custom CSS.
'css' => array(
drupal_get_path('module', 'color') . '/color.css' => array(),
),
// Add custom JavaScript.
'js' => array(
drupal_get_path('module', 'color') . '/color.js',
array(
'data' => array(
'color' => array(
'reference' => color_get_palette($theme, TRUE),
'schemes' => $schemes,
),
'gradients' => $info['gradients'],
),
'type' => 'setting',
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment