X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/24ac4f5092661ce053f33d460306bf81d6a3dc8a..bc034b92ca42b68512daa81ae3306d0d351af04c:/src/editor/modules/documentCanvas/canvas/canvas.js
diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js
index 8b94782..830db75 100644
--- a/src/editor/modules/documentCanvas/canvas/canvas.js
+++ b/src/editor/modules/documentCanvas/canvas/canvas.js
@@ -4,14 +4,16 @@ define([
'libs/backbone',
'modules/documentCanvas/canvas/documentElement',
'modules/documentCanvas/canvas/keyboard',
-'modules/documentCanvas/canvas/utils'
-], function($, _, Backbone, documentElement, keyboard, utils) {
+'modules/documentCanvas/canvas/utils',
+'modules/documentCanvas/canvas/wlxmlListener'
+], function($, _, Backbone, documentElement, keyboard, utils, wlxmlListener) {
'use strict';
var Canvas = function(wlxmlDocument, publisher) {
this.eventBus = _.extend({}, Backbone.Events);
this.wrapper = $('
').addClass('canvas-wrapper').attr('contenteditable', true);
+ this.wlxmlListener = wlxmlListener.create(this);
this.loadWlxmlDocument(wlxmlDocument);
this.publisher = publisher ? publisher : function() {};
};
@@ -19,10 +21,10 @@ var Canvas = function(wlxmlDocument, publisher) {
$.extend(Canvas.prototype, {
loadWlxmlDocument: function(wlxmlDocument) {
- wlxmlDocument = wlxmlDocument || this.wlxmlDocument;
if(!wlxmlDocument) {
return false;
}
+
var canvasDOM = this.generateCanvasDOM(wlxmlDocument.root);
this.wrapper.empty();
@@ -30,18 +32,7 @@ $.extend(Canvas.prototype, {
this.d = this.wrapper.children(0);
this.setupEventHandling();
- var canvas = this;
-
- if(this.wlxmlDocument !== wlxmlDocument) {
- wlxmlDocument.on('change', function(event) {
- var canvasNode = utils.findCanvasElement(event.meta.node);
- if(event.type === 'nodeAttrChange' && event.meta.attr === 'class') {
- canvasNode.setWlxmlClass(event.meta.newVal);
- }
-
- });
- }
- this.wlxmlDocument = wlxmlDocument;
+ this.wlxmlListener.listenTo(wlxmlDocument);
},
generateCanvasDOM: function(wlxmlNode) {