From 63a5ad275bcd70d09925b6a3326fe0a051c5fddd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 May 2015 09:04:11 -0400 Subject: [PATCH] feature(dom) duplicatePanel: show content of directory under cursor in target panel --- HELP.md | 1 + lib/client/dom.js | 15 +++++++++++++++ lib/client/key.js | 30 ++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index 7e467deb..ac3cbb4a 100644 --- a/HELP.md +++ b/HELP.md @@ -123,6 +123,7 @@ Hot keys | `Ctrl + d` | clear local storage | `Ctrl + a` | select all files in a panel | `Up`, `Down`, `Enter` | file system navigation +| `Alt + Left/Right` | show content of directory under cursor in target panel | `Ctrl + \` | go to the root directory | `Tab` | move via panels | `Page Up` | up on one page diff --git a/lib/client/dom.js b/lib/client/dom.js index a64b6177..ca4602b1 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1773,6 +1773,21 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return this; }; + this.duplicatePanel = function() { + var isDir = CurrentInfo.isDir, + path = CurrentInfo.dirPath, + panel = CurrentInfo.panelPassive; + + if (isDir) + path = CurrentInfo.path; + + CloudCmd.loadDir({ + path: path, + panel: panel, + noCurrent: true + }); + }; + this.CurrentInfo = CurrentInfo, this.updateCurrentInfo = function(currentFile) { diff --git a/lib/client/key.js b/lib/client/key.js index be9e2ab8..022a4a59 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -19,7 +19,10 @@ var CloudCmd, Util, DOM; PAGE_DOWN : 34, END : 35, HOME : 36, + + LEFT : 37, UP : 38, + RIGHT : 39, DOWN : 40, INSERT : 45, @@ -217,6 +220,7 @@ var CloudCmd, Util, DOM; panel = Info.panel, path = Info.path, keyCode = event.keyCode, + alt = event.altKey, shift = event.shiftKey, ctrl = event.ctrlKey, meta = event.metaKey, @@ -353,7 +357,7 @@ var CloudCmd, Util, DOM; * выделяем предыдущую строку */ case Key.UP: if (shift) - DOM.toggleSelectedFile(current); + DOM.toggleSelectedFile(current); DOM.setCurrentFile(prev); event.preventDefault(); @@ -362,12 +366,34 @@ var CloudCmd, Util, DOM; /* если нажали клавишу в низ - выделяем следующую строку */ case Key.DOWN: if (shift) - DOM.toggleSelectedFile(current); + DOM.toggleSelectedFile(current); DOM.setCurrentFile(next); event.preventDefault(); break; + case Key.LEFT: + if (alt) { + name = Info.panel.getAttribute('data-name'); + + if (name === 'js-right') { + DOM.duplicatePanel(); + event.preventDefault(); + } + } + break; + + case Key.RIGHT: + if (alt) { + name = Info.panel.getAttribute('data-name'); + + if (name === 'js-left') { + DOM.duplicatePanel(); + event.preventDefault(); + } + } + break; + /* если нажали клавишу Home * * переходим к самому верхнему * * элементу */