mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
Revert some changes, and plan to complete the adaptation of the function in a new way of global-*.
This commit is contained in:
parent
c14f7a75d6
commit
bf83b2a1e5
@ -160,11 +160,7 @@ export function initGlobalButtons(): void {
|
||||
// There are a few cancel buttons in non-modal forms, and there are some dynamically created forms (eg: the "Edit Issue Content")
|
||||
addDelegatedEventListener(document, 'click', 'form button.ui.cancel.button', (_ /* el */, e) => e.preventDefault());
|
||||
|
||||
initTargetButtons(document);
|
||||
}
|
||||
|
||||
export function initTargetButtons(target: ParentNode): void {
|
||||
queryElems(target, '.show-panel', (el) => el.addEventListener('click', onShowPanelClick));
|
||||
queryElems(target, '.hide-panel', (el) => el.addEventListener('click', onHidePanelClick));
|
||||
queryElems(target, '.show-modal', (el) => el.addEventListener('click', onShowModalClick));
|
||||
queryElems(document, '.show-panel', (el) => el.addEventListener('click', onShowPanelClick));
|
||||
queryElems(document, '.hide-panel', (el) => el.addEventListener('click', onHidePanelClick));
|
||||
queryElems(document, '.show-modal', (el) => el.addEventListener('click', onShowModalClick));
|
||||
}
|
||||
|
@ -6,11 +6,7 @@ import {GET} from '../modules/fetch.ts';
|
||||
const {i18n} = window.config;
|
||||
|
||||
export function initCopyContent() {
|
||||
initTargetCopyContent(document);
|
||||
}
|
||||
|
||||
export function initTargetCopyContent(target: ParentNode) {
|
||||
const btn = target.querySelector('#copy-content');
|
||||
const btn = document.querySelector('#copy-content');
|
||||
if (!btn || btn.classList.contains('disabled')) return;
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
|
@ -2,11 +2,7 @@ import {createTippy} from '../modules/tippy.ts';
|
||||
import {toggleElem} from '../utils/dom.ts';
|
||||
|
||||
export function initRepoEllipsisButton() {
|
||||
initTargetRepoEllipsisButton(document);
|
||||
}
|
||||
|
||||
export function initTargetRepoEllipsisButton(target: ParentNode) {
|
||||
for (const button of target.querySelectorAll<HTMLButtonElement>('.js-toggle-commit-body')) {
|
||||
for (const button of document.querySelectorAll<HTMLButtonElement>('.js-toggle-commit-body')) {
|
||||
button.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
const expanded = this.getAttribute('aria-expanded') === 'true';
|
||||
|
@ -20,6 +20,12 @@ import {initRepoNew} from './repo-new.ts';
|
||||
import {createApp} from 'vue';
|
||||
import RepoBranchTagSelector from '../components/RepoBranchTagSelector.vue';
|
||||
|
||||
function initRepoBranchTagSelector(selector: string) {
|
||||
for (const elRoot of document.querySelectorAll(selector)) {
|
||||
createApp(RepoBranchTagSelector, {elRoot}).mount(elRoot);
|
||||
}
|
||||
}
|
||||
|
||||
export function initBranchSelectorTabs() {
|
||||
const elSelectBranches = document.querySelectorAll('.ui.dropdown.select-branch');
|
||||
for (const elSelectBranch of elSelectBranches) {
|
||||
@ -32,17 +38,11 @@ export function initBranchSelectorTabs() {
|
||||
}
|
||||
}
|
||||
|
||||
export function initTargetRepoBranchTagSelector(target: ParentNode, selector: string = '.js-branch-tag-selector') {
|
||||
for (const elRoot of target.querySelectorAll(selector)) {
|
||||
createApp(RepoBranchTagSelector, {elRoot}).mount(elRoot);
|
||||
}
|
||||
}
|
||||
|
||||
export function initRepository() {
|
||||
const pageContent = document.querySelector('.page-content.repository');
|
||||
if (!pageContent) return;
|
||||
|
||||
initTargetRepoBranchTagSelector(document);
|
||||
initRepoBranchTagSelector('.js-branch-tag-selector');
|
||||
initRepoCommentFormAndSidebar();
|
||||
|
||||
// Labels
|
||||
|
@ -2,12 +2,12 @@ import {createApp, ref} from 'vue';
|
||||
import {toggleElem} from '../utils/dom.ts';
|
||||
import {GET, PUT} from '../modules/fetch.ts';
|
||||
import ViewFileTree from '../components/ViewFileTree.vue';
|
||||
import {initMarkupContent} from '../markup/content.ts';
|
||||
import {initTargetRepoBranchTagSelector} from './repo-legacy.ts';
|
||||
import {initTargetRepoEllipsisButton} from './repo-commit.ts';
|
||||
import {initTargetPdfViewer} from '../render/pdf.ts';
|
||||
import {initTargetButtons} from './common-button.ts';
|
||||
import {initTargetCopyContent} from './copycontent.ts';
|
||||
// import {initMarkupContent} from '../markup/content.ts';
|
||||
// import {initTargetRepoBranchTagSelector} from './repo-legacy.ts';
|
||||
// import {initTargetRepoEllipsisButton} from './repo-commit.ts';
|
||||
// import {initTargetPdfViewer} from '../render/pdf.ts';
|
||||
// import {initTargetButtons} from './common-button.ts';
|
||||
// import {initTargetCopyContent} from './copycontent.ts';
|
||||
|
||||
async function toggleSidebar(visibility: boolean, isSigned: boolean) {
|
||||
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
|
||||
@ -58,13 +58,13 @@ function reloadContentScript(contentEl: Element) {
|
||||
contentEl.querySelector('.show-tree-sidebar-button').addEventListener('click', () => {
|
||||
toggleSidebar(true, document.querySelector('.repo-view-file-tree-sidebar').hasAttribute('data-is-signed'));
|
||||
});
|
||||
initMarkupContent();
|
||||
initTargetButtons(contentEl);
|
||||
// initMarkupContent();
|
||||
// initTargetButtons(contentEl);
|
||||
// initTargetDropdown(contentEl);
|
||||
initTargetPdfViewer(contentEl);
|
||||
initTargetRepoBranchTagSelector(contentEl);
|
||||
initTargetRepoEllipsisButton(contentEl);
|
||||
initTargetCopyContent(contentEl);
|
||||
// initTargetPdfViewer(contentEl);
|
||||
// initTargetRepoBranchTagSelector(contentEl);
|
||||
// initTargetRepoEllipsisButton(contentEl);
|
||||
// initTargetCopyContent(contentEl);
|
||||
}
|
||||
|
||||
export async function initViewFileTreeSidebar() {
|
||||
|
@ -1,11 +1,7 @@
|
||||
import {htmlEscape} from 'escape-goat';
|
||||
|
||||
export async function initPdfViewer() {
|
||||
initTargetPdfViewer(document);
|
||||
}
|
||||
|
||||
export async function initTargetPdfViewer(target: ParentNode) {
|
||||
const els = target.querySelectorAll('.pdf-content');
|
||||
const els = document.querySelectorAll('.pdf-content');
|
||||
if (!els.length) return;
|
||||
|
||||
const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
|
||||
|
Loading…
x
Reference in New Issue
Block a user