1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | import theHTMLElementsFactory from '../../core/uiLib/HTMLElementsFactory.js'; |
26 | import theTranslator from '../../core/uiLib/Translator.js'; |
27 | import BaseControl from '../baseControl/BaseControl.js'; |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | class AddressControl extends BaseControl { |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | #addressInput; |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | #addressButton; |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | constructor ( eventListeners ) { |
57 | |
58 | super ( ); |
59 | |
60 | |
61 | const headerControlElement = theHTMLElementsFactory.create ( |
62 | 'div', |
63 | { |
64 | className : 'TravelNotes-BaseDialog-FlexRow' |
65 | }, |
66 | this.controlHTMLElement ); |
67 | this.#addressButton = theHTMLElementsFactory.create ( |
68 | 'div', |
69 | { |
70 | className : 'TravelNotes-BaseDialog-Button', |
71 | title : theTranslator.getText ( 'AddressControl - Reset address' ), |
72 | textContent : '🔄' |
73 | }, |
74 | headerControlElement |
75 | ); |
76 | theHTMLElementsFactory.create ( |
77 | 'text', |
78 | { |
79 | value : theTranslator.getText ( 'AddressControl - Address' ) |
80 | }, |
81 | headerControlElement |
82 | ); |
83 | this.#addressInput = theHTMLElementsFactory.create ( |
84 | 'input', |
85 | { |
86 | type : 'text', |
87 | className : 'TravelNotes-AdressControl-InputText', |
88 | dataset : { Name : 'address' } |
89 | }, |
90 | theHTMLElementsFactory.create ( |
91 | 'div', |
92 | { |
93 | className : 'TravelNotes-BaseDialog-FlexRow' |
94 | }, |
95 | this.controlHTMLElement ) |
96 | ); |
97 | |
98 | |
99 | if ( eventListeners.controlFocus ) { |
100 | this.#addressInput.addEventListener ( 'focus', eventListeners.controlFocus ); |
101 | } |
102 | if ( eventListeners.controlInput ) { |
103 | this.#addressInput.addEventListener ( 'input', eventListeners.controlInput ); |
104 | } |
105 | if ( eventListeners.addressButtonClick ) { |
106 | this.#addressButton.addEventListener ( 'click', eventListeners.addressButtonClick ); |
107 | } |
108 | } |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | destructor ( eventListeners ) { |
116 | if ( eventListeners.controlFocus ) { |
117 | this.#addressInput.removeEventListener ( 'focus', eventListeners.controlFocus ); |
118 | } |
119 | if ( eventListeners.controlInput ) { |
120 | this.#addressInput.removeEventListener ( 'input', eventListeners.controlInput ); |
121 | } |
122 | if ( eventListeners.addressButtonClick ) { |
123 | this.#addressButton.removeEventListener ( 'click', eventListeners.addressButtonClick ); |
124 | } |
125 | } |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | get address ( ) { return this.#addressInput.value; } |
133 | |
134 | set address ( Value ) { this.#addressInput.value = Value; } |
135 | |
136 | } |
137 | |
138 | export default AddressControl; |
139 | |
140 | |
141 | |