41 lines
911 B
JavaScript
41 lines
911 B
JavaScript
|
|
SVG.Bare = SVG.invent({
|
|
// Initialize
|
|
create: function(element, inherit) {
|
|
// construct element
|
|
this.constructor.call(this, SVG.create(element))
|
|
|
|
// inherit custom methods
|
|
if (inherit)
|
|
for (var method in inherit.prototype)
|
|
if (typeof inherit.prototype[method] === 'function')
|
|
this[method] = inherit.prototype[method]
|
|
}
|
|
|
|
// Inherit from
|
|
, inherit: SVG.Element
|
|
|
|
// Add methods
|
|
, extend: {
|
|
// Insert some plain text
|
|
words: function(text) {
|
|
// remove contents
|
|
while (this.node.hasChildNodes())
|
|
this.node.removeChild(this.node.lastChild)
|
|
|
|
// create text node
|
|
this.node.appendChild(document.createTextNode(text))
|
|
|
|
return this
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
SVG.extend(SVG.Parent, {
|
|
// Create an element that is not described by SVG.js
|
|
element: function(element, inherit) {
|
|
return this.put(new SVG.Bare(element, inherit))
|
|
}
|
|
})
|