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 theOsmSearchEngine from '../../../core/osmSearch/OsmSearchEngine.js'; |
26 | import theOsmSearchDictionary from '../../../core/osmSearch/OsmSearchDictionary.js'; |
27 | import theEventDispatcher from '../../../core/lib/EventDispatcher.js'; |
28 | import theTravelNotesData from '../../../data/TravelNotesData.js'; |
29 | |
30 | import { ZERO } from '../../../main/Constants.js'; |
31 | |
32 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
33 | /** |
34 | click event listener for the search button |
35 | */ |
36 | /* ------------------------------------------------------------------------------------------------------------------------- */ |
37 | |
38 | class SearchButtonClickEL { |
39 | |
40 | /** |
41 | A reference to the osmSearchTree Object |
42 | @type {OsmSearchTree} |
43 | */ |
44 | |
45 | #osmSearchTree; |
46 | |
47 | /** |
48 | A reference to the osmSearchWait Object |
49 | @type {OsmSearchWait} |
50 | */ |
51 | |
52 | #osmSearchWait; |
53 | |
54 | /** |
55 | The constructor |
56 | @param {OsmSearchTree} osmSearchTree A reference to the OsmSearchTree object |
57 | @param {OsmSearchWait} osmSearchWait A reference to the OsmSearchWait object |
58 | */ |
59 | |
60 | constructor ( osmSearchTree, osmSearchWait ) { |
61 | Object.freeze ( this ); |
62 | this.#osmSearchTree = osmSearchTree; |
63 | this.#osmSearchWait = osmSearchWait; |
64 | } |
65 | |
66 | /** |
67 | Event listener method |
68 | @param {Event} clickEvent The event to handle |
69 | */ |
70 | |
71 | handleEvent ( clickEvent ) { |
72 | clickEvent.stopPropagation ( ); |
73 | theOsmSearchDictionary.dictionary.isExpanded = false; |
74 | this.#osmSearchTree.redraw ( ); |
75 | theTravelNotesData.searchData.length = ZERO; |
76 | theEventDispatcher.dispatch ( 'updateosmsearch' ); |
77 | this.#osmSearchWait.showWait ( ); |
78 | theOsmSearchEngine.search ( ); |
79 | |
80 | // Notice: theOsmSearchEngine send a 'updateosmsearch' event when the search is succesfully done |
81 | } |
82 | } |
83 | |
84 | export default SearchButtonClickEL; |
85 | |
86 | /* --- End of file --------------------------------------------------------------------------------------------------------- */ |
87 |