From fe422743bb93c0a5a0e176202cc8b5db66eea495 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 May 2015 09:59:17 -0400 Subject: [PATCH] feature(dom) add swapPanels --- HELP.md | 1 + lib/client/dom.js | 33 +++++++++++++++++++++++++++++++++ lib/client/key.js | 6 ++++++ 3 files changed, 40 insertions(+) diff --git a/HELP.md b/HELP.md index ac3cbb4a..55028b18 100644 --- a/HELP.md +++ b/HELP.md @@ -122,6 +122,7 @@ Hot keys | `Ctrl + r` | refresh | `Ctrl + d` | clear local storage | `Ctrl + a` | select all files in a panel +| `Ctrl + u` | swap panels | `Up`, `Down`, `Enter` | file system navigation | `Alt + Left/Right` | show content of directory under cursor in target panel | `Ctrl + \` | go to the root directory diff --git a/lib/client/dom.js b/lib/client/dom.js index ca4602b1..6fec2d09 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1788,6 +1788,39 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }); }; + this.swapPanels = function() { + var Info = CurrentInfo, + panel = Info.panel, + panelPassive = Info.panelPassive, + + currentIndex = [].indexOf.call(Info.files, Info.element), + + dirPath = DOM.getCurrentDirPath(), + dirPathPassive = DOM.getNotCurrentDirPath(); + + CloudCmd.loadDir({ + path: dirPath, + panel: panelPassive, + noCurrent: true + }); + + CloudCmd.loadDir({ + path: dirPathPassive, + panel: panel + }, function() { + var el, + files = Info.files, + length = files.length - 1; + + if (currentIndex > length) + currentIndex = length; + + el = files[currentIndex]; + + DOM.setCurrentFile(el); + }); + }; + this.CurrentInfo = CurrentInfo, this.updateCurrentInfo = function(currentFile) { diff --git a/lib/client/key.js b/lib/client/key.js index 022a4a59..80cecc5e 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -42,6 +42,7 @@ var CloudCmd, Util, DOM; R : 82, S : 83, T : 84, + U : 85, V : 86, @@ -352,6 +353,11 @@ var CloudCmd, Util, DOM; event.preventDefault(); break; + case Key.U: + if (ctrlMeta) + DOM.swapPanels(); + break; + /* навигация по таблице файлов * * если нажали клавишу вверх * * выделяем предыдущую строку */