{I" class:ETI"ProcessedAsset;FI"logical_path;TI"#method-draw-js/src/embedapi.js;FI" pathname;TI"m/Users/jeff/workspace/windmill_labs/method-draw/vendor/assets/javascripts/method-draw-js/src/embedapi.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+)6ƒTI" length;Ti¡I" digest;TI"%43a86243e3c6a3867ea678cdd77e4839;FI" source;TI"¡/* function embedded_svg_edit(frame){ //initialize communication this.frame = frame; this.stack = []; //callback stack var editapi = this; window.addEventListener("message", function(e){ if(e.data.substr(0,5) == "ERROR"){ editapi.stack.splice(0,1)[0](e.data,"error") }else{ editapi.stack.splice(0,1)[0](e.data) } }, false) } embedded_svg_edit.prototype.call = function(code, callback){ this.stack.push(callback); this.frame.contentWindow.postMessage(code,"*"); } embedded_svg_edit.prototype.getSvgString = function(callback){ this.call("svgCanvas.getSvgString()",callback) } embedded_svg_edit.prototype.setSvgString = function(svg){ this.call("svgCanvas.setSvgString('"+svg.replace(/'/g, "\\'")+"')"); } */ /* 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 embedded_svg_edit(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. The only difference is when handling returns, the callback notation is used instead. var blah = new embedded_svg_edit(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 embedded_svg_edit(frame){ //initialize communication this.frame = frame; //this.stack = [] //callback stack this.callbacks = {}; //successor to stack this.encode = embedded_svg_edit.encode; //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