tooltip.js 17.3 KB
Newer Older
Mark Otto's avatar
grunt    
Mark Otto committed
1
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
XhmikosR's avatar
XhmikosR committed
2

Mark Otto's avatar
grunt    
Mark Otto committed
3
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4

Mark Otto's avatar
grunt    
Mark Otto committed
5
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7
8

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
9
 * Bootstrap (v4.0.0-alpha.5): tooltip.js
10
11
12
13
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
grunt    
Mark Otto committed
14
var Tooltip = function ($) {
15

16
17
  /**
   * Check for Tether dependency
Mark Otto's avatar
grunt    
Mark Otto committed
18
   * Tether - http://tether.io/
19
   */
XhmikosR's avatar
XhmikosR committed
20
  if (window.Tether === undefined) {
Mark Otto's avatar
grunt    
Mark Otto committed
21
    throw new Error('Bootstrap tooltips require Tether (http://tether.io/)');
22
23
  }

24
25
26
27
28
29
30
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'tooltip';
Mark Otto's avatar
Mark Otto committed
31
  var VERSION = '4.0.0-alpha.5';
32
  var DATA_KEY = 'bs.tooltip';
fat's avatar
fat committed
33
  var EVENT_KEY = '.' + DATA_KEY;
34
35
36
37
38
39
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 150;
  var CLASS_PREFIX = 'bs-tether';

  var Default = {
    animation: true,
Mark Otto's avatar
grunt    
Mark Otto committed
40
    template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-inner"></div></div>',
41
42
43
44
45
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
fat's avatar
fat committed
46
    placement: 'top',
47
    offset: '0 0',
Mark Otto's avatar
grunt    
Mark Otto committed
48
49
    constraints: [],
    container: false
fat's avatar
fat committed
50
51
52
53
54
  };

  var DefaultType = {
    animation: 'boolean',
    template: 'string',
XhmikosR's avatar
XhmikosR committed
55
    title: '(string|element|function)',
fat's avatar
fat committed
56
57
58
59
60
61
    trigger: 'string',
    delay: '(number|object)',
    html: 'boolean',
    selector: '(string|boolean)',
    placement: '(string|function)',
    offset: 'string',
Mark Otto's avatar
grunt    
Mark Otto committed
62
63
    constraints: 'array',
    container: '(string|element|boolean)'
64
65
  };

fat's avatar
fat committed
66
67
68
69
70
  var AttachmentMap = {
    TOP: 'bottom center',
    RIGHT: 'middle left',
    BOTTOM: 'top center',
    LEFT: 'middle right'
71
72
73
  };

  var HoverState = {
Mark Otto's avatar
grunt    
Mark Otto committed
74
    ACTIVE: 'active',
75
76
77
78
    OUT: 'out'
  };

  var Event = {
fat's avatar
fat committed
79
80
81
82
83
84
85
86
87
88
    HIDE: 'hide' + EVENT_KEY,
    HIDDEN: 'hidden' + EVENT_KEY,
    SHOW: 'show' + EVENT_KEY,
    SHOWN: 'shown' + EVENT_KEY,
    INSERTED: 'inserted' + EVENT_KEY,
    CLICK: 'click' + EVENT_KEY,
    FOCUSIN: 'focusin' + EVENT_KEY,
    FOCUSOUT: 'focusout' + EVENT_KEY,
    MOUSEENTER: 'mouseenter' + EVENT_KEY,
    MOUSELEAVE: 'mouseleave' + EVENT_KEY
89
90
91
92
  };

  var ClassName = {
    FADE: 'fade',
Mark Otto's avatar
grunt    
Mark Otto committed
93
    ACTIVE: 'active'
94
95
96
97
  };

  var Selector = {
    TOOLTIP: '.tooltip',
98
99
    TOOLTIP_INNER: '.tooltip-inner'
  };
100
101

  var TetherClass = {
fat's avatar
fat committed
102
103
104
105
106
107
108
109
110
    element: false,
    enabled: false
  };

  var Trigger = {
    HOVER: 'hover',
    FOCUS: 'focus',
    CLICK: 'click',
    MANUAL: 'manual'
111
112
113
114
115
116
117
118
  };

  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */

Mark Otto's avatar
grunt    
Mark Otto committed
119
  var Tooltip = function () {
120
121
122
123
124
125
126
127
    function Tooltip(element, config) {
      _classCallCheck(this, Tooltip);

      // private
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
Mark Otto's avatar
grunt    
Mark Otto committed
128
      this._isTransitioning = false;
fat's avatar
fat committed
129
      this._tether = null;
130
131
132
133
134
135
136
137
138

      // protected
      this.element = element;
      this.config = this._getConfig(config);
      this.tip = null;

      this._setListeners();
    }

Jacob Thornton's avatar
Jacob Thornton committed
139
140
    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
141
    // public
142

Mark Otto's avatar
grunt    
Mark Otto committed
143
144
145
    Tooltip.prototype.enable = function enable() {
      this._isEnabled = true;
    };
146

Mark Otto's avatar
grunt    
Mark Otto committed
147
148
149
    Tooltip.prototype.disable = function disable() {
      this._isEnabled = false;
    };
150

Mark Otto's avatar
grunt    
Mark Otto committed
151
152
153
    Tooltip.prototype.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };
Mark Otto's avatar
Mark Otto committed
154

Mark Otto's avatar
grunt    
Mark Otto committed
155
156
157
158
    Tooltip.prototype.toggle = function toggle(event) {
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
        var context = $(event.currentTarget).data(dataKey);
Mark Otto's avatar
Mark Otto committed
159

Mark Otto's avatar
grunt    
Mark Otto committed
160
161
162
        if (!context) {
          context = new this.constructor(event.currentTarget, this._getDelegateConfig());
          $(event.currentTarget).data(dataKey, context);
163
        }
fat's avatar
fat committed
164

Mark Otto's avatar
grunt    
Mark Otto committed
165
        context._activeTrigger.click = !context._activeTrigger.click;
fat's avatar
fat committed
166

Mark Otto's avatar
grunt    
Mark Otto committed
167
168
169
170
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
        } else {
          context._leave(null, context);
fat's avatar
fat committed
171
        }
Mark Otto's avatar
grunt    
Mark Otto committed
172
      } else {
fat's avatar
fat committed
173

Mark Otto's avatar
grunt    
Mark Otto committed
174
        if ($(this.getTipElement()).hasClass(ClassName.ACTIVE)) {
Mark Otto's avatar
grunt    
Mark Otto committed
175
176
177
          this._leave(null, this);
          return;
        }
fat's avatar
fat committed
178

Mark Otto's avatar
grunt    
Mark Otto committed
179
        this._enter(null, this);
180
      }
