Pārlūkot izejas kodu

Merge pull request #1054 from kkrisstoff/task/make-extended-toolbar-dynamically-created-buttons

make extended buttons dynamic
master
hristoterezov 8 gadus atpakaļ
vecāks
revīzija
a7a7f269c3
5 mainītis faili ar 162 papildinājumiem un 102 dzēšanām
  1. 3
    18
      css/_toolbars.scss
  2. 3
    27
      index.html
  3. 14
    2
      interface_config.js
  4. 1
    1
      modules/UI/UI.js
  5. 141
    54
      modules/UI/toolbars/Toolbar.js

+ 3
- 18
css/_toolbars.scss Parādīt failu

42
     margin-right: auto;
42
     margin-right: auto;
43
     width: auto;
43
     width: auto;
44
     border-radius: 3px;
44
     border-radius: 3px;
45
-
46
-    /**
47
-     * First button in the toolbar.
48
-     */
49
-    .first {
50
-        border-bottom-left-radius: 3px;
51
-        border-top-left-radius: 3px;
52
-    }
53
-
54
-    /**
55
-     * Last button in the toolbar.
56
-     */
57
-    .last {
58
-        border-bottom-right-radius: 3px;
59
-        border-top-right-radius: 3px;
60
-    }
45
+    overflow: hidden;
61
 
46
 
62
     /**
47
     /**
63
      * Splitter button in the toolbar.
48
      * Splitter button in the toolbar.
75
     display: flex;
60
     display: flex;
76
     width: $defaultToolbarSize;
61
     width: $defaultToolbarSize;
77
     height: 100%;
62
     height: 100%;
78
-    top: 0px;
79
-    left: 0px;
63
+    top: 0;
64
+    left: 0;
80
     padding-top: 10px;
65
     padding-top: 10px;
81
     box-sizing: border-box;
66
     box-sizing: border-box;
82
     flex-direction: column;
67
     flex-direction: column;

+ 3
- 27
index.html Parādīt failu

131
                 <div id="notice" class="notice" style="display: none">
131
                 <div id="notice" class="notice" style="display: none">
132
                     <span id="noticeText" class="noticeText"></span>
132
                     <span id="noticeText" class="noticeText"></span>
133
                 </div>
133
                 </div>
134
-                <span id="mainToolbar" class="toolbar"></span>
134
+                <div id="mainToolbar" class="toolbar"></div>
135
         </div>
135
         </div>
136
         <div id="subject" class="hide"></div>
136
         <div id="subject" class="hide"></div>
137
 
137
 
138
         <div id="extendedToolbar" class="toolbar">
138
         <div id="extendedToolbar" class="toolbar">
139
-            <a class="button" id="toolbar_button_profile" data-container="body" data-placement="right" data-i18n="[content]toolbar.profile">
140
-                <img id="avatar" src="images/avatar2.png"/>
141
-            </a>
142
-            <a class="button icon-contactList" id="toolbar_contact_list" shortcut="contactlistpopover">
143
-                <span class="badge-round">
144
-                    <span id="numberOfParticipants"></span>
145
-                </span>
146
-            </a>
147
-            <!--a class="button icon-link" id="toolbar_button_link"></a-->
148
-            <a class="button icon-chat" id="toolbar_button_chat" shortcut="toggleChatPopover">
149
-                <span class="badge-round">
150
-                    <span id="unreadMessages"></span>
151
-                </span>
152
-            </a>
153
-            <a class="button" id="toolbar_button_record" style="display: none"></a>
154
-            <a class="button icon-share-doc" id="toolbar_button_etherpad"></a>
155
-            <a class="button icon-shared-video" id="toolbar_button_sharedvideo" style="display: none">
156
-                <ul id="sharedVideoMutedPopup" class="loginmenu extendedToolbarPopup">
157
-                    <li data-i18n="[html]toolbar.sharedVideoMutedPopup"></li>
158
-                </ul>
159
-            </a>
160
-            <a class="button icon-telephone" id="toolbar_button_sip" style="display: none"></a>
161
-            <a class="button icon-dialpad" id="toolbar_button_dialpad" style="display: none"></a>
162
-            <a class="button icon-settings" id="toolbar_button_settings"></a>
163
-            <a class="button icon-raised-hand" id="toolbar_button_raisehand" shortcut="raiseHandPopover"></a>
164
-            <a class="button icon-toggle-filmstrip" id="toolbar_film_strip" data-container="body" shortcut="filmstripPopover"></a>
139
+            <div id="extendedToolbarButtons"></div>
140
+
165
             <a class="button icon-feedback" id="feedbackButton"></a>
141
             <a class="button icon-feedback" id="feedbackButton"></a>
166
 
142
 
167
             <div id="sideToolbarContainer">
143
             <div id="sideToolbarContainer">

+ 14
- 2
interface_config.js Parādīt failu

24
     AUTHENTICATION_ENABLE: true,
24
     AUTHENTICATION_ENABLE: true,
25
     // the toolbar buttons line is intentionally left in one line, to be able
25
     // the toolbar buttons line is intentionally left in one line, to be able
26
     // to easily override values or remove them using regex
26
     // to easily override values or remove them using regex
27
-    MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'invite', 'fullscreen', 'hangup'], // jshint ignore:line
28
     /**
27
     /**
29
      * The index of the splitter button in the main toolbar. The splitter
28
      * The index of the splitter button in the main toolbar. The splitter
30
      * button is a button in the toolbar that will be applied a special styling
29
      * button is a button in the toolbar that will be applied a special styling
31
      * visually dividing the toolbar buttons.
30
      * visually dividing the toolbar buttons.
32
      */
