'radios', '#title' => t('Choose a style'), '#description' => t('Mouse over the radio buttons to see a preview.'), '#options' => array( 'default' => t('default'), 'netflix' => t('Netflix'), 'facebook' => t('Facebook'), 'transparent' => t('Transparent with Big Text'), 'big_green' => t('Green with no border'), 'google_maps' => t('Google Maps'), ), '#default_value' => variable_get('beautytips_styles', 'default'), ); $path = drupal_get_path('module', 'beautytips') .'/js/bt_admin_page.js'; drupal_add_js($path); beautytips_add_beautytips(); } /** * Clear menu cache and theme registry in case beautytips help tips turned on or off */ function beautytips_ui_admin_submit($form, $form_state) { variable_set('beautytips_always_add', $form_state['values']['beautytips_always_add']); module_invoke('menu', 'rebuild'); cache_clear_all('*', 'cache_menu', TRUE); drupal_rebuild_theme_registry(); beautytips_ui_set_style($form_state['values']['beautytips_styles']); } /** * Implementation of hook_menu. */ function beautytips_ui_menu() { $items = array(); $menu_items = beautytips_ui_include_invoke('beautytips', 'menu_items', $args = NULL); if (is_array($menu_items)) { foreach ($menu_items as $menu_item) { if (is_array($menu_item)) { $path = key($menu_item); $items[$path] = $menu_item[$path]; } } } return $items; } /** * Determine whether an include implements a hook, cf. module_hook. * * @param $tooltip * The name of the tooltip file (without the .inc extension), such as 'youtube' or 'google'. * @param $hook * The name of the hook (e.g. "thumbnail", "settings", etc.). * @return * TRUE if the tooltip is loaded and the hook is implemented. */ function beautytips_ui_include_hook($module, $tooltip, $hook) { return function_exists($module .'_'. $tooltip .'_'. $hook); } /** * Invoke hook in a particular include. * * @param $module * the helper module * @param $tooltip * The name of the tooltip (without the .inc extension). * @param $hook * The name of the hook (e.g. "menu_change", "form_change", etc.). * @param ... * Arguments to pass to the hook implementation. * @return * The return value of the hook implementation. */ function beautytips_ui_include_invoke($module, $hook, $args) { $includes = beautytips_ui_include_list(); foreach ($includes as $tooltip) { $function = $module .'_'. $tooltip .'_'. $hook; $params[] = beautytips_ui_include_hook($module, $tooltip, $hook) ? call_user_func_array($function, $args) : NULL; } return $params; } /** * Maintains a list of all loaded include files. * * @param $file * ------------------------- * @return * An array of all loaded includes. (w/o appended .inc) */ // TODO: This may need to change - only unclude the items needed - maybe function beautytips_ui_include_list() { static $list = array(); $dir = drupal_get_path('module', 'beautytips') .'/includes'; $files = file_scan_directory($dir, '.inc'); foreach ($files as $file) { include_once('./'. $file->filename); $list[$file->filename] = $file->name; } return $list; } /** * See jQuery.bt.js for descriptions of defaults * Sets the default style for beautytips */ function beautytips_ui_set_style($style) { $bt_defaults = array(); // The default style isn't necessarily needed here. switch ($style) { case 'default': $bt_defaults = array( 'cssStyles' => array(), ); break; case 'netflix': $bt_defaults = array( 'positions' => array(0 => 'right', 1 => 'left'), 'fill' => '#FFF', 'padding' => 5, //'shadow' => true, //Reimplement shadow when issue is fixed //'shadowBlur' => 12, 'strokeStyle' => '#B9090B', 'spikeLength' => 50, 'spikeGirth' => 60, 'cornerRadius' => 10, 'centerPointY' => .1, 'overlap' => -8, 'cssStyles' => array( 'fontSize' => '12px', 'fontFamily' => 'arial,helvetica,sans-serif', ), ); break; case 'facebook': $bt_defaults = array( 'fill' => '#F7F7F7', 'padding' => 8, 'strokeStyle' => '#B7B7B7', 'cornerRadius' => 0, 'cssStyles' => array( 'fontFamily' => '"lucida grande",tahoma,verdana,arial,sans-serif', 'fontSize' => '11px', ), ); break; case 'transparent': $bt_defaults = array( 'fill' => 'rgba(0, 0, 0, .8)', 'padding' => 20, 'strokeStyle' => '#CC0', 'strokeWidth' => 3, 'spikeLength' => 40, 'spikeGirth' => 40, 'cornerRadius' => 40, 'cssStyles' => array( 'color' => '#FFF', 'fontWeight' => 'bold', ), ); break; case 'big_green': $bt_defaults = array( 'fill' => '#00FF4E', 'padding' => 20, 'strokeWidth' => 0, 'spikeLength' => 40, 'spikeGirth' => 40, 'cornerRadius' => 15, 'cssStyles' => array( 'fontFamily' => '"lucida grande",tahoma,verdana,arial,sans-serif', 'fontSize' => '14px', ), ); break; case 'google_maps': $bt_defaults = array( 'positions' => array(0 => 'top', 1 => 'bottom'), 'fill' => '#FFF', 'padding' => 15, 'strokeStyle' => '#ABABAB', 'strokeWidth' => 1, 'spikeLength' => 65, 'spikeGirth' => 40, 'cornerRadius' => 25, 'centerPointX' => .9, 'cssStyles' => array(), ); break; } variable_set('beautytips_defaults', $bt_defaults); } /** * Implementation of hook_form_alter. * Adds beautytips for textareas and textfields */ function beautytips_ui_form_alter(&$form, $form_state, $form_id) { beautytips_ui_include_invoke('beautytips', 'form_change', array( 'form' => &$form, 'form_state' => $form_state, 'form_id' => $form_id, ) ); } /** * Implementation of hook_menu_alter(). */ function beautytips_ui_menu_alter(&$items) { beautytips_ui_include_invoke('beautytips', 'menu_change', array('items' => &$items)); } /** * Implementation of hook_theme_registry_alter(). */ function beautytips_ui_theme_registry_alter(&$theme_registry) { beautytips_ui_include_invoke('beautytips', 'theme_change', array('theme_registry' => &$theme_registry)); }