summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorErik Sargent <esthepiking@gmail.com>2012-11-28 10:22:20 -0700
committerErik Sargent <esthepiking@gmail.com>2012-11-28 10:22:20 -0700
commitb78dc3f48acd17f3bd2557362a40e367ef28fb6b (patch)
treecd525345a2a16ebbd4f85b44e268b29e800ae264 /apps/files/js
parent0c6b53c25e29ff05f843ab1d62228411ba6a777c (diff)
downloadnextcloud-server-b78dc3f48acd17f3bd2557362a40e367ef28fb6b.tar.gz
nextcloud-server-b78dc3f48acd17f3bd2557362a40e367ef28fb6b.zip
keycode naming
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/keyboardshortcuts.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js
index e53f44f3bf0..eecf30bd10b 100644
--- a/apps/files/js/keyboardshortcuts.js
+++ b/apps/files/js/keyboardshortcuts.js
@@ -9,14 +9,23 @@ Array.prototype.remove = function(from, to) {
};
Files.bindKeyboardShortcuts = function (document, $){
- var keys = []
+ var keys = [];
+ keyCodes = {
+ shift: 16,
+ n: 78,
+ cmdFirefox: 224,
+ cmdOpera: 17,
+ leftCmdWebKit: 91,
+ rightCmdWebKit: 93,
+ esc: 27
+ };
$(document).keydown(function(event){//check for modifier keys
if($.inArray(event.keyCode, keys) == -1)
keys.push(event.keyCode);
console.log(event.keyCode);
- if($.inArray(78, keys) !== -1 && ($.inArray(224, keys) !== -1 || $.inArray(17, keys) !== -1 || $.inArray(91, keys) !== -1 || $.inArray(93, keys) !== -1)){ //78=n, 224=cmd(firefox), 17=cmd(Opera), 91=leftCmd(WebKit), 93=rightCmd(WebKit)
+ if($.inArray(keyCodes.n, keys) !== -1 && ($.inArray(keyCodes.cmdFirefox, keys) !== -1 || $.inArray(keyCodes.cmdOpera, keys) !== -1 || $.inArray(keyCodes.leftCmdWebKit, keys) !== -1 || $.inArray(keyCodes.rightCmdWebKit, keys) !== -1)){
event.preventDefault(); //Prevent web browser from responding
}
});
@@ -26,27 +35,27 @@ Files.bindKeyboardShortcuts = function (document, $){
console.log(JSON.stringify(keys));
- if($.inArray(78, keys) !== -1 && ($.inArray(224, keys) !== -1 || $.inArray(17, keys) !== -1 || $.inArray(91, keys) !== -1 || $.inArray(93, keys) !== -1)){ //78=n, 224=cmd(firefox), 17=cmd(Opera), 91=leftCmd(WebKit), 93=rightCmd(WebKit)
- if($.inArray(16, keys) !== -1){ //16=shift, New File
+ if($.inArray(keyCodes.n, keys) !== -1 && ($.inArray(keyCodes.cmdFirefox, keys) !== -1 || $.inArray(keyCodes.cmdOpera, keys) !== -1 || $.inArray(keyCodes.leftCmdWebKit, keys) !== -1 || $.inArray(keyCodes.rightCmdWebKit, keys) !== -1)){
+ if($.inArray(keyCodes.shift, keys) !== -1){ //16=shift, New File
$("#new").addClass("active");
$(".popup.popupTop").toggle(true);
$('#new li[data-type="file"]').trigger('click');
console.log("new file");
- keys.remove($.inArray(78, keys));
+ keys.remove($.inArray(keyCodes.n, keys));
}
else{ //New Folder
$("#new").addClass("active");
$(".popup.popupTop").toggle(true);
$('#new li[data-type="folder"]').trigger('click');
console.log("new folder");
- keys.remove($.inArray(78, keys));
+ keys.remove($.inArray(keyCodes.n, keys));
}
}
- if($("#new").hasClass("active") && $.inArray(27, keys) !== -1){
+ if($("#new").hasClass("active") && $.inArray(keyCodes.esc, keys) !== -1){
$("#controls").trigger('click');
console.log("close");
}
keys.remove($.inArray(event.keyCode, keys));
});
-}; \ No newline at end of file
+}; \ No newline at end of file