浏览代码

ref(UIUtil): add showOrHideElement

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

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

@@ -392,11 +392,7 @@ var Recording = {
392 392
         let shouldShow = show && _isRecordingButtonEnabled();
393 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,11 +476,8 @@ var Recording = {
480 476
 
481 477
         // Recording spinner
482 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 482
     // checks whether recording is enabled and whether we have params
490 483
     // to start automatically recording

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

@@ -268,11 +268,9 @@ export default {
268 268
      * @param {boolean} show {true} to show those options, {false} to hide them
269 269
      */
270 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,11 +403,7 @@ Toolbar = {
403 403
      */
404 404
     showAuthenticateButton (show) {
405 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 409
     showEtherpadButton () {
@@ -425,10 +421,8 @@ Toolbar = {
425 421
         if (shouldShow) {
426 422
             let el = document.getElementById(id);
427 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 428
     // checks whether desktop sharing is enabled and whether
@@ -446,22 +440,15 @@ Toolbar = {
446 440
             && UIUtil.isButtonEnabled('sip') && show;
447 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 446
     // Shows or hides the dialpad button
457 447
     showDialPadButton (show) {
458 448
         let shouldShow = UIUtil.isButtonEnabled('dialpad') && show;
459 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,13 +457,13 @@ Toolbar = {
470 457
      */
471 458
     setAuthenticatedIdentity (authIdentity) {
472 459
         let id = 'toolbar_auth_identity';
460
+
473 461
         if(authIdentity) {
474
-            UIUtil.showElement(id);
475 462
             $(`#${id}`).text(authIdentity);
476 463
         } else {
477
-            UIUtil.hideElement(id);
478 464
             $(`#${id}`).text('');
479 465
         }
466
+        UIUtil.showOrHideElement(id, !!authIdentity);
480 467
     },
481 468
 
482 469
     /**
@@ -485,11 +472,8 @@ Toolbar = {
485 472
      */
486 473
     showLoginButton (show) {
487 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,11 +482,8 @@ Toolbar = {
498 482
      */
499 483
     showLogoutButton (show) {
500 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,6 +265,21 @@ const IndicatorFontSizes = {
265 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 284
      * Hides the element given by id.
270 285
      *

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

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

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

@@ -215,13 +215,10 @@ SmallVideo.prototype.hideIndicator = function () {
215 215
  * @param {boolean} isMuted indicates if the muted element should be shown
216 216
  * or hidden
217 217
  */
218
-SmallVideo.prototype.showAudioIndicator = function(isMuted) {
218
+SmallVideo.prototype.showAudioIndicator = function (isMuted) {
219 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 223
     this.isAudioMuted = isMuted;
227 224
 };
@@ -270,11 +267,8 @@ SmallVideo.prototype.setVideoMutedView = function(isMuted) {
270 267
     this.updateView();
271 268
 
272 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,11 +570,7 @@ SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
576 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,11 +594,7 @@ SmallVideo.prototype.showRaisedHandIndicator = function (show) {
604 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,11 +1144,7 @@ var VideoLayout = {
1144 1144
     updateResolutionLabel(isResolutionHD) {
1145 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
     /**

正在加载...
取消
保存