浏览代码

Adds tooltips

j8
yanas 8 年前
父节点
当前提交
96bbf0419c

+ 6
- 2
app.js 查看文件

@@ -8,10 +8,14 @@ import "jquery-ui";
8 8
 import "strophe";
9 9
 import "strophe-disco";
10 10
 import "strophe-caps";
11
-import "tooltip";
12
-import "popover";
13 11
 import "jQuery-Impromptu";
14 12
 import "autosize";
13
+
14
+import 'aui';
15
+import 'aui-experimental';
16
+import 'aui-css';
17
+import 'aui-experimental-css';
18
+
15 19
 window.toastr = require("toastr");
16 20
 
17 21
 import URLProcessor from "./modules/config/URLProcessor";

+ 1
- 0
css/_toolbars.scss 查看文件

@@ -129,6 +129,7 @@ a.button:hover,
129 129
 a.button:active,
130 130
 a.button.selected {
131 131
     cursor: pointer;
132
+    text-decoration: none;
132 133
     // sum opacity with background layer should give us 0.8
133 134
     background: $toolbarSelectBackground;
134 135
 }

+ 15
- 15
index.html 查看文件

@@ -120,28 +120,28 @@
120 120
                     </li>
121 121
                 </ul>
122 122
             </span>
123
-            <a class="button icon-contactList" id="toolbar_contact_list" data-container="body" data-toggle="popover" data-placement="right" shortcut="contactlistpopover"  data-i18n="[content]bottomtoolbar.contactlist" content="Open / close contact list">
123
+            <a class="button icon-contactList" id="toolbar_contact_list" shortcut="contactlistpopover">
124 124
                 <span id="numberOfParticipants"></span>
125 125
             </a>
126
-            <!--a class="button icon-link" id="toolbar_button_link" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[content]toolbar.invite" content="Invite others"></a-->
127
-            <a class="button icon-chat" id="toolbar_button_chat" data-container="body" data-toggle="popover" shortcut="toggleChatPopover" data-placement="right" data-i18n="[content]toolbar.chat" content="Open / close chat">
126
+            <!--a class="button icon-link" id="toolbar_button_link"></a-->
127
+            <a class="button icon-chat" id="toolbar_button_chat" shortcut="toggleChatPopover">
128 128
                 <span id="unreadMessages"></span>
129 129
             </a>
130
-            <a class="button" id="toolbar_button_record" data-container="body" data-toggle="popover" data-placement="right" style="display: none"></a>
131
-            <a class="button icon-security" id="toolbar_button_security" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[content]toolbar.lock" content="Lock / unlock room"></a>
132
-            <a class="button icon-share-doc" id="toolbar_button_etherpad" data-container="body" data-toggle="popover" data-placement="right" content="Shared document" data-i18n="[content]toolbar.etherpad"></a>
133
-            <a class="button icon-shared-video" id="toolbar_button_sharedvideo" data-container="body" data-toggle="popover" data-placement="right" content="Share a YouTube video" data-i18n="[content]toolbar.sharedvideo" style="display: none">
130
+            <a class="button" id="toolbar_button_record" style="display: none"></a>
131
+            <a class="button icon-security" id="toolbar_button_security"></a>
132
+            <a class="button icon-share-doc" id="toolbar_button_etherpad"></a>
133
+            <a class="button icon-shared-video" id="toolbar_button_sharedvideo" style="display: none">
134 134
                 <ul id="sharedVideoMutedPopup" class="loginmenu extendedToolbarPopup">
135 135
                     <li data-i18n="[html]toolbar.sharedVideoMutedPopup"></li>
136 136
                 </ul>
137 137
             </a>
