|
@@ -1,89 +1,101 @@
|
1
|
1
|
/* global $, APP, AJS */
|
2
|
2
|
|
3
|
|
-let $overlay;
|
|
3
|
+import Overlay from '../overlay/Overlay';
|
4
|
4
|
|
5
|
5
|
/**
|
6
|
|
- * Conference reload counter in seconds.
|
7
|
|
- * @type {number}
|
|
6
|
+ * An overlay dialog which is shown before the conference is reloaded. Shows
|
|
7
|
+ * a warning message and counts down towards the reload.
|
8
|
8
|
*/
|
9
|
|
-let timeLeft;
|
10
|
|
-
|
11
|
|
-/**
|
12
|
|
- * Conference reload timeout in seconds.
|
13
|
|
- * @type {number}
|
14
|
|
- */
|
15
|
|
-let timeout;
|
16
|
|
-
|
17
|
|
-/**
|
18
|
|
- * Internal function that constructs overlay with the warning message and count
|
19
|
|
- * down towards the conference reload.
|
20
|
|
- */
|
21
|
|
-function buildReloadOverlayHtml() {
|
22
|
|
- $overlay = $(`
|
23
|
|
- <div class='overlay_container'>
|
24
|
|
- <div class='overlay_content'>
|
25
|
|
- <span data-i18n='dialog.serviceUnavailable'
|
26
|
|
- class='overlay_text_small'></span>
|
27
|
|
- <span data-i18n='dialog.conferenceReloadMsg'
|
28
|
|
- class='overlay_text_small'></span>
|
29
|
|
- <div>
|
30
|
|
- <div id='reloadProgressBar' class="aui-progress-indicator">
|
31
|
|
- <span class="aui-progress-indicator-value"></span>
|
32
|
|
- </div>
|
33
|
|
- <span id='reloadSecRemaining' class='overlay_text_small'>
|
34
|
|
- </span>
|
|
9
|
+class PageReloadOverlayImpl extends Overlay{
|
|
10
|
+ /**
|
|
11
|
+ * Creates new <tt>PageReloadOverlayImpl</tt>
|
|
12
|
+ * @param {number} timeoutSeconds how long the overlay dialog will be
|
|
13
|
+ * displayed, before the conference will be reloaded.
|
|
14
|
+ */
|
|
15
|
+ constructor(timeoutSeconds) {
|
|
16
|
+ super();
|
|
17
|
+ /**
|
|
18
|
+ * Conference reload counter in seconds.
|
|
19
|
+ * @type {number}
|
|
20
|
+ */
|
|
21
|
+ this.timeLeft = timeoutSeconds;
|
|
22
|
+ /**
|
|
23
|
+ * Conference reload timeout in seconds.
|
|
24
|
+ * @type {number}
|
|
25
|
+ */
|
|
26
|
+ this.timeout = timeoutSeconds;
|
|
27
|
+ }
|
|
28
|
+ /**
|
|
29
|
+ * Constructs overlay body with the warning message and count down towards
|
|
30
|
+ * the conference reload.
|
|
31
|
+ * @override
|
|
32
|
+ */
|
|
33
|
+ _buildOverlayContent() {
|
|
34
|
+ return `
|
|
35
|
+ <span data-i18n='dialog.serviceUnavailable'
|
|
36
|
+ class='overlay_text_small'></span>
|
|
37
|
+ <span data-i18n='dialog.conferenceReloadMsg'
|
|
38
|
+ class='overlay_text_small'></span>
|
|
39
|
+ <div>
|
|
40
|
+ <div id='reloadProgressBar' class="aui-progress-indicator">
|
|
41
|
+ <span class="aui-progress-indicator-value"></span>
|
35
|
42
|
</div>
|
36
|
|
- </div>
|
37
|
|
- </div>`);
|
38
|
|
-
|
39
|
|
- APP.translation.translateElement($overlay);
|
40
|
|
-}
|
41
|
|
-
|
42
|
|
-/**
|
43
|
|
- * Updates the progress indicator position and the label with the time left.
|
44
|
|
- */
|
45
|
|
-function updateDisplay() {
|
|
43
|
+ <span id='reloadSecRemaining' class='overlay_text_small'>
|
|
44
|
+ </span>
|
|
45
|
+ </div>`;
|
|
46
|
+ }
|
46
|
47
|
|
47
|
|
- const timeLeftTxt
|
48
|
|
- = APP.translation.translateString(
|
49
|
|
- "dialog.conferenceReloadTimeLeft",
|
50
|
|
- { seconds: timeLeft });
|
51
|
|
- $("#reloadSecRemaining").text(timeLeftTxt);
|
|
48
|
+ /**
|
|
49
|
+ * Updates the progress indicator position and the label with the time left.
|
|
50
|
+ */
|
|
51
|
+ updateDisplay() {
|
52
|
52
|
|
53
|
|
- const ratio = (timeout-timeLeft)/timeout;
|
54
|
|
- AJS.progressBars.update("#reloadProgressBar", ratio);
|
55
|
|
-}
|
|
53
|
+ const timeLeftTxt
|
|
54
|
+ = APP.translation.translateString(
|
|
55
|
+ "dialog.conferenceReloadTimeLeft",
|
|
56
|
+ { seconds: this.timeLeft });
|
|
57
|
+ $("#reloadSecRemaining").text(timeLeftTxt);
|
56
|
58
|
|
57
|
|
-/**
|
58
|
|
- * Starts the reload countdown with the animation.
|
59
|
|
- * @param {number} timeoutSeconds how many seconds before the conference
|
60
|
|
- * reload will happen.
|
61
|
|
- */
|
62
|
|
-function start(timeoutSeconds) {
|
|
59
|
+ const ratio = (this.timeout - this.timeLeft) / this.timeout;
|
|
60
|
+ AJS.progressBars.update("#reloadProgressBar", ratio);
|
|
61
|
+ }
|
63
|
62
|
|
64
|
|
- timeLeft = timeout = timeoutSeconds;
|
|
63
|
+ /**
|
|
64
|
+ * Starts the reload countdown with the animation.
|
|
65
|
+ * @override
|
|
66
|
+ */
|
|
67
|
+ _onShow() {
|
65
|
68
|
|
66
|
|
- // Initialize displays
|
67
|
|
- updateDisplay();
|
|
69
|
+ // Initialize displays
|
|
70
|
+ this.updateDisplay();
|
68
|
71
|
|
69
|
|
- var intervalId = window.setInterval(function() {
|
|
72
|
+ var intervalId = window.setInterval(function() {
|
70
|
73
|
|
71
|
|
- if (timeLeft >= 1) {
|
72
|
|
- timeLeft -= 1;
|
73
|
|
- }
|
|
74
|
+ if (this.timeLeft >= 1) {
|
|
75
|
+ this.timeLeft -= 1;
|
|
76
|
+ }
|
74
|
77
|
|
75
|
|
- updateDisplay();
|
|
78
|
+ this.updateDisplay();
|
76
|
79
|
|
77
|
|
- if (timeLeft === 0) {
|
78
|
|
- window.clearInterval(intervalId);
|
79
|
|
- APP.ConferenceUrl.reload();
|
80
|
|
- }
|
81
|
|
- }, 1000);
|
|
80
|
+ if (this.timeLeft === 0) {
|
|
81
|
+ window.clearInterval(intervalId);
|
|
82
|
+ APP.ConferenceUrl.reload();
|
|
83
|
+ }
|
|
84
|
+ }.bind(this), 1000);
|
82
|
85
|
|
83
|
|
- console.info(
|
84
|
|
- "The conference will be reloaded after " + timeLeft + " seconds.");
|
|
86
|
+ console.info(
|
|
87
|
+ "The conference will be reloaded after "
|
|
88
|
+ + this.timeLeft + " seconds.");
|
|
89
|
+ }
|
85
|
90
|
}
|
86
|
91
|
|
|
92
|
+/**
|
|
93
|
+ * Holds the page reload overlay instance.
|
|
94
|
+ *
|
|
95
|
+ * {@type PageReloadOverlayImpl}
|
|
96
|
+ */
|
|
97
|
+let overlay;
|
|
98
|
+
|
87
|
99
|
export default {
|
88
|
100
|
/**
|
89
|
101
|
* Checks whether the page reload overlay has been displayed.
|
|
@@ -91,7 +103,7 @@ export default {
|
91
|
103
|
* visible or <tt>false</tt> otherwise.
|
92
|
104
|
*/
|
93
|
105
|
isVisible() {
|
94
|
|
- return $overlay && $overlay.parents('body').length > 0;
|
|
106
|
+ return overlay && overlay.isVisible();
|
95
|
107
|
},
|
96
|
108
|
/**
|
97
|
109
|
* Shows the page reload overlay which will do the conference reload after
|
|
@@ -102,11 +114,9 @@ export default {
|
102
|
114
|
*/
|
103
|
115
|
show(timeoutSeconds) {
|
104
|
116
|
|
105
|
|
- !$overlay && buildReloadOverlayHtml();
|
106
|
|
-
|
107
|
|
- if (!this.isVisible()) {
|
108
|
|
- $overlay.appendTo('body');
|
109
|
|
- start(timeoutSeconds);
|
|
117
|
+ if (!overlay) {
|
|
118
|
+ overlay = new PageReloadOverlayImpl(timeoutSeconds);
|
110
|
119
|
}
|
|
120
|
+ overlay.show();
|
111
|
121
|
}
|
112
|
122
|
};
|