summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorErik Sargent <esthepiking@gmail.com>2012-11-28 09:50:54 -0700
committerErik Sargent <esthepiking@gmail.com>2012-11-28 09:50:54 -0700
commitfa858d7149b30cb956df2a50008014ec1d857876 (patch)
tree5d13ba73d421492d4b731b802e53fa9efb7ed4e1 /apps
parentccb9bb4be00ae98609632d5c774542ef7eb6437d (diff)
downloadnextcloud-server-fa858d7149b30cb956df2a50008014ec1d857876.tar.gz
nextcloud-server-fa858d7149b30cb956df2a50008014ec1d857876.zip
initial setup
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/keyboardshortcuts.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js
new file mode 100644
index 00000000000..2a193f775ab
--- /dev/null
+++ b/apps/files/js/keyboardshortcuts.js
@@ -0,0 +1,52 @@
+// your file
+var Files = Files || {};
+
+// Array Remove - By John Resig (MIT Licensed)
+Array.prototype.remove = function(from, to) {
+ var rest = this.slice((to || from) + 1 || this.length);
+ this.length = from < 0 ? this.length + from : from;
+ return this.push.apply(this, rest);
+};
+
+Files.bindKeyboardShortcuts = function (document, $){
+ var keys = []
+
+ $(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)
+ event.preventDefault(); //Prevent web browser from responding
+ }
+ });
+
+ $(document).keyup(function(event){
+ // do your event.keyCode checks in here
+
+ 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
+ $("#new").addClass("active");
+ $(".popup.popupTop").toggle(true);
+ $('#new li[data-type="file"]').trigger('click');
+ console.log("new file");
+ keys.remove($.inArray(78, 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));
+ }
+ }
+ if($("#new").hasClass("active") && $.inArray(27, keys) !== -1){
+ $("#controls").trigger('click');
+ console.log("close");
+ }
+
+ keys.remove($.inArray(event.keyCode, keys));
+ });
+}; \ No newline at end of file