bootstrap.js 94.2 KB
Newer Older
Jacob Thornton's avatar
Jacob Thornton committed
2001

Mark Otto's avatar
grunt    
Mark Otto committed
2002
2003
2004
    Modal.prototype._resetScrollbar = function _resetScrollbar() {
      document.body.style.paddingRight = this._originalBodyPadding;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2005

Mark Otto's avatar
grunt    
Mark Otto committed
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
    Modal.prototype._getScrollbarWidth = function _getScrollbarWidth() {
      // thx d.walsh
      var scrollDiv = document.createElement('div');
      scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
      document.body.appendChild(scrollDiv);
      var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
      document.body.removeChild(scrollDiv);
      return scrollbarWidth;
    };

    // static

    Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
        var _config = $.extend({}, Modal.Default, $(this).data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config);

        if (!data) {
          data = new Modal(this, _config);
          $(this).data(DATA_KEY, data);
Jacob Thornton's avatar
Jacob Thornton committed
2026
2027
        }

Mark Otto's avatar
grunt    
Mark Otto committed
2028
2029
2030
        if (typeof config === 'string') {
          if (data[config] === undefined) {
            throw new Error('No method named "' + config + '"');
Jacob Thornton's avatar
Jacob Thornton committed
2031
          }
Mark Otto's avatar
grunt    
Mark Otto committed
2032
2033
2034
2035
2036
2037
2038
2039
          data[config](relatedTarget);
        } else if (_config.show) {
          data.show(relatedTarget);
        }
      });
    };

    _createClass(Modal, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }, {
      key: 'Default',
      get: function get() {
        return Default;
      }
    }]);

    return Modal;
Mark Otto's avatar
grunt    
Mark Otto committed
2052
2053
2054
2055
2056
2057
2058
  }();

  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
2059
2060
2061
2062

  $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
    var _this13 = this;

Mark Otto's avatar
grunt    
Mark Otto committed
2063
    var target = void 0;
Jacob Thornton's avatar
Jacob Thornton committed
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
    var selector = Util.getSelectorFromElement(this);

    if (selector) {
      target = $(selector)[0];
    }

    var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data());

    if (this.tagName === 'A') {
      event.preventDefault();
    }

    var $target = $(target).one(Event.SHOW, function (showEvent) {
      if (showEvent.isDefaultPrevented()) {
        // only register focus restorer if modal will actually get shown
        return;
      }

      $target.one(Event.HIDDEN, function () {
        if ($(_this13).is(':visible')) {
          _this13.focus();
        }
      });
    });

    Modal._jQueryInterface.call($(target), config, this);
  });

  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */

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

  return Modal;
Mark Otto's avatar
grunt    
Mark Otto committed
2106
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
2107
2108
2109

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
2110
 * Bootstrap (v4.0.0-alpha.4): scrollspy.js
Jacob Thornton's avatar
Jacob Thornton committed
2111
2112
2113
2114
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
grunt    
Mark Otto committed
2115
var ScrollSpy = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
2116
2117
2118
2119
2120
2121
2122
2123

  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'scrollspy';
Mark Otto's avatar
Mark Otto committed
2124
  var VERSION = '4.0.0-alpha.4';
Jacob Thornton's avatar
Jacob Thornton committed
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
  var DATA_KEY = 'bs.scrollspy';
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var JQUERY_NO_CONFLICT = $.fn[NAME];

  var Default = {
    offset: 10,
    method: 'auto',
    target: ''
  };

  var DefaultType = {
    offset: 'number',
    method: 'string',
    target: '(string|element)'
  };

  var Event = {
    ACTIVATE: 'activate' + EVENT_KEY,
    SCROLL: 'scroll' + EVENT_KEY,
    LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY
  };

  var ClassName = {
Jacob Thornton's avatar
Jacob Thornton committed
2149
    DROPDOWN_ITEM: 'dropdown-item',
Jacob Thornton's avatar
Jacob Thornton committed
2150
    DROPDOWN_MENU: 'dropdown-menu',
Jacob Thornton's avatar
Jacob Thornton committed
2151
2152
    NAV_LINK: 'nav-link',
    NAV: 'nav',
Jacob Thornton's avatar
Jacob Thornton committed
2153
2154
2155
2156
2157
2158
    ACTIVE: 'active'
  };

  var Selector = {
    DATA_SPY: '[data-spy="scroll"]',
    ACTIVE: '.active',
Jacob Thornton's avatar
Jacob Thornton committed
2159
    LIST_ITEM: '.list-item',
Jacob Thornton's avatar
Jacob Thornton committed
2160
2161
    LI: 'li',
    LI_DROPDOWN: 'li.dropdown',
Jacob Thornton's avatar
Jacob Thornton committed
2162
2163
2164
2165
    NAV_LINKS: '.nav-link',
    DROPDOWN: '.dropdown',
    DROPDOWN_ITEMS: '.dropdown-item',
    DROPDOWN_TOGGLE: '.dropdown-toggle'
Jacob Thornton's avatar
Jacob Thornton committed
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
  };

  var OffsetMethod = {
    OFFSET: 'offset',
    POSITION: 'position'
  };

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

