function beautytips_add_beautytips in BeautyTips 6.2
Same name and namespace in other branches
- 8 beautytips.module \beautytips_add_beautytips()
- 6 beautytips.module \beautytips_add_beautytips()
- 7.2 beautytips.module \beautytips_add_beautytips()
This is the API. Call this function to add beautytips.
Parameters
array $options - See README.txt for details:
7 calls to beautytips_add_beautytips()
- beautytips_admin in ./
beautytips.admin.inc - Menu callback - beautytips admin settings form TODO: Add animation options.
- beautytips_drupal_help_main in includes/
drupal_help.inc - Menu callback; prints a page listing a glossary of Drupal terminology. Beautytips added for the help links
- beautytips_init in ./
beautytips.module - Implementation of hook_init().
- beautytips_manager_init in ./
beautytips_manager.module - Implementation of hook_init().
- beautytips_textinput_form_change in includes/
textinput.inc
File
- ./
beautytips.module, line 54 - Provides API for adding beautytips to pages. TODO: Add status about excanvas on status page.
Code
function beautytips_add_beautytips($options = NULL) {
static $added = FALSE;
static $hover_added = FALSE;
$settings = array(
'beautytips' => array(),
);
$js_added = drupal_add_js($data = NULL, 'setting');
if (count($options)) {
foreach ($options as $beautytip => $content) {
// Ensure the js settings are not added more than once
if (isset($js_added['setting']) && is_array($js_added['setting'])) {
foreach ($js_added['setting'] as $setting) {
if (isset($setting['beautytips']) && is_array($setting['beautytips'])) {
if (array_key_exists($beautytip, $setting['beautytips'])) {
unset($content);
}
}
}
}
// Setup the settings array for adding js
if (isset($content) && is_array($content)) {
// Add hover intent js if specified
if (isset($content['trigger'])) {
if ($content['trigger'] == 'hover') {
$content['hoverIntentOpts'] = array(
'interval' => 0,
'timeout' => 0,
);
}
else {
if ($content['trigger'] == 'hoverIntent' && !$hover_added) {
$hover_added = TRUE;
drupal_add_js(drupal_get_path('module', 'beautytips') . '/other_libs/jquery.hoverIntent.minified.js');
}
}
}
$style = isset($content['style']) ? $content['style'] : 'default';
$settings['beautytips'][$beautytip] = array_merge(beautytips_get_style($style), $content);
$keys_no_add = array(
'cssSelect',
'style',
'list',
'text',
'preEval',
'ajaxDisableLink',
'animate',
);
foreach ($settings['beautytips'][$beautytip] as $key => $value) {
if (!in_array($key, $keys_no_add)) {
$settings['beautytips'][$beautytip]['list'][] = $key;
}
}
}
}
if ($added && !empty($settings['beautytips'])) {
drupal_add_js($settings, 'setting');
}
}
// Add beautytips jQuery plugin
if (!$added) {
$path = drupal_get_path('module', 'beautytips');
// Add excanvas for IE
$expath = $path . '/other_libs/excanvas_r3';
if (file_exists($expath . '/excanvas.compiled.js')) {
drupal_add_js($expath . '/excanvas.compiled.js');
}
drupal_add_js($path . '/js/jquery.bt.min.js');
drupal_add_js($path . '/js/beautytips.min.js');
drupal_add_js($settings, 'setting');
$added = TRUE;
}
}