Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

keyboardshortcut.js 3.2KB

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