function beautytips_manager_admin in BeautyTips 6.2
Form for configuring custom beautytips.
1 string reference to 'beautytips_manager_admin'
- beautytips_manager_menu in ./
beautytips_manager.module - Implementation of hook_menu().
File
- ./
beautytips_manager.module, line 112
Code
function beautytips_manager_admin(&$form_state, $bid = NULL) {
drupal_add_css(drupal_get_path('module', 'beautytips') . '/css/beautytips.css');
$tip = beautytips_manager_get_custom_tip($bid);
$form = array();
$form['tip'] = array(
'#type' => 'markup',
'#value' => '',
'#tree' => TRUE,
);
$form['tip']['bid'] = array(
'#type' => 'value',
'#value' => is_object($tip) ? $tip->bid : 0,
);
$form['tip']['element'] = array(
'#type' => 'textfield',
'#title' => t('Element'),
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => is_object($tip) ? $tip->element : '',
);
$content_options = array(
'attribute' => 'attribute',
'text' => 'text',
'ajax' => 'ajax',
);
$description = t('Content to display in the beautytip. The data entered here depends on the Content Type.');
$types = array();
$types[0] = t('attribute - Enter the attribute of the element that should be displayed. (If empty, the title will be selected.)');
$types[0] .= '<br />' . t('ex. "alt"');
$types[1] = t('text - Enter the text that should be displayed with in the beautytip.');
$types[1] .= '<br />' . t('ex. "This is my beautytip!"');
$types[2] = t('ajax - This will grab the page from the "href" attribute and display that page. Enter css selectors to narrow the down the content from that page.');
$types[2] .= '<br />' . t('ex. "#my-id .my-class"');
if (user_access('use Javascript for custom beautytip display')) {
$content_options['js'] = 'js';
$types[3] = 'js - Directly enter javascript to select the content.';
$types[3] .= '<br />' . t('ex. "$(this).next(\'.description\').html()"');
}
$form['tip']['content_type'] = array(
'#type' => 'radios',
'#title' => t('Type of Content'),
'#description' => t('This helps determine from where to pull the content to be displayed.'),
'#options' => $content_options,
'#default_value' => is_object($tip) ? $tip->content_type : 0,
);
$form['tip']['content'] = array(
'#type' => 'textarea',
'#title' => t('Content to Display'),
'#description' => theme('item_list', $types),
'#default_value' => is_object($tip) ? $tip->content : '',
);
$triggers = beautytips_manager_get_triggers();
$form['tip']['trigger_on'] = array(
'#type' => 'select',
'#title' => t('Trigger On'),
'#description' => t('Not all events are available for all elements. See jQuery <a href="@events">events documentation</a> for details.', array(
'@events' => 'http://docs.jquery.com/Events',
)),
'#options' => $triggers,
'#default_value' => is_object($tip) ? $tip->trigger_on : 0,
'#prefix' => '<div class="beautytips-triggers">',
);
$form['tip']['trigger_off'] = array(
'#type' => 'select',
'#title' => t('Trigger Off'),
'#options' => $triggers,
'#suffix' => '</div>',
'#default_value' => is_object($tip) ? $tip->trigger_off : 0,
);
$styles = beautytips_get_styles();
foreach ($styles as $key => $style) {
$style_options[$key] = $key;
}
$form['tip']['style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#options' => $style_options,
'#default_value' => is_object($tip) ? $tip->style : 'default',
);
$form['tip']['shrink'] = array(
'#type' => 'checkbox',
'#title' => t('Shrink to Fit'),
'#description' => t('Shrink the beautytip to the size of the content. This can sometimes help with sizing problems and is good for tips with just one line.'),
'#default_value' => is_object($tip) ? $tip->shrink : FALSE,
);
$positions = is_object($tip) ? explode(',', $tip->positions) : array();
$form['tip']['positions'] = array(
'#type' => 'fieldset',
'#title' => t('Positions'),
'#description' => t("Optionally enter the order of positions in which you want the tip to appear. It will use first in order with available space. The last value will be used if others don't have enough space. If no entries, then the tip will be placed in the area with the most space. Only enter an order for those you wish to use"),
'#tree' => TRUE,
);
$positions_list = array(
'top',
'bottom',
'left',
'right',
);
foreach ($positions_list as $position) {
$form['tip']['positions'][$position] = array(
'#type' => 'textfield',
'#title' => t($position),
'#default_value' => array_search($position, $positions) !== FALSE ? array_search($position, $positions) : '',
'#size' => 1,
'#maxlength' => 1,
'#prefix' => '<div class="beautytips-positions">',
'#suffix' => '</div>',
);
}
$form['tip']['animation_on'] = array(
'#type' => 'select',
'#title' => t('Animation (On)'),
'#options' => array(
'' => '<none>',
'fadeIn' => 'fadeIn',
),
'#description' => t("These animations will be applied to the tip when it is turn on or off."),
'#default_value' => is_object($tip) ? $tip->animation_on : '',
'#prefix' => '<div class="beautytips-animations">',
);
$form['tip']['animation_off'] = array(
'#type' => 'select',
'#title' => t('Animation (Off)'),
'#options' => array(
'' => '<none>',
'fadeOut' => 'fadeOut',
'slideOut' => 'slideOut',
),
'#default_value' => is_object($tip) ? $tip->animation_off : '',
'#suffix' => '</div>',
);
$options = array(
t('Show on every page except the listed pages.'),
t('Show on only the listed pages.'),
);
$description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
$form['tip']['visibility'] = array(
'#type' => 'radios',
'#title' => t('Show beautytip on specific pages'),
'#options' => $options,
'#default_value' => is_object($tip) ? $tip->visibility : 0,
'#prefix' => '<div id="edit-tip-visibility-wrapper">',
'#suffix' => '</div>',
);
$form['tip']['pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => is_object($tip) ? $tip->pages : '',
'#description' => $description,
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
$form['#submit'][] = 'beautytips_manager_admin_submit';
return $form;
}