138
-            <a class="button icon-telephone" id="toolbar_button_sip" data-container="body" data-toggle="popover" data-placement="right" content="Call SIP number" data-i18n="[content]toolbar.sip" style="display: none"></a>
139
-            <a class="button icon-dialpad" id="toolbar_button_dialpad" data-container="body" data-toggle="popover" data-placement="right" content="Open dialpad" data-i18n="[content]toolbar.dialpad" style="display: none"></a>
140
-            <a class="button icon-settings" id="toolbar_button_settings" data-container="body" data-toggle="popover" data-placement="right" content="Settings" data-i18n="[content]toolbar.Settings"></a>
141
-            <a class="button icon-raised-hand" id="toolbar_button_raisehand" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[content]toolbar.raiseHand" content="Raise Hand" shortcut="raiseHandPopover"></a>
142
-            <a class="button icon-full-screen" id="toolbar_button_fullScreen" data-container="body" data-toggle="popover" data-placement="right" shortcut="toggleFullscreenPopover" data-i18n="[content]toolbar.fullscreen" content="Enter / Exit Full Screen"></a>
143
-            <a class="button icon-toggle-filmstrip" id="toolbar_film_strip" data-container="body" data-toggle="popover" shortcut="filmstripPopover" data-placement="right" data-i18n="[content]toolbar.filmstrip" content="Show / hide videos"></a>
144
-            <a class="button icon-feedback" id="feedbackButton" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[content]feedback"></a>
138
+            <a class="button icon-telephone" id="toolbar_button_sip" style="display: none"></a>
139
+            <a class="button icon-dialpad" id="toolbar_button_dialpad" style="display: none"></a>
140
+            <a class="button icon-settings" id="toolbar_button_settings"></a>
141
+            <a class="button icon-raised-hand" id="toolbar_button_raisehand" shortcut="raiseHandPopover"></a>
142
+            <a class="button icon-full-screen" id="toolbar_button_fullScreen" shortcut="toggleFullscreenPopover"></a>
143
+            <a class="button icon-toggle-filmstrip" id="toolbar_film_strip" data-container="body" shortcut="filmstripPopover"></a>
144
+            <a class="button icon-feedback" id="feedbackButton"></a>
145 145
             <div id="sideToolbarContainer">
146 146
                 <div id="profile_container" class="sideToolbarContainer__inner">
147 147
                     <div class="title" data-i18n="profile.title"></div>
@@ -208,7 +208,7 @@
208 208
                         <input type="checkbox" id="followMeCheckBox">
209 209
                         <label class="followMeLabel" for="followMeCheckBox" data-i18n="settings.followMe"></label>
210 210
                     </div>
211
-                    <a id="downloadlog" data-container="body" data-toggle="popover" data-placement="right" data-i18n="[data-content]downloadlogs" ><i class="icon-download"></i></a>
211
+                    <a id="downloadlog" data-container="body"><i class="icon-download"></i></a>
212 212
                 </div>
213 213
             </div>
214 214
         </div>

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

