|
@@ -10,48 +10,72 @@ const FilmStrip = {
|
10
|
10
|
* emit/fire {UIEvents} (such as {UIEvents.TOGGLED_FILM_STRIP}).
|
11
|
11
|
*/
|
12
|
12
|
init (eventEmitter) {
|
|
13
|
+ this.iconMenuDownClassName = 'icon-menu-down';
|
|
14
|
+ this.iconMenuUpClassName = 'icon-menu-up';
|
13
|
15
|
this.filmStrip = $('#remoteVideos');
|
14
|
16
|
this.eventEmitter = eventEmitter;
|
15
|
|
- this.filmStripIsVisible = true;
|
16
|
|
- this.renderFilmstripToolbar();
|
17
|
|
- this.activateHideButton();
|
|
17
|
+ this._initFilmStripToolbar();
|
|
18
|
+ this.registerListeners();
|
18
|
19
|
},
|
19
|
20
|
|
20
|
21
|
/**
|
21
|
|
- * Attach 'click' listener to "hide filmstrip" button
|
|
22
|
+ * Initializes the filmstrip toolbar
|
22
|
23
|
*/
|
23
|
|
- activateHideButton () {
|
24
|
|
- $('#videospace').on('click', '#hideVideoToolbar', () => {
|
25
|
|
- var icon = document.querySelector('#hideVideoToolbar i');
|
|
24
|
+ _initFilmStripToolbar() {
|
|
25
|
+ let toolbar = this._generateFilmStripToolbar();
|
|
26
|
+ let container = document.querySelector('.filmstrip');
|
26
|
27
|
|
27
|
|
- this.filmStripIsVisible = !this.filmStripIsVisible;
|
28
|
|
- this.toggleFilmStrip(this.filmStripIsVisible);
|
|
28
|
+ UIUtil.prependChild(container, toolbar);
|
29
|
29
|
|
30
|
|
- icon.classList.remove(
|
31
|
|
- this.filmStripIsVisible ? 'icon-menu-up' : 'icon-menu-down');
|
32
|
|
- icon.classList.add(
|
33
|
|
- this.filmStripIsVisible ? 'icon-menu-down' : 'icon-menu-up');
|
34
|
|
- });
|
|
30
|
+ let iconSelector = '#hideVideoToolbar i';
|
|
31
|
+ this.toggleFilmStripIcon = document.querySelector(iconSelector);
|
35
|
32
|
},
|
36
|
33
|
|
37
|
34
|
/**
|
38
|
|
- * Shows toolbar on the right of the filmstrip
|
|
35
|
+ * Generates HTML layout for filmstrip toolbar
|
|
36
|
+ * @returns {HTMLElement}
|
|
37
|
+ * @private
|
39
|
38
|
*/
|
40
|
|
- renderFilmstripToolbar () {
|
41
|
|
- // create toolbar
|
42
|
|
- var container = document.createElement('div');
|
43
|
|
- container.className = 'filmstripToolbar';
|
|
39
|
+ _generateFilmStripToolbar() {
|
|
40
|
+ let container = document.createElement('div');
|
|
41
|
+ let isVisible = this.isFilmStripVisible();
|
|
42
|
+ container.className = 'filmstrip__toolbar';
|
44
|
43
|
|
45
|
44
|
container.innerHTML = `
|
46
|
45
|
<button id="hideVideoToolbar">
|
47
|
|
- <i class="icon-menu-${this.filmStripIsVisible ? 'down' : 'up'}">
|
|
46
|
+ <i class="icon-menu-${isVisible ? 'down' : 'up'}">
|
48
|
47
|
</i>
|
49
|
48
|
</button>
|
50
|
49
|
`;
|
51
|
50
|
|
52
|
|
- // show toolbar
|
53
|
|
- document.querySelector('#videospace')
|
54
|
|
- .insertBefore(container, document.querySelector('#remoteVideos'));
|
|
51
|
+ return container;
|
|
52
|
+ },
|
|
53
|
+
|
|
54
|
+ /**
|
|
55
|
+ * Attach 'click' listener to "hide filmstrip" button
|
|
56
|
+ */
|
|
57
|
+ registerListeners() {
|
|
58
|
+ let toggleFilmstripMethod = this.toggleFilmStrip.bind(this);
|
|
59
|
+ let selector = '#hideVideoToolbar';
|
|
60
|
+ $('#videospace').on('click', selector, toggleFilmstripMethod);
|
|
61
|
+ },
|
|
62
|
+
|
|
63
|
+ /**
|
|
64
|
+ * Changes classes of icon for showing down state
|
|
65
|
+ */
|
|
66
|
+ showMenuDownIcon() {
|
|
67
|
+ let icon = this.toggleFilmStripIcon;
|
|
68
|
+ icon.classList.add(this.iconMenuDownClassName);
|
|
69
|
+ icon.classList.remove(this.iconMenuUpClassName);
|
|
70
|
+ },
|
|
71
|
+
|
|
72
|
+ /**
|
|
73
|
+ * Changes classes of icon for showing up state
|
|
74
|
+ */
|
|
75
|
+ showMenuUpIcon() {
|
|
76
|
+ let icon = this.toggleFilmStripIcon;
|
|
77
|
+ icon.classList.add(this.iconMenuUpClassName);
|
|
78
|
+ icon.classList.remove(this.iconMenuDownClassName);
|
55
|
79
|
},
|
56
|
80
|
|
57
|
81
|
/**
|
|
@@ -62,14 +86,22 @@ const FilmStrip = {
|
62
|
86
|
* (i.e. toggled); otherwise, the visibility will be set to the specified
|
63
|
87
|
* value.
|
64
|
88
|
*/
|
65
|
|
- toggleFilmStrip (visible) {
|
66
|
|
- if (typeof visible === 'boolean'
|
67
|
|
- && this.isFilmStripVisible() == visible) {
|
|
89
|
+ toggleFilmStrip(visible) {
|
|
90
|
+ let isVisibleDefined = typeof visible === 'boolean';
|
|
91
|
+ if (!isVisibleDefined) {
|
|
92
|
+ visible = this.isFilmStripVisible();
|
|
93
|
+ } else if (this.isFilmStripVisible() === visible) {
|
68
|
94
|
return;
|
69
|
95
|
}
|
70
|
96
|
|
71
|
97
|
this.filmStrip.toggleClass("hidden");
|
72
|
98
|
|
|
99
|
+ if (!visible) {
|
|
100
|
+ this.showMenuDownIcon();
|
|
101
|
+ } else {
|
|
102
|
+ this.showMenuUpIcon();
|
|
103
|
+ }
|
|
104
|
+
|
73
|
105
|
// Emit/fire UIEvents.TOGGLED_FILM_STRIP.
|
74
|
106
|
var eventEmitter = this.eventEmitter;
|
75
|
107
|
if (eventEmitter) {
|
|
@@ -79,18 +111,26 @@ const FilmStrip = {
|
79
|
111
|
}
|
80
|
112
|
},
|
81
|
113
|
|
82
|
|
- isFilmStripVisible () {
|
|
114
|
+ /**
|
|
115
|
+ * Shows if filmstrip is visible
|
|
116
|
+ * @returns {boolean}
|
|
117
|
+ */
|
|
118
|
+ isFilmStripVisible() {
|
83
|
119
|
return !this.filmStrip.hasClass('hidden');
|
84
|
120
|
},
|
85
|
121
|
|
86
|
|
- setupFilmStripOnly () {
|
|
122
|
+ setupFilmStripOnly() {
|
87
|
123
|
this.filmStrip.css({
|
88
|
124
|
padding: "0px 0px 18px 0px",
|
89
|
125
|
right: 0
|
90
|
126
|
});
|
91
|
127
|
},
|
92
|
128
|
|
93
|
|
- getFilmStripHeight () {
|
|
129
|
+ /**
|
|
130
|
+ * Returns the height of filmstrip
|
|
131
|
+ * @returns {number} height
|
|
132
|
+ */
|
|
133
|
+ getFilmStripHeight() {
|
94
|
134
|
if (this.isFilmStripVisible()) {
|
95
|
135
|
return this.filmStrip.outerHeight();
|
96
|
136
|
} else {
|
|
@@ -98,12 +138,20 @@ const FilmStrip = {
|
98
|
138
|
}
|
99
|
139
|
},
|
100
|
140
|
|
101
|
|
- getFilmStripWidth () {
|
|
141
|
+ /**
|
|
142
|
+ * Returns the width of filmstip
|
|
143
|
+ * @returns {number} width
|
|
144
|
+ */
|
|
145
|
+ getFilmStripWidth() {
|
102
|
146
|
return this.filmStrip.innerWidth()
|
103
|
147
|
- parseInt(this.filmStrip.css('paddingLeft'), 10)
|
104
|
148
|
- parseInt(this.filmStrip.css('paddingRight'), 10);
|
105
|
149
|
},
|
106
|
150
|
|
|
151
|
+ /**
|
|
152
|
+ * Calculates the size for thumbnails: local and remote one
|
|
153
|
+ * @returns {*|{localVideo, remoteVideo}}
|
|
154
|
+ */
|
107
|
155
|
calculateThumbnailSize() {
|
108
|
156
|
let availableSizes = this.calculateAvailableSize();
|
109
|
157
|
let width = availableSizes.availableWidth;
|
|
@@ -115,7 +163,7 @@ const FilmStrip = {
|
115
|
163
|
/**
|
116
|
164
|
* Normalizes local and remote thumbnail ratios
|
117
|
165
|
*/
|
118
|
|
- normalizeThumbnailRatio () {
|
|
166
|
+ normalizeThumbnailRatio() {
|
119
|
167
|
let remoteHeightRatio = interfaceConfig.REMOTE_THUMBNAIL_RATIO_HEIGHT;
|
120
|
168
|
let remoteWidthRatio = interfaceConfig.REMOTE_THUMBNAIL_RATIO_WIDTH;
|
121
|
169
|
|
|
@@ -146,6 +194,11 @@ const FilmStrip = {
|
146
|
194
|
return { localRatio, remoteRatio };
|
147
|
195
|
},
|
148
|
196
|
|
|
197
|
+ /**
|
|
198
|
+ * Calculates available size for one thumbnail according to
|
|
199
|
+ * the current window size
|
|
200
|
+ * @returns {{availableWidth: number, availableHeight: number}}
|
|
201
|
+ */
|
149
|
202
|
calculateAvailableSize() {
|
150
|
203
|
let availableHeight = interfaceConfig.FILM_STRIP_MAX_HEIGHT;
|
151
|
204
|
let thumbs = this.getThumbs(true);
|
|
@@ -221,6 +274,13 @@ const FilmStrip = {
|
221
|
274
|
return { availableWidth, availableHeight };
|
222
|
275
|
},
|
223
|
276
|
|
|
277
|
+ /**
|
|
278
|
+ * Takes the available size for thumbnail and calculates
|
|
279
|
+ * final size of thumbnails
|
|
280
|
+ * @param availableWidth
|
|
281
|
+ * @param availableHeight
|
|
282
|
+ * @returns {{localVideo, remoteVideo}}
|
|
283
|
+ */
|
224
|
284
|
calculateThumbnailSizeFromAvailable(availableWidth, availableHeight) {
|
225
|
285
|
let { localRatio, remoteRatio } = this.normalizeThumbnailRatio();
|
226
|
286
|
let { remoteThumbs } = this.getThumbs(true);
|
|
@@ -251,7 +311,15 @@ const FilmStrip = {
|
251
|
311
|
};
|
252
|
312
|
},
|
253
|
313
|
|
254
|
|
- resizeThumbnails (local, remote,
|
|
314
|
+ /**
|
|
315
|
+ * Resizes thumbnails
|
|
316
|
+ * @param local
|
|
317
|
+ * @param remote
|
|
318
|
+ * @param animate
|
|
319
|
+ * @param forceUpdate
|
|
320
|
+ * @returns {Promise}
|
|
321
|
+ */
|
|
322
|
+ resizeThumbnails(local, remote,
|
255
|
323
|
animate = false, forceUpdate = false) {
|
256
|
324
|
|
257
|
325
|
return new Promise(resolve => {
|
|
@@ -289,7 +357,12 @@ const FilmStrip = {
|
289
|
357
|
});
|
290
|
358
|
},
|
291
|
359
|
|
292
|
|
- getThumbs (only_visible = false) {
|
|
360
|
+ /**
|
|
361
|
+ * Returns thumbnails of the filmstrip
|
|
362
|
+ * @param only_visible
|
|
363
|
+ * @returns {object} thumbnails
|
|
364
|
+ */
|
|
365
|
+ getThumbs(only_visible = false) {
|
293
|
366
|
let selector = 'span';
|
294
|
367
|
if (only_visible) {
|
295
|
368
|
selector += ':visible';
|