浏览代码

ref(UIUtil): add showOrHideElement

j8
paweldomas 8 年前
父节点
当前提交
51da40e90c

+ 3
- 10
modules/UI/recording/Recording.js 查看文件

392
         let shouldShow = show && _isRecordingButtonEnabled();
392
         let shouldShow = show && _isRecordingButtonEnabled();
393
         let id = 'toolbar_button_record';
393
         let id = 'toolbar_button_record';
394
 
394
 
395
-        if (shouldShow) {
396
-            UIUtil.showElement(id);
397
-        } else {
398
-            UIUtil.hideElement(id);
399
-        }
395
+        UIUtil.showOrHideElement(id, shouldShow);
400
     },
396
     },
401
 
397
 
402
     /**
398
     /**
480
 
476
 
481
         // Recording spinner
477
         // Recording spinner
482
         let spinnerId = 'recordingSpinner';
478
         let spinnerId = 'recordingSpinner';
483
-        if(recordingState === Status.RETRYING) {
484
-            UIUtil.showElement(spinnerId);
485
-        } else {
486
-            UIUtil.hideElement(spinnerId);
487
-        }
479
+        UIUtil.showOrHideElement(
480
+            spinnerId, recordingState === Status.RETRYING);
488
     },
481
     },
489
     // checks whether recording is enabled and whether we have params
482
     // checks whether recording is enabled and whether we have params
490
     // to start automatically recording
483
     // to start automatically recording

+ 3
- 5
modules/UI/side_pannels/settings/SettingsMenu.js 查看文件

268
      * @param {boolean} show {true} to show those options, {false} to hide them
268
      * @param {boolean} show {true} to show those options, {false} to hide them
269
      */
269
      */
270
     showFollowMeOptions (show) {
270
     showFollowMeOptions (show) {
271
-        if (show && UIUtil.isSettingEnabled('moderator')) {
272
-            UIUtil.showElement("followMeOptions");
273
-        } else {
274
-            UIUtil.hideElement("followMeOptions");
275
-        }
271
+        UIUtil.showOrHideElement(
272
+            "followMeOptions",
273
+            show && UIUtil.isSettingEnabled('moderator'));
276
     },
274
     },
277
 
275
 
278
     /**
276
     /**

+ 11
- 30
modules/UI/toolbars/Toolbar.js 查看文件

403
      */
403
      */
404
     showAuthenticateButton (show) {
404
     showAuthenticateButton (show) {
405
         let id = 'authenticationContainer';
405
         let id = 'authenticationContainer';
406
-        if (show) {
407
-            UIUtil.showElement(id);
408
-        } else {
409
-            UIUtil.hideElement(id);
410
-        }
406
+        UIUtil.showOrHideElement(id, show);
411
     },
407
     },
412
 
408
 
413
     showEtherpadButton () {
409
     showEtherpadButton () {
425
         if (shouldShow) {
421
         if (shouldShow) {
426
             let el = document.getElementById(id);
422
             let el = document.getElementById(id);
427
             UIUtil.setTooltip(el, 'toolbar.sharedvideo', 'right');
423
             UIUtil.setTooltip(el, 'toolbar.sharedvideo', 'right');
428
-            UIUtil.showElement(id);
429
-        } else {
430
-            UIUtil.hideElement(id);
431
         }
424
         }
425
+        UIUtil.showOrHideElement(id, shouldShow);
432
     },
426
     },
433
 
427
 
434
     // checks whether desktop sharing is enabled and whether
428
     // checks whether desktop sharing is enabled and whether
446
             && UIUtil.isButtonEnabled('sip') && show;
440
             && UIUtil.isButtonEnabled('sip') && show;
447
         let id = 'toolbar_button_sip';
441
         let id = 'toolbar_button_sip';
448
 
442
 
449
-        if (shouldShow) {
450
-            UIUtil.showElement(id);
451
-        } else {
452
-            UIUtil.hideElement(id);
453
-        }
443
+        UIUtil.showOrHideElement(id, shouldShow);
454
     },
444
     },
455
 
445
 
456
     // Shows or hides the dialpad button
446
     // Shows or hides the dialpad button
457
     showDialPadButton (show) {
447
     showDialPadButton (show) {
458
         let shouldShow = UIUtil.isButtonEnabled('dialpad') && show;
448
         let shouldShow = UIUtil.isButtonEnabled('dialpad') && show;
459
         let id = 'toolbar_button_dialpad';
449
         let id = 'toolbar_button_dialpad';
460
-        if (shouldShow) {
461
-            UIUtil.showElement(id);
462
-        } else {
463
-            UIUtil.hideElement(id);
464
-        }
450
+
451
+        UIUtil.showOrHideElement(id, shouldShow);
465
     },
452
     },
466
 
453
 
467
     /**
454
     /**
470
      */
457
      */
471
     setAuthenticatedIdentity (authIdentity) {
458
     setAuthenticatedIdentity (authIdentity) {
472
         let id = 'toolbar_auth_identity';
459
         let id = 'toolbar_auth_identity';
460
+
473
         if(authIdentity) {
461
         if(authIdentity) {
474
-            UIUtil.showElement(id);
475
             $(`#${id}`).text(authIdentity);
462
             $(`#${id}`).text(authIdentity);
476
         } else {
463
         } else {
477
-            UIUtil.hideElement(id);
478
             $(`#${id}`).text('');
464
             $(`#${id}`).text('');
479
         }
465
         }
466
+        UIUtil.showOrHideElement(id, !!authIdentity);
480
     },
467
     },
481
 
468
 
482
     /**
469
     /**
485
      */
472
      */
