瀏覽代碼

Fixes toolbar tooltip positioning

j8
yanas 8 年之前
父節點
當前提交
2ffef3bdda

+ 18
- 13
react/features/toolbox/components/PrimaryToolbar.web.js 查看文件

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

+ 30
- 30
react/features/toolbox/components/SecondaryToolbar.web.js 查看文件

12
     showRecordingButton,
12
     showRecordingButton,
13
     toggleSideToolbarContainer
13
     toggleSideToolbarContainer
14
 } from '../actions';
14
 } from '../actions';
15
-import Toolbar from './Toolbar';
16
 import { getToolbarClassNames } from '../functions';
15
 import { getToolbarClassNames } from '../functions';
16
+import Toolbar from './Toolbar';
17
 
17
 
18
 declare var APP: Object;
18
 declare var APP: Object;
19
 declare var config: Object;
19
 declare var config: Object;
79
              * @type {Object}
79
              * @type {Object}
80
              */
80
              */
81
             profile: {
81
             profile: {
82
-                onMount: () => {
82
+                onMount: () =>
83
                     APP.tokenData.isGuest
83
                     APP.tokenData.isGuest
84
-                    || this.props._onSetProfileButtonUnclickable(true);
85
-                }
84
+                        || this.props._onSetProfileButtonUnclickable(true)
86
             },
85
             },
87
 
86
 
88
             /**
87
             /**
91
              * @type {button}
90
              * @type {button}
92
              */
91
              */
93
             raisehand: {
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
              * @type {Object}
106
              * @type {Object}
108
              */
107
              */
109
             recording: {
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
      * @returns {void}
128
      * @returns {void}
132
      */
129
      */
133
     componentDidMount(): void {
130
     componentDidMount(): void {
134
-        APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
131
+        APP.UI.addListener(
132
+            UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
135
             this.props._onSideToolbarContainerToggled);
133
             this.props._onSideToolbarContainerToggled);
136
     }
134
     }
137
 
135
 
141
      * @returns {void}
139
      * @returns {void}
142
      */
140
      */
143
     componentWillUnmount(): void {
141
     componentWillUnmount(): void {
144
-        APP.UI.removeListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
142
+        APP.UI.removeListener(
143
+            UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
145
             this.props._onSideToolbarContainerToggled);
144
             this.props._onSideToolbarContainerToggled);
146
     }
145
     }
147
 
146
 
154
         const { _secondaryToolbarButtons } = this.props;
153
         const { _secondaryToolbarButtons } = this.props;
155
 
154
 
156
         // The number of buttons to show in the toolbar isn't fixed, it depends
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
         if (_secondaryToolbarButtons.size === 0) {
158
         if (_secondaryToolbarButtons.size === 0) {
160
             return null;
159
             return null;
161
         }
160
         }
167
             <Toolbar
166
             <Toolbar
168
                 buttonHandlers = { buttonHandlers }
167
                 buttonHandlers = { buttonHandlers }
169
                 className = { secondaryToolbarClassName }
168
                 className = { secondaryToolbarClassName }
170
-                toolbarButtons = { _secondaryToolbarButtons }>
169
+                toolbarButtons = { _secondaryToolbarButtons }
170
+                tooltipPosition = { 'right' }>
171
                 <FeedbackButton />
171
                 <FeedbackButton />
172
             </Toolbar>
172
             </Toolbar>
173
         );
173
         );
179
  *
179
  *
180
  * @param {Function} dispatch - Redux action dispatcher.
180
  * @param {Function} dispatch - Redux action dispatcher.
