| 1602 | // ========================== |
| 1603 | |
| 1604 | function ScrollSpy(element, options) { |
| 1605 | var href |
| 1606 | var process = $.proxy(this.process, this) |
| 1607 | |
| 1608 | this.$element = $(element).is('body') ? $(window) : $(element) |
| 1609 | this.$body = $('body') |
| 1610 | this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process) |
| 1611 | this.options = $.extend({}, ScrollSpy.DEFAULTS, options) |
| 1612 | this.selector = (this.options.target |
| 1613 | || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 |
| 1614 | || '') + ' .nav li > a' |
| 1615 | this.offsets = $([]) |
| 1616 | this.targets = $([]) |
| 1617 | this.activeTarget = null |
| 1618 | |
| 1619 | this.refresh() |
| 1620 | this.process() |
| 1621 | } |
| 1622 | |
| 1623 | ScrollSpy.DEFAULTS = { |
| 1624 | offset: 10 |