Mark Otto's avatar
grunt    
Mark Otto committed
2179
  var ScrollSpy = function () {
Jacob Thornton's avatar
Jacob Thornton committed
2180
2181
2182
2183
2184
2185
    function ScrollSpy(element, config) {
      _classCallCheck(this, ScrollSpy);

      this._element = element;
      this._scrollElement = element.tagName === 'BODY' ? window : element;
      this._config = this._getConfig(config);
Jacob Thornton's avatar
Jacob Thornton committed
2186
      this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS);
Jacob Thornton's avatar
Jacob Thornton committed
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
      this._offsets = [];
      this._targets = [];
      this._activeTarget = null;
      this._scrollHeight = 0;

      $(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this));

      this.refresh();
      this._process();
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
2200
    // public
Jacob Thornton's avatar
Jacob Thornton committed
2201

Mark Otto's avatar
grunt    
Mark Otto committed
2202
2203
    ScrollSpy.prototype.refresh = function refresh() {
      var _this14 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2204

Mark Otto's avatar
grunt    
Mark Otto committed
2205
      var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET;
Jacob Thornton's avatar
Jacob Thornton committed
2206

Mark Otto's avatar
grunt    
Mark Otto committed
2207
      var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
Jacob Thornton's avatar
Jacob Thornton committed
2208

Mark Otto's avatar
grunt    
Mark Otto committed
2209
      var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
Jacob Thornton's avatar
Jacob Thornton committed
2210

Mark Otto's avatar
grunt    
Mark Otto committed
2211
2212
      this._offsets = [];
      this._targets = [];
Jacob Thornton's avatar
Jacob Thornton committed
2213

Mark Otto's avatar
grunt    
Mark Otto committed
2214
      this._scrollHeight = this._getScrollHeight();
Jacob Thornton's avatar
Jacob Thornton committed
2215

Mark Otto's avatar
grunt    
Mark Otto committed
2216
      var targets = $.makeArray($(this._selector));
Jacob Thornton's avatar
Jacob Thornton committed
2217

Mark Otto's avatar
grunt    
Mark Otto committed
2218
2219
2220
      targets.map(function (element) {
        var target = void 0;
        var targetSelector = Util.getSelectorFromElement(element);
Jacob Thornton's avatar
Jacob Thornton committed
2221

Mark Otto's avatar
grunt    
Mark Otto committed
2222
2223
2224
        if (targetSelector) {
          target = $(targetSelector)[0];
        }
Jacob Thornton's avatar
Jacob Thornton committed
2225

Mark Otto's avatar
grunt    
Mark Otto committed
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
        if (target && (target.offsetWidth || target.offsetHeight)) {
          // todo (fat): remove sketch reliance on jQuery position/offset
          return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
        }
        return null;
      }).filter(function (item) {
        return item;
      }).sort(function (a, b) {
        return a[0] - b[0];
      }).forEach(function (item) {
        _this14._offsets.push(item[0]);
        _this14._targets.push(item[1]);
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
2240

Mark Otto's avatar
grunt    
Mark Otto committed
2241
2242
2243
    ScrollSpy.prototype.dispose = function dispose() {
      $.removeData(this._element, DATA_KEY);
      $(this._scrollElement).off(EVENT_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
2244

Mark Otto's avatar
grunt    
Mark Otto committed
2245
2246
2247
2248
2249
2250
2251
2252
2253
      this._element = null;
      this._scrollElement = null;
      this._config = null;
      this._selector = null;
      this._offsets = null;
      this._targets = null;
      this._activeTarget = null;
      this._scrollHeight = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2254

Mark Otto's avatar
grunt    
Mark Otto committed
2255
    // private
Jacob Thornton's avatar
Jacob Thornton committed
2256

Mark Otto's avatar
grunt    
Mark Otto committed
2257
2258
    ScrollSpy.prototype._getConfig = function _getConfig(config) {
      config = $.extend({}, Default, config);
Jacob Thornton's avatar
Jacob Thornton committed
2259

Mark Otto's avatar
grunt    
Mark Otto committed
2260
2261
2262
2263
2264
2265
2266
      if (typeof config.target !== 'string') {
        var id = $(config.target).attr('id');
        if (!id) {
          id = Util.getUID(NAME);
          $(config.target).attr('id', id);
        }
        config.target = '#' + id;
Jacob Thornton's avatar
Jacob Thornton committed
2267
2268
      }

Mark Otto's avatar
grunt    
Mark Otto committed
2269
2270
2271
2272
      Util.typeCheckConfig(NAME, config, DefaultType);

      return config;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2273

Mark Otto's avatar
grunt    
Mark Otto committed
2274
2275
2276
    ScrollSpy.prototype._getScrollTop = function _getScrollTop() {
      return this._scrollElement === window ? this._scrollElement.scrollY : this._scrollElement.scrollTop;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2277

Mark Otto's avatar
grunt    
Mark Otto committed
2278
2279
2280
    ScrollSpy.prototype._getScrollHeight = function _getScrollHeight() {
      return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
    };
Jacob Thornton's avatar
Jacob Thornton committed
2281

Mark Otto's avatar
grunt    
Mark Otto committed
2282
2283
2284
2285
    ScrollSpy.prototype._process = function _process() {
      var scrollTop = this._getScrollTop() + this._config.offset;
      var scrollHeight = this._getScrollHeight();
      var maxScroll = this._config.offset + scrollHeight - this._scrollElement.offsetHeight;
Jacob Thornton's avatar
Jacob Thornton committed
2286

Mark Otto's avatar
grunt    
Mark Otto committed
2287
2288
2289
      if (this._scrollHeight !== scrollHeight) {
        this.refresh();
      }
Jacob Thornton's avatar
Jacob Thornton committed
2290

Mark Otto's avatar
grunt    
Mark Otto committed
2291
2292
2293
2294
2295
      if (scrollTop >= maxScroll) {
        var target = this._targets[this._targets.length - 1];

        if (this._activeTarget !== target) {
          this._activate(target);
Jacob Thornton's avatar
Jacob Thornton committed
2296
2297
        }
      }
Jacob Thornton's avatar
Jacob Thornton committed
2298

Mark Otto's avatar
grunt    
Mark Otto committed
2299
2300
      if (this._activeTarget && scrollTop < this._offsets[0]) {
        this._activeTarget = null;
Jacob Thornton's avatar
Jacob Thornton committed
2301
        this._clear();
Mark Otto's avatar
grunt    
Mark Otto committed
2302
2303
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2304

Mark Otto's avatar
grunt    
Mark Otto committed
2305
2306
      for (var i = this._offsets.length; i--;) {
        var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (this._offsets[i + 1] === undefined || scrollTop < this._offsets[i + 1]);
Jacob Thornton's avatar
Jacob Thornton committed
2307

Mark Otto's avatar
grunt    
Mark Otto committed
2308
2309
        if (isActiveTarget) {
          this._activate(this._targets[i]);
Jacob Thornton's avatar
Jacob Thornton committed
2310
        }
Jacob Thornton's avatar
Jacob Thornton committed
2311
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
    };

    ScrollSpy.prototype._activate = function _activate(target) {
      this._activeTarget = target;

      this._clear();

      var queries = this._selector.split(',');
      queries = queries.map(function (selector) {
        return selector + '[data-target="' + target + '"],' + (selector + '[href="' + target + '"]');
      });

      var $link = $(queries.join(','));

      if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
        $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
        $link.addClass(ClassName.ACTIVE);
      } else {
        // todo (fat) this is kinda sus...
        // recursively add actives to tested nav-links
        $link.parents(Selector.LI).find(Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
2333
2334
      }

Mark Otto's avatar
grunt    
Mark Otto committed
2335
2336
2337
2338
      $(this._scrollElement).trigger(Event.ACTIVATE, {
        relatedTarget: target
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
2339

Mark Otto's avatar
grunt    
Mark Otto committed
2340
2341
2342
    ScrollSpy.prototype._clear = function _clear() {
      $(this._selector).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
    };
Jacob Thornton's avatar
Jacob Thornton committed
2343

Mark Otto's avatar
grunt    
Mark Otto committed
2344
    // static
Jacob Thornton's avatar
Jacob Thornton committed
2345

Mark Otto's avatar
grunt    
Mark Otto committed
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
    ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
        var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config || null;

        if (!data) {
          data = new ScrollSpy(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
2359
          }
Mark Otto's avatar
grunt    
Mark Otto committed
2360
2361
2362
2363
2364
2365
          data[config]();
        }
      });
    };

    _createClass(ScrollSpy, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }, {
      key: 'Default',
      get: function get() {
        return Default;
      }
    }]);

    return ScrollSpy;
Mark Otto's avatar
grunt    
Mark Otto committed
2378
2379
2380
2381
2382
2383
2384
  }();

  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408

  $(window).on(Event.LOAD_DATA_API, function () {
    var scrollSpys = $.makeArray($(Selector.DATA_SPY));

    for (var i = scrollSpys.length; i--;) {
      var $spy = $(scrollSpys[i]);
      ScrollSpy._jQueryInterface.call($spy, $spy.data());
    }
  });

  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */

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

  return ScrollSpy;
Mark Otto's avatar
grunt    
Mark Otto committed
2409
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
2410
2411
2412

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
2413
 * Bootstrap (v4.0.0-alpha.4): tab.js
Jacob Thornton's avatar
Jacob Thornton committed
2414
2415
2416
2417
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
grunt    
Mark Otto committed
2418
var Tab = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
2419
2420
2421
2422
2423
2424
2425
2426

  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'tab';
Mark Otto's avatar
Mark Otto committed
2427
  var VERSION = '4.0.0-alpha.4';
Jacob Thornton's avatar
Jacob Thornton committed
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
  var DATA_KEY = 'bs.tab';
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 150;

  var Event = {
    HIDE: 'hide' + EVENT_KEY,
    HIDDEN: 'hidden' + EVENT_KEY,
    SHOW: 'show' + EVENT_KEY,
    SHOWN: 'shown' + EVENT_KEY,
    CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
  };

  var ClassName = {
    DROPDOWN_MENU: 'dropdown-menu',
    ACTIVE: 'active',
    FADE: 'fade',
    IN: 'in'
  };

  var Selector = {
    A: 'a',
    LI: 'li',
Jacob Thornton's avatar
Jacob Thornton committed
2452
    DROPDOWN: '.dropdown',
Jacob Thornton's avatar
Jacob Thornton committed
2453
    UL: 'ul:not(.dropdown-menu)',
Jacob Thornton's avatar
Jacob Thornton committed
2454
    FADE_CHILD: '> .nav-item .fade, > .fade',
Jacob Thornton's avatar
Jacob Thornton committed
2455
    ACTIVE: '.active',
Jacob Thornton's avatar
Jacob Thornton committed
2456
    ACTIVE_CHILD: '> .nav-item > .active, > .active',
Jacob Thornton's avatar
Jacob Thornton committed
2457
    DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"]',
Jacob Thornton's avatar
Jacob Thornton committed
2458
2459
    DROPDOWN_TOGGLE: '.dropdown-toggle',
    DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
Jacob Thornton's avatar
Jacob Thornton committed
2460
2461
2462
2463
2464
2465
2466
2467
  };

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

Mark Otto's avatar
grunt    
Mark Otto committed
2468
  var Tab = function () {
Jacob Thornton's avatar
Jacob Thornton committed
2469
2470
2471
2472
    function Tab(element) {
      _classCallCheck(this, Tab);

      this._element = element;
Jacob Thornton's avatar
Jacob Thornton committed
2473
    }
Jacob Thornton's avatar
Jacob Thornton committed
2474
2475
2476

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
2477
    // public
Jacob Thornton's avatar
Jacob Thornton committed
2478

Mark Otto's avatar
grunt    
Mark Otto committed
2479
2480
    Tab.prototype.show = function show() {
      var _this15 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2481

Mark Otto's avatar
grunt    
Mark Otto committed
2482
2483
2484
      if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE)) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2485

Mark Otto's avatar
grunt    
Mark Otto committed
2486
2487
2488
2489
      var target = void 0;
      var previous = void 0;
      var ulElement = $(this._element).closest(Selector.UL)[0];
      var selector = Util.getSelectorFromElement(this._element);
Jacob Thornton's avatar
Jacob Thornton committed
2490

Mark Otto's avatar
grunt    
Mark Otto committed
2491
2492
2493
2494
      if (ulElement) {
        previous = $.makeArray($(ulElement).find(Selector.ACTIVE));
        previous = previous[previous.length - 1];
      }
Jacob Thornton's avatar
Jacob Thornton committed
2495

Mark Otto's avatar
grunt    
Mark Otto committed
2496
2497
2498
      var hideEvent = $.Event(Event.HIDE, {
        relatedTarget: this._element
      });
Jacob Thornton's avatar
Jacob Thornton committed
2499

Mark Otto's avatar
grunt    
Mark Otto committed
2500
2501
2502
      var showEvent = $.Event(Event.SHOW, {
        relatedTarget: previous
      });
Jacob Thornton's avatar
Jacob Thornton committed
2503

Mark Otto's avatar
grunt    
Mark Otto committed
2504
2505
2506
      if (previous) {
        $(previous).trigger(hideEvent);
      }
Jacob Thornton's avatar
Jacob Thornton committed
2507

Mark Otto's avatar
grunt    
Mark Otto committed
2508
      $(this._element).trigger(showEvent);
Jacob Thornton's avatar
Jacob Thornton committed
2509

Mark Otto's avatar
grunt    
Mark Otto committed
2510
2511
2512
      if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2513

Mark Otto's avatar
grunt    
Mark Otto committed
2514
2515
2516
      if (selector) {
        target = $(selector)[0];
      }
Jacob Thornton's avatar
Jacob Thornton committed
2517

Mark Otto's avatar
grunt    
Mark Otto committed
2518
      this._activate(this._element, ulElement);
Jacob Thornton's avatar
Jacob Thornton committed
2519

Mark Otto's avatar
grunt    
Mark Otto committed
2520
2521
2522
2523
      var complete = function complete() {
        var hiddenEvent = $.Event(Event.HIDDEN, {
          relatedTarget: _this15._element
        });
Jacob Thornton's avatar
Jacob Thornton committed
2524

Mark Otto's avatar
grunt    
Mark Otto committed
2525
2526
2527
        var shownEvent = $.Event(Event.SHOWN, {
          relatedTarget: previous
        });
Jacob Thornton's avatar
Jacob Thornton committed
2528

Mark Otto's avatar
grunt    
Mark Otto committed
2529
2530
2531
        $(previous).trigger(hiddenEvent);
        $(_this15._element).trigger(shownEvent);
      };
Jacob Thornton's avatar
Jacob Thornton committed
2532

Mark Otto's avatar
grunt    
Mark Otto committed
2533
2534
2535
2536
      if (target) {
        this._activate(target, target.parentNode, complete);
      } else {
        complete();
Jacob Thornton's avatar
Jacob Thornton committed
2537
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2538
    };
Jacob Thornton's avatar
Jacob Thornton committed
2539

Mark Otto's avatar
grunt    
Mark Otto committed
2540
2541
2542
2543
    Tab.prototype.dispose = function dispose() {
      $.removeClass(this._element, DATA_KEY);
      this._element = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2544

Mark Otto's avatar
grunt    
Mark Otto committed
2545
    // private
Jacob Thornton's avatar
Jacob Thornton committed
2546

Mark Otto's avatar
grunt    
Mark Otto committed
2547
2548
2549
    Tab.prototype._activate = function _activate(element, container, callback) {
      var active = $(container).find(Selector.ACTIVE_CHILD)[0];
      var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0]));
Jacob Thornton's avatar
Jacob Thornton committed
2550

Mark Otto's avatar
grunt    
Mark Otto committed
2551
      var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback);
Jacob Thornton's avatar
Jacob Thornton committed
2552

Mark Otto's avatar
grunt    
Mark Otto committed
2553
2554
2555
2556
      if (active && isTransitioning) {
        $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
      } else {
        complete();
Jacob Thornton's avatar
Jacob Thornton committed
2557
2558
      }

Mark Otto's avatar
grunt    
Mark Otto committed
2559
2560
2561
2562
      if (active) {
        $(active).removeClass(ClassName.IN);
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2563

Mark Otto's avatar
grunt    
Mark Otto committed
2564
2565
2566
    Tab.prototype._transitionComplete = function _transitionComplete(element, active, isTransitioning, callback) {
      if (active) {
        $(active).removeClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
2567

Mark Otto's avatar
grunt    
Mark Otto committed
2568
2569
2570
2571
        var dropdownChild = $(active).find(Selector.DROPDOWN_ACTIVE_CHILD)[0];

        if (dropdownChild) {
          $(dropdownChild).removeClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
2572
2573
        }

Mark Otto's avatar
grunt    
Mark Otto committed
2574
2575
        active.setAttribute('aria-expanded', false);
      }
Jacob Thornton's avatar
Jacob Thornton committed
2576

Mark Otto's avatar
grunt    
Mark Otto committed
2577
2578
      $(element).addClass(ClassName.ACTIVE);
      element.setAttribute('aria-expanded', true);
Jacob Thornton's avatar
Jacob Thornton committed
2579

Mark Otto's avatar
grunt    
Mark Otto committed
2580
2581
2582
2583
2584
2585
      if (isTransitioning) {
        Util.reflow(element);
        $(element).addClass(ClassName.IN);
      } else {
        $(element).removeClass(ClassName.FADE);
      }
Jacob Thornton's avatar
Jacob Thornton committed
2586

Mark Otto's avatar
grunt    
Mark Otto committed
2587
      if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
Jacob Thornton's avatar
Jacob Thornton committed
2588

Mark Otto's avatar
grunt    
Mark Otto committed
2589
2590
2591
        var dropdownElement = $(element).closest(Selector.DROPDOWN)[0];
        if (dropdownElement) {
          $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
2592
2593
        }

Mark Otto's avatar
grunt    
Mark Otto committed
2594
2595
2596
2597
2598
        element.setAttribute('aria-expanded', true);
      }

      if (callback) {
        callback();
Jacob Thornton's avatar
Jacob Thornton committed
2599
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2600
    };
Jacob Thornton's avatar
Jacob Thornton committed
2601

Mark Otto's avatar
grunt    
Mark Otto committed
2602
    // static
Jacob Thornton's avatar
Jacob Thornton committed
2603

Mark Otto's avatar
grunt    
Mark Otto committed
2604
2605
2606
2607
    Tab._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var $this = $(this);
        var data = $this.data(DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
2608

Mark Otto's avatar
grunt    
Mark Otto committed
2609
2610
2611
2612
        if (!data) {
          data = data = new Tab(this);
          $this.data(DATA_KEY, data);
        }
Jacob Thornton's avatar
Jacob Thornton committed
2613

Mark Otto's avatar
grunt    
Mark Otto committed
2614
2615
2616
        if (typeof config === 'string') {
          if (data[config] === undefined) {
            throw new Error('No method named "' + config + '"');
Jacob Thornton's avatar
Jacob Thornton committed
2617
          }
Mark Otto's avatar
grunt    
Mark Otto committed
2618
2619
2620
2621
2622
2623
          data[config]();
        }
      });
    };

    _createClass(Tab, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
2624
2625
2626
2627
2628
2629
2630
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }]);

    return Tab;
Mark Otto's avatar
grunt    
Mark Otto committed
2631
2632
2633
2634
2635
2636
2637
  }();

  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657

  $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
    event.preventDefault();
    Tab._jQueryInterface.call($(this), 'show');
  });

  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */

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

  return Tab;
