blob: 393ce6ee88bdbd738422fa9aee88e11b277e733e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
SVG.Bare = SVG.invent({
// Initialize
create: function (element, inherit) {
// construct element
SVG.Element.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))
}
})
|