| 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 theHTMLSanitizer from '../../../core/htmlSanitizer/HTMLSanitizer.js';  | 
| 26 | |
| 27 | import { ICON_DIMENSIONS } from '../../../main/Constants.js';  | 
| 28 | |
| 29 | /* ------------------------------------------------------------------------------------------------------------------------- */ | 
| 30 | /** | 
| 31 | Simple container for predefined icons data of the NoteDialogToolbar | 
| 32 | */ | 
| 33 | /* ------------------------------------------------------------------------------------------------------------------------- */ | 
| 34 | |
| 35 | class PredefinedIconData {  | 
| 36 | |
| 37 |     /** | 
| 38 |     The name of the predefined icon. This name will be displayed in the select of the NoteDialogToolbar | 
| 39 |     @type {String} | 
| 40 |     */ | 
| 41 | |
| 42 | #name;  | 
| 43 | |
| 44 |     /** | 
| 45 |     The html definition of the predefined icon | 
| 46 |     @type {String} | 
| 47 |     */ | 
| 48 | |
| 49 | #icon;  | 
| 50 | |
| 51 |     /** | 
| 52 |     The tooltip of the predefined icon | 
| 53 |     @type {String} | 
| 54 |     */ | 
| 55 | |
| 56 | #tooltip;  | 
| 57 | |
| 58 |     /** | 
| 59 |     The width of the predefined icon | 
| 60 |     @type {Number} | 
| 61 |     */ | 
| 62 | |
| 63 | #width;  | 
| 64 | |
| 65 |     /** | 
| 66 |     The height of the predefined icon | 
| 67 |     @type {Number} | 
| 68 |     */ | 
| 69 | |
| 70 | #height;  | 
| 71 | |
| 72 |     /** | 
| 73 |     The constructor | 
| 74 |     @param {JsonObject} jsonPredefinedIconData A json object with the data for the predefined icon | 
| 75 |     */ | 
| 76 | |
| 77 |     constructor ( jsonPredefinedIconData ) { | 
| 78 |         this.#name = | 
| 79 |             'string' === typeof ( jsonPredefinedIconData?.name ) | 
| 80 | ?  | 
| 81 | theHTMLSanitizer.sanitizeToJsString ( jsonPredefinedIconData.name )  | 
| 82 | :  | 
| 83 |                 '?'; | 
| 84 |         this.#icon = | 
| 85 |             'string' === typeof ( jsonPredefinedIconData.icon ) | 
| 86 | ?  | 
| 87 | theHTMLSanitizer.sanitizeToHtmlString ( jsonPredefinedIconData?.icon ).htmlString  | 
| 88 | :  | 
| 89 |                 '?'; | 
| 90 |         this.#tooltip = | 
| 91 |             'string' === typeof ( jsonPredefinedIconData?.tooltip ) | 
| 92 | ?  | 
| 93 | theHTMLSanitizer.sanitizeToHtmlString ( jsonPredefinedIconData.tooltip ).htmlString  | 
| 94 | :  | 
| 95 |                 '?'; | 
| 96 |         this.#width = | 
| 97 | 'number' === typeof ( jsonPredefinedIconData?.width ) ? jsonPredefinedIconData.width : ICON_DIMENSIONS.width;  | 
| 98 |         this.#height = | 
| 99 | 'number' === typeof ( jsonPredefinedIconData?.height ) ? jsonPredefinedIconData.height : ICON_DIMENSIONS.height;  | 
| 100 | }  | 
| 101 | |
| 102 |     /** | 
| 103 |     The name of the predefined icon. This name will be displayed in the select of the NoteDialog | 
| 104 |     @type {String} | 
| 105 |     */ | 
| 106 | |
| 107 | get name ( ) { return this.#name; }  | 
| 108 | |
| 109 |     /** | 
| 110 |     The html definition of the predefined icon | 
| 111 |     @type {String} | 
| 112 |     */ | 
| 113 | |
| 114 | get icon ( ) { return this.#icon; }  | 
| 115 | |
| 116 |     /** | 
| 117 |     The tooltip of the predefined icon | 
| 118 |     @type {String} | 
| 119 |     */ | 
| 120 | |
| 121 | get tooltip ( ) { return this.#tooltip; }  | 
| 122 | |
| 123 |     /** | 
| 124 |     The width of the predefined icon | 
| 125 |     @type {Number} | 
| 126 |     */ | 
| 127 | |
| 128 | get width ( ) { return this.#width; }  | 
| 129 | |
| 130 |     /** | 
| 131 |     The height of the predefined icon | 
| 132 |     @type {Number} | 
| 133 |     */ | 
| 134 | |
| 135 | get height ( ) { return this.#height; }  | 
| 136 | |
| 137 | }  | 
| 138 | |
| 139 | export default PredefinedIconData;  | 
| 140 | |
| 141 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ | 
| 142 |