@@ -98,9 +98,70 @@ const mobileMenu = (() => {
9898 toggleMenu ( 'products-mobile-menu' , 'productsMobileMenuState' )
9999 } else if ( event . target . closest ( '[data-resources-mobile-menu-toggle]' ) ) {
100100 toggleMenu ( 'resources-mobile-menu' , 'resourcesMobileMenuState' )
101+ } else if ( event . target . closest ( '.header-link' ) ) {
102+ // Handle header link clicks
103+ event . preventDefault ( )
104+ copyHeaderLinkToClipboard ( event . target . closest ( '.header-link' ) )
101105 }
102106 }
103107
108+ // Copy header link URL to clipboard
109+ function copyHeaderLinkToClipboard ( linkElement ) {
110+ const href = linkElement . getAttribute ( 'href' )
111+ const fullUrl = window . location . origin + window . location . pathname + href
112+
113+ if ( navigator . clipboard && navigator . clipboard . writeText ) {
114+ navigator . clipboard . writeText ( fullUrl ) . then ( ( ) => {
115+ showCopyFeedback ( linkElement )
116+ } ) . catch ( err => {
117+ console . error ( 'Failed to copy link: ' , err )
118+ fallbackCopyToClipboard ( fullUrl , linkElement )
119+ } )
120+ } else {
121+ // Fallback for older browsers
122+ fallbackCopyToClipboard ( fullUrl , linkElement )
123+ }
124+ }
125+
126+ // Show visual feedback when link is copied
127+ function showCopyFeedback ( linkElement ) {
128+ const originalTitle = linkElement . getAttribute ( 'title' )
129+
130+ linkElement . setAttribute ( 'title' , 'Copied!' )
131+ linkElement . classList . add ( 'copied' )
132+
133+ setTimeout ( ( ) => {
134+ linkElement . setAttribute ( 'title' , originalTitle )
135+ linkElement . classList . remove ( 'copied' )
136+ } , 1500 )
137+ }
138+
139+ // Fallback copy method for older browsers
140+ function fallbackCopyToClipboard ( text , linkElement ) {
141+ const textArea = document . createElement ( 'textarea' )
142+ textArea . value = text
143+ textArea . style . position = 'fixed'
144+ textArea . style . left = '-999999px'
145+ textArea . style . top = '-999999px'
146+ document . body . appendChild ( textArea )
147+ textArea . focus ( )
148+ textArea . select ( )
149+
150+ try {
151+ const successful = document . execCommand ( 'copy' )
152+ if ( successful ) {
153+ showCopyFeedback ( linkElement )
154+ console . log ( 'Link copied to clipboard (fallback)' )
155+ } else {
156+ console . error ( 'Fallback copy failed' )
157+ }
158+ } catch ( err ) {
159+ console . error ( 'Fallback copy failed: ' , err )
160+ }
161+
162+ document . body . removeChild ( textArea )
163+ }
164+
104165 function allowFocus ( selector , state ) {
105166 const container = document . querySelector ( selector )
106167 const focusable = container . querySelectorAll ( 'button, [href], input, select, textarea' )
0 commit comments