|
@ -82,7 +82,7 @@ exports.getSVGElement = function (elementType, JSONcontainer, svgContainer) { |
|
|
* @returns {*} |
|
|
* @returns {*} |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer) { |
|
|
|
|
|
|
|
|
exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer, insertBefore) { |
|
|
var element; |
|
|
var element; |
|
|
// allocate DOM element, if it doesnt yet exist, create one.
|
|
|
// allocate DOM element, if it doesnt yet exist, create one.
|
|
|
if (JSONcontainer.hasOwnProperty(elementType)) { // this element has been created before
|
|
|
if (JSONcontainer.hasOwnProperty(elementType)) { // this element has been created before
|
|
@ -94,14 +94,24 @@ exports.getDOMElement = function (elementType, JSONcontainer, DOMContainer) { |
|
|
else { |
|
|
else { |
|
|
// create a new element and add it to the SVG
|
|
|
// create a new element and add it to the SVG
|
|
|
element = document.createElement(elementType); |
|
|
element = document.createElement(elementType); |
|
|
DOMContainer.appendChild(element); |
|
|
|
|
|
|
|
|
if (insertBefore !== undefined) { |
|
|
|
|
|
DOMContainer.insertBefore(element, insertBefore); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
DOMContainer.appendChild(element); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
// create a new element and add it to the SVG, also create a new object in the svgElements to keep track of it.
|
|
|
// create a new element and add it to the SVG, also create a new object in the svgElements to keep track of it.
|
|
|
element = document.createElement(elementType); |
|
|
element = document.createElement(elementType); |
|
|
JSONcontainer[elementType] = {used: [], redundant: []}; |
|
|
JSONcontainer[elementType] = {used: [], redundant: []}; |
|
|
DOMContainer.appendChild(element); |
|
|
|
|
|
|
|
|
if (insertBefore !== undefined) { |
|
|
|
|
|
DOMContainer.insertBefore(element, insertBefore); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
DOMContainer.appendChild(element); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
JSONcontainer[elementType].used.push(element); |
|
|
JSONcontainer[elementType].used.push(element); |
|
|
return element; |
|
|
return element; |
|
|