Pārlūkot izejas kodu

Clean up js from styles

master
Ilya Daynatovich 8 gadus atpakaļ
vecāks
revīzija
1b1b9475a4
2 mainītis faili ar 42 papildinājumiem un 15 dzēšanām
  1. 12
    2
      modules/UI/util/UIUtil.js
  2. 30
    13
      modules/UI/videolayout/SmallVideo.js

+ 12
- 2
modules/UI/util/UIUtil.js Parādīt failu

228
      * @param {String} the identifier of the element to show
228
      * @param {String} the identifier of the element to show
229
      */
229
      */
230
     showElement(id) {
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
         if (!element) {
238
         if (!element) {
234
             return;
239
             return;
249
      * @param {String} the identifier of the element to hide
254
      * @param {String} the identifier of the element to hide
250
      */
255
      */
251
     hideElement(id) {
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
         if (!element) {
264
         if (!element) {
255
             return;
265
             return;

+ 30
- 13
modules/UI/videolayout/SmallVideo.js Parādīt failu

216
  * or hidden
216
  * or hidden
217
  */
217
  */
218
 SmallVideo.prototype.showAudioIndicator = function(isMuted) {
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
  * Returns the audio muted indicator jquery object. If it doesn't exists -
228
  * Returns the audio muted indicator jquery object. If it doesn't exists -
225
  * creates it.
229
  * creates it.
226
  *
230
  *
227
- * @returns {jQuery|HTMLElement} the audio muted indicator
231
+ * @returns {HTMLElement} the audio muted indicator
228
  */
232
  */
229
 SmallVideo.prototype.getAudioMutedIndicator = function () {
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
     if (audioMutedSpan) {
237
     if (audioMutedSpan) {
234
         return audioMutedSpan;
238
         return audioMutedSpan;
241
         "videothumbnail.mute",
245
         "videothumbnail.mute",
242
         "top");
246
         "top");
243
 
247
 
248
+    let mutedIndicator = document.createElement('i');
249
+    mutedIndicator.className = 'icon-mic-disabled';
250
+    audioMutedSpan.appendChild(mutedIndicator);
251
+
244
     this.container
252
     this.container
245
         .querySelector('.videocontainer__toolbar')
253
         .querySelector('.videocontainer__toolbar')
246
         .appendChild(audioMutedSpan);
254
         .appendChild(audioMutedSpan);
247
 
255
 
248
-
249
-    var mutedIndicator = document.createElement('i');
250
-    mutedIndicator.className = 'icon-mic-disabled';
251
-    audioMutedSpan.appendChild(mutedIndicator);
252
-
253
     return audioMutedSpan;
256
     return audioMutedSpan;
254
 };
257
 };
255
 
258
 
263
 SmallVideo.prototype.setVideoMutedView = function(isMuted) {
266
 SmallVideo.prototype.setVideoMutedView = function(isMuted) {
264
     this.isVideoMuted = isMuted;
267
     this.isVideoMuted = isMuted;
265
     this.updateView();
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
         tooltip: 'speaker'
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
         tooltip: 'raisedHand'
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
 /**

Notiek ielāde…
Atcelt
Saglabāt