|
@@ -127,74 +127,119 @@ RemoteVideo.prototype._isHovered = function () {
|
127
|
127
|
* @private
|
128
|
128
|
*/
|
129
|
129
|
RemoteVideo.prototype._generatePopupContent = function () {
|
130
|
|
- var popupmenuElement = document.createElement('ul');
|
|
130
|
+ let popupmenuElement = document.createElement('ul');
|
131
|
131
|
popupmenuElement.className = 'popupmenu';
|
132
|
132
|
popupmenuElement.id = `remote_popupmenu_${this.id}`;
|
133
|
133
|
|
134
|
|
- var muteMenuItem = document.createElement('li');
|
135
|
|
- var muteLinkItem = document.createElement('a');
|
|
134
|
+ let muteTranslationKey;
|
|
135
|
+ let muteClassName;
|
|
136
|
+ if (this.isAudioMuted) {
|
|
137
|
+ muteTranslationKey = 'videothumbnail.muted';
|
|
138
|
+ muteClassName = 'mutelink disabled';
|
|
139
|
+ } else {
|
|
140
|
+ muteTranslationKey = 'videothumbnail.domute';
|
|
141
|
+ muteClassName = 'mutelink';
|
|
142
|
+ }
|
136
|
143
|
|
137
|
|
- var mutedIndicator = "<i class='icon-mic-disabled'></i>";
|
|
144
|
+ let muteHandler = this._muteHandler.bind(this);
|
|
145
|
+ let kickHandler = this._kickHandler.bind(this);
|
|
146
|
+
|
|
147
|
+ let menuItems = [
|
|
148
|
+ {
|
|
149
|
+ id: 'mutelink_' + this.id,
|
|
150
|
+ handler: muteHandler,
|
|
151
|
+ icon: 'icon-mic-disabled',
|
|
152
|
+ className: muteClassName,
|
|
153
|
+ data: {
|
|
154
|
+ i18n: muteTranslationKey
|
|
155
|
+ }
|
|
156
|
+ }, {
|
|
157
|
+ id: 'ejectlink_' + this.id,
|
|
158
|
+ handler: kickHandler,
|
|
159
|
+ icon: 'icon-kick',
|
|
160
|
+ data: {
|
|
161
|
+ i18n: 'videothumbnail.kick'
|
|
162
|
+ }
|
|
163
|
+ }
|
|
164
|
+ ];
|
138
|
165
|
|
139
|
|
- var doMuteHTML = mutedIndicator +
|
140
|
|
- " <div data-i18n='videothumbnail.domute'></div>";
|
|
166
|
+ menuItems.forEach(el => {
|
|
167
|
+ let menuItem = this._generatePopupMenuItem(el);
|
|
168
|
+ popupmenuElement.appendChild(menuItem);
|
|
169
|
+ });
|
141
|
170
|
|
142
|
|
- var mutedHTML = mutedIndicator +
|
143
|
|
- " <div data-i18n='videothumbnail.muted'></div>";
|
|
171
|
+ APP.translation.translateElement($(popupmenuElement));
|
144
|
172
|
|
145
|
|
- muteLinkItem.id = "mutelink_" + this.id;
|
|
173
|
+ return popupmenuElement;
|
|
174
|
+};
|
146
|
175
|
|
147
|
|
- if (this.isAudioMuted) {
|
148
|
|
- muteLinkItem.innerHTML = mutedHTML;
|
149
|
|
- muteLinkItem.className = 'mutelink disabled';
|
150
|
|
- }
|
151
|
|
- else {
|
152
|
|
- muteLinkItem.innerHTML = doMuteHTML;
|
153
|
|
- muteLinkItem.className = 'mutelink';
|
154
|
|
- }
|
|
176
|
+RemoteVideo.prototype._muteHandler = function () {
|
|
177
|
+ if (this.isAudioMuted)
|
|
178
|
+ return;
|
155
|
179
|
|
156
|
|
- // Delegate event to the document.
|
157
|
|
- $(document).on("click", "#mutelink_" + this.id, () => {
|
158
|
|
- if (this.isAudioMuted)
|
159
|
|
- return;
|
|
180
|
+ RemoteVideo.showMuteParticipantDialog().then(reason => {
|
|
181
|
+ if(reason === MUTED_DIALOG_BUTTON_VALUES.muted) {
|
|
182
|
+ this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
|
|
183
|
+ }
|
|
184
|
+ }).catch(e => {
|
|
185
|
+ //currently shouldn't be called
|
|
186
|
+ console.error(e);
|
|
187
|
+ });
|
160
|
188
|
|
161
|
|
- RemoteVideo.showMuteParticipantDialog().then(reason => {
|
162
|
|
- if(reason === MUTED_DIALOG_BUTTON_VALUES.muted) {
|
163
|
|
- this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
|
164
|
|
- }
|
165
|
|
- }).catch(e => {
|
166
|
|
- //currently shouldn't be called
|
167
|
|
- console.error(e);
|
168
|
|
- });
|
|
189
|
+ this.popover.forceHide();
|
|
190
|
+};
|
169
|
191
|
|
170
|
|
- this.popover.forceHide();
|
171
|
|
- });
|
|
192
|
+RemoteVideo.prototype._kickHandler = function () {
|
|
193
|
+ this.emitter.emit(UIEvents.USER_KICKED, this.id);
|
|
194
|
+ this.popover.forceHide();
|
|
195
|
+};
|
172
|
196
|
|
173
|
|
- muteMenuItem.appendChild(muteLinkItem);
|
174
|
|
- popupmenuElement.appendChild(muteMenuItem);
|
|
197
|
+RemoteVideo.prototype._generatePopupMenuItem = function (opts = {}) {
|
|
198
|
+ let {
|
|
199
|
+ id,
|
|
200
|
+ handler,
|
|
201
|
+ icon,
|
|
202
|
+ data,
|
|
203
|
+ className
|
|
204
|
+ } = opts;
|
175
|
205
|
|
176
|
|
- var ejectIndicator = "<i style='float:left;' class='icon-kick'></i>";
|
|
206
|
+ handler = handler || $.noop;
|
177
|
207
|
|
178
|
|
- var ejectMenuItem = document.createElement('li');
|
179
|
|
- var ejectLinkItem = document.createElement('a');
|
|
208
|
+ let menuItem = document.createElement('li');
|
|
209
|
+ menuItem.className = 'popupmenu__item';
|
180
|
210
|
|
181
|
|
- var ejectText = "<div data-i18n='videothumbnail.kick'></div>";
|
|
211
|
+ let linkItem = document.createElement('a');
|
|
212
|
+ linkItem.className = 'popupmenu__link';
|
182
|
213
|
|
183
|
|
- ejectLinkItem.className = 'ejectlink';
|
184
|
|
- ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
|
185
|
|
- ejectLinkItem.id = "ejectlink_" + this.id;
|
|
214
|
+ if (className) {
|
|
215
|
+ linkItem.className += ` ${className}`;
|
|
216
|
+ }
|
186
|
217
|
|
187
|
|
- $(document).on("click", "#ejectlink_" + this.id, function(){
|
188
|
|
- this.emitter.emit(UIEvents.USER_KICKED, this.id);
|
189
|
|
- this.popover.forceHide();
|
190
|
|
- }.bind(this));
|
|
218
|
+ if (icon) {
|
|
219
|
+ let indicator = document.createElement('span');
|
|
220
|
+ indicator.className = 'popupmenu__icon';
|
|
221
|
+ indicator.innerHTML = `<i class="${icon}"></i>`;
|
|
222
|
+ linkItem.appendChild(indicator);
|
|
223
|
+ }
|
191
|
224
|
|
192
|
|
- ejectMenuItem.appendChild(ejectLinkItem);
|
193
|
|
- popupmenuElement.appendChild(ejectMenuItem);
|
|
225
|
+ let textContent = document.createElement('span');
|
|
226
|
+ textContent.className = 'popupmenu__text';
|
194
|
227
|
|
195
|
|
- APP.translation.translateElement($(popupmenuElement));
|
|
228
|
+ if (data) {
|
|
229
|
+ let dataKeys = Object.keys(data);
|
|
230
|
+ dataKeys.forEach(key => {
|
|
231
|
+ textContent.dataset[key] = data[key];
|
|
232
|
+ });
|
|
233
|
+ }
|
196
|
234
|
|
197
|
|
- return popupmenuElement;
|
|
235
|
+ linkItem.appendChild(textContent);
|
|
236
|
+ linkItem.id = id;
|
|
237
|
+
|
|
238
|
+ // Delegate event to the document.
|
|
239
|
+ $(document).on("click", `#${id}`, handler);
|
|
240
|
+ menuItem.appendChild(linkItem);
|
|
241
|
+
|
|
242
|
+ return menuItem;
|
198
|
243
|
};
|
199
|
244
|
|
200
|
245
|
/**
|