mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
Replace Fomantic's hard-forked jQuery modal with native `<dialog>` elements, advancing https://github.com/go-gitea/gitea/issues/29849. The UI is visually unchanged. Dialogs open with `show()` over an `inert` page, so tooltips, popups and toasts mounted on `<body>` stay usable above them, unlike with `showModal()` (https://github.com/whatwg/html/issues/9936). - Remove the Fomantic modal and dimmer, add `showModal` and `hideModal` - Declare modals as `<dialog class="modal-dialog">`, shown inside a `.modal-backdrop`, instead of `ui modal` with its unused size classes - Remove two modals that could never be opened - Block the page while a modal is open, close the topmost one on Escape and restore focus to its opener - Allow stacked modals, use a confirm modal instead of `window.confirm` for deleting content history - Hide popups and toasts when a modal opens or closes - Keep the release notes modal open when generating notes fails Fixes: https://github.com/go-gitea/gitea/issues/39643 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
export function initFomanticTransition() {
|
|
// stand-in for removed transition module
|
|
$.fn.transition = function (arg0: any) {
|
|
if (arg0 === 'is supported') return true;
|
|
if (arg0 === 'is animating') return false;
|
|
if (arg0 === 'is inward') return false;
|
|
if (arg0 === 'is outward') return false;
|
|
|
|
let argObj: Record<string, any>;
|
|
if (typeof arg0 === 'string') {
|
|
if (arg0 === 'stop all') return this;
|
|
argObj = {animation: arg0};
|
|
} else if (typeof arg0 === 'object') {
|
|
argObj = arg0;
|
|
} else {
|
|
throw new Error(`invalid argument: ${arg0}`);
|
|
}
|
|
|
|
const isAnimationIn = argObj.animation?.startsWith('show') || argObj.animation?.endsWith(' in');
|
|
const isAnimationOut = argObj.animation?.startsWith('hide') || argObj.animation?.endsWith(' out');
|
|
this.each((_, el) => {
|
|
let toShow = isAnimationIn;
|
|
if (!isAnimationIn && !isAnimationOut) {
|
|
// If the animation is not in/out, then it must be a toggle animation.
|
|
// Fomantic uses computed styles to check "visibility", but to avoid unnecessary arguments, here it only checks the class.
|
|
toShow = this.hasClass('hidden'); // maybe it could also check "!this.hasClass('visible')", leave it to the future until there is a real problem.
|
|
}
|
|
argObj.onStart?.call(el);
|
|
if (toShow) {
|
|
el.classList.remove('hidden');
|
|
el.classList.add('visible', 'transition');
|
|
if (argObj.displayType) el.style.setProperty('display', argObj.displayType, 'important');
|
|
} else {
|
|
el.classList.add('hidden');
|
|
el.classList.remove('visible'); // don't remove the transition class because the Fomantic animation style is `.hidden.transition`.
|
|
el.style.removeProperty('display');
|
|
}
|
|
argObj.onComplete?.call(el);
|
|
});
|
|
return this;
|
|
};
|
|
}
|