You are here

function qtip_library in qTip (Stylish jQuery Tooltips) 7

Same name and namespace in other branches
  1. 7.2 qtip.module \qtip_library()

Implements hook_library().

File

./qtip.module, line 7

Code

function qtip_library() {
  $lib_version = variable_get('qtip_lib_version', '2.0.0pre');
  $lib_path = drupal_get_path('module', 'qtip') . '/library/';

  //$lib_file = sprintf('jquery.qtip', $lib_version);

  // Create the library
  $libraries['qtip'] = array(
    'title' => 'qTip',
    'website' => 'http://craigsworks.com/projects/qtip',
    'version' => $lib_version,
    'js' => array(
      $lib_path . '/jquery.qtip.js' => array(),
      drupal_get_path('module', 'qtip') . '/js/qtip.js' => array(),
      drupal_get_path('module', 'qtip') . '/js/qtip.modal.js' => array(),
    ),
    'css' => array(
      drupal_get_path('module', 'qtip') . '/library/jquery.qtip.css' => array(
        'type' => 'file',
        'media' => 'screen',
      ),
      drupal_get_path('module', 'qtip') . '/css/qtip.css' => array(
        'type' => 'file',
        'media' => 'screen',
      ),
      drupal_get_path('module', 'qtip') . '/css/qtip.modal.css' => array(
        'type' => 'file',
        'media' => 'screen',
      ),
    ),
  );

  // We have to get the right setting for the tooltip
  $qtip_position_map = array(
    'top_left' => 'bottom_right',
    'top_center' => 'bottom_center',
    'top_right' => 'bottom_left',
    'right_center' => 'left_center',
    'bottom_right' => 'top_left',
    'bottom_center' => 'top_center',
    'bottom_left' => 'top_right',
    'left_center' => 'right_center',
  );

  // Get the qTip settings, set by the administrator
  $target_position = variable_get('qtip_target_position', 'top_right');
  $tooltip_position = $qtip_position_map[$target_position];
  $settings = array(
    'target_position' => $target_position,
    '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'),
    'additional_elements' => variable_get('qtip_additional_elements', ''),
  );

  // Send the settings to qtip.js
  drupal_add_js(array(
    'qtip' => $settings,
  ), 'setting');
  return $libraries;
}