Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

keyboardshortcut.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* global APP, $ */
  2. //maps keycode to character, id of popover for given function and function
  3. var shortcuts = {};
  4. function initShortcutHandlers() {
  5. shortcuts = {
  6. 191: {
  7. character: "/",
  8. function: function(e) {
  9. // Only trigger on "?", not on "/".
  10. if (e.shiftKey) {
  11. APP.UI.toggleKeyboardShortcutsPanel();
  12. }
  13. }
  14. },
  15. 67: {
  16. character: "C",
  17. id: "toggleChatPopover",
  18. function: function() {
  19. APP.UI.toggleChat();
  20. }
  21. },
  22. 68: {
  23. character: "D",
  24. id: "toggleDesktopSharingPopover",
  25. function: function () {
  26. APP.conference.toggleScreenSharing();
  27. }
  28. },
  29. 70: {
  30. character: "F",
  31. id: "filmstripPopover",
  32. function: function() {
  33. APP.UI.toggleFilmStrip();
  34. }
  35. },
  36. 77: {
  37. character: "M",
  38. id: "mutePopover",
  39. function: function() {
  40. APP.conference.toggleAudioMuted();
  41. }
  42. },
  43. 82: {
  44. character: "R",
  45. function: function() {
  46. APP.conference.maybeToggleRaisedHand();
  47. }
  48. },
  49. 84: {
  50. character: "T",
  51. function: function() {
  52. APP.conference.muteAudio(true);
  53. }
  54. },
  55. 86: {
  56. character: "V",
  57. id: "toggleVideoPopover",
  58. function: function() {
  59. APP.conference.toggleVideoMuted();
  60. }
  61. }
  62. };
  63. }
  64. var KeyboardShortcut = {
  65. init: function () {
  66. initShortcutHandlers();
  67. window.onkeyup = function(e) {
  68. var keycode = e.which;
  69. if(!($(":focus").is("input[type=text]") ||
  70. $(":focus").is("input[type=password]") ||
  71. $(":focus").is("textarea"))) {
  72. if (typeof shortcuts[keycode] === "object") {
  73. shortcuts[keycode].function(e);
  74. }
  75. else if (keycode >= "0".charCodeAt(0) &&
  76. keycode <= "9".charCodeAt(0)) {
  77. APP.UI.clickOnVideo(keycode - "0".charCodeAt(0) + 1);
  78. }
  79. //esc while the smileys are visible hides them
  80. } else if (keycode === 27 &&
  81. $('#smileysContainer').is(':visible')) {
  82. APP.UI.toggleSmileys();
  83. }
  84. };
  85. window.onkeydown = function(e) {
  86. if(!($(":focus").is("input[type=text]") ||
  87. $(":focus").is("input[type=password]") ||
  88. $(":focus").is("textarea"))) {
  89. if(e.which === "T".charCodeAt(0)) {
  90. if(APP.conference.isLocalAudioMuted())
  91. APP.conference.muteAudio(false);
  92. }
  93. }
  94. };
  95. var self = this;
  96. $('body').popover({ selector: '[data-toggle=popover]',
  97. trigger: 'click hover',
  98. content: function() {
  99. return this.getAttribute("content") +
  100. self.getShortcut(this.getAttribute("shortcut"));
  101. }
  102. });
  103. },
  104. /**
  105. *
  106. * @param id indicates the popover associated with the shortcut
  107. * @returns {string} the keyboard shortcut used for the id given
  108. */
  109. getShortcut: function (id) {
  110. for (var keycode in shortcuts) {
  111. if (shortcuts.hasOwnProperty(keycode)) {
  112. if (shortcuts[keycode].id === id) {
  113. return " (" + shortcuts[keycode].character + ")";
  114. }
  115. }
  116. }
  117. return "";
  118. }
  119. };
  120. module.exports = KeyboardShortcut;