@@ -140,10 +140,14 @@ var Feedback = {
140 140
 
141 141
         _showFeedbackButton(this.enabled);
142 142
 
143
-        $("#feedbackButton").click(function (event) {
143
+        let $feedbackButton = $("#feedbackButton");
144
+
145
+        $feedbackButton.click(function (event) {
144 146
             Feedback.openFeedbackWindow();
145 147
         });
146 148
 
149
+        UIUtil.setTooltip($feedbackButton.get(0), 'feedback', 'right');
150
+
147 151
         // Show / hide the feedback button whenever the film strip is
148 152
         // shown / hidden.
149 153
         emitter.addListener(UIEvents.TOGGLE_FILM_STRIP, function () {

+ 19
- 1
modules/UI/UI.js 查看文件

@@ -339,6 +339,22 @@ UI.handleToggleFilmStrip = () => {
339 339
     VideoLayout.resizeVideoArea(true, false);
340 340
 };
341 341
 
342
+/**
343
+ * Sets tooltip defaults.
344
+ *
345
+ * @private
346
+ */
347
+function _setTooltipDefaults() {
348
+    $.fn.tooltip.defaults = {
349
+        opacity: 1, //defaults to 1
350
+        offset: 1,
351
+        delayIn: 0, //defaults to 500
352
+        hoverable: true,
353
+        hideOnClick: true,
354
+        aria: true
355
+    };
356
+}
357
+
342 358
 /**
343 359
  * Setup some UI event listeners.
344 360
  */
@@ -431,6 +447,9 @@ UI.start = function () {
431 447
     // Set the defaults for prompt dialogs.
432 448
     $.prompt.setDefaults({persistent: false});
433 449
 
450
+    // Set the defaults for tooltips.
451
+    _setTooltipDefaults();
452
+
434 453
     registerListeners();
435 454
 
436 455
     ToolbarToggler.init();
@@ -476,7 +495,6 @@ UI.start = function () {
476 495
         $("#downloadlog").css("display", "none");
477 496
         FilmStrip.setupFilmStripOnly();
478 497
         messageHandler.enableNotifications(false);
479
-        $('body').popover("disable");
480 498
         JitsiPopover.enabled = false;
481 499
     }
482 500
 

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

@@ -270,6 +270,9 @@ var Recording = {
270 270
     initRecordingButton(recordingType) {
271 271
         let selector = $('#toolbar_button_record');
272 272
 
273
+        let button = selector.get(0);
274
+        UIUtil.setTooltip(button, 'liveStreaming.buttonTooltip', 'right');
275
+
273 276
         if (recordingType === 'jibri') {
274 277
             this.baseClass = "fa fa-play-circle";
275 278
             this.recordingTitle = "dialog.liveStreaming";

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

@@ -180,6 +180,7 @@ const buttonHandlers = {
180 180
 const defaultToolbarButtons = {
181 181
     'microphone': {
182 182
         id: 'toolbar_button_mute',
183
+        tooltipKey: 'toolbar.mute',
183 184
         className: "button icon-microphone",
184 185
         shortcut: 'M',
185 186
         shortcutAttr: 'mutePopover',
@@ -205,6 +206,7 @@ const defaultToolbarButtons = {
205 206
     },
206 207
     'camera': {
207 208
         id: 'toolbar_button_camera',
209
+        tooltipKey: 'toolbar.videomute',
208 210
         className: "button icon-camera",
209 211
         shortcut: 'V',
210 212
         shortcutAttr: 'toggleVideoPopover',
@@ -218,6 +220,7 @@ const defaultToolbarButtons = {
218 220
     },
219 221
     'desktop': {
220 222
         id: 'toolbar_button_desktopsharing',
223
+        tooltipKey: 'toolbar.sharescreen',
221 224
         className: 'button icon-share-desktop',
222 225
         shortcut: 'D',
223 226
         shortcutAttr: 'toggleDesktopSharingPopover',
@@ -230,16 +233,19 @@ const defaultToolbarButtons = {
230 233
         i18n: '[content]toolbar.sharescreen'
231 234
     },
232 235
     'security': {
233
-        id: 'toolbar_button_security'
236
+        id: 'toolbar_button_security',
237
+        tooltipKey: 'toolbar.lock'
234 238
     },
235 239
     'invite': {
236 240
         id: 'toolbar_button_link',
241
+        tooltipKey: 'toolbar.invite',
237 242
         className: 'button icon-link',
238 243
         content: 'Invite others',
239 244
         i18n: '[content]toolbar.invite'
240 245
     },
241 246
     'chat': {
242 247
         id: 'toolbar_button_chat',
248
+        tooltipKey: 'toolbar.chat',
243 249
         shortcut: 'C',
244 250
         shortcutAttr: 'toggleChatPopover',
245 251
         shortcutFunc: function() {
@@ -251,17 +257,21 @@ const defaultToolbarButtons = {
251 257
     },
252 258
     'contacts': {
253 259
         id: 'toolbar_contact_list',
260
+        tooltipKey: 'bottomtoolbar.contactlist',
254 261
         sideContainerId: 'contacts_container'
255 262
     },
256 263
     'profile': {
257 264
         id: 'toolbar_button_profile',
265
+        tooltipKey: 'profile.setDisplayNameLabel',
258 266
         sideContainerId: 'profile_container'
259 267
     },
260 268
     'etherpad': {
261
-        id: 'toolbar_button_etherpad'
269
+        id: 'toolbar_button_etherpad',
270
+        tooltipKey: 'toolbar.etherpad',
262 271
     },
263 272
     'fullscreen': {
264 273
         id: 'toolbar_button_fullScreen',
274
+        tooltipKey: 'toolbar.fullscreen',
265 275
         className: "button icon-full-screen",
266 276
         shortcut: 'F',
267 277
         shortcutAttr: 'toggleFullscreenPopover',
@@ -275,16 +285,19 @@ const defaultToolbarButtons = {
275 285
     },
276 286
     'settings': {
277 287
         id: 'toolbar_button_settings',
288
+        tooltipKey: 'toolbar.Settings',
278 289
         sideContainerId: "settings_container"
279 290
     },
280 291
     'hangup': {
281 292
         id: 'toolbar_button_hangup',
293
+        tooltipKey: 'toolbar.hangup',
282 294
         className: "button icon-hangup",
283 295
         content: "Hang Up",
284 296
         i18n: "[content]toolbar.hangup"
285 297
     },
286 298
     'filmstrip': {
287 299
         id: 'toolbar_film_strip',
300
+        tooltipKey: 'toolbar.filmstrip',
288 301
         shortcut: "F",
289 302
         shortcutAttr: "filmstripPopover",
290 303
         shortcutFunc: function() {
@@ -295,6 +308,7 @@ const defaultToolbarButtons = {
295 308
     },
296 309
     'raisehand': {
297 310
         id: "toolbar_button_raisehand",
311
+        tooltipKey: 'toolbar.raiseHand',
298 312
         className: "button icon-raised-hand",
299 313
         shortcut: "R",
300 314
         shortcutAttr: "raiseHandPopover",
@@ -351,7 +365,17 @@ const Toolbar = {
351 365
         Object.keys(defaultToolbarButtons).forEach(
352 366
             id => {
353 367
                 if (UIUtil.isButtonEnabled(id)) {
354
-                    var button = defaultToolbarButtons[id];
368
+                    let button = defaultToolbarButtons[id];
369
+                    let buttonElement = document.getElementById(button.id);
370
+
371
+                    let tooltipPosition
372
+                        = (interfaceConfig.MAIN_TOOLBAR_BUTTONS
373
+                                .indexOf(id) > -1)
374
+                            ? "bottom" : "right";
375
+
376
+                    UIUtil.setTooltip(  buttonElement,
377
+                                        button.tooltipKey,
378
+                                        tooltipPosition);
355 379
 
356 380
                     if (button.shortcut)
357 381
                         APP.keyboardshortcut.registerShortcut(
@@ -452,9 +476,11 @@ const Toolbar = {
452 476
 
453 477
     // Shows or hides the 'shared video' button.
454 478
     showSharedVideoButton () {
479
+        let $element = $('#toolbar_button_sharedvideo');
455 480
         if (UIUtil.isButtonEnabled('sharedvideo')
456 481
                 && config.disableThirdPartyRequests !== true) {
457
-            $('#toolbar_button_sharedvideo').css({display: "inline-block"});
482
+            $element.css({display: "inline-block"});
483
+            UIUtil.setTooltip($element.get(0), 'toolbar.sharedvideo', 'right');
458 484
         } else {
459 485
             $('#toolbar_button_sharedvideo').css({display: "none"});
460 486
         }
@@ -744,7 +770,6 @@ const Toolbar = {
744 770
             buttonElement.setAttribute("data-i18n", button.i18n);
745 771
 
746 772
         buttonElement.setAttribute("data-container", "body");
747
-        buttonElement.setAttribute("data-toggle", "popover");
748 773
         buttonElement.setAttribute("data-placement", "bottom");
749 774
         this._addPopups(buttonElement, button.popups);
750 775
 

+ 46
- 6
modules/UI/util/UIUtil.js 查看文件

@@ -1,4 +1,6 @@
1
-/* global $, config, interfaceConfig */
1
+/* global $, APP, config, AJS, interfaceConfig */
2
+
3
+import KeyboardShortcut from '../../keyboardshortcut/keyboardshortcut';
2 4
 
3 5
 /**
4 6
  * Created by hristo on 12/22/14.
@@ -82,12 +84,50 @@
82 84
         context.putImageData(imgData, 0, 0);
83 85
     },
84 86
 
87
+    /**
88
+     * Sets the tooltip to the given element.
89
+     *
90
+     * @param element the element to set the tooltip to
91
+     * @param key the tooltip data-i18n key
92
+     * @param position the position of the tooltip in relation to the element
93
+     */
85 94
     setTooltip: function (element, key, position) {
86
-        element.setAttribute("data-i18n", "[data-content]" + key);
87
-        element.setAttribute("data-toggle", "popover");
88
-        element.setAttribute("data-placement", position);
89
-        element.setAttribute("data-html", true);
90
-        element.setAttribute("data-container", "body");
95
+        let positions = {
96
+            'top': 's',
97
+            'top-left': 'se',
98
+            'left': 'e',
99
+            'bottom-left': 'ne',
100
+            'bottom': 'n',
101
+            'bottom-right': 'nw',
102
+            'right': 'w',
103
+            'top-right': 'sw'
104
+        };
105
+
106
+        element.setAttribute("data-i18n", "[content]" + key);
107
+        APP.translation.translateElement($(element));
108
+
109
+        AJS.$(element).tooltip({
110
+            gravity: positions[position],
111
+            title: this._getTooltipText.bind(this, element),
112
+            html: true
113
+        });
114
+    },
115
+
116
+    /**
117
+     * Internal util function for generating tooltip title.
118
+     *
119
+     * @param element
120
+     * @returns {string|*}
121
+     * @private
122
+     */
123
+    _getTooltipText: function (element) {
124
+        let title = element.getAttribute('content');
125
+        let shortcut = element.getAttribute('shortcut');
126
+        if(shortcut) {
127
+            let shortcutString = KeyboardShortcut.getShortcutTooltip(shortcut);
128
+            title += ` ${shortcutString}`;
129
+        }
130
+        return title;
91 131
     },
92 132
 
93 133
     /**

+ 1
- 2
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -197,7 +197,6 @@ SmallVideo.prototype.showAudioIndicator = function(isMuted) {
197 197
 
198 198
     if (!isMuted) {
199 199
         if (audioMutedSpan.length > 0) {
200
-            audioMutedSpan.popover('hide');
201 200
             audioMutedSpan.remove();
202 201
             this.updateIconPositions();
203 202
         }
@@ -304,7 +303,7 @@ SmallVideo.prototype.createModeratorIndicatorElement = function () {
304 303
 
305 304
     UIUtil.setTooltip(indicatorSpan[0],
306 305
         "videothumbnail.moderator",
307
-        "top");
306
+        "top-left");
308 307
 
309 308
     //translates text in focus indicators
310 309
     APP.translation

+ 1
- 8
modules/keyboardshortcut/keyboardshortcut.js 查看文件

@@ -74,13 +74,6 @@ var KeyboardShortcut = {
74 74
                 }
75 75
             }
76 76
         };
77
-        $('body').popover({ selector: '[data-toggle=popover]',
78
-            trigger: 'click hover',
79
-            content: function() {
80
-                return this.getAttribute("content")
81
-                    + self._getShortcutTooltip(this.getAttribute("shortcut"));
82
-            }
83
-        });
84 77
     },
85 78
 
86 79
     /**
@@ -128,7 +121,7 @@ var KeyboardShortcut = {
128 121
      * or an empty string if the shortcutAttr is null, an empty string or not
129 122
      * found in the shortcut mapping
130 123
      */
131
-    _getShortcutTooltip: function (shortcutAttr) {
124
+    getShortcutTooltip: function (shortcutAttr) {
132 125
         if (typeof shortcutAttr === "string" && shortcutAttr.length > 0) {
133 126
             for (var key in _shortcuts) {
134 127
                 if (_shortcuts.hasOwnProperty(key)

+ 9
- 1
package.json 查看文件

@@ -16,6 +16,7 @@
16 16
   "readmeFilename": "README.md",
17 17
   "//": "Callstats.io does not work with recent versions of jsSHA (2.0.1 in particular)",
18 18
   "dependencies": {
19
+    "@atlassian/aui": "^6.0.0",
19 20
     "async": "0.9.0",
20 21
     "autosize": "^1.18.13",
21 22
     "bootstrap": "3.1.1",
@@ -83,7 +84,11 @@
83 84
     "tooltip": "./node_modules/bootstrap/js/tooltip.js",
84 85
     "popover": "./node_modules/bootstrap/js/popover.js",
85 86
     "jQuery-Impromptu": "./node_modules/jQuery-Impromptu/dist/jquery-impromptu.js",
86
-    "autosize": "./node_modules/autosize/build/jquery.autosize.js"
87
+    "autosize": "./node_modules/autosize/build/jquery.autosize.js",
88
+    "aui": "./node_modules/@atlassian/aui/dist/aui/js/aui.js",
89
+    "aui-experimental": "./node_modules/@atlassian/aui/dist/aui/js/aui-experimental.js",
90
+    "aui-css": "./node_modules/@atlassian/aui/dist/aui/css/aui.min.css",
91
+    "aui-experimental-css": "./node_modules/@atlassian/aui/dist/aui/css/aui-experimental.min.css"
87 92
   },
88 93
   "browserify-shim": {
89 94
     "jquery": [
@@ -109,6 +114,9 @@
109 114
     "jQuery-Impromptu": {
110 115
       "depends": "jquery:jQuery"
111 116
     },
117
+    "aui-experimental": {
118
+      "depends": "aui:AJS"
119
+    },
112 120
     "jquery-contextmenu": {
113 121
       "depends": "jquery:jQuery"
114 122
     },

正在加载...
取消
保存