1
|
/**
|
2
|
* Class representing a modal window displaying a change separately from viewport and sidebar.
|
3
|
* @see Change
|
4
|
* @constructor
|
5
|
* @param {Change} change Change to be displayed in the modal window.
|
6
|
*/
|
7
|
function ChangeModalWindow(change) {
|
8
|
var rootElement;
|
9
|
|
10
|
var change;
|
11
|
|
12
|
/**
|
13
|
* Sets a change to be displayed in the modal window.
|
14
|
* @param {Change} newValue Change to be displayed in this modal window.
|
15
|
*/
|
16
|
this.setChange = function(newValue) {
|
17
|
change = newValue;
|
18
|
};
|
19
|
|
20
|
this.open = function() {
|
21
|
rootElement.classList.remove('hidden');
|
22
|
};
|
23
|
|
24
|
/**
|
25
|
* Closes this modal window.
|
26
|
*/
|
27
|
this.close = function() {
|
28
|
rootElement.classList.add('hidden');
|
29
|
};
|
30
|
|
31
|
/**
|
32
|
* Creates a new HTML DOM element representing the modal window in memory. Binds user interactions to local handler functions.
|
33
|
* @returns {Element} HTML DOM element.
|
34
|
*/
|
35
|
this.render = function() {
|
36
|
rootElement = app.utils.createHtmlElement('div', {
|
37
|
'class': 'change-modal modal hidden',
|
38
|
});
|
39
|
|
40
|
var modalContent = app.utils.createHtmlElement('div', {
|
41
|
'class': 'modal-content',
|
42
|
});
|
43
|
rootElement.appendChild(modalContent);
|
44
|
|
45
|
var closeButton = app.utils.createHtmlElement('button', {
|
46
|
'class': 'close-button button',
|
47
|
});
|
48
|
closeButton.appendChild(app.utils.createTextElement('×'));
|
49
|
closeButton.addEventListener('click', closeButtonClick.bind(this));
|
50
|
modalContent.appendChild(closeButton);
|
51
|
|
52
|
return rootElement;
|
53
|
};
|
54
|
|
55
|
/**
|
56
|
* Close button click interaction. Closes the modal window.
|
57
|
* @param {Event} e Click event.
|
58
|
*/
|
59
|
function closeButtonClick(e) {
|
60
|
this.close();
|
61
|
}
|
62
|
}
|