You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dimmer.js 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. import $ from 'jquery';
  2. import {queryElemChildren} from '../../utils/dom.js';
  3. export function initFomanticDimmer() {
  4. // stand-in for removed dimmer module
  5. $.fn.dimmer = function (arg0, arg1) {
  6. if (arg0 === 'add content') {
  7. const $el = arg1;
  8. const existingDimmer = document.querySelector('body > .ui.dimmer');
  9. if (existingDimmer) {
  10. queryElemChildren(existingDimmer, '*', (el) => el.classList.add('hidden'));
  11. this._dimmer = existingDimmer;
  12. } else {
  13. this._dimmer = document.createElement('div');
  14. this._dimmer.classList.add('ui', 'dimmer');
  15. document.body.append(this._dimmer);
  16. }
  17. this._dimmer.append($el[0]);
  18. } else if (arg0 === 'get dimmer') {
  19. return $(this._dimmer);
  20. } else if (arg0 === 'show') {
  21. this._dimmer.classList.add('active');
  22. document.body.classList.add('tw-overflow-hidden');
  23. } else if (arg0 === 'hide') {
  24. const cb = arg1;
  25. this._dimmer.classList.remove('active');
  26. document.body.classList.remove('tw-overflow-hidden');
  27. cb();
  28. }
  29. return this;
  30. };
  31. }