scrollspy.js 15 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
1
/*!
XhmikosR's avatar
XhmikosR committed
2
  * Bootstrap scrollspy.js v4.3.1 (https://getbootstrap.com/)
Mark Otto's avatar
Mark Otto committed
3
  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
XhmikosR's avatar
Dist    
XhmikosR committed
4
5
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
Mark Otto's avatar
dist    
Mark Otto committed
6
(function (global, factory) {
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
10
  (global = global || self, global.ScrollSpy = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine));
}(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
  Data = Data && Data.hasOwnProperty('default') ? Data['default'] : Data;
  EventHandler = EventHandler && EventHandler.hasOwnProperty('default') ? EventHandler['default'] : EventHandler;
  Manipulator = Manipulator && Manipulator.hasOwnProperty('default') ? Manipulator['default'] : Manipulator;
  SelectorEngine = SelectorEngine && SelectorEngine.hasOwnProperty('default') ? SelectorEngine['default'] : SelectorEngine;
Mark Otto's avatar
dist    
Mark Otto committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

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

  function _defineProperty(obj, key, value) {
    if (key in obj) {
      Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
      });
    } else {
      obj[key] = value;
    }

    return obj;
  }

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);

    if (Object.getOwnPropertySymbols) {
      var symbols = Object.getOwnPropertySymbols(object);
      if (enumerableOnly) symbols = symbols.filter(function (sym) {
        return Object.getOwnPropertyDescriptor(object, sym).enumerable;
      });
      keys.push.apply(keys, symbols);
    }

    return keys;
  }

  function _objectSpread2(target) {
Mark Otto's avatar
dist    
Mark Otto committed
63
64
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i] != null ? arguments[i] : {};
Mark Otto's avatar
dist    
Mark Otto committed
65

66
67
68
69
70
71
72
73
74
75
      if (i % 2) {
        ownKeys(source, true).forEach(function (key) {
          _defineProperty(target, key, source[key]);
        });
      } else if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
      } else {
        ownKeys(source).forEach(function (key) {
          Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
Mark Otto's avatar
dist    
Mark Otto committed
76
77
      }
    }
Mark Otto's avatar
dist    
Mark Otto committed
78

Mark Otto's avatar
dist    
Mark Otto committed
79
80
    return target;
  }
fat's avatar
fat committed
81

XhmikosR's avatar
XhmikosR committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  /**
   * --------------------------------------------------------------------------
   * Bootstrap (v4.3.1): util/index.js
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */
  var MAX_UID = 1000000;

  var toType = function toType(obj) {
    return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  };
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */


  var getUID = function getUID(prefix) {
    do {
      // eslint-disable-next-line no-bitwise
      prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
    } while (document.getElementById(prefix));

    return prefix;
  };

XhmikosR's avatar
XhmikosR committed
109
  var getSelector = function getSelector(element) {
XhmikosR's avatar
XhmikosR committed
110
111
112
113
    var selector = element.getAttribute('data-target');

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

XhmikosR's avatar
XhmikosR committed
117
118
119
120
121
122
123
    return selector;
  };

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

    if (selector) {
XhmikosR's avatar
XhmikosR committed
124
125
      return document.querySelector(selector) ? selector : null;
    }
XhmikosR's avatar
XhmikosR committed
126
127

    return null;
XhmikosR's avatar
XhmikosR committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  };

  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 + "\"."));
      }
    });
  };

  var makeArray = function makeArray(nodeList) {
    if (!nodeList) {
      return [];
    }

    return [].slice.call(nodeList);
  };

XhmikosR's avatar
XhmikosR committed
154
155
156
157
158
159
160
161
162
163
164
  var getjQuery = function getjQuery() {
    var _window = window,
        jQuery = _window.jQuery;

    if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
      return jQuery;
    }

    return null;
  };

XhmikosR's avatar
Dist    
XhmikosR committed
165
166
167
168
169
170
171
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'scrollspy';
XhmikosR's avatar
XhmikosR committed
172
  var VERSION = '4.3.1';
