scrollspy.js 14.6 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
1
/*!
XhmikosR's avatar
XhmikosR committed
2
  * Bootstrap scrollspy.js v5.0.0-alpha3 (https://getbootstrap.com/)
XhmikosR's avatar
XhmikosR committed
3
  * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
XhmikosR's avatar
XhmikosR committed
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
XhmikosR's avatar
Dist    
XhmikosR committed
5
  */
Mark Otto's avatar
dist    
Mark Otto committed
6
(function (global, factory) {
XhmikosR's avatar
XhmikosR committed
7
8
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js')) :
  typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', './dom/selector-engine.js'], factory) :
XhmikosR's avatar
XhmikosR committed
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine));
XhmikosR's avatar
XhmikosR committed
10
}(this, (function (Data, EventHandler, Manipulator, SelectorEngine) { 'use strict';
Mark Otto's avatar
dist    
Mark Otto committed
11

XhmikosR's avatar
XhmikosR committed
12
13
14
15
16
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

  var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
  var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
  var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
  var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
Mark Otto's avatar
dist    
Mark Otto committed
18

XhmikosR's avatar
XhmikosR committed
19
20
  /**
   * --------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
21
   * Bootstrap (v5.0.0-alpha3): util/index.js
XhmikosR's avatar
XhmikosR committed
22
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
XhmikosR's avatar
XhmikosR committed
23
24
25
26
27
   * --------------------------------------------------------------------------
   */
  var MAX_UID = 1000000;

  var toType = function toType(obj) {
XhmikosR's avatar
XhmikosR committed
28
29
30
31
    if (obj === null || obj === undefined) {
      return "" + obj;
    }

XhmikosR's avatar
XhmikosR committed
32
33
34
35
36
37
38
39
40
41
42
    return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  };
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */


  var getUID = function getUID(prefix) {
    do {
Mark Otto's avatar
Mark Otto committed
43
      prefix += Math.floor(Math.random() * MAX_UID);
XhmikosR's avatar
XhmikosR committed
44
45
46
47
48
    } while (document.getElementById(prefix));

    return prefix;
  };

XhmikosR's avatar
XhmikosR committed
49
  var getSelector = function getSelector(element) {
XhmikosR's avatar
XhmikosR committed
50
    var selector = element.getAttribute('data-bs-target');
XhmikosR's avatar
XhmikosR committed
51
52
53

    if (!selector || selector === '#') {
      var hrefAttr = element.getAttribute('href');
XhmikosR's avatar
XhmikosR committed
54
      selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
XhmikosR's avatar
XhmikosR committed
55
56
    }

XhmikosR's avatar
XhmikosR committed
57
58
59
60
61
62
63
    return selector;
  };

  var getSelectorFromElement = function getSelectorFromElement(element) {
    var selector = getSelector(element);

    if (selector) {
XhmikosR's avatar
XhmikosR committed
64
65
      return document.querySelector(selector) ? selector : null;
    }
XhmikosR's avatar
XhmikosR committed
66
67

    return null;
XhmikosR's avatar
XhmikosR committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  };

  var isElement = function isElement(obj) {
    return (obj[0] || obj).nodeType;
  };

  var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
    Object.keys(configTypes).forEach(function (property) {
      var expectedTypes = configTypes[property];
      var value = config[property];
      var valueType = value && isElement(value) ? 'element' : toType(value);

      if (!new RegExp(expectedTypes).test(valueType)) {
        throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
      }
    });
  };

XhmikosR's avatar
XhmikosR committed
86
87
88
89
  var getjQuery = function getjQuery() {
    var _window = window,
        jQuery = _window.jQuery;

XhmikosR's avatar
XhmikosR committed
90
    if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
XhmikosR's avatar
XhmikosR committed
91
92
93
94
95
96
      return jQuery;
    }

    return null;
  };

XhmikosR's avatar
XhmikosR committed
97
98
99
100
101
102
103
104
  var onDOMContentLoaded = function onDOMContentLoaded(callback) {
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', callback);
    } else {
      callback();
    }
  };

XhmikosR's avatar
XhmikosR committed
105
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
Mark Otto's avatar
Mark Otto committed
106
107
108
109

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

  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
