From: Aleksander Ɓukasz Date: Mon, 7 Oct 2013 14:08:59 +0000 (+0200) Subject: integration: canvas fixes X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/a3b1c058b5c4453838cb896aa3b8c3a803949ffb integration: canvas fixes --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 482afb9..8c2e2e1 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -9,15 +9,18 @@ define([ '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 = $('
').addClass('canvas-wrapper').attr('contenteditable', true); @@ -550,8 +553,8 @@ $.extend(Cursor.prototype, { }) return { - fromXML: function(wlxmlNode, publisher) { - return new Canvas(wlxmlNode, publisher); + fromXMLDocument: function(wlxmlDocument, publisher) { + return new Canvas(wlxmlDocument, publisher); } }; diff --git a/src/editor/modules/documentCanvas/canvas/canvas.test.js b/src/editor/modules/documentCanvas/canvas/canvas.test.js index 35b943d..f0ba395 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.test.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.test.js @@ -19,7 +19,7 @@ var nodeFromXML = function(xml) { describe('new Canvas', function() { it('abc', function() { var doc = wlxml.WLXMLDocumentFromXML('
Alice has a cat!
'), - c = canvas.fromXML(doc); + c = canvas.fromXMLDocument(doc); expect(c.doc().children()).to.have.length(3) }); diff --git a/src/editor/modules/documentCanvas/documentCanvas.js b/src/editor/modules/documentCanvas/documentCanvas.js index 84fb086..88538c4 100644 --- a/src/editor/modules/documentCanvas/documentCanvas.js +++ b/src/editor/modules/documentCanvas/documentCanvas.js @@ -10,7 +10,7 @@ define([ 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,