Mark Otto's avatar
grunt    
Mark Otto committed
2658
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
2659

XhmikosR's avatar
XhmikosR committed
2660
2661
/* global Tether */

Jacob Thornton's avatar
Jacob Thornton committed
2662
2663
/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
2664
 * Bootstrap (v4.0.0-alpha.4): tooltip.js
Jacob Thornton's avatar
Jacob Thornton committed
2665
2666
2667
2668
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
grunt    
Mark Otto committed
2669
var Tooltip = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
2670

2671
2672
  /**
   * Check for Tether dependency
Mark Otto's avatar
grunt    
Mark Otto committed
2673
   * Tether - http://tether.io/
2674
   */
XhmikosR's avatar
XhmikosR committed
2675
  if (window.Tether === undefined) {
Mark Otto's avatar
grunt    
Mark Otto committed
2676
    throw new Error('Bootstrap tooltips require Tether (http://tether.io/)');
2677
2678
  }

Jacob Thornton's avatar
Jacob Thornton committed
2679
2680
2681
2682
2683
2684
2685
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'tooltip';
Mark Otto's avatar
Mark Otto committed
2686
  var VERSION = '4.0.0-alpha.4';
Jacob Thornton's avatar
Jacob Thornton committed
2687
2688
2689
2690
2691
2692
2693
2694
  var DATA_KEY = 'bs.tooltip';
  var EVENT_KEY = '.' + DATA_KEY;
  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
