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 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
26 | /** |
27 | @event additinerarypointmarker |
28 | fired when an ItineraryPoint marker must be added to the map |
29 | */ |
30 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
31 | |
32 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
33 | /** |
34 | @event addrectangle |
35 | fired when a rectangle must be added to the map |
36 | */ |
37 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
38 | |
39 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
40 | /** |
41 | @event addsearchpointmarker |
42 | fired when a SearchPoint marker must be added to the map |
43 | */ |
44 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
45 | |
46 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
47 | /** |
48 | @event addwaypoint |
49 | fired when a WayPoint must be added to the map |
50 | */ |
51 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
52 | |
53 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
54 | /** |
55 | @event geolocationpositionchanged |
56 | fired when the map must be updated, changing the position on the map |
57 | */ |
58 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
59 | |
60 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
61 | /** |
62 | @event geolocationstatuschanged |
63 | fired when theTravelNotesToolbar must be updated, changing the geolocation button |
64 | and when the geolocation marker must be removed from the map |
65 | */ |
66 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
67 | |
68 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
69 | /** |
70 | @event layerchange |
71 | fired when the background map must be changed |
72 | */ |
73 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
74 | |
75 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
76 | /** |
77 | @event noteupdated |
78 | fired when a note must be updated, added or removed on the map |
79 | */ |
80 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
81 | |
82 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
83 | /** |
84 | @event profileclosed |
85 | fired when a profile window is closed |
86 | */ |
87 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
88 | |
89 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
90 | /** |
91 | @event providersadded |
92 | fired when one or more providers keys are added |
93 | */ |
94 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
95 | |
96 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
97 | /** |
98 | @event removeallobjects |
99 | fired when all objects have to be removed from the map |
100 | */ |
101 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
102 | |
103 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
104 | /** |
105 | @event removeobject |
106 | fired when an object must be removed from the map |
107 | */ |
108 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
109 | |
110 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
111 | /** |
112 | @event routepropertiesupdated |
113 | fired when the properties of a route must be changed on the map |
114 | */ |
115 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
116 | |
117 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
118 | /** |
119 | @event routeupdated |
120 | fired when a route must be updated, added or removed on the map |
121 | */ |
122 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
123 | |
124 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
125 | /** |
126 | @event setprovider |
127 | fired when the provider must be updated on theProvidersToolbar |
128 | */ |
129 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
130 | |
131 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
132 | /** |
133 | @event settransitmode |
134 | fired when the transit mode must be updated on theProvidersToolbar |
135 | */ |
136 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
137 | |
138 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
139 | /** |
140 | @event showtravelproperties |
141 | fired when the travel properties dialog must be displayed |
142 | */ |
143 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
144 | |
145 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
146 | /** |
147 | @event updateosmsearch |
148 | fired when the osmsearch dialog must be updated |
149 | */ |
150 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
151 | |
152 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
153 | /** |
154 | @event updateroadbook |
155 | fired when the roadbook must be updated |
156 | */ |
157 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
158 | |
159 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
160 | /** |
161 | @event updatetravelnotes |
162 | fired when TravelNotesDialog must be updated |
163 | */ |
164 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
165 | |
166 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
167 | /** |
168 | @event updatetravelproperties |
169 | fired when travel properties dialog must be updated |
170 | */ |
171 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
172 | |
173 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
174 | /** |
175 | @event zoomto |
176 | fired when a zoom to a point or to an array of points must be performed on the map |
177 | */ |
178 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
179 | |
180 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
181 | /** |
182 | This class contains methods for dispatching events |
183 | See theEventDispatcher for the one and only one instance of this class |
184 | */ |
185 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
186 | |
187 | class EventDispatcher { |
188 | |
189 | /** |
190 | The constructor |
191 | */ |
192 | |
193 | constructor ( ) { |
194 | Object.freeze ( this ); |
195 | } |
196 | |
197 | /** |
198 | Creates and dispatch an event to the correct target |
199 | @param {String} eventName the name of the event |
200 | @param {Object} eventData An object to set as data property of the event |
201 | */ |
202 | |
203 | dispatch ( eventName, eventData ) { |
204 | const dispatchedEvent = new Event ( eventName ); |
205 | if ( eventData ) { |
206 | dispatchedEvent.data = eventData; |
207 | } |
208 | document.dispatchEvent ( dispatchedEvent ); |
209 | } |
210 | } |
211 | |
212 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
213 | /** |
214 | The one and only one instance of EventDispatcher class |
215 | @type {EventDispatcher} |
216 | */ |
217 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
218 | |
219 | const theEventDispatcher = new EventDispatcher ( ); |
220 | |
221 | export default theEventDispatcher; |
222 | |
223 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
224 |