Canvas.prototype.splitNode = function(options) {\r
options = _.extend({textNodeIdx: 0}, options);\r
\r
- var element = $(this.content.find('#' + options.node.id).get(0));\r
+ var nodeToSplit = $(this.content.find('#' + options.node.id).get(0));\r
\r
- var elementContents = element.contents();\r
- if(elementContents.length === 0 || \r
- elementContents.length - 1 < options.textNodeIdx || \r
- elementContents.get(options.textNodeIdx).nodeType != 3)\r
+ var nodeContents = nodeToSplit.contents();\r
+ if(nodeContents.length === 0 || \r
+ nodeContents.length - 1 < options.textNodeIdx || \r
+ nodeContents.get(options.textNodeIdx).nodeType != 3)\r
return false;\r
\r
- var textElement = elementContents.get(options.textNodeIdx);\r
+ var textNode = $(nodeContents.get(options.textNodeIdx));\r
\r
var succeedingNodes = [];\r
var passed = false;\r
- elementContents.each(function() {\r
+ nodeContents.each(function() {\r
var node = this;\r
if(passed)\r
succeedingNodes.push(node);\r
- if(node.isSameNode(textElement))\r
+ if(node.isSameNode(textNode.get(0)))\r
passed = true;\r
});\r
\r
- var prefix = textElement.data.substr(0, options.offset);\r
- var suffix = textElement.data.substr(options.offset);\r
+ var prefix = textNode.text().substr(0, options.offset);\r
+ var suffix = textNode.text().substr(options.offset);\r
\r
- var $textElement = $(textElement);\r
- $textElement.before(prefix);\r
- $textElement.remove();\r
- var newNode = this._createNode(element.attr('wlxml-tag'), element.attr('wlxml-class'));\r
+ textNode.before(prefix);\r
+ textNode.remove();\r
+ \r
+ var newNode = this._createNode(nodeToSplit.attr('wlxml-tag'), nodeToSplit.attr('wlxml-class'));\r
newNode.append(suffix);\r
succeedingNodes.forEach(function(node) {\r
newNode.append(node)\r
});\r
- element.after(newNode);\r
+ nodeToSplit.after(newNode);\r
}\r
\r
Canvas.prototype.createList = function(options) {\r