瀏覽代碼

Clean up js from styles

master
Ilya Daynatovich 8 年之前
父節點
當前提交
1b1b9475a4
共有 2 個文件被更改,包括 42 次插入15 次删除
  1. 12
    2
      modules/UI/util/UIUtil.js
  2. 30
    13
      modules/UI/videolayout/SmallVideo.js

+ 12
- 2
modules/UI/util/UIUtil.js 查看文件

@@ -228,7 +228,12 @@ const SHOW_CLASSES = {
228 228
      * @param {String} the identifier of the element to show
229 229
      */
230 230
     showElement(id) {
231
-        let element = document.getElementById(id);
231
+        let element;
232
+        if (id instanceof HTMLElement) {
233
+            element = id;
234
+        } else {
235
+            element = document.getElementById(id);
236
+        }
232 237
 
233 238
         if (!element) {
234 239
             return;
@@ -249,7 +254,12 @@ const SHOW_CLASSES = {
249 254
      * @param {String} the identifier of the element to hide
250 255
      */
251 256
     hideElement(id) {
252
-        let element = document.getElementById(id);
257
+        let element;
258
+        if (id instanceof HTMLElement) {
259
+            element = id;
260
+        } else {
261
+            element = document.getElementById(id);
262
+        }
253 263
 
254 264
         if (!element) {
255 265
             return;

+ 30
- 13
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -216,19 +216,23 @@ SmallVideo.prototype.hideIndicator = function () {
216 216
  * or hidden
217 217
  */
218 218
 SmallVideo.prototype.showAudioIndicator = function(isMuted) {
219
-    this.getAudioMutedIndicator().classList.toggle('hide', !isMuted);
220
-    this.isAudioMuted = isMuted;
219
+    let mutedIndicator = this.getAudioMutedIndicator();
220
+    if (isMuted) {
221
+        UIUtil.showElement(mutedIndicator);
222
+    } else {
223
+        UIUtil.hideElement(mutedIndicator);
224
+    }
221 225
 };
222 226
 
223 227
 /**
224 228
  * Returns the audio muted indicator jquery object. If it doesn't exists -
225 229
  * creates it.
226 230
  *
227
- * @returns {jQuery|HTMLElement} the audio muted indicator
231
+ * @returns {HTMLElement} the audio muted indicator
228 232
  */
229 233
 SmallVideo.prototype.getAudioMutedIndicator = function () {
230
-    var selector = '#' + this.videoSpanId + ' .audioMuted';
231
-    var audioMutedSpan = document.querySelector(selector);
234
+    let selector = '#' + this.videoSpanId + ' .audioMuted';
235
+    let audioMutedSpan = document.querySelector(selector);
232 236
 
233 237
     if (audioMutedSpan) {
234 238
         return audioMutedSpan;
@@ -241,15 +245,14 @@ SmallVideo.prototype.getAudioMutedIndicator = function () {
241 245
         "videothumbnail.mute",
242 246
         "top");
243 247
 
248
+    let mutedIndicator = document.createElement('i');
249
+    mutedIndicator.className = 'icon-mic-disabled';
250
+    audioMutedSpan.appendChild(mutedIndicator);
251
+
244 252
     this.container
245 253
         .querySelector('.videocontainer__toolbar')
246 254
         .appendChild(audioMutedSpan);
247 255
 
248
-
249
-    var mutedIndicator = document.createElement('i');
250
-    mutedIndicator.className = 'icon-mic-disabled';
251
-    audioMutedSpan.appendChild(mutedIndicator);
252
-
253 256
     return audioMutedSpan;
254 257
 };
255 258
 
@@ -263,7 +266,13 @@ SmallVideo.prototype.getAudioMutedIndicator = function () {
263 266
 SmallVideo.prototype.setVideoMutedView = function(isMuted) {
264 267
     this.isVideoMuted = isMuted;
265 268
     this.updateView();
266
-    this.getVideoMutedIndicator().classList.toggle('hide', !isMuted);
269
+
270
+    let element = this.getVideoMutedIndicator();
271
+    if (isMuted) {
272
+        UIUtil.showElement(element);
273
+    } else {
274
+        UIUtil.hideElement(element);
275
+    }
267 276
 };
268 277
 
269 278
 /**
@@ -565,7 +574,11 @@ SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
565 574
         tooltip: 'speaker'
566 575
     });
567 576
 
568
-    indicatorSpan.classList.toggle('show', show);
577
+    if (show) {
578
+        UIUtil.showElement(indicatorSpan);
579
+    } else {
580
+        UIUtil.hideElement(indicatorSpan);
581
+    }
569 582
 };
570 583
 
571 584
 /**
@@ -589,7 +602,11 @@ SmallVideo.prototype.showRaisedHandIndicator = function (show) {
589 602
         tooltip: 'raisedHand'
590 603
     });
591 604
 
592
-    indicatorSpan.classList.toggle('show', show);
605
+    if (show) {
606
+        UIUtil.showElement(indicatorSpan);
607
+    } else {
608
+        UIUtil.hideElement(indicatorSpan);
609
+    }
593 610
 };
594 611
 
595 612
 /**

Loading…
取消
儲存