integration: canvas fixes
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 7 Oct 2013 14:08:59 +0000 (16:08 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:52 +0000 (14:50 +0100)
src/editor/modules/documentCanvas/canvas/canvas.js
src/editor/modules/documentCanvas/canvas/canvas.test.js
src/editor/modules/documentCanvas/documentCanvas.js

index 482afb9..8c2e2e1 100644 (file)
@@ -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 = $('<div>').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);
     }
 };
 
index 35b943d..f0ba395 100644 (file)
@@ -19,7 +19,7 @@ var nodeFromXML = function(xml) {
 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)
     });
index 84fb086..88538c4 100644 (file)
@@ -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,