fix(edit) isChanged: create -> beforeClose

This commit is contained in:
coderaiser 2015-10-24 06:36:37 -04:00
parent 1c3a117d02
commit 2a8d7be8e2

View file

@ -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);