This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/modules/contrib/webform/js/webform.tooltip.js
2017-03-16 15:29:07 +00:00

47 lines
1.1 KiB
JavaScript

/**
* @file
* Javascript behaviors for jQuery UI tooltip integration.
*
* Please Note:
* jQuery UI's tooltip implementation is not very responsive or adaptive.
*
* @see https://www.drupal.org/node/2207383
*/
(function ($, Drupal) {
'use strict';
/**
* Initialize jQuery UI tooltip element support.
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.webformTooltipElement = {
attach: function (context) {
$(context).find('.js-webform-tooltip-element').once('webform-tooltip-element').each(function () {
var $element = $(this);
var $description = $element.children('.description.visually-hidden');
$element.tooltip({
items: ':input',
content: $description.html()
});
});
}
};
/**
* Initialize jQuery UI tooltip link support.
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.webformTooltipLink = {
attach: function (context) {
$(context).find('a.js-webform-tooltip-link').once('webform-tooltip-link').each(function () {
$(this).tooltip();
});
}
};
})(jQuery, Drupal);