Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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