mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-26 23:35:20 +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")
|
// 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());
|
addDelegatedEventListener(document, 'click', 'form button.ui.cancel.button', (_ /* el */, e) => e.preventDefault());
|
||||||
|
|
||||||
initTargetButtons(document);
|
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));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,7 @@ import {GET} from '../modules/fetch.ts';
|
|||||||
const {i18n} = window.config;
|
const {i18n} = window.config;
|
||||||
|
|
||||||
export function initCopyContent() {
|
export function initCopyContent() {
|
||||||
initTargetCopyContent(document);
|
const btn = document.querySelector('#copy-content');
|
||||||
}
|
|
||||||
|
|
||||||
export function initTargetCopyContent(target: ParentNode) {
|
|
||||||
const btn = target.querySelector('#copy-content');
|
|
||||||
if (!btn || btn.classList.contains('disabled')) return;
|
if (!btn || btn.classList.contains('disabled')) return;
|
||||||
|
|
||||||
btn.addEventListener('click', async () => {
|
btn.addEventListener('click', async () => {
|
||||||
|
@ -2,11 +2,7 @@ import {createTippy} from '../modules/tippy.ts';
|
|||||||
import {toggleElem} from '../utils/dom.ts';
|
import {toggleElem} from '../utils/dom.ts';
|
||||||
|
|
||||||
export function initRepoEllipsisButton() {
|
export function initRepoEllipsisButton() {
|
||||||
initTargetRepoEllipsisButton(document);
|
for (const button of document.querySelectorAll<HTMLButtonElement>('.js-toggle-commit-body')) {
|
||||||
}
|
|
||||||
|
|
||||||
export function initTargetRepoEllipsisButton(target: ParentNode) {
|
|
||||||
for (const button of target.querySelectorAll<HTMLButtonElement>('.js-toggle-commit-body')) {
|
|
||||||
button.addEventListener('click', function (e) {
|
button.addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const expanded = this.getAttribute('aria-expanded') === 'true';
|
const expanded = this.getAttribute('aria-expanded') === 'true';
|
||||||
|
@ -20,6 +20,12 @@ import {initRepoNew} from './repo-new.ts';
|
|||||||
import {createApp} from 'vue';
|
import {createApp} from 'vue';
|
||||||
import RepoBranchTagSelector from '../components/RepoBranchTagSelector.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() {
|
export function initBranchSelectorTabs() {
|
||||||
const elSelectBranches = document.querySelectorAll('.ui.dropdown.select-branch');
|
const elSelectBranches = document.querySelectorAll('.ui.dropdown.select-branch');
|
||||||
for (const elSelectBranch of elSelectBranches) {
|
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() {
|
export function initRepository() {
|
||||||
const pageContent = document.querySelector('.page-content.repository');
|
const pageContent = document.querySelector('.page-content.repository');
|
||||||
if (!pageContent) return;
|
if (!pageContent) return;
|
||||||
|
|
||||||
initTargetRepoBranchTagSelector(document);
|
initRepoBranchTagSelector('.js-branch-tag-selector');
|
||||||
initRepoCommentFormAndSidebar();
|
initRepoCommentFormAndSidebar();
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
|
@ -2,12 +2,12 @@ import {createApp, ref} from 'vue';
|
|||||||
import {toggleElem} from '../utils/dom.ts';
|
import {toggleElem} from '../utils/dom.ts';
|
||||||
import {GET, PUT} from '../modules/fetch.ts';
|
import {GET, PUT} from '../modules/fetch.ts';
|
||||||
import ViewFileTree from '../components/ViewFileTree.vue';
|
import ViewFileTree from '../components/ViewFileTree.vue';
|
||||||
import {initMarkupContent} from '../markup/content.ts';
|
// import {initMarkupContent} from '../markup/content.ts';
|
||||||
import {initTargetRepoBranchTagSelector} from './repo-legacy.ts';
|
// import {initTargetRepoBranchTagSelector} from './repo-legacy.ts';
|
||||||
import {initTargetRepoEllipsisButton} from './repo-commit.ts';
|
// import {initTargetRepoEllipsisButton} from './repo-commit.ts';
|
||||||
import {initTargetPdfViewer} from '../render/pdf.ts';
|
// import {initTargetPdfViewer} from '../render/pdf.ts';
|
||||||
import {initTargetButtons} from './common-button.ts';
|
// import {initTargetButtons} from './common-button.ts';
|
||||||
import {initTargetCopyContent} from './copycontent.ts';
|
// import {initTargetCopyContent} from './copycontent.ts';
|
||||||
|
|
||||||
async function toggleSidebar(visibility: boolean, isSigned: boolean) {
|
async function toggleSidebar(visibility: boolean, isSigned: boolean) {
|
||||||
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
|
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', () => {
|
contentEl.querySelector('.show-tree-sidebar-button').addEventListener('click', () => {
|
||||||
toggleSidebar(true, document.querySelector('.repo-view-file-tree-sidebar').hasAttribute('data-is-signed'));
|
toggleSidebar(true, document.querySelector('.repo-view-file-tree-sidebar').hasAttribute('data-is-signed'));
|
||||||
});
|
});
|
||||||
initMarkupContent();
|
// initMarkupContent();
|
||||||
initTargetButtons(contentEl);
|
// initTargetButtons(contentEl);
|
||||||
// initTargetDropdown(contentEl);
|
// initTargetDropdown(contentEl);
|
||||||
initTargetPdfViewer(contentEl);
|
// initTargetPdfViewer(contentEl);
|
||||||
initTargetRepoBranchTagSelector(contentEl);
|
// initTargetRepoBranchTagSelector(contentEl);
|
||||||
initTargetRepoEllipsisButton(contentEl);
|
// initTargetRepoEllipsisButton(contentEl);
|
||||||
initTargetCopyContent(contentEl);
|
// initTargetCopyContent(contentEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initViewFileTreeSidebar() {
|
export async function initViewFileTreeSidebar() {
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import {htmlEscape} from 'escape-goat';
|
import {htmlEscape} from 'escape-goat';
|
||||||
|
|
||||||
export async function initPdfViewer() {
|
export async function initPdfViewer() {
|
||||||
initTargetPdfViewer(document);
|
const els = document.querySelectorAll('.pdf-content');
|
||||||
}
|
|
||||||
|
|
||||||
export async function initTargetPdfViewer(target: ParentNode) {
|
|
||||||
const els = target.querySelectorAll('.pdf-content');
|
|
||||||
if (!els.length) return;
|
if (!els.length) return;
|
||||||
|
|
||||||
const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
|
const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user