Commit bc07e2ad authored by Jacob Thornton's avatar Jacob Thornton
Browse files

allow for pushstate in scrollspy

parent b6278989
Showing with 25 additions and 7 deletions
+25 -7
......@@ -54,7 +54,8 @@
$targets = this.$body
.find(this.selector)
.map(function () {
var href = $(this).attr('href')
var $el = $(this)
, href = $el.data('target') || $el.attr('href')
, $href = /^#\w/.test(href) && $(href)
return ( $href
&& href.length
......@@ -91,6 +92,7 @@
, activate: function (target) {
var active
, selector
this.activeTarget = target
......@@ -98,7 +100,11 @@
.parent('.active')
.removeClass('active')
active = $(this.selector + '[href="' + target + '"]')
selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]'
active = $(selector)
.parent('li')
.addClass('active')
......
......@@ -1309,7 +1309,8 @@
$targets = this.$body
.find(this.selector)
.map(function () {
var href = $(this).attr('href')
var $el = $(this)
, href = $el.data('target') || $el.attr('href')
, $href = /^#\w/.test(href) && $(href)
return ( $href
&& href.length
......@@ -1346,6 +1347,7 @@
, activate: function (target) {
var active
, selector
this.activeTarget = target
......@@ -1353,7 +1355,11 @@
.parent('.active')
.removeClass('active')
active = $(this.selector + '[href="' + target + '"]')
selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]'
active = $(selector)
.parent('li')
.addClass('active')
......
This diff is collapsed.
......@@ -54,7 +54,8 @@
$targets = this.$body
.find(this.selector)
.map(function () {
var href = $(this).attr('href')
var $el = $(this)
, href = $el.data('target') || $el.attr('href')
, $href = /^#\w/.test(href) && $(href)
return ( $href
&& href.length
......@@ -91,6 +92,7 @@
, activate: function (target) {
var active
, selector
this.activeTarget = target
......@@ -98,7 +100,11 @@
.parent('.active')
.removeClass('active')
active = $(this.selector + '[href="' + target + '"]')
selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]'
active = $(selector)
.parent('li')
.addClass('active')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment