X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/c986f6ebfd3d20bdc75ce00ee09bd2c716e0cb16..8bf6c2bb6ef0a358a3591d19d6aff7a1f7f22b92:/modules/documentCanvas/canvas.js diff --git a/modules/documentCanvas/canvas.js b/modules/documentCanvas/canvas.js index c2f6c85..9177968 100644 --- a/modules/documentCanvas/canvas.js +++ b/modules/documentCanvas/canvas.js @@ -11,6 +11,10 @@ define([ var Canvas = function(html) { this.dom = $(template); this.content = this.dom.find('#rng-module-documentCanvas-content'); + this.setHTML(html); +}; + +Canvas.prototype.setHTML = function(html) { if(html) { this.content.html(html); } @@ -38,6 +42,10 @@ Canvas.prototype.findNodes = function(desc) { return toret; }; +Canvas.prototype.getNodeById = function(id) { + return canvasNode.create($(this.content.find('#' +id))); +} + Canvas.prototype.nodeAppend = function(options) { var element; // = $(this.content.find('#' + options.context.id).get(0)); if(options.to === 'root') { @@ -90,7 +98,7 @@ Canvas.prototype.nodeSplit = function(options) { var node = this; if(passed) succeedingNodes.push(node); - if(node.isSameNode(textNode.get(0))) + if(node === textNode.get(0)) passed = true; }); @@ -117,7 +125,7 @@ Canvas.prototype.nodeRemove = function(options) { Canvas.prototype.listCreate = function(options) { var element1 = $(this.content.find('#' + options.start.getId()).get(0)); var element2 = $(this.content.find('#' + options.end.getId()).get(0)); - if(!element1.parent().get(0).isSameNode(element2.parent().get(0))) + if(!element1.parent().get(0) === element2.parent().get(0)) return false; var parent = element1.parent(); @@ -134,7 +142,7 @@ Canvas.prototype.listCreate = function(options) { var canvas = this; parent.contents().each(function() { var node = this; - if(node.isSameNode(element1.get(0))) + if(node === element1.get(0)) place = 'inside'; if(place === 'inside') { var $node; @@ -148,12 +156,24 @@ Canvas.prototype.listCreate = function(options) { $node.attr('wlxml-class', 'item'); nodesToWrap.push($node); } - if(node.isSameNode(element2.get(0))) + if(node === element2.get(0)) return false; }); - var list = canvasNode.create({tag: 'div', klass: 'list-items'}).dom; //this._createNode('div', 'list-items'); - element1.before(list); + var list = canvasNode.create({tag: 'div', klass: 'list-items' + (options.type === 'enum' ? '-enum' : '')}).dom; //this._createNode('div', 'list-items'); + + var parentNode = options.start.parent(); + + var toret; + if(parentNode && parentNode.isOfClass('list-items')) { + list.wrap('