XhmikosR's avatar
Dist    
XhmikosR committed
110
111
112
113
114
115
116
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'scrollspy';
XhmikosR's avatar
XhmikosR committed
117
  var VERSION = '5.0.0-alpha3';
XhmikosR's avatar
Dist    
XhmikosR committed
118
119
120
121
122
123
124
125
126
127
128
129
130
  var DATA_KEY = 'bs.scrollspy';
  var EVENT_KEY = "." + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var Default = {
    offset: 10,
    method: 'auto',
    target: ''
  };
  var DefaultType = {
    offset: 'number',
    method: 'string',
    target: '(string|element)'
  };
XhmikosR's avatar
XhmikosR committed
131
132
133
134
135
  var EVENT_ACTIVATE = "activate" + EVENT_KEY;
  var EVENT_SCROLL = "scroll" + EVENT_KEY;
  var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
  var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  var CLASS_NAME_ACTIVE = 'active';
XhmikosR's avatar
XhmikosR committed
136
  var SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
XhmikosR's avatar
XhmikosR committed
137
138
139
140
141
142
143
144
  var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  var SELECTOR_NAV_LINKS = '.nav-link';
  var SELECTOR_NAV_ITEMS = '.nav-item';
  var SELECTOR_LIST_ITEMS = '.list-group-item';
  var SELECTOR_DROPDOWN = '.dropdown';
  var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  var METHOD_OFFSET = 'offset';
  var METHOD_POSITION = 'position';
XhmikosR's avatar
XhmikosR committed
145
146
147
148
149
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
150

XhmikosR's avatar
XhmikosR committed
151
  var ScrollSpy = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
152
153
154
155
156
157
    function ScrollSpy(element, config) {
      var _this = this;

      this._element = element;
      this._scrollElement = element.tagName === 'BODY' ? window : element;
      this._config = this._getConfig(config);
XhmikosR's avatar
XhmikosR committed
158
      this._selector = this._config.target + " " + SELECTOR_NAV_LINKS + ", " + this._config.target + " " + SELECTOR_LIST_ITEMS + ", " + this._config.target + " ." + CLASS_NAME_DROPDOWN_ITEM;
XhmikosR's avatar
Dist    
XhmikosR committed
159
160
161
162
      this._offsets = [];
      this._targets = [];
      this._activeTarget = null;
      this._scrollHeight = 0;
XhmikosR's avatar
XhmikosR committed
163
      EventHandler__default['default'].on(this._scrollElement, EVENT_SCROLL, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
164
165
166
        return _this._process(event);
      });
      this.refresh();
Jacob Thornton's avatar
Jacob Thornton committed
167

XhmikosR's avatar
Dist    
XhmikosR committed
168
      this._process();
XhmikosR's avatar
XhmikosR committed
169

XhmikosR's avatar
XhmikosR committed
170
      Data__default['default'].setData(element, DATA_KEY, this);
XhmikosR's avatar
Dist    
XhmikosR committed
171
    } // Getters
fat's avatar
fat committed
172
173


XhmikosR's avatar
Dist    
XhmikosR committed
174
    var _proto = ScrollSpy.prototype;
fat's avatar
fat committed
175

