/* Embedded SVG-edit API General usage: - Have an iframe somewhere pointing to a version of svg-edit > r1000 - Initialize the magic with: var svgCanvas = new EmbeddedSVGEdit(window.frames['svgedit']); - Pass functions in this format: svgCanvas.setSvgString("string") - Or if a callback is needed: svgCanvas.setSvgString("string")(function(data, error){ if(error){ //there was an error }else{ //handle data } }) Everything is done with the same API as the real svg-edit, and all documentation is unchanged. This file depends on the postMessage API which can only support JSON-serializable arguments and return values, so, for example, arguments whose value is "undefined", a function, a non-finite number, or a built-in object like Date(), RegExp(), etc. will most likely not behave as expected. In such a case one may need to host the SVG editor on the same domain and reference the JavaScript methods on the frame itself. The only other difference is when handling returns: the callback notation is used instead. var blah = new EmbeddedSVGEdit(window.frames['svgedit']); blah.clearSelection("woot","blah",1337,[1,2,3,4,5,"moo"],-42,{a: "tree",b:6, c: 9})(function(){console.log("GET DATA",arguments)}) */ (function () {'use strict'; var cbid = 0; function getCallbackSetter (d) { return function(){ var t = this, // new callback args = [].slice.call(arguments), cbid = t.send(d, args, function(){}); // the callback (currently it's nothing, but will be set later) return function(newcallback){ t.callbacks[cbid] = newcallback; // set callback }; }; } function EmbeddedSVGEdit(frame){ if (!(this instanceof EmbeddedSVGEdit)) { // Allow invocation without "new" keyword return new EmbeddedSVGEdit(frame); } // initialize communication this.frame = frame; this.callbacks = {}; // successor to stack //List of functions extracted with this: //Run in firebug on http://svg-edit.googlecode.com/svn/trunk/docs/files/svgcanvas-js.html //for(var i=0,q=[],f = document.querySelectorAll("div.CFunction h3.CTitle a");i