Quellcode durchsuchen

Merge branch 'restyle-toggle-state'

master
Lyubomir Marinov vor 8 Jahren
Ursprung
Commit
b8af817ea3

+ 5
- 4
conference.js Datei anzeigen

@@ -579,11 +579,11 @@ export default {
579 579
                 // if user didn't give access to mic or camera or doesn't have
580 580
                 // them at all, we disable corresponding toolbar buttons
581 581
                 if (!tracks.find((t) => t.isAudioTrack())) {
582
-                    APP.UI.disableMicrophoneButton();
582
+                    APP.UI.setMicrophoneButtonEnabled(false);
583 583
                 }
584 584
 
585 585
                 if (!tracks.find((t) => t.isVideoTrack())) {
586
-                    APP.UI.disableCameraButton();
586
+                    APP.UI.setCameraButtonEnabled(false);
587 587
                 }
588 588
 
589 589
                 this._initDeviceList();
@@ -966,7 +966,8 @@ export default {
966 966
 
967 967
                 APP.UI.addLocalStream(stream);
968 968
 
969
-                stream.videoType === 'camera' && APP.UI.enableCameraButton();
969
+                stream.videoType === 'camera'
970
+                    && APP.UI.setCameraButtonEnabled(true);
970 971
             } else {
971 972
                 this.videoMuted = false;
972 973
                 this.isSharingScreen = false;
@@ -1006,7 +1007,7 @@ export default {
1006 1007
                 this.audioMuted = false;
1007 1008
             }
1008 1009
 
1009
-            APP.UI.enableMicrophoneButton();
1010
+            APP.UI.setMicrophoneButtonEnabled(true);
1010 1011
             APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted);
1011 1012
         });
1012 1013
     },

+ 0
- 4
css/_base.scss Datei anzeigen

@@ -81,10 +81,6 @@ form {
81 81
     display: block;
82 82
 }
83 83
 
