diff --git a/lib/client.js b/lib/client.js index 86e4a891..53fb1064 100644 --- a/lib/client.js +++ b/lib/client.js @@ -359,23 +359,9 @@ var Util, DOM, CloudFunc; */ this.ajaxLoad = function(path, options, panel) { var SLASH = '/', - dirPath = DOM.getCurrentDirPath(), fsPath = decodeURI(path), noJSONPath = Util.rmStr(fsPath, '?json' ), - cleanPath = Util.rmStrOnce(noJSONPath, CloudFunc.FS) || SLASH, - setTitle = function() { - var title; - - dirPath = CloudFunc.rmLastSlash(dirPath) || '/'; - - if (dirPath !== cleanPath) { - if (!options.nohistory) - DOM.setHistory(noJSONPath, null, noJSONPath); - - title = CloudFunc.getTitle(cleanPath); - DOM.setTitle(title); - } - }; + cleanPath = Util.rmStrOnce(noJSONPath, CloudFunc.FS) || SLASH; if (!options) options = {}; @@ -398,13 +384,11 @@ var Util, DOM, CloudFunc; if (!ret && json) { json = Util.parseJSON(json); CloudCmd.createFileTable(json, panel); - setTitle(); } else DOM.getCurrentFileContent({ url : fsPath, dataType : 'json', success : function(json) { - setTitle(); CloudCmd.createFileTable(json, panel); Storage.set(cleanPath, json); } diff --git a/lib/client/dom.js b/lib/client/dom.js index b283b01b..5c8e9058 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1075,16 +1075,32 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * unified way to set current file */ this.setCurrentFile = function(currentFile) { - var ret, + var ret, path, pathWas, title, + FS = CloudFunc.FS, CENTER = true, currentFileWas = this.getCurrentFile(); if (currentFile) { - if (currentFileWas) + if (currentFileWas) { + pathWas = DOM.getCurrentDirPath(); unsetCurrentFile(currentFileWas); + } this.addClass(currentFile, CURRENT_FILE); + path = DOM.getCurrentDirPath(); + + if (path !== pathWas) { + title = CloudFunc.getTitle(path); + this.setTitle(title); + + if (path !== '/') + path = FS + path; + + DOM.setHistory(path, null, path); + } + + /* scrolling to current file */ this.scrollIntoViewIfNeeded(currentFile, CENTER); @@ -1826,7 +1842,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; current = Info.element, panel = Info.panel, filesPassive = Info.filesPassive; - + id = panel.id; TabPanel[id] = current;