This commit is contained in:
silverwind 2024-04-26 23:20:17 +02:00
parent ea07720a9b
commit 623da66687
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
2 changed files with 14 additions and 8 deletions

View File

@ -2,6 +2,7 @@
.ui.dimmer { .ui.dimmer {
position: fixed; position: fixed;
display: none;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
@ -12,6 +13,8 @@
overflow-y: auto; overflow-y: auto;
justify-content: center; justify-content: center;
padding: 8px 0; padding: 8px 0;
transition: opacity 1s ease;
user-select: none;
} }
.ui.active.dimmer { .ui.active.dimmer {
@ -21,5 +24,5 @@
.ui.dimmer > * { .ui.dimmer > * {
position: static; position: static;
margin: auto !important; margin: auto 0 !important;
} }

View File

@ -1,24 +1,27 @@
import $ from 'jquery'; import $ from 'jquery';
import {showElem, hideElem, queryElemChildren} from '../../utils/dom.js'; import {queryElemChildren} from '../../utils/dom.js';
export function initFomanticDimmer() { export function initFomanticDimmer() {
// stand-in for removed dimmer module // stand-in for removed dimmer module
$.fn.dimmer = function (arg0, $el) { $.fn.dimmer = function (arg0, $el) {
if (arg0 === 'add content') { if (arg0 === 'add content') {
this._dimmer = document.createElement('div'); const existingDimmer = document.querySelector('body > .ui.dimmer');
queryElemChildren(document.body, '.ui.dimmer', (el) => el.remove()); if (existingDimmer) {
this._dimmer.classList.add('ui', 'dimmer', 'tw-hidden'); queryElemChildren(existingDimmer, '*', (el) => el.remove());
this._dimmer = existingDimmer;
} else {
this._dimmer = document.createElement('div');
this._dimmer.classList.add('ui', 'dimmer');
document.body.append(this._dimmer);
}
this._dimmer.append($el[0]); this._dimmer.append($el[0]);
document.body.append(this._dimmer);
} else if (arg0 === 'get dimmer') { } else if (arg0 === 'get dimmer') {
return $(this._dimmer); return $(this._dimmer);
} else if (arg0 === 'show') { } else if (arg0 === 'show') {
this._dimmer.classList.add('active'); this._dimmer.classList.add('active');
showElem(this._dimmer);
document.body.classList.add('tw-overflow-hidden'); document.body.classList.add('tw-overflow-hidden');
} else if (arg0 === 'hide') { } else if (arg0 === 'hide') {
this._dimmer.classList.remove('active'); this._dimmer.classList.remove('active');
hideElem(this._dimmer);
document.body.classList.remove('tw-overflow-hidden'); document.body.classList.remove('tw-overflow-hidden');
} }
return this; return this;