diff --git a/app.js b/app.js index f3ab204e4..e0ab84592 100644 --- a/app.js +++ b/app.js @@ -836,6 +836,7 @@ function getConferenceHandler() { } function toggleVideo() { + buttonClick("#video", "icon-camera icon-camera-disabled"); if (!(connection && connection.jingle.localVideo)) return; @@ -1099,7 +1100,12 @@ $(document).ready(function () { Chat.init(); $('body').popover({ selector: '[data-toggle=popover]', - trigger: 'click hover'}); + trigger: 'click hover', + content: function() { + return this.getAttribute("content") + + KeyboardShortcut.getShortcut(this.getAttribute("shortcut")); + } + }); // Set the defaults for prompt dialogs. jQuery.prompt.setDefaults({persistent: false}); diff --git a/index.html b/index.html index 015ef7fe9..738983ed1 100644 --- a/index.html +++ b/index.html @@ -50,6 +50,7 @@ + @@ -156,62 +157,62 @@
- + - + - + diff --git a/keyboard_shortcut.js b/keyboard_shortcut.js new file mode 100644 index 000000000..aac145c8f --- /dev/null +++ b/keyboard_shortcut.js @@ -0,0 +1,73 @@ +var KeyboardShortcut = (function(my) { + var shortcuts = { + 67: { + character: "C", + id: "toggleChatPopover", + function: BottomToolbar.toggleChat + }, + 70: { + character: "F", + id: "filmstripPopover", + function: BottomToolbar.toggleFilmStrip + }, + 77: { + character: "M", + id: "mutePopover", + function: toggleAudio + }, + 84: { + character: "T", + function: function() { + if(!isAudioMuted()) { + toggleAudio(); + } + } + }, + 86: { + character: "V", + id: "toggleVideoPopover", + function: toggleVideo + } + }; + + window.onkeyup = function(e) { + if($("#chatspace").css("display") === "none") { + var keycode = e.which; + if (typeof shortcuts[keycode] === "object") { + shortcuts[keycode].function(); + } else if (keycode >= 49 && keycode <= 57) { + var remoteVideos = $(".videocontainer:not(#mixedstream)"), + videoWanted = keycode - 48; + if (remoteVideos.length > videoWanted) { + remoteVideos[videoWanted].click(); + } + } + } + }; + + window.onkeydown = function(e) { + if($("#chatspace").css("display") === "none") { + if(e.which === 84) { + if(isAudioMuted()) { + toggleAudio(); + } + } + } + }; + /** + * + * @param id indicates the popover associated with the shortcut + * @returns {string} the keyboard shortcut used for the id given + */ + my.getShortcut = function(id) { + for(var keycode in shortcuts) { + if(shortcuts.hasOwnProperty(keycode)) { + if (shortcuts[keycode].id === id) { + return " (" + shortcuts[keycode].character + ")"; + } + } + } + return ""; + }; + return my; +}(KeyboardShortcut || {}));