gitea源码

repo-commit.ts 982B

123456789101112131415161718192021222324252627
  1. import {createTippy} from '../modules/tippy.ts';
  2. import {toggleElem} from '../utils/dom.ts';
  3. import {registerGlobalEventFunc, registerGlobalInitFunc} from '../modules/observer.ts';
  4. export function initRepoEllipsisButton() {
  5. registerGlobalEventFunc('click', 'onRepoEllipsisButtonClick', async (el: HTMLInputElement, e: Event) => {
  6. e.preventDefault();
  7. const expanded = el.getAttribute('aria-expanded') === 'true';
  8. toggleElem(el.parentElement.querySelector('.commit-body'));
  9. el.setAttribute('aria-expanded', String(!expanded));
  10. });
  11. }
  12. export function initCommitStatuses() {
  13. registerGlobalInitFunc('initCommitStatuses', (el: HTMLElement) => {
  14. const nextEl = el.nextElementSibling;
  15. if (!nextEl.matches('.tippy-target')) throw new Error('Expected next element to be a tippy target');
  16. createTippy(el, {
  17. content: nextEl,
  18. placement: 'bottom-start',
  19. interactive: true,
  20. role: 'dialog',
  21. theme: 'box-with-header',
  22. });
  23. });
  24. }