File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1818
1919 function jumpToAnchor ( e ) {
2020 if ( e ) {
21+ if ( e . altKey ) return
2122 window . location . hash = '#' + this . id
2223 e . preventDefault ( )
2324 }
Original file line number Diff line number Diff line change 11; ( function ( ) {
22 'use strict'
33
4+ var pageSpec = document . querySelector ( 'head meta[name=page-spec]' ) . content
45 var editPageLink = document . querySelector ( '.toolbar .edit-this-page a' )
5- if ( ! editPageLink ) return
6- editPageLink . addEventListener ( 'click' , function ( e ) {
7- if ( e . altKey ) navigator . clipboard . writeText ( document . querySelector ( 'head meta[name=page-spec]' ) . content )
6+ if ( editPageLink ) editPageLink . addEventListener ( 'click' , onEditPageLinkClick )
7+ ; [ ] . slice . call ( document . querySelectorAll ( '.doc a.anchor' ) ) . forEach ( function ( anchor ) {
8+ if ( / H [ 2 - 6 ] / . test ( anchor . parentNode . tagName ) ) anchor . addEventListener ( 'click' , onSectionAnchorClick . bind ( anchor ) )
89 } )
10+
11+ function onEditPageLinkClick ( e ) {
12+ if ( e . altKey ) navigator . clipboard . writeText ( pageSpec )
13+ }
14+
15+ function onSectionAnchorClick ( e ) {
16+ if ( e . altKey ) {
17+ e . preventDefault ( )
18+ navigator . clipboard . writeText ( pageSpec + decodeFragment ( this . hash ) )
19+ }
20+ }
21+
22+ function decodeFragment ( hash ) {
23+ return ~ hash . indexOf ( '%' ) ? decodeURIComponent ( hash ) : hash
24+ }
925} ) ( )
You can’t perform that action at this time.
0 commit comments