您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Toolbar.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /* global APP, $, config, interfaceConfig */
  2. /* jshint -W101 */
  3. var messageHandler = require("../util/MessageHandler");
  4. var BottomToolbar = require("./BottomToolbar");
  5. var Prezi = require("../prezi/Prezi");
  6. var Etherpad = require("../etherpad/Etherpad");
  7. var PanelToggler = require("../side_pannels/SidePanelToggler");
  8. var Authentication = require("../authentication/Authentication");
  9. var UIUtil = require("../util/UIUtil");
  10. var AuthenticationEvents
  11. = require("../../../service/authentication/AuthenticationEvents");
  12. var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter");
  13. var Feedback = require("../Feedback");
  14. var UIEvents = require("../../../service/UI/UIEvents");
  15. var roomUrl = null;
  16. var sharedKey = '';
  17. var recordingToaster = null;
  18. var emitter = null;
  19. var buttonHandlers = {
  20. "toolbar_button_mute": function () {
  21. if (APP.RTC.localAudio.isMuted()) {
  22. AnalyticsAdapter.sendEvent('toolbar.audio.unmuted');
  23. emitter.emit(UIEvents.AUDIO_MUTED, false);
  24. } else {
  25. AnalyticsAdapter.sendEvent('toolbar.audio.muted');
  26. emitter.emit(UIEvents.AUDIO_MUTED, true);
  27. }
  28. },
  29. "toolbar_button_camera": function () {
  30. if (APP.RTC.localVideo.isMuted()) {
  31. AnalyticsAdapter.sendEvent('toolbar.video.enabled');
  32. emitter.emit(UIEvents.VIDEO_MUTED, false);
  33. } else {
  34. AnalyticsAdapter.sendEvent('toolbar.video.disabled');
  35. emitter.emit(UIEvents.VIDEO_MUTED, true);
  36. }
  37. },
  38. /*"toolbar_button_authentication": function () {
  39. return Toolbar.authenticateClicked();
  40. },*/
  41. "toolbar_button_record": function () {
  42. AnalyticsAdapter.sendEvent('toolbar.recording.toggled');
  43. return toggleRecording();
  44. },
  45. "toolbar_button_security": function () {
  46. if (sharedKey) {
  47. AnalyticsAdapter.sendEvent('toolbar.lock.disabled');
  48. } else {
  49. AnalyticsAdapter.sendEvent('toolbar.lock.enabled');
  50. }
  51. return Toolbar.openLockDialog();
  52. },
  53. "toolbar_button_link": function () {
  54. AnalyticsAdapter.sendEvent('toolbar.invite.clicked');
  55. return Toolbar.openLinkDialog();
  56. },
  57. "toolbar_button_chat": function () {
  58. AnalyticsAdapter.sendEvent('toolbar.chat.toggled');
  59. return BottomToolbar.toggleChat();
  60. },
  61. "toolbar_button_prezi": function () {
  62. AnalyticsAdapter.sendEvent('toolbar.prezi.clicked');
  63. return Prezi.openPreziDialog();
  64. },
  65. "toolbar_button_etherpad": function () {
  66. AnalyticsAdapter.sendEvent('toolbar.etherpad.clicked');
  67. return Etherpad.toggleEtherpad(0);
  68. },
  69. "toolbar_button_desktopsharing": function () {
  70. if (APP.desktopsharing.isUsingScreenStream) {
  71. AnalyticsAdapter.sendEvent('toolbar.screen.disabled');
  72. } else {
  73. AnalyticsAdapter.sendEvent('toolbar.screen.enabled');
  74. }
  75. return APP.desktopsharing.toggleScreenSharing();
  76. },
  77. "toolbar_button_fullScreen": function() {
  78. AnalyticsAdapter.sendEvent('toolbar.fullscreen.enabled');
  79. UIUtil.buttonClick("#toolbar_button_fullScreen", "icon-full-screen icon-exit-full-screen");
  80. return Toolbar.toggleFullScreen();
  81. },
  82. "toolbar_button_sip": function () {
  83. AnalyticsAdapter.sendEvent('toolbar.sip.clicked');
  84. return callSipButtonClicked();
  85. },
  86. "toolbar_button_dialpad": function () {
  87. AnalyticsAdapter.sendEvent('toolbar.sip.dialpad.clicked');
  88. return dialpadButtonClicked();
  89. },
  90. "toolbar_button_settings": function () {
  91. AnalyticsAdapter.sendEvent('toolbar.settings.toggled');
  92. PanelToggler.toggleSettingsMenu();
  93. },
  94. "toolbar_button_hangup": function () {
  95. AnalyticsAdapter.sendEvent('toolbar.hangup');
  96. return hangup();
  97. },
  98. "toolbar_button_login": function () {
  99. AnalyticsAdapter.sendEvent('toolbar.authenticate.login.clicked');
  100. Toolbar.authenticateClicked();
  101. },
  102. "toolbar_button_logout": function () {
  103. AnalyticsAdapter.sendEvent('toolbar.authenticate.logout.clicked');
  104. // Ask for confirmation
  105. messageHandler.openTwoButtonDialog(
  106. "dialog.logoutTitle",
  107. null,
  108. "dialog.logoutQuestion",
  109. null,
  110. false,
  111. "dialog.Yes",
  112. function (evt, yes) {
  113. if (yes) {
  114. APP.xmpp.logout(function (url) {
  115. if (url) {
  116. window.location.href = url;
  117. } else {
  118. hangup();
  119. }
  120. });
  121. }
  122. });
  123. }
  124. };
  125. var defaultToolbarButtons = {
  126. 'microphone': '#toolbar_button_mute',
  127. 'camera': '#toolbar_button_camera',
  128. 'desktop': '#toolbar_button_desktopsharing',
  129. 'security': '#toolbar_button_security',
  130. 'invite': '#toolbar_button_link',
  131. 'chat': '#toolbar_button_chat',
  132. 'prezi': '#toolbar_button_prezi',
  133. 'etherpad': '#toolbar_button_etherpad',
  134. 'fullscreen': '#toolbar_button_fullScreen',
  135. 'settings': '#toolbar_button_settings',
  136. 'hangup': '#toolbar_button_hangup'
  137. };
  138. /**
  139. * Hangs up this call.
  140. */
  141. function hangup() {
  142. var conferenceDispose = function () {
  143. APP.xmpp.disposeConference();
  144. if (config.enableWelcomePage) {
  145. setTimeout(function() {
  146. window.localStorage.welcomePageDisabled = false;
  147. window.location.pathname = "/";
  148. }, 3000);
  149. }
  150. };
  151. if (Feedback.isEnabled())
  152. {
  153. // If the user has already entered feedback, we'll show the window and
  154. // immidiately start the conference dispose timeout.
  155. if (Feedback.feedbackScore > 0) {
  156. Feedback.openFeedbackWindow();
  157. conferenceDispose();
  158. }
  159. // Otherwise we'll wait for user's feedback.
  160. else
  161. Feedback.openFeedbackWindow(conferenceDispose);
  162. }
  163. else {
  164. conferenceDispose();
  165. // If the feedback functionality isn't enabled we show a thank you
  166. // dialog.
  167. APP.UI.messageHandler.openMessageDialog(null, null, null,
  168. APP.translation.translateString("dialog.thankYou",
  169. {appName:interfaceConfig.APP_NAME}));
  170. }
  171. }
  172. /**
  173. * Starts or stops the recording for the conference.
  174. */
  175. function toggleRecording(predefinedToken) {
  176. APP.xmpp.toggleRecording(function (callback) {
  177. if (predefinedToken) {
  178. callback(UIUtil.escapeHtml(predefinedToken));
  179. return;
  180. }
  181. var msg = APP.translation.generateTranslationHTML(
  182. "dialog.recordingToken");
  183. var token = APP.translation.translateString("dialog.token");
  184. APP.UI.messageHandler.openTwoButtonDialog(null, null, null,
  185. '<h2>' + msg + '</h2>' +
  186. '<input name="recordingToken" type="text" ' +
  187. ' data-i18n="[placeholder]dialog.token" ' +
  188. 'placeholder="' + token + '" autofocus>',
  189. false,
  190. "dialog.Save",
  191. function (e, v, m, f) {
  192. if (v) {
  193. var token = f.recordingToken;
  194. if (token) {
  195. callback(UIUtil.escapeHtml(token));
  196. }
  197. }
  198. },
  199. null,
  200. function () { },
  201. ':input:first'
  202. );
  203. }, Toolbar.setRecordingButtonState);
  204. }
  205. /**
  206. * Locks / unlocks the room.
  207. */
  208. function lockRoom(lock) {
  209. var currentSharedKey = '';
  210. if (lock)
  211. currentSharedKey = sharedKey;
  212. APP.xmpp.lockRoom(currentSharedKey, function (res) {
  213. // password is required
  214. if (sharedKey) {
  215. console.log('set room password');
  216. Toolbar.lockLockButton();
  217. }
  218. else {
  219. console.log('removed room password');
  220. Toolbar.unlockLockButton();
  221. }
  222. }, function (err) {
  223. console.warn('setting password failed', err);
  224. messageHandler.showError("dialog.lockTitle",
  225. "dialog.lockMessage");
  226. Toolbar.setSharedKey('');
  227. }, function () {
  228. console.warn('room passwords not supported');
  229. messageHandler.showError("dialog.warning",
  230. "dialog.passwordNotSupported");
  231. Toolbar.setSharedKey('');
  232. });
  233. }
  234. /**
  235. * Invite participants to conference.
  236. */
  237. function inviteParticipants() {
  238. if (roomUrl === null)
  239. return;
  240. var sharedKeyText = "";
  241. if (sharedKey && sharedKey.length > 0) {
  242. sharedKeyText =
  243. APP.translation.translateString("email.sharedKey",
  244. {sharedKey: sharedKey});
  245. sharedKeyText = sharedKeyText.replace(/\n/g, "%0D%0A");
  246. }
  247. var supportedBrowsers = "Chromium, Google Chrome " +
  248. APP.translation.translateString("email.and") + " Opera";
  249. var conferenceName = roomUrl.substring(roomUrl.lastIndexOf('/') + 1);
  250. var subject = APP.translation.translateString("email.subject",
  251. {appName:interfaceConfig.APP_NAME, conferenceName: conferenceName});
  252. var body = APP.translation.translateString("email.body",
  253. {appName:interfaceConfig.APP_NAME, sharedKeyText: sharedKeyText,
  254. roomUrl: roomUrl, supportedBrowsers: supportedBrowsers});
  255. body = body.replace(/\n/g, "%0D%0A");
  256. if (window.localStorage.displayname) {
  257. body += "%0D%0A%0D%0A" + window.localStorage.displayname;
  258. }
  259. if (interfaceConfig.INVITATION_POWERED_BY) {
  260. body += "%0D%0A%0D%0A--%0D%0Apowered by jitsi.org";
  261. }
  262. window.open("mailto:?subject=" + subject + "&body=" + body, '_blank');
  263. }
  264. function dialpadButtonClicked() {
  265. //TODO show the dialpad box
  266. }
  267. function callSipButtonClicked() {
  268. var defaultNumber
  269. = config.defaultSipNumber ? config.defaultSipNumber : '';
  270. var sipMsg = APP.translation.generateTranslationHTML(
  271. "dialog.sipMsg");
  272. messageHandler.openTwoButtonDialog(null, null, null,
  273. '<h2>' + sipMsg + '</h2>' +
  274. '<input name="sipNumber" type="text"' +
  275. ' value="' + defaultNumber + '" autofocus>',
  276. false,
  277. "dialog.Dial",
  278. function (e, v, m, f) {
  279. if (v) {
  280. var numberInput = f.sipNumber;
  281. if (numberInput) {
  282. APP.xmpp.dial(
  283. numberInput, 'fromnumber', APP.conference.roomName, sharedKey);
  284. }
  285. }
  286. },
  287. null, null, ':input:first'
  288. );
  289. }
  290. var Toolbar = (function (my) {
  291. my.init = function (eventEmitter) {
  292. emitter = eventEmitter;
  293. UIUtil.hideDisabledButtons(defaultToolbarButtons);
  294. for(var k in buttonHandlers)
  295. $("#" + k).click(buttonHandlers[k]);
  296. // Update login info
  297. APP.xmpp.addListener(
  298. AuthenticationEvents.IDENTITY_UPDATED,
  299. function (authenticationEnabled, userIdentity) {
  300. var loggedIn = false;
  301. if (userIdentity) {
  302. loggedIn = true;
  303. }
  304. Toolbar.showAuthenticateButton(authenticationEnabled);
  305. if (authenticationEnabled) {
  306. Toolbar.setAuthenticatedIdentity(userIdentity);
  307. Toolbar.showLoginButton(!loggedIn);
  308. Toolbar.showLogoutButton(loggedIn);
  309. }
  310. }
  311. );
  312. };
  313. /**
  314. * Sets shared key
  315. * @param sKey the shared key
  316. */
  317. my.setSharedKey = function (sKey) {
  318. sharedKey = sKey;
  319. };
  320. my.authenticateClicked = function () {
  321. Authentication.focusAuthenticationWindow();
  322. if (!APP.xmpp.isExternalAuthEnabled()) {
  323. Authentication.xmppAuthenticate();
  324. return;
  325. }
  326. // Get authentication URL
  327. if (!APP.xmpp.isMUCJoined()) {
  328. APP.xmpp.getLoginUrl(APP.conference.roomName, function (url) {
  329. // If conference has not been started yet - redirect to login page
  330. window.location.href = url;
  331. });
  332. } else {
  333. APP.xmpp.getPopupLoginUrl(APP.conference.roomName, function (url) {
  334. // Otherwise - open popup with authentication URL
  335. var authenticationWindow = Authentication.createAuthenticationWindow(
  336. function () {
  337. // On popup closed - retry room allocation
  338. APP.xmpp.allocateConferenceFocus(
  339. APP.conference.roomName,
  340. function () { console.info("AUTH DONE"); }
  341. );
  342. }, url);
  343. if (!authenticationWindow) {
  344. messageHandler.openMessageDialog(
  345. null, "dialog.popupError");
  346. }
  347. });
  348. }
  349. };
  350. /**
  351. * Updates the room invite url.
  352. */
  353. my.updateRoomUrl = function (newRoomUrl) {
  354. roomUrl = newRoomUrl;
  355. // If the invite dialog has been already opened we update the information.
  356. var inviteLink = document.getElementById('inviteLinkRef');
  357. if (inviteLink) {
  358. inviteLink.value = roomUrl;
  359. inviteLink.select();
  360. $('#inviteLinkRef').parent()
  361. .find('button[value=true]').prop('disabled', false);
  362. }
  363. };
  364. /**
  365. * Disables and enables some of the buttons.
  366. */
  367. my.setupButtonsFromConfig = function () {
  368. if (UIUtil.isButtonEnabled('prezi')) {
  369. $("#toolbar_button_prezi").css({display: "none"});
  370. }
  371. };
  372. /**
  373. * Opens the lock room dialog.
  374. */
  375. my.openLockDialog = function () {
  376. // Only the focus is able to set a shared key.
  377. if (!APP.xmpp.isModerator()) {
  378. if (sharedKey) {
  379. messageHandler.openMessageDialog(null,
  380. "dialog.passwordError");
  381. } else {
  382. messageHandler.openMessageDialog(null, "dialog.passwordError2");
  383. }
  384. } else {
  385. if (sharedKey) {
  386. messageHandler.openTwoButtonDialog(null, null,
  387. "dialog.passwordCheck",
  388. null,
  389. false,
  390. "dialog.Remove",
  391. function (e, v) {
  392. if (v) {
  393. Toolbar.setSharedKey('');
  394. lockRoom(false);
  395. }
  396. });
  397. } else {
  398. var msg = APP.translation.generateTranslationHTML(
  399. "dialog.passwordMsg");
  400. var yourPassword = APP.translation.translateString(
  401. "dialog.yourPassword");
  402. messageHandler.openTwoButtonDialog(null, null, null,
  403. '<h2>' + msg + '</h2>' +
  404. '<input name="lockKey" type="text"' +
  405. ' data-i18n="[placeholder]dialog.yourPassword" ' +
  406. 'placeholder="' + yourPassword + '" autofocus>',
  407. false,
  408. "dialog.Save",
  409. function (e, v, m, f) {
  410. if (v) {
  411. var lockKey = f.lockKey;
  412. if (lockKey) {
  413. Toolbar.setSharedKey(
  414. UIUtil.escapeHtml(lockKey));
  415. lockRoom(true);
  416. }
  417. }
  418. },
  419. null, null, 'input:first'
  420. );
  421. }
  422. }
  423. };
  424. /**
  425. * Opens the invite link dialog.
  426. */
  427. my.openLinkDialog = function () {
  428. var inviteAttributes;
  429. if (roomUrl === null) {
  430. inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' +
  431. APP.translation.translateString("roomUrlDefaultMsg") + '"';
  432. } else {
  433. inviteAttributes = "value=\"" + encodeURI(roomUrl) + "\"";
  434. }
  435. messageHandler.openTwoButtonDialog("dialog.shareLink",
  436. null, null,
  437. '<input id="inviteLinkRef" type="text" ' +
  438. inviteAttributes + ' onclick="this.select();" readonly>',
  439. false,
  440. "dialog.Invite",
  441. function (e, v) {
  442. if (v) {
  443. if (roomUrl) {
  444. inviteParticipants();
  445. }
  446. }
  447. },
  448. function (event) {
  449. if (roomUrl) {
  450. document.getElementById('inviteLinkRef').select();
  451. } else {
  452. if (event && event.target)
  453. $(event.target)
  454. .find('button[value=true]').prop('disabled', true);
  455. }
  456. }
  457. );
  458. };
  459. /**
  460. * Opens the settings dialog.
  461. * FIXME: not used ?
  462. */
  463. my.openSettingsDialog = function () {
  464. var settings1 = APP.translation.generateTranslationHTML(
  465. "dialog.settings1");
  466. var settings2 = APP.translation.generateTranslationHTML(
  467. "dialog.settings2");
  468. var settings3 = APP.translation.generateTranslationHTML(
  469. "dialog.settings3");
  470. var yourPassword = APP.translation.translateString(
  471. "dialog.yourPassword");
  472. messageHandler.openTwoButtonDialog(null,
  473. '<h2>' + settings1 + '</h2>' +
  474. '<input type="checkbox" id="initMuted">' +
  475. settings2 + '<br/>' +
  476. '<input type="checkbox" id="requireNicknames">' +
  477. settings3 +
  478. '<input id="lockKey" type="text" placeholder="' + yourPassword +
  479. '" data-i18n="[placeholder]dialog.yourPassword" autofocus>',
  480. null,
  481. null,
  482. false,
  483. "dialog.Save",
  484. function () {
  485. document.getElementById('lockKey').focus();
  486. },
  487. function (e, v) {
  488. if (v) {
  489. if ($('#initMuted').is(":checked")) {
  490. // it is checked
  491. }
  492. if ($('#requireNicknames').is(":checked")) {
  493. // it is checked
  494. }
  495. /*
  496. var lockKey = document.getElementById('lockKey');
  497. if (lockKey.value) {
  498. setSharedKey(lockKey.value);
  499. lockRoom(true);
  500. }
  501. */
  502. }
  503. }
  504. );
  505. };
  506. /**
  507. * Toggles the application in and out of full screen mode
  508. * (a.k.a. presentation mode in Chrome).
  509. */
  510. my.toggleFullScreen = function () {
  511. var fsElement = document.documentElement;
  512. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  513. //Enter Full Screen
  514. if (fsElement.mozRequestFullScreen) {
  515. fsElement.mozRequestFullScreen();
  516. }
  517. else {
  518. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  519. }
  520. } else {
  521. //Exit Full Screen
  522. if (document.mozCancelFullScreen) {
  523. document.mozCancelFullScreen();
  524. } else {
  525. document.webkitCancelFullScreen();
  526. }
  527. }
  528. };
  529. /**
  530. * Unlocks the lock button state.
  531. */
  532. my.unlockLockButton = function () {
  533. if ($("#toolbar_button_security").hasClass("icon-security-locked"))
  534. UIUtil.buttonClick("#toolbar_button_security", "icon-security icon-security-locked");
  535. };
  536. /**
  537. * Updates the lock button state to locked.
  538. */
  539. my.lockLockButton = function () {
  540. if ($("#toolbar_button_security").hasClass("icon-security"))
  541. UIUtil.buttonClick("#toolbar_button_security", "icon-security icon-security-locked");
  542. };
  543. /**
  544. * Shows or hides authentication button
  545. * @param show <tt>true</tt> to show or <tt>false</tt> to hide
  546. */
  547. my.showAuthenticateButton = function (show) {
  548. if (UIUtil.isButtonEnabled('authentication') && show) {
  549. $('#authentication').css({display: "inline"});
  550. }
  551. else {
  552. $('#authentication').css({display: "none"});
  553. }
  554. };
  555. // Shows or hides the 'recording' button.
  556. my.showRecordingButton = function (show) {
  557. if (UIUtil.isButtonEnabled('recording') && show) {
  558. $('#toolbar_button_record').css({display: "inline-block"});
  559. }
  560. else {
  561. $('#toolbar_button_record').css({display: "none"});
  562. }
  563. };
  564. // Sets the state of the recording button
  565. my.setRecordingButtonState = function (recordingState) {
  566. var selector = $('#toolbar_button_record');
  567. if (recordingState === 'on') {
  568. selector.removeClass("icon-recEnable");
  569. selector.addClass("icon-recEnable active");
  570. $("#largeVideo").toggleClass("videoMessageFilter", true);
  571. var recordOnKey = "recording.on";
  572. $('#videoConnectionMessage').attr("data-i18n", recordOnKey);
  573. $('#videoConnectionMessage').text(APP.translation.translateString(recordOnKey));
  574. setTimeout(function(){
  575. $("#largeVideo").toggleClass("videoMessageFilter", false);
  576. $('#videoConnectionMessage').css({display: "none"});
  577. }, 1500);
  578. recordingToaster = messageHandler.notify(null, "recording.toaster", null,
  579. null, null, {timeOut: 0, closeButton: null, tapToDismiss: false});
  580. } else if (recordingState === 'off') {
  581. selector.removeClass("icon-recEnable active");
  582. selector.addClass("icon-recEnable");
  583. $("#largeVideo").toggleClass("videoMessageFilter", false);
  584. $('#videoConnectionMessage').css({display: "none"});
  585. if (recordingToaster)
  586. messageHandler.remove(recordingToaster);
  587. } else if (recordingState === 'pending') {
  588. selector.removeClass("icon-recEnable active");
  589. selector.addClass("icon-recEnable");
  590. $("#largeVideo").toggleClass("videoMessageFilter", true);
  591. var recordPendingKey = "recording.pending";
  592. $('#videoConnectionMessage').attr("data-i18n", recordPendingKey);
  593. $('#videoConnectionMessage').text(APP.translation.translateString(recordPendingKey));
  594. $('#videoConnectionMessage').css({display: "block"});
  595. }
  596. };
  597. // checks whether recording is enabled and whether we have params
  598. // to start automatically recording
  599. my.checkAutoRecord = function () {
  600. if (UIUtil.isButtonEnabled('recording') && config.autoRecord) {
  601. toggleRecording(config.autoRecordToken);
  602. }
  603. };
  604. // checks whether desktop sharing is enabled and whether
  605. // we have params to start automatically sharing
  606. my.checkAutoEnableDesktopSharing = function () {
  607. if (UIUtil.isButtonEnabled('desktop')
  608. && config.autoEnableDesktopSharing) {
  609. APP.desktopsharing.toggleScreenSharing();
  610. }
  611. };
  612. // Shows or hides SIP calls button
  613. my.showSipCallButton = function (show) {
  614. if (APP.xmpp.isSipGatewayEnabled() && UIUtil.isButtonEnabled('sip') && show) {
  615. $('#toolbar_button_sip').css({display: "inline-block"});
  616. } else {
  617. $('#toolbar_button_sip').css({display: "none"});
  618. }
  619. };
  620. // Shows or hides the dialpad button
  621. my.showDialPadButton = function (show) {
  622. if (UIUtil.isButtonEnabled('dialpad') && show) {
  623. $('#toolbar_button_dialpad').css({display: "inline-block"});
  624. } else {
  625. $('#toolbar_button_dialpad').css({display: "none"});
  626. }
  627. };
  628. /**
  629. * Displays user authenticated identity name(login).
  630. * @param authIdentity identity name to be displayed.
  631. */
  632. my.setAuthenticatedIdentity = function (authIdentity) {
  633. if (authIdentity) {
  634. var selector = $('#toolbar_auth_identity');
  635. selector.css({display: "list-item"});
  636. selector.text(authIdentity);
  637. } else {
  638. $('#toolbar_auth_identity').css({display: "none"});
  639. }
  640. };
  641. /**
  642. * Shows/hides login button.
  643. * @param show <tt>true</tt> to show
  644. */
  645. my.showLoginButton = function (show) {
  646. if (UIUtil.isButtonEnabled('authentication') && show) {
  647. $('#toolbar_button_login').css({display: "list-item"});
  648. } else {
  649. $('#toolbar_button_login').css({display: "none"});
  650. }
  651. };
  652. /**
  653. * Shows/hides logout button.
  654. * @param show <tt>true</tt> to show
  655. */
  656. my.showLogoutButton = function (show) {
  657. if (UIUtil.isButtonEnabled('authentication') && show) {
  658. $('#toolbar_button_logout').css({display: "list-item"});
  659. } else {
  660. $('#toolbar_button_logout').css({display: "none"});
  661. }
  662. };
  663. /**
  664. * Sets the state of the button. The button has blue glow if desktop
  665. * streaming is active.
  666. * @param active the state of the desktop streaming.
  667. */
  668. my.changeDesktopSharingButtonState = function (active) {
  669. var button = $("#toolbar_button_desktopsharing");
  670. if (active) {
  671. button.addClass("glow");
  672. } else {
  673. button.removeClass("glow");
  674. }
  675. };
  676. return my;
  677. }(Toolbar || {}));
  678. module.exports = Toolbar;