summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9f6d153)
Up until now a stub empty document was loaded.
'use strict';
/* global gettext, alert, window */
'use strict';
/* global gettext, alert, window */
-var logger = logging.getLogger('editor.modules.data'),
- stubDocument = '<section><div>' + gettext('This is an empty document.') + '</div></section>';
+var logger = logging.getLogger('editor.modules.data');
return function(sandbox) {
return function(sandbox) {
var loadDocument = function(text, isDraft, draftTimestamp) {
logger.debug('loading document');
var loadDocument = function(text, isDraft, draftTimestamp) {
logger.debug('loading document');
- wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {editorConfig: sandbox.getConfig()}, Document);
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {editorConfig: sandbox.getConfig()}, Document.Document);
} catch(e) {
logger.exception(e);
} catch(e) {
logger.exception(e);
- alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO
- wlxmlDocument = wlxml.WLXMLDocumentFromXML(stubDocument, {}, Document);
+ alert(gettext('The content of this document seems to be invalid - only XML source editing will be possible. :(')); // TODO
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {}, Document.DumbDocument);
+ xmlValid = false;
}
}, sandbox.getConfig().autoSaveInterval || 2500);
}
}
}, sandbox.getConfig().autoSaveInterval || 2500);
}
- sandbox.publish('ready', isDraft, draftTimestamp);
+ sandbox.publish('ready', isDraft, draftTimestamp, xmlValid);
};
function readCookie(name) {
};
function readCookie(name) {
+var DumbDocument = function() {
+ Document.apply(this, Array.prototype.slice.call(arguments, 0));
+};
+DumbDocument.prototype = Object.create(Document.prototype);
+_.extend(DumbDocument.prototype, {
+ loadXML: function(xml) {
+ this._xml = xml;
+ this.trigger('contentSet');
+ },
+ toXML: function() {
+ return this._xml;
+ }
+});
+
+return {Document: Document, DumbDocument: DumbDocument};
});
\ No newline at end of file
});
\ No newline at end of file
};
eventHandlers.data = {
};
eventHandlers.data = {
- ready: function(usingDraft, draftTimestamp) {
+ ready: function(usingDraft, draftTimestamp, xmlValid) {
wlxmlDocument = sandbox.getModule('data').getDocument();
views.mainLayout.setView('mainView', views.mainTabs.getAsView());
wlxmlDocument = sandbox.getModule('data').getDocument();
views.mainLayout.setView('mainView', views.mainTabs.getAsView());
sandbox.getModule('mainBar').setCommandEnabled('drop-draft', usingDraft);
sandbox.getModule('mainBar').setCommandEnabled('save', usingDraft);
sandbox.getModule('mainBar').setCommandEnabled('drop-draft', usingDraft);
sandbox.getModule('mainBar').setCommandEnabled('save', usingDraft);
- _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'mainBar', 'indicator', 'documentHistory', 'diffViewer', 'statusBar'], function(moduleName) {
+
+ var toStart = ['sourceEditor', 'documentToolbar', 'mainBar', 'indicator', 'documentHistory', 'diffViewer', 'statusBar'];
+ if(xmlValid) {
+ toStart.push('documentCanvas');
+ }
+ _.each(toStart, function(moduleName) {
sandbox.getModule(moduleName).start();
});
sandbox.getModule(moduleName).start();
});