File : uis/waitUI/WaitUI.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
27
/* ------------------------------------------------------------------------------------------------------------------------- */
28
/**
29
This class display a Wait window on the screen with a message and an animation
30
*/
31
/* ------------------------------------------------------------------------------------------------------------------------- */
32
33
class WaitUI {
34
35
    /**
36
    The background div
37
    @type {HTMLElement}
38
    */
39
40
    #backgroundDiv;
41
42
    /**
43
    The message div
44
    @type {HTMLElement}
45
    */
46
47
    #messageDiv;
48
49
    /**
50
    The constructor
51
    */
52
53
    constructor ( ) {
54
        Object.freeze ( this );
55
    }
56
57
    /**
58
    creates the user interface
59
    */
60
61
    createUI ( ) {
62
63
        // We can create the waitUI only once...
64
        if ( this.#backgroundDiv ) {
65
            return;
66
        }
67
68
        // Background div, so the map and controls are unavailable
69
        this.#backgroundDiv = theHTMLElementsFactory.create ( 'div', { className : 'TravelNotes-Background' }, document.body );
70
71
        // Wait div
72
        const waitDiv = theHTMLElementsFactory.create ( 'div', { id : 'TravelNotes-WaitUI' }, this.#backgroundDiv );
73
74
        // Message div
75
        this.#messageDiv = theHTMLElementsFactory.create ( 'div', { id : 'TravelNotes-WaitUI-MessageDiv' }, waitDiv );
76
        theHTMLElementsFactory.create (
77
            'div',
78
            {
79
                className : 'TravelNotes-WaitAnimationBullet'
80
            },
81
            theHTMLElementsFactory.create ( 'div', { className : 'TravelNotes-WaitAnimation' }, waitDiv ) );
82
    }
83
84
    /**
85
    Show an info in the WaitUI
86
    @param {String} info The info to be displayed
87
    */
88
89
    showInfo ( info ) {
90
        this.#messageDiv.textContent = info;
91
    }
92
93
    /**
94
    Close the WaitUI
95
    */
96
97
    close ( ) {
98
        document.body.removeChild ( this.#backgroundDiv );
99
        this.#backgroundDiv = null;
100
    }
101
}
102
103
export default WaitUI;
104
105
/* --- End of file --------------------------------------------------------------------------------------------------------- */
106