formtips.module 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @file
  4. * Form tips module uses JS to move form descriptions to tooltips.
  5. */
  6. define('FORMTIPS_SELECTORS', '');
  7. define('FORMTIPS_INTERVAL', 500);
  8. define('FORMTIPS_SENSITIVITY', 3);
  9. define('FORMTIPS_TIMEOUT', 1000);
  10. define('FORMTIPS_MAX_WIDTH', '500px');
  11. /**
  12. * Implements hook_init().
  13. */
  14. function formtips_init() {
  15. $module_path = drupal_get_path('module', 'formtips');
  16. if (variable_get('formtips_hoverintent', 1)) {
  17. drupal_add_js($module_path . '/hoverintent.minified.js');
  18. }
  19. drupal_add_js($module_path . '/formtips.js');
  20. drupal_add_css($module_path . '/formtips.css');
  21. drupal_add_js(formtips_js_settings(), 'setting');
  22. }
  23. /**
  24. * Generates the JS settings array.
  25. */
  26. function formtips_js_settings() {
  27. $selectors = explode("\r\n", variable_get('formtips_selectors', FORMTIPS_SELECTORS));
  28. return array('formtips' => array(
  29. 'selectors' => $selectors,
  30. 'interval' => variable_get('formtips_interval', FORMTIPS_INTERVAL),
  31. 'sensitivity' => variable_get('formtips_sensitivity', FORMTIPS_SENSITIVITY),
  32. 'timeout' => variable_get('formtips_timeout', FORMTIPS_TIMEOUT),
  33. 'max_width' => variable_get('formtips_max_width', FORMTIPS_MAX_WIDTH),
  34. 'trigger_action' => variable_get('formtips_trigger_action', 'hover'),
  35. ));
  36. }
  37. /**
  38. * Implements hook_menu().
  39. */
  40. function formtips_menu() {
  41. $items = array();
  42. $items['admin/config/user-interface/formtips'] = array(
  43. 'title' => 'Form tips',
  44. 'description' => 'Settings for the Formtips module.',
  45. 'page callback' => 'drupal_get_form',
  46. 'page arguments' => array('formtips_setting_form'),
  47. 'access arguments' => array('administer formtips'),
  48. 'file' => 'formtips.admin.inc',
  49. );
  50. return $items;
  51. }
  52. /**
  53. * Implements hook_permission().
  54. */
  55. function formtips_permission() {
  56. return array(
  57. 'administer formtips' => array(
  58. 'title' => t('Administer Form tips'),
  59. 'description' => t('Perform administration tasks for Form tips.'),
  60. ),
  61. );
  62. }