2017-02-15 08:54:57 +00:00
|
|
|
/* global AJS, APP, $, config, interfaceConfig, JitsiMeetJS */
|
2015-12-10 16:36:03 +00:00
|
|
|
import UIUtil from '../util/UIUtil';
|
|
|
|
import UIEvents from '../../../service/UI/UIEvents';
|
2016-09-08 22:34:16 +00:00
|
|
|
import SideContainerToggler from "../side_pannels/SideContainerToggler";
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-10 16:36:03 +00:00
|
|
|
let emitter = null;
|
2016-10-12 00:08:24 +00:00
|
|
|
let Toolbar;
|
2015-12-10 13:30:25 +00:00
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
/**
|
|
|
|
* Handlers for toolbar buttons.
|
|
|
|
*
|
|
|
|
* buttonId {string}: handler {function}
|
|
|
|
*/
|
2015-12-10 13:30:25 +00:00
|
|
|
const buttonHandlers = {
|
2016-09-11 21:54:32 +00:00
|
|
|
"toolbar_button_profile": function () {
|
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');
|
|
|
|
emitter.emit(UIEvents.TOGGLE_PROFILE);
|
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
"toolbar_button_mute": function () {
|
2016-04-19 18:07:04 +00:00
|
|
|
let sharedVideoManager = APP.UI.getSharedVideoManager();
|
|
|
|
|
2015-12-09 13:09:12 +00:00
|
|
|
if (APP.conference.audioMuted) {
|
2016-04-19 18:07:04 +00:00
|
|
|
// If there's a shared video with the volume "on" and we aren't
|
|
|
|
// the video owner, we warn the user
|
|
|
|
// that currently it's not possible to unmute.
|
|
|
|
if (sharedVideoManager
|
|
|
|
&& sharedVideoManager.isSharedVideoVolumeOn()
|
|
|
|
&& !sharedVideoManager.isSharedVideoOwner()) {
|
2017-02-15 08:54:57 +00:00
|
|
|
APP.UI.showCustomToolbarPopup(
|
|
|
|
'#unableToUnmutePopup', true, 5000);
|
2016-04-19 18:07:04 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.audio.unmuted');
|
2016-04-19 18:07:04 +00:00
|
|
|
emitter.emit(UIEvents.AUDIO_MUTED, false, true);
|
|
|
|
}
|
2015-09-02 17:08:48 +00:00
|
|
|
} else {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.audio.muted');
|
2016-04-19 18:07:04 +00:00
|
|
|
emitter.emit(UIEvents.AUDIO_MUTED, true, true);
|
2015-09-02 17:08:48 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
|
|
|
"toolbar_button_camera": function () {
|
2015-12-09 13:09:12 +00:00
|
|
|
if (APP.conference.videoMuted) {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.video.enabled');
|
2015-12-03 13:11:01 +00:00
|
|
|
emitter.emit(UIEvents.VIDEO_MUTED, false);
|
2015-09-02 17:08:48 +00:00
|
|
|
} else {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.video.disabled');
|
2015-12-03 13:11:01 +00:00
|
|
|
emitter.emit(UIEvents.VIDEO_MUTED, true);
|
2015-09-02 17:08:48 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
|
|
|
"toolbar_button_link": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.invite.clicked');
|
2016-10-12 00:08:24 +00:00
|
|
|
emitter.emit(UIEvents.INVITE_CLICKED);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
|
|
|
"toolbar_button_chat": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.chat.toggled');
|
2015-12-10 13:30:25 +00:00
|
|
|
emitter.emit(UIEvents.TOGGLE_CHAT);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
2016-09-08 18:16:23 +00:00
|
|
|
"toolbar_contact_list": function () {
|
|
|
|
JitsiMeetJS.analytics.sendEvent(
|
|
|
|
'toolbar.contacts.toggled');
|
|
|
|
emitter.emit(UIEvents.TOGGLE_CONTACT_LIST);
|
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
"toolbar_button_etherpad": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.etherpad.clicked');
|
2015-12-09 13:09:12 +00:00
|
|
|
emitter.emit(UIEvents.ETHERPAD_CLICKED);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
2016-03-18 20:00:55 +00:00
|
|
|
"toolbar_button_sharedvideo": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.sharedvideo.clicked');
|
2016-03-18 20:00:55 +00:00
|
|
|
emitter.emit(UIEvents.SHARED_VIDEO_CLICKED);
|
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
"toolbar_button_desktopsharing": function () {
|
2016-02-04 15:25:11 +00:00
|
|
|
if (APP.conference.isSharingScreen) {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.screen.disabled');
|
2015-09-02 17:08:48 +00:00
|
|
|
} else {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.screen.enabled');
|
2015-09-02 17:08:48 +00:00
|
|
|
}
|
2015-12-30 13:28:56 +00:00
|
|
|
emitter.emit(UIEvents.TOGGLE_SCREENSHARING);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
2015-07-28 21:52:32 +00:00
|
|
|
"toolbar_button_fullScreen": function() {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.fullscreen.enabled');
|
2016-10-13 20:09:18 +00:00
|
|
|
|
|
|
|
emitter.emit(UIEvents.TOGGLE_FULLSCREEN);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
|
|
|
"toolbar_button_sip": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.sip.clicked');
|
2015-12-10 15:48:56 +00:00
|
|
|
showSipNumberInput();
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
2015-04-08 10:51:29 +00:00
|
|
|
"toolbar_button_dialpad": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.sip.dialpad.clicked');
|
2015-12-10 13:30:25 +00:00
|
|
|
dialpadButtonClicked();
|
2015-04-08 10:51:29 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
"toolbar_button_settings": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.settings.toggled');
|
2015-12-10 13:30:25 +00:00
|
|
|
emitter.emit(UIEvents.TOGGLE_SETTINGS);
|
2015-01-07 14:54:03 +00:00
|
|
|
},
|
|
|
|
"toolbar_button_hangup": function () {
|
2016-08-09 20:04:40 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.hangup');
|
2015-12-10 15:48:56 +00:00
|
|
|
emitter.emit(UIEvents.HANGUP);
|
2015-02-18 15:50:47 +00:00
|
|
|
},
|
2016-09-14 01:50:30 +00:00
|
|
|
"toolbar_button_raisehand": function () {
|
2016-11-08 03:23:33 +00:00
|
|
|
JitsiMeetJS.analytics.sendEvent('toolbar.raiseHand.clicked');
|
2016-09-14 01:50:30 +00:00
|
|
|
APP.conference.maybeToggleRaisedHand();
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
};
|
2016-09-11 21:54:32 +00:00
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
/**
|
|
|
|
* All toolbars buttons description
|
|
|
|
*/
|
2015-12-10 16:36:03 +00:00
|
|
|
const defaultToolbarButtons = {
|
2016-08-29 03:59:09 +00:00
|
|
|
'microphone': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_mute',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.mute',
|
2016-09-11 21:54:32 +00:00
|
|
|
className: "button icon-microphone",
|
2016-08-29 03:59:09 +00:00
|
|
|
shortcut: 'M',
|
|
|
|
shortcutAttr: 'mutePopover',
|
|
|
|
shortcutFunc: function() {
|
|
|
|
JitsiMeetJS.analytics.sendEvent('shortcut.audiomute.toggled');
|
|
|
|
APP.conference.toggleAudioMuted();
|
|
|
|
},
|
2016-09-11 21:54:32 +00:00
|
|
|
shortcutDescription: "keyboardShortcuts.mute",
|
2016-09-12 19:43:34 +00:00
|
|
|
popups: [
|
|
|
|
{
|
2017-02-15 08:54:57 +00:00
|
|
|
id: 'micMutedPopup',
|
|
|
|
className: 'loginmenu',
|
|
|
|
dataAttr: '[title]toolbar.micMutedPopup'
|
2016-09-12 19:43:34 +00:00
|
|
|
},
|
|
|
|
{
|
2017-02-15 08:54:57 +00:00
|
|
|
id: 'unableToUnmutePopup',
|
|
|
|
className: 'loginmenu',
|
|
|
|
dataAttr: '[title]toolbar.unableToUnmutePopup'
|
2016-09-13 21:23:38 +00:00
|
|
|
},
|
|
|
|
{
|
2017-02-15 08:54:57 +00:00
|
|
|
id: 'talkWhileMutedPopup',
|
|
|
|
className: 'loginmenu',
|
|
|
|
dataAttr: '[title]toolbar.talkWhileMutedPopup'
|
2016-09-12 19:43:34 +00:00
|
|
|
}
|
|
|
|
],
|
2016-09-11 21:54:32 +00:00
|
|
|
content: "Mute / Unmute",
|
|
|
|
i18n: "[content]toolbar.mute"
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'camera': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_camera',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.videomute',
|
2016-09-11 21:54:32 +00:00
|
|
|
className: "button icon-camera",
|
2016-08-29 03:59:09 +00:00
|
|
|
shortcut: 'V',
|
|
|
|
shortcutAttr: 'toggleVideoPopover',
|
|
|
|
shortcutFunc: function() {
|
|
|
|
JitsiMeetJS.analytics.sendEvent('shortcut.videomute.toggled');
|
|
|
|
APP.conference.toggleVideoMuted();
|
|
|
|
},
|
2016-09-11 21:54:32 +00:00
|
|
|
shortcutDescription: "keyboardShortcuts.videoMute",
|
|
|
|
content: "Start / stop camera",
|
|
|
|
i18n: "[content]toolbar.videomute"
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'desktop': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_desktopsharing',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.sharescreen',
|
2016-09-13 04:10:18 +00:00
|
|
|
className: 'button icon-share-desktop',
|
2016-08-29 03:59:09 +00:00
|
|
|
shortcut: 'D',
|
|
|
|
shortcutAttr: 'toggleDesktopSharingPopover',
|
|
|
|
shortcutFunc: function() {
|
|
|
|
JitsiMeetJS.analytics.sendEvent('shortcut.screen.toggled');
|
|
|
|
APP.conference.toggleScreenSharing();
|
|
|
|
},
|
2016-09-13 04:10:18 +00:00
|
|
|
shortcutDescription: 'keyboardShortcuts.toggleScreensharing',
|
|
|
|
content: 'Share screen',
|
|
|
|
i18n: '[content]toolbar.sharescreen'
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'invite': {
|
2016-09-13 04:10:18 +00:00
|
|
|
id: 'toolbar_button_link',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.invite',
|
2016-09-13 04:10:18 +00:00
|
|
|
className: 'button icon-link',
|
|
|
|
content: 'Invite others',
|
|
|
|
i18n: '[content]toolbar.invite'
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'chat': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_chat',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.chat',
|
2016-10-11 13:30:28 +00:00
|
|
|
className: 'button icon-chat',
|
2016-08-29 03:59:09 +00:00
|
|
|
shortcut: 'C',
|
|
|
|
shortcutAttr: 'toggleChatPopover',
|
|
|
|
shortcutFunc: function() {
|
|
|
|
JitsiMeetJS.analytics.sendEvent('shortcut.chat.toggled');
|
|
|
|
APP.UI.toggleChat();
|
|
|
|
},
|
2016-09-13 04:10:18 +00:00
|
|
|
shortcutDescription: 'keyboardShortcuts.toggleChat',
|
2016-10-11 13:30:28 +00:00
|
|
|
sideContainerId: 'chat_container',
|
|
|
|
html: `<span class="badge-round">
|
|
|
|
<span id="unreadMessages"></span>
|
|
|
|
</span>`
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
2016-09-08 18:16:23 +00:00
|
|
|
'contacts': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_contact_list',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'bottomtoolbar.contactlist',
|
2016-10-11 13:30:28 +00:00
|
|
|
className: 'button icon-contactList',
|
2016-10-31 17:56:05 +00:00
|
|
|
sideContainerId: 'contacts_container',
|
|
|
|
html: `<span class="badge-round">
|
|
|
|
<span id="numberOfParticipants"></span>
|
|
|
|
</span>`
|
2016-09-08 18:16:23 +00:00
|
|
|
},
|
2016-09-11 21:54:32 +00:00
|
|
|
'profile': {
|
|
|
|
id: 'toolbar_button_profile',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'profile.setDisplayNameLabel',
|
2016-10-11 13:30:28 +00:00
|
|
|
className: 'button',
|
|
|
|
sideContainerId: 'profile_container',
|
|
|
|
html: `<img id="avatar" src="images/avatar2.png"/>`
|
2016-09-11 21:54:32 +00:00
|
|
|
},
|
2016-08-29 03:59:09 +00:00
|
|
|
'etherpad': {
|
2016-09-16 03:22:56 +00:00
|
|
|
id: 'toolbar_button_etherpad',
|
|
|
|
tooltipKey: 'toolbar.etherpad',
|
2016-10-11 13:30:28 +00:00
|
|
|
className: 'button icon-share-doc'
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'fullscreen': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_fullScreen',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.fullscreen',
|
2016-09-11 21:54:32 +00:00
|
|
|
className: "button icon-full-screen",
|
2016-09-29 12:31:45 +00:00
|
|
|
shortcut: 'S',
|
2016-09-11 21:54:32 +00:00
|
|
|
shortcutAttr: 'toggleFullscreenPopover',
|
|
|
|
shortcutFunc: function() {
|
|
|
|
JitsiMeetJS.analytics.sendEvent('shortcut.fullscreen.toggled');
|
|
|
|
APP.UI.toggleFullScreen();
|
|
|
|
},
|
2016-09-29 12:31:45 +00:00
|
|
|
shortcutDescription: "keyboardShortcuts.fullScreen",
|
2016-09-11 21:54:32 +00:00
|
|
|
content: "Enter / Exit Full Screen",
|
|
|
|
i18n: "[content]toolbar.fullscreen"
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'settings': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_settings',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.Settings',
|
2016-10-11 13:30:28 +00:00
|
|
|
className: 'button icon-settings',
|
2016-09-08 22:34:16 +00:00
|
|
|
sideContainerId: "settings_container"
|
2016-08-29 03:59:09 +00:00
|
|
|
},
|
|
|
|
'hangup': {
|
2016-09-11 21:54:32 +00:00
|
|
|
id: 'toolbar_button_hangup',
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.hangup',
|
2016-09-11 21:54:32 +00:00
|
|
|
className: "button icon-hangup",
|
|
|
|
content: "Hang Up",
|
|
|
|
i18n: "[content]toolbar.hangup"
|
2016-09-08 18:16:23 +00:00
|
|
|
},
|
2016-09-14 01:50:30 +00:00
|
|
|
'raisehand': {
|
|
|
|
id: "toolbar_button_raisehand",
|
2016-09-16 03:22:56 +00:00
|
|
|
tooltipKey: 'toolbar.raiseHand',
|
2016-09-14 01:50:30 +00:00
|
|
|
className: "button icon-raised-hand",
|
|
|
|
shortcut: "R",
|
|
|
|
shortcutAttr: "raiseHandPopover",
|
|
|
|
shortcutFunc: function() {
|
|
|
|
JitsiMeetJS.analytics.sendEvent("shortcut.raisehand.clicked");
|
|
|
|
APP.conference.maybeToggleRaisedHand();
|
|
|
|
},
|
|
|
|
shortcutDescription: "keyboardShortcuts.raiseHand",
|
|
|
|
content: "Raise Hand",
|
|
|
|
i18n: "[content]toolbar.raiseHand"
|
2016-10-11 13:30:28 +00:00
|
|
|
},
|
|
|
|
//init and btn handler: Recording.initRecordingButton (Recording.js)
|
|
|
|
'recording': {
|
|
|
|
id: 'toolbar_button_record',
|
|
|
|
tooltipKey: 'liveStreaming.buttonTooltip',
|
2016-11-28 15:26:34 +00:00
|
|
|
className: 'button',
|
|
|
|
hidden: true // will be displayed once
|
|
|
|
// the recording functionality is detected
|
2016-10-11 13:30:28 +00:00
|
|
|
},
|
|
|
|
'sharedvideo': {
|
|
|
|
id: 'toolbar_button_sharedvideo',
|
|
|
|
tooltipKey: 'toolbar.sharedvideo',
|
2016-10-31 17:56:05 +00:00
|
|
|
className: 'button icon-shared-video',
|
2017-02-15 08:54:57 +00:00
|
|
|
popups: [
|
|
|
|
{
|
|
|
|
id: 'sharedVideoMutedPopup',
|
|
|
|
className: 'loginmenu extendedToolbarPopup',
|
|
|
|
dataAttr: '[title]toolbar.sharedVideoMutedPopup',
|
|
|
|
dataAttrPosition: 'w'
|
|
|
|
}
|
|
|
|
]
|
2016-10-11 13:30:28 +00:00
|
|
|
},
|
|
|
|
'sip': {
|
|
|
|
id: 'toolbar_button_sip',
|
|
|
|
tooltipKey: 'toolbar.sip',
|
2016-11-28 15:26:34 +00:00
|
|
|
className: 'button icon-telephone',
|
|
|
|
hidden: true // will be displayed once
|
|
|
|
// the SIP calls functionality is detected
|
2016-10-11 13:30:28 +00:00
|
|
|
},
|
|
|
|
'dialpad': {
|
|
|
|
id: 'toolbar_button_dialpad',
|
|
|
|
tooltipKey: 'toolbar.dialpad',
|
|
|
|
className: 'button icon-dialpad',
|
|
|
|
//TODO: remove it after UI.updateDTMFSupport fix
|
|
|
|
hidden: true
|
2016-08-29 03:59:09 +00:00
|
|
|
}
|
2015-08-28 21:13:40 +00:00
|
|
|
};
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
function dialpadButtonClicked() {
|
|
|
|
//TODO show the dialpad box
|
2015-04-08 10:51:29 +00:00
|
|
|
}
|
|
|
|
|
2015-12-10 15:48:56 +00:00
|
|
|
function showSipNumberInput () {
|
2015-12-10 13:30:25 +00:00
|
|
|
let defaultNumber = config.defaultSipNumber
|
|
|
|
? config.defaultSipNumber
|
|
|
|
: '';
|
2016-10-12 00:08:24 +00:00
|
|
|
let titleKey = "dialog.sipMsg";
|
|
|
|
let msgString = (`
|
2016-11-09 16:46:58 +00:00
|
|
|
<input class="input-control"
|
|
|
|
name="sipNumber" type="text"
|
2016-10-11 13:30:28 +00:00
|
|
|
value="${defaultNumber}" autofocus>`);
|
2016-10-12 00:08:24 +00:00
|
|
|
|
|
|
|
APP.UI.messageHandler.openTwoButtonDialog({
|
|
|
|
titleKey,
|
|
|
|
msgString,
|
|
|
|
leftButtonKey: "dialog.Dial",
|
|
|
|
submitFunction: function (e, v, m, f) {
|
2015-12-10 15:48:56 +00:00
|
|
|
if (v && f.sipNumber) {
|
|
|
|
emitter.emit(UIEvents.SIP_DIAL, f.sipNumber);
|
2015-01-09 10:18:58 +00:00
|
|
|
}
|
|
|
|
},
|
2016-10-12 00:08:24 +00:00
|
|
|
focus: ':input:first'
|
|
|
|
});
|
2015-01-09 10:18:58 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
/**
|
|
|
|
* Get place for toolbar button.
|
|
|
|
* Now it can be in main toolbar or in extended (left) toolbar
|
|
|
|
*
|
|
|
|
* @param btn {string}
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
function getToolbarButtonPlace (btn) {
|
|
|
|
return interfaceConfig.MAIN_TOOLBAR_BUTTONS.includes(btn) ?
|
|
|
|
'main' :
|
|
|
|
'extended';
|
|
|
|
}
|
|
|
|
|
2017-02-15 21:39:16 +00:00
|
|
|
/**
|
|
|
|
* Event handler for side toolbar container toggled event.
|
|
|
|
*
|
|
|
|
* @param {string} containerId - ID of the container.
|
|
|
|
* @param {boolean} isVisible - Flag showing whether container
|
|
|
|
* is visible.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function onSideToolbarContainerToggled(containerId, isVisible) {
|
|
|
|
Toolbar._handleSideToolbarContainerToggled(containerId, isVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for local raise hand changed event.
|
|
|
|
*
|
|
|
|
* @param {boolean} isRaisedHand - Flag showing whether hand is raised.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function onLocalRaiseHandChanged(isRaisedHand) {
|
|
|
|
Toolbar._setToggledState("toolbar_button_raisehand", isRaisedHand);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for full screen toggled event.
|
|
|
|
*
|
|
|
|
* @param {boolean} isFullScreen - Flag showing whether app in full
|
|
|
|
* screen mode.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function onFullScreenToggled(isFullScreen) {
|
|
|
|
Toolbar._handleFullScreenToggled(isFullScreen);
|
|
|
|
}
|
|
|
|
|
2016-10-12 00:08:24 +00:00
|
|
|
Toolbar = {
|
2015-12-09 17:10:49 +00:00
|
|
|
init (eventEmitter) {
|
2015-12-03 13:11:01 +00:00
|
|
|
emitter = eventEmitter;
|
2016-04-07 17:08:00 +00:00
|
|
|
// The toolbar is enabled by default.
|
|
|
|
this.enabled = true;
|
2016-09-08 18:16:23 +00:00
|
|
|
this.toolbarSelector = $("#mainToolbarContainer");
|
|
|
|
this.extendedToolbarSelector = $("#extendedToolbar");
|
2015-12-10 16:36:03 +00:00
|
|
|
|
2017-02-15 21:39:16 +00:00
|
|
|
// Unregister listeners in case of reinitialization.
|
|
|
|
this.unregisterListeners();
|
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
// Initialise the toolbar buttons.
|
|
|
|
// The main toolbar will only take into account
|
|
|
|
// it's own configuration from interface_config.
|
|
|
|
this._initToolbarButtons();
|
2015-08-28 21:13:40 +00:00
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
this._setShortcutsAndTooltips();
|
2016-08-29 03:59:09 +00:00
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
this._setButtonHandlers();
|
2016-09-08 22:34:16 +00:00
|
|
|
|
2017-02-15 21:39:16 +00:00
|
|
|
this.registerListeners();
|
2016-10-13 20:09:18 +00:00
|
|
|
|
2017-02-15 08:54:57 +00:00
|
|
|
APP.UI.addListener(UIEvents.SHOW_CUSTOM_TOOLBAR_BUTTON_POPUP,
|
2017-02-16 22:14:58 +00:00
|
|
|
(popupID, show, timeout) => {
|
|
|
|
Toolbar._showCustomToolbarPopup(popupID, show, timeout);
|
2017-02-15 08:54:57 +00:00
|
|
|
});
|
|
|
|
|
2016-09-13 23:19:38 +00:00
|
|
|
if(!APP.tokenData.isGuest) {
|
|
|
|
$("#toolbar_button_profile").addClass("unclickable");
|
2016-09-21 21:35:42 +00:00
|
|
|
UIUtil.removeTooltip(
|
|
|
|
document.getElementById('toolbar_button_profile'));
|
2016-09-13 23:19:38 +00:00
|
|
|
}
|
2015-12-09 17:10:49 +00:00
|
|
|
},
|
2017-02-15 21:39:16 +00:00
|
|
|
/**
|
|
|
|
* Register listeners for UI events of toolbar component.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
registerListeners() {
|
|
|
|
APP.UI.addListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
|
|
|
|
onSideToolbarContainerToggled);
|
|
|
|
|
|
|
|
APP.UI.addListener(UIEvents.LOCAL_RAISE_HAND_CHANGED,
|
|
|
|
onLocalRaiseHandChanged);
|
|
|
|
|
|
|
|
APP.UI.addListener(UIEvents.FULLSCREEN_TOGGLED, onFullScreenToggled);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Unregisters handlers for UI events of Toolbar component.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
unregisterListeners() {
|
|
|
|
APP.UI.removeListener(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
|
|
|
|
onSideToolbarContainerToggled);
|
|
|
|
|
|
|
|
APP.UI.removeListener(UIEvents.LOCAL_RAISE_HAND_CHANGED,
|
|
|
|
onLocalRaiseHandChanged);
|
|
|
|
|
|
|
|
APP.UI.removeListener(UIEvents.FULLSCREEN_TOGGLED,
|
|
|
|
onFullScreenToggled);
|
|
|
|
},
|
2016-04-07 17:08:00 +00:00
|
|
|
/**
|
|
|
|
* Enables / disables the toolbar.
|
|
|
|
* @param {e} set to {true} to enable the toolbar or {false}
|
|
|
|
* to disable it
|
|
|
|
*/
|
|
|
|
enable (e) {
|
|
|
|
this.enabled = e;
|
|
|
|
if (!e && this.isVisible())
|
|
|
|
this.hide(false);
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Indicates if the bottom toolbar is currently enabled.
|
|
|
|
* @return {this.enabled}
|
|
|
|
*/
|
|
|
|
isEnabled() {
|
|
|
|
return this.enabled;
|
|
|
|
},
|
2014-12-16 13:54:13 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
showEtherpadButton () {
|
|
|
|
if (!$('#toolbar_button_etherpad').is(":visible")) {
|
|
|
|
$('#toolbar_button_etherpad').css({display: 'inline-block'});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
// Shows or hides the 'shared video' button.
|
2016-03-26 00:38:56 +00:00
|
|
|
showSharedVideoButton () {
|
2016-11-04 13:58:43 +00:00
|
|
|
let id = 'toolbar_button_sharedvideo';
|
|
|
|
let shouldShow = UIUtil.isButtonEnabled('sharedvideo')
|
|
|
|
&& !config.disableThirdPartyRequests;
|
|
|
|
|
|
|
|
if (shouldShow) {
|
|
|
|
let el = document.getElementById(id);
|
|
|
|
UIUtil.setTooltip(el, 'toolbar.sharedvideo', 'right');
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(id, shouldShow);
|
2016-03-18 20:00:55 +00:00
|
|
|
},
|
|
|
|
|
2015-11-13 22:18:22 +00:00
|
|
|
// checks whether desktop sharing is enabled and whether
|
|
|
|
// we have params to start automatically sharing
|
2015-12-09 17:10:49 +00:00
|
|
|
checkAutoEnableDesktopSharing () {
|
2016-04-07 17:08:00 +00:00
|
|
|
if (UIUtil.isButtonEnabled('desktop')
|
|
|
|
&& config.autoEnableDesktopSharing) {
|
2015-12-30 13:28:56 +00:00
|
|
|
emitter.emit(UIEvents.TOGGLE_SCREENSHARING);
|
2015-11-13 22:18:22 +00:00
|
|
|
}
|
2015-12-09 17:10:49 +00:00
|
|
|
},
|
2015-11-13 22:18:22 +00:00
|
|
|
|
2014-08-08 13:25:24 +00:00
|
|
|
// Shows or hides SIP calls button
|
2015-12-09 17:10:49 +00:00
|
|
|
showSipCallButton (show) {
|
2016-11-04 13:58:43 +00:00
|
|
|
let shouldShow = APP.conference.sipGatewayEnabled()
|
|
|
|
&& UIUtil.isButtonEnabled('sip') && show;
|
|
|
|
let id = 'toolbar_button_sip';
|
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(id, shouldShow);
|
2015-12-09 17:10:49 +00:00
|
|
|
},
|
2014-08-08 13:25:24 +00:00
|
|
|
|
2015-04-08 10:51:29 +00:00
|
|
|
// Shows or hides the dialpad button
|
2015-12-09 17:10:49 +00:00
|
|
|
showDialPadButton (show) {
|
2016-11-04 13:58:43 +00:00
|
|
|
let shouldShow = UIUtil.isButtonEnabled('dialpad') && show;
|
|
|
|
let id = 'toolbar_button_dialpad';
|
2016-11-23 21:04:05 +00:00
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(id, shouldShow);
|
2015-12-09 17:10:49 +00:00
|
|
|
},
|
2015-04-08 10:51:29 +00:00
|
|
|
|
2014-09-24 12:47:26 +00:00
|
|
|
/**
|
2016-02-04 15:25:11 +00:00
|
|
|
* Update the state of the button. The button has blue glow if desktop
|
2014-11-28 15:16:27 +00:00
|
|
|
* streaming is active.
|
2014-09-24 12:47:26 +00:00
|
|
|
*/
|
2016-02-04 15:25:11 +00:00
|
|
|
updateDesktopSharingButtonState () {
|
2016-10-06 21:25:15 +00:00
|
|
|
this._setToggledState( "toolbar_button_desktopsharing",
|
|
|
|
APP.conference.isSharingScreen);
|
2016-09-16 05:09:26 +00:00
|
|
|
},
|
|
|
|
|
2016-02-09 10:19:43 +00:00
|
|
|
/**
|
|
|
|
* Marks video icon as muted or not.
|
2016-10-06 21:25:15 +00:00
|
|
|
*
|
2016-02-09 10:19:43 +00:00
|
|
|
* @param {boolean} muted if icon should look like muted or not
|
|
|
|
*/
|
2016-10-06 21:25:15 +00:00
|
|
|
toggleVideoIcon (muted) {
|
2016-02-09 10:19:43 +00:00
|
|
|
$('#toolbar_button_camera').toggleClass("icon-camera-disabled", muted);
|
2016-10-06 21:25:15 +00:00
|
|
|
|
|
|
|
this._setToggledState("toolbar_button_camera", muted);
|
2016-02-09 10:19:43 +00:00
|
|
|
},
|
|
|
|
|
2016-05-17 15:58:25 +00:00
|
|
|
/**
|
2016-10-07 18:55:27 +00:00
|
|
|
* Enables / disables audio toolbar button.
|
|
|
|
*
|
|
|
|
* @param {boolean} enabled indicates if the button should be enabled
|
|
|
|
* or disabled
|
2016-05-17 15:58:25 +00:00
|
|
|
*/
|
2016-10-07 18:55:27 +00:00
|
|
|
setVideoIconEnabled (enabled) {
|
2016-10-07 20:31:00 +00:00
|
|
|
this._setMediaIconEnabled(
|
|
|
|
'#toolbar_button_camera',
|
|
|
|
enabled,
|
|
|
|
/* data-i18n attribute value */
|
|
|
|
`[content]toolbar.${enabled ? 'videomute' : 'cameraDisabled'}`,
|
|
|
|
/* shortcut attribute value */
|
|
|
|
'toggleVideoPopover');
|
|
|
|
|
|
|
|
enabled || this.toggleVideoIcon(!enabled);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables/disables the toolbar button associated with a specific media such
|
|
|
|
* as audio or video.
|
|
|
|
*
|
|
|
|
* @param {string} btn - The jQuery selector <tt>string</tt> which
|
|
|
|
* identifies the toolbar button to be enabled/disabled.
|
|
|
|
* @param {boolean} enabled - <tt>true</tt> to enable the specified
|
|
|
|
* <tt>btn</tt> or <tt>false</tt> to disable it.
|
|
|
|
* @param {string} dataI18n - The value to assign to the <tt>data-i18n</tt>
|
|
|
|
* attribute of the specified <tt>btn</tt>.
|
|
|
|
* @param {string} shortcut - The value, if any, to assign to the
|
|
|
|
* <tt>shortcut</tt> attribute of the specified <tt>btn</tt> if the toolbar
|
|
|
|
* button is enabled.
|
|
|
|
*/
|
|
|
|
_setMediaIconEnabled(btn, enabled, dataI18n, shortcut) {
|
|
|
|
const $btn = $(btn);
|
2016-05-17 15:58:25 +00:00
|
|
|
|
|
|
|
$btn
|
2016-10-07 20:31:00 +00:00
|
|
|
.prop('disabled', !enabled)
|
|
|
|
.attr('data-i18n', dataI18n)
|
|
|
|
.attr('shortcut', enabled && shortcut ? shortcut : '');
|
2016-05-17 15:58:25 +00:00
|
|
|
|
2016-10-07 18:55:27 +00:00
|
|
|
enabled
|
2016-10-07 20:31:00 +00:00
|
|
|
? $btn.removeAttr('disabled')
|
|
|
|
: $btn.attr('disabled', 'disabled');
|
2016-05-17 15:58:25 +00:00
|
|
|
|
|
|
|
APP.translation.translateElement($btn);
|
|
|
|
},
|
|
|
|
|
2016-02-09 10:19:43 +00:00
|
|
|
/**
|
|
|
|
* Marks audio icon as muted or not.
|
2016-10-06 21:25:15 +00:00
|
|
|
*
|
2016-02-09 10:19:43 +00:00
|
|
|
* @param {boolean} muted if icon should look like muted or not
|
|
|
|
*/
|
2016-10-06 21:25:15 +00:00
|
|
|
toggleAudioIcon(muted) {
|
2016-10-07 20:31:00 +00:00
|
|
|
$('#toolbar_button_mute')
|
|
|
|
.toggleClass("icon-microphone", !muted)
|
|
|
|
.toggleClass("icon-mic-disabled", muted);
|
2016-10-06 21:25:15 +00:00
|
|
|
|
|
|
|
this._setToggledState("toolbar_button_mute", muted);
|
2016-04-07 17:08:00 +00:00
|
|
|
},
|
|
|
|
|
2016-05-17 15:58:25 +00:00
|
|
|
/**
|
2016-10-07 18:55:27 +00:00
|
|
|
* Enables / disables audio toolbar button.
|
|
|
|
*
|
|
|
|
* @param {boolean} enabled indicates if the button should be enabled
|
|
|
|
* or disabled
|
2016-05-17 15:58:25 +00:00
|
|
|
*/
|
2016-10-07 18:55:27 +00:00
|
|
|
setAudioIconEnabled (enabled) {
|
2016-10-07 20:31:00 +00:00
|
|
|
this._setMediaIconEnabled(
|
|
|
|
'#toolbar_button_mute',
|
|
|
|
enabled,
|
|
|
|
/* data-i18n attribute value */
|
|
|
|
`[content]toolbar.${enabled ? 'mute' : 'micDisabled'}`,
|
|
|
|
/* shortcut attribute value */
|
|
|
|
'mutePopover');
|
|
|
|
|
|
|
|
enabled || this.toggleAudioIcon(!enabled);
|
2016-05-17 15:58:25 +00:00
|
|
|
},
|
|
|
|
|
2016-04-07 17:08:00 +00:00
|
|
|
/**
|
|
|
|
* Indicates if the toolbar is currently hovered.
|
2016-08-09 22:39:24 +00:00
|
|
|
* @return {boolean} true if the toolbar is currently hovered,
|
|
|
|
* false otherwise
|
2016-04-07 17:08:00 +00:00
|
|
|
*/
|
|
|
|
isHovered() {
|
2016-08-09 22:39:24 +00:00
|
|
|
var hovered = false;
|
2016-04-07 17:08:00 +00:00
|
|
|
this.toolbarSelector.find('*').each(function () {
|
|
|
|
let id = $(this).attr('id');
|
|
|
|
if ($(`#${id}:hover`).length > 0) {
|
2016-08-09 22:39:24 +00:00
|
|
|
hovered = true;
|
|
|
|
// break each
|
|
|
|
return false;
|
2016-04-07 17:08:00 +00:00
|
|
|
}
|
|
|
|
});
|
2016-08-09 22:39:24 +00:00
|
|
|
if (hovered)
|
|
|
|
return true;
|
2016-09-08 18:16:23 +00:00
|
|
|
if ($("#bottomToolbar:hover").length > 0
|
|
|
|
|| $("#extendedToolbar:hover").length > 0
|
2016-09-10 02:26:29 +00:00
|
|
|
|| SideContainerToggler.isHovered()) {
|
2016-04-07 17:08:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this toolbar is currently visible, or false otherwise.
|
|
|
|
* @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
|
|
|
|
*/
|
|
|
|
isVisible() {
|
2016-10-25 11:55:43 +00:00
|
|
|
return this.toolbarSelector.hasClass("fadeIn");
|
2016-04-07 17:08:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the toolbar with animation or not depending on the animate
|
|
|
|
* parameter.
|
|
|
|
*/
|
|
|
|
hide() {
|
2016-10-25 11:55:43 +00:00
|
|
|
this.toolbarSelector
|
|
|
|
.removeClass("fadeIn")
|
|
|
|
.addClass("fadeOut");
|
2016-09-10 02:26:29 +00:00
|
|
|
|
|
|
|
let slideInAnimation = (SideContainerToggler.isVisible)
|
|
|
|
? "slideInExtX"
|
|
|
|
: "slideInX";
|
|
|
|
let slideOutAnimation = (SideContainerToggler.isVisible)
|
|
|
|
? "slideOutExtX"
|
|
|
|
: "slideOutX";
|
|
|
|
|
|
|
|
this.extendedToolbarSelector.toggleClass(slideInAnimation)
|
|
|
|
.toggleClass(slideOutAnimation);
|
2016-04-07 17:08:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the toolbar with animation or not depending on the animate
|
|
|
|
* parameter.
|
|
|
|
*/
|
|
|
|
show() {
|
2016-10-25 11:55:43 +00:00
|
|
|
if (this.toolbarSelector.hasClass("fadeOut")) {
|
|
|
|
this.toolbarSelector.removeClass("fadeOut");
|
|
|
|
}
|
2016-09-08 18:16:23 +00:00
|
|
|
|
2016-09-10 02:26:29 +00:00
|
|
|
let slideInAnimation = (SideContainerToggler.isVisible)
|
|
|
|
? "slideInExtX"
|
|
|
|
: "slideInX";
|
|
|
|
let slideOutAnimation = (SideContainerToggler.isVisible)
|
|
|
|
? "slideOutExtX"
|
|
|
|
: "slideOutX";
|
|
|
|
|
2016-10-25 11:55:43 +00:00
|
|
|
if (this.extendedToolbarSelector.hasClass(slideOutAnimation)) {
|
2016-09-10 02:26:29 +00:00
|
|
|
this.extendedToolbarSelector.toggleClass(slideOutAnimation);
|
2016-10-25 11:55:43 +00:00
|
|
|
}
|
2016-09-08 18:16:23 +00:00
|
|
|
|
2016-10-25 11:55:43 +00:00
|
|
|
this.toolbarSelector.addClass("fadeIn");
|
2016-09-10 02:26:29 +00:00
|
|
|
this.extendedToolbarSelector.toggleClass(slideInAnimation);
|
|
|
|
},
|
|
|
|
|
|
|
|
registerClickListeners(listener) {
|
|
|
|
$('#mainToolbarContainer').click(listener);
|
|
|
|
|
|
|
|
$("#extendedToolbar").click(listener);
|
2016-09-08 22:34:16 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2016-09-10 02:26:29 +00:00
|
|
|
* Handles the side toolbar toggle.
|
2016-10-13 20:09:18 +00:00
|
|
|
*
|
|
|
|
* @param {string} containerId the identifier of the container element
|
2016-09-08 22:34:16 +00:00
|
|
|
*/
|
2016-10-03 16:12:04 +00:00
|
|
|
_handleSideToolbarContainerToggled(containerId) {
|
2016-09-08 22:34:16 +00:00
|
|
|
Object.keys(defaultToolbarButtons).forEach(
|
|
|
|
id => {
|
|
|
|
if (!UIUtil.isButtonEnabled(id))
|
|
|
|
return;
|
|
|
|
|
|
|
|
var button = defaultToolbarButtons[id];
|
|
|
|
|
|
|
|
if (button.sideContainerId
|
|
|
|
&& button.sideContainerId === containerId) {
|
|
|
|
UIUtil.buttonClick(button.id, "selected");
|
2016-09-11 21:54:32 +00:00
|
|
|
return;
|
2016-09-08 22:34:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2016-09-11 21:54:32 +00:00
|
|
|
},
|
2016-09-14 01:50:30 +00:00
|
|
|
|
2016-10-13 20:09:18 +00:00
|
|
|
/**
|
|
|
|
* Handles full screen toggled.
|
|
|
|
*
|
|
|
|
* @param {boolean} isFullScreen indicates if we're currently in full
|
|
|
|
* screen mode
|
|
|
|
*/
|
|
|
|
_handleFullScreenToggled(isFullScreen) {
|
|
|
|
let element
|
|
|
|
= document.getElementById("toolbar_button_fullScreen");
|
|
|
|
|
|
|
|
element.className = isFullScreen
|
|
|
|
? element.className
|
|
|
|
.replace("icon-full-screen", "icon-exit-full-screen")
|
|
|
|
: element.className
|
|
|
|
.replace("icon-exit-full-screen", "icon-full-screen");
|
|
|
|
|
|
|
|
Toolbar._setToggledState("toolbar_button_fullScreen", isFullScreen);
|
|
|
|
},
|
|
|
|
|
2016-09-11 21:54:32 +00:00
|
|
|
/**
|
2016-10-11 13:30:28 +00:00
|
|
|
* Initialise toolbar buttons.
|
2016-09-11 21:54:32 +00:00
|
|
|
*/
|
2016-10-11 13:30:28 +00:00
|
|
|
_initToolbarButtons() {
|
|
|
|
interfaceConfig.TOOLBAR_BUTTONS.forEach((value, index) => {
|
|
|
|
let place = getToolbarButtonPlace(value);
|
|
|
|
|
2016-09-11 21:54:32 +00:00
|
|
|
if (value && value in defaultToolbarButtons) {
|
|
|
|
let button = defaultToolbarButtons[value];
|
2016-10-11 13:30:28 +00:00
|
|
|
this._addToolbarButton(
|
2016-09-11 21:54:32 +00:00
|
|
|
button,
|
2016-10-11 13:30:28 +00:00
|
|
|
place,
|
2016-10-17 20:59:35 +00:00
|
|
|
(interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX !== undefined
|
2016-10-14 20:27:08 +00:00
|
|
|
&& index
|
|
|
|
=== interfaceConfig.MAIN_TOOLBAR_SPLITTER_INDEX));
|
2016-09-11 21:54:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-09-13 04:10:18 +00:00
|
|
|
/**
|
2016-10-11 13:30:28 +00:00
|
|
|
* Adds the given button to the main (top) or extended (left) toolbar.
|
2016-09-13 04:10:18 +00:00
|
|
|
*
|
|
|
|
* @param {Object} the button to add.
|
|
|
|
* @param {boolean} isFirst indicates if this is the first button in the
|
|
|
|
* toolbar
|
|
|
|
* @param {boolean} isLast indicates if this is the last button in the
|
|
|
|
* toolbar
|
2016-10-14 20:27:08 +00:00
|
|
|
* @param {boolean} isSplitter if this button is a splitter button for
|
|
|
|
* the dialog, which means that a special splitter style will be applied
|
2016-09-13 04:10:18 +00:00
|
|
|
*/
|
2016-10-11 13:30:28 +00:00
|
|
|
_addToolbarButton(button, place, isSplitter) {
|
|
|
|
const places = {
|
|
|
|
main: 'mainToolbar',
|
|
|
|
extended: 'extendedToolbarButtons'
|
|
|
|
};
|
|
|
|
let id = places[place];
|
2016-09-11 21:54:32 +00:00
|
|
|
let buttonElement = document.createElement("a");
|
2016-11-01 15:59:57 +00:00
|
|
|
if (button.className) {
|
|
|
|
buttonElement.className = button.className;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSplitter) {
|
|
|
|
let splitter = document.createElement('span');
|
|
|
|
splitter.className = 'toolbar__splitter';
|
|
|
|
document.getElementById(id).appendChild(splitter);
|
|
|
|
}
|
2016-09-11 21:54:32 +00:00
|
|
|
|
|
|
|
buttonElement.id = button.id;
|
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
if (button.html)
|
|
|
|
buttonElement.innerHTML = button.html;
|
|
|
|
|
|
|
|
//TODO: remove it after UI.updateDTMFSupport fix
|
|
|
|
if (button.hidden)
|
|
|
|
buttonElement.style.display = 'none';
|
|
|
|
|
2016-09-11 21:54:32 +00:00
|
|
|
if (button.shortcutAttr)
|
|
|
|
buttonElement.setAttribute("shortcut", button.shortcutAttr);
|
|
|
|
|
|
|
|
if (button.content)
|
|
|
|
buttonElement.setAttribute("content", button.content);
|
|
|
|
|
|
|
|
if (button.i18n)
|
|
|
|
buttonElement.setAttribute("data-i18n", button.i18n);
|
|
|
|
|
|
|
|
buttonElement.setAttribute("data-container", "body");
|
|
|
|
buttonElement.setAttribute("data-placement", "bottom");
|
2016-09-12 19:43:34 +00:00
|
|
|
this._addPopups(buttonElement, button.popups);
|
2016-09-11 21:54:32 +00:00
|
|
|
|
2016-10-11 13:30:28 +00:00
|
|
|
document.getElementById(id)
|
2016-09-11 21:54:32 +00:00
|
|
|
.appendChild(buttonElement);
|
2016-09-12 19:43:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_addPopups(buttonElement, popups = []) {
|
|
|
|
popups.forEach((popup) => {
|
2017-02-15 08:54:57 +00:00
|
|
|
const popupElement = document.createElement('div');
|
2016-09-12 19:43:34 +00:00
|
|
|
popupElement.id = popup.id;
|
|
|
|
popupElement.className = popup.className;
|
2017-02-15 08:54:57 +00:00
|
|
|
popupElement.setAttribute('data-i18n', popup.dataAttr);
|
|
|
|
|
|
|
|
let gravity = 'n';
|
|
|
|
if (popup.dataAttrPosition)
|
|
|
|
gravity = popup.dataAttrPosition;
|
2017-02-16 22:14:58 +00:00
|
|
|
// use custom attribute to save gravity option
|
|
|
|
// we use 'data-tooltip' in UIUtil to activate all tooltips
|
|
|
|
// but we want these to be manually triggered
|
|
|
|
popupElement.setAttribute('tooltip-gravity', gravity);
|
|
|
|
|
|
|
|
APP.translation.translateElement($(popupElement));
|
2017-02-15 08:54:57 +00:00
|
|
|
|
2016-09-12 19:43:34 +00:00
|
|
|
buttonElement.appendChild(popupElement);
|
|
|
|
});
|
2016-10-06 21:25:15 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-02-15 08:54:57 +00:00
|
|
|
* Show custom popup/tooltip for a specified button.
|
|
|
|
* @param popupSelectorID the selector id of the popup to show
|
|
|
|
* @param show true or false/show or hide the popup
|
|
|
|
* @param timeout the time to show the popup
|
|
|
|
*/
|
|
|
|
_showCustomToolbarPopup(popupSelectorID, show, timeout) {
|
|
|
|
|
2017-02-16 22:14:58 +00:00
|
|
|
const gravity = $(popupSelectorID).attr('tooltip-gravity');
|
2017-02-15 08:54:57 +00:00
|
|
|
AJS.$(popupSelectorID)
|
|
|
|
.tooltip({
|
|
|
|
trigger: 'manual',
|
|
|
|
html: true,
|
|
|
|
gravity: gravity,
|
|
|
|
title: 'title'});
|
|
|
|
if (show) {
|
|
|
|
AJS.$(popupSelectorID).tooltip('show');
|
|
|
|
setTimeout(function () {
|
|
|
|
// hide the tooltip
|
|
|
|
AJS.$(popupSelectorID).tooltip('hide');
|
|
|
|
}, timeout);
|
|
|
|
} else {
|
|
|
|
AJS.$(popupSelectorID).tooltip('hide');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2016-10-06 21:25:15 +00:00
|
|
|
* Sets the toggled state of the given element depending on the isToggled
|
|
|
|
* parameter.
|
|
|
|
*
|
|
|
|
* @param elementId the element identifier
|
|
|
|
* @param isToggled indicates if the element should be toggled or untoggled
|
|
|
|
*/
|
2016-10-07 18:55:27 +00:00
|
|
|
_setToggledState(elementId, isToggled) {
|
2016-10-06 21:25:15 +00:00
|
|
|
$("#" + elementId).toggleClass("toggled", isToggled);
|
2016-10-11 13:30:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets Shortcuts and Tooltips for all toolbar buttons
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_setShortcutsAndTooltips() {
|
|
|
|
Object.keys(defaultToolbarButtons).forEach(
|
|
|
|
id => {
|
|
|
|
if (UIUtil.isButtonEnabled(id)) {
|
|
|
|
let button = defaultToolbarButtons[id];
|
|
|
|
let buttonElement = document.getElementById(button.id);
|
|
|
|
if (!buttonElement) return false;
|
|
|
|
let tooltipPosition
|
|
|
|
= (interfaceConfig.MAIN_TOOLBAR_BUTTONS
|
|
|
|
.indexOf(id) > -1)
|
|
|
|
? "bottom" : "right";
|
|
|
|
|
|
|
|
UIUtil.setTooltip( buttonElement,
|
|
|
|
button.tooltipKey,
|
|
|
|
tooltipPosition);
|
|
|
|
|
|
|
|
if (button.shortcut)
|
|
|
|
APP.keyboardshortcut.registerShortcut(
|
|
|
|
button.shortcut,
|
|
|
|
button.shortcutAttr,
|
|
|
|
button.shortcutFunc,
|
|
|
|
button.shortcutDescription
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets Handlers for all toolbar buttons
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_setButtonHandlers() {
|
|
|
|
Object.keys(buttonHandlers).forEach(
|
|
|
|
buttonId => $(`#${buttonId}`).click(function(event) {
|
|
|
|
!$(this).prop('disabled') && buttonHandlers[buttonId](event);
|
|
|
|
})
|
|
|
|
);
|
2015-12-09 17:10:49 +00:00
|
|
|
}
|
|
|
|
};
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2016-10-03 16:12:04 +00:00
|
|
|
export default Toolbar;
|