2695
    template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-inner"></div></div>',
Jacob Thornton's avatar
Jacob Thornton committed
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
    trigger: 'hover focus',
    title: '',
    delay: 0,
    html: false,
    selector: false,
    placement: 'top',
    offset: '0 0',
    constraints: []
  };

  var DefaultType = {
    animation: 'boolean',
    template: 'string',
XhmikosR's avatar
XhmikosR committed
2709
    title: '(string|element|function)',
Jacob Thornton's avatar
Jacob Thornton committed
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
    trigger: 'string',
    delay: '(number|object)',
    html: 'boolean',
    selector: '(string|boolean)',
    placement: '(string|function)',
    offset: 'string',
    constraints: 'array'
  };

  var AttachmentMap = {
    TOP: 'bottom center',
    RIGHT: 'middle left',
    BOTTOM: 'top center',
    LEFT: 'middle right'
  };

  var HoverState = {
    IN: 'in',
    OUT: 'out'
  };

  var Event = {
    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
  };

  var ClassName = {
    FADE: 'fade',
    IN: 'in'
  };

  var Selector = {
    TOOLTIP: '.tooltip',
    TOOLTIP_INNER: '.tooltip-inner'
  };

  var TetherClass = {
    element: false,
    enabled: false
  };

  var Trigger = {
    HOVER: 'hover',
    FOCUS: 'focus',
    CLICK: 'click',
    MANUAL: 'manual'
  };

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

