You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Toolbar.js 24KB

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