//
// empty -> loading -> synced -> unsynced -> loading
// \
-// -> dirty -> updating -> synced
+// -> dirty -> updating -> updated -> synced
//
Editor.XMLModel = Editor.Model.extend({
_className: 'Editor.XMLModel',
dataType: 'text',
success: this.loadingSucceeded.bind(this)
});
+ return true;
}
+ return false;
+ },
+
+ update: function(message) {
+ if (this.get('state') == 'dirty') {
+ this.set('state', 'updating');
+
+ var payload = {
+ contents: this.get('data')
+ };
+ if (message) {
+ payload.message = message;
+ }
+
+ $.ajax({
+ url: this.serverURL,
+ type: 'put',
+ dataType: 'json',
+ data: payload,
+ success: this.updatingSucceeded.bind(this),
+ error: this.updatingFailed.bind(this)
+ });
+ return true;
+ }
+ return false;
+ },
+
+ updatingSucceeded: function() {
+ if (this.get('state') != 'updating') {
+ alert('erroneous state:', this.get('state'));
+ }
+ this.set('state', 'updated');
+ },
+
+ updatingFailed: function() {
+ if (this.get('state') != 'updating') {
+ alert('erroneous state:', this.get('state'));
+ }
+ this.set('state', 'dirty');
},
set: function(property, value) {
}
}
}
+ },
+
+ quickSave: function(message) {
+ for (var key in this.contentModels) {
+ if (this.contentModels[key].get('state') == 'dirty') {
+ this.contentModels[key].update(message);
+ break;
+ }
+ }
}
});
$(function() {
doc = new Editor.DocumentModel();
var editor = new EditorView('#body-wrap', doc);
+ editor.freeze();
var splitView = new SplitView('#splitview', doc);
leftPanelView = new PanelContainerView('#left-panel-container', doc);
rightPanelContainer = new PanelContainerView('#right-panel-container', doc);