View source
<?php
function tipsy_page_build(&$page) {
drupal_add_library('tipsy', 'tipsy', TRUE);
}
function tipsy_library() {
$module_path = drupal_get_path('module', 'tipsy');
$libraries = array();
$libraries['tipsy'] = array(
'title' => 'Tipsy',
'website' => 'http://onehackoranother.com/projects/jquery/tipsy/',
'version' => '0.1.7',
'js' => array(
$module_path . '/javascripts/jquery.tipsy.js' => array(),
$module_path . '/javascripts/tipsy.js' => array(),
),
'css' => array(
$module_path . '/stylesheets/tipsy.css' => array(
'type' => 'file',
),
),
);
$settings = _tipsy_get_settings();
if ($settings['drupal_forms']['forms'] == 0) {
unset($settings['drupal_forms']);
}
drupal_add_js(array(
'tipsy' => $settings,
), 'setting');
return $libraries;
}
function tipsy_menu() {
$items = array();
$items['admin/config/user-interface/tipsy'] = array(
'title' => 'Tipsy',
'description' => 'Integrates tipsy tooltips with Drupal',
'page callback' => 'drupal_get_form',
'access callback' => 'user_access',
'access arguments' => array(
'administer tipsy',
),
'page arguments' => array(
'tipsy_admin',
),
'file' => 'tipsy.admin.inc',
);
return $items;
}
function tipsy_permission() {
$permissions = array();
$permissions['administer tipsy'] = array(
'title' => t('Administer tipsy'),
'description' => t('Allows users to configure tipsy.'),
);
return $permissions;
}
function tipsy_theme() {
return array(
'tipsy_custom_selectors_form' => array(
'render element' => 'form',
'file' => 'tipsy.admin.inc',
),
);
}
function _tipsy_get_settings($new_rule = FALSE) {
if ($new_rule == TRUE) {
$settings = array(
'selector' => '',
'options' => array(
'fade' => 1,
'gravity' => 'w',
'delayIn' => 0,
'delayOut' => 0,
'trigger' => 'hover',
'opacity' => '0.8',
'offset' => 0,
'html' => 0,
'tooltip_content' => array(
'source' => 'attribute',
'selector' => 'title',
),
),
);
}
else {
$wide_settings = array(
'drupal_forms' => array(
'forms' => FALSE,
'options' => array(
'fade' => 1,
'gravity' => 'autoWE',
'delayIn' => 0,
'delayOut' => 0,
'trigger' => 'focus',
'opacity' => '0.8',
'offset' => 0,
),
),
'custom_selectors' => array(
0 => array(
'selector' => '.tipsy',
'options' => array(
'fade' => 1,
'gravity' => 'w',
'delayIn' => 0,
'delayOut' => 0,
'trigger' => 'hover',
'opacity' => '0.8',
'offset' => 0,
'html' => 0,
'tooltip_content' => array(
'source' => 'attribute',
'selector' => 'title',
),
),
),
),
);
$settings = variable_get('tipsy', $wide_settings);
$converted_settings = FALSE;
foreach ($settings['custom_selectors'] as &$selector) {
if (isset($selector['options']['title'])) {
$selector['options']['tooltip_content']['source'] = 'attribute';
$selector['options']['tooltip_content']['selector'] = $selector['options']['title'];
unset($selector['options']['title']);
$converted_settings = TRUE;
}
}
if ($converted_settings) {
variable_set('tipsy', $settings);
}
}
return $settings;
}