summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Sargent <esthepiking@gmail.com>2012-11-28 10:36:54 -0700
committerErik Sargent <esthepiking@gmail.com>2012-11-28 10:36:54 -0700
commit8722d3751c8f7ea29746dd0bab663b5400d268a1 (patch)
tree5bc5f3916c2a4bd4cd9f011774d833ad54396b66
parentb78dc3f48acd17f3bd2557362a40e367ef28fb6b (diff)
downloadnextcloud-server-8722d3751c8f7ea29746dd0bab663b5400d268a1.tar.gz
nextcloud-server-8722d3751c8f7ea29746dd0bab663b5400d268a1.zip
Keys array
-rw-r--r--apps/files/js/keyboardshortcuts.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/files/js/keyboardshortcuts.js b/apps/files/js/keyboardshortcuts.js
index eecf30bd10b..13777fd76b6 100644
--- a/apps/files/js/keyboardshortcuts.js
+++ b/apps/files/js/keyboardshortcuts.js
@@ -1,12 +1,16 @@
// 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);
-};
+function removeA(arr) {
+ var what, a = arguments, L = a.length, ax;
+ while (L > 1 && arr.length) {
+ what = a[--L];
+ while ((ax= arr.indexOf(what)) !== -1) {
+ arr.splice(ax, 1);
+ }
+ }
+ return arr;
+}
Files.bindKeyboardShortcuts = function (document, $){
var keys = [];
@@ -41,14 +45,16 @@ Files.bindKeyboardShortcuts = function (document, $){
$(".popup.popupTop").toggle(true);
$('#new li[data-type="file"]').trigger('click');
console.log("new file");
- keys.remove($.inArray(keyCodes.n, keys));
+/* keys.remove($.inArray(keyCodes.n, keys)); */
+ removeA(keys, keyCodes.n);
}
else{ //New Folder
$("#new").addClass("active");
$(".popup.popupTop").toggle(true);
$('#new li[data-type="folder"]').trigger('click');
console.log("new folder");
- keys.remove($.inArray(keyCodes.n, keys));
+/* keys.remove($.inArray(keyCodes.n, keys)); */
+ removeA(keys, keyCodes.n);
}
}
if($("#new").hasClass("active") && $.inArray(keyCodes.esc, keys) !== -1){
@@ -56,6 +62,7 @@ Files.bindKeyboardShortcuts = function (document, $){
console.log("close");
}
- keys.remove($.inArray(event.keyCode, keys));
+/* keys.remove($.inArray(event.keyCode, keys)); */
+ removeA(keys, event.keyCode);
});
}; \ No newline at end of file