File : dialogs/osmSearchDialog/osmSearchToolbarButtons/OsmSearchToolbarButtons.js

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 theTranslator from '../../../core/uiLib/Translator.js';
27
import ClearButtonClickEL from './ClearButtonClickEL.js';
28
import CollapseButtonClickEL from './CollapseButtonClickEL.js';
29
import ExpandTreeButtonClickEL from './ExpandTreeButtonClickEL.js';
30
import SearchButtonClickEL from './SearchButtonClickEL.js';
31
32
/* ------------------------------------------------------------------------------------------------------------------------- */
33
/**
34
This class build the search toolbar and contains also the event listeners for the toolbar
35
*/
36
/* ------------------------------------------------------------------------------------------------------------------------- */
37
38
class OsmSearchToolbarButtons {
39
40
    /**
41
    The toolbar container
42
    @type {HTMLElement}
43
    */
44
45
    #toolbarButtonsHTMLElement;
46
47
    /**
48
    The constructor
49
    @param {OsmSearchTree} osmSearchTree A reference to the OsmSearchTree object
50
    @param {OsmSearchWait} osmSearchWait A reference to the OsmSearchWait object
51
    */
52
53
    constructor ( osmSearchTree, osmSearchWait ) {
54
55
        Object.freeze ( this );
56
57
        // container
58
        this.#toolbarButtonsHTMLElement = theHTMLElementsFactory.create (
59
            'div'
60
        );
61
62
        // Search button
63
        theHTMLElementsFactory.create (
64
            'div',
65
            {
66
                className : 'TravelNotes-BaseDialog-Button',
67
                title : theTranslator.getText ( 'OsmSearchToolbarButtons - Start the search' ),
68
                textContent : '🔎'
69
            },
70
            this.#toolbarButtonsHTMLElement
71
        )
72
            .addEventListener ( 'click', new SearchButtonClickEL ( osmSearchTree, osmSearchWait ), false );
73
74
        // Expand tree button
75
        theHTMLElementsFactory.create (
76
            'div',
77
            {
78
                className : 'TravelNotes-BaseDialog-Button',
79
                title : theTranslator.getText ( 'OsmSearchToolbarButtons - Expand the tree' ),
80
                textContent : '▼'
81
            },
82
            this.#toolbarButtonsHTMLElement
83
        )
84
            .addEventListener ( 'click', new ExpandTreeButtonClickEL ( osmSearchTree ), false );
85
86
        // Collapse button
87
        theHTMLElementsFactory.create (
88
            'div',
89
            {
90
                className : 'TravelNotes-BaseDialog-Button',
91
                title : theTranslator.getText ( 'OsmSearchToolbarButtons - Collapse the tree' ),
92
                textContent : '▶'
93
            },
94
            this.#toolbarButtonsHTMLElement
95
        )
96
            .addEventListener ( 'click', new CollapseButtonClickEL ( osmSearchTree ), false );
97
98
        // clear button
99
        theHTMLElementsFactory.create (
100
            'div',
101
            {
102
                className : 'TravelNotes-BaseDialog-Button',
103
                title : theTranslator.getText ( 'OsmSearchToolbarButtons - Clear the tree' ),
104
                textContent : '❌'
105
            },
106
            this.#toolbarButtonsHTMLElement
107
        )
108
            .addEventListener ( 'click', new ClearButtonClickEL ( osmSearchTree ), false );
109
110
    }
111
112
    /**
113
    The toolbar htmlElement
114
    @type {HTMLElement}
115
    */
116
117
    get toolbarButtonsHTMLElement ( ) { return this.#toolbarButtonsHTMLElement; }
118
119
}
120
121
export default OsmSearchToolbarButtons;
122
123
/* --- End of file --------------------------------------------------------------------------------------------------------- */
124