Skip to content

Commit bf83b2a

Browse files
committed
Revert some changes, and plan to complete the adaptation of the function in a new way of global-*.
1 parent c14f7a7 commit bf83b2a

File tree

6 files changed

+25
-41
lines changed

6 files changed

+25
-41
lines changed

web_src/js/features/common-button.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,7 @@ export function initGlobalButtons(): void {
160160
// There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content")
161161
addDelegatedEventListener(document, 'click', 'form button.ui.cancel.button', (_ /* el */, e) => e.preventDefault());
162162

163-
initTargetButtons(document);
164-
}
165-
166-
export function initTargetButtons(target: ParentNode): void {
167-
queryElems(target, '.show-panel', (el) => el.addEventListener('click', onShowPanelClick));
168-
queryElems(target, '.hide-panel', (el) => el.addEventListener('click', onHidePanelClick));
169-
queryElems(target, '.show-modal', (el) => el.addEventListener('click', onShowModalClick));
163+
queryElems(document, '.show-panel', (el) => el.addEventListener('click', onShowPanelClick));
164+
queryElems(document, '.hide-panel', (el) => el.addEventListener('click', onHidePanelClick));
165+
queryElems(document, '.show-modal', (el) => el.addEventListener('click', onShowModalClick));
170166
}

web_src/js/features/copycontent.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import {GET} from '../modules/fetch.ts';
66
const {i18n} = window.config;
77

88
export function initCopyContent() {
9-
initTargetCopyContent(document);
10-
}
11-
12-
export function initTargetCopyContent(target: ParentNode) {
13-
const btn = target.querySelector('#copy-content');
9+
const btn = document.querySelector('#copy-content');
1410
if (!btn || btn.classList.contains('disabled')) return;
1511

1612
btn.addEventListener('click', async () => {

web_src/js/features/repo-commit.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import {createTippy} from '../modules/tippy.ts';
22
import {toggleElem} from '../utils/dom.ts';
33

44
export function initRepoEllipsisButton() {
5-
initTargetRepoEllipsisButton(document);
6-
}
7-
8-
export function initTargetRepoEllipsisButton(target: ParentNode) {
9-
for (const button of target.querySelectorAll<HTMLButtonElement>('.js-toggle-commit-body')) {
5+
for (const button of document.querySelectorAll<HTMLButtonElement>('.js-toggle-commit-body')) {
106
button.addEventListener('click', function (e) {
117
e.preventDefault();
128
const expanded = this.getAttribute('aria-expanded') === 'true';

web_src/js/features/repo-legacy.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import {initRepoNew} from './repo-new.ts';
2020
import {createApp} from 'vue';
2121
import RepoBranchTagSelector from '../components/RepoBranchTagSelector.vue';
2222

23+
function initRepoBranchTagSelector(selector: string) {
24+
for (const elRoot of document.querySelectorAll(selector)) {
25+
createApp(RepoBranchTagSelector, {elRoot}).mount(elRoot);
26+
}
27+
}
28+
2329
export function initBranchSelectorTabs() {
2430
const elSelectBranches = document.querySelectorAll('.ui.dropdown.select-branch');
2531
for (const elSelectBranch of elSelectBranches) {
@@ -32,17 +38,11 @@ export function initBranchSelectorTabs() {
3238
}
3339
}
3440

35-
export function initTargetRepoBranchTagSelector(target: ParentNode, selector: string = '.js-branch-tag-selector') {
36-
for (const elRoot of target.querySelectorAll(selector)) {
37-
createApp(RepoBranchTagSelector, {elRoot}).mount(elRoot);
38-
}
39-
}
40-
4141
export function initRepository() {
4242
const pageContent = document.querySelector('.page-content.repository');
4343
if (!pageContent) return;
4444

45-
initTargetRepoBranchTagSelector(document);
45+
initRepoBranchTagSelector('.js-branch-tag-selector');
4646
initRepoCommentFormAndSidebar();
4747

4848
// Labels

web_src/js/features/repo-view-file-tree-sidebar.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import {createApp, ref} from 'vue';
22
import {toggleElem} from '../utils/dom.ts';
33
import {GET, PUT} from '../modules/fetch.ts';
44
import ViewFileTree from '../components/ViewFileTree.vue';
5-
import {initMarkupContent} from '../markup/content.ts';
6-
import {initTargetRepoBranchTagSelector} from './repo-legacy.ts';
7-
import {initTargetRepoEllipsisButton} from './repo-commit.ts';
8-
import {initTargetPdfViewer} from '../render/pdf.ts';
9-
import {initTargetButtons} from './common-button.ts';
10-
import {initTargetCopyContent} from './copycontent.ts';
5+
// import {initMarkupContent} from '../markup/content.ts';
6+
// import {initTargetRepoBranchTagSelector} from './repo-legacy.ts';
7+
// import {initTargetRepoEllipsisButton} from './repo-commit.ts';
8+
// import {initTargetPdfViewer} from '../render/pdf.ts';
9+
// import {initTargetButtons} from './common-button.ts';
10+
// import {initTargetCopyContent} from './copycontent.ts';
1111

1212
async function toggleSidebar(visibility: boolean, isSigned: boolean) {
1313
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
@@ -58,13 +58,13 @@ function reloadContentScript(contentEl: Element) {
5858
contentEl.querySelector('.show-tree-sidebar-button').addEventListener('click', () => {
5959
toggleSidebar(true, document.querySelector('.repo-view-file-tree-sidebar').hasAttribute('data-is-signed'));
6060
});
61-
initMarkupContent();
62-
initTargetButtons(contentEl);
61+
// initMarkupContent();
62+
// initTargetButtons(contentEl);
6363
// initTargetDropdown(contentEl);
64-
initTargetPdfViewer(contentEl);
65-
initTargetRepoBranchTagSelector(contentEl);
66-
initTargetRepoEllipsisButton(contentEl);
67-
initTargetCopyContent(contentEl);
64+
// initTargetPdfViewer(contentEl);
65+
// initTargetRepoBranchTagSelector(contentEl);
66+
// initTargetRepoEllipsisButton(contentEl);
67+
// initTargetCopyContent(contentEl);
6868
}
6969

7070
export async function initViewFileTreeSidebar() {

web_src/js/render/pdf.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import {htmlEscape} from 'escape-goat';
22

33
export async function initPdfViewer() {
4-
initTargetPdfViewer(document);
5-
}
6-
7-
export async function initTargetPdfViewer(target: ParentNode) {
8-
const els = target.querySelectorAll('.pdf-content');
4+
const els = document.querySelectorAll('.pdf-content');
95
if (!els.length) return;
106

117
const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');

0 commit comments

Comments
 (0)