function beautytips_add_beautytips in BeautyTips 6
Same name and namespace in other branches
- 8 beautytips.module \beautytips_add_beautytips()
- 6.2 beautytips.module \beautytips_add_beautytips()
- 7.2 beautytips.module \beautytips_add_beautytips()
This is the API. Call this function to add beautytips. See README.txt for more info.
5 calls to beautytips_add_beautytips()
- beautytips_admin in ./
beautytips.module - Beautytips administration page
- beautytips_form_alter in ./
beautytips.module - Implementation of hook_form_alter. Adds beautytips for textareas and textfields
- beautytips_help_main in ./
beautytips.module - Menu callback; prints a page listing a glossary of Drupal terminology. Beautytips added for the help links
- theme_beautytips_advanced_help_topic in ./
beautytips.module - Override of theme_advanced_help_topic to add Beautytips Display a help icon with a link to view the topic in a popup.
- theme_beautytips_more_help_link in ./
beautytips.module - Returns code that emits the 'more help'-link. Overrides theme_more_help_link
File
- ./
beautytips.module, line 119 - Provides API for adding beautytips to pages. Adds Beautytips settings page and provides some built in functionality.
Code
function beautytips_add_beautytips($options = NULL) {
static $added = FALSE;
$settings = array(
'beautytips' => array(),
);
$js_added = drupal_add_js($data = NULL, 'setting');
if (is_array($options)) {
// Make sure the settings are not added more than once
if (is_array($js_added['setting'])) {
foreach ($js_added['setting'] as $js_setting) {
if (isset($js_setting['beautytips'])) {
foreach ($js_setting['beautytips'] as $key => $value) {
if (isset($options[$key])) {
unset($options[$key]);
}
}
}
}
}
$settings['beautytips'] = array();
foreach ($options as $beautytip => $content) {
if (is_array($content)) {
$settings['beautytips'][$beautytip] = $content;
$get_keys = array_keys($content);
$count = 0;
for ($i = 0; $i < count($content); $i++) {
$key = $get_keys[$i];
if ($key != 'area' && $key != 'additionalJavascript') {
if ($key != 'list' && $key != 'text') {
$settings['beautytips'][$beautytip]['list'][$count] = $key;
$count++;
}
}
}
}
}
if ($added && !empty($settings['beautytips'])) {
drupal_add_js($settings, 'setting');
}
}
// Add beautytips jQuery plugin
if (!$added) {
$path = drupal_get_path('module', 'beautytips');
drupal_add_js($path . '/js/jquery.bt.min.js');
drupal_add_css($path . '/js/jquery.bt.css');
drupal_add_js($path . '/js/beautytips.js');
//for IE add this
$expath = $path . '/other_libs/excanvas_r3';
if (count(file_scan_directory($expath, 'excanvas.js', array(
'.',
'..',
'CVS',
), 0, FALSE))) {
drupal_add_js($expath . '/excanvas.js');
}
$settings['beautytips_defaults'] = theme('beautytips_styles');
drupal_add_js($settings, 'setting');
$added = TRUE;
}
}