XhmikosR's avatar
Dist    
XhmikosR committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
  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)'
  };
  var Event = {
    ACTIVATE: "activate" + EVENT_KEY,
    SCROLL: "scroll" + EVENT_KEY,
    LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY
  };
  var ClassName = {
    DROPDOWN_ITEM: 'dropdown-item',
    ACTIVE: 'active'
  };
  var Selector = {
    DATA_SPY: '[data-spy="scroll"]',
    NAV_LIST_GROUP: '.nav, .list-group',
    NAV_LINKS: '.nav-link',
    NAV_ITEMS: '.nav-item',
    LIST_ITEMS: '.list-group-item',
    DROPDOWN: '.dropdown',
    DROPDOWN_TOGGLE: '.dropdown-toggle'
  };
  var OffsetMethod = {
    OFFSET: 'offset',
    POSITION: 'position'
Mark Otto's avatar
dist    
Mark Otto committed
207
208
    /**
     * ------------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
209
     * Class Definition
Mark Otto's avatar
dist    
Mark Otto committed
210
211
     * ------------------------------------------------------------------------
     */
fat's avatar
fat committed
212

XhmikosR's avatar
Dist    
XhmikosR committed
213
214
215
216
217
218
219
220
221
222
223
  };

  var ScrollSpy =
  /*#__PURE__*/
  function () {
    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
Dist.    
XhmikosR committed
224
      this._selector = this._config.target + " " + Selector.NAV_LINKS + "," + (this._config.target + " " + Selector.LIST_ITEMS + ",") + (this._config.target + " ." + ClassName.DROPDOWN_ITEM);
XhmikosR's avatar
Dist    
XhmikosR committed
225
226
227
228
      this._offsets = [];
      this._targets = [];
      this._activeTarget = null;
      this._scrollHeight = 0;
XhmikosR's avatar
XhmikosR committed
229
      EventHandler.on(this._scrollElement, Event.SCROLL, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
230
231
232
        return _this._process(event);
      });
      this.refresh();
Jacob Thornton's avatar
Jacob Thornton committed
233

XhmikosR's avatar
Dist    
XhmikosR committed
234
      this._process();
XhmikosR's avatar
XhmikosR committed
235
236

      Data.setData(element, DATA_KEY, this);
XhmikosR's avatar
Dist    
XhmikosR committed
237
    } // Getters
fat's avatar
fat committed
238
239


XhmikosR's avatar
Dist    
XhmikosR committed
240
    var _proto = ScrollSpy.prototype;
fat's avatar
fat committed
241

