summaryrefslogtreecommitdiffstats
path: root/src/bare.js
blob: a0b1ee3256e61045913e6954f56eb4ff44176c49 (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
44
45
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')
					element[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))
	}
	// Add symbol element
, symbol: function() {
		return this.defs().element('symbol', SVG.Container)
	}

})