'use strict';
-var Canvas = function(wlxml, publisher) {
+var Canvas = function(wlxmlDocument, publisher) {
this.eventBus = _.extend({}, Backbone.Events);
- this.loadWlxmlDocument(wlxml);
+ this.loadWlxmlDocument(wlxmlDocument);
this.publisher = publisher ? publisher : function() {};
};
$.extend(Canvas.prototype, {
loadWlxmlDocument: function(wlxmlDocument) {
+ if(!wlxmlDocument) {
+ return false;
+ }
var canvasDOM = this.generateCanvasDOM(wlxmlDocument.root);
this.wrapper = $('<div>').addClass('canvas-wrapper').attr('contenteditable', true);
})
return {
- fromXML: function(wlxmlNode, publisher) {
- return new Canvas(wlxmlNode, publisher);
+ fromXMLDocument: function(wlxmlDocument, publisher) {
+ return new Canvas(wlxmlDocument, publisher);
}
};
describe('new Canvas', function() {
it('abc', function() {
var doc = wlxml.WLXMLDocumentFromXML('<section>Alice <span>has</span> a cat!</div>'),
- c = canvas.fromXML(doc);
+ c = canvas.fromXMLDocument(doc);
expect(c.doc().children()).to.have.length(3)
});
return function(sandbox) {
- var canvas = canvas3.fromXML('', sandbox.publish);
+ var canvas = canvas3.fromXMLDocument(null, sandbox.publish);
var canvasWrapper = $(template);
var shownAlready = false;
var scrollbarPosition = 0,