Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Toolbar.js 24KB

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