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.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. 67: {
  7. character: "C",
  8. id: "toggleChatPopover",
  9. function: APP.UI.toggleChat
  10. },
  11. 68: {
  12. character: "D",
  13. id: "toggleDesktopSharingPopover",
  14. function: APP.desktopsharing.toggleScreenSharing
  15. },
  16. 70: {
  17. character: "F",
  18. id: "filmstripPopover",
  19. function: APP.UI.toggleFilmStrip
  20. },
  21. 77: {
  22. character: "M",
  23. id: "mutePopover",
  24. function: APP.conference.toggleAudioMuted
  25. },
  26. 84: {
  27. character: "T",
  28. function: function() {
  29. APP.conference.muteAudio(true);
  30. }
  31. },
  32. 86: {
  33. character: "V",
  34. id: "toggleVideoPopover",
  35. function: APP.conference.toggleVideoMuted
  36. }
  37. };
  38. }
  39. var KeyboardShortcut = {
  40. init: function () {
  41. initShortcutHandlers();
  42. window.onkeyup = function(e) {
  43. var keycode = e.which;
  44. if(!($(":focus").is("input[type=text]") ||
  45. $(":focus").is("input[type=password]") ||
  46. $(":focus").is("textarea"))) {
  47. if (typeof shortcuts[keycode] === "object") {
  48. shortcuts[keycode].function();
  49. }
  50. else if (keycode >= "0".charCodeAt(0) &&
  51. keycode <= "9".charCodeAt(0)) {
  52. APP.UI.clickOnVideo(keycode - "0".charCodeAt(0) + 1);
  53. }
  54. //esc while the smileys are visible hides them
  55. } else if (keycode === 27 &&
  56. $('#smileysContainer').is(':visible')) {
  57. APP.UI.toggleSmileys();
  58. }
  59. };
  60. window.onkeydown = function(e) {
  61. if(!($(":focus").is("input[type=text]") ||
  62. $(":focus").is("input[type=password]") ||
  63. $(":focus").is("textarea"))) {
  64. if(e.which === "T".charCodeAt(0)) {
  65. APP.conference.muteAudio(true);
  66. }
  67. }
  68. };
  69. var self = this;
  70. $('body').popover({ selector: '[data-toggle=popover]',
  71. trigger: 'click hover',
  72. content: function() {
  73. return this.getAttribute("content") +
  74. self.getShortcut(this.getAttribute("shortcut"));
  75. }
  76. });
  77. },
  78. /**
  79. *
  80. * @param id indicates the popover associated with the shortcut
  81. * @returns {string} the keyboard shortcut used for the id given
  82. */
  83. getShortcut: function (id) {
  84. for (var keycode in shortcuts) {
  85. if (shortcuts.hasOwnProperty(keycode)) {
  86. if (shortcuts[keycode].id === id) {
  87. return " (" + shortcuts[keycode].character + ")";
  88. }
  89. }
  90. }
  91. return "";
  92. }
  93. };
  94. module.exports = KeyboardShortcut;