| 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 theHTMLElementsFactory from '../../../core/uiLib/HTMLElementsFactory.js'; |
| 26 | import theTranslator from '../../../core/uiLib/Translator.js'; |
| 27 | import { ICON_DIMENSIONS } from '../../../main/Constants.js'; |
| 28 | import BaseControl from '../../../controls/baseControl/BaseControl.js'; |
| 29 | |
| 30 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
| 31 | /** |
| 32 | This class is the icnWidth and iconHeight control of the NoteDialog |
| 33 | */ |
| 34 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
| 35 | |
| 36 | class NoteDialogIconDimsControl extends BaseControl { |
| 37 | |
| 38 | /** |
| 39 | The width input |
| 40 | @type {HTMLElement} |
| 41 | */ |
| 42 | |
| 43 | #iconWidthInput = null; |
| 44 | |
| 45 | /** |
| 46 | The height input |
| 47 | @type {HTMLElement} |
| 48 | */ |
| 49 | |
| 50 | #iconHeightInput = null; |
| 51 | |
| 52 | /** |
| 53 | The constructor |
| 54 | @param {NoteDialogEventListeners} eventListeners A reference to the eventListeners object of the NoteDialog |
| 55 | */ |
| 56 | |
| 57 | constructor ( eventListeners ) { |
| 58 | |
| 59 | super ( ); |
| 60 | |
| 61 | // HTMLElements creation |
| 62 | theHTMLElementsFactory.create ( |
| 63 | 'text', |
| 64 | { |
| 65 | value : theTranslator.getText ( 'NoteDialogIconDimsControl - Icon width' ) |
| 66 | }, |
| 67 | this.controlHTMLElement |
| 68 | ); |
| 69 | this.#iconWidthInput = theHTMLElementsFactory.create ( |
| 70 | 'input', |
| 71 | { |
| 72 | type : 'number', |
| 73 | className : 'TravelNotes-NoteDialog-NumberInput', |
| 74 | value : ICON_DIMENSIONS.width, |
| 75 | dataset : { Name : 'iconWidth' } |
| 76 | }, |
| 77 | this.controlHTMLElement |
| 78 | ); |
| 79 | |
| 80 | theHTMLElementsFactory.create ( |
| 81 | 'text', |
| 82 | { |
| 83 | value : theTranslator.getText ( 'NoteDialogIconDimsControl - Icon height' ) |
| 84 | }, |
| 85 | this.controlHTMLElement |
| 86 | ); |
| 87 | this.#iconHeightInput = theHTMLElementsFactory.create ( |
| 88 | 'input', |
| 89 | { |
| 90 | type : 'number', |
| 91 | className : 'TravelNotes-NoteDialog-NumberInput', |
| 92 | value : ICON_DIMENSIONS.height, |
| 93 | dataset : { Name : 'iconHeight' } |
| 94 | }, |
| 95 | this.controlHTMLElement |
| 96 | ); |
| 97 | |
| 98 | // event listeners |
| 99 | this.#iconWidthInput.addEventListener ( 'input', eventListeners.controlInput ); |
| 100 | this.#iconHeightInput.addEventListener ( 'input', eventListeners.controlInput ); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | Remove event listeners |
| 105 | @param {NoteDialogEventListeners} eventListeners A reference to the eventListeners object of the NoteDialog |
| 106 | */ |
| 107 | |
| 108 | destructor ( eventListeners ) { |
| 109 | this.#iconWidthInput.removeEventListener ( 'input', eventListeners.controlInput ); |
| 110 | this.#iconHeightInput.removeEventListener ( 'input', eventListeners.controlInput ); |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | The icon width value in the control |
| 115 | @type {Number} |
| 116 | */ |
| 117 | |
| 118 | get iconWidth ( ) { return Number.parseInt ( this.#iconWidthInput.value ); } |
| 119 | |
| 120 | set iconWidth ( value ) { this.#iconWidthInput.value = value; } |
| 121 | |
| 122 | /** |
| 123 | The icon width height in the control |
| 124 | @type {Number} |
| 125 | */ |
| 126 | |
| 127 | get iconHeight ( ) { return Number.parseInt ( this.#iconHeightInput.value ); } |
| 128 | |
| 129 | set iconHeight ( value ) { this.#iconHeightInput.value = value; } |
| 130 | |
| 131 | } |
| 132 | |
| 133 | export default NoteDialogIconDimsControl; |
| 134 | |
| 135 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
| 136 |