84
-.active {
85
-    background-color: #00ccff;
86
-}
87
-
88 84
 .watermark {
89 85
     display: block;
90 86
     position: absolute;

+ 3
- 4
css/_toolbars.scss Datei anzeigen

@@ -42,7 +42,7 @@
42 42
     margin-left: auto;
43 43
     margin-right: auto;
44 44
     width: auto;
45
-    border-radius: 4px;
45
+    border-radius: 3px;
46 46
 
47 47
     .first {
48 48
         border-bottom-left-radius: 4px;
@@ -111,9 +111,8 @@
111 111
     cursor: default;
112 112
 }
113 113
 
114
-.button.glow
115
-{
116
-    text-shadow: 0px 0px 5px $toolbarToggleBackground;
114
+.button.toggled {
115
+    background: $toolbarToggleBackground !important;
117 116
 }
118 117
 
119 118
 a.button.unclickable:hover,

+ 1
- 1
css/_variables.scss Datei anzeigen

@@ -30,7 +30,7 @@ $toolbarSelectBackground: rgba(0, 0, 0, .6);
30 30
 
31 31
 $toolbarBadgeBackground: #165ECC;
32 32
 $toolbarBadgeColor: #FFFFFF;
33
-$toolbarToggleBackground: #165ECC;
33
+$toolbarToggleBackground: #12499C;
34 34
 
35 35
 // Main controls
36 36
 $inputBackground: rgba(132, 132, 132, .5);

+ 14
- 22
modules/UI/UI.js Datei anzeigen

@@ -820,7 +820,7 @@ UI.askForNickname = function () {
820 820
 UI.setAudioMuted = function (id, muted) {
821 821
     VideoLayout.onAudioMute(id, muted);
822 822
     if (APP.conference.isLocalId(id)) {
823
-        Toolbar.markAudioIconAsMuted(muted);
823
+        Toolbar.toggleAudioIcon(muted);
824 824
     }
825 825
 };
826 826
 
@@ -830,7 +830,7 @@ UI.setAudioMuted = function (id, muted) {
830 830
 UI.setVideoMuted = function (id, muted) {
831 831
     VideoLayout.onVideoMute(id, muted);
832 832
     if (APP.conference.isLocalId(id)) {
833
-        Toolbar.markVideoIconAsMuted(muted);
833
+        Toolbar.toggleVideoIcon(muted);
834 834
     }
835 835
 };
836 836
 
@@ -1459,31 +1459,23 @@ UI.onSharedVideoStop = function (id, attributes) {
1459 1459
 };
1460 1460
 
1461 1461
 /**
1462
- * Disables camera toolbar button.
1463
- */
1464
-UI.disableCameraButton = function () {
1465
-    Toolbar.markVideoIconAsDisabled(true);
1466
-};
1467
-
1468
-/**
1469
- * Enables camera toolbar button.
1470
- */
1471
-UI.enableCameraButton = function () {
1472
-    Toolbar.markVideoIconAsDisabled(false);
1473
-};
1474
-
1475
-/**
1476
- * Disables microphone toolbar button.
1462
+ * Enables / disables camera toolbar button.
1463
+ *
1464
+ * @param {boolean} enabled indicates if the camera button should be enabled
1465
+ * or disabled
1477 1466
  */
1478
-UI.disableMicrophoneButton = function () {
1479
-    Toolbar.markAudioIconAsDisabled(true);
1467
+UI.setCameraButtonEnabled = function (enabled) {
1468
+    Toolbar.setVideoIconEnabled(enabled);
1480 1469
 };
1481 1470
 
1482 1471
 /**
1483
- * Enables microphone toolbar button.
1472
+ * Enables / disables microphone toolbar button.
1473
+ *
1474
+ * @param {boolean} enabled indicates if the microphone button should be
1475
+ * enabled or disabled
1484 1476
  */
1485
-UI.enableMicrophoneButton = function () {
1486
-    Toolbar.markAudioIconAsDisabled(false);
1477
+UI.setMicrophoneButtonEnabled = function (enabled) {
1478
+    Toolbar.setAudioIconEnabled(enabled);
1487 1479
 };
1488 1480
 
1489 1481
 UI.showRingOverLay = function () {

+ 15
- 9
modules/UI/recording/Recording.js Datei anzeigen

@@ -422,7 +422,6 @@ var Recording = {
422 422
      * @param recordingState gives us the current recording state
423 423
      */
424 424
     updateRecordingUI (recordingState) {
425
-        let buttonSelector = $('#toolbar_button_record');
426 425
 
427 426
         let oldState = this.currentState;
428 427
         this.currentState = recordingState;
@@ -431,8 +430,7 @@ var Recording = {
431 430
         if (recordingState === Status.ON ||
432 431
             recordingState === Status.RETRYING) {
433 432
 
434
-            buttonSelector.removeClass(this.baseClass);
435
-            buttonSelector.addClass(this.baseClass + " active");
433
+            this._setToolbarButtonToggled(true);
436 434
 
437 435
             this._updateStatusLabel(this.recordingOnKey, false);
438 436
         }
@@ -447,8 +445,7 @@ var Recording = {
447 445
                 && !isStartingStatus(oldState))
448 446
                 return;
449 447
 
450
-            buttonSelector.removeClass(this.baseClass + " active");
451
-            buttonSelector.addClass(this.baseClass);
448
+            this._setToolbarButtonToggled(false);
452 449
 
453 450
             let messageKey;
454 451
             if (isStartingStatus(oldState))
@@ -464,15 +461,14 @@ var Recording = {
464 461
         }
465 462
         else if (recordingState === Status.PENDING) {
466 463
 
467
-            buttonSelector.removeClass(this.baseClass + " active");
468
-            buttonSelector.addClass(this.baseClass);
464
+            this._setToolbarButtonToggled(false);
469 465
 
470 466
             this._updateStatusLabel(this.recordingPendingKey, true);
471 467
         }
472 468
         else if (recordingState === Status.ERROR
473 469
                     || recordingState === Status.FAILED) {
474
-            buttonSelector.removeClass(this.baseClass + " active");
475
-            buttonSelector.addClass(this.baseClass);
470
+
471
+            this._setToolbarButtonToggled(false);
476 472
 
477 473
             this._updateStatusLabel(this.recordingErrorKey, true);
478 474
         }
@@ -513,6 +509,16 @@ var Recording = {
513 509
 
514 510
         labelTextSelector.attr("data-i18n", textKey);
515 511
         labelTextSelector.text(APP.translation.translateString(textKey));
512
+    },
513
+
514
+    /**
515
+     * Sets the toggled state of the recording toolbar button.
516
+     *
517
+     * @param {boolean} isToggled indicates if the button should be toggled
518
+     * or not
519
+     */
520
+    _setToolbarButtonToggled(isToggled) {
521
+        $("#toolbar_button_record").toggleClass("toggled", isToggled);
516 522
     }
517 523
 };
518 524
 

+ 77
- 51
modules/UI/toolbars/Toolbar.js Datei anzeigen

@@ -413,14 +413,14 @@ const Toolbar = {
413 413
         );
414 414
 
415 415
         APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
416
-            function(containerId, isVisible) {
416
+            (containerId, isVisible) => {
417 417
                 Toolbar._handleSideToolbarContainerToggled( containerId,
418 418
                                                             isVisible);
419 419
             });
420 420
 
421 421
         APP.UI.addListener(UIEvents.LOCAL_RAISE_HAND_CHANGED,
422
-            function(isRaisedHand) {
423
-                Toolbar._toggleRaiseHand(isRaisedHand);
422
+            (isRaisedHand) => {
423
+                this._setToggledState("toolbar_button_raisehand", isRaisedHand);
424 424
             });
425 425
 
426 426
         if(!APP.tokenData.isGuest) {
@@ -582,82 +582,97 @@ const Toolbar = {
582 582
      * streaming is active.
583 583
      */
584 584
     updateDesktopSharingButtonState () {
585
-        let button = $("#toolbar_button_desktopsharing");
586
-        if (APP.conference.isSharingScreen) {
587
-            button.addClass("glow");
588
-        } else {
589
-            button.removeClass("glow");
590
-        }
585
+        this._setToggledState(  "toolbar_button_desktopsharing",
586
+                                APP.conference.isSharingScreen);
591 587
     },
592 588
 
593 589
     /**
594
-     * Toggles / untoggles the view for raised hand.
590
+     * Marks video icon as muted or not.
591
+     *
592
+     * @param {boolean} muted if icon should look like muted or not
595 593
      */
596
-    _toggleRaiseHand(isRaisedHand) {
597
-        $('#toolbar_button_raisehand').toggleClass("glow", isRaisedHand);
594
+    toggleVideoIcon (muted) {
595
+        $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
596
+
597
+        this._setToggledState("toolbar_button_camera", muted);
598 598
     },
599 599
 
600 600
     /**
601
-     * Marks video icon as muted or not.
602
-     * @param {boolean} muted if icon should look like muted or not
601
+     * Enables / disables audio toolbar button.
602
+     *
603
+     * @param {boolean} enabled indicates if the button should be enabled
604
+     * or disabled
603 605
      */
604
-    markVideoIconAsMuted (muted) {
605
-        $('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
606
+    setVideoIconEnabled (enabled) {
607
+        this._setMediaIconEnabled(
608
+                '#toolbar_button_camera',
609
+                enabled,
610
+                /* data-i18n attribute value */
611
+                `[content]toolbar.${enabled ? 'videomute' : 'cameraDisabled'}`,
612
+                /* shortcut attribute value */
613
+                'toggleVideoPopover');
614
+
615
+        enabled || this.toggleVideoIcon(!enabled);
606 616
     },
607 617
 
608 618
     /**
609
-     * Marks video icon as disabled or not.
610
-     * @param {boolean} disabled if icon should look like disabled or not
619
+     * Enables/disables the toolbar button associated with a specific media such
620
+     * as audio or video.
621
+     *
622
+     * @param {string} btn - The jQuery selector <tt>string</tt> which
623
+     * identifies the toolbar button to be enabled/disabled.
624
+     * @param {boolean} enabled - <tt>true</tt> to enable the specified
625
+     * <tt>btn</tt>  or <tt>false</tt> to disable it.
626
+     * @param {string} dataI18n - The value to assign to the <tt>data-i18n</tt>
627
+     * attribute of the specified <tt>btn</tt>.
628
+     * @param {string} shortcut - The value, if any, to assign to the
629
+     * <tt>shortcut</tt> attribute of the specified <tt>btn</tt> if the toolbar
630
+     * button is enabled.
611 631
      */
612
-    markVideoIconAsDisabled (disabled) {
613
-        var $btn = $('#toolbar_button_camera');
632
+    _setMediaIconEnabled(btn, enabled, dataI18n, shortcut) {
633
+        const $btn = $(btn);
614 634
 
615 635
         $btn
616
-            .prop("disabled", disabled)
617
-            .attr("data-i18n", disabled
618
-                ? "[content]toolbar.cameraDisabled"
619
-                : "[content]toolbar.videomute")
620
-            .attr("shortcut", disabled ? "" : "toggleVideoPopover");
636
+            .prop('disabled', !enabled)
637
+            .attr('data-i18n', dataI18n)
638
+            .attr('shortcut', enabled && shortcut ? shortcut : '');
621 639
 
622
-        disabled
623
-            ? $btn.attr("disabled", "disabled")
624
-            : $btn.removeAttr("disabled");
640
+        enabled
641
+            ? $btn.removeAttr('disabled')
642
+            : $btn.attr('disabled', 'disabled');
625 643
 
626 644
         APP.translation.translateElement($btn);
627
-
628
-        disabled && this.markVideoIconAsMuted(disabled);
629 645
     },
630 646
 
631 647
     /**
632 648
      * Marks audio icon as muted or not.
649
+     *
633 650
      * @param {boolean} muted if icon should look like muted or not
634 651
      */
635
-    markAudioIconAsMuted (muted) {
636
-        $('#toolbar_button_mute').toggleClass("icon-microphone",
637
-            !muted).toggleClass("icon-mic-disabled", muted);
652
+    toggleAudioIcon(muted) {
653
+        $('#toolbar_button_mute')
654
+            .toggleClass("icon-microphone", !muted)
655
+            .toggleClass("icon-mic-disabled", muted);
656
+
657
+        this._setToggledState("toolbar_button_mute", muted);
638 658
     },
639 659
 
640 660
     /**
641
-     * Marks audio icon as disabled or not.
642
-     * @param {boolean} disabled if icon should look like disabled or not
661
+     * Enables / disables audio toolbar button.
662
+     *
663
+     * @param {boolean} enabled indicates if the button should be enabled
664
+     * or disabled
643 665
      */
644
-    markAudioIconAsDisabled (disabled) {
645
-        var $btn = $('#toolbar_button_mute');
646
-
647
-        $btn
648
-            .prop("disabled", disabled)
649
-            .attr("data-i18n", disabled
650
-                ? "[content]toolbar.micDisabled"
651
-                : "[content]toolbar.mute")
652
-            .attr("shortcut", disabled ? "" : "mutePopover");
653
-
654
-        disabled
655
-            ? $btn.attr("disabled", "disabled")
656
-            : $btn.removeAttr("disabled");
657
-
658
-        APP.translation.translateElement($btn);
666
+    setAudioIconEnabled (enabled) {
667
+        this._setMediaIconEnabled(
668
+                '#toolbar_button_mute',
669
+                enabled,
670
+                /* data-i18n attribute value */
671
+                `[content]toolbar.${enabled ? 'mute' : 'micDisabled'}`,
672
+                /* shortcut attribute value */
673
+                'mutePopover');
659 674
 
660
-        disabled && this.markAudioIconAsMuted(disabled);
675
+        enabled || this.toggleAudioIcon(!enabled);
661 676
     },
662 677
 
663 678
     /**
@@ -819,6 +834,17 @@ const Toolbar = {
819 834
             popupElement.appendChild(liElement);
820 835
             buttonElement.appendChild(popupElement);
821 836
         });
837
+    },
838
+
839
+    /**
840
+     * Sets the toggled state of the given element depending on the isToggled
841
+     * parameter.
842
+     *
843
+     * @param elementId the element identifier
844
+     * @param isToggled indicates if the element should be toggled or untoggled
845
+     */
846
+     _setToggledState(elementId, isToggled) {
847
+        $("#" + elementId).toggleClass("toggled", isToggled);
822 848
     }
823 849
 };
824 850
 

+ 2
- 2
modules/devices/mediaDeviceHelper.js Datei anzeigen

@@ -58,7 +58,7 @@ function getNewAudioInputDevice(newDevices, localAudio) {
58 58
         // Otherwise we assume that we don't have any audio input devices
59 59
         // to use and that's why disable microphone button on UI.
60 60
         else {
61
-            APP.UI.disableMicrophoneButton();
61
+            APP.UI.setMicrophoneButtonEnabled(false);
62 62
         }
63 63
     } else {
64 64
         // And here we handle case when we already have some device working,
@@ -100,7 +100,7 @@ function getNewVideoInputDevice(newDevices, localVideo) {
100 100
         // Otherwise we assume that we don't have any video input devices
101 101
         // to use and that's why disable microphone button on UI.
102 102
         else {
103
-            APP.UI.disableCameraButton();
103
+            APP.UI.setCameraButtonEnabled(false);
104 104
         }
105 105
     } else {
106 106
         // And here we handle case when we already have some device working,

Laden…
Abbrechen
Speichern