| 1 | /* |
| 2 | Copyright - 2017 2023 - wwwouaiebe - Contact: https://www.ouaie.be/ |
| 3 | |
| 4 | This program is free software; |
| 5 | you can redistribute it and/or modify it under the terms of the |
| 6 | GNU General Public License as published by the Free Software Foundation; |
| 7 | either version 3 of the License, or any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | /* |
| 19 | Changes: |
| 20 | - v4.0.0: |
| 21 | - created from v3.6.0 |
| 22 | Doc reviewed 202208 |
| 23 | */ |
| 24 | |
| 25 | import ModalBaseDialog from '../baseDialog/ModalBaseDialog.js'; |
| 26 | import theHTMLElementsFactory from '../../core/uiLib/HTMLElementsFactory.js'; |
| 27 | |
| 28 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
| 29 | /** |
| 30 | A customizable text dialog with two buttons. |
| 31 | Create an instance of the dialog, then execute the show ( ) method. The Promise returned by the show ( ) method fullfil |
| 32 | when the first button is used and reject when the second button or the cancel button on the topbar is used |
| 33 | */ |
| 34 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
| 35 | |
| 36 | class TwoButtonsDialog extends ModalBaseDialog { |
| 37 | |
| 38 | /** |
| 39 | A html element with the text |
| 40 | @type {HTMLElement} |
| 41 | */ |
| 42 | |
| 43 | #textControl; |
| 44 | |
| 45 | /** |
| 46 | The constructor |
| 47 | @param {BaseDialogOptions|Object} options An Object with the needed options. See DialogOptions class. |
| 48 | */ |
| 49 | |
| 50 | constructor ( options ) { |
| 51 | super ( options ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | Create all the controls needed for the dialog. |
| 56 | Overload of the base class createContentHTML |
| 57 | */ |
| 58 | |
| 59 | createContentHTML ( ) { |
| 60 | this.#textControl = theHTMLElementsFactory.create ( |
| 61 | 'div', |
| 62 | { |
| 63 | textContent : this.options.text || '' |
| 64 | } |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | An array with the HTMLElements that have to be added in the content of the dialog. |
| 70 | Overload of the BaseDialog contentHTMLElements property. |
| 71 | @type {Array.<HTMLElement>} |
| 72 | */ |
| 73 | |
| 74 | get contentHTMLElements ( ) { |
| 75 | return [ this.#textControl ]; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | The title of the dialog. Overload of the BaseDialog title property. |
| 80 | @type {String} |
| 81 | */ |
| 82 | |
| 83 | get title ( ) { return this.options.title || ''; } |
| 84 | } |
| 85 | |
| 86 | export default TwoButtonsDialog; |
| 87 | |
| 88 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
| 89 |