Kaynağa Gözat

Fixes toolbar tooltip positioning

j8
yanas 8 yıl önce
ebeveyn
işleme
2ffef3bdda

+ 18
- 13
react/features/toolbox/components/PrimaryToolbar.web.js Dosyayı Görüntüle

@@ -6,8 +6,8 @@ import { connect } from 'react-redux';
6 6
 import UIEvents from '../../../../service/UI/UIEvents';
7 7
 
8 8
 import { showDesktopSharingButton, toggleFullScreen } from '../actions';
9
-import Toolbar from './Toolbar';
10 9
 import { getToolbarClassNames } from '../functions';
10
+import Toolbar from './Toolbar';
11 11
 
12 12
 declare var APP: Object;
13 13
 declare var interfaceConfig: Object;
@@ -19,8 +19,6 @@ declare var interfaceConfig: Object;
19 19
  * @extends Component
20 20
  */
21 21
 class PrimaryToolbar extends Component {
22
-    state: Object;
23
-
24 22
     static propTypes = {
25 23
         /**
26 24
          * Handler for toggling fullscreen mode.
@@ -43,6 +41,8 @@ class PrimaryToolbar extends Component {
43 41
         _visible: React.PropTypes.bool
44 42
     };
45 43
 
44
+    state: Object;
45
+
46 46
     /**
47 47
      * Constructs instance of primary toolbar React component.
48 48
      *
@@ -68,10 +68,12 @@ class PrimaryToolbar extends Component {
68 68
              */
69 69
             fullscreen: {
70 70
                 onMount: () =>
71
-                    APP.UI.addListener(UIEvents.FULLSCREEN_TOGGLED,
71
+                    APP.UI.addListener(
72
+                        UIEvents.FULLSCREEN_TOGGLED,
72 73
                         this.props._onFullScreenToggled),
73 74
                 onUnmount: () =>
74
-                    APP.UI.removeListener(UIEvents.FULLSCREEN_TOGGLED,
75
+                    APP.UI.removeListener(
76
+                        UIEvents.FULLSCREEN_TOGGLED,
75 77
                         this.props._onFullScreenToggled)
76 78
             }
77 79
         };
@@ -105,21 +107,24 @@ class PrimaryToolbar extends Component {
105 107
         const { _primaryToolbarButtons } = this.props;
106 108
 
107 109
         // The number of buttons to show in the toolbar isn't fixed, it depends
108
-        // on availability of features and configuration parameters, so if we
109
-        // don't have anything to render we exit here.
110
+        // on the availability of features and configuration parameters. So
111
+        // there may be nothing to render.
110 112
         if (_primaryToolbarButtons.size === 0) {
111 113
             return null;
112 114
         }
113 115
 
114 116
         const { buttonHandlers, splitterIndex } = this.state;
115 117
         const { primaryToolbarClassName } = getToolbarClassNames(this.props);
118
+        const tooltipPosition
119
+            = interfaceConfig.filmStripOnly ? 'left' : 'bottom';
116 120
 
117 121
         return (
118 122
             <Toolbar
119 123
                 buttonHandlers = { buttonHandlers }
120 124
                 className = { primaryToolbarClassName }
121 125
                 splitterIndex = { splitterIndex }
122
-                toolbarButtons = { _primaryToolbarButtons } />
126
+                toolbarButtons = { _primaryToolbarButtons }
127
+                tooltipPosition = { tooltipPosition } />
123 128
         );
124 129
     }
125 130
 }
@@ -129,7 +134,7 @@ class PrimaryToolbar extends Component {
129 134
  *
130 135
  * @param {Function} dispatch - Redux action dispatcher.
131 136
  * @returns {{
132
- *      _onShowDesktopSharingButton: Function
137
+ *     _onShowDesktopSharingButton: Function
133 138
  * }}
134 139
  * @private
135 140
  */
@@ -162,8 +167,8 @@ function _mapDispatchToProps(dispatch: Function): Object {
162 167
  *
163 168
  * @param {Object} state - Snapshot of Redux store.
164 169
  * @returns {{
165
- *      _primaryToolbarButtons: Map,
166
- *      _visible: boolean
170
+ *     _primaryToolbarButtons: Map,
171
+ *     _visible: boolean
167 172
  * }}
168 173
  * @private
169 174
  */
@@ -177,7 +182,7 @@ function _mapStateToProps(state: Object): Object {
177 182
         /**
178 183
          * Default toolbar buttons for primary toolbar.
179 184
          *
180
-         * @protected
185
+         * @private
181 186
          * @type {Map}
182 187
          */
183 188
         _primaryToolbarButtons: primaryToolbarButtons,
@@ -185,7 +190,7 @@ function _mapStateToProps(state: Object): Object {
185 190
         /**
186 191
          * Shows whether toolbox is visible.
187 192
          *
188
-         * @protected
193
+         * @private
189 194
          * @type {boolean}
190 195
          */
191 196
         _visible: visible

+ 30
- 30
react/features/toolbox/components/SecondaryToolbar.web.js Dosyayı Görüntüle

@@ -12,8 +12,8 @@ import {
12 12
     showRecordingButton,
13 13
     toggleSideToolbarContainer
14 14
 } from '../actions';
15
-import Toolbar from './Toolbar';
16 15
 import { getToolbarClassNames } from '../functions';
16
+import Toolbar from './Toolbar';
17 17
 
18 18
 declare var APP: Object;
19 19
 declare var config: Object;
@@ -79,10 +79,9 @@ class SecondaryToolbar extends Component {
79 79
              * @type {Object}
80 80
              */
81 81
             profile: {
82
-                onMount: () => {
82
+                onMount: () =>
83 83
                     APP.tokenData.isGuest
84
-                    || this.props._onSetProfileButtonUnclickable(true);
85
-                }
84
+                        || this.props._onSetProfileButtonUnclickable(true)
86 85
             },
87 86
 
88 87
             /**
@@ -91,14 +90,14 @@ class SecondaryToolbar extends Component {
91 90
              * @type {button}
92 91
              */
93 92
             raisehand: {
94
-                onMount: () => {
95
-                    APP.UI.addListener(UIEvents.LOCAL_RAISE_HAND_CHANGED,
96
-                        this.props._onLocalRaiseHandChanged);
97
-                },
98
-                onUnmount: () => {
99
-                    APP.UI.removeListener(UIEvents.LOCAL_RAISE_HAND_CHANGED,
100
-                        this.props._onLocalRaiseHandChanged);
101
-                }
93
+                onMount: () =>
94
+                    APP.UI.addListener(
95
+                        UIEvents.LOCAL_RAISE_HAND_CHANGED,
96
+                        this.props._onLocalRaiseHandChanged),
97
+                onUnmount: () =>
98
+                    APP.UI.removeListener(
99
+                        UIEvents.LOCAL_RAISE_HAND_CHANGED,
100
+                        this.props._onLocalRaiseHandChanged)
102 101
             },
103 102
 
104 103
             /**
@@ -107,11 +106,9 @@ class SecondaryToolbar extends Component {
107 106
              * @type {Object}
108 107
              */
109 108
             recording: {
110
-                onMount: () => {
111
-                    if (config.enableRecording) {
112
-                        this.props._onShowRecordingButton();
113
-                    }
114
-                }
109
+                onMount: () =>
110
+                    config.enableRecording
111
+                        && this.props._onShowRecordingButton()
115 112
             }
116 113
         };
117 114
 
@@ -131,7 +128,8 @@ class SecondaryToolbar extends Component {
131 128
      * @returns {void}
132 129
      */
133 130
     componentDidMount(): void {
134
-        APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
131
+        APP.UI.addListener(
132
+            UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
135 133
             this.props._onSideToolbarContainerToggled);
136 134
     }
137 135
 
@@ -141,7 +139,8 @@ class SecondaryToolbar extends Component {
141 139
      * @returns {void}
142 140
      */
143 141
     componentWillUnmount(): void {
144
-        APP.UI.removeListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
142
+        APP.UI.removeListener(
143
+            UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
145 144
             this.props._onSideToolbarContainerToggled);
146 145
     }
147 146
 
@@ -154,8 +153,8 @@ class SecondaryToolbar extends Component {
154 153
         const { _secondaryToolbarButtons } = this.props;
155 154
 
156 155
         // The number of buttons to show in the toolbar isn't fixed, it depends
157
-        // on availability of features and configuration parameters, so if we
158
-        // don't have anything to render we exit here.
156
+        // on the availability of features and configuration parameters. So
157
+        // there may be nothing to render.
159 158
         if (_secondaryToolbarButtons.size === 0) {
160 159
             return null;
161 160
         }
@@ -167,7 +166,8 @@ class SecondaryToolbar extends Component {
167 166
             <Toolbar
168 167
                 buttonHandlers = { buttonHandlers }
169 168
                 className = { secondaryToolbarClassName }
170
-                toolbarButtons = { _secondaryToolbarButtons }>
169
+                toolbarButtons = { _secondaryToolbarButtons }
170
+                tooltipPosition = { 'right' }>
171 171
                 <FeedbackButton />
172 172
             </Toolbar>
173 173
         );
@@ -179,10 +179,10 @@ class SecondaryToolbar extends Component {
179 179
  *
180 180
  * @param {Function} dispatch - Redux action dispatcher.
181 181
  * @returns {{
182
- *      _onLocalRaiseHandChanged: Function,
183
- *      _onSetProfileButtonUnclickable: Function,
184
- *      _onShowRecordingButton: Function,
185
- *      _onSideToolbarContainerToggled
182
+ *     _onLocalRaiseHandChanged: Function,
183
+ *     _onSetProfileButtonUnclickable: Function,
184
+ *     _onShowRecordingButton: Function,
185
+ *     _onSideToolbarContainerToggled
186 186
  * }}
187 187
  * @private
188 188
  */
@@ -237,8 +237,8 @@ function _mapDispatchToProps(dispatch: Function): Object {
237 237
  *
238 238
  * @param {Object} state - Snapshot of Redux store.
239 239
  * @returns {{
240
- *      _secondaryToolbarButtons: Map,
241
- *      _visible: boolean
240
+ *     _secondaryToolbarButtons: Map,
241
+ *     _visible: boolean
242 242
  * }}
243 243
  * @private
244 244
  */
@@ -252,7 +252,7 @@ function _mapStateToProps(state: Object): Object {
252 252
         /**
253 253
          * Default toolbar buttons for secondary toolbar.
254 254
          *
255
-         * @protected
255
+         * @private
256 256
          * @type {Map}
257 257
          */
258 258
         _secondaryToolbarButtons: secondaryToolbarButtons,
@@ -260,7 +260,7 @@ function _mapStateToProps(state: Object): Object {
260 260
         /**
261 261
          * Shows whether toolbar is visible.
262 262
          *
263
-         * @protected
263
+         * @private
264 264
          * @type {boolean}
265 265
          */
266 266
         _visible: visible

+ 16
- 14
react/features/toolbox/components/Toolbar.web.js Dosyayı Görüntüle

@@ -60,7 +60,13 @@ class Toolbar extends Component {
60 60
         /**
61 61
          * Map with toolbar buttons.
62 62
          */
63
-        toolbarButtons: React.PropTypes.instanceOf(Map)
63
+        toolbarButtons: React.PropTypes.instanceOf(Map),
64
+
65
+        /**
66
+         * Indicates the position of the tooltip.
67
+         */
68
+        tooltipPosition:
69
+            React.PropTypes.oneOf([ 'bottom', 'left', 'right', 'top' ])
64 70
     };
65 71
 
66 72
     /**
@@ -73,7 +79,7 @@ class Toolbar extends Component {
73 79
 
74 80
         this._setButtonHandlers();
75 81
 
76
-        // Bind methods to save the context
82
+        // Bind callbacks to preverse this.
77 83
         this._renderToolbarButton = this._renderToolbarButton.bind(this);
78 84
     }
79 85
 
@@ -115,7 +121,7 @@ class Toolbar extends Component {
115 121
     _renderToolbarButton(acc: Array<*>, keyValuePair: Array<*>,
116 122
                          index: number): Array<ReactElement<*>> {
117 123
         const [ key, button ] = keyValuePair;
118
-        const { splitterIndex } = this.props;
124
+        const { splitterIndex, tooltipPosition } = this.props;
119 125
 
120 126
         if (splitterIndex && index === splitterIndex) {
121 127
             const splitter = <span className = 'toolbar__splitter' />;
@@ -131,7 +137,8 @@ class Toolbar extends Component {
131 137
                 key = { key }
132 138
                 onClick = { onClick }
133 139
                 onMount = { onMount }
134
-                onUnmount = { onUnmount } />
140
+                onUnmount = { onUnmount }
141
+                tooltipPosition = { tooltipPosition } />
135 142
         );
136 143
 
137 144
         return acc;
@@ -149,16 +156,11 @@ class Toolbar extends Component {
149 156
             toolbarButtons
150 157
         } = this.props;
151 158
 
152
-        // Only a few buttons have custom button handlers defined, so this
153
-        // list may be undefined or empty depending on the buttons we're
154
-        // rendering.
155
-        // TODO: merge the buttonHandlers and onClick properties and come up
156
-        // with a consistent event handling property.
157
-        if (!buttonHandlers) {
158
-            return;
159
-        }
160
-
161
-        Object.keys(buttonHandlers).forEach(key => {
159
+        // Only a few buttons have buttonHandlers defined, so it may be
160
+        // undefined or empty depending on the buttons rendered.
161
+        // TODO Merge the buttonHandlers and onClick properties and come up with
162
+        // a consistent event handling property.
163
+        buttonHandlers && Object.keys(buttonHandlers).forEach(key => {
162 164
             let button = toolbarButtons.get(key);
163 165
 
164 166
             if (button) {

+ 8
- 5
react/features/toolbox/components/ToolbarButton.web.js Dosyayı Görüntüle

@@ -49,7 +49,13 @@ class ToolbarButton extends AbstractToolbarButton {
49 49
         /**
50 50
          * Translation helper function.
51 51
          */
52
-        t: React.PropTypes.func
52
+        t: React.PropTypes.func,
53
+
54
+        /**
55
+         * Indicates the position of the tooltip.
56
+         */
57
+        tooltipPosition:
58
+            React.PropTypes.oneOf([ 'bottom', 'left', 'right', 'top' ])
53 59
     };
54 60
 
55 61
     /**
@@ -199,13 +205,10 @@ class ToolbarButton extends AbstractToolbarButton {
199 205
      * @returns {void}
200 206
      */
201 207
     _setShortcutAndTooltip(): void {
202
-        const { button } = this.props;
208
+        const { button, tooltipPosition } = this.props;
203 209
         const name = button.buttonName;
204 210
 
205 211
         if (UIUtil.isButtonEnabled(name)) {
206
-            const tooltipPosition
207
-                = interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) > -1
208
-                ? 'bottom' : 'right';
209 212
 
210 213
             if (!button.unclickable) {
211 214
                 UIUtil.setTooltip(this.button,

Loading…
İptal
Kaydet