feature(edward) isChanged: rm confirm, save

This commit is contained in:
coderaiser 2015-01-23 10:49:23 -05:00
parent 3179b6feea
commit 2792d57c28
2 changed files with 24 additions and 12 deletions

View file

@ -16,10 +16,11 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
Menu,
Images = DOM.Images,
MSG_CHANGED,
Element,
ConfigView = {
beforeClose: function() {
edward.isChanged();
isChanged();
exec.ifExist(Menu, 'hide');
},
afterShow: function() {
@ -67,6 +68,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
path = Info.path;
Images.show.load();
setMsgChanged(name);
if (callback)
ConfigView.beforeShow = callback;
@ -222,6 +224,23 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
}
}
function setMsgChanged(name) {
var msg = 'Do you want to save changes to' + name + '?';
MSG_CHANGED = msg;
}
function isChanged() {
var is = edward.isChanged();
if (is) {
is = confirm(MSG_CHANGED);
if (is)
edward.save();
}
}
init(callback);
}

View file

@ -56,7 +56,7 @@ var join, ace, load, Util, DOM, io, daffy, restafary;
ace.require('ace/ext/language_tools');
Modelist = ace.require('ace/ext/modelist');
load.json('/json/edit.json', function(error, config) {
load.json(PREFIX + '/json/edit.json', function(error, config) {
var options = config.options;
Config = config;
@ -127,17 +127,10 @@ var join, ace, load, Util, DOM, io, daffy, restafary;
};
edward.isChanged = function() {
var is,
value = edward.getValue(),
isEqual = value === Value,
msg = 'Do you want to save changes to ' + name + '?';
var value = edward.getValue(),
isEqual = value === Value;
if (!isEqual) {
is = confirm(msg);
if (is)
edward.save();
}
return !isEqual;
};
edward.setValue = function(value) {