mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-14 18:57:56 +01:00
Minor optimization.
This commit is contained in:
parent
873e635b9a
commit
8f05606449
@ -40,27 +40,23 @@ web2d.peer.svg.TextPeer = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setText : function(text) {
|
setText : function(text) {
|
||||||
var i = 0;
|
// Remove all previous nodes ...
|
||||||
var childs = this._native.childNodes;
|
while (this._native.firstChild) {
|
||||||
for (i = 0; i < childs.length; i++) {
|
this._native.removeChild(this._native.firstChild);
|
||||||
Element.dispose(childs[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._text = text;
|
this._text = text;
|
||||||
var lines = text.split('\n');
|
if (text) {
|
||||||
|
var lines = text.split('\n');
|
||||||
|
lines.forEach(function(line) {
|
||||||
|
var tspan = window.document.createElementNS(this.svgNamespace, 'tspan');
|
||||||
|
tspan.setAttribute('dy', '1em');
|
||||||
|
tspan.setAttribute('x', this.getPosition().x);
|
||||||
|
|
||||||
var tspans = [];
|
tspan.textContent = line.length == 0 ? " " : line;
|
||||||
lines.forEach(function(line) {
|
this._native.appendChild(tspan);
|
||||||
|
}.bind(this));
|
||||||
var tspan = window.document.createElementNS(this.svgNamespace, 'tspan');
|
}
|
||||||
tspan.setAttribute('dy', '1em');
|
|
||||||
tspan.setAttribute('x', this.getPosition().x);
|
|
||||||
var tspanContent = window.document.createTextNode(line.length == 0 ? " " : line);
|
|
||||||
tspan.appendChild(tspanContent);
|
|
||||||
tspans.push(tspan);
|
|
||||||
|
|
||||||
this._native.appendChild(tspan);
|
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getText : function() {
|
getText : function() {
|
||||||
@ -73,10 +69,10 @@ web2d.peer.svg.TextPeer = new Class({
|
|||||||
this._native.setAttribute('x', x);
|
this._native.setAttribute('x', x);
|
||||||
|
|
||||||
// tspan must be positioned manually.
|
// tspan must be positioned manually.
|
||||||
var tspans = this._native.childNodes;
|
this._native.getElements('tspan').forEach(function(span) {
|
||||||
for (var i = 0; i < tspans.length; i++) {
|
span.setAttribute('x', x);
|
||||||
tspans[i].setAttribute('x', x);
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getPosition : function() {
|
getPosition : function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user