From 4b712c95c6f6538889cfe113ea938845afdc5834 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 May 2015 09:07:09 -0400 Subject: [PATCH] fix(edit) setValueFirst before edward loaded --- lib/client/edit.js | 49 ++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index dcbf8092..2726fcf1 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -33,7 +33,9 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; }; function init(callback) { - var element = createElement(); + var element; + + element = createElement(); element.addEventListener('contextmenu', setMenu); @@ -65,30 +67,32 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; } this.show = function(callback) { - Images.show.load(); - - if (callback) - ConfigView.beforeShow = callback; - - Info.getData(function(error, data) { - var path = Info.path, - isDir = Info.isDir, - name = Info.name; + if (!Loading) { + Images.show.load(); - if (isDir) - name += '.json'; + if (callback) + ConfigView.beforeShow = callback; - if (error) { - alert(error); - } else { - edward.setValueFirst(path, data); + Info.getData(function(error, data) { + var path = Info.path, + isDir = Info.isDir, + name = Info.name; - setMsgChanged(name); - edward.setModeForPath(name); + if (isDir) + name += '.json'; - CloudCmd.View.show(Element, ConfigView); - } - }); + if (error) { + alert(error); + } else { + edward.setValueFirst(path, data); + + setMsgChanged(name); + edward.setModeForPath(name); + + CloudCmd.View.show(Element, ConfigView); + } + }); + } return this; }; @@ -137,12 +141,11 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; maxSize : CloudFunc.MAX_FILE_SIZE }; - Loading = false; - edward = window[Editor]; edward(element, options, function() { Util.timeEnd(Name + ' load'); + Loading = false; exec(callback); }); });