formtips.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. (function ($) {
  2. Drupal.behaviors.formtips = {
  3. attach: function (context) {
  4. var settings = Drupal.settings.formtips,
  5. selectors = $.isArray(settings.selectors) ? settings.selectors.join(', ') : settings.selectors;
  6. $('.form-item .description')
  7. .not(selectors).not('.formtips-processed')
  8. .addClass('formtips-processed').each(function(index) {
  9. var description = $(this),
  10. item = $(this).closest('.form-item'),
  11. label = item.find('label:first');
  12. description.hide();
  13. item.css('position', 'relative');
  14. label.wrap('<div class="formtips-wrapper clear-block"/>').append('<a class="formtip"></a>');
  15. if (settings.trigger_action == 'click') {
  16. item.find('.formtip').click(function(e) {
  17. description.toggle('fast');
  18. e.preventDefault();
  19. });
  20. }
  21. else {
  22. item.find('.formtip').hoverIntent({
  23. sensitivity: settings.sensitivity,
  24. interval: settings.interval,
  25. over: function () {
  26. description.show('fast');
  27. },
  28. timeout: settings.timeout,
  29. out: function () {
  30. description.hide('fast');
  31. }
  32. });
  33. };
  34. });
  35. $('.form-item .description.formtips-processed').css('max-width', settings.maxWidth);
  36. }
  37. };
  38. })(jQuery);