Skip to content

Commit

Permalink
Fixed nav-current matching for sites that exclude file names from the…
Browse files Browse the repository at this point in the history
… URL.
  • Loading branch information
Paul Jackson authored and Paul Jackson committed Sep 19, 2012
1 parent 9b9a6d1 commit 72202c1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Binary file removed build/js/images/toolbar/gradient.png
Binary file not shown.
Binary file removed build/js/images/toolbar/top_of_page.png
Binary file not shown.
2 changes: 1 addition & 1 deletion build/js/pe-ap-min.js

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions src/js/pe-ap.js
Expand Up @@ -704,15 +704,16 @@
* @return {jQuery object} Link where match found
*/
navcurrent: function (menusrc, bcsrc, navclass) {
var pageurl = window.location.pathname,
pageurlquery = pageurl + window.location.search,
var pageurl = window.location.hostname + window.location.pathname,
pageurlquery = window.location.search,
menulinks,
menulink,
menulinkurl,
menulinkquery,
menulinkslen,
bclinks,
bclink,
bclinkurl,
bclinkslen,
bcindex,
h1text = pe.main.find('h1').text(),
Expand All @@ -727,17 +728,18 @@

while (menulinkslen--) {
menulink = menulinks[menulinkslen];
if (menulink.getAttribute('href').indexOf('#') !== 0) {
menulinkurl = menulink.pathname;
if (menulink.getAttribute('href').slice(0, 1) !== '#') {
menulinkurl = menulink.hostname + menulink.pathname;
menulinkquery = menulink.search;
bcindex = bclinkslen;
if ((menulinkquery.length !== 0 && (menulinkurl + menulinkquery).indexOf(pageurlquery) !== -1) || (menulinkquery.length === 0 && menulinkurl.indexOf(pageurl) !== -1) || menulink.innerHTML === h1text) {
if ((pageurl.slice(-menulinkurl.length) === menulinkurl && (menulinkquery.length === 0 || pageurlquery.slice(-menulinkquery.length) === menulinkquery)) || menulink.innerHTML === h1text) {
match = true;
break;
}
while (bcindex--) {
bclink = bclinks[bcindex];
if (bclink.pathname.indexOf(menulinkurl) !== -1) {
bclinkurl = bclink.hostname + bclink.pathname;
if (bclinkurl.indexOf(menulinkurl) !== -1) {
match = true;
break;
}
Expand Down

0 comments on commit 72202c1

Please sign in to comment.