31
      */
33
     //MAIN_TOOLBAR_SPLITTER_INDEX: -1,
32
     //MAIN_TOOLBAR_SPLITTER_INDEX: -1,
34
-    TOOLBAR_BUTTONS: ['profile', 'authentication', 'microphone', 'camera', 'desktop', 'recording', 'security', 'raisehand', 'chat', 'etherpad', 'sharedvideo', 'sip', 'dialpad', 'settings', 'hangup', 'filmstrip', 'contacts'], // jshint ignore:line
33
+    /**
34
+     * the toolbar buttons line is intentionally left in one line, to be able
35
+     * to easily override values or remove them using regex
36
+     */
37
+    TOOLBAR_BUTTONS: [
38
+        //main toolbar
39
+        'microphone', 'camera', 'desktop', 'invite', 'fullscreen', 'hangup',
40
+        //extended toolbar
41
+        'profile', 'contacts', 'chat', 'recording', 'etherpad', 'sharedvideo', 'sip', 'dialpad', 'settings', 'raisehand', 'filmstrip'], // jshint ignore:line
42
+    /**
43
+     * Main Toolbar Buttons
44
+     * All of them should be in TOOLBAR_BUTTONS
45
+     */
46
+    MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'invite', 'fullscreen', 'hangup'], // jshint ignore:line
35
     SETTINGS_SECTIONS: ['language', 'devices', 'moderator'],
47
     SETTINGS_SECTIONS: ['language', 'devices', 'moderator'],
36
     // Determines how the video would fit the screen. 'both' would fit the whole
48
     // Determines how the video would fit the screen. 'both' would fit the whole
37
     // screen, 'height' would fit the original video height to the height of the
49
     // screen, 'height' would fit the original video height to the height of the

+ 1
- 1
modules/UI/UI.js Parādīt failu

1021
 // eslint-disable-next-line no-unused-vars
1021
 // eslint-disable-next-line no-unused-vars
1022
 UI.updateDTMFSupport = function (isDTMFSupported) {
1022
 UI.updateDTMFSupport = function (isDTMFSupported) {
1023
     //TODO: enable when the UI is ready
1023
     //TODO: enable when the UI is ready
1024
-    //Toolbar.showDialPadButton(dtmfSupport);
1024
+    //Toolbar.showDialPadButton(isDTMFSupported);
1025
 };
1025
 };