Mark Otto's avatar
grunt    
Mark Otto committed
181
    };
182

Mark Otto's avatar
grunt    
Mark Otto committed
183
184
    Tooltip.prototype.dispose = function dispose() {
      clearTimeout(this._timeout);
185

Mark Otto's avatar
grunt    
Mark Otto committed
186
      this.cleanupTether();
187

Mark Otto's avatar
grunt    
Mark Otto committed
188
      $.removeData(this.element, this.constructor.DATA_KEY);
189

Mark Otto's avatar
grunt    
Mark Otto committed
190
      $(this.element).off(this.constructor.EVENT_KEY);
Mark Otto's avatar
grunt    
Mark Otto committed
191
      $(this.element).closest('.modal').off('hide.bs.modal');
192

Mark Otto's avatar
grunt    
Mark Otto committed
193
194
195
      if (this.tip) {
        $(this.tip).remove();
      }
196

Mark Otto's avatar
grunt    
Mark Otto committed
197
198
199
200
201
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
      this._tether = null;
202

Mark Otto's avatar
grunt    
Mark Otto committed
203
204
205
206
      this.element = null;
      this.config = null;
      this.tip = null;
    };
207

Mark Otto's avatar
grunt    
Mark Otto committed
208
209
    Tooltip.prototype.show = function show() {
      var _this = this;
210

Mark Otto's avatar
grunt    
Mark Otto committed
211
212
213
      if ($(this.element).css('display') === 'none') {
        throw new Error('Please use show on visible elements');
      }
214

Mark Otto's avatar
grunt    
Mark Otto committed
215
      var showEvent = $.Event(this.constructor.Event.SHOW);
Mark Otto's avatar
grunt    
Mark Otto committed
216
      if (this.isWithContent() && this._isEnabled) {
Mark Otto's avatar
grunt    
Mark Otto committed
217
218
219
        if (this._isTransitioning) {
          throw new Error('Tooltip is transitioning');
        }
Mark Otto's avatar
grunt    
Mark Otto committed
220
        $(this.element).trigger(showEvent);
221

Mark Otto's avatar
grunt    
Mark Otto committed
222
        var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
223

Mark Otto's avatar
grunt    
Mark Otto committed
224
225
226
        if (showEvent.isDefaultPrevented() || !isInTheDom) {
          return;
        }
227

Mark Otto's avatar
grunt    
Mark Otto committed
228
229
        var tip = this.getTipElement();
        var tipId = Util.getUID(this.constructor.NAME);
230

Mark Otto's avatar
grunt    
Mark Otto committed
231
232
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
233

Mark Otto's avatar
grunt    
Mark Otto committed
234
        this.setContent();
235

Mark Otto's avatar
grunt    
Mark Otto committed
236
237
238
        if (this.config.animation) {
          $(tip).addClass(ClassName.FADE);
        }
239

Mark Otto's avatar
grunt    
Mark Otto committed
240
        var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
241

Mark Otto's avatar
grunt    
Mark Otto committed
242
        var attachment = this._getAttachment(placement);
243

Mark Otto's avatar
grunt    
Mark Otto committed
244
245
246
        var container = this.config.container === false ? document.body : $(this.config.container);

        $(tip).data(this.constructor.DATA_KEY, this).appendTo(container);
Mark Otto's avatar
Mark Otto committed
247

Mark Otto's avatar
grunt    
Mark Otto committed
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
        $(this.element).trigger(this.constructor.Event.INSERTED);

        this._tether = new Tether({
          attachment: attachment,
          element: tip,
          target: this.element,
          classes: TetherClass,
          classPrefix: CLASS_PREFIX,
          offset: this.config.offset,
          constraints: this.config.constraints,
          addTargetClasses: false
        });

        Util.reflow(tip);
        this._tether.position();

Mark Otto's avatar
grunt    
Mark Otto committed
264
        $(tip).addClass(ClassName.ACTIVE);
265
266

        var complete = function complete() {
Mark Otto's avatar
grunt    
Mark Otto committed
267
268
          var prevHoverState = _this._hoverState;
          _this._hoverState = null;
Mark Otto's avatar
grunt    
Mark Otto committed
269
          _this._isTransitioning = false;
270

Mark Otto's avatar
grunt    
Mark Otto committed
271
          $(_this.element).trigger(_this.constructor.Event.SHOWN);
272

Mark Otto's avatar
grunt    
Mark Otto committed
273
274
          if (prevHoverState === HoverState.OUT) {
            _this._leave(null, _this);
275
276
277
          }
        };

Mark Otto's avatar
grunt    
Mark Otto committed
278
        if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
Mark Otto's avatar
grunt    
Mark Otto committed
279
          this._isTransitioning = true;
Mark Otto's avatar
grunt    
Mark Otto committed
280
          $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
281
282
283
          return;
        }

Mark Otto's avatar
grunt    
Mark Otto committed
284
285
286
        complete();
      }
    };
