@@ -42,34 +42,38 @@ export async function initCitationFileCopyContent() {
4242 citationCopyApa . classList . toggle ( 'primary' , ! isBibtex ) ;
4343 } ;
4444
45- document . querySelector ( '#cite-repo-button' ) ?. addEventListener ( 'click' , async ( ) => {
46- fomanticQuery ( elModal ) . modal ( 'show' ) ;
47- elModal . classList . add ( 'is-loading' ) ;
45+ const citeBtnMobile = document . querySelector < HTMLButtonElement > ( '.only-mobile #cite-repo-button' ) ;
46+ const citeBtnDesktop = document . querySelector < HTMLButtonElement > ( '.not-mobile #cite-repo-button' ) ;
47+ for ( const citeBtn of [ citeBtnMobile , citeBtnDesktop ] ) {
48+ citeBtn ?. addEventListener ( 'click' , async ( ) => {
49+ fomanticQuery ( elModal ) . modal ( 'show' ) ;
50+ elModal . classList . add ( 'is-loading' ) ;
4851
49- try {
5052 try {
51- await initInputCitationValue ( citationCopyApa , citationCopyBibtex ) ;
52- } catch ( e ) {
53- console . error ( `initCitationFileCopyContent error: ${ e } ` , e ) ;
54- return ;
55- }
56- updateUi ( ) ;
57-
58- citationCopyApa . addEventListener ( 'click' , ( ) => {
59- localStorage . setItem ( 'citation-copy-format' , 'apa' ) ;
53+ try {
54+ await initInputCitationValue ( citationCopyApa , citationCopyBibtex ) ;
55+ } catch ( e ) {
56+ console . error ( `initCitationFileCopyContent error: ${ e } ` , e ) ;
57+ return ;
58+ }
6059 updateUi ( ) ;
61- } ) ;
6260
63- citationCopyBibtex . addEventListener ( 'click' , ( ) => {
64- localStorage . setItem ( 'citation-copy-format' , 'bibtex ' ) ;
65- updateUi ( ) ;
66- } ) ;
61+ citationCopyApa . addEventListener ( 'click' , ( ) => {
62+ localStorage . setItem ( 'citation-copy-format' , 'apa ' ) ;
63+ updateUi ( ) ;
64+ } ) ;
6765
68- inputContent . addEventListener ( 'click' , ( ) => {
69- inputContent . select ( ) ;
70- } ) ;
71- } finally {
72- elModal . classList . remove ( 'is-loading' ) ;
73- }
74- } ) ;
66+ citationCopyBibtex . addEventListener ( 'click' , ( ) => {
67+ localStorage . setItem ( 'citation-copy-format' , 'bibtex' ) ;
68+ updateUi ( ) ;
69+ } ) ;
70+
71+ inputContent . addEventListener ( 'click' , ( ) => {
72+ inputContent . select ( ) ;
73+ } ) ;
74+ } finally {
75+ elModal . classList . remove ( 'is-loading' ) ;
76+ }
77+ } ) ;
78+ }
7579}
0 commit comments