From 2c024d10ba63c3bc6ea184edd693b10d858d32ee Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 14 Nov 2016 16:09:12 +0200 Subject: [PATCH] feature(dom) add setCurrentByName --- lib/client.js | 5 +---- lib/client/dom.js | 15 ++++++++------- lib/client/operation.js | 9 ++------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/client.js b/lib/client.js index 602605c1..4526060e 100644 --- a/lib/client.js +++ b/lib/client.js @@ -391,11 +391,8 @@ var Util, DOM, CloudFunc, join; Storage.set(path, obj); createFileTable(obj, panel, options, function() { - var current; - if (isRefresh && !noCurrent) { - current = DOM.getCurrentByName(name); - DOM.setCurrentFile(current); + DOM.setCurrentByName(name); } Util.exec(callback); diff --git a/lib/client/dom.js b/lib/client/dom.js index 987c78dd..d722cdb7 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -383,8 +383,7 @@ var CloudCmd, Util, DOM, CloudFunc; func = function(name) { return function() { CloudCmd.refresh(null, function() { - var current = DOM.getCurrentByName(name); - DOM.setCurrentFile(current); + DOM.setCurrentByName(name); }); }; }, @@ -478,9 +477,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (name) RESTful.write(path, function(error) { !error && CloudCmd.refresh(null, function() { - var current = DOM.getCurrentByName(name); - - DOM.setCurrentFile(current); + DOM.setCurrentByName(name); }); }); }); @@ -791,11 +788,15 @@ var CloudCmd, Util, DOM, CloudFunc; return refresh; }; + this.setCurrentByName = function(name) { + var current = this.getCurrentByName(name) + return this.setCurrentFile(current); + } /** * unified way to set current file */ - this.setCurrentFile = function(currentFile, options) { + this.setCurrentFile = function(currentFile, options) { var path, pathWas, title, o = options, FS = CloudFunc.FS, @@ -834,7 +835,7 @@ var CloudCmd, Util, DOM, CloudFunc; Cmd.updateCurrentInfo(); } - return this; + return this; }; /* diff --git a/lib/client/operation.js b/lib/client/operation.js index 6b68803b..8ceb020c 100644 --- a/lib/client/operation.js +++ b/lib/client/operation.js @@ -426,13 +426,10 @@ var panel = Info.panel, panelPassive = Info.panelPassive, setCurrent = function() { - var current; - if (!name) name = data.names[0]; - current = DOM.getCurrentByName(name); - DOM.setCurrentFile(current); + DOM.setCurrentByName(name); }; if (!Info.isOnePanel) @@ -496,9 +493,7 @@ op(fileFrom, function(error) { !error && CloudCmd.refresh(null, function() { - var file = DOM.getCurrentByName(name); - - DOM.setCurrentFile(file); + DOM.setCurrentByName(name); }); }); }