Added support for plugging in event handlers - will allow the wave gadget to receive state notifications without any wave specific code in the editor itself
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@43 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
d5ba10b166
commit
4d33fb925e
|
@ -32,12 +32,19 @@ function SvgCanvas(doc)
|
|||
var freehand_min_y = null;
|
||||
var freehand_max_y = null;
|
||||
var selected = null;
|
||||
var events = {};
|
||||
|
||||
// private functions
|
||||
var getId = function() {
|
||||
return "svg_"+obj_num;
|
||||
}
|
||||
|
||||
var call = function(event, arg) {
|
||||
if (events[event]) {
|
||||
return events[event](this,arg);
|
||||
}
|
||||
}
|
||||
|
||||
var assignAttributes = function(node, attrs) {
|
||||
for (i in attrs) {
|
||||
node.setAttributeNS(null, i, attrs[i]);
|
||||
|
@ -66,6 +73,7 @@ function SvgCanvas(doc)
|
|||
assignAttributes(shape, data.attr);
|
||||
cleanupElement(shape);
|
||||
svgdoc.documentElement.appendChild(shape);
|
||||
call("changed",shape);
|
||||
}
|
||||
|
||||
var svgToString = function(elem, indent) {
|
||||
|
@ -393,6 +401,7 @@ function SvgCanvas(doc)
|
|||
} else if (element != null) {
|
||||
element.setAttribute("opacity", current_opacity);
|
||||
cleanupElement(element);
|
||||
call("changed",element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,6 +491,10 @@ function SvgCanvas(doc)
|
|||
current_stroke_opacity = val;
|
||||
}
|
||||
|
||||
this.bind = function(event, f) {
|
||||
events[event] = f;
|
||||
}
|
||||
|
||||
this.setup = function(evt) {
|
||||
assignAttributes(svgroot, {
|
||||
"onmouseup": "svgcanvas.mouseUp(evt)",
|
||||
|
|
Loading…
Reference in New Issue