Skip to content

Commit

Permalink
fix link highlighting in manual (mrdoob#23113)
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman authored Jan 3, 2022
1 parent 71a8dca commit f87682a
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions manual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ <h1><a href="https://threejs.org">three.js</a></h1>

// Activate content and title change on browser navigation

window.onpopstate = createNewIframe;
window.onpopstate = function() {

updateNavigation();
createNewIframe();

}

// Create the navigation panel and configure the iframe

Expand Down Expand Up @@ -189,14 +194,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
window.location.hash = pageURL;
panel.classList.remove( 'open' );


content.querySelectorAll( 'a' ).forEach( function ( item ) {

item.classList.remove( 'selected' );

} );

link.classList.add( 'selected' );
updateNavigation();

} );

Expand Down Expand Up @@ -224,7 +222,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
}

const categories = list[ language ];
const selectedPage = window.location.hash.substring( 1 );
const selectedPage = window.location.hash.substring( 1 ).replace( /\.html$/, '' );

for ( const category in categories ) {

Expand Down Expand Up @@ -286,6 +284,26 @@ <h1><a href="https://threejs.org">three.js</a></h1>

}

function updateNavigation() {

const selectedPage = window.location.hash.substring( 1 ).replace( /\.html$/, '' );

content.querySelectorAll( 'a' ).forEach( function ( item ) {

if ( item.href.includes( selectedPage ) ) {

item.classList.add( 'selected' );

} else {

item.classList.remove( 'selected' );

}

} );

}

// Auto change language url. If a reader open a document in English, when he click "zh", the document he read will auto change into Chinese version

function autoChangeUrlLanguage( language ) {
Expand Down Expand Up @@ -430,6 +448,7 @@ <h1><a href="https://threejs.org">three.js</a></h1>
} else {

window.location.hash = newHash;
updateNavigation();
createNewIframe();

}
Expand Down

0 comments on commit f87682a

Please sign in to comment.