From a3b1c058b5c4453838cb896aa3b8c3a803949ffb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 7 Oct 2013 16:08:59 +0200 Subject: [PATCH 1/1] integration: canvas fixes --- src/editor/modules/documentCanvas/canvas/canvas.js | 11 +++++++---- .../modules/documentCanvas/canvas/canvas.test.js | 2 +- src/editor/modules/documentCanvas/documentCanvas.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) 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, -- 2.20.1