diff options
author | Erik Sargent <esthepiking@gmail.com> | 2012-11-28 21:00:11 -0700 |
---|---|---|
committer | Erik Sargent <esthepiking@gmail.com> | 2012-11-28 21:00:11 -0700 |
commit | dafe028c111a66b622eb920a7ed5f5e3e3d5abdf (patch) | |
tree | 2a796187dac4d56c36636d7c1ef41f4249501030 /apps | |
parent | a73a263543c9b28264288f6c6600a35619b9bb17 (diff) | |
download | nextcloud-server-dafe028c111a66b622eb920a7ed5f5e3e3d5abdf.tar.gz nextcloud-server-dafe028c111a66b622eb920a7ed5f5e3e3d5abdf.zip |
Rename
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/js/keyboardshortcuts.js | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js index 95e1ce428c9..c77e2d611cb 100644 --- a/apps/files/js/keyboardshortcuts.js +++ b/apps/files/js/keyboardshortcuts.js @@ -17,6 +17,7 @@ Files.bindKeyboardShortcuts = function (document, $) { var keyCodes = { shift: 16, n: 78, + r: 82, cmdFirefox: 224, cmdOpera: 17, leftCmdWebKit: 91, @@ -25,15 +26,35 @@ Files.bindKeyboardShortcuts = function (document, $) { esc: 27, downArrow: 40, upArrow: 38, - enter: 13 + enter: 13, + backspace: 8, + delete: 46 }; $(document).keydown(function(event){//check for modifier keys + var preventDefault = false; if($.inArray(event.keyCode, keys) === -1) keys.push(event.keyCode); console.log(event.keyCode); 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 || $.inArray(keyCodes.ctrl, keys) !== -1)){ + preventDefault = true; + } + if($.inArray(keyCodes.backspace, keys) !== -1 && !$("#new").hasClass("active")) { + $("#fileList tr").each(function(index){ + if($(this).hasClass("mouseOver")){ + preventDefault = true; + } + }); + } + if(!$("#new").hasClass("active") && $.inArray(keyCodes.r, keys) !== -1 && ($.inArray(keyCodes.cmdFirefox, keys) !== -1 || $.inArray(keyCodes.cmdOpera, keys) !== -1 || $.inArray(keyCodes.leftCmdWebKit, keys) !== -1 || $.inArray(keyCodes.rightCmdWebKit, keys) !== -1 || $.inArray(keyCodes.ctrl, keys) !== -1) && $.inArray(keyCodes.shift, keys) !== -1){ + $("#fileList tr").each(function(index){ + if($(this).hasClass("mouseOver")){ + preventDefault = true; + } + }); + } + if(preventDefault){ event.preventDefault(); //Prevent web browser from responding event.stopPropagation(); return false; @@ -62,12 +83,12 @@ Files.bindKeyboardShortcuts = function (document, $) { } } - if($("#new").hasClass("active") && $.inArray(keyCodes.esc, keys) !== -1){ + else if($("#new").hasClass("active") && $.inArray(keyCodes.esc, keys) !== -1){ $("#controls").trigger('click'); console.log("close"); } - if(!$("#new").hasClass("active") && $.inArray(keyCodes.downArrow, keys) !== -1){ + else if($.inArray(keyCodes.downArrow, keys) !== -1){ var select = -1; $("#fileList tr").each(function(index){ if($(this).hasClass("mouseOver")){ @@ -88,7 +109,7 @@ Files.bindKeyboardShortcuts = function (document, $) { } } - if(!$("#new").hasClass("active") && $.inArray(keyCodes.upArrow, keys) !== -1){ + else if($.inArray(keyCodes.upArrow, keys) !== -1){ var select = -1; $("#fileList tr").each(function(index){ if($(this).hasClass("mouseOver")){ @@ -109,11 +130,28 @@ Files.bindKeyboardShortcuts = function (document, $) { } } - if($.inArray(keyCodes.enter, keys) !== -1){ + else if(!$("#new").hasClass("active") && $.inArray(keyCodes.enter, keys) !== -1){ + $("#fileList tr").each(function(index){ + if($(this).hasClass("mouseOver")){ + $(this).removeClass("mouseOver"); + $(this).find("span.nametext").trigger('click'); + } + }); + } + + else if(!$("#new").hasClass("active") && ($.inArray(keyCodes.backspace, keys) !== -1 || $.inArray(keyCodes.delete, keys) !== -1)) { $("#fileList tr").each(function(index){ if($(this).hasClass("mouseOver")){ $(this).removeClass("mouseOver"); - $(this).find("span:first").trigger('click'); + $(this).find("a.action.delete").trigger('click'); + } + }); + } + else if(!$("#new").hasClass("active") && $.inArray(keyCodes.r, keys) !== -1 && ($.inArray(keyCodes.cmdFirefox, keys) !== -1 || $.inArray(keyCodes.cmdOpera, keys) !== -1 || $.inArray(keyCodes.leftCmdWebKit, keys) !== -1 || $.inArray(keyCodes.rightCmdWebKit, keys) !== -1 || $.inArray(keyCodes.ctrl, keys) !== -1) && $.inArray(keyCodes.shift, keys) !== -1){ + $("#fileList tr").each(function(index){ + if($(this).hasClass("mouseOver")){ + $(this).removeClass("mouseOver"); + $(this).find("a[data-action='Rename']").trigger('click'); } }); } |