181
  * @returns {{
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
  * @private
187
  * @private
188
  */
188
  */
237
  *
237
  *
238
  * @param {Object} state - Snapshot of Redux store.
238
  * @param {Object} state - Snapshot of Redux store.
239
  * @returns {{
239
  * @returns {{
240
- *      _secondaryToolbarButtons: Map,
241
- *      _visible: boolean
240
+ *     _secondaryToolbarButtons: Map,
241
+ *     _visible: boolean
242
  * }}
242
  * }}
243
  * @private
243
  * @private
244
  */
244
  */
252
         /**
252
         /**
253
          * Default toolbar buttons for secondary toolbar.
253
          * Default toolbar buttons for secondary toolbar.
254
          *
254
          *
255
-         * @protected
255
+         * @private
256
          * @type {Map}
256
          * @type {Map}
257
          */
257
          */
258
         _secondaryToolbarButtons: secondaryToolbarButtons,
258
         _secondaryToolbarButtons: secondaryToolbarButtons,
260
         /**
260
         /**
261
          * Shows whether toolbar is visible.
261
          * Shows whether toolbar is visible.
262
          *
262
          *
263
-         * @protected
263
+         * @private
264
          * @type {boolean}
264
          * @type {boolean}
265
          */
265
          */
266
         _visible: visible
266
         _visible: visible

+ 16
- 14
react/features/toolbox/components/Toolbar.web.js 查看文件

60
         /**
60
         /**
61
          * Map with toolbar buttons.
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
 
79
 
74
         this._setButtonHandlers();
80
         this._setButtonHandlers();
75
 
81
 
76
-        // Bind methods to save the context
82
+        // Bind callbacks to preverse this.
77
         this._renderToolbarButton = this._renderToolbarButton.bind(this);
83
         this._renderToolbarButton = this._renderToolbarButton.bind(this);
78
     }
84
     }
79
 
85
 
115
     _renderToolbarButton(acc: Array<*>, keyValuePair: Array<*>,
121
     _renderToolbarButton(acc: Array<*>, keyValuePair: Array<*>,
116
                          index: number): Array<ReactElement<*>> {
122
                          index: number): Array<ReactElement<*>> {
117
         const [ key, button ] = keyValuePair;
123
         const [ key, button ] = keyValuePair;
118
-        const { splitterIndex } = this.props;
124
+        const { splitterIndex, tooltipPosition } = this.props;
119
 
125
 
120
         if (splitterIndex && index === splitterIndex) {
126
         if (splitterIndex && index === splitterIndex) {
121
             const splitter = <span className = 'toolbar__splitter' />;
127
             const splitter = <span className = 'toolbar__splitter' />;
131
                 key = { key }
137
                 key = { key }
132
                 onClick = { onClick }
138
                 onClick = { onClick }
133
                 onMount = { onMount }
139
                 onMount = { onMount }
134
-                onUnmount = { onUnmount } />
140
+                onUnmount = { onUnmount }
141
+                tooltipPosition = { tooltipPosition } />
135
         );
142
         );
136
 
143
 
137
         return acc;
144
         return acc;
149
             toolbarButtons
156
             toolbarButtons
150
         } = this.props;
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
             let button = toolbarButtons.get(key);
164
             let button = toolbarButtons.get(key);
163
 
165
 
164
             if (button) {
166
             if (button) {

+ 8
- 5
react/features/toolbox/components/ToolbarButton.web.js 查看文件

49
         /**
49
         /**
50
          * Translation helper function.
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
      * @returns {void}
205
      * @returns {void}
200
      */
206
      */
201
     _setShortcutAndTooltip(): void {
207
     _setShortcutAndTooltip(): void {
202
-        const { button } = this.props;
208
+        const { button, tooltipPosition } = this.props;
203
         const name = button.buttonName;
209
         const name = button.buttonName;
204
 
210
 
205
         if (UIUtil.isButtonEnabled(name)) {
211
         if (UIUtil.isButtonEnabled(name)) {
206
-            const tooltipPosition
207
-                = interfaceConfig.MAIN_TOOLBAR_BUTTONS.indexOf(name) > -1
208
-                ? 'bottom' : 'right';
209
 
212
 
210
             if (!button.unclickable) {
213
             if (!button.unclickable) {
211
                 UIUtil.setTooltip(this.button,
214
                 UIUtil.setTooltip(this.button,

Loading…
取消
儲存