Skip to content

Commit a4b0b0e

Browse files
committed
improve
1 parent 8a865de commit a4b0b0e

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

web_src/js/features/citation.ts

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

web_src/js/features/repo-home.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import {fomanticQuery} from '../modules/fomantic/base.ts';
77
const {appSubUrl} = window.config;
88

99
export function initRepoTopicBar() {
10-
const mgrBtns = document.querySelectorAll<HTMLButtonElement>('#manage_topic');
11-
if (mgrBtns.length === 0) return;
10+
const mgrBtnMobile = document.querySelector<HTMLButtonElement>('.only-mobile #manage_topic');
11+
const mgrBtnDesktop = document.querySelector<HTMLButtonElement>('.not-mobile #manage_topic');
12+
13+
for (const mgrBtn of [mgrBtnMobile, mgrBtnDesktop]) {
14+
if (!mgrBtn) continue;
1215

13-
for (const mgrBtn of mgrBtns) {
1416
const editDiv = mgrBtn.parentNode.querySelector('#topic_edit');
1517
const viewDiv = mgrBtn.parentNode.querySelector('#repo-topics');
1618
const topicDropdown = editDiv.querySelector('.ui.dropdown');

0 commit comments

Comments
 (0)