287

Mark Otto's avatar
grunt    
Mark Otto committed
288
289
    Tooltip.prototype.hide = function hide(callback) {
      var _this2 = this;
290

Mark Otto's avatar
grunt    
Mark Otto committed
291
292
      var tip = this.getTipElement();
      var hideEvent = $.Event(this.constructor.Event.HIDE);
Mark Otto's avatar
grunt    
Mark Otto committed
293
294
295
      if (this._isTransitioning) {
        throw new Error('Tooltip is transitioning');
      }
Mark Otto's avatar
grunt    
Mark Otto committed
296
      var complete = function complete() {
Mark Otto's avatar
grunt    
Mark Otto committed
297
        if (_this2._hoverState !== HoverState.ACTIVE && tip.parentNode) {
Mark Otto's avatar
grunt    
Mark Otto committed
298
          tip.parentNode.removeChild(tip);
299
300
        }

Mark Otto's avatar
grunt    
Mark Otto committed
301
302
        _this2.element.removeAttribute('aria-describedby');
        $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
Mark Otto's avatar
grunt    
Mark Otto committed
303
        _this2._isTransitioning = false;
Mark Otto's avatar
grunt    
Mark Otto committed
304
        _this2.cleanupTether();
305

Mark Otto's avatar
grunt    
Mark Otto committed
306
307
308
309
        if (callback) {
          callback();
        }
      };
310

Mark Otto's avatar
grunt    
Mark Otto committed
311
312
313
314
      $(this.element).trigger(hideEvent);

      if (hideEvent.isDefaultPrevented()) {
        return;
315
316
      }

Mark Otto's avatar
grunt    
Mark Otto committed
317
      $(tip).removeClass(ClassName.ACTIVE);
318

Mark Otto's avatar
grunt    
Mark Otto committed
319
      if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
Mark Otto's avatar
grunt    
Mark Otto committed
320
        this._isTransitioning = true;
Mark Otto's avatar
grunt    
Mark Otto committed
321
322
323
        $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
      } else {
        complete();
324
      }
