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