486
     showLoginButton (show) {
473
     showLoginButton (show) {
487
         let id = 'toolbar_button_login';
474
         let id = 'toolbar_button_login';
488
-        if (show) {
489
-            UIUtil.showElement(id);
490
-        } else {
491
-            UIUtil.hideElement(id);
492
-        }
475
+
476
+        UIUtil.showOrHideElement(id, show);
493
     },
477
     },
494
 
478
 
495
     /**
479
     /**
498
      */
482
      */
499
     showLogoutButton (show) {
483
     showLogoutButton (show) {
500
         let id = 'toolbar_button_logout';
484
         let id = 'toolbar_button_logout';
501
-        if (show) {
502
-            UIUtil.showElement(id);
503
-        } else {
504
-            UIUtil.hideElement(id);
505
-        }
485
+
486
+        UIUtil.showOrHideElement(id, show);
506
     },
487
     },
507
 
488
 
508
     /**
489
     /**

+ 15
- 0
modules/UI/util/UIUtil.js 查看文件

265
         element.classList.add(className);
265
         element.classList.add(className);
266
     },
266
     },
267
 
267
 
268
+    /**
269
+     * Shows or hides the element given (optionally by id).
270
+     *
271
+     * @param {string|HTMLElement} idOrElement the identifier or the element
272
+     *        to show/hide
273
+     * @param {boolean} show <tt>true</tt> to show or <tt>false</tt> to hide
274
+     */
275
+    showOrHideElement(idOrElement, show) {
276
+        if (show) {
277
+            this.showElement(idOrElement);
278
+        } else {
279
+            this.hideElement(idOrElement);
280
+        }
281
+    },
282
+
268
     /**
283
     /**
269
      * Hides the element given by id.
284
      * Hides the element given by id.
270
      *
285
      *

+ 3
- 3
modules/UI/videolayout/LargeVideoManager.js 查看文件

333
         }
333
         }
334
 
334
 
335
         let id = 'localConnectionMessage';
335
         let id = 'localConnectionMessage';
336
+
337
+        UIUtil.showOrHideElement(id, show);
338
+
336
         if (show) {
339
         if (show) {
337
-            UIUtil.showElement(id);
338
             // Avatar message conflicts with 'videoConnectionMessage',
340
             // Avatar message conflicts with 'videoConnectionMessage',
339
             // so it must be hidden
341
             // so it must be hidden
340
             this.showRemoteConnectionMessage(false);
342
             this.showRemoteConnectionMessage(false);
341
-        } else {
342
-            UIUtil.hideElement(id);
343
         }
343
         }
344
     }
344
     }
345
 
345
 

+ 7
- 21
modules/UI/videolayout/SmallVideo.js 查看文件

215
  * @param {boolean} isMuted indicates if the muted element should be shown
215
  * @param {boolean} isMuted indicates if the muted element should be shown
216
  * or hidden
216
  * or hidden
217
  */
217
  */
218
-SmallVideo.prototype.showAudioIndicator = function(isMuted) {
218
+SmallVideo.prototype.showAudioIndicator = function (isMuted) {
219
     let mutedIndicator = this.getAudioMutedIndicator();
219
     let mutedIndicator = this.getAudioMutedIndicator();
220
-    if (isMuted) {
221
-        UIUtil.showElement(mutedIndicator);
222
-    } else {
223
-        UIUtil.hideElement(mutedIndicator);
224
-    }
220
+
221
+    UIUtil.showOrHideElement(mutedIndicator, isMuted);
225
 
222
 
226
     this.isAudioMuted = isMuted;
223
     this.isAudioMuted = isMuted;
227
 };
224
 };
270
     this.updateView();
267
     this.updateView();
271
 
268
 
272
     let element = this.getVideoMutedIndicator();
269
     let element = this.getVideoMutedIndicator();
273
-    if (isMuted) {
274
-        UIUtil.showElement(element);
275
-    } else {
276
-        UIUtil.hideElement(element);
277
-    }
270
+
271
+    UIUtil.showOrHideElement(element, isMuted);
278
 };
272
 };
279
 
273
 
280
 /**
274
 /**
576
         tooltip: 'speaker'
570
         tooltip: 'speaker'
577
     });
571
     });
578
 
572
 
579
-    if (show) {
580
-        UIUtil.showElement(indicatorSpan);
581
-    } else {
582
-        UIUtil.hideElement(indicatorSpan);
583
-    }
573
+    UIUtil.showOrHideElement(indicatorSpan, show);
584
 };
574
 };
585
 
575
 
586
 /**
576
 /**
604
         tooltip: 'raisedHand'
594
         tooltip: 'raisedHand'
605
     });
595
     });
606
 
596
 
607
-    if (show) {
608
-        UIUtil.showElement(indicatorSpan);
609
-    } else {
610
-        UIUtil.hideElement(indicatorSpan);
611
-    }
597
+    UIUtil.showOrHideElement(indicatorSpan, show);
612
 };
598
 };
613
 
599
 
614
 /**
600
 /**

+ 1
- 5
modules/UI/videolayout/VideoLayout.js 查看文件

1144
     updateResolutionLabel(isResolutionHD) {
1144
     updateResolutionLabel(isResolutionHD) {
1145
         let id = 'videoResolutionLabel';
1145
         let id = 'videoResolutionLabel';
1146
 
1146
 
1147
-        if (isResolutionHD) {
1148
-            UIUtil.showElement(id);
1149
-        } else {
1150
-            UIUtil.hideElement(id);
1151
-        }
1147
+        UIUtil.showOrHideElement(id, isResolutionHD);
1152
     },
1148
     },
1153
 
1149
 
1154
     /**
1150
     /**

正在加载...
取消
保存