fix for blank grid

master
Mark MacKay 2012-08-08 01:04:58 -05:00
parent 86f24f713f
commit 6c83a8d487
7 changed files with 34 additions and 28 deletions

BIN
editor/.DS_Store vendored

Binary file not shown.

View File

@ -171,7 +171,7 @@ svgEditor.addExtension("view_grid", function(s) {
if (gr) {
svgEditor.curConfig.showGrid = showGrid = true;
$('#view_grid').addClass('push_button_pressed');
$('#canvasGrid').attr('display', 'normal');
$('#canvasGrid').attr('display', 'inline');
updateGrid(svgCanvas.getZoom());
}
else {

View File

@ -5199,6 +5199,9 @@ this.svgCanvasToString = function() {
selectOnly([current_group]);
}
//hide grid, otherwise shows a black canvas
$('#canvasGrid').attr('display', 'none');
var naked_svgs = [];
// Unwrap gsvg if it has no special attributes (only id and style)

View File

@ -301,18 +301,18 @@ break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},conve
"z";break;case 12:O-=g;case 13:if(w){g+=O;ea="l"}else{O+=g;g=O;ea="L"}ua([[O,n]]);break;case 14:Z-=n;case 15:if(w){n+=Z;ea="l"}else{Z+=n;n=Z;ea="L"}ua([[g,Z]]);break;case 2:case 4:case 18:O-=g;Z-=n;case 5:case 3:if(A&&E.getItem(F-1).pathSegType===1&&!w){g=A[0];n=A[1]}case 19:if(w){g+=O;n+=Z}else{O+=g;Z+=n;g=O;n=Z}if(oa===3)A=[g,n];ua([[O,Z]]);break;case 6:O-=g;aa-=g;X-=g;Z-=n;U-=n;ha-=n;case 7:if(w){g+=O;n+=Z}else{O+=g;aa+=g;X+=g;Z+=n;U+=n;ha+=n;g=O;n=Z}ua([[aa,U],[X,ha],[O,Z]]);break;case 8:O-=g;
aa-=g;Z-=n;U-=n;case 9:if(w){g+=O;n+=Z}else{O+=g;aa+=g;Z+=n;U+=n;g=O;n=Z}ua([[aa,U],[O,Z]]);break;case 10:O-=g;Z-=n;case 11:if(w){g+=O;n+=Z}else{O+=g;Z+=n;g=O;n=Z}ua([[I.r1,I.r2]],[I.angle,I.largeArcFlag?1:0,I.sweepFlag?1:0],[O,Z]);break;case 16:O-=g;X-=g;Z-=n;ha-=n;case 17:if(w){g+=O;n+=Z}else{O+=g;X+=g;Z+=n;ha+=n;g=O;n=Z}ua([[X,ha],[O,Z]])}}return s}}}(),Nb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],m=0,C=["fill","stroke",
"filter","marker-start","marker-mid","marker-end"],z=C.length,G=l.getElementsByTagNameNS(b,"*"),D=G.length,w=0;w<D;w++){for(var E=G[w],J=0;J<z;J++){var g=ja(E.getAttribute(C[J]));g&&k.push(g.substr(1))}(E=ca(E))&&E.indexOf("#")===0&&k.push(E.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(w=e.length;w--;){C=e[w];z=C.id;if(k.indexOf(z)<0){sb[z]=C;C.parentNode.removeChild(C);m++}}return m};this.svgCanvasToString=function(){for(;Nb()>0;);La.clear(true);
$.each(l.childNodes,function(m,C){m&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&l.insertBefore(C,l.firstChild)});if(K){Gb();$a([K])}var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,C=m.length,z=0;z<C;z++)if(m[z].nodeName=="id"||m[z].nodeName=="style")C--;if(C<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var k=this.svgToString(l,0);e.length&&$(e).each(function(){wb(this)});return k};this.svgToString=function(e,k){var m=[],C=svgedit.utilities.toXml,z=
o.baseUnit,G=RegExp("^-?[\\d\\.]+"+z+"$");if(e){la(e);var D=e.attributes,w,E,J=e.childNodes;for(E=0;E<k;E++)m.push(" ");m.push("<");m.push(e.nodeName);if(e.id==="svgcontent"){E=zb();if(z!=="px"){E.w=svgedit.units.convertUnit(E.w,z)+z;E.h=svgedit.units.convertUnit(E.h,z)+z}m.push(' width="'+E.w+'" height="'+E.h+'" xmlns="'+b+'"');var g={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(F,I){var O=I.namespaceURI;if(O&&!g[O]&&za[O]!=="xmlns"&&za[O]!=="xml"){g[O]=true;m.push(" xmlns:"+
za[O]+'="'+O+'"')}})});E=D.length;for(z=["width","height","xmlns","x","y","viewBox","id","overflow"];E--;){w=D.item(E);var n=C(w.nodeValue);if(w.nodeName.indexOf("xmlns:")!==0)if(n!=""&&z.indexOf(w.localName)==-1)if(!w.namespaceURI||za[w.namespaceURI]){m.push(" ");m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var s=["-moz-math-font-style","_moz-math-font-style"];for(E=D.length-1;E>=0;E--){w=D.item(E);n=C(w.nodeValue);if(!(s.indexOf(w.localName)>=
0))if(n!="")if(n.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&n.indexOf("se_")===0)){m.push(" ");if(w.localName==="d")n=La.convertPath(e,true);if(isNaN(n)){if(G.test(n))n=svgedit.units.shortFloat(n)+z}else n=svgedit.units.shortFloat(n);if(cb.apply&&e.nodeName==="image"&&w.localName==="href"&&cb.images&&cb.images==="embed"){var A=Wa[n];if(A)n=A}if(!w.namespaceURI||w.namespaceURI==b||za[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");
k++;D=false;for(E=0;E<J.length;E++){z=J.item(E);switch(z.nodeType){case 1:m.push("\n");m.push(this.svgToString(J.item(E),k));break;case 3:z=z.nodeValue.replace(/^\s+|\s+$/g,"");if(z!=""){D=true;m.push(C(z)+"")}break;case 4:m.push("\n");m.push(Array(k+1).join(" "));m.push("<![CDATA[");m.push(z.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("<!--");m.push(z.data);m.push("--\>")}}k--;if(!D){m.push("\n");for(E=0;E<k;E++)m.push(" ")}m.push("</");m.push(e.nodeName);
m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var m=document.createElement("canvas");m.width=this.width;m.height=this.height;m.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=m.toDataURL().replace(";base64",C+";base64");Wa[e]=C}catch(z){Wa[e]=false}Ba=e;k&&k(Wa[e])}).attr("src",e)};this.setGoodImage=function(e){Ba=e};this.open=function(){};this.save=function(e){Pa();e&&$.extend(cb,e);cb.apply=true;
e=this.svgCanvasToString();L("saved",e)};this.rasterExport=function(){Pa();var e=[],k={feGaussianBlur:Ua.exportNoBlur,foreignObject:Ua.exportNoforeignObject,"[stroke-dasharray]":Ua.exportNoDashArray},m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=Ua.exportNoText;$.each(k,function(C,z){m.find(C).length&&e.push(z)});k=this.svgCanvasToString();L("exported",{svg:k,issues:e})};this.getSvgString=function(){cb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>
0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Kb=this.uniquifyElems=function(e){var k={},m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(w){if(w.nodeType==1){if(w.id){w.id in k||(k[w.id]={elem:null,attrs:[],hrefs:[]});k[w.id].elem=w}$.each(tb,function(J,g){var n=w.getAttributeNode(g);if(n){var s=svgedit.utilities.getUrlFromAttr(n.value);if(s=s?s.substr(1):null){s in k||(k[s]=
{elem:null,attrs:[],hrefs:[]});k[s].attrs.push(n)}}});var E=svgedit.utilities.getHref(w);if(E&&m.indexOf(w.nodeName)>=0)if(E=E.substr(1)){E in k||(k[E]={elem:null,attrs:[],hrefs:[]});k[E].hrefs.push(w)}}});for(var C in k)if(C){var z=k[C].elem;if(z){e=ka();z.id=e;z=k[C].attrs;for(var G=z.length;G--;){var D=z[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}z=k[C].hrefs;for(G=z.length;G--;)svgedit.utilities.setHref(z[G],"#"+e)}}},yb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=
k.find("use");k.each(function(){var m=ca(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",m).data("ref",m)}})},Lb=this.convertGradients=function(e){var k=$(e).find("linearGradient, radialGradient");if(!k.length&&svgedit.browser.isWebkit())k=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});k.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+
this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),z=this.gradientTransform.baseVal;if(z&&z.numberOfItems>0){var G=fa(z).matrix;z=M(C.x1,C.y1,G);G=M(C.x2,C.y2,G);C.x1=z.x;C.y1=z.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-m.x)/m.width,y1:(C.y1-m.y)/m.height,x2:(C.x2-m.x)/m.width,y2:(C.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Ob=this.convertToGroup=
function(e){e||(e=H[0]);var k=$(e),m=new Da,C;if(k.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");C=T(e);var z=d.createSVGTransform();z.setTranslate(m.x,m.y);C.appendItem(z);Sa(e);L("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");z=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");z.x-=+G[0];z.y-=+G[1]}C+=" translate("+(z.x||0)+","+(z.y||0)+")";z=k.prev();m.addSubCommand(new Ja(k[0],
$.each(l.childNodes,function(m,C){m&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&l.insertBefore(C,l.firstChild)});if(K){Gb();$a([K])}$("#canvasGrid").attr("display","none");var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,C=m.length,z=0;z<C;z++)if(m[z].nodeName=="id"||m[z].nodeName=="style")C--;if(C<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var k=this.svgToString(l,0);e.length&&$(e).each(function(){wb(this)});return k};this.svgToString=function(e,
k){var m=[],C=svgedit.utilities.toXml,z=o.baseUnit,G=RegExp("^-?[\\d\\.]+"+z+"$");if(e){la(e);var D=e.attributes,w,E,J=e.childNodes;for(E=0;E<k;E++)m.push(" ");m.push("<");m.push(e.nodeName);if(e.id==="svgcontent"){E=zb();if(z!=="px"){E.w=svgedit.units.convertUnit(E.w,z)+z;E.h=svgedit.units.convertUnit(E.h,z)+z}m.push(' width="'+E.w+'" height="'+E.h+'" xmlns="'+b+'"');var g={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(F,I){var O=I.namespaceURI;if(O&&!g[O]&&za[O]!=="xmlns"&&
za[O]!=="xml"){g[O]=true;m.push(" xmlns:"+za[O]+'="'+O+'"')}})});E=D.length;for(z=["width","height","xmlns","x","y","viewBox","id","overflow"];E--;){w=D.item(E);var n=C(w.nodeValue);if(w.nodeName.indexOf("xmlns:")!==0)if(n!=""&&z.indexOf(w.localName)==-1)if(!w.namespaceURI||za[w.namespaceURI]){m.push(" ");m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var s=["-moz-math-font-style","_moz-math-font-style"];for(E=D.length-1;E>=0;E--){w=D.item(E);
n=C(w.nodeValue);if(!(s.indexOf(w.localName)>=0))if(n!="")if(n.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&n.indexOf("se_")===0)){m.push(" ");if(w.localName==="d")n=La.convertPath(e,true);if(isNaN(n)){if(G.test(n))n=svgedit.units.shortFloat(n)+z}else n=svgedit.units.shortFloat(n);if(cb.apply&&e.nodeName==="image"&&w.localName==="href"&&cb.images&&cb.images==="embed"){var A=Wa[n];if(A)n=A}if(!w.namespaceURI||w.namespaceURI==b||za[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(n);
m.push('"')}}}}if(e.hasChildNodes()){m.push(">");k++;D=false;for(E=0;E<J.length;E++){z=J.item(E);switch(z.nodeType){case 1:m.push("\n");m.push(this.svgToString(J.item(E),k));break;case 3:z=z.nodeValue.replace(/^\s+|\s+$/g,"");if(z!=""){D=true;m.push(C(z)+"")}break;case 4:m.push("\n");m.push(Array(k+1).join(" "));m.push("<![CDATA[");m.push(z.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("<!--");m.push(z.data);m.push("--\>")}}k--;if(!D){m.push("\n");for(E=0;E<
k;E++)m.push(" ")}m.push("</");m.push(e.nodeName);m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var m=document.createElement("canvas");m.width=this.width;m.height=this.height;m.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=m.toDataURL().replace(";base64",C+";base64");Wa[e]=C}catch(z){Wa[e]=false}Ba=e;k&&k(Wa[e])}).attr("src",e)};this.setGoodImage=function(e){Ba=e};this.open=function(){};this.save=
function(e){Pa();e&&$.extend(cb,e);cb.apply=true;e=this.svgCanvasToString();L("saved",e)};this.rasterExport=function(){Pa();var e=[],k={feGaussianBlur:Ua.exportNoBlur,foreignObject:Ua.exportNoforeignObject,"[stroke-dasharray]":Ua.exportNoDashArray},m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=Ua.exportNoText;$.each(k,function(C,z){m.find(C).length&&e.push(z)});k=this.svgCanvasToString();L("exported",{svg:k,issues:e})};this.getSvgString=function(){cb.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Kb=this.uniquifyElems=function(e){var k={},m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(w){if(w.nodeType==1){if(w.id){w.id in k||(k[w.id]={elem:null,attrs:[],hrefs:[]});k[w.id].elem=w}$.each(tb,function(J,g){var n=w.getAttributeNode(g);if(n){var s=svgedit.utilities.getUrlFromAttr(n.value);
if(s=s?s.substr(1):null){s in k||(k[s]={elem:null,attrs:[],hrefs:[]});k[s].attrs.push(n)}}});var E=svgedit.utilities.getHref(w);if(E&&m.indexOf(w.nodeName)>=0)if(E=E.substr(1)){E in k||(k[E]={elem:null,attrs:[],hrefs:[]});k[E].hrefs.push(w)}}});for(var C in k)if(C){var z=k[C].elem;if(z){e=ka();z.id=e;z=k[C].attrs;for(var G=z.length;G--;){var D=z[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}z=k[C].hrefs;for(G=z.length;G--;)svgedit.utilities.setHref(z[G],"#"+e)}}},yb=this.setUseData=function(e){var k=
$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var m=ca(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",m).data("ref",m)}})},Lb=this.convertGradients=function(e){var k=$(e).find("linearGradient, radialGradient");if(!k.length&&svgedit.browser.isWebkit())k=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});k.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+
this.id+')"],[stroke="url(#'+this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),z=this.gradientTransform.baseVal;if(z&&z.numberOfItems>0){var G=fa(z).matrix;z=M(C.x1,C.y1,G);G=M(C.x2,C.y2,G);C.x1=z.x;C.y1=z.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-m.x)/m.width,y1:(C.y1-m.y)/m.height,x2:(C.x2-m.x)/m.width,y2:(C.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},
Ob=this.convertToGroup=function(e){e||(e=H[0]);var k=$(e),m=new Da,C;if(k.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");C=T(e);var z=d.createSVGTransform();z.setTranslate(m.x,m.y);C.appendItem(z);Sa(e);L("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");z=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");z.x-=+G[0];z.y-=+G[1]}C+=" translate("+(z.x||0)+","+(z.y||0)+")";z=k.prev();m.addSubCommand(new Ja(k[0],
k[0].nextSibling,k[0].parentNode));k.remove();G=$(l).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,w=0;w<D.length;w++)k.appendChild(D[w].cloneNode(true));if(svgedit.browser.isGecko()){D=$(ib()).children("linearGradient,radialGradient,pattern").clone();$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Kb(k);svgedit.browser.isGecko()&&$(ib()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();z.after(k);if(C){if(!G){z=e.nextSibling;
C.removeChild(e);m.addSubCommand(new Ja(e,z,C))}m.addSubCommand(new Ha(k))}yb(k);svgedit.browser.isGecko()?Lb(ib()):Lb(k);svgedit.utilities.walkTreePost(k,function(E){try{Sa(E)}catch(J){console.log(J)}});$(k).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});$a([k]);(e=Fb(k,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);
this.prepareSvg(k);var m=new Da("Change Source"),C=l.nextSibling,z=d.removeChild(l);m.addSubCommand(new Ja(z,C,d));l=f.adoptNode?f.adoptNode(k.documentElement):f.importNode(k.documentElement,true);d.appendChild(l);var G=$(l);c.current_drawing_=new svgedit.draw.Drawing(l,v);var D=B().getNonce();D?L("setnonce",D):L("unsetnonce");G.find("image").each(function(){var A=this;Db(A);var F=ca(this);if(F.indexOf("data:")===0){var I=F.match(/svgedit_url=(.*?);/);if(I){var O=decodeURIComponent(I[1]);$(new Image).load(function(){A.setAttributeNS("http://www.w3.org/1999/xlink",
@ -662,7 +662,7 @@ l(B,"stroke-linejoin",b.strokeLinejoin);v.addSubCommand(new h(B,d));d={}});u=o(b
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,v);l.lineTo(0.5,0);l.moveTo(v,0.5);l.lineTo(0,0.5);l.stroke();B=B.toDataURL("image/png");f.setAttribute("width",v);f.setAttribute("height",v);f.parentNode.setAttribute("width",v);f.parentNode.setAttribute("height",v);svgCanvas.setHref(f,B)}if(!document.getElementById("canvasGrid")){var h=document.getElementById("svgcanvas").ownerDocument,b=false;a=a.assignAttributes;var o=document.createElement("canvas");$(o).hide().appendTo("body");var u=h.createElementNS("http://www.w3.org/2000/svg",
"g");a(u,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var c=$("#canvas_background");c.after(u);u=h.createElementNS("http://www.w3.org/2000/svg","pattern");a(u,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var f=h.createElementNS("http://www.w3.org/2000/svg","image");a(f,{x:0,y:0,width:100,height:100});u.appendChild(f);$("#svgroot defs").append(u);h=h.createElementNS("http://www.w3.org/2000/svg","rect");a(h,{width:"100%",height:"100%",
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(h)}return{name:"view_grid",zoomChanged:function(d){b&&p(d)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){svgEditor.curConfig.showGrid=b=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
b=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(N){var H=q[N];if(H){K=H;H.buttons.length||h(N,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+N+".json",function(S){K=q[N]={data:S.data,size:S.size,fill:S.fill};h(N,S);a()})}}function h(N,H){var S=K.size||300,T=K.fill||false,M=S*0.05;M=[-M,-M,S+M*2,S+M*2].join(" ");S=T?0:S/30;S=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
b=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","inline");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(N){var H=q[N];if(H){K=H;H.buttons.length||h(N,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+N+".json",function(S){K=q[N]={data:S.data,size:S.size,fill:S.fill};h(N,S);a()})}}function h(N,H){var S=K.size||300,T=K.fill||false,M=S*0.05;M=[-M,-M,S+M*2,S+M*2].join(" ");S=T?0:S/30;S=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
M+'"><path fill="#333" stroke="transparent" stroke-width="'+S+'" /></svg></svg>',"text/xml");S.documentElement.setAttribute("width",40);S.documentElement.setAttribute("height",40);S=$(document.importNode(S.documentElement,true));T=H.data;K.buttons=[];for(var ga in T){M=T[ga];var pa=S.clone();pa.find("path").attr("d",M);M=pa.wrap('<div class="tool_button">').parent().attr({id:R+"_"+ga,title:ga});K.buttons.push(M[0])}}var b,o,u=svgEditor.canvas,c,f,d,l=u.getRootElem(),v={},B={basic:"Basic",object:"Objects",
symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},q={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z",
triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",

View File

@ -171,7 +171,7 @@ svgEditor.addExtension("view_grid", function(s) {
if (gr) {
svgEditor.curConfig.showGrid = showGrid = true;
$('#view_grid').addClass('push_button_pressed');
$('#canvasGrid').attr('display', 'normal');
$('#canvasGrid').attr('display', 'inline');
updateGrid(svgCanvas.getZoom());
}
else {

View File

@ -5199,6 +5199,9 @@ this.svgCanvasToString = function() {
selectOnly([current_group]);
}
//hide grid, otherwise shows a black canvas
$('#canvasGrid').attr('display', 'none');
var naked_svgs = [];
// Unwrap gsvg if it has no special attributes (only id and style)

View File

@ -301,18 +301,18 @@ break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},conve
"z";break;case 12:O-=g;case 13:if(w){g+=O;ea="l"}else{O+=g;g=O;ea="L"}ua([[O,n]]);break;case 14:Z-=n;case 15:if(w){n+=Z;ea="l"}else{Z+=n;n=Z;ea="L"}ua([[g,Z]]);break;case 2:case 4:case 18:O-=g;Z-=n;case 5:case 3:if(A&&E.getItem(F-1).pathSegType===1&&!w){g=A[0];n=A[1]}case 19:if(w){g+=O;n+=Z}else{O+=g;Z+=n;g=O;n=Z}if(oa===3)A=[g,n];ua([[O,Z]]);break;case 6:O-=g;aa-=g;X-=g;Z-=n;U-=n;ha-=n;case 7:if(w){g+=O;n+=Z}else{O+=g;aa+=g;X+=g;Z+=n;U+=n;ha+=n;g=O;n=Z}ua([[aa,U],[X,ha],[O,Z]]);break;case 8:O-=g;
aa-=g;Z-=n;U-=n;case 9:if(w){g+=O;n+=Z}else{O+=g;aa+=g;Z+=n;U+=n;g=O;n=Z}ua([[aa,U],[O,Z]]);break;case 10:O-=g;Z-=n;case 11:if(w){g+=O;n+=Z}else{O+=g;Z+=n;g=O;n=Z}ua([[I.r1,I.r2]],[I.angle,I.largeArcFlag?1:0,I.sweepFlag?1:0],[O,Z]);break;case 16:O-=g;X-=g;Z-=n;ha-=n;case 17:if(w){g+=O;n+=Z}else{O+=g;X+=g;Z+=n;ha+=n;g=O;n=Z}ua([[X,ha],[O,Z]])}}return s}}}(),Nb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],m=0,C=["fill","stroke",
"filter","marker-start","marker-mid","marker-end"],z=C.length,G=l.getElementsByTagNameNS(b,"*"),D=G.length,w=0;w<D;w++){for(var E=G[w],J=0;J<z;J++){var g=ja(E.getAttribute(C[J]));g&&k.push(g.substr(1))}(E=ca(E))&&E.indexOf("#")===0&&k.push(E.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(w=e.length;w--;){C=e[w];z=C.id;if(k.indexOf(z)<0){sb[z]=C;C.parentNode.removeChild(C);m++}}return m};this.svgCanvasToString=function(){for(;Nb()>0;);La.clear(true);
$.each(l.childNodes,function(m,C){m&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&l.insertBefore(C,l.firstChild)});if(K){Gb();$a([K])}var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,C=m.length,z=0;z<C;z++)if(m[z].nodeName=="id"||m[z].nodeName=="style")C--;if(C<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var k=this.svgToString(l,0);e.length&&$(e).each(function(){wb(this)});return k};this.svgToString=function(e,k){var m=[],C=svgedit.utilities.toXml,z=
o.baseUnit,G=RegExp("^-?[\\d\\.]+"+z+"$");if(e){la(e);var D=e.attributes,w,E,J=e.childNodes;for(E=0;E<k;E++)m.push(" ");m.push("<");m.push(e.nodeName);if(e.id==="svgcontent"){E=zb();if(z!=="px"){E.w=svgedit.units.convertUnit(E.w,z)+z;E.h=svgedit.units.convertUnit(E.h,z)+z}m.push(' width="'+E.w+'" height="'+E.h+'" xmlns="'+b+'"');var g={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(F,I){var O=I.namespaceURI;if(O&&!g[O]&&za[O]!=="xmlns"&&za[O]!=="xml"){g[O]=true;m.push(" xmlns:"+
za[O]+'="'+O+'"')}})});E=D.length;for(z=["width","height","xmlns","x","y","viewBox","id","overflow"];E--;){w=D.item(E);var n=C(w.nodeValue);if(w.nodeName.indexOf("xmlns:")!==0)if(n!=""&&z.indexOf(w.localName)==-1)if(!w.namespaceURI||za[w.namespaceURI]){m.push(" ");m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var s=["-moz-math-font-style","_moz-math-font-style"];for(E=D.length-1;E>=0;E--){w=D.item(E);n=C(w.nodeValue);if(!(s.indexOf(w.localName)>=
0))if(n!="")if(n.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&n.indexOf("se_")===0)){m.push(" ");if(w.localName==="d")n=La.convertPath(e,true);if(isNaN(n)){if(G.test(n))n=svgedit.units.shortFloat(n)+z}else n=svgedit.units.shortFloat(n);if(cb.apply&&e.nodeName==="image"&&w.localName==="href"&&cb.images&&cb.images==="embed"){var A=Wa[n];if(A)n=A}if(!w.namespaceURI||w.namespaceURI==b||za[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");
k++;D=false;for(E=0;E<J.length;E++){z=J.item(E);switch(z.nodeType){case 1:m.push("\n");m.push(this.svgToString(J.item(E),k));break;case 3:z=z.nodeValue.replace(/^\s+|\s+$/g,"");if(z!=""){D=true;m.push(C(z)+"")}break;case 4:m.push("\n");m.push(Array(k+1).join(" "));m.push("<![CDATA[");m.push(z.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("<!--");m.push(z.data);m.push("--\>")}}k--;if(!D){m.push("\n");for(E=0;E<k;E++)m.push(" ")}m.push("</");m.push(e.nodeName);
m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var m=document.createElement("canvas");m.width=this.width;m.height=this.height;m.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=m.toDataURL().replace(";base64",C+";base64");Wa[e]=C}catch(z){Wa[e]=false}Ba=e;k&&k(Wa[e])}).attr("src",e)};this.setGoodImage=function(e){Ba=e};this.open=function(){};this.save=function(e){Pa();e&&$.extend(cb,e);cb.apply=true;
e=this.svgCanvasToString();L("saved",e)};this.rasterExport=function(){Pa();var e=[],k={feGaussianBlur:Ua.exportNoBlur,foreignObject:Ua.exportNoforeignObject,"[stroke-dasharray]":Ua.exportNoDashArray},m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=Ua.exportNoText;$.each(k,function(C,z){m.find(C).length&&e.push(z)});k=this.svgCanvasToString();L("exported",{svg:k,issues:e})};this.getSvgString=function(){cb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>
0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Kb=this.uniquifyElems=function(e){var k={},m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(w){if(w.nodeType==1){if(w.id){w.id in k||(k[w.id]={elem:null,attrs:[],hrefs:[]});k[w.id].elem=w}$.each(tb,function(J,g){var n=w.getAttributeNode(g);if(n){var s=svgedit.utilities.getUrlFromAttr(n.value);if(s=s?s.substr(1):null){s in k||(k[s]=
{elem:null,attrs:[],hrefs:[]});k[s].attrs.push(n)}}});var E=svgedit.utilities.getHref(w);if(E&&m.indexOf(w.nodeName)>=0)if(E=E.substr(1)){E in k||(k[E]={elem:null,attrs:[],hrefs:[]});k[E].hrefs.push(w)}}});for(var C in k)if(C){var z=k[C].elem;if(z){e=ka();z.id=e;z=k[C].attrs;for(var G=z.length;G--;){var D=z[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}z=k[C].hrefs;for(G=z.length;G--;)svgedit.utilities.setHref(z[G],"#"+e)}}},yb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=
k.find("use");k.each(function(){var m=ca(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",m).data("ref",m)}})},Lb=this.convertGradients=function(e){var k=$(e).find("linearGradient, radialGradient");if(!k.length&&svgedit.browser.isWebkit())k=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});k.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+
this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),z=this.gradientTransform.baseVal;if(z&&z.numberOfItems>0){var G=fa(z).matrix;z=M(C.x1,C.y1,G);G=M(C.x2,C.y2,G);C.x1=z.x;C.y1=z.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-m.x)/m.width,y1:(C.y1-m.y)/m.height,x2:(C.x2-m.x)/m.width,y2:(C.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Ob=this.convertToGroup=
function(e){e||(e=H[0]);var k=$(e),m=new Da,C;if(k.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");C=T(e);var z=d.createSVGTransform();z.setTranslate(m.x,m.y);C.appendItem(z);Sa(e);L("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");z=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");z.x-=+G[0];z.y-=+G[1]}C+=" translate("+(z.x||0)+","+(z.y||0)+")";z=k.prev();m.addSubCommand(new Ja(k[0],
$.each(l.childNodes,function(m,C){m&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&l.insertBefore(C,l.firstChild)});if(K){Gb();$a([K])}$("#canvasGrid").attr("display","none");var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,C=m.length,z=0;z<C;z++)if(m[z].nodeName=="id"||m[z].nodeName=="style")C--;if(C<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var k=this.svgToString(l,0);e.length&&$(e).each(function(){wb(this)});return k};this.svgToString=function(e,
k){var m=[],C=svgedit.utilities.toXml,z=o.baseUnit,G=RegExp("^-?[\\d\\.]+"+z+"$");if(e){la(e);var D=e.attributes,w,E,J=e.childNodes;for(E=0;E<k;E++)m.push(" ");m.push("<");m.push(e.nodeName);if(e.id==="svgcontent"){E=zb();if(z!=="px"){E.w=svgedit.units.convertUnit(E.w,z)+z;E.h=svgedit.units.convertUnit(E.h,z)+z}m.push(' width="'+E.w+'" height="'+E.h+'" xmlns="'+b+'"');var g={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(F,I){var O=I.namespaceURI;if(O&&!g[O]&&za[O]!=="xmlns"&&
za[O]!=="xml"){g[O]=true;m.push(" xmlns:"+za[O]+'="'+O+'"')}})});E=D.length;for(z=["width","height","xmlns","x","y","viewBox","id","overflow"];E--;){w=D.item(E);var n=C(w.nodeValue);if(w.nodeName.indexOf("xmlns:")!==0)if(n!=""&&z.indexOf(w.localName)==-1)if(!w.namespaceURI||za[w.namespaceURI]){m.push(" ");m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var s=["-moz-math-font-style","_moz-math-font-style"];for(E=D.length-1;E>=0;E--){w=D.item(E);
n=C(w.nodeValue);if(!(s.indexOf(w.localName)>=0))if(n!="")if(n.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&n.indexOf("se_")===0)){m.push(" ");if(w.localName==="d")n=La.convertPath(e,true);if(isNaN(n)){if(G.test(n))n=svgedit.units.shortFloat(n)+z}else n=svgedit.units.shortFloat(n);if(cb.apply&&e.nodeName==="image"&&w.localName==="href"&&cb.images&&cb.images==="embed"){var A=Wa[n];if(A)n=A}if(!w.namespaceURI||w.namespaceURI==b||za[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(n);
m.push('"')}}}}if(e.hasChildNodes()){m.push(">");k++;D=false;for(E=0;E<J.length;E++){z=J.item(E);switch(z.nodeType){case 1:m.push("\n");m.push(this.svgToString(J.item(E),k));break;case 3:z=z.nodeValue.replace(/^\s+|\s+$/g,"");if(z!=""){D=true;m.push(C(z)+"")}break;case 4:m.push("\n");m.push(Array(k+1).join(" "));m.push("<![CDATA[");m.push(z.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("<!--");m.push(z.data);m.push("--\>")}}k--;if(!D){m.push("\n");for(E=0;E<
k;E++)m.push(" ")}m.push("</");m.push(e.nodeName);m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var m=document.createElement("canvas");m.width=this.width;m.height=this.height;m.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=m.toDataURL().replace(";base64",C+";base64");Wa[e]=C}catch(z){Wa[e]=false}Ba=e;k&&k(Wa[e])}).attr("src",e)};this.setGoodImage=function(e){Ba=e};this.open=function(){};this.save=
function(e){Pa();e&&$.extend(cb,e);cb.apply=true;e=this.svgCanvasToString();L("saved",e)};this.rasterExport=function(){Pa();var e=[],k={feGaussianBlur:Ua.exportNoBlur,foreignObject:Ua.exportNoforeignObject,"[stroke-dasharray]":Ua.exportNoDashArray},m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=Ua.exportNoText;$.each(k,function(C,z){m.find(C).length&&e.push(z)});k=this.svgCanvasToString();L("exported",{svg:k,issues:e})};this.getSvgString=function(){cb.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Kb=this.uniquifyElems=function(e){var k={},m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(w){if(w.nodeType==1){if(w.id){w.id in k||(k[w.id]={elem:null,attrs:[],hrefs:[]});k[w.id].elem=w}$.each(tb,function(J,g){var n=w.getAttributeNode(g);if(n){var s=svgedit.utilities.getUrlFromAttr(n.value);
if(s=s?s.substr(1):null){s in k||(k[s]={elem:null,attrs:[],hrefs:[]});k[s].attrs.push(n)}}});var E=svgedit.utilities.getHref(w);if(E&&m.indexOf(w.nodeName)>=0)if(E=E.substr(1)){E in k||(k[E]={elem:null,attrs:[],hrefs:[]});k[E].hrefs.push(w)}}});for(var C in k)if(C){var z=k[C].elem;if(z){e=ka();z.id=e;z=k[C].attrs;for(var G=z.length;G--;){var D=z[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}z=k[C].hrefs;for(G=z.length;G--;)svgedit.utilities.setHref(z[G],"#"+e)}}},yb=this.setUseData=function(e){var k=
$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var m=ca(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",m).data("ref",m)}})},Lb=this.convertGradients=function(e){var k=$(e).find("linearGradient, radialGradient");if(!k.length&&svgedit.browser.isWebkit())k=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});k.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+
this.id+')"],[stroke="url(#'+this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),z=this.gradientTransform.baseVal;if(z&&z.numberOfItems>0){var G=fa(z).matrix;z=M(C.x1,C.y1,G);G=M(C.x2,C.y2,G);C.x1=z.x;C.y1=z.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-m.x)/m.width,y1:(C.y1-m.y)/m.height,x2:(C.x2-m.x)/m.width,y2:(C.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},
Ob=this.convertToGroup=function(e){e||(e=H[0]);var k=$(e),m=new Da,C;if(k.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");C=T(e);var z=d.createSVGTransform();z.setTranslate(m.x,m.y);C.appendItem(z);Sa(e);L("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");z=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");z.x-=+G[0];z.y-=+G[1]}C+=" translate("+(z.x||0)+","+(z.y||0)+")";z=k.prev();m.addSubCommand(new Ja(k[0],
k[0].nextSibling,k[0].parentNode));k.remove();G=$(l).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,w=0;w<D.length;w++)k.appendChild(D[w].cloneNode(true));if(svgedit.browser.isGecko()){D=$(ib()).children("linearGradient,radialGradient,pattern").clone();$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Kb(k);svgedit.browser.isGecko()&&$(ib()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();z.after(k);if(C){if(!G){z=e.nextSibling;
C.removeChild(e);m.addSubCommand(new Ja(e,z,C))}m.addSubCommand(new Ha(k))}yb(k);svgedit.browser.isGecko()?Lb(ib()):Lb(k);svgedit.utilities.walkTreePost(k,function(E){try{Sa(E)}catch(J){console.log(J)}});$(k).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});$a([k]);(e=Fb(k,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);
this.prepareSvg(k);var m=new Da("Change Source"),C=l.nextSibling,z=d.removeChild(l);m.addSubCommand(new Ja(z,C,d));l=f.adoptNode?f.adoptNode(k.documentElement):f.importNode(k.documentElement,true);d.appendChild(l);var G=$(l);c.current_drawing_=new svgedit.draw.Drawing(l,v);var D=B().getNonce();D?L("setnonce",D):L("unsetnonce");G.find("image").each(function(){var A=this;Db(A);var F=ca(this);if(F.indexOf("data:")===0){var I=F.match(/svgedit_url=(.*?);/);if(I){var O=decodeURIComponent(I[1]);$(new Image).load(function(){A.setAttributeNS("http://www.w3.org/1999/xlink",
@ -662,7 +662,7 @@ l(B,"stroke-linejoin",b.strokeLinejoin);v.addSubCommand(new h(B,d));d={}});u=o(b
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,v);l.lineTo(0.5,0);l.moveTo(v,0.5);l.lineTo(0,0.5);l.stroke();B=B.toDataURL("image/png");f.setAttribute("width",v);f.setAttribute("height",v);f.parentNode.setAttribute("width",v);f.parentNode.setAttribute("height",v);svgCanvas.setHref(f,B)}if(!document.getElementById("canvasGrid")){var h=document.getElementById("svgcanvas").ownerDocument,b=false;a=a.assignAttributes;var o=document.createElement("canvas");$(o).hide().appendTo("body");var u=h.createElementNS("http://www.w3.org/2000/svg",
"g");a(u,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var c=$("#canvas_background");c.after(u);u=h.createElementNS("http://www.w3.org/2000/svg","pattern");a(u,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var f=h.createElementNS("http://www.w3.org/2000/svg","image");a(f,{x:0,y:0,width:100,height:100});u.appendChild(f);$("#svgroot defs").append(u);h=h.createElementNS("http://www.w3.org/2000/svg","rect");a(h,{width:"100%",height:"100%",
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(h)}return{name:"view_grid",zoomChanged:function(d){b&&p(d)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){svgEditor.curConfig.showGrid=b=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
b=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(N){var H=q[N];if(H){K=H;H.buttons.length||h(N,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+N+".json",function(S){K=q[N]={data:S.data,size:S.size,fill:S.fill};h(N,S);a()})}}function h(N,H){var S=K.size||300,T=K.fill||false,M=S*0.05;M=[-M,-M,S+M*2,S+M*2].join(" ");S=T?0:S/30;S=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
b=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","inline");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(N){var H=q[N];if(H){K=H;H.buttons.length||h(N,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+N+".json",function(S){K=q[N]={data:S.data,size:S.size,fill:S.fill};h(N,S);a()})}}function h(N,H){var S=K.size||300,T=K.fill||false,M=S*0.05;M=[-M,-M,S+M*2,S+M*2].join(" ");S=T?0:S/30;S=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
M+'"><path fill="#333" stroke="transparent" stroke-width="'+S+'" /></svg></svg>',"text/xml");S.documentElement.setAttribute("width",40);S.documentElement.setAttribute("height",40);S=$(document.importNode(S.documentElement,true));T=H.data;K.buttons=[];for(var ga in T){M=T[ga];var pa=S.clone();pa.find("path").attr("d",M);M=pa.wrap('<div class="tool_button">').parent().attr({id:R+"_"+ga,title:ga});K.buttons.push(M[0])}}var b,o,u=svgEditor.canvas,c,f,d,l=u.getRootElem(),v={},B={basic:"Basic",object:"Objects",
symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},q={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z",
triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",