mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-15 17:28:22 +08:00
Refactor buttons to use new init framework (#33774)
Make buttons to use new init framework * "js-toggle-commit-body" * "show-panel/hide-panel/show-modal" * "copy-content" --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@ -1,15 +1,14 @@
|
||||
import {createTippy} from '../modules/tippy.ts';
|
||||
import {toggleElem} from '../utils/dom.ts';
|
||||
import {registerGlobalEventFunc} from '../modules/observer.ts';
|
||||
|
||||
export function initRepoEllipsisButton() {
|
||||
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';
|
||||
toggleElem(this.parentElement.querySelector('.commit-body'));
|
||||
this.setAttribute('aria-expanded', String(!expanded));
|
||||
});
|
||||
}
|
||||
registerGlobalEventFunc('click', 'onRepoEllipsisButtonClick', async (el: HTMLInputElement, e: Event) => {
|
||||
e.preventDefault();
|
||||
const expanded = el.getAttribute('aria-expanded') === 'true';
|
||||
toggleElem(el.parentElement.querySelector('.commit-body'));
|
||||
el.setAttribute('aria-expanded', String(!expanded));
|
||||
});
|
||||
}
|
||||
|
||||
export function initCommitStatuses() {
|
||||
|
Reference in New Issue
Block a user