Mark Otto's avatar
grunt    
Mark Otto committed
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343

      this._hoverState = '';
    };

    // protected

    Tooltip.prototype.isWithContent = function isWithContent() {
      return Boolean(this.getTitle());
    };

    Tooltip.prototype.getTipElement = function getTipElement() {
      return this.tip = this.tip || $(this.config.template)[0];
    };

    Tooltip.prototype.setContent = function setContent() {
      var $tip = $(this.getTipElement());

      this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle());

344
      $tip.removeClass(ClassName.FADE + ' ' + ClassName.ACTIVE);
Mark Otto's avatar
grunt    
Mark Otto committed
345
346
347
348
349
350
351
352
353
354
355

      this.cleanupTether();
    };

    Tooltip.prototype.setElementContent = function setElementContent($element, content) {
      var html = this.config.html;
      if ((typeof content === 'undefined' ? 'undefined' : _typeof(content)) === 'object' && (content.nodeType || content.jquery)) {
        // content is a DOM node or a jQuery
        if (html) {
          if (!$(content).parent().is($element)) {
            $element.empty().append(content);
XhmikosR's avatar
XhmikosR committed
356
357
          }
        } else {
Mark Otto's avatar
grunt    
Mark Otto committed
358
          $element.text($(content).text());
XhmikosR's avatar
XhmikosR committed
359
        }
Mark Otto's avatar
grunt    
Mark Otto committed
360
361
      } else {
        $element[html ? 'html' : 'text'](content);
XhmikosR's avatar
XhmikosR committed
362
      }
Mark Otto's avatar
grunt    
Mark Otto committed
363
    };
364

Mark Otto's avatar
grunt    
Mark Otto committed
365
366
    Tooltip.prototype.getTitle = function getTitle() {
      var title = this.element.getAttribute('data-original-title');
367

Mark Otto's avatar
grunt    
Mark Otto committed
368
369
      if (!title) {
        title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
370
371
      }

Mark Otto's avatar
grunt    
Mark Otto committed
372
373
      return title;
    };
374

Mark Otto's avatar
grunt    
Mark Otto committed
375
376
377
    Tooltip.prototype.cleanupTether = function cleanupTether() {
      if (this._tether) {
        this._tether.destroy();
fat's avatar
fat committed
378
      }
Mark Otto's avatar
grunt    
Mark Otto committed
379
    };
380

Mark Otto's avatar
grunt    
Mark Otto committed
381
    // private
382

Mark Otto's avatar
grunt    
Mark Otto committed
383
384
385
    Tooltip.prototype._getAttachment = function _getAttachment(placement) {
      return AttachmentMap[placement.toUpperCase()];
    };
386

Mark Otto's avatar
grunt    
Mark Otto committed
387
388
    Tooltip.prototype._setListeners = function _setListeners() {
      var _this3 = this;
389

Mark Otto's avatar
grunt    
Mark Otto committed
390
391
392
393
      var triggers = this.config.trigger.split(' ');

      triggers.forEach(function (trigger) {
        if (trigger === 'click') {
Mark Otto's avatar
grunt    
Mark Otto committed
394
395
396
          $(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, function (event) {
            return _this3.toggle(event);
          });
Mark Otto's avatar
grunt    
Mark Otto committed
397
398
399
400
        } else if (trigger !== Trigger.MANUAL) {
          var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
          var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;

Mark Otto's avatar
grunt    
Mark Otto committed
401
402
403
404
405
          $(_this3.element).on(eventIn, _this3.config.selector, function (event) {
            return _this3._enter(event);
          }).on(eventOut, _this3.config.selector, function (event) {
            return _this3._leave(event);
          });
406
        }
Mark Otto's avatar
grunt    
Mark Otto committed
407
408
409
410

        $(_this3.element).closest('.modal').on('hide.bs.modal', function () {
          return _this3.hide();
        });
Mark Otto's avatar
grunt    
Mark Otto committed
411
412
413
414
415
416
417
418
419
      });

      if (this.config.selector) {
        this.config = $.extend({}, this.config, {
          trigger: 'manual',
          selector: ''
        });
      } else {
        this._fixTitle();
420
      }
Mark Otto's avatar
grunt    
Mark Otto committed
421
    };
