aboutsummaryrefslogtreecommitdiffstats
path: root/bower_components/bootstrap/js/scrollspy.js
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2015-07-08 07:35:02 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2015-07-08 07:35:02 -0300
commitb0b24795b24ee6809397fbbadf42f31f310a219f (patch)
tree46d05bb47460b4ec679211717c4ab07414b80d9c /bower_components/bootstrap/js/scrollspy.js
parent5ec02211214350ee558fd9f6bb052264fd24f75e (diff)
Imported Upstream version 7.6.0upstream/7.6.0
Diffstat (limited to 'bower_components/bootstrap/js/scrollspy.js')
-rw-r--r--bower_components/bootstrap/js/scrollspy.js54
1 files changed, 28 insertions, 26 deletions
diff --git a/bower_components/bootstrap/js/scrollspy.js b/bower_components/bootstrap/js/scrollspy.js
index db23787..7208e25 100644
--- a/bower_components/bootstrap/js/scrollspy.js
+++ b/bower_components/bootstrap/js/scrollspy.js
@@ -1,8 +1,8 @@
/* ========================================================================
- * Bootstrap: scrollspy.js v3.2.0
+ * Bootstrap: scrollspy.js v3.3.5
* http://getbootstrap.com/javascript/#scrollspy
* ========================================================================
- * Copyright 2011-2014 Twitter, Inc.
+ * Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
@@ -14,10 +14,8 @@
// ==========================
function ScrollSpy(element, options) {
- var process = $.proxy(this.process, this)
-
- this.$body = $('body')
- this.$scrollElement = $(element).is('body') ? $(window) : $(element)
+ this.$body = $(document.body)
+ this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
this.selector = (this.options.target || '') + ' .nav li > a'
this.offsets = []
@@ -25,12 +23,12 @@
this.activeTarget = null
this.scrollHeight = 0
- this.$scrollElement.on('scroll.bs.scrollspy', process)
+ this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
this.refresh()
this.process()
}
- ScrollSpy.VERSION = '3.2.0'
+ ScrollSpy.VERSION = '3.3.5'
ScrollSpy.DEFAULTS = {
offset: 10
@@ -41,20 +39,19 @@
}
ScrollSpy.prototype.refresh = function () {
- var offsetMethod = 'offset'
- var offsetBase = 0
+ var that = this
+ var offsetMethod = 'offset'
+ var offsetBase = 0
+
+ this.offsets = []
+ this.targets = []
+ this.scrollHeight = this.getScrollHeight()
if (!$.isWindow(this.$scrollElement[0])) {
offsetMethod = 'position'
offsetBase = this.$scrollElement.scrollTop()
}
- this.offsets = []
- this.targets = []
- this.scrollHeight = this.getScrollHeight()
-
- var self = this
-
this.$body
.find(this.selector)
.map(function () {
@@ -69,8 +66,8 @@
})
.sort(function (a, b) { return a[0] - b[0] })
.each(function () {
- self.offsets.push(this[0])
- self.targets.push(this[1])
+ that.offsets.push(this[0])
+ that.targets.push(this[1])
})
}
@@ -91,14 +88,15 @@
return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
}
- if (activeTarget && scrollTop <= offsets[0]) {
- return activeTarget != (i = targets[0]) && this.activate(i)
+ if (activeTarget && scrollTop < offsets[0]) {
+ this.activeTarget = null
+ return this.clear()
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
+ && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
&& this.activate(targets[i])
}
}
@@ -106,13 +104,11 @@
ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target
- $(this.selector)
- .parentsUntil(this.options.target, '.active')
- .removeClass('active')
+ this.clear()
var selector = this.selector +
- '[data-target="' + target + '"],' +
- this.selector + '[href="' + target + '"]'
+ '[data-target="' + target + '"],' +
+ this.selector + '[href="' + target + '"]'
var active = $(selector)
.parents('li')
@@ -127,6 +123,12 @@
active.trigger('activate.bs.scrollspy')
}
+ ScrollSpy.prototype.clear = function () {
+ $(this.selector)
+ .parentsUntil(this.options.target, '.active')
+ .removeClass('active')
+ }
+
// SCROLLSPY PLUGIN DEFINITION
// ===========================