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 theNoteHTMLViewsFactory from '../../../viewsFactories/NoteHTMLViewsFactory.js'; |
27 | import NoteAndRoute from '../../../data/NoteAndRoute.js'; |
28 | |
29 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
30 | /** |
31 | This class is the notePreview control of the NotDialog |
32 | */ |
33 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
34 | |
35 | class NoteDialogPreviewControl { |
36 | |
37 | /** |
38 | The container for the preview note |
39 | @type {HTMLElement} |
40 | */ |
41 | |
42 | #previewHTMLElement; |
43 | |
44 | /** |
45 | A reference to the note displayed in the control |
46 | @type {Note} |
47 | */ |
48 | |
49 | #previewNote; |
50 | |
51 | /** |
52 | The constructor |
53 | @param {Note} previewNote A reference to the note displayed in the control |
54 | */ |
55 | |
56 | constructor ( previewNote ) { |
57 | |
58 | Object.freeze ( this ); |
59 | |
60 | this.#previewNote = previewNote; |
61 | |
62 | // HTMLElements creation |
63 | this.#previewHTMLElement = theHTMLElementsFactory.create ( |
64 | 'div', |
65 | { |
66 | className : 'TravelNotes-NoteDialog-PreviewDiv' |
67 | } |
68 | ); |
69 | this.#previewHTMLElement.appendChild ( |
70 | theNoteHTMLViewsFactory.getNoteTextAndIconHTML ( |
71 | 'TravelNotes-NoteDialog-', |
72 | new NoteAndRoute ( this.#previewNote, null ) |
73 | ) |
74 | ); |
75 | } |
76 | |
77 | /** |
78 | Update the control |
79 | */ |
80 | |
81 | update ( ) { |
82 | this.#previewHTMLElement.textContent = ''; |
83 | this.#previewHTMLElement.appendChild ( |
84 | theNoteHTMLViewsFactory.getNoteTextAndIconHTML ( |
85 | 'TravelNotes-NoteDialog-', |
86 | { note : this.#previewNote, route : null } |
87 | ) |
88 | ); |
89 | } |
90 | |
91 | /** |
92 | An array with the HTML elements of the control |
93 | @type {Array.<HTMLElement>} |
94 | */ |
95 | |
96 | get HTMLElements ( ) { return [ this.#previewHTMLElement ]; } |
97 | |
98 | } |
99 | |
100 | export default NoteDialogPreviewControl; |
101 | |
102 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
103 |