Mark Otto's avatar
grunt    
Mark Otto committed
2772
  var Tooltip = function () {
Jacob Thornton's avatar
Jacob Thornton committed
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
    function Tooltip(element, config) {
      _classCallCheck(this, Tooltip);

      // private
      this._isEnabled = true;
      this._timeout = 0;
      this._hoverState = '';
      this._activeTrigger = {};
      this._tether = null;

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

      this._setListeners();
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
2793
    // public
Jacob Thornton's avatar
Jacob Thornton committed
2794

Mark Otto's avatar
grunt    
Mark Otto committed
2795
2796
2797
    Tooltip.prototype.enable = function enable() {
      this._isEnabled = true;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2798

Mark Otto's avatar
grunt    
Mark Otto committed
2799
2800
2801
    Tooltip.prototype.disable = function disable() {
      this._isEnabled = false;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2802

Mark Otto's avatar
grunt    
Mark Otto committed
2803
2804
2805
2806
2807
2808
2809
2810
    Tooltip.prototype.toggleEnabled = function toggleEnabled() {
      this._isEnabled = !this._isEnabled;
    };

    Tooltip.prototype.toggle = function toggle(event) {
      if (event) {
        var dataKey = this.constructor.DATA_KEY;
        var context = $(event.currentTarget).data(dataKey);
Jacob Thornton's avatar
Jacob Thornton committed
2811

Mark Otto's avatar
grunt    
Mark Otto committed
2812
2813
2814
2815
        if (!context) {
          context = new this.constructor(event.currentTarget, this._getDelegateConfig());
          $(event.currentTarget).data(dataKey, context);
        }
Jacob Thornton's avatar
Jacob Thornton committed
2816

Mark Otto's avatar
grunt    
Mark Otto committed
2817
        context._activeTrigger.click = !context._activeTrigger.click;
Jacob Thornton's avatar
Jacob Thornton committed
2818

Mark Otto's avatar
grunt    
Mark Otto committed
2819
2820
2821
2822
2823
2824
        if (context._isWithActiveTrigger()) {
          context._enter(null, context);
        } else {
          context._leave(null, context);
        }
      } else {
Jacob Thornton's avatar
Jacob Thornton committed
2825

Mark Otto's avatar
grunt    
Mark Otto committed
2826
2827
2828
        if ($(this.getTipElement()).hasClass(ClassName.IN)) {
          this._leave(null, this);
          return;
Jacob Thornton's avatar
Jacob Thornton committed
2829
2830
        }

Mark Otto's avatar
grunt    
Mark Otto committed
2831
2832
2833
        this._enter(null, this);
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2834

Mark Otto's avatar
grunt    
Mark Otto committed
2835
2836
    Tooltip.prototype.dispose = function dispose() {
      clearTimeout(this._timeout);
Jacob Thornton's avatar
Jacob Thornton committed
2837

Mark Otto's avatar
grunt    
Mark Otto committed
2838
      this.cleanupTether();
Jacob Thornton's avatar
Jacob Thornton committed
2839

Mark Otto's avatar
grunt    
Mark Otto committed
2840
      $.removeData(this.element, this.constructor.DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
2841

Mark Otto's avatar
grunt    
Mark Otto committed
2842
      $(this.element).off(this.constructor.EVENT_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
2843

Mark Otto's avatar
grunt    
Mark Otto committed
2844
2845
      if (this.tip) {
        $(this.tip).remove();
Jacob Thornton's avatar
Jacob Thornton committed
2846
2847
      }

Mark Otto's avatar
grunt    
Mark Otto committed
2848
2849
2850
2851
2852
      this._isEnabled = null;
      this._timeout = null;
      this._hoverState = null;
      this._activeTrigger = null;
      this._tether = null;
Jacob Thornton's avatar
Jacob Thornton committed
2853

Mark Otto's avatar
grunt    
Mark Otto committed
2854
2855
2856
2857
      this.element = null;
      this.config = null;
      this.tip = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2858

Mark Otto's avatar
grunt    
Mark Otto committed
2859
2860
    Tooltip.prototype.show = function show() {
      var _this16 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2861

Mark Otto's avatar
grunt    
Mark Otto committed
2862
      var showEvent = $.Event(this.constructor.Event.SHOW);
Jacob Thornton's avatar
Jacob Thornton committed
2863

Mark Otto's avatar
grunt    
Mark Otto committed
2864
2865
      if (this.isWithContent() && this._isEnabled) {
        $(this.element).trigger(showEvent);
Jacob Thornton's avatar
Jacob Thornton committed
2866

Mark Otto's avatar
grunt    
Mark Otto committed
2867
        var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
Jacob Thornton's avatar
Jacob Thornton committed
2868

Mark Otto's avatar
grunt    
Mark Otto committed
2869
2870
2871
        if (showEvent.isDefaultPrevented() || !isInTheDom) {
          return;
        }
Jacob Thornton's avatar
Jacob Thornton committed
2872

Mark Otto's avatar
grunt    
Mark Otto committed
2873
2874
        var tip = this.getTipElement();
        var tipId = Util.getUID(this.constructor.NAME);
Jacob Thornton's avatar
Jacob Thornton committed
2875

Mark Otto's avatar
grunt    
Mark Otto committed
2876
2877
        tip.setAttribute('id', tipId);
        this.element.setAttribute('aria-describedby', tipId);
Jacob Thornton's avatar
Jacob Thornton committed
2878

Mark Otto's avatar
grunt    
Mark Otto committed
2879
        this.setContent();
Jacob Thornton's avatar
Jacob Thornton committed
2880

Mark Otto's avatar
grunt    
Mark Otto committed
2881
2882
2883
        if (this.config.animation) {
          $(tip).addClass(ClassName.FADE);
        }
Jacob Thornton's avatar
Jacob Thornton committed
2884

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

Mark Otto's avatar
grunt    
Mark Otto committed
2887
        var attachment = this._getAttachment(placement);
Jacob Thornton's avatar
Jacob Thornton committed
2888

Mark Otto's avatar
grunt    
Mark Otto committed
2889
        $(tip).data(this.constructor.DATA_KEY, this).appendTo(document.body);
Jacob Thornton's avatar
Jacob Thornton committed
2890

Mark Otto's avatar
grunt    
Mark Otto committed
2891
        $(this.element).trigger(this.constructor.Event.INSERTED);
Jacob Thornton's avatar
Jacob Thornton committed
2892

Mark Otto's avatar
grunt    
Mark Otto committed
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
        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
        });
Jacob Thornton's avatar
Jacob Thornton committed
2903

Mark Otto's avatar
grunt    
Mark Otto committed
2904
2905
        Util.reflow(tip);
        this._tether.position();
Jacob Thornton's avatar
Jacob Thornton committed
2906

Mark Otto's avatar
grunt    
Mark Otto committed
2907
        $(tip).addClass(ClassName.IN);
Jacob Thornton's avatar
Jacob Thornton committed
2908
2909

        var complete = function complete() {
Mark Otto's avatar
grunt    
Mark Otto committed
2910
2911
          var prevHoverState = _this16._hoverState;
          _this16._hoverState = null;
Jacob Thornton's avatar
Jacob Thornton committed
2912

Mark Otto's avatar
grunt    
Mark Otto committed
2913
          $(_this16.element).trigger(_this16.constructor.Event.SHOWN);
Jacob Thornton's avatar
Jacob Thornton committed
2914

Mark Otto's avatar
grunt    
Mark Otto committed
2915
2916
          if (prevHoverState === HoverState.OUT) {
            _this16._leave(null, _this16);
Jacob Thornton's avatar
Jacob Thornton committed
2917
          }
Jacob Thornton's avatar
Jacob Thornton committed
2918
2919
        };

Mark Otto's avatar
grunt    
Mark Otto committed
2920
2921
        if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
          $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
Jacob Thornton's avatar
Jacob Thornton committed
2922
          return;
Jacob Thornton's avatar
Jacob Thornton committed
2923
2924
        }

Mark Otto's avatar
grunt    
Mark Otto committed
2925
2926
2927
        complete();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2928

Mark Otto's avatar
grunt    
Mark Otto committed
2929
2930
    Tooltip.prototype.hide = function hide(callback) {
      var _this17 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2931

Mark Otto's avatar
grunt    
Mark Otto committed
2932
2933
2934
2935
2936
      var tip = this.getTipElement();
      var hideEvent = $.Event(this.constructor.Event.HIDE);
      var complete = function complete() {
        if (_this17._hoverState !== HoverState.IN && tip.parentNode) {
          tip.parentNode.removeChild(tip);
Jacob Thornton's avatar
Jacob Thornton committed
2937
2938
        }

Mark Otto's avatar
grunt    
Mark Otto committed
2939
2940
2941
        _this17.element.removeAttribute('aria-describedby');
        $(_this17.element).trigger(_this17.constructor.Event.HIDDEN);
        _this17.cleanupTether();
Jacob Thornton's avatar
Jacob Thornton committed
2942

Mark Otto's avatar
grunt    
Mark Otto committed
2943
2944
2945
2946
        if (callback) {
          callback();
        }
      };
Jacob Thornton's avatar
Jacob Thornton committed
2947

Mark Otto's avatar
grunt    
Mark Otto committed
2948
2949
2950
2951
      $(this.element).trigger(hideEvent);

      if (hideEvent.isDefaultPrevented()) {
        return;
Jacob Thornton's avatar
Jacob Thornton committed
2952
2953
      }

Mark Otto's avatar
grunt    
Mark Otto committed
2954
      $(tip).removeClass(ClassName.IN);
Jacob Thornton's avatar
Jacob Thornton committed
2955

Mark Otto's avatar
grunt    
Mark Otto committed
2956
      if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
Jacob Thornton's avatar
Jacob Thornton committed
2957

Mark Otto's avatar
grunt    
Mark Otto committed
2958
2959
2960
        $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
      } else {
        complete();
Jacob Thornton's avatar
Jacob Thornton committed
2961
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992

      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());

      $tip.removeClass(ClassName.FADE).removeClass(ClassName.IN);

      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
2993
2994
          }
        } else {
Mark Otto's avatar
grunt    
Mark Otto committed
2995
          $element.text($(content).text());
XhmikosR's avatar
XhmikosR committed
2996
        }
Mark Otto's avatar
grunt    
Mark Otto committed
2997
2998
      } else {
        $element[html ? 'html' : 'text'](content);
XhmikosR's avatar
XhmikosR committed
2999
      }
Mark Otto's avatar
grunt    
Mark Otto committed
3000
    };
For faster browsing, not all history is shown. View entire blame