@@ -451,19 +451,12 @@ const goToTop = (event) => {
451451 window . scrollTo ( { top : 0 } ) ;
452452} ;
453453
454-
455-
456- function goToHomepage ( event ) {
457- event . preventDefault ( ) ;
458- updateHistory ( "/" ) ;
459- }
460-
461454function copyURI ( evt ) {
462- navigator . clipboard . writeText (
463- window . location . origin + evt . target . closest ( "a" ) . getAttribute ( 'href' )
464- ) . then ( ( ) => { } , ( ) => {
455+ const url = window . location . origin + evt . target . closest ( "a" ) . getAttribute ( 'href' )
456+ navigator . clipboard . writeText ( url ) . then ( ( ) => { } , ( ) => {
465457 console . log ( "clipboard copy failed" ) ;
466458 } ) ;
459+ updateHistory ( url ) ;
467460}
468461
469462function toggleExpandShortcode ( event ) {
@@ -515,7 +508,7 @@ function handleDocumentChange(event) {
515508 const selectedVersion = target . value ;
516509 const currentPath = window . location . pathname ;
517510 //const versionedPath = target.dataset.path;
518-
511+
519512 window . setupDocSearch ( selectedVersion ) ; // TODO: Only if on versioned page?
520513
521514 localStorage . setItem ( 'docs-version' , selectedVersion ) ; // TODO: handle multiple
@@ -566,45 +559,43 @@ function handleDocumentClick(event) {
566559 }
567560 return ;
568561 }
569-
562+
570563 // Internal link clicks (.link)
571- const linkElement = closest ( '.link' ) ;
572- if ( linkElement && ! linkElement . getAttribute ( "target" ) ) {
564+ if ( target . classList . contains ( 'link' ) && ! target . getAttribute ( "target" ) ) {
573565 event . preventDefault ( ) ;
574- let href = linkElement . getAttribute ( 'href' ) ;
566+ let href = target . getAttribute ( 'href' ) ;
575567 if ( href ) {
576568 updateHistory ( href ) ;
577569 }
578570 return ;
579571 }
580-
572+
581573 // Card link clicks
582- if ( closest ( '. card-link') ) {
574+ if ( target . classList . contains ( ' card-link') ) {
583575 event . preventDefault ( ) ;
584- const cardLink = closest ( '.card-link' ) ;
585- const href = cardLink . getAttribute ( 'href' ) ;
576+ const href = target . getAttribute ( 'href' ) ;
586577 if ( href ) {
587578 updateHistory ( href ) ;
588579 }
589580 return ;
590581 }
591-
582+
592583 // Code show more button clicks
593584 if ( closest ( '.code-show-more' ) ) {
594585 target . classList . toggle ( "expanded" ) ;
595586 const prevElement = target . previousElementSibling ;
596587 if ( prevElement ) prevElement . classList . toggle ( "expanded" ) ;
597588 return ;
598589 }
599-
590+
600591 // OpenAPI property clicks
601592 if ( closest ( '.openapi-prop' ) && target === closest ( '.openapi-prop' ) ) {
602593 target . classList . toggle ( "collapsed" ) ;
603594 const content = target . querySelector ( '.openapi-prop-content' ) ;
604595 if ( content ) content . classList . toggle ( "hidden" ) ;
605596 return ;
606597 }
607-
598+
608599 // OpenAPI table show children clicks
609600 if ( closest ( '.openapi-table.show-children' ) ) {
610601 target . classList . toggle ( "collapsed" ) ;
@@ -614,37 +605,32 @@ function handleDocumentClick(event) {
614605 }
615606 return ;
616607 }
617-
608+
618609 // Tab clicks
619610 if ( target . hasAttribute ( 'data-tab-group' ) && target . hasAttribute ( 'data-tab-item' ) ) {
620611 event . preventDefault ( ) ;
621612 switchTab ( target . getAttribute ( 'data-tab-group' ) , target . getAttribute ( 'data-tab-item' ) , event ) ;
622613 return ;
623614 }
624-
615+
625616 // Back to top button
626617 if ( closest ( '.back-to-top' ) ) {
627618 event . preventDefault ( ) ;
628619 goToTop ( event ) ;
629620 return ;
630621 }
631-
622+
632623 // Copy URI clicks
633624 if ( closest ( '.header-link' ) ) {
634- copyURI ( event ) ;
635- return ;
636- }
637-
638- // Expand shortcode clicks
639- if ( closest ( '.expand-label' ) ) {
640625 event . preventDefault ( ) ;
641- toggleExpandShortcode ( event ) ;
626+ copyURI ( event ) ;
642627 return ;
643628 }
644-
629+
645630 // Homepage clicks
646- if ( closest ( '.home-link' ) ) {
647- goToHomepage ( event ) ;
631+ if ( target . classList . contains ( 'home-link' ) ) {
632+ event . preventDefault ( ) ;
633+ updateHistory ( "/" ) ;
648634 return ;
649635 }
650636
0 commit comments