JC Brand 1 неделя назад
Родитель
Сommit
70ed0263cc
1 измененных файлов с 23 добавлено и 24 удалено
  1. 23 24
      src/plugins/modal/modal.js

+ 23 - 24
src/plugins/modal/modal.js

@@ -1,10 +1,10 @@
 import { html } from 'lit';
-import Modal from "bootstrap/js/src/modal.js";
+import Modal from 'bootstrap/js/src/modal.js';
 import { getOpenPromise } from '@converse/openpromise';
-import { Model} from '@converse/skeletor';
+import { Model } from '@converse/skeletor';
 import { CustomElement } from 'shared/components/element.js';
 import { u } from '@converse/headless';
-import { modal_close_button } from "./templates/buttons.js";
+import { modal_close_button } from './templates/buttons.js';
 import tplModal from './templates/modal.js';
 
 import './styles/_modal.scss';
@@ -14,10 +14,10 @@ class BaseModal extends CustomElement {
      * @typedef {import('lit').TemplateResult} TemplateResult
      */
 
-    static get properties () {
+    static get properties() {
         return {
             model: { type: Model },
-        }
+        };
     }
 
     /** @type {Modal} */
@@ -26,18 +26,18 @@ class BaseModal extends CustomElement {
     /**
      * @param {Object} options
      */
-    constructor (options) {
+    constructor(options) {
         super();
         this.model = null;
         this.className = u.isTestEnv() ? 'modal' : 'modal fade';
         this.tabIndex = -1;
         this.ariaHidden = 'true';
 
-        this.onKeyDown = /** @param {KeyboardEvent} ev */(ev) => {
+        this.onKeyDown = /** @param {KeyboardEvent} ev */ (ev) => {
             if (ev.key === 'Escape' && this.ariaHidden === 'false') {
                 this.close();
             }
-        }
+        };
 
         this.initialized = getOpenPromise();
 
@@ -63,26 +63,25 @@ class BaseModal extends CustomElement {
         super.disconnectedCallback();
     }
 
-
-    get modal () {
+    get modal() {
         if (!this.#modal) {
             this.#modal = new Modal(this, {
                 backdrop: u.isTestEnv() ? false : true,
-                keyboard: true
+                keyboard: true,
             });
         }
         return this.#modal;
     }
 
-    initialize () {
-        this.requestUpdate()
+    initialize() {
+        this.requestUpdate();
         this.initialized.resolve();
     }
 
     /**
      * @returns {TemplateResult|string}
      */
-    renderModal () {
+    renderModal() {
         return '';
     }
 
@@ -90,17 +89,17 @@ class BaseModal extends CustomElement {
      * @returns {TemplateResult|string}
      */
     renderModalFooter() {
-        return html`<div class="modal-footer">${ modal_close_button }</div>`;
+        return html`<div class="modal-footer">${modal_close_button}</div>`;
     }
 
-    render () {
+    render() {
         return tplModal(this);
     }
 
     /**
      * @returns {string|TemplateResult}
      */
-    getModalTitle () {
+    getModalTitle() {
         // Intended to be overwritten
         return '';
     }
@@ -108,19 +107,19 @@ class BaseModal extends CustomElement {
     /**
      * @param {Event} [ev]
      */
-    switchTab (ev) {
+    switchTab(ev) {
         ev?.stopPropagation();
         ev?.preventDefault();
-        this.tab = /** @type {HTMLElement} */(ev.target).getAttribute('data-name');
+        this.tab = /** @type {HTMLElement} */ (ev.target).getAttribute('data-name');
         this.requestUpdate();
     }
 
-    close () {
+    close() {
         this.modal.hide();
     }
 
-    insertIntoDOM () {
-        const container_el = document.querySelector("#converse-modals");
+    insertIntoDOM() {
+        const container_el = document.querySelector('#converse-modals');
         container_el.insertAdjacentElement('beforeend', this);
     }
 
@@ -128,14 +127,14 @@ class BaseModal extends CustomElement {
      * @param {string} message
      * @param {'primary'|'secondary'|'danger'} type
      */
-    alert (message, type='primary') {
+    alert(message, type = 'primary') {
         this.model.set('alert', { message, type });
         setTimeout(() => {
             this.model.set('alert', undefined);
         }, 5000);
     }
 
-    async show () {
+    async show() {
         await this.initialized;
         this.modal.show();
         this.requestUpdate();