3 * The SVG element.. - with a 'g' subelement, that can handle moving / panning etc..
6 * The SVG element is the only element that handles events
7 * if you click on it, it will look for roo-svg-observable in the event handler and pass on events to children.
14 Roo.namespace('Roo.svg');
16 Roo.svg.Canvas = function(cfg)
18 Roo.svg.Canvas.superclass.constructor.call(this, cfg);
27 Roo.extend(Roo.svg.Canvas, Roo.bootstrap.Component, {
30 height : 100, // changeable...
33 getAutoCreate : function(){
38 xmlns: "http://www.w3.org/2000/svg",
52 initEvents: function()
54 Roo.svg.Canvas.superclass.initEvents.call(this);
57 this.el.on('click', this.relayEvent, this);
58 this.el.on('dblclick', this.relayEvent, this);
59 this.el.on('context', this.relayEvent, this); // ??? any others
60 this.g = this.el.select('g', true).first();
65 relayEvent: function(e)
68 var cel = e.getTarget().findParent('roo-svg-observable', false, true);
69 if (typeof(cel.listeners[e.type]) == 'undefined') {
70 this.fireEvent(e.type)
73 cel.listeners[e.type].fire(e, cel);
78 fitToParent : function()
80 // should it fit Horizontal - as per this?
81 // or fit full ? // in which case pan/zoom done by drag?
83 if (!this.el.dom.parentNode) { // check if this Element still exists
86 var p = Roo.get(this.el.dom.parentNode);
87 var gs = this.g.dom.getBBox();
89 var x = p.getComputedWidth() - p.getFrameWidth('lr');
92 height : (gs.height / gs.width) //p.getComputedHeight() - p.getFrameWidth('tb')