fat's avatar
fat committed
422

Mark Otto's avatar
grunt    
Mark Otto committed
423
424
425
426
427
428
429
    Tooltip.prototype._fixTitle = function _fixTitle() {
      var titleType = _typeof(this.element.getAttribute('data-original-title'));
      if (this.element.getAttribute('title') || titleType !== 'string') {
        this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
        this.element.setAttribute('title', '');
      }
    };
430

Mark Otto's avatar
grunt    
Mark Otto committed
431
432
    Tooltip.prototype._enter = function _enter(event, context) {
      var dataKey = this.constructor.DATA_KEY;
433

Mark Otto's avatar
grunt    
Mark Otto committed
434
      context = context || $(event.currentTarget).data(dataKey);
435

Mark Otto's avatar
grunt    
Mark Otto committed
436
437
438
439
      if (!context) {
        context = new this.constructor(event.currentTarget, this._getDelegateConfig());
        $(event.currentTarget).data(dataKey, context);
      }
440

Mark Otto's avatar
grunt    
Mark Otto committed
441
442
443
      if (event) {
        context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
      }
444

Mark Otto's avatar
grunt    
Mark Otto committed
445
446
      if ($(context.getTipElement()).hasClass(ClassName.ACTIVE) || context._hoverState === HoverState.ACTIVE) {
        context._hoverState = HoverState.ACTIVE;
Mark Otto's avatar
grunt    
Mark Otto committed
447
448
449
450
451
        return;
      }

      clearTimeout(context._timeout);

Mark Otto's avatar
grunt    
Mark Otto committed
452
      context._hoverState = HoverState.ACTIVE;
453

Mark Otto's avatar
grunt    
Mark Otto committed
454
455
456
457
458
459
      if (!context.config.delay || !context.config.delay.show) {
        context.show();
        return;
      }

      context._timeout = setTimeout(function () {
Mark Otto's avatar
grunt    
Mark Otto committed
460
        if (context._hoverState === HoverState.ACTIVE) {
461
462
          context.show();
        }
Mark Otto's avatar
grunt    
Mark Otto committed
463
464
      }, context.config.delay.show);
    };
465

Mark Otto's avatar
grunt    
Mark Otto committed
466
467
    Tooltip.prototype._leave = function _leave(event, context) {
      var dataKey = this.constructor.DATA_KEY;
fat's avatar
fat committed
468

Mark Otto's avatar
grunt    
Mark Otto committed
469
      context = context || $(event.currentTarget).data(dataKey);
470

Mark Otto's avatar
grunt    
Mark Otto committed
471
472
473
474
      if (!context) {
        context = new this.constructor(event.currentTarget, this._getDelegateConfig());
        $(event.currentTarget).data(dataKey, context);
      }
475

Mark Otto's avatar
grunt    
Mark Otto committed
476
477
478
      if (event) {
        context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
      }
479

Mark Otto's avatar
grunt    
Mark Otto committed
480
481
482
483
484
      if (context._isWithActiveTrigger()) {
        return;
      }

      clearTimeout(context._timeout);
485

Mark Otto's avatar
grunt    
Mark Otto committed
486
      context._hoverState = HoverState.OUT;
487

Mark Otto's avatar
grunt    
Mark Otto committed
488
489
490
491
      if (!context.config.delay || !context.config.delay.hide) {
        context.hide();
        return;
      }
492

Mark Otto's avatar
grunt    
Mark Otto committed
493
494
      context._timeout = setTimeout(function () {
        if (context._hoverState === HoverState.OUT) {
495
496
          context.hide();
        }
Mark Otto's avatar
grunt    
Mark Otto committed
497
498
      }, context.config.delay.hide);
    };
499

