2016-11-09 10:41:23 +00:00
|
|
|
/* global $, APP, JitsiMeetJS, interfaceConfig */
|
2016-02-24 21:05:24 +00:00
|
|
|
|
2016-03-11 10:55:29 +00:00
|
|
|
import UIEvents from "../../../service/UI/UIEvents";
|
2016-02-24 21:05:24 +00:00
|
|
|
import UIUtil from "../util/UIUtil";
|
|
|
|
|
|
|
|
const FilmStrip = {
|
2016-03-11 10:55:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param eventEmitter the {EventEmitter} through which {FilmStrip} is to
|
|
|
|
* emit/fire {UIEvents} (such as {UIEvents.TOGGLED_FILM_STRIP}).
|
|
|
|
*/
|
|
|
|
init (eventEmitter) {
|
2016-11-03 11:44:17 +00:00
|
|
|
this.iconMenuDownClassName = 'icon-menu-down';
|
|
|
|
this.iconMenuUpClassName = 'icon-menu-up';
|
2016-11-04 16:13:57 +00:00
|
|
|
this.filmStripContainerClassName = 'filmstrip';
|
2016-02-24 21:05:24 +00:00
|
|
|
this.filmStrip = $('#remoteVideos');
|
2016-03-11 10:55:29 +00:00
|
|
|
this.eventEmitter = eventEmitter;
|
2016-11-03 11:44:17 +00:00
|
|
|
this._initFilmStripToolbar();
|
|
|
|
this.registerListeners();
|
2016-10-18 15:16:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2016-11-03 11:44:17 +00:00
|
|
|
* Initializes the filmstrip toolbar
|
2016-10-18 15:16:14 +00:00
|
|
|
*/
|
2016-11-03 11:44:17 +00:00
|
|
|
_initFilmStripToolbar() {
|
|
|
|
let toolbar = this._generateFilmStripToolbar();
|
2016-11-04 16:13:57 +00:00
|
|
|
let className = this.filmStripContainerClassName;
|
|
|
|
let container = document.querySelector(`.${className}`);
|
2016-10-18 15:16:14 +00:00
|
|
|
|
2016-11-03 14:18:28 +00:00
|
|
|
UIUtil.prependChild(container, toolbar);
|
2016-10-18 15:16:14 +00:00
|
|
|
|
2016-11-03 11:44:17 +00:00
|
|
|
let iconSelector = '#hideVideoToolbar i';
|
|
|
|
this.toggleFilmStripIcon = document.querySelector(iconSelector);
|
2016-10-18 15:16:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2016-11-03 11:44:17 +00:00
|
|
|
* Generates HTML layout for filmstrip toolbar
|
|
|
|
* @returns {HTMLElement}
|
|
|
|
* @private
|
2016-10-18 15:16:14 +00:00
|
|
|
*/
|
2016-11-03 11:44:17 +00:00
|
|
|
_generateFilmStripToolbar() {
|
|
|
|
let container = document.createElement('div');
|
2016-11-03 13:02:03 +00:00
|
|
|
let isVisible = this.isFilmStripVisible();
|
2016-11-03 15:07:48 +00:00
|
|
|
container.className = 'filmstrip__toolbar';
|
2017-01-12 20:51:53 +00:00
|
|
|
if(!interfaceConfig.filmStripOnly) {
|
|
|
|
container.innerHTML = `
|
|
|
|
<button id="hideVideoToolbar">
|
|
|
|
<i class="icon-menu-${isVisible ? 'down' : 'up'}">
|
|
|
|
</i>
|
|
|
|
</button>
|
|
|
|
`;
|
|
|
|
}
|
2016-10-18 15:16:14 +00:00
|
|
|
|
2016-11-03 11:44:17 +00:00
|
|
|
return container;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attach 'click' listener to "hide filmstrip" button
|
|
|
|
*/
|
|
|
|
registerListeners() {
|
2016-11-18 17:26:33 +00:00
|
|
|
// Important:
|
|
|
|
// Firing the event instead of executing toggleFilmstrip method because
|
|
|
|
// it's important to hide the filmstrip by UI.toggleFilmstrip in order
|
|
|
|
// to correctly resize the video area.
|
|
|
|
$('#hideVideoToolbar').on('click',
|
|
|
|
() => this.eventEmitter.emit(UIEvents.TOGGLE_FILM_STRIP));
|
2016-11-09 10:41:23 +00:00
|
|
|
|
|
|
|
this._registerToggleFilmstripShortcut();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registering toggle filmstrip shortcut
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_registerToggleFilmstripShortcut() {
|
|
|
|
let shortcut = 'F';
|
|
|
|
let shortcutAttr = 'filmstripPopover';
|
|
|
|
let description = 'keyboardShortcuts.toggleFilmstrip';
|
2016-11-18 17:26:33 +00:00
|
|
|
// Important:
|
|
|
|
// Firing the event instead of executing toggleFilmstrip method because
|
|
|
|
// it's important to hide the filmstrip by UI.toggleFilmstrip in order
|
|
|
|
// to correctly resize the video area.
|
|
|
|
let handler = () => this.eventEmitter.emit(UIEvents.TOGGLE_FILM_STRIP);
|
2016-11-09 10:41:23 +00:00
|
|
|
|
|
|
|
APP.keyboardshortcut.registerShortcut(
|
|
|
|
shortcut,
|
|
|
|
shortcutAttr,
|
|
|
|
handler,
|
|
|
|
description
|
|
|
|
);
|
2016-11-03 11:44:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes classes of icon for showing down state
|
|
|
|
*/
|
|
|
|
showMenuDownIcon() {
|
|
|
|
let icon = this.toggleFilmStripIcon;
|
2017-01-12 20:51:53 +00:00
|
|
|
if(icon) {
|
|
|
|
icon.classList.add(this.iconMenuDownClassName);
|
|
|
|
icon.classList.remove(this.iconMenuUpClassName);
|
|
|
|
}
|
2016-11-03 11:44:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes classes of icon for showing up state
|
|
|
|
*/
|
|
|
|
showMenuUpIcon() {
|
|
|
|
let icon = this.toggleFilmStripIcon;
|
2017-01-12 20:51:53 +00:00
|
|
|
if(icon) {
|
|
|
|
icon.classList.add(this.iconMenuUpClassName);
|
|
|
|
icon.classList.remove(this.iconMenuDownClassName);
|
|
|
|
}
|
2016-02-24 21:05:24 +00:00
|
|
|
},
|
|
|
|
|
2016-03-11 10:54:06 +00:00
|
|
|
/**
|
|
|
|
* Toggles the visibility of the film strip.
|
|
|
|
*
|
|
|
|
* @param visible optional {Boolean} which specifies the desired visibility
|
|
|
|
* of the film strip. If not specified, the visibility will be flipped
|
|
|
|
* (i.e. toggled); otherwise, the visibility will be set to the specified
|
|
|
|
* value.
|
2016-12-04 19:28:48 +00:00
|
|
|
* @param {Boolean} sendAnalytics - True to send an analytics event. The
|
|
|
|
* default value is true.
|
2016-11-18 17:26:33 +00:00
|
|
|
*
|
|
|
|
* Note:
|
|
|
|
* This method shouldn't be executed directly to hide the filmstrip.
|
|
|
|
* It's important to hide the filmstrip with UI.toggleFilmstrip in order
|
|
|
|
* to correctly resize the video area.
|
2016-03-11 10:54:06 +00:00
|
|
|
*/
|
2016-12-02 22:23:12 +00:00
|
|
|
toggleFilmStrip(visible, sendAnalytics = true) {
|
2016-12-04 19:28:48 +00:00
|
|
|
const isVisibleDefined = typeof visible === 'boolean';
|
2016-11-03 13:02:03 +00:00
|
|
|
if (!isVisibleDefined) {
|
|
|
|
visible = this.isFilmStripVisible();
|
|
|
|
} else if (this.isFilmStripVisible() === visible) {
|
2016-03-11 10:54:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-12-04 19:28:48 +00:00
|
|
|
if (sendAnalytics) {
|
2016-12-02 22:23:12 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.filmstrip.toggled');
|
|
|
|
}
|
2016-02-24 21:05:24 +00:00
|
|
|
this.filmStrip.toggleClass("hidden");
|
2016-03-11 10:55:29 +00:00
|
|
|
|
2016-12-04 19:28:48 +00:00
|
|
|
if (visible) {
|
2016-11-03 13:02:03 +00:00
|
|
|
this.showMenuUpIcon();
|
2016-12-04 19:28:48 +00:00
|
|
|
} else {
|
|
|
|
this.showMenuDownIcon();
|
2016-11-03 13:02:03 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 10:55:29 +00:00
|
|
|
// Emit/fire UIEvents.TOGGLED_FILM_STRIP.
|
2016-12-04 19:28:48 +00:00
|
|
|
const eventEmitter = this.eventEmitter;
|
2016-03-11 10:55:29 +00:00
|
|
|
if (eventEmitter) {
|
|
|
|
eventEmitter.emit(
|
2016-09-14 15:11:53 +00:00
|
|
|
UIEvents.TOGGLED_FILM_STRIP,
|
|
|
|
this.isFilmStripVisible());
|
2016-03-11 10:55:29 +00:00
|
|
|
}
|
2016-02-24 21:05:24 +00:00
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
|
|
|
* Shows if filmstrip is visible
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2016-11-03 11:44:17 +00:00
|
|
|
isFilmStripVisible() {
|
2016-02-24 21:05:24 +00:00
|
|
|
return !this.filmStrip.hasClass('hidden');
|
|
|
|
},
|
|
|
|
|
2016-11-03 11:44:17 +00:00
|
|
|
setupFilmStripOnly() {
|
2016-02-24 21:05:24 +00:00
|
|
|
this.filmStrip.css({
|
|
|
|
padding: "0px 0px 18px 0px",
|
|
|
|
right: 0
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
|
|
|
* Returns the height of filmstrip
|
|
|
|
* @returns {number} height
|
|
|
|
*/
|
2016-11-03 11:44:17 +00:00
|
|
|
getFilmStripHeight() {
|
2016-02-24 21:05:24 +00:00
|
|
|
if (this.isFilmStripVisible()) {
|
2016-11-11 17:55:18 +00:00
|
|
|
return $(`.${this.filmStripContainerClassName}`).outerHeight();
|
2016-02-24 21:05:24 +00:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
|
|
|
* Returns the width of filmstip
|
|
|
|
* @returns {number} width
|
|
|
|
*/
|
2016-11-03 11:44:17 +00:00
|
|
|
getFilmStripWidth() {
|
2016-02-24 21:05:24 +00:00
|
|
|
return this.filmStrip.innerWidth()
|
|
|
|
- parseInt(this.filmStrip.css('paddingLeft'), 10)
|
|
|
|
- parseInt(this.filmStrip.css('paddingRight'), 10);
|
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
|
|
|
* Calculates the size for thumbnails: local and remote one
|
|
|
|
* @returns {*|{localVideo, remoteVideo}}
|
|
|
|
*/
|
2016-09-15 02:20:54 +00:00
|
|
|
calculateThumbnailSize() {
|
|
|
|
let availableSizes = this.calculateAvailableSize();
|
|
|
|
let width = availableSizes.availableWidth;
|
|
|
|
let height = availableSizes.availableHeight;
|
|
|
|
|
|
|
|
return this.calculateThumbnailSizeFromAvailable(width, height);
|
|
|
|
},
|
|
|
|
|
2016-11-07 23:00:50 +00:00
|
|
|
/**
|
|
|
|
* Calculates available size for one thumbnail according to
|
|
|
|
* the current window size.
|
|
|
|
*
|
|
|
|
* @returns {{availableWidth: number, availableHeight: number}}
|
|
|
|
*/
|
2016-09-15 02:20:54 +00:00
|
|
|
calculateAvailableSize() {
|
|
|
|
let availableHeight = interfaceConfig.FILM_STRIP_MAX_HEIGHT;
|
|
|
|
let thumbs = this.getThumbs(true);
|
|
|
|
let numvids = thumbs.remoteThumbs.length;
|
2016-02-24 21:05:24 +00:00
|
|
|
|
|
|
|
let localVideoContainer = $("#localVideoContainer");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the videoAreaAvailableWidth is set we use this one to calculate
|
|
|
|
* the filmStrip width, because we're probably in a state where the
|
|
|
|
* film strip size hasn't been updated yet, but it will be.
|
|
|
|
*/
|
2016-03-02 19:21:26 +00:00
|
|
|
let videoAreaAvailableWidth
|
2016-09-08 18:16:23 +00:00
|
|
|
= UIUtil.getAvailableVideoWidth()
|
2016-11-10 17:07:12 +00:00
|
|
|
- this._getFilmstripExtraPanelsWidth()
|
2016-09-14 15:11:53 +00:00
|
|
|
- UIUtil.parseCssInt(this.filmStrip.css('right'), 10)
|
|
|
|
- UIUtil.parseCssInt(this.filmStrip.css('paddingLeft'), 10)
|
|
|
|
- UIUtil.parseCssInt(this.filmStrip.css('paddingRight'), 10)
|
|
|
|
- UIUtil.parseCssInt(this.filmStrip.css('borderLeftWidth'), 10)
|
|
|
|
- UIUtil.parseCssInt(this.filmStrip.css('borderRightWidth'), 10)
|
2016-05-01 18:35:18 +00:00
|
|
|
- 5;
|
|
|
|
|
|
|
|
let availableWidth = videoAreaAvailableWidth;
|
|
|
|
|
2016-09-15 02:20:54 +00:00
|
|
|
// If local thumb is not hidden
|
|
|
|
if(thumbs.localThumb) {
|
2016-05-01 18:35:18 +00:00
|
|
|
availableWidth = Math.floor(
|
2016-09-15 02:20:54 +00:00
|
|
|
(videoAreaAvailableWidth - (
|
2016-05-01 18:35:18 +00:00
|
|
|
UIUtil.parseCssInt(
|
|
|
|
localVideoContainer.css('borderLeftWidth'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
localVideoContainer.css('borderRightWidth'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
localVideoContainer.css('paddingLeft'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
localVideoContainer.css('paddingRight'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
localVideoContainer.css('marginLeft'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
localVideoContainer.css('marginRight'), 10)))
|
2016-09-15 02:20:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the number of videos is 0 or undefined we don't need to calculate
|
|
|
|
// further.
|
|
|
|
if (numvids) {
|
|
|
|
let remoteVideoContainer = thumbs.remoteThumbs.eq(0);
|
|
|
|
availableWidth = Math.floor(
|
|
|
|
(videoAreaAvailableWidth - numvids * (
|
|
|
|
UIUtil.parseCssInt(
|
|
|
|
remoteVideoContainer.css('borderLeftWidth'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
remoteVideoContainer.css('borderRightWidth'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
remoteVideoContainer.css('paddingLeft'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
remoteVideoContainer.css('paddingRight'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
remoteVideoContainer.css('marginLeft'), 10)
|
|
|
|
+ UIUtil.parseCssInt(
|
|
|
|
remoteVideoContainer.css('marginRight'), 10)))
|
|
|
|
);
|
|
|
|
}
|
2016-02-24 21:05:24 +00:00
|
|
|
|
|
|
|
let maxHeight
|
|
|
|
// If the MAX_HEIGHT property hasn't been specified
|
|
|
|
// we have the static value.
|
2016-09-15 02:20:54 +00:00
|
|
|
= Math.min(interfaceConfig.FILM_STRIP_MAX_HEIGHT || 120,
|
|
|
|
availableHeight);
|
2016-02-24 21:05:24 +00:00
|
|
|
|
|
|
|
availableHeight
|
2016-09-15 02:20:54 +00:00
|
|
|
= Math.min(maxHeight, window.innerHeight - 18);
|
|
|
|
|
|
|
|
return { availableWidth, availableHeight };
|
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
2016-11-08 11:10:50 +00:00
|
|
|
* Traverse all elements inside the filmstrip
|
|
|
|
* and calculates the sum of all of them except
|
|
|
|
* remote videos element. Used for calculation of
|
2016-11-10 17:07:12 +00:00
|
|
|
* available width for video thumbnails.
|
|
|
|
*
|
2016-11-08 11:10:50 +00:00
|
|
|
* @returns {number} calculated width
|
|
|
|
* @private
|
2016-11-04 16:13:57 +00:00
|
|
|
*/
|
2016-11-10 17:07:12 +00:00
|
|
|
_getFilmstripExtraPanelsWidth() {
|
2016-11-04 16:13:57 +00:00
|
|
|
let className = this.filmStripContainerClassName;
|
2016-11-08 11:10:50 +00:00
|
|
|
let width = 0;
|
2016-11-04 16:13:57 +00:00
|
|
|
$(`.${className}`)
|
|
|
|
.children()
|
|
|
|
.each(function () {
|
|
|
|
if (this.id !== 'remoteVideos') {
|
2016-11-08 11:10:50 +00:00
|
|
|
width += $(this).outerWidth();
|
2016-11-04 16:13:57 +00:00
|
|
|
}
|
|
|
|
});
|
2016-11-08 11:10:50 +00:00
|
|
|
return width;
|
2016-11-04 16:13:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
Calculate the thumbnail size in order to fit all the thumnails in passed
|
2016-09-19 16:20:59 +00:00
|
|
|
* dimensions.
|
|
|
|
* NOTE: Here we assume that the remote and local thumbnails are with the
|
|
|
|
* same height.
|
|
|
|
* @param {int} availableWidth the maximum width for all thumbnails
|
|
|
|
* @param {int} availableHeight the maximum height for all thumbnails
|
2016-11-04 16:13:57 +00:00
|
|
|
* @returns {{localVideo, remoteVideo}}
|
2016-11-03 13:12:45 +00:00
|
|
|
*/
|
2016-09-15 02:20:54 +00:00
|
|
|
calculateThumbnailSizeFromAvailable(availableWidth, availableHeight) {
|
2016-09-19 16:20:59 +00:00
|
|
|
/**
|
|
|
|
* Let:
|
|
|
|
* lW - width of the local thumbnail
|
|
|
|
* rW - width of the remote thumbnail
|
|
|
|
* h - the height of the thumbnails
|
|
|
|
* remoteRatio - width:height for the remote thumbnail
|
|
|
|
* localRatio - width:height for the local thumbnail
|
|
|
|
* numberRemoteThumbs - number of remote thumbnails (we have only one
|
|
|
|
* local thumbnail)
|
|
|
|
*
|
|
|
|
* Since the height for local thumbnail = height for remote thumbnail
|
|
|
|
* and we know the ratio (width:height) for the local and for the
|
|
|
|
* remote thumbnail we can find rW/lW:
|
|
|
|
* rW / remoteRatio = lW / localRatio then -
|
|
|
|
* remoteLocalWidthRatio = rW / lW = remoteRatio / localRatio
|
|
|
|
* and rW = lW * remoteRatio / localRatio = lW * remoteLocalWidthRatio
|
|
|
|
* And the total width for the thumbnails is:
|
|
|
|
* totalWidth = rW * numberRemoteThumbs + lW
|
|
|
|
* = lW * remoteLocalWidthRatio * numberRemoteThumbs + lW =
|
|
|
|
* lW * (remoteLocalWidthRatio * numberRemoteThumbs + 1)
|
|
|
|
* and the h = lW/localRatio
|
|
|
|
*
|
|
|
|
* In order to fit all the thumbails in the area defined by
|
|
|
|
* availableWidth * availableHeight we should check one of the
|
|
|
|
* following options:
|
|
|
|
* 1) if availableHeight == h - totalWidth should be less than
|
|
|
|
* availableWidth
|
|
|
|
* 2) if availableWidth == totalWidth - h should be less than
|
|
|
|
* availableHeight
|
|
|
|
*
|
|
|
|
* 1) or 2) will be true and we are going to use it to calculate all
|
|
|
|
* sizes.
|
|
|
|
*
|
|
|
|
* if 1) is true that means that
|
|
|
|
* availableHeight/h > availableWidth/totalWidth otherwise 2) is true
|
|
|
|
*/
|
2016-09-15 02:20:54 +00:00
|
|
|
|
2016-09-19 16:20:59 +00:00
|
|
|
const numberRemoteThumbs = this.getThumbs(true).remoteThumbs.length;
|
|
|
|
const remoteLocalWidthRatio = interfaceConfig.REMOTE_THUMBNAIL_RATIO /
|
|
|
|
interfaceConfig.LOCAL_THUMBNAIL_RATIO;
|
|
|
|
const lW = Math.min(availableWidth /
|
|
|
|
(remoteLocalWidthRatio * numberRemoteThumbs + 1), availableHeight *
|
|
|
|
interfaceConfig.LOCAL_THUMBNAIL_RATIO);
|
|
|
|
const h = lW / interfaceConfig.LOCAL_THUMBNAIL_RATIO;
|
2016-11-04 16:13:57 +00:00
|
|
|
return {
|
|
|
|
localVideo:{
|
2016-09-19 16:20:59 +00:00
|
|
|
thumbWidth: lW,
|
|
|
|
thumbHeight: h
|
2016-11-04 16:13:57 +00:00
|
|
|
},
|
|
|
|
remoteVideo: {
|
2016-09-19 16:20:59 +00:00
|
|
|
thumbWidth: lW * remoteLocalWidthRatio,
|
|
|
|
thumbHeight: h
|
|
|
|
}
|
|
|
|
};
|
2016-02-24 21:05:24 +00:00
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
|
|
|
* Resizes thumbnails
|
|
|
|
* @param local
|
|
|
|
* @param remote
|
|
|
|
* @param animate
|
|
|
|
* @param forceUpdate
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2016-12-04 19:28:48 +00:00
|
|
|
resizeThumbnails(local, remote, animate = false, forceUpdate = false) {
|
2016-02-24 21:05:24 +00:00
|
|
|
return new Promise(resolve => {
|
2016-09-15 02:20:54 +00:00
|
|
|
let thumbs = this.getThumbs(!forceUpdate);
|
2016-11-11 14:05:41 +00:00
|
|
|
let promises = [];
|
|
|
|
|
|
|
|
if(thumbs.localThumb) {
|
|
|
|
promises.push(new Promise((resolve) => {
|
|
|
|
thumbs.localThumb.animate({
|
|
|
|
height: local.thumbHeight,
|
|
|
|
width: local.thumbWidth
|
|
|
|
}, this._getAnimateOptions(animate, resolve));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
if(thumbs.remoteThumbs) {
|
|
|
|
promises.push(new Promise((resolve) => {
|
|
|
|
thumbs.remoteThumbs.animate({
|
|
|
|
height: remote.thumbHeight,
|
|
|
|
width: remote.thumbWidth
|
|
|
|
}, this._getAnimateOptions(animate, resolve));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
promises.push(new Promise((resolve) => {
|
|
|
|
this.filmStrip.animate({
|
|
|
|
// adds 2 px because of small video 1px border
|
|
|
|
height: remote.thumbHeight + 2
|
|
|
|
}, this._getAnimateOptions(animate, resolve));
|
|
|
|
}));
|
2016-11-11 15:09:07 +00:00
|
|
|
|
2016-11-14 10:45:28 +00:00
|
|
|
promises.push(new Promise(() => {
|
|
|
|
let { localThumb } = this.getThumbs();
|
|
|
|
let height = localThumb.height();
|
|
|
|
let fontSize = UIUtil.getIndicatorFontSize(height);
|
|
|
|
this.filmStrip.find('.indicator').animate({
|
|
|
|
fontSize
|
|
|
|
}, this._getAnimateOptions(animate, resolve));
|
|
|
|
}));
|
2016-02-24 21:05:24 +00:00
|
|
|
|
|
|
|
if (!animate) {
|
|
|
|
resolve();
|
|
|
|
}
|
2016-11-11 14:05:41 +00:00
|
|
|
|
|
|
|
Promise.all(promises).then(resolve);
|
2016-02-24 21:05:24 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-11-11 14:05:41 +00:00
|
|
|
/**
|
|
|
|
* Helper method. Returns options for jQuery animation
|
|
|
|
* @param animate {Boolean} - animation flag
|
|
|
|
* @param cb {Function} - complete callback
|
|
|
|
* @returns {Object} - animation options object
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_getAnimateOptions(animate, cb = $.noop) {
|
|
|
|
return {
|
|
|
|
queue: false,
|
|
|
|
duration: animate ? 500 : 0,
|
|
|
|
complete: cb
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2016-11-03 13:12:45 +00:00
|
|
|
/**
|
|
|
|
* Returns thumbnails of the filmstrip
|
|
|
|
* @param only_visible
|
|
|
|
* @returns {object} thumbnails
|
|
|
|
*/
|
2016-11-03 11:44:17 +00:00
|
|
|
getThumbs(only_visible = false) {
|
2016-02-24 21:05:24 +00:00
|
|
|
let selector = 'span';
|
|
|
|
if (only_visible) {
|
|
|
|
selector += ':visible';
|
|
|
|
}
|
|
|
|
|
2016-09-15 02:20:54 +00:00
|
|
|
let localThumb = $("#localVideoContainer");
|
|
|
|
let remoteThumbs = this.filmStrip.children(selector)
|
|
|
|
.not("#localVideoContainer");
|
|
|
|
|
2016-05-01 18:35:18 +00:00
|
|
|
// Exclude the local video container if it has been hidden.
|
2016-09-15 02:20:54 +00:00
|
|
|
if (localThumb.hasClass("hidden")) {
|
|
|
|
return { remoteThumbs };
|
|
|
|
} else {
|
|
|
|
return { remoteThumbs, localThumb };
|
|
|
|
}
|
2016-09-28 21:31:40 +00:00
|
|
|
}
|
2016-02-24 21:05:24 +00:00
|
|
|
};
|
|
|
|
|
2016-09-23 21:44:32 +00:00
|
|
|
export default FilmStrip;
|