6 var Drupal
= Drupal
|| {};
8 (function ($, Drupal
, Bootstrap
) {
12 * Extend the Bootstrap Tooltip plugin constructor class.
14 Bootstrap
.extendPlugin('tooltip', function (settings
) {
17 animation
: !!settings
.tooltip_animation
,
18 enabled
: settings
.tooltip_enabled
,
19 html
: !!settings
.tooltip_html
,
20 placement
: settings
.tooltip_placement
,
21 selector
: settings
.tooltip_selector
,
22 trigger
: settings
.tooltip_trigger
,
23 delay
: parseInt(settings
.tooltip_delay
, 10),
24 container
: settings
.tooltip_container
32 * @todo This should really be properly delegated if selector option is set.
34 Drupal
.behaviors
.bootstrapTooltips
= {
35 attach: function (context
) {
36 // Immediately return if tooltips are not available.
37 if (!$.fn
.tooltip
|| !$.fn
.tooltip
.Constructor
.DEFAULTS
.enabled
) {
41 var elements
= $(context
).find('[data-toggle="tooltip"]').toArray();
42 for (var i
= 0; i
< elements
.length
; i
++) {
43 var $element
= $(elements
[i
]);
44 var options
= $.extend({}, $.fn
.tooltip
.Constructor
.DEFAULTS
, $element
.data());
45 $element
.tooltip(options
);
48 detach: function (context
) {
49 // Immediately return if tooltips are not available.
50 if (!$.fn
.tooltip
|| !$.fn
.tooltip
.Constructor
.DEFAULTS
.enabled
) {
54 // Destroy all tooltips.
55 $(context
).find('[data-toggle="tooltip"]').tooltip('destroy');
59 })(window
.jQuery
, window
.Drupal
, window
.Drupal
.bootstrap
);