Mark Otto's avatar
grunt    
Mark Otto committed
500
501
502
503
    Tooltip.prototype._isWithActiveTrigger = function _isWithActiveTrigger() {
      for (var trigger in this._activeTrigger) {
        if (this._activeTrigger[trigger]) {
          return true;
504
505
506
        }
      }

Mark Otto's avatar
grunt    
Mark Otto committed
507
508
509
510
511
      return false;
    };

    Tooltip.prototype._getConfig = function _getConfig(config) {
      config = $.extend({}, this.constructor.Default, $(this.element).data(), config);
fat's avatar
fat committed
512

Mark Otto's avatar
grunt    
Mark Otto committed
513
514
515
516
517
      if (config.delay && typeof config.delay === 'number') {
        config.delay = {
          show: config.delay,
          hide: config.delay
        };
518
      }
Mark Otto's avatar
grunt    
Mark Otto committed
519
520
521
522
523
524
525
526
527
528
529
530
531

      Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);

      return config;
    };

    Tooltip.prototype._getDelegateConfig = function _getDelegateConfig() {
      var config = {};

      if (this.config) {
        for (var key in this.config) {
          if (this.constructor.Default[key] !== this.config[key]) {
            config[key] = this.config[key];
532
533
534
          }
        }
      }
Jacob Thornton's avatar
Jacob Thornton committed
535

Mark Otto's avatar
grunt    
Mark Otto committed
536
537
      return config;
    };
Jacob Thornton's avatar
Jacob Thornton committed
538

Mark Otto's avatar
grunt    
Mark Otto committed
539
    // static
Jacob Thornton's avatar
Jacob Thornton committed
540

Mark Otto's avatar
grunt    
Mark Otto committed
541
542
543
    Tooltip._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
Mark Otto's avatar
grunt    
Mark Otto committed
544
        var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config;
545

Mark Otto's avatar
grunt    
Mark Otto committed
546
        if (!data && /dispose|hide/.test(config)) {
Mark Otto's avatar
grunt    
Mark Otto committed
547
548
          return;
        }
549

Mark Otto's avatar
grunt    
Mark Otto committed
550
551
552
553
554
555
556
557
        if (!data) {
          data = new Tooltip(this, _config);
          $(this).data(DATA_KEY, data);
        }

        if (typeof config === 'string') {
          if (data[config] === undefined) {
            throw new Error('No method named "' + config + '"');
Jacob Thornton's avatar
Jacob Thornton committed
558
          }
Mark Otto's avatar
grunt    
Mark Otto committed
559
560
561
562
563
564
          data[config]();
        }
      });
    };

    _createClass(Tooltip, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
565
566
      key: 'VERSION',
      get: function get() {
567
568
569
570
        return VERSION;
      }
    }, {
      key: 'Default',
Jacob Thornton's avatar
Jacob Thornton committed
571
      get: function get() {
572
573
        return Default;
      }
fat's avatar
fat committed
574
575
    }, {
      key: 'NAME',
Jacob Thornton's avatar
Jacob Thornton committed
576
      get: function get() {
fat's avatar
fat committed
577
578
579
580
        return NAME;
      }
    }, {
      key: 'DATA_KEY',
Jacob Thornton's avatar
Jacob Thornton committed
581
      get: function get() {
fat's avatar
fat committed
582
583
584
585
        return DATA_KEY;
      }
    }, {
      key: 'Event',
Jacob Thornton's avatar
Jacob Thornton committed
586
      get: function get() {
fat's avatar
fat committed
587
588
        return Event;
      }
fat's avatar
fat committed
589
590
    }, {
      key: 'EVENT_KEY',
Jacob Thornton's avatar
Jacob Thornton committed
591
      get: function get() {
fat's avatar
fat committed
592
593
        return EVENT_KEY;
      }
fat's avatar
fat committed
594
595
    }, {
      key: 'DefaultType',
Jacob Thornton's avatar
Jacob Thornton committed
596
      get: function get() {
fat's avatar
fat committed
597
598
        return DefaultType;
      }
599
600
601
    }]);

    return Tooltip;
Mark Otto's avatar
grunt    
Mark Otto committed
602
603
604
605
606
607
608
  }();

  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */
609
610
611
612
613
614
615
616
617

  $.fn[NAME] = Tooltip._jQueryInterface;
  $.fn[NAME].Constructor = Tooltip;
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Tooltip._jQueryInterface;
  };

  return Tooltip;
Mark Otto's avatar
grunt    
Mark Otto committed
618
}(jQuery); /* global Tether */
Jacob Thornton's avatar
Jacob Thornton committed
619
//# sourceMappingURL=tooltip.js.map