function image_hotspots_style_config in Image Hotspots 7.2
Builds Hotspots-style configuration form.
1 string reference to 'image_hotspots_style_config'
- image_hotspots_menu in ./
image_hotspots.module - Implements hook_menu().
File
- includes/
image_hotspots.admin.inc, line 11 - Admin configuration for module.
Code
function image_hotspots_style_config($form, &$form_state) {
$default_settings = variable_get('image_hotspots_settings', image_hotspots_default());
$presets = count($default_settings);
$form_state['storage']['hotspot_style'] = isset($form_state['storage']['hotspot_style']) ? $form_state['storage']['hotspot_style'] : 0;
$form['color_example'] = array(
'#prefix' => '<div class="hotspots_example">',
'#suffix' => '</div>',
'#attached' => array(
'css' => array(
drupal_get_path('module', 'image_hotspots') . '/themes/image_hotspots.css',
),
'css' => array(
drupal_get_path('module', 'image_hotspots') . '/themes/image_hotspots_adm.css',
),
'js' => array(
drupal_get_path('module', 'image_hotspots') . '/themes/hotspots_color_adm.js',
),
),
);
$form['old_style'] = array(
'#type' => 'container',
'#tree' => TRUE,
'#prefix' => '<div id="old_style">',
'#suffix' => '</div>',
);
$form['hotspot_style'] = array(
'#type' => 'container',
'#tree' => TRUE,
'#prefix' => '<div id="hotspot_style">',
'#suffix' => '</div>',
);
if ($presets > 0) {
foreach ($default_settings as $setting => $values) {
$form['old_style'][$setting] = image_hotspots_build_row();
$form['old_style'][$setting]['#states'] = array(
'disabled' => array(
':input[name="old_style[' . $setting . '][remove]"]' => array(
'checked' => TRUE,
),
),
'visible' => array(
':input[name="old_style[' . $setting . '][remove]"]' => array(
'checked' => FALSE,
),
),
);
$form['old_style'][$setting]['border']['width']['#states'] = array(
'disabled' => array(
':input[name="old_style[' . $setting . '][border][style]"]' => array(
'value' => 'none',
),
),
);
$form['old_style'][$setting]['border']['color']['#states'] = $form['old_style'][$setting]['border']['width']['#states'];
// @todo: Make it more cleanly.
$form['old_style'][$setting]['color']['#value'] = isset($values['background-color']) ? $values['background-color'] : '';
$form['old_style'][$setting]['opacity']['#value'] = isset($values['opacity']) ? $values['opacity'] : '';
$form['old_style'][$setting]['border']['color']['#value'] = isset($values['border']['color']) ? $values['border']['color'] : '';
$form['old_style'][$setting]['border']['width']['#value'] = isset($values['border']['width']) ? $values['border']['width'] : '';
$form['old_style'][$setting]['border']['style']['#default_value'] = isset($values['border']['style']) ? $values['border']['style'] : '';
}
}
if ($form_state['storage']['hotspot_style']) {
for ($i = 1; $i <= $form_state['storage']['hotspot_style']; $i++) {
$form['hotspot_style'][$i] = image_hotspots_build_row();
$form['hotspot_style'][$i]['#states'] = array(
'disabled' => array(
':input[name="hotspot_style[' . $i . '][remove]"]' => array(
'checked' => TRUE,
),
),
'visible' => array(
':input[name="hotspot_style[' . $i . '][remove]"]' => array(
'checked' => FALSE,
),
),
);
$form['hotspot_style'][$i]['border']['width']['#states'] = array(
'disabled' => array(
':input[name="hotspot_style[' . $i . '][border][style]"]' => array(
'value' => 'none',
),
),
);
$form['hotspot_style'][$i]['border']['color']['#states'] = $form['hotspot_style'][$i]['border']['width']['#states'];
}
}
$form['add_participant'] = array(
'#type' => 'button',
'#value' => t('+'),
'#href' => '',
'#ajax' => array(
'callback' => 'image_hotspots_add_row',
'wrapper' => 'hotspot_style',
),
);
$form['submit'] = array(
'#value' => t('Save'),
'#type' => 'submit',
);
$form['default'] = array(
'#value' => t('Default'),
'#type' => 'submit',
);
$form_state['storage']['hotspot_style']++;
return $form;
}