XhmikosR's avatar
Dist    
XhmikosR committed
176
177
178
    // Public
    _proto.refresh = function refresh() {
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
179

XhmikosR's avatar
XhmikosR committed
180
      var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
XhmikosR's avatar
Dist    
XhmikosR committed
181
      var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
XhmikosR's avatar
XhmikosR committed
182
      var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
XhmikosR's avatar
Dist    
XhmikosR committed
183
184
185
      this._offsets = [];
      this._targets = [];
      this._scrollHeight = this._getScrollHeight();
XhmikosR's avatar
XhmikosR committed
186
      var targets = SelectorEngine__default['default'].find(this._selector);
XhmikosR's avatar
Dist    
XhmikosR committed
187
      targets.map(function (element) {
XhmikosR's avatar
XhmikosR committed
188
        var targetSelector = getSelectorFromElement(element);
XhmikosR's avatar
XhmikosR committed
189
        var target = targetSelector ? SelectorEngine__default['default'].findOne(targetSelector) : null;
190

XhmikosR's avatar
Dist    
XhmikosR committed
191
192
        if (target) {
          var targetBCR = target.getBoundingClientRect();
fat's avatar
fat committed
193

XhmikosR's avatar
Dist    
XhmikosR committed
194
          if (targetBCR.width || targetBCR.height) {
XhmikosR's avatar
XhmikosR committed
195
            return [Manipulator__default['default'][offsetMethod](target).top + offsetBase, targetSelector];
Mark Otto's avatar
dist    
Mark Otto committed
196
          }
XhmikosR's avatar
Dist    
XhmikosR committed
197
        }
fat's avatar
fat committed
198

XhmikosR's avatar
Dist    
XhmikosR committed
199
200
201
202
203
204
205
        return null;
      }).filter(function (item) {
        return item;
      }).sort(function (a, b) {
        return a[0] - b[0];
      }).forEach(function (item) {
        _this2._offsets.push(item[0]);
fat's avatar
fat committed
206

XhmikosR's avatar
Dist    
XhmikosR committed
207
208
209
        _this2._targets.push(item[1]);
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
210

XhmikosR's avatar
Dist    
XhmikosR committed
211
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
212
213
      Data__default['default'].removeData(this._element, DATA_KEY);
      EventHandler__default['default'].off(this._scrollElement, EVENT_KEY);
XhmikosR's avatar
Dist    
XhmikosR committed
214
215
216
217
218
219
220
221
      this._element = null;
      this._scrollElement = null;
      this._config = null;
      this._selector = null;
      this._offsets = null;
      this._targets = null;
      this._activeTarget = null;
      this._scrollHeight = null;
Mark Otto's avatar
Mark Otto committed
222
223
    } // Private
    ;
XhmikosR's avatar
Dist    
XhmikosR committed
224
225

    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
226
      config = _extends({}, Default, typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist    
XhmikosR committed
227

XhmikosR's avatar
XhmikosR committed
228
      if (typeof config.target !== 'string' && isElement(config.target)) {
XhmikosR's avatar
XhmikosR committed
229
        var id = config.target.id;
XhmikosR's avatar
Dist    
XhmikosR committed
230
231

        if (!id) {
XhmikosR's avatar
XhmikosR committed
232
233
          id = getUID(NAME);
          config.target.id = id;
Mark Otto's avatar
dist    
Mark Otto committed
234
        }
matus's avatar
matus committed
235

XhmikosR's avatar
Dist    
XhmikosR committed
236
237
        config.target = "#" + id;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
238

XhmikosR's avatar
XhmikosR committed
239
      typeCheckConfig(NAME, config, DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
240
241
      return config;
    };
fat's avatar
fat committed
242

XhmikosR's avatar
Dist    
XhmikosR committed
243
244
245
    _proto._getScrollTop = function _getScrollTop() {
      return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
    };
fat's avatar
fat committed
246

XhmikosR's avatar
Dist    
XhmikosR committed
247
248
249
    _proto._getScrollHeight = function _getScrollHeight() {
      return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
    };
fat's avatar
fat committed
250

XhmikosR's avatar
Dist    
XhmikosR committed
251
252
253
    _proto._getOffsetHeight = function _getOffsetHeight() {
      return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
    };
fat's avatar
fat committed
254

XhmikosR's avatar
Dist    
XhmikosR committed
255
256
    _proto._process = function _process() {
      var scrollTop = this._getScrollTop() + this._config.offset;
fat's avatar
fat committed
257

XhmikosR's avatar
Dist    
XhmikosR committed
258
      var scrollHeight = this._getScrollHeight();
Mark Otto's avatar
dist    
Mark Otto committed
259

XhmikosR's avatar
Dist    
XhmikosR committed
260
      var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
Mark Otto's avatar
dist    
Mark Otto committed
261

XhmikosR's avatar
Dist    
XhmikosR committed
262
263
264
      if (this._scrollHeight !== scrollHeight) {
        this.refresh();
      }
Mark Otto's avatar
dist    
Mark Otto committed
265

XhmikosR's avatar
Dist    
XhmikosR committed
266
267
      if (scrollTop >= maxScroll) {
        var target = this._targets[this._targets.length - 1];
fat's avatar
fat committed
268

XhmikosR's avatar
Dist    
XhmikosR committed
269
270
        if (this._activeTarget !== target) {
          this._activate(target);
Mark Otto's avatar
dist    
Mark Otto committed
271
        }
fat's avatar
fat committed
272

XhmikosR's avatar
Dist    
XhmikosR committed
273
274
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
275

XhmikosR's avatar
Dist    
XhmikosR committed
276
277
      if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
        this._activeTarget = null;
Mark Otto's avatar
dist    
Mark Otto committed
278

XhmikosR's avatar
Dist    
XhmikosR committed
279
        this._clear();
Mark Otto's avatar
dist    
Mark Otto committed
280

XhmikosR's avatar
Dist    
XhmikosR committed
281
282
        return;
      }
fat's avatar
fat committed
283

XhmikosR's avatar
XhmikosR committed
284
      for (var i = this._offsets.length; i--;) {
XhmikosR's avatar
Dist    
XhmikosR committed
285
        var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
Mark Otto's avatar
dist    
Mark Otto committed
286

XhmikosR's avatar
Dist    
XhmikosR committed
287
288
289
290
291
        if (isActiveTarget) {
          this._activate(this._targets[i]);
        }
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
292

XhmikosR's avatar
Dist    
XhmikosR committed
293
294
    _proto._activate = function _activate(target) {
      this._activeTarget = target;
Mark Otto's avatar
dist    
Mark Otto committed
295

XhmikosR's avatar
Dist    
XhmikosR committed
296
      this._clear();
Mark Otto's avatar
dist    
Mark Otto committed
297

XhmikosR's avatar
Dist    
XhmikosR committed
298
      var queries = this._selector.split(',').map(function (selector) {
XhmikosR's avatar
XhmikosR committed
299
        return selector + "[data-bs-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
XhmikosR's avatar
Dist    
XhmikosR committed
300
      });
XhmikosR's avatar
Dist    
XhmikosR committed
301

XhmikosR's avatar
XhmikosR committed
302
      var link = SelectorEngine__default['default'].findOne(queries.join(','));
Mark Otto's avatar
dist    
Mark Otto committed
303

XhmikosR's avatar
XhmikosR committed
304
      if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
XhmikosR's avatar
XhmikosR committed
305
        SelectorEngine__default['default'].findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE);
XhmikosR's avatar
XhmikosR committed
306
        link.classList.add(CLASS_NAME_ACTIVE);
XhmikosR's avatar
Dist    
XhmikosR committed
307
308
      } else {
        // Set triggered link as active
XhmikosR's avatar
XhmikosR committed
309
        link.classList.add(CLASS_NAME_ACTIVE);
XhmikosR's avatar
XhmikosR committed
310
        SelectorEngine__default['default'].parents(link, SELECTOR_NAV_LIST_GROUP).forEach(function (listGroup) {
XhmikosR's avatar
XhmikosR committed
311
312
          // Set triggered links parents as active
          // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
XhmikosR's avatar
XhmikosR committed
313
          SelectorEngine__default['default'].prev(listGroup, SELECTOR_NAV_LINKS + ", " + SELECTOR_LIST_ITEMS).forEach(function (item) {
XhmikosR's avatar
XhmikosR committed
314
            return item.classList.add(CLASS_NAME_ACTIVE);
XhmikosR's avatar
XhmikosR committed
315
316
          }); // Handle special case when .nav-link is inside .nav-item

XhmikosR's avatar
XhmikosR committed
317
318
          SelectorEngine__default['default'].prev(listGroup, SELECTOR_NAV_ITEMS).forEach(function (navItem) {
            SelectorEngine__default['default'].children(navItem, SELECTOR_NAV_LINKS).forEach(function (item) {
XhmikosR's avatar
XhmikosR committed
319
              return item.classList.add(CLASS_NAME_ACTIVE);
XhmikosR's avatar
XhmikosR committed
320
321
322
            });
          });
        });
XhmikosR's avatar
Dist    
XhmikosR committed
323
      }
Mark Otto's avatar
grunt    
Mark Otto committed
324

XhmikosR's avatar
XhmikosR committed
325
      EventHandler__default['default'].trigger(this._scrollElement, EVENT_ACTIVATE, {
XhmikosR's avatar
Dist    
XhmikosR committed
326
327
328
        relatedTarget: target
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
329

XhmikosR's avatar
Dist    
XhmikosR committed
330
    _proto._clear = function _clear() {
XhmikosR's avatar
XhmikosR committed
331
      SelectorEngine__default['default'].find(this._selector).filter(function (node) {
XhmikosR's avatar
XhmikosR committed
332
        return node.classList.contains(CLASS_NAME_ACTIVE);
XhmikosR's avatar
Dist    
XhmikosR committed
333
      }).forEach(function (node) {
XhmikosR's avatar
XhmikosR committed
334
        return node.classList.remove(CLASS_NAME_ACTIVE);
XhmikosR's avatar
Dist    
XhmikosR committed
335
      });
Mark Otto's avatar
Mark Otto committed
336
337
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
338

XhmikosR's avatar
XhmikosR committed
339
    ScrollSpy.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist    
XhmikosR committed
340
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
341
        var data = Data__default['default'].getData(this, DATA_KEY);
Mark Otto's avatar
dist    
Mark Otto committed
342

XhmikosR's avatar
Dist    
XhmikosR committed
343
        var _config = typeof config === 'object' && config;
Mark Otto's avatar
dist    
Mark Otto committed
344

XhmikosR's avatar
Dist    
XhmikosR committed
345
346
347
        if (!data) {
          data = new ScrollSpy(this, _config);
        }
Mark Otto's avatar
dist    
Mark Otto committed
348

XhmikosR's avatar
Dist    
XhmikosR committed
349
350
351
        if (typeof config === 'string') {
          if (typeof data[config] === 'undefined') {
            throw new TypeError("No method named \"" + config + "\"");
Mark Otto's avatar
dist    
Mark Otto committed
352
          }
Mark Otto's avatar
dist    
Mark Otto committed
353

XhmikosR's avatar
Dist    
XhmikosR committed
354
          data[config]();
Mark Otto's avatar
dist    
Mark Otto committed
355
        }
XhmikosR's avatar
Dist    
XhmikosR committed
356
357
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
358

XhmikosR's avatar
XhmikosR committed
359
    ScrollSpy.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
360
      return Data__default['default'].getData(element, DATA_KEY);
XhmikosR's avatar
XhmikosR committed
361
362
    };

XhmikosR's avatar
Dist    
XhmikosR committed
363
364
365
366
367
368
369
370
371
372
373
    _createClass(ScrollSpy, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default;
      }
    }]);
fat's avatar
fat committed
374

XhmikosR's avatar
Dist    
XhmikosR committed
375
376
377
378
379
380
381
    return ScrollSpy;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
382

Mark Otto's avatar
dist    
Mark Otto committed
383

XhmikosR's avatar
XhmikosR committed
384
385
386
  EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, function () {
    SelectorEngine__default['default'].find(SELECTOR_DATA_SPY).forEach(function (spy) {
      return new ScrollSpy(spy, Manipulator__default['default'].getDataAttributes(spy));
XhmikosR's avatar
XhmikosR committed
387
    });
XhmikosR's avatar
Dist    
XhmikosR committed
388
389
390
391
392
  });
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
393
   * add .ScrollSpy to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
394
   */
fat's avatar
fat committed
395

XhmikosR's avatar
XhmikosR committed
396
397
398
  onDOMContentLoaded(function () {
    var $ = getjQuery();
    /* istanbul ignore if */
399

XhmikosR's avatar
XhmikosR committed
400
401
402
403
    if ($) {
      var JQUERY_NO_CONFLICT = $.fn[NAME];
      $.fn[NAME] = ScrollSpy.jQueryInterface;
      $.fn[NAME].Constructor = ScrollSpy;
Mark Otto's avatar
dist    
Mark Otto committed
404

XhmikosR's avatar
XhmikosR committed
405
406
407
408
409
410
      $.fn[NAME].noConflict = function () {
        $.fn[NAME] = JQUERY_NO_CONFLICT;
        return ScrollSpy.jQueryInterface;
      };
    }
  });
fat's avatar
fat committed
411
412

  return ScrollSpy;
Mark Otto's avatar
dist    
Mark Otto committed
413

XhmikosR's avatar
XhmikosR committed
414
})));
Mark Otto's avatar
dist    
Mark Otto committed
415
//# sourceMappingURL=scrollspy.js.map