diff options
author | Mark Otto <markdotto@gmail.com> | 2017-04-08 23:22:53 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2017-04-08 23:22:53 +0300 |
commit | 364e01885fadeb341e1000d6f50291e5a5ada199 (patch) | |
tree | 160bdf7e792e19ac451690e0e63a1e3a673ec45c /js/dist/scrollspy.js | |
parent | f7881336e508f6f4fcfb279eb8a8f26509a05b67 (diff) |
grunt
Diffstat (limited to 'js/dist/scrollspy.js')
-rw-r--r-- | js/dist/scrollspy.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/js/dist/scrollspy.js b/js/dist/scrollspy.js index 10fc3c394a..e8be562ec3 100644 --- a/js/dist/scrollspy.js +++ b/js/dist/scrollspy.js @@ -47,18 +47,15 @@ var ScrollSpy = function ($) { var ClassName = { DROPDOWN_ITEM: 'dropdown-item', DROPDOWN_MENU: 'dropdown-menu', - NAV_LINK: 'nav-link', - NAV: 'nav', ACTIVE: 'active' }; var Selector = { DATA_SPY: '[data-spy="scroll"]', ACTIVE: '.active', - LIST_ITEM: '.list-item', - LI: 'li', - LI_DROPDOWN: 'li.dropdown', + NAV_LIST_GROUP: '.nav, .list-group', NAV_LINKS: '.nav-link', + LIST_ITEMS: '.list-group-item', DROPDOWN: '.dropdown', DROPDOWN_ITEMS: '.dropdown-item', DROPDOWN_TOGGLE: '.dropdown-toggle' @@ -84,7 +81,7 @@ var ScrollSpy = function ($) { this._element = element; this._scrollElement = element.tagName === 'BODY' ? window : element; this._config = this._getConfig(config); - this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS); + this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.LIST_ITEMS + ',') + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS); this._offsets = []; this._targets = []; this._activeTarget = null; @@ -238,9 +235,11 @@ var ScrollSpy = function ($) { $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); $link.addClass(ClassName.ACTIVE); } else { - // todo (fat) this is kinda sus... - // recursively add actives to tested nav-links - $link.parents(Selector.LI).find('> ' + Selector.NAV_LINKS).addClass(ClassName.ACTIVE); + // Set triggered link as active + $link.addClass(ClassName.ACTIVE); + // Set triggered links parents as active + // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor + $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_LINKS + ', ' + Selector.LIST_ITEMS).addClass(ClassName.ACTIVE); } $(this._scrollElement).trigger(Event.ACTIVATE, { |