File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
utils/docs/template/static/scripts Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,45 @@ if ( typeof prettyPrint === 'function' ) {
55
66}
77
8+ // Scroll to hash on page load
9+ ( function ( ) {
10+
11+ const hash = window . location . hash . substring ( 1 ) ;
12+
13+ if ( hash ) {
14+
15+ const element = document . getElementById ( hash ) ;
16+
17+ if ( element ) element . scrollIntoView ( ) ;
18+
19+ }
20+
21+ } ) ( ) ;
22+
23+ // Update URL hash when clicking on method/property links
24+ ( function ( ) {
25+
26+ const h1 = document . querySelector ( 'h1' ) ;
27+ const className = h1 ? h1 . textContent . trim ( ) : null ;
28+
29+ if ( ! className ) return ;
30+
31+ document . addEventListener ( 'click' , function ( event ) {
32+
33+ const target = event . target . closest ( 'a[href^="#"]' ) ;
34+
35+ if ( ! target || ! target . hash ) return ;
36+
37+ const hash = target . hash . substring ( 1 ) ;
38+ const newHash = ( hash !== className ) ? `#${ className } .${ hash } ` : `#${ hash } ` ;
39+ const targetWindow = ( window . parent !== window ) ? window . parent : window ;
40+
41+ targetWindow . history . pushState ( null , '' , newHash ) ;
42+
43+ } ) ;
44+
45+ } ) ( ) ;
46+
847// Add code copy buttons
948( function addCopyButtons ( ) {
1049
You can’t perform that action at this time.
0 commit comments