From 55bbf70d3f5553f74c4dae37ef152843accd7d2c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 26 Dec 2016 14:42:57 +0200 Subject: [PATCH] refactor(edit) show --- client/edit.js | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/client/edit.js b/client/edit.js index 0075c74d..65854ab9 100644 --- a/client/edit.js +++ b/client/edit.js @@ -75,36 +75,36 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format; return element; } - this.show = function(callback) { - if (!Loading) { - Images.show.load(); + this.show = function(callback) { + if (Loading) + return this; + + Images.show.load(); + + if (callback) + ConfigView.beforeShow = callback; + + Info.getData(function(error, data) { + var path = Info.path; + var isDir = Info.isDir; + var name = Info.name; - if (callback) - ConfigView.beforeShow = callback; + if (isDir) + name += '.json'; - Info.getData(function(error, data) { - var path = Info.path, - isDir = Info.isDir, - name = Info.name; - - if (isDir) - name += '.json'; - - if (error) { - Images.hide(); - } else { - editor.setValueFirst(path, data); - - setMsgChanged(name); - - editor - .setModeForPath(name) - .setOption('fontSize', 16); - - CloudCmd.View.show(Element, ConfigView); - } - }); - } + if (error) + return Images.hide(); + + editor.setValueFirst(path, data); + + setMsgChanged(name); + + editor + .setModeForPath(name) + .setOption('fontSize', 16); + + CloudCmd.View.show(Element, ConfigView); + }); return this; };