feature(edit) save -> Edit.save

This commit is contained in:
coderaiser 2014-11-07 10:22:47 -05:00
parent 29341eb1ec
commit 47e0dbfdca

View file

@ -165,7 +165,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
is = Dialog.confirm(msg);
if (is)
save();
Edit.save();
}
}
@ -230,13 +230,17 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
Ace.commands.addCommand({
name : 'save',
bindKey : { win: 'Ctrl-S', mac: 'Command-S' },
exec : save
exec : function() {
Edit.save();
}
});
Ace.commands.addCommand({
name : 'saveMC',
bindKey : { win: 'F2', mac: 'F2' },
exec : save
exec : function() {
Edit.save();
}
});
Ace.commands.addCommand({
@ -265,7 +269,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
});
}
function save () {
Edit.save = function() {
var path = Info.path,
value = Ace.getValue();
@ -289,9 +293,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
var result = data || Value;
if (isPatch)
RESTful.patch(path, patch, onSave);
Edit.save.patch(path, patch);
else
RESTful.write(path + query, result, onSave);
Edit.save.write(path + query, result);
}, function(func) {
zip(value, function(error, data) {
if (error)
@ -304,7 +308,15 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
}, exec.with(doDiff, path));
});
}
};
Edit.save.patch = function(path, patch) {
RESTful.patch(path, patch, onSave);
};
Edit.save.write = function(path, result) {
RESTful.write(path, result, onSave);
};
function doDiff(path, callback) {
var value = Ace.getValue();
@ -421,7 +433,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
}
},
menuData = {
'Save Ctrl+S' : save,
'Save Ctrl+S' : function() {
Edit.save();
},
'Go To Line Ctrl+G' : function() {
Edit.goToLine();
},