You are here

function qtip_init in qTip (Stylish jQuery Tooltips) 6

Same name and namespace in other branches
  1. 6.2 qtip.module \qtip_init()
  2. 7.2 qtip.module \qtip_init()
  3. 7 qtip.module \qtip_init()

Implements of hook_init().

File

./qtip.module, line 14

Code

function qtip_init() {

  // We have to get the right setting for the tooltip
  switch (variable_get('qtip_target_position', 'top_right')) {
    case 'top_left':
      $tooltip_position = 'bottom_right';
      break;
    case 'top_center':
      $tooltip_position = 'bottom_center';
      break;
    case 'top_right':
      $tooltip_position = 'bottom_left';
      break;
    case 'right_center':
      $tooltip_position = 'left_center';
      break;
    case 'bottom_right':
      $tooltip_position = 'top_left';
      break;
    case 'bottom_center':
      $tooltip_position = 'top_center';
      break;
    case 'bottom_left':
      $tooltip_position = 'top_right';
      break;
    case 'left_center':
      $tooltip_position = 'right_center';
  }

  // Settings set by the administrator to send to qtip.js
  drupal_add_js(array(
    'qtip' => array(
      'target_position' => variable_get('qtip_target_position', 'top_right'),
      'tooltip_position' => $tooltip_position,
      'show_speech_bubble_tip' => variable_get('qtip_show_speech_bubble_tip', TRUE),
      'show_speech_bubble_tip_side' => variable_get('qtip_show_speech_bubble_tip_side', FALSE),
      'speech_bubble_size' => variable_get('qtip_speech_bubble_tip_size', 12),
      'show_speech_bubble_tip_solid' => variable_get('qtip_show_speech_bubble_tip_solid', FALSE),
      'show_shadow' => variable_get('qtip_show_shadow', FALSE),
      'rounded_corners' => variable_get('qtip_rounded_corners', FALSE),
      'color' => variable_get('qtip_color', ''),
      'custom_color' => variable_get('qtip_custom_color', ''),
      'show_event_type' => variable_get('qtip_show_event_type', 'mouseenter'),
      'hide_event_type' => variable_get('qtip_hide_event_type', 'mouseleave'),
      //      'show_solo' => variable_get('qtip_show_solo', TRUE),
      'show_webform_descriptions' => variable_get('qtip_show_webform_descriptions', FALSE),
      'additional_elements' => variable_get('qtip_additional_elements', ''),
    ),
  ), 'setting');
  drupal_add_css(drupal_get_path('module', 'qtip') . '/library/jquery.qtip.css');
  drupal_add_css(drupal_get_path('module', 'qtip') . '/css/qtip.css');

  // Check to see if qtip library is in sites/all/libraries/qtip first...
  if (file_exists(QTIP_PATH . QTIP_FILE)) {
    drupal_add_js(QTIP_PATH . QTIP_FILE);
  }
  drupal_add_js(drupal_get_path('module', 'qtip') . '/js/qtip.js');

  // Only load qtip.admin.js file if currently viewing qTip settings page
  if (request_uri() == base_path() . 'admin/settings/qtip') {
    drupal_add_js(drupal_get_path('module', 'qtip') . '/js/qtip.admin.js');
  }
}