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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 secrect 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 secrect 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. $.prompt('<input id="inviteLinkRef" type="text" value="' +
  72. encodeURI(roomUrl) + '" onclick="this.select();" readonly>',
  73. {
  74. title: "Share this link with everyone you want to invite",
  75. persistent: false,
  76. buttons: { "Cancel": false},
  77. loaded: function (event) {
  78. document.getElementById('inviteLinkRef').select();
  79. }
  80. }
  81. );
  82. };
  83. /**
  84. * Opens the settings dialog.
  85. */
  86. my.openSettingsDialog = function() {
  87. $.prompt('<h2>Configure your conference</h2>' +
  88. '<input type="checkbox" id="initMuted"> Participants join muted<br/>' +
  89. '<input type="checkbox" id="requireNicknames"> Require nicknames<br/><br/>' +
  90. 'Set a secrect key to lock your room: <input id="lockKey" type="text" placeholder="your shared key" autofocus>',
  91. {
  92. persistent: false,
  93. buttons: { "Save": true, "Cancel": false},
  94. defaultButton: 1,
  95. loaded: function (event) {
  96. document.getElementById('lockKey').focus();
  97. },
  98. submit: function (e, v, m, f) {
  99. if (v) {
  100. if ($('#initMuted').is(":checked")) {
  101. // it is checked
  102. }
  103. if ($('#requireNicknames').is(":checked")) {
  104. // it is checked
  105. }
  106. /*
  107. var lockKey = document.getElementById('lockKey');
  108. if (lockKey.value)
  109. {
  110. setSharedKey(lockKey.value);
  111. lockRoom(true);
  112. }
  113. */
  114. }
  115. }
  116. }
  117. );
  118. };
  119. /**
  120. * Toggles the application in and out of full screen mode
  121. * (a.k.a. presentation mode in Chrome).
  122. */
  123. my.toggleFullScreen = function() {
  124. var fsElement = document.documentElement;
  125. if (!document.mozFullScreen && !document.webkitIsFullScreen) {
  126. //Enter Full Screen
  127. if (fsElement.mozRequestFullScreen) {
  128. fsElement.mozRequestFullScreen();
  129. }
  130. else {
  131. fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  132. }
  133. } else {
  134. //Exit Full Screen
  135. if (document.mozCancelFullScreen) {
  136. document.mozCancelFullScreen();
  137. } else {
  138. document.webkitCancelFullScreen();
  139. }
  140. }
  141. };
  142. /**
  143. * Shows the main toolbar.
  144. */
  145. my.showToolbar = function() {
  146. if (!$('#header').is(':visible')) {
  147. $('#header').show("slide", { direction: "up", duration: 300});
  148. if (toolbarTimeout) {
  149. clearTimeout(toolbarTimeout);
  150. toolbarTimeout = null;
  151. }
  152. toolbarTimeout = setTimeout(hideToolbar, TOOLBAR_TIMEOUT);
  153. TOOLBAR_TIMEOUT = 4000;
  154. }
  155. if (focus != null)
  156. {
  157. // TODO: Enable settings functionality. Need to uncomment the settings button in index.html.
  158. // $('#settingsButton').css({visibility:"visible"});
  159. }
  160. // Show/hide desktop sharing button
  161. showDesktopSharingButton();
  162. };
  163. /**
  164. * Docks/undocks the toolbar.
  165. *
  166. * @param isDock indicates what operation to perform
  167. */
  168. my.dockToolbar = function(isDock) {
  169. if (isDock) {
  170. // First make sure the toolbar is shown.
  171. if (!$('#header').is(':visible')) {
  172. Toolbar.showToolbar();
  173. }
  174. // Then clear the time out, to dock the toolbar.
  175. clearTimeout(toolbarTimeout);
  176. toolbarTimeout = null;
  177. }
  178. else {
  179. if (!$('#header').is(':visible')) {
  180. Toolbar.showToolbar();
  181. }
  182. else {
  183. toolbarTimeout = setTimeout(hideToolbar, TOOLBAR_TIMEOUT);
  184. }
  185. }
  186. };
  187. /**
  188. * Updates the lock button state.
  189. */
  190. my.updateLockButton = function() {
  191. buttonClick("#lockIcon", "icon-security icon-security-locked");
  192. };
  193. /**
  194. * Hides the toolbar.
  195. */
  196. var hideToolbar = function () {
  197. var isToolbarHover = false;
  198. $('#header').find('*').each(function () {
  199. var id = $(this).attr('id');
  200. if ($("#" + id + ":hover").length > 0) {
  201. isToolbarHover = true;
  202. }
  203. });
  204. clearTimeout(toolbarTimeout);
  205. toolbarTimeout = null;
  206. if (!isToolbarHover) {
  207. $('#header').hide("slide", { direction: "up", duration: 300});
  208. }
  209. else {
  210. toolbarTimeout = setTimeout(hideToolbar, TOOLBAR_TIMEOUT);
  211. }
  212. };
  213. return my;
  214. }(Toolbar || {}));