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.

keyboardshortcut.bundle.js 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.keyboardshortcut=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. //maps keycode to character, id of popover for given function and function
  3. var shortcuts = {
  4. 67: {
  5. character: "C",
  6. id: "toggleChatPopover",
  7. function: UI.toggleChat
  8. },
  9. 70: {
  10. character: "F",
  11. id: "filmstripPopover",
  12. function: UI.toggleFilmStrip
  13. },
  14. 77: {
  15. character: "M",
  16. id: "mutePopover",
  17. function: UI.toggleAudio
  18. },
  19. 84: {
  20. character: "T",
  21. function: function() {
  22. if(!RTC.localAudio.isMuted()) {
  23. UI.toggleAudio();
  24. }
  25. }
  26. },
  27. 86: {
  28. character: "V",
  29. id: "toggleVideoPopover",
  30. function: UI.toggleVideo
  31. }
  32. };
  33. var KeyboardShortcut = {
  34. init: function () {
  35. window.onkeyup = function(e) {
  36. var keycode = e.which;
  37. if(!($(":focus").is("input[type=text]") ||
  38. $(":focus").is("input[type=password]") ||
  39. $(":focus").is("textarea"))) {
  40. if (typeof shortcuts[keycode] === "object") {
  41. shortcuts[keycode].function();
  42. }
  43. else if (keycode >= "0".charCodeAt(0) &&
  44. keycode <= "9".charCodeAt(0)) {
  45. UI.clickOnVideo(keycode - "0".charCodeAt(0) + 1);
  46. }
  47. //esc while the smileys are visible hides them
  48. } else if (keycode === 27 && $('#smileysContainer').is(':visible')) {
  49. UI.toggleSmileys();
  50. }
  51. };
  52. window.onkeydown = function(e) {
  53. if(!($(":focus").is("input[type=text]") ||
  54. $(":focus").is("input[type=password]") ||
  55. $(":focus").is("textarea"))) {
  56. if(e.which === "T".charCodeAt(0)) {
  57. if(RTC.localAudio.isMuted()) {
  58. UI.toggleAudio();
  59. }
  60. }
  61. }
  62. };
  63. var self = this;
  64. $('body').popover({ selector: '[data-toggle=popover]',
  65. trigger: 'click hover',
  66. content: function() {
  67. return this.getAttribute("content") +
  68. self.getShortcut(this.getAttribute("shortcut"));
  69. }
  70. });
  71. },
  72. /**
  73. *
  74. * @param id indicates the popover associated with the shortcut
  75. * @returns {string} the keyboard shortcut used for the id given
  76. */
  77. getShortcut: function (id) {
  78. for (var keycode in shortcuts) {
  79. if (shortcuts.hasOwnProperty(keycode)) {
  80. if (shortcuts[keycode].id === id) {
  81. return " (" + shortcuts[keycode].character + ")";
  82. }
  83. }
  84. }
  85. return "";
  86. }
  87. };
  88. module.exports = KeyboardShortcut;
  89. },{}]},{},[1])(1)
  90. });