options = _.extend({textNodeIdx: 0}, options);\r
if(typeof options.textNodeIdx === 'number')\r
options.textNodeIdx = [options.textNodeIdx];\r
- var container = $(this.content.find('#' + options.inside.getId()).get(0));\r
- \r
- var containerContent = container.contents();\r
- var idx1 = Math.min.apply(Math, options.textNodeIdx);\r
- var idx2 = Math.max.apply(Math, options.textNodeIdx);\r
- var textNode1 = $(containerContent.get(idx1));\r
- var textNode2 = $(containerContent.get(idx2));\r
- var sameNode = textNode1.get(0) === textNode2.get(0);\r
+ \r
+ var container = $(this.content.find('#' + options.inside.getId()).get(0)),\r
+ containerContent = container.contents(),\r
+ idx1 = Math.min.apply(Math, options.textNodeIdx),\r
+ idx2 = Math.max.apply(Math, options.textNodeIdx),\r
+ textNode1 = $(containerContent.get(idx1)),\r
+ textNode2 = $(containerContent.get(idx2)),\r
+ sameNode = textNode1.get(0) === textNode2.get(0),\r
+ prefixOutside = textNode1.text().substr(0, options.offsetStart),\r
+ prefixInside = textNode1.text().substr(options.offsetStart),\r
+ suffixInside = textNode2.text().substr(0, options.offsetEnd),\r
+ suffixOutside = textNode2.text().substr(options.offsetEnd)\r
+ ;\r
+ \r
textNode1.after(options._with.dom);\r
textNode1.detach();\r
- if(!sameNode)\r
- textNode2.detach();\r
- \r
- var prefixOutside = textNode1.text().substr(0, options.offsetStart);\r
- var prefixInside = textNode1.text().substr(options.offsetStart)\r
- var suffixInside = textNode2.text().substr(0, options.offsetEnd)\r
- var suffixOutside = textNode2.text().substr(options.offsetEnd);\r
- var core;\r
- if(sameNode)\r
- core = textNode1.text().substr(options.offsetStart, options.offsetEnd - options.offsetStart);\r
\r
options._with.dom.before(prefixOutside);\r
if(sameNode) {\r
+ var core = textNode1.text().substr(options.offsetStart, options.offsetEnd - options.offsetStart);\r
options._with.setContent(core);\r
} else {\r
+ textNode2.detach();\r
options._with.dom.append(prefixInside);\r
for(var i = idx1 + 1; i < idx2; i++) {\r
options._with.dom.append(containerContent[i]);\r