1
0
Fork 0
forked from forgejo/forgejo

Remove fomantic transition module (#26469)

Removes all dropdown and dimmer animations. Works everywhere as far as I
can tell, but need to give this thorough testing. Removes around 70kb
JS/CSS.

Note, I'm not 100% sure regarding the various callbacks, those will need
more investigation, but it appears to work nonetheless.

Fixes: https://github.com/go-gitea/gitea/issues/15709
This commit is contained in:
silverwind 2023-08-17 00:12:40 +02:00 committed by GitHub
parent 3b129aaa80
commit 376c0e25f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 3177 deletions

View file

@ -22,6 +22,43 @@ export function initGiteaFomantic() {
return escape(text, preserveHTML) + svg('octicon-x', 16, `${className.delete} icon`);
};
// stand-in for removed transition module
$.fn.transition = function (arg) {
if (arg === 'is supported') return true;
if (arg === 'is animating') return false;
if (arg === 'is inward') return false;
if (arg === 'is outward') return false;
if (arg === 'stop all') return;
const isIn = arg?.animation?.endsWith(' in');
const isOut = arg?.animation?.endsWith(' out');
let ret;
if (arg === 'show' || isIn) {
arg?.onStart?.(this);
ret = this.each((_, el) => {
el.classList.remove('hidden');
el.classList.add('visible');
if (isIn) el.classList.add('transition');
if (arg?.displayType) el.style.setProperty('display', arg.displayType, 'important');
arg?.onShow?.(this);
});
arg?.onComplete?.(this);
} else if (arg === 'hide' || isOut) {
arg?.onStart?.(this);
ret = this.each((_, el) => {
el.classList.add('hidden');
el.classList.remove('visible');
// don't remove the transition class because fomantic didn't do it either
el.style.removeProperty('display');
arg?.onHidden?.(this);
});
arg?.onComplete?.(this);
}
return ret;
};
initFomanticApiPatch();
// Use the patches to improve accessibility, these patches are designed to be as independent as possible, make it easy to modify or remove in the future.