From b5ee03c816da14c66220627ac28f8d9d58c372df Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 23 Jul 2015 09:19:10 -0400 Subject: [PATCH] feature(dom) add unselectFiles --- lib/client/dom.js | 16 ++++++++++++++++ lib/client/key.js | 4 ++++ lib/client/listeners.js | 2 ++ 3 files changed, 22 insertions(+) diff --git a/lib/client/dom.js b/lib/client/dom.js index 8e903f32..1bd9a340 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -583,6 +583,22 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return ret; }; + + /* + * unselect all files + */ + this.unselectFiles = function(files) { + var array, + isArray = Array.isArray(files); + + if (!files) { + array = DOM.getSelectedFiles(); + } else if (!isArray) + array = [].slice.call(files); + + array.forEach(DOM.toggleSelectedFile); + }; + /** * get all selected files with current included * diff --git a/lib/client/key.js b/lib/client/key.js index 2ebcd672..47e4baa8 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -367,6 +367,8 @@ var CloudCmd, Util, DOM; case Key.UP: if (shift) DOM.toggleSelectedFile(current); + else + DOM.unselectFiles(); DOM.setCurrentFile(prev); event.preventDefault(); @@ -377,6 +379,8 @@ var CloudCmd, Util, DOM; case Key.DOWN: if (shift) DOM.toggleSelectedFile(current); + else + DOM.unselectFiles(); DOM.setCurrentFile(next); event.preventDefault(); diff --git a/lib/client/listeners.js b/lib/client/listeners.js index 33da03bb..19416259 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -166,6 +166,8 @@ var Util, DOM, CloudFunc, CloudCmd; if (!DOM.isSelected(current)) DOM.toggleSelectedFile(current); }); + else + DOM.unselectFiles(); } function changePanel(element) {