From 2a8d7be8e2a6810f85a832bd46a07ce4739fd9a9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 24 Oct 2015 06:36:37 -0400 Subject: [PATCH] fix(edit) isChanged: create -> beforeClose --- lib/client/edit.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index a5649643..6d4b0db0 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -27,6 +27,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format; ConfigView = { beforeClose: function() { exec.ifExist(Menu, 'hide'); + isChanged(Edit.hide); }, afterShow: function() { editor @@ -115,14 +116,6 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format; DOM.setCurrentSize(size); }); - editor.addCommand({ - name : 'hide', - bindKey : { win: 'Esc', mac: 'Esc' }, - exec : function () { - isChanged(Edit.hide); - } - }); - return this; }; @@ -216,16 +209,13 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format; MSG_CHANGED = msg; } - function isChanged(fn) { + function isChanged() { var is = editor.isChanged(); - if (!is) - fn(); - else - Dialog.confirm(TITLE, MSG_CHANGED).then(function() { + is && Dialog.confirm(TITLE, MSG_CHANGED, {cancel: false}) + .then(function() { editor.save(); - fn(); - }).catch(fn); + }); } init(callback);