XhmikosR's avatar
Dist    
XhmikosR committed
242
243
244
    // Public
    _proto.refresh = function refresh() {
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
245

XhmikosR's avatar
Dist    
XhmikosR committed
246
247
248
249
250
251
      var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
      var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
      var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
      this._offsets = [];
      this._targets = [];
      this._scrollHeight = this._getScrollHeight();
XhmikosR's avatar
XhmikosR committed
252
      var targets = makeArray(SelectorEngine.find(this._selector));
XhmikosR's avatar
Dist    
XhmikosR committed
253
254
      targets.map(function (element) {
        var target;
XhmikosR's avatar
XhmikosR committed
255
        var targetSelector = getSelectorFromElement(element);
Mark Otto's avatar
dist    
Mark Otto committed
256

XhmikosR's avatar
Dist    
XhmikosR committed
257
        if (targetSelector) {
XhmikosR's avatar
XhmikosR committed
258
          target = SelectorEngine.findOne(targetSelector);
XhmikosR's avatar
Dist    
XhmikosR committed
259
        }
260

XhmikosR's avatar
Dist    
XhmikosR committed
261
262
        if (target) {
          var targetBCR = target.getBoundingClientRect();
fat's avatar
fat committed
263

XhmikosR's avatar
Dist    
XhmikosR committed
264
          if (targetBCR.width || targetBCR.height) {
XhmikosR's avatar
XhmikosR committed
265
            return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector];
Mark Otto's avatar
dist    
Mark Otto committed
266
          }
XhmikosR's avatar
Dist    
XhmikosR committed
267
        }
fat's avatar
fat committed
268

XhmikosR's avatar
Dist    
XhmikosR committed
269
270
271
272
273
274
275
        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
276

XhmikosR's avatar
Dist    
XhmikosR committed
277
278
279
        _this2._targets.push(item[1]);
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
280

XhmikosR's avatar
Dist    
XhmikosR committed
281
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
282
283
      Data.removeData(this._element, DATA_KEY);
      EventHandler.off(this._scrollElement, EVENT_KEY);
XhmikosR's avatar
Dist    
XhmikosR committed
284
285
286
287
288
289
290
291
      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
292
293
    } // Private
    ;
XhmikosR's avatar
Dist    
XhmikosR committed
294
295

    _proto._getConfig = function _getConfig(config) {
296
      config = _objectSpread2({}, Default, {}, typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist    
XhmikosR committed
297
298

      if (typeof config.target !== 'string') {
XhmikosR's avatar
XhmikosR committed
299
        var id = config.target.id;
XhmikosR's avatar
Dist    
XhmikosR committed
300
301

        if (!id) {
XhmikosR's avatar
XhmikosR committed
302
303
          id = getUID(NAME);
          config.target.id = id;
Mark Otto's avatar
dist    
Mark Otto committed
304
        }
matus's avatar
matus committed
305

XhmikosR's avatar
Dist    
XhmikosR committed
306
307
        config.target = "#" + id;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
308

XhmikosR's avatar
XhmikosR committed
309
      typeCheckConfig(NAME, config, DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
310
311
      return config;
    };
fat's avatar
fat committed
312

XhmikosR's avatar
Dist    
XhmikosR committed
313
314
315
    _proto._getScrollTop = function _getScrollTop() {
      return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
    };
fat's avatar
fat committed
316

XhmikosR's avatar
Dist    
XhmikosR committed
317
318
319
    _proto._getScrollHeight = function _getScrollHeight() {
      return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
    };
fat's avatar
fat committed
320

XhmikosR's avatar
Dist    
XhmikosR committed
321
322
323
    _proto._getOffsetHeight = function _getOffsetHeight() {
      return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
    };
fat's avatar
fat committed
324

XhmikosR's avatar
Dist    
XhmikosR committed
325
326
    _proto._process = function _process() {
      var scrollTop = this._getScrollTop() + this._config.offset;
fat's avatar
fat committed
327

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
332
333
334
      if (this._scrollHeight !== scrollHeight) {
        this.refresh();
      }
Mark Otto's avatar
dist    
Mark Otto committed
335

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

XhmikosR's avatar
Dist    
XhmikosR committed
339
340
        if (this._activeTarget !== target) {
          this._activate(target);
Mark Otto's avatar
dist    
Mark Otto committed
341
        }
fat's avatar
fat committed
342

XhmikosR's avatar
Dist    
XhmikosR committed
343
344
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
345

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

XhmikosR's avatar
Dist    
XhmikosR committed
349
        this._clear();
Mark Otto's avatar
dist    
Mark Otto committed
350

XhmikosR's avatar
Dist    
XhmikosR committed
351
352
        return;
      }
fat's avatar
fat committed
353

XhmikosR's avatar
Dist    
XhmikosR committed
354
      var offsetLength = this._offsets.length;
Mark Otto's avatar
dist    
Mark Otto committed
355

XhmikosR's avatar
Dist    
XhmikosR committed
356
357
      for (var i = offsetLength; i--;) {
        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
358

XhmikosR's avatar
Dist    
XhmikosR committed
359
360
361
362
363
        if (isActiveTarget) {
          this._activate(this._targets[i]);
        }
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
364

XhmikosR's avatar
Dist    
XhmikosR committed
365
366
    _proto._activate = function _activate(target) {
      this._activeTarget = target;
Mark Otto's avatar
dist    
Mark Otto committed
367

XhmikosR's avatar
Dist    
XhmikosR committed
368
      this._clear();
Mark Otto's avatar
dist    
Mark Otto committed
369

XhmikosR's avatar
Dist    
XhmikosR committed
370
371
      var queries = this._selector.split(',').map(function (selector) {
        return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
XhmikosR's avatar
Dist    
XhmikosR committed
372
      });
XhmikosR's avatar
Dist    
XhmikosR committed
373

XhmikosR's avatar
XhmikosR committed
374
      var link = SelectorEngine.findOne(queries.join(','));
Mark Otto's avatar
dist    
Mark Otto committed
375

XhmikosR's avatar
XhmikosR committed
376
377
378
      if (link.classList.contains(ClassName.DROPDOWN_ITEM)) {
        SelectorEngine.findOne(Selector.DROPDOWN_TOGGLE, SelectorEngine.closest(link, Selector.DROPDOWN)).classList.add(ClassName.ACTIVE);
        link.classList.add(ClassName.ACTIVE);
XhmikosR's avatar
Dist    
XhmikosR committed
379
380
      } else {
        // Set triggered link as active
XhmikosR's avatar
XhmikosR committed
381
382
383
384
385
386
387
388
389
390
391
392
393
394
        link.classList.add(ClassName.ACTIVE);
        SelectorEngine.parents(link, Selector.NAV_LIST_GROUP).forEach(function (listGroup) {
          // Set triggered links parents as active
          // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
          SelectorEngine.prev(listGroup, Selector.NAV_LINKS + ", " + Selector.LIST_ITEMS).forEach(function (item) {
            return item.classList.add(ClassName.ACTIVE);
          }); // Handle special case when .nav-link is inside .nav-item

          SelectorEngine.prev(listGroup, Selector.NAV_ITEMS).forEach(function (navItem) {
            SelectorEngine.children(navItem, Selector.NAV_LINKS).forEach(function (item) {
              return item.classList.add(ClassName.ACTIVE);
            });
          });
        });
XhmikosR's avatar
Dist    
XhmikosR committed
395
      }
Mark Otto's avatar
grunt    
Mark Otto committed
396

XhmikosR's avatar
XhmikosR committed
397
      EventHandler.trigger(this._scrollElement, Event.ACTIVATE, {
XhmikosR's avatar
Dist    
XhmikosR committed
398
399
400
        relatedTarget: target
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
401

XhmikosR's avatar
Dist    
XhmikosR committed
402
    _proto._clear = function _clear() {
XhmikosR's avatar
XhmikosR committed
403
      makeArray(SelectorEngine.find(this._selector)).filter(function (node) {
XhmikosR's avatar
Dist    
XhmikosR committed
404
405
406
407
        return node.classList.contains(ClassName.ACTIVE);
      }).forEach(function (node) {
        return node.classList.remove(ClassName.ACTIVE);
      });
Mark Otto's avatar
Mark Otto committed
408
409
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
410

XhmikosR's avatar
XhmikosR committed
411
    ScrollSpy.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist    
XhmikosR committed
412
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
413
        var data = Data.getData(this, DATA_KEY);
Mark Otto's avatar
dist    
Mark Otto committed
414

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

XhmikosR's avatar
Dist    
XhmikosR committed
417
418
419
        if (!data) {
          data = new ScrollSpy(this, _config);
        }
Mark Otto's avatar
dist    
Mark Otto committed
420

XhmikosR's avatar
Dist    
XhmikosR committed
421
422
423
        if (typeof config === 'string') {
          if (typeof data[config] === 'undefined') {
            throw new TypeError("No method named \"" + config + "\"");
Mark Otto's avatar
dist    
Mark Otto committed
424
          }
Mark Otto's avatar
dist    
Mark Otto committed
425

XhmikosR's avatar
Dist    
XhmikosR committed
426
          data[config]();
Mark Otto's avatar
dist    
Mark Otto committed
427
        }
XhmikosR's avatar
Dist    
XhmikosR committed
428
429
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
430

XhmikosR's avatar
XhmikosR committed
431
    ScrollSpy.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
432
433
434
      return Data.getData(element, DATA_KEY);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
435
436
437
438
439
440
441
442
443
444
445
    _createClass(ScrollSpy, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default;
      }
    }]);
fat's avatar
fat committed
446

XhmikosR's avatar
Dist    
XhmikosR committed
447
448
449
450
451
452
453
    return ScrollSpy;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
454

Mark Otto's avatar
dist    
Mark Otto committed
455

XhmikosR's avatar
XhmikosR committed
456
457
458
459
  EventHandler.on(window, Event.LOAD_DATA_API, function () {
    makeArray(SelectorEngine.find(Selector.DATA_SPY)).forEach(function (spy) {
      return new ScrollSpy(spy, Manipulator.getDataAttributes(spy));
    });
XhmikosR's avatar
Dist    
XhmikosR committed
460
  });
XhmikosR's avatar
XhmikosR committed
461
  var $ = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
462
463
464
465
466
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
467

468
469
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
470
471
472
473
  if ($) {
    var JQUERY_NO_CONFLICT = $.fn[NAME];
    $.fn[NAME] = ScrollSpy.jQueryInterface;
    $.fn[NAME].Constructor = ScrollSpy;
Mark Otto's avatar
dist    
Mark Otto committed
474

XhmikosR's avatar
XhmikosR committed
475
476
477
    $.fn[NAME].noConflict = function () {
      $.fn[NAME] = JQUERY_NO_CONFLICT;
      return ScrollSpy.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
478
479
    };
  }
fat's avatar
fat committed
480
481

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

Mark Otto's avatar
Mark Otto committed
483
}));
Mark Otto's avatar
dist    
Mark Otto committed
484
//# sourceMappingURL=scrollspy.js.map