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 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. var Toolbar = (function (my) {
  2. var INITIAL_TOOLBAR_TIMEOUT = 20000;
  3. var TOOLBAR_TIMEOUT = INITIAL_TOOLBAR_TIMEOUT;
  4. /**
  5. * Opens the lock room dialog.
  6. */
  7. my.openLockDialog = function () {
  8. // Only the focus is able to set a shared key.
  9. if (focus === null) {
  10. if (sharedKey)
  11. $.prompt("This conversation is currently protected by"
  12. + " a shared secret key.",
  13. {
  14. title: "Secrect key",
  15. persistent: false
  16. }
  17. );
  18. else
  19. $.prompt("This conversation isn't currently protected by"
  20. + " a secret key. Only the owner of the conference" +
  21. + " could set a shared key.",
  22. {
  23. title: "Secrect key",
  24. persistent: false
  25. }
  26. );
  27. } else {
  28. if (sharedKey) {
  29. $.prompt("Are you sure you would like to remove your secret key?",
  30. {
  31. title: "Remove secret key",
  32. persistent: false,
  33. buttons: { "Remove": true, "Cancel": false},
  34. defaultButton: 1,
  35. submit: function (e, v, m, f) {
  36. if (v) {
  37. setSharedKey('');
  38. lockRoom(false);
  39. }
  40. }
  41. }
  42. );
  43. } else {
  44. $.prompt('<h2>Set a secret key to lock your room</h2>' +
  45. '<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
  46. {
  47. persistent: false,
  48. buttons: { "Save": true, "Cancel": false},
  49. defaultButton: 1,
  50. loaded: function (event) {
  51. document.getElementById('lockKey').focus();
  52. },
  53. submit: function (e, v, m, f) {
  54. if (v) {
  55. var lockKey = document.getElementById('lockKey');
  56. if (lockKey.value) {
  57. setSharedKey(Util.escapeHtml(lockKey.value));
  58. lockRoom(true);
  59. }
  60. }
  61. }
  62. }
  63. );
  64. }
  65. }
  66. };
  67. /**
  68. * Opens the invite link dialog.
  69. */
  70. my.openLinkDialog = function () {
  71. var inviteLink;
  72. if (roomUrl == null)
  73. inviteLink = "Your conference is currently being created...";
  74. else
  75. inviteLink = encodeURI(roomUrl);
  76. $.prompt('<input id="inviteLinkRef" type="text" value="' +
  77. inviteLink + '" onclick="this.select();" readonly>',
  78. {
  79. title: "Share this link with everyone you want to invite",
  80. persistent: false,
  81. buttons: { "Invite": true, "Cancel": false},
  82. defaultButton: 1,
  83. loaded: function (event) {
  84. if (roomUrl)
  85. document.getElementById('inviteLinkRef').select();
  86. else
  87. document.getElementById('jqi_state0_buttonInvite')
  88. .disabled = true;
  89. },
  90. submit: function (e, v, m, f) {
  91. if (v) {
  92. if (roomUrl) {
  93. inviteParticipants();
  94. }
  95. }
  96. }
  97. }
  98. );
  99. };
  100. /**
  101. * Invite participants to conference.
  102. */
  103. function inviteParticipants() {
  104. if (roomUrl == null)
  105. return;
  106. var sharedKeyText = "";
  107. if (sharedKey && sharedKey.length > 0)
  108. sharedKeyText
  109. = "This conference is password protected. Please use the "
  110. + "following pin when joining:%0D%0A%0D%0A"
  111. + sharedKey + "%0D%0A%0D%0A";
  112. var conferenceName = roomUrl.substring(roomUrl.lastIndexOf('/') + 1);
  113. var subject = "Invitation to a Jitsi Meet (" + conferenceName + ")";
  114. var body = "Hey there, I%27d like to invite you to a Jitsi Meet"
  115. + " conference I%27ve just set up.%0D%0A%0D%0A"
  116. + "Please click on the following link in order"
  117. + " to join the conference.%0D%0A%0D%0A"
  118. + roomUrl + "%0D%0A%0D%0A"
  119. + sharedKeyText
  120. + "Note that Jitsi Meet is currently only supported by Chromim,"
  121. + " Google Chrome and Opera, so you need"
  122. + " to be using one of these browsers.%0D%0A%0D%0A"
  123. + "Talk to you in a sec!";
  124. if (window.localStorage.displayname)
  125. body += "%0D%0A%0D%0A" + window.localStorage.displayname;
  126. window.open("mailto:?subject=" + subject + "&body=" + body, '_blank');
  127. }
  128. /**
  129. * Opens the settings dialog.
  130. */
  131. my.openSettingsDialog = function () {
  132. $.prompt('<h2>Configure your conference</h2>' +
  133. '<input type="checkbox" id="initMuted"> Participants join muted<br/>' +
  134. '<input type="checkbox" id="requireNicknames"> Require nicknames<br/><br/>' +
  135. 'Set a secret key to lock your room: <input id="lockKey" type="text" placeholder="your shared key" autofocus>',
  136. {
  137. persistent: false,
  138. buttons: { "Save": true, "Cancel": false},
  139. defaultButton: 1,
  140. loaded: function (event) {
  141. document.getElementById('lockKey').focus();
  142. },
  143. submit: function (e, v, m, f) {
  144. if (v) {
  145. if ($('#initMuted').is(":checked")) {
  146. // it is checked
  147. }
  148. if ($('#requireNicknames').is(":checked")) {
  149. // it is checked
  150. }
  151. /*
  152. var lockKey = document.getElementById('lockKey');
  153. if (lockKey.value)
  154. {
  155. setSharedKey(lockKey.value);
  156. lockRoom(true);
  157. }
  158. */
  159. }
  160. }
  161. }
  162. );
  163. };
  164. /**
  165. * Toggles the application in and out of full screen mode
  166. * (a.k.a. presentation mode in Chrome).
  167. */
  168. my.toggleFullScreen = function() {
  169. var fsElement = document.documentElement;
  170. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  171. //Enter Full Screen
  172. if (fsElement.mozRequestFullScreen) {
  173. fsElement.mozRequestFullScreen();
  174. }
  175. else {
  176. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  177. }
  178. } else {
  179. //Exit Full Screen
  180. if (document.mozCancelFullScreen) {
  181. document.mozCancelFullScreen();
  182. } else {
  183. document.webkitCancelFullScreen();
  184. }
  185. }
  186. };
  187. /**
  188. * Shows the main toolbar.
  189. */
  190. my.showToolbar = function() {
  191. if (!$('#header').is(':visible')) {
  192. $('#header').show("slide", { direction: "up", duration: 300});
  193. $('#subject').animate({top: "+=40"}, 300);
  194. if (toolbarTimeout) {
  195. clearTimeout(toolbarTimeout);
  196. toolbarTimeout = null;
  197. }
  198. toolbarTimeout = setTimeout(hideToolbar, TOOLBAR_TIMEOUT);
  199. TOOLBAR_TIMEOUT = 4000;
  200. }
  201. if (focus != null)
  202. {
  203. // TODO: Enable settings functionality. Need to uncomment the settings button in index.html.
  204. // $('#settingsButton').css({visibility:"visible"});
  205. }
  206. // Show/hide desktop sharing button
  207. showDesktopSharingButton();
  208. };
  209. /**
  210. * Docks/undocks the toolbar.
  211. *
  212. * @param isDock indicates what operation to perform
  213. */
  214. my.dockToolbar = function(isDock) {
  215. if (isDock) {
  216. // First make sure the toolbar is shown.
  217. if (!$('#header').is(':visible')) {
  218. Toolbar.showToolbar();
  219. }
  220. // Then clear the time out, to dock the toolbar.
  221. if (toolbarTimeout) {
  222. clearTimeout(toolbarTimeout);
  223. toolbarTimeout = null;
  224. }
  225. }
  226. else {
  227. if (!$('#header').is(':visible')) {
  228. Toolbar.showToolbar();
  229. }
  230. else {
  231. toolbarTimeout = setTimeout(hideToolbar, TOOLBAR_TIMEOUT);
  232. }
  233. }
  234. };
  235. /**
  236. * Updates the lock button state.
  237. */
  238. my.updateLockButton = function() {
  239. buttonClick("#lockIcon", "icon-security icon-security-locked");
  240. };
  241. /**
  242. * Hides the toolbar.
  243. */
  244. var hideToolbar = function () {
  245. var isToolbarHover = false;
  246. $('#header').find('*').each(function () {
  247. var id = $(this).attr('id');
  248. if ($("#" + id + ":hover").length > 0) {
  249. isToolbarHover = true;
  250. }
  251. });
  252. clearTimeout(toolbarTimeout);
  253. toolbarTimeout = null;
  254. if (!isToolbarHover) {
  255. $('#header').hide("slide", { direction: "up", duration: 300});
  256. $('#subject').animate({top: "-=40"}, 300);
  257. }
  258. else {
  259. toolbarTimeout = setTimeout(hideToolbar, TOOLBAR_TIMEOUT);
  260. }
  261. };
  262. // Shows or hides the 'recording' button.
  263. my.showRecordingButton = function (show) {
  264. if (!config.enableRecording) {
  265. return;
  266. }
  267. if (show) {
  268. $('#recording').css({display: "inline"});
  269. }
  270. else {
  271. $('#recording').css({display: "none"});
  272. }
  273. };
  274. // Toggle the state of the recording button
  275. my.toggleRecordingButtonState = function() {
  276. $('#recordButton').toggleClass('active');
  277. };
  278. return my;
  279. }(Toolbar || {}));