2015-07-28 18:22:11 +00:00
|
|
|
/* global APP, $ */
|
2015-01-22 16:26:05 +00:00
|
|
|
//maps keycode to character, id of popover for given function and function
|
2015-07-02 21:33:06 +00:00
|
|
|
var shortcuts = {};
|
|
|
|
function initShortcutHandlers() {
|
|
|
|
shortcuts = {
|
|
|
|
67: {
|
|
|
|
character: "C",
|
|
|
|
id: "toggleChatPopover",
|
2016-02-05 18:53:31 +00:00
|
|
|
function: function() {
|
|
|
|
APP.UI.toggleChat();
|
|
|
|
}
|
2015-07-02 21:33:06 +00:00
|
|
|
},
|
2015-11-12 22:56:35 +00:00
|
|
|
68: {
|
|
|
|
character: "D",
|
|
|
|
id: "toggleDesktopSharingPopover",
|
2016-02-04 15:25:11 +00:00
|
|
|
function: function () {
|
|
|
|
APP.conference.toggleScreenSharing();
|
2016-02-05 18:53:31 +00:00
|
|
|
}
|
2015-11-12 22:56:35 +00:00
|
|
|
},
|
2015-07-02 21:33:06 +00:00
|
|
|
70: {
|
|
|
|
character: "F",
|
|
|
|
id: "filmstripPopover",
|
2016-02-05 18:53:31 +00:00
|
|
|
function: function() {
|
|
|
|
APP.UI.toggleFilmStrip();
|
|
|
|
}
|
2015-07-02 21:33:06 +00:00
|
|
|
},
|
|
|
|
77: {
|
|
|
|
character: "M",
|
|
|
|
id: "mutePopover",
|
2016-02-05 18:53:31 +00:00
|
|
|
function: function() {
|
|
|
|
APP.conference.toggleAudioMuted();
|
|
|
|
}
|
2015-07-02 21:33:06 +00:00
|
|
|
},
|
|
|
|
84: {
|
|
|
|
character: "T",
|
|
|
|
function: function() {
|
2015-12-03 13:11:01 +00:00
|
|
|
APP.conference.muteAudio(true);
|
2015-01-22 16:26:05 +00:00
|
|
|
}
|
2015-07-02 21:33:06 +00:00
|
|
|
},
|
|
|
|
86: {
|
|
|
|
character: "V",
|
|
|
|
id: "toggleVideoPopover",
|
2016-02-05 18:53:31 +00:00
|
|
|
function: function() {
|
|
|
|
APP.conference.toggleVideoMuted();
|
|
|
|
}
|
2015-01-22 16:26:05 +00:00
|
|
|
}
|
2015-07-02 21:33:06 +00:00
|
|
|
};
|
|
|
|
}
|
2015-01-22 16:26:05 +00:00
|
|
|
|
|
|
|
var KeyboardShortcut = {
|
|
|
|
init: function () {
|
2015-07-02 21:33:06 +00:00
|
|
|
initShortcutHandlers();
|
2015-01-22 16:26:05 +00:00
|
|
|
window.onkeyup = function(e) {
|
|
|
|
var keycode = e.which;
|
|
|
|
if(!($(":focus").is("input[type=text]") ||
|
|
|
|
$(":focus").is("input[type=password]") ||
|
|
|
|
$(":focus").is("textarea"))) {
|
|
|
|
if (typeof shortcuts[keycode] === "object") {
|
|
|
|
shortcuts[keycode].function();
|
|
|
|
}
|
|
|
|
else if (keycode >= "0".charCodeAt(0) &&
|
|
|
|
keycode <= "9".charCodeAt(0)) {
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.UI.clickOnVideo(keycode - "0".charCodeAt(0) + 1);
|
2015-01-22 16:26:05 +00:00
|
|
|
}
|
|
|
|
//esc while the smileys are visible hides them
|
2015-09-11 02:42:15 +00:00
|
|
|
} else if (keycode === 27 &&
|
|
|
|
$('#smileysContainer').is(':visible')) {
|
2015-01-28 14:35:22 +00:00
|
|
|
APP.UI.toggleSmileys();
|
2015-01-22 16:26:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.onkeydown = function(e) {
|
|
|
|
if(!($(":focus").is("input[type=text]") ||
|
|
|
|
$(":focus").is("input[type=password]") ||
|
|
|
|
$(":focus").is("textarea"))) {
|
|
|
|
if(e.which === "T".charCodeAt(0)) {
|
2016-02-09 16:29:50 +00:00
|
|
|
if(APP.conference.isLocalAudioMuted())
|
|
|
|
APP.conference.muteAudio(false);
|
2015-01-22 16:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-01-24 14:28:02 +00:00
|
|
|
var self = this;
|
|
|
|
$('body').popover({ selector: '[data-toggle=popover]',
|
|
|
|
trigger: 'click hover',
|
|
|
|
content: function() {
|
|
|
|
return this.getAttribute("content") +
|
|
|
|
self.getShortcut(this.getAttribute("shortcut"));
|
|
|
|
}
|
|
|
|
});
|
2015-01-22 16:26:05 +00:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param id indicates the popover associated with the shortcut
|
|
|
|
* @returns {string} the keyboard shortcut used for the id given
|
|
|
|
*/
|
|
|
|
getShortcut: function (id) {
|
|
|
|
for (var keycode in shortcuts) {
|
|
|
|
if (shortcuts.hasOwnProperty(keycode)) {
|
|
|
|
if (shortcuts[keycode].id === id) {
|
|
|
|
return " (" + shortcuts[keycode].character + ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = KeyboardShortcut;
|