Updated the Bootstrap theme.
[yaffs-website] / web / themes / contrib / bootstrap / js / tooltip.js
1 /**
2  * @file
3  * Bootstrap Tooltips.
4  */
5
6 var Drupal = Drupal || {};
7
8 (function ($, Drupal, Bootstrap) {
9   "use strict";
10
11   /**
12    * Extend the Bootstrap Tooltip plugin constructor class.
13    */
14   Bootstrap.extendPlugin('tooltip', function (settings) {
15     return {
16       DEFAULTS: {
17         animation: !!settings.tooltip_animation,
18         html: !!settings.tooltip_html,
19         placement: settings.tooltip_placement,
20         selector: settings.tooltip_selector,
21         trigger: settings.tooltip_trigger,
22         delay: parseInt(settings.tooltip_delay, 10),
23         container: settings.tooltip_container
24       }
25     };
26   });
27
28   /**
29    * Bootstrap Tooltips.
30    *
31    * @todo This should really be properly delegated if selector option is set.
32    */
33   Drupal.behaviors.bootstrapTooltips = {
34     attach: function (context) {
35       var elements = $(context).find('[data-toggle="tooltip"]').toArray();
36       for (var i = 0; i < elements.length; i++) {
37         var $element = $(elements[i]);
38         var options = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, $element.data());
39         $element.tooltip(options);
40       }
41     },
42     detach: function (context) {
43       // Destroy all tooltips.
44       $(context).find('[data-toggle="tooltip"]').tooltip('destroy');
45     }
46   };
47
48 })(window.jQuery, window.Drupal, window.Drupal.bootstrap);