1026
 
1026
 
1027
 /**
1027
 /**

+ 141
- 54
modules/UI/toolbars/Toolbar.js Parādīt failu

6
 let emitter = null;
6
 let emitter = null;
7
 let Toolbar;
7
 let Toolbar;
8
 
8
 
9
+/**
10
+ * Handlers for toolbar buttons.
11
+ *
12
+ * buttonId {string}: handler {function}
13
+ */
9
 const buttonHandlers = {
14
 const buttonHandlers = {
10
     "toolbar_button_profile": function () {
15
     "toolbar_button_profile": function () {
11
         JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
16
         JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
124
     }
129
     }
125
 };
130
 };
126
 
131
 
132
+/**
133
+ * All toolbars buttons description
134
+ */
127
 const defaultToolbarButtons = {
135
 const defaultToolbarButtons = {
128
     'microphone': {
136
     'microphone': {
129
         id: 'toolbar_button_mute',
137
         id: 'toolbar_button_mute',
194
     'chat': {
202
     'chat': {
195
         id: 'toolbar_button_chat',
203
         id: 'toolbar_button_chat',
196
         tooltipKey: 'toolbar.chat',
204
         tooltipKey: 'toolbar.chat',
205
+        className: 'button icon-chat',
197
         shortcut: 'C',
206
         shortcut: 'C',
198
         shortcutAttr: 'toggleChatPopover',
207
         shortcutAttr: 'toggleChatPopover',
199
         shortcutFunc: function() {
208
         shortcutFunc: function() {
201
             APP.UI.toggleChat();
210
             APP.UI.toggleChat();
202
         },
211
         },
203
         shortcutDescription: 'keyboardShortcuts.toggleChat',
212
         shortcutDescription: 'keyboardShortcuts.toggleChat',
204
-        sideContainerId: 'chat_container'
213
+        sideContainerId: 'chat_container',
214
+        html: `<span class="badge-round">
215
+                   <span id="unreadMessages"></span>
216
+               </span>`
205
     },
217
     },
206
     'contacts': {
218
     'contacts': {
207
         id: 'toolbar_contact_list',
219
         id: 'toolbar_contact_list',
208
         tooltipKey: 'bottomtoolbar.contactlist',
220
         tooltipKey: 'bottomtoolbar.contactlist',
209
-        sideContainerId: 'contacts_container'
221
+        className: 'button icon-contactList',
222
+        sideContainerId: 'contacts_container',
223
+        html: `<span class="badge-round">
224
+                   <span id="numberOfParticipants"></span>
225
+               </span>`
210
     },
226
     },
211
     'profile': {
227
     'profile': {
212
         id: 'toolbar_button_profile',
228
         id: 'toolbar_button_profile',
213
         tooltipKey: 'profile.setDisplayNameLabel',
229
         tooltipKey: 'profile.setDisplayNameLabel',
214
-        sideContainerId: 'profile_container'
230
+        className: 'button',
231
+        sideContainerId: 'profile_container',
232
+        html: `<img id="avatar" src="images/avatar2.png"/>`
215
     },
233
     },
216
     'etherpad': {
234
     'etherpad': {
217
         id: 'toolbar_button_etherpad',
235
         id: 'toolbar_button_etherpad',
218
         tooltipKey: 'toolbar.etherpad',
236
         tooltipKey: 'toolbar.etherpad',
237
+        className: 'button icon-share-doc'
219
     },
238
     },
220
     'fullscreen': {
239
     'fullscreen': {
221
         id: 'toolbar_button_fullScreen',
240
         id: 'toolbar_button_fullScreen',
234
     'settings': {
253
     'settings': {
235
         id: 'toolbar_button_settings',
254
         id: 'toolbar_button_settings',
236
         tooltipKey: 'toolbar.Settings',
255
         tooltipKey: 'toolbar.Settings',
256
+        className: 'button icon-settings',
237
         sideContainerId: "settings_container"
257
         sideContainerId: "settings_container"
238
     },
258
     },
239
     'hangup': {
259
     'hangup': {
246
     'filmstrip': {
266
     'filmstrip': {
247
         id: 'toolbar_film_strip',
267
         id: 'toolbar_film_strip',
248
         tooltipKey: 'toolbar.filmstrip',
268
         tooltipKey: 'toolbar.filmstrip',
269
+        className: "button icon-toggle-filmstrip",
249
         shortcut: "F",
270
         shortcut: "F",
250
         shortcutAttr: "filmstripPopover",
271
         shortcutAttr: "filmstripPopover",
251
         shortcutFunc: function() {
272
         shortcutFunc: function() {
267
         shortcutDescription: "keyboardShortcuts.raiseHand",
288
         shortcutDescription: "keyboardShortcuts.raiseHand",
268
         content: "Raise Hand",
289
         content: "Raise Hand",
269
         i18n: "[content]toolbar.raiseHand"
290
         i18n: "[content]toolbar.raiseHand"
291
+    },
292
+    //init and btn handler: Recording.initRecordingButton (Recording.js)
293
+    'recording': {
294
+        id: 'toolbar_button_record',
295
+        tooltipKey: 'liveStreaming.buttonTooltip',
296
+        className: 'button'
297
+    },
298
+    'sharedvideo': {
299
+        id: 'toolbar_button_sharedvideo',
300
+        tooltipKey: 'toolbar.sharedvideo',
301
+        className: 'button icon-shared-video',
302
+        html: `<ul id="sharedVideoMutedPopup" 
303
+                   class="loginmenu extendedToolbarPopup">
304
+                   <li data-i18n="[html]toolbar.sharedVideoMutedPopup"></li>
305
+               </ul>
306
+`
307
+    },
308
+    'sip': {
309
+        id: 'toolbar_button_sip',
310
+        tooltipKey: 'toolbar.sip',
311
+        className: 'button icon-telephone'
312
+    },
313
+    'dialpad': {
314
+        id: 'toolbar_button_dialpad',
315
+        tooltipKey: 'toolbar.dialpad',
316
+        className: 'button icon-dialpad',
317
+        //TODO: remove it after UI.updateDTMFSupport fix
318
+        hidden: true
270
     }
319
     }
271
 };
320
 };
272
 
321
 
281
     let titleKey = "dialog.sipMsg";
330
     let titleKey = "dialog.sipMsg";
282
     let msgString = (`
331
     let msgString = (`
283
             <input name="sipNumber" type="text"
332
             <input name="sipNumber" type="text"
284
-                   value="${defaultNumber}" autofocus>
285
-    `);
333
+                   value="${defaultNumber}" autofocus>`);
286
 
334
 
287
     APP.UI.messageHandler.openTwoButtonDialog({
335
     APP.UI.messageHandler.openTwoButtonDialog({
288
         titleKey,
336
         titleKey,
297
     });
345
     });
298
 }
346
 }
299
 
347
 
348
+/**
349
+ * Get place for toolbar button.
350
+ * Now it can be in main toolbar or in extended (left) toolbar
351
+ *
352
+ * @param btn {string}
353
+ * @returns {string}
354
+ */
355
+function getToolbarButtonPlace (btn) {
356
+    return interfaceConfig.MAIN_TOOLBAR_BUTTONS.includes(btn) ?
357
+        'main' :
358
+        'extended';
359
+}
360
+
300
 Toolbar = {
361
 Toolbar = {
301
     init (eventEmitter) {
362
     init (eventEmitter) {
302
         emitter = eventEmitter;
363
         emitter = eventEmitter;
305
         this.toolbarSelector = $("#mainToolbarContainer");
366
         this.toolbarSelector = $("#mainToolbarContainer");
306
         this.extendedToolbarSelector = $("#extendedToolbar");
367
         this.extendedToolbarSelector = $("#extendedToolbar");
307
 
368
 
308
-        // First hide all disabled buttons in the extended toolbar.
309
-        // TODO: Make the extended toolbar dynamically created.
310
-        UIUtil.hideDisabledButtons(defaultToolbarButtons);
369
+        // Initialise the toolbar buttons.
370
+        // The main toolbar will only take into account
371
+        // it's own configuration from interface_config.
372
+        this._initToolbarButtons();
311
 
373
 
312
-        // Initialise the main toolbar. The main toolbar will only take into
313
-        // account it's own configuration from interface_config.
314
-        this._initMainToolbarButtons();
315
-
316
-        Object.keys(defaultToolbarButtons).forEach(
317
-            id => {
318
-                if (UIUtil.isButtonEnabled(id)) {
319
-                    let button = defaultToolbarButtons[id];
320
-                    let buttonElement = document.getElementById(button.id);
321
-
322
-                    let tooltipPosition
323
-                        = (interfaceConfig.MAIN_TOOLBAR_BUTTONS
324
-                                .indexOf(id) > -1)
325
-                            ? "bottom" : "right";
326
-
327
-                    UIUtil.setTooltip(  buttonElement,
328
-                                        button.tooltipKey,
329
-                                        tooltipPosition);
330
-
331
-                    if (button.shortcut)
332
-                        APP.keyboardshortcut.registerShortcut(
333
-                            button.shortcut,
334
-                            button.shortcutAttr,
335
-                            button.shortcutFunc,
336
-                            button.shortcutDescription
337
-                        );
338
-                }
339
-            }
340
-        );
374
+        this._setShortcutsAndTooltips();
341
 
375
 
342
-        Object.keys(buttonHandlers).forEach(
343
-            buttonId => $(`#${buttonId}`).click(function(event) {
344
-                !$(this).prop('disabled') && buttonHandlers[buttonId](event);
345
-            })
346
-        );
376
+        this._setButtonHandlers();
347
 
377
 
348
         APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
378
         APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
349
             (containerId, isVisible) => {
379
             (containerId, isVisible) => {
703
     },
733
     },
704
 
734
 
705
     /**
735
     /**
706
-     * Initialise main toolbar buttons.
736
+     * Initialise toolbar buttons.
707
      */
737
      */
708
-    _initMainToolbarButtons() {
709
-        interfaceConfig.MAIN_TOOLBAR_BUTTONS.forEach((value, index) => {
738
+    _initToolbarButtons() {
739
+        interfaceConfig.TOOLBAR_BUTTONS.forEach((value, index) => {
740
+            let place = getToolbarButtonPlace(value);
741
+
710
             if (value && value in defaultToolbarButtons) {
742
             if (value && value in defaultToolbarButtons) {
711
                 let button = defaultToolbarButtons[value];
743
                 let button = defaultToolbarButtons[value];
712
-                this._addMainToolbarButton(
744
+                this._addToolbarButton(
713
                     button,
745
                     button,
714
-                    (index === 0),
715
-                    (index === interfaceConfig.MAIN_TOOLBAR_BUTTONS.length -1),
746
+                    place,
716
                     (interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX !== undefined
747
                     (interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX !== undefined
717
                         && index
748
                         && index
718
                             === interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX));
749
                             === interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX));
721
     },
752
     },
722
 
753
 
723
     /**
754
     /**
724
-     * Adds the given button to the main (top) toolbar.
755
+     * Adds the given button to the main (top) or extended (left) toolbar.
725
      *
756
      *
726
      * @param {Object} the button to add.
757
      * @param {Object} the button to add.
727
      * @param {boolean} isFirst indicates if this is the first button in the
758
      * @param {boolean} isFirst indicates if this is the first button in the
731
      * @param {boolean} isSplitter if this button is a splitter button for
762
      * @param {boolean} isSplitter if this button is a splitter button for
732
      * the dialog, which means that a special splitter style will be applied
763
      * the dialog, which means that a special splitter style will be applied
733
      */
764
      */
734
-    _addMainToolbarButton(button, isFirst, isLast, isSplitter) {
765
+    _addToolbarButton(button, place, isSplitter) {
766
+        const places = {
767
+            main: 'mainToolbar',
768
+            extended: 'extendedToolbarButtons'
769
+        };
770
+        let id = places[place];
735
         let buttonElement = document.createElement("a");
771
         let buttonElement = document.createElement("a");
736
         if (button.className)
772
         if (button.className)
737
             buttonElement.className = button.className
773
             buttonElement.className = button.className
738
-                                    + ((isFirst) ? " first" : "")
739
-                                    + ((isLast) ? " last" : "")
740
-                                    + ((isSplitter) ? " splitter": "");
774
+                + ((isSplitter) ? " splitter": "");
741
 
775
 
742
         buttonElement.id = button.id;
776
         buttonElement.id = button.id;
743
 
777
 
778
+        if (button.html)
779
+            buttonElement.innerHTML = button.html;
780
+
781
+        //TODO: remove it after UI.updateDTMFSupport fix
782
+        if (button.hidden)
783
+            buttonElement.style.display = 'none';
784
+
744
         if (button.shortcutAttr)
785
         if (button.shortcutAttr)
745
             buttonElement.setAttribute("shortcut", button.shortcutAttr);
786
             buttonElement.setAttribute("shortcut", button.shortcutAttr);
746
 
787
 
754
         buttonElement.setAttribute("data-placement", "bottom");
795
         buttonElement.setAttribute("data-placement", "bottom");
755
         this._addPopups(buttonElement, button.popups);
796
         this._addPopups(buttonElement, button.popups);
756
 
797
 
757
-        document.getElementById("mainToolbar")
798
+        document.getElementById(id)
758
             .appendChild(buttonElement);
799
             .appendChild(buttonElement);
759
     },
800
     },
760
 
801
 
779
      */
820
      */
780
      _setToggledState(elementId, isToggled) {
821
      _setToggledState(elementId, isToggled) {
781
         $("#" + elementId).toggleClass("toggled", isToggled);
822
         $("#" + elementId).toggleClass("toggled", isToggled);
823
+    },
824
+
825
+    /**
826
+     * Sets Shortcuts and Tooltips for all toolbar buttons
827
+     *
828
+     * @private
829
+     */
830
+    _setShortcutsAndTooltips() {
831
+        Object.keys(defaultToolbarButtons).forEach(
832
+            id => {
833
+                if (UIUtil.isButtonEnabled(id)) {
834
+                    let button = defaultToolbarButtons[id];
835
+                    let buttonElement = document.getElementById(button.id);
836
+                    if (!buttonElement) return false;
837
+                    let tooltipPosition
838
+                        = (interfaceConfig.MAIN_TOOLBAR_BUTTONS
839
+                        .indexOf(id) > -1)
840
+                        ? "bottom" : "right";
841
+
842
+                    UIUtil.setTooltip(  buttonElement,
843
+                        button.tooltipKey,
844
+                        tooltipPosition);
845
+
846
+                    if (button.shortcut)
847
+                        APP.keyboardshortcut.registerShortcut(
848
+                            button.shortcut,
849
+                            button.shortcutAttr,
850
+                            button.shortcutFunc,
851
+                            button.shortcutDescription
852
+                        );
853
+                }
854
+            }
855
+        );
856
+    },
857
+
858
+    /**
859
+     * Sets Handlers for all toolbar buttons
860
+     *
861
+     * @private
862
+     */
863
+    _setButtonHandlers() {
864
+        Object.keys(buttonHandlers).forEach(
865
+            buttonId => $(`#${buttonId}`).click(function(event) {
866
+                !$(this).prop('disabled') && buttonHandlers[buttonId](event);
867
+            })
868
+        );
782
     }
869
     }
783
 };
870
 };
784
 
871
 

Notiek ielāde…
Atcelt
Saglabāt