adding support for pinch zoom

master
Mark MacKay 2015-06-25 19:00:03 +02:00
parent b479d9f5a6
commit 326f134db2
10 changed files with 228 additions and 229 deletions

View File

@ -341,7 +341,7 @@ button.cancel,input.Cancel,input.cancel,input.jGraduate_Cancel,button.cancel{-we
#workarea.rect,#workarea.line,#workarea.ellipse,#workarea.path,#workarea.shapelib{cursor:crosshair}
#workarea.text{cursor:text}
#workarea.eyedropper{cursor:url(../images/eyedropper.png) 0 16,crosshair}
#workarea.fhpath{cursor:url(../images/pencil_cursor.png) 0 20,crosshair}
#workarea.fhpath{cursor:url(../images/pencil_cursor.png) 0 16,crosshair}
#workarea.rotate *{cursor:url(../images/rotate.png) 12 12,auto}
#workarea.select text,#workarea.multiselect text{cursor:default}
#workarea.n-resize *{cursor:n-resize!important}

View File

@ -241,104 +241,104 @@ $(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":D.points=e.getAt
function(e){if(I[0]!=null)for(var k=I.length,l=0;l<k;++l){var C=I[l];if(C==null)break;ra.releaseSelector(C);I[l]=null}e||M("selected",I)},qb=this.addToSelection=function(e,k){if(e.length!=0){for(var l=0;l<I.length;){if(I[l]==null)break;++l}for(var C=e.length;C--;){var A=e[C];if(A&&svgedit.utilities.getBBox(A)){if(A.tagName==="a"&&A.childNodes.length===1)A=A.firstChild;if(I.indexOf(A)==-1){I[l]=A;l++;A=ra.requestSelector(A);I.length>1&&A.showGrips(false)}}}M("selected",I);k||I.length==1?ra.requestSelector(I[0]).showGrips(true):
ra.requestSelector(I[0]).showGrips(false);for(I.sort(function(G,D){if(G&&D&&G.compareDocumentPosition)return 3-(D.compareDocumentPosition(G)&6);else if(G==null)return 1});I[0]==null;)I.shift(0)}},rb=this.selectOnly=function(e,k){xa(true);qb(e,k)};this.removeFromSelection=function(e){if(I[0]!=null)if(e.length!=0){var k=Array(I.length);j=0;len=I.length;for(var l=0;l<len;++l){var C=I[l];if(C)if(e.indexOf(C)==-1){k[j]=C;j++}else ra.releaseSelector(C)}I=k}};this.selectAllInCurrentLayer=function(){var e=
B().getCurrentLayer();if(e){Ha="select";rb($(L||e).children())}};var Bb=this.getMouseTarget=function(e){if(e==null||e.target==null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var k=B().getCurrentLayer();if([d,a,n,k].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return ra.selectorParentGroup;
for(;e.parentNode&&e.parentNode!==(L||k);)e=e.parentNode;return e};(function(){var e=null,k=null,l=null,C=null,A=null,G={},D={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(z){if(!c.spaceKey){var F=z.button===2;mb=n.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var h=N(z.pageX,z.pageY,mb),m=h.x*(isBotchedZoom?1:q);h=h.y*(isBotchedZoom?1:q);z.preventDefault();if(F)Ha="select";m=m/q;h=h/q;var o=Bb(z);if(o.tagName==="a"&&o.childNodes.length===1)o=o.firstChild;var u=
C=k=m,E=A=l=h;if(p.gridSnapping){m=va(m);h=va(h);k=va(k);l=va(l)}if(o==ra.selectorParentGroup&&I[0]!=null){o=z.target;var H=cb(o,"type");if(H=="rotate"){Ha="rotate";current_rotate_mode=cb(o,"dir")}else if(H=="resize"){Ha="resize";db=cb(o,"dir")}o=I[0]}Sa=o.getAttribute("transform");H=R(o);switch(Ha){case "select":Ka=true;db="none";if(F)Ka=false;if(o!=d){if(I.indexOf(o)==-1){z.shiftKey||xa(true);qb([o]);wb=o;La.clear()}if(!F)for(F=0;F<I.length;++F)if(I[F]!=null){var J=R(I[F]);J.numberOfItems?J.insertItemBefore(d.createSVGTransform(),
0):J.appendItem(d.createSVGTransform())}}else if(!F){xa();Ha="multiselect";if(sa==null)sa=ra.getRubberBandBox();C*=q;A*=q;ma(sa,{x:C,y:A,width:0,height:0,display:"inline"},100)}break;case "zoom":Ka=true;if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:u*q,y:u*q,width:0,height:0,display:"inline"},100);break;case "resize":Ka=true;k=m;l=h;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var O={};$.each(G,function(X,ba){O[X]=ba/q});G=O;F=na(o)?1:0;if(oa(H)){H.insertItemBefore(d.createSVGTransform(),F);
H.insertItemBefore(d.createSVGTransform(),F);H.insertItemBefore(d.createSVGTransform(),F)}else{H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(m=svgedit.browser.isWebkit())J=function(X){var ba=X.getAttributeNS(null,"stroke");X.removeAttributeNS(null,"stroke");setTimeout(function(){X.setAttributeNS(null,"stroke",ba)},0)};o.style.vectorEffect="non-scaling-stroke";m&&J(o);h=o.getElementsByTagName("*");
u=h.length;for(F=0;F<u;F++){h[F].style.vectorEffect="non-scaling-stroke";m&&J(h[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ka=true;e=u+","+E+" ";J=K.stroke_width==0?1:K.stroke_width;S({element:"polyline",curStyles:true,attr:{points:e,id:ka(),fill:"none",opacity:K.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});D.minx=u;D.maxx=u;D.miny=E;D.maxy=E;break;case "image":Ka=true;J=S({element:"image",attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2,style:"pointer-events:inherit"}});
U(J,Ga);Fb(J);break;case "square":case "rect":Ka=true;k=m;l=h;S({element:"rect",curStyles:true,attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2}});break;case "line":Ka=true;J=K.stroke_width==0?1:K.stroke_width;S({element:"line",curStyles:true,attr:{x1:m,y1:h,x2:m,y2:h,id:ka(),stroke:K.stroke,"stroke-width":J,"stroke-dasharray":K.stroke_dasharray,"stroke-linejoin":K.stroke_linejoin,"stroke-linecap":K.stroke_linecap,"stroke-opacity":K.stroke_opacity,fill:"none",opacity:K.opacity/2,style:"pointer-events:none"}});
break;case "circle":Ka=true;S({element:"circle",curStyles:true,attr:{cx:m,cy:h,r:0,id:ka(),opacity:K.opacity/2}});break;case "ellipse":Ka=true;S({element:"ellipse",curStyles:true,attr:{cx:m,cy:h,rx:0,ry:0,id:ka(),opacity:K.opacity/2}});break;case "text":Ka=true;S({element:"text",curStyles:true,attr:{x:m,y:h,id:ka(),fill:Ua.fill,"stroke-width":Ua.stroke_width,"font-size":Ua.font_size,"font-family":Ua.font_family,"text-anchor":"left","xml:space":"preserve",opacity:K.opacity}});break;case "path":case "pathedit":k*=
q;l*=q;La.mouseDown(z,o,k,l);Ka=true;break;case "textedit":k*=q;l*=q;bb.mouseDown(z,o,k,l);Ka=true;break;case "rotate":Ka=true;c.undoMgr.beginUndoableChange("transform",I);document.getElementById("workarea").className="rotate"}J=ib("mouseDown",{event:z,start_x:k,start_y:l,selectedElements:I},true);$.each(J,function(X,ba){if(ba&&ba.started)Ka=true});if(Ha)document.getElementById("workarea").className=Ha=="resize"?z.target.style.cursor:Ha}}).mousemove(function(z){if(!(z.originalEvent.touches&&z.originalEvent.touches.length>
1))if(Ka)if(!(z.button===1||c.spaceKey)){var F=I[0],h=N(z.pageX,z.pageY,mb),m=h.x*(isBotchedZoom?1:q);h=h.y*(isBotchedZoom?1:q);var o=pa(aa()),u=x=m/q,E=y=h/q;if(p.gridSnapping){x=va(x);y=va(y)}z.preventDefault();switch(Ha){case "select":if(I[0]!==null){u=x-k;var H=y-l;if(p.gridSnapping){u=va(u);H=va(H)}if(z.shiftKey){var J=V(k,l,x,y);x=J.x;y=J.y}if(u!=0||H!=0){E=I.length;for(var O=0;O<E;++O){F=I[O];if(F==null)break;var X=d.createSVGTransform();o=R(F);if(J){u=J.x-k;H=J.y-l}X.setTranslate(u,H);o.numberOfItems?
o.replaceItem(X,0):o.appendItem(X);ra.requestSelector(F).resize()}if(z.altKey)if(!c.addClones){c.addClones=c.cloneSelectedElements(0,0,X);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(ua){ua.parentNode&&ua.parentNode.removeChild(ua);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",I)}}break;case "multiselect":u*=q;E*=q;ma(sa,{x:Math.min(C,u),y:Math.min(A,E),width:Math.abs(u-C),height:Math.abs(E-A)},100);o=[];u=[];J=ob();E=I.length;for(O=0;O<
E;++O){H=J.indexOf(I[O]);if(H==-1)o.push(I[O]);else J[H]=null}E=J.length;for(O=0;O<E;++O)J[O]&&u.push(J[O]);o.length>0&&c.removeFromSelection(o);u.length>0&&qb(u);break;case "resize":o=R(F);u=(J=oa(o))?G:svgedit.utilities.getBBox(F);E=u.x;O=u.y;var ba=u.width,T=u.height;u=x-k;H=y-l;if(p.gridSnapping){u=va(u);H=va(H);T=va(T);ba=va(ba)}if(X=na(F)){var fa=Math.sqrt(u*u+H*H);H=Math.atan2(H,u)-X*Math.PI/180;u=fa*Math.cos(H);H=fa*Math.sin(H)}if(db.indexOf("n")==-1&&db.indexOf("s")==-1)H=0;if(db.indexOf("e")==
-1&&db.indexOf("w")==-1)u=0;var ha=fa=0,W=T?(T+H)/T:1,qa=ba?(ba+u)/ba:1;if(db.indexOf("n")>=0){W=T?(T-H)/T:1;ha=T}if(db.indexOf("w")>=0){qa=ba?(ba-u)/ba:1;fa=ba}u=d.createSVGTransform();H=d.createSVGTransform();ba=d.createSVGTransform();if(p.gridSnapping){E=va(E);fa=va(fa);O=va(O);ha=va(ha)}u.setTranslate(-(E+fa),-(O+ha));if(z.shiftKey)if(qa==1)qa=W;else W=qa;H.setScale(qa,W);ba.setTranslate(E+fa,O+ha);if(J){J=X?1:0;o.replaceItem(u,2+J);o.replaceItem(H,1+J);o.replaceItem(ba,0+J)}else{J=o.numberOfItems;
o.replaceItem(ba,J-3);o.replaceItem(H,J-2);o.replaceItem(u,J-1)}ra.requestSelector(F).resize();M("transition",I);break;case "zoom":u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-A*q)},100);break;case "text":ma(o,{x:x,y:y},1E3);break;case "line":u=null;window.opera||d.suspendRedraw(1E3);if(p.gridSnapping){x=va(x);y=va(y)}E=x;J=y;if(z.shiftKey){J=V(k,l,E,J);E=J.x;J=J.y}o.setAttributeNS(null,"x2",E);o.setAttributeNS(null,"y2",J);window.opera||d.unsuspendRedraw(u);
break;case "foreignObject":case "square":case "rect":case "image":u=Math.abs(x-k);J=Math.abs(y-l);if(Ha=="square"||z.shiftKey){u=J=Math.max(u,J);E=k<x?k:k-u;O=l<y?l:l-J}else{E=Math.min(k,x);O=Math.min(l,y)}if(z.altKey){u*=2;J*=2;E=k-u/2;O=l-J/2}if(p.gridSnapping){u=va(u);J=va(J);E=va(E);O=va(O)}ma(o,{width:u,height:J,x:E,y:O},1E3);break;case "circle":u=$(o).attr(["cx","cy"]);J=u.cx;E=u.cy;u=Math.sqrt((x-J)*(x-J)+(y-E)*(y-E));if(p.gridSnapping)u=va(u);o.setAttributeNS(null,"r",u);break;case "ellipse":u=
$(o).attr(["cx","cy"]);J=Math.abs(k+(x-k)/2);E=Math.abs(l+(y-l)/2);u=null;window.opera||d.suspendRedraw(1E3);if(p.gridSnapping){x=va(x);J=va(J);y=va(y);E=va(E)}O=Math.abs(k-J);H=Math.abs(l-E);if(z.shiftKey){H=O;E=y>l?l+O:l-O}if(z.altKey){J=k;E=l;O=Math.abs(x-J);H=z.shiftKey?O:Math.abs(y-E)}o.setAttributeNS(null,"rx",O);o.setAttributeNS(null,"ry",H);o.setAttributeNS(null,"cx",J);o.setAttributeNS(null,"cy",E);window.opera||d.unsuspendRedraw(u);break;case "fhellipse":case "fhrect":D.minx=Math.min(u,
D.minx);D.maxx=Math.max(u,D.maxx);D.miny=Math.min(E,D.miny);D.maxy=Math.max(E,D.maxy);case "fhpath":e+=+u+","+E+" ";o.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=q;y*=q;if(p.gridSnapping){x=va(x);y=va(y);k=va(k);l=va(l)}if(z.shiftKey){if(J=svgedit.path.path){o=J.dragging?J.dragging[0]:k;J=J.dragging?J.dragging[1]:l}else{o=k;J=l}J=V(o,J,x,y);x=J.x;y=J.y}if(sa&&sa.getAttribute("display")!=="none"){u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-
A*q)},100)}La.mouseMove(z,x,y);break;case "textedit":x*=q;y*=q;bb.mouseMove(m,h);break;case "rotate":u=svgedit.utilities.getBBox(F);J=u.x+u.width/2;E=u.y+u.height/2;o=ea(F);o=N(J,E,o);J=o.x;E=o.y;o=u.x;O=u.y;if(current_rotate_mode=="nw")o=u.x+u.width;if(current_rotate_mode=="se")O=u.y+u.height;if(current_rotate_mode=="sw"){o=u.x+u.width;O=u.y+u.height}compensation_angle=(Math.atan2(E-O,J-o)*(180/Math.PI)-90)%360;X=(Math.atan2(E-y,J-x)*(180/Math.PI)-90)%360;X+=compensation_angle;if(p.gridSnapping)X=
va(X);if(z.shiftKey)X=Math.round(X/45)*45;c.setRotationAngle(X<-180?360+X:X,true);M("transition",I)}ib("mouseMove",{event:z,mouse_x:m,mouse_y:h,selected:F})}}).click(function(z){z.preventDefault();return false}).dblclick(function(z){var F=z.target.parentNode,h=Bb(z),m=h.tagName;if(F!==L){if(m==="text"&&Ha!=="textedit"){z=N(z.pageX,z.pageY,mb);bb.select(h,z.x,z.y)}if((m==="g"||m==="a")&&na(h)){Db(h);h=I[0];xa(true)}L&&Eb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||h===ra.selectorParentGroup||
Kb(h)}}).mouseup(function(z){c.addClones=false;window.removeEventListener("keyup",c.removeClones);I=I.filter(Boolean);if(z.button!==2){var F=wb;wb=null;if(Ka){var h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;var o=m/q,u=h/q,E=pa(aa()),H=false;Ka=false;switch(Ha){case "resize":case "multiselect":if(sa!=null){sa.setAttribute("display","none");hb=[]}Ha="select";case "select":if(I[0]!=null){if(I.length==1){m=I[0];switch(m.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Xa.fill=
m.getAttribute("fill");Xa.fill_opacity=m.getAttribute("fill-opacity");Xa.stroke=m.getAttribute("stroke");Xa.stroke_opacity=m.getAttribute("stroke-opacity");Xa.stroke_width=m.getAttribute("stroke-width");Xa.stroke_dasharray=m.getAttribute("stroke-dasharray");Xa.stroke_linejoin=m.getAttribute("stroke-linejoin");Xa.stroke_linecap=m.getAttribute("stroke-linecap")}if(m.tagName=="text"){Ua.font_size=m.getAttribute("font-size");Ua.font_family=m.getAttribute("font-family")}ra.requestSelector(m).showGrips(true)}Ea();
C=(m=svgedit.browser.isGecko())?C*q:C;A=m?A*q:A;m=Math.abs(u-A);if(m>1||m>1){z=I.length;for(m=0;m<z;++m){if(I[m]==null)break;I[m].firstChild||ra.requestSelector(I[m]).resize()}}else{m=z.target;if(I[0].nodeName==="path"&&I[1]==null)La.select(I[0]);else z.shiftKey&&F!=m&&c.removeFromSelection([m])}if(svgedit.browser.supportsNonScalingStroke())if(z=I[0]){z.removeAttribute("style");svgedit.utilities.walkTree(z,function(X){X.removeAttribute("style")})}}return;case "zoom":sa!=null&&sa.setAttribute("display",
"none");M("zoomed",{x:Math.min(C,o),y:Math.min(A,u),width:Math.abs(o-C),height:Math.abs(u-A),factor:z.altKey?0.5:2});return;case "fhpath":F=E.getAttribute("points");u=F.indexOf(",");if(H=u>=0?F.indexOf(",",u+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)E=La.smoothPolylineIntoPath(E);break;case "line":F=$(E).attr(["x1","x2","y1","y2"]);H=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(E).attr(["width","height"]);H=F.width!=0||F.height!=0||Ha==="image";break;
case "circle":H=E.getAttribute("r")!=0;break;case "ellipse":F=$(E).attr(["rx","ry"]);H=F.rx!=null||F.ry!=null;break;case "fhellipse":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"ellipse",curStyles:true,attr:{cx:(D.minx+D.maxx)/2,cy:(D.miny+D.maxy)/2,rx:(D.maxx-D.minx)/2,ry:(D.maxy-D.miny)/2,id:aa()}});M("changed",[E]);H=true}break;case "fhrect":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"rect",curStyles:true,attr:{x:D.minx,y:D.miny,width:D.maxx-D.minx,height:D.maxy-D.miny,id:aa()}});
M("changed",[E]);H=true}break;case "text":H=true;rb([E]);bb.start(E);break;case "path":E=null;Ka=true;F=La.mouseUp(z,E,m,h);E=F.element;H=F.keep;break;case "pathedit":H=true;E=null;La.mouseUp(z);break;case "textedit":H=false;E=null;bb.mouseUp(z,m,h);break;case "rotate":H=true;E=null;Ha="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||wa(F);Ea();M("changed",I)}m=ib("mouseUp",{event:z,mouse_x:m,mouse_y:h},true);$.each(m,function(X,ba){if(ba){H=ba.keep||H;E=ba.element;Ka=ba.started||Ka}});if(!H&&
E!=null){B().releaseId(aa());E.parentNode.removeChild(E);E=null;for(m=z.target;m.parentNode.parentNode.tagName=="g";)m=m.parentNode;if((Ha!="path"||!drawn_path)&&m.parentNode.id!="selectorParentGroup"&&m.id!="svgcanvas"&&m.id!="svgroot"){c.setMode("select");rb([m],true)}}else if(E!=null){c.addedNew=true;z=0.2;var J;if(false.beginElement&&E.getAttribute("opacity")!=K.opacity){J=$(false).clone().attr({to:K.opacity,dur:z}).appendTo(E);try{J[0].beginElement()}catch(O){}}else z=0;setTimeout(function(){J&&
J.remove();E.setAttribute("opacity",K.opacity);E.setAttribute("style","pointer-events:inherit");la(E);if(Ha==="path")La.toEditMode(E);else p.selectNew&&rb([E],true);wa(new Ia(E));M("changed",[E])},z*1E3)}Sa=null}}});$(a).bind("mousewheel DOMMouseScroll",function(z){if(z.shiftKey){z.preventDefault();mb=n.getScreenCTM().inverse();var F=N(z.pageX,z.pageY,mb);F={x:F.x,y:F.y,width:0,height:0};if(z.wheelDelta)if(z.wheelDelta>=120)F.factor=2;else{if(z.wheelDelta<=-120)F.factor=0.5}else if(z.detail)if(z.detail>
0)F.factor=0.5;else if(z.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var Fb=function(e){$(e).click(function(k){k.preventDefault()})},bb=c.textActions=function(){function e(T){var fa=h.value==="";$(h).focus();if(!arguments.length)if(fa)T=0;else{if(h.selectionEnd!==h.selectionStart)return;T=h.selectionEnd}var ha;ha=E[T];fa||h.setSelectionRange(T,T);m=pa("text_cursor");if(!m){m=document.createElementNS(b,"line");ma(m,{id:"text_cursor",stroke:"#333","stroke-width":1});m=pa("selectorParentGroup").appendChild(m)}u||
(u=setInterval(function(){var W=m.getAttribute("display")==="none";m.setAttribute("display",W?"inline":"none")},600));fa=G(ha.x,H.y);ha=G(ha.x,H.y+H.height);ma(m,{x1:fa.x,y1:fa.y,x2:ha.x,y2:ha.y,visibility:"visible",display:"inline"});o&&o.setAttribute("d","M 0 0")}function k(T,fa,ha){if(T===fa)e(fa);else{ha||h.setSelectionRange(T,fa);o=pa("text_selectblock");if(!o){o=document.createElementNS(b,"path");ma(o,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});pa("selectorParentGroup").appendChild(o)}T=
E[T];var W=E[fa];m.setAttribute("visibility","hidden");fa=G(T.x,H.y);ha=G(T.x+(W.x-T.x),H.y);var qa=G(T.x,H.y+H.height);T=G(T.x+(W.x-T.x),H.y+H.height);ma(o,{d:"M"+fa.x+","+fa.y+" L"+ha.x+","+ha.y+" "+T.x+","+T.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function l(T,fa){var ha=d.createSVGPoint();ha.x=T;ha.y=fa;if(E.length==1)return 0;ha=F.getCharNumAtPosition(ha);if(ha<0){ha=E.length-2;if(T<=E[0].x)ha=0}else if(ha>=E.length-2)ha=E.length-2;var W=E[ha];T>W.x+W.width/2&&ha++;return ha}function C(T,
fa,ha){var W=h.selectionStart;T=l(T,fa);k(Math.min(W,T),Math.max(W,T),!ha)}function A(T,fa){var ha={x:T,y:fa};ha.x/=q;ha.y/=q;if(J){var W=N(ha.x,ha.y,J.inverse());ha.x=W.x;ha.y=W.y}return ha}function G(T,fa){var ha={x:T,y:fa};if(J){var W=N(ha.x,ha.y,J);ha.x=W.x;ha.y=W.y}ha.x*=q;ha.y*=q;return ha}function D(T){k(0,F.textContent.length);$(this).unbind(T)}function z(T){if(ba&&F){var fa=N(T.pageX,T.pageY,mb);fa=A(fa.x*q,fa.y*q);fa=l(fa.x,fa.y);var ha=F.textContent,W=ha.substr(0,fa).replace(/[a-z0-9]+$/i,
"").length;ha=ha.substr(fa).match(/^[a-z0-9]+/i);k(W,(ha?ha[0].length:0)+fa);$(T.target).click(D);setTimeout(function(){$(T.target).unbind("click",D)},300)}}var F,h,m,o,u,E=[],H,J,O,X,ba;return{select:function(T,fa,ha){F=T;bb.toEditMode(fa,ha)},start:function(T){F=T;bb.toEditMode()},mouseDown:function(T,fa,ha,W){T=A(ha,W);h.focus();e(l(T.x,T.y));O=ha;X=W},mouseMove:function(T,fa){var ha=A(T,fa);C(ha.x,ha.y)},mouseUp:function(T,fa,ha){var W=A(fa,ha);C(W.x,W.y,true);T.target!==F&&fa<O+2&&fa>O-2&&ha<
X+2&&ha>X-2&&bb.toSelectMode(true)},setCursor:e,toEditMode:function(T,fa){rb([F],false);ba=false;Ha="textedit";ra.requestSelector(F).showGrips(false);ra.requestSelector(F);bb.init();$(F).css("cursor","text");if(arguments.length){var ha=A(T,fa);e(l(ha.x,ha.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(T){Ha="select";clearInterval(u);u=null;o&&$(o).attr("display","none");m&&$(m).attr("visibility","hidden");$(F).css("cursor","move");if(T){xa();$(F).css("cursor","move");M("selected",
[F]);qb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(h).blur();F=false},setInputElem:function(T){h=T},clear:function(){Ha=="textedit"&&bb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=I[0];ra.requestSelector(F).showGrips(false)}var T=F.textContent.length,fa=F.getAttribute("transform");H=svgedit.utilities.getBBox(F);J=fa?ea(F):null;E=Array(T);h.focus();$(F).unbind("dblclick",z).dblclick(z);if(!T)var ha={x:H.x+H.width/2,width:0};for(fa=0;fa<T;fa++){var W=F.getStartPositionOfChar(fa);
ha=F.getEndPositionOfChar(fa);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*q;W.x-=qa;ha.x-=qa;W.x/=q;ha.x/=q}E[fa]={x:W.x,y:H.y,width:ha.x-W.x,height:H.height}}E.push({x:ha.x,width:0});k(h.selectionStart,h.selectionEnd,true)}}}}(),La=c.pathActions=function(){var e=false,k,l,C;svgedit.path.Path.prototype.endChanges=function(D){if(svgedit.browser.isWebkit()){var z=this.elem;z.setAttribute("d",La.convertPath(z))}D=new Ma(this.elem,{d:this.last_d},D);wa(D);M("changed",[this.elem])};
svgedit.path.Path.prototype.addPtsToSelection=function(D){$.isArray(D)||(D=[D]);for(var z=0;z<D.length;z++){var F=D[z],h=this.segs[F];h.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();z=this.selected_pts.length;for(D=Array(z);z--;){h=this.segs[this.selected_pts[z]];h.select(true);D[z]=h.ptgrip}La.canDeleteNodes=true;La.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",D)};var A=k=null,G=false;this.lastCtrlPoint=[0,0];return{mouseDown:function(D,
z,F,h){if(Ha==="path"){mouse_x=F;mouse_y=h;F=mouse_x/q;z=mouse_y/q;h=pa("path_stretch_line");l=[F,z];if(p.gridSnapping){F=va(F);z=va(z);mouse_x=va(mouse_x);mouse_y=va(mouse_y)}if(!h){h=document.createElementNS(b,"path");ma(h,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});h=pa("selectorParentGroup").appendChild(h)}h.setAttribute("display","inline");this.stretchy=h;var m=null;if(A){m=A.pathSegList;for(var o=m.numberOfItems,u=6/q,E=false;o;){o--;var H=m.getItem(o),J=H.x;H=H.y;
if(F>=J-u&&F<=J+u&&z>=H-u&&z<=H+u){E=true;break}}u=aa();svgedit.path.removePath_(u);u=pa(u);J=m.numberOfItems;if(E){if(o<=1&&J>=2){F=m.getItem(0).x;z=m.getItem(0).y;o=svgedit.path.first_grip?svgedit.path.first_grip[0]/q:m.getItem(0).x;E=svgedit.path.first_grip?svgedit.path.first_grip[1]/q:m.getItem(0).y;D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(F,z):A.createSVGPathSegCurvetoCubicAbs(F,z,D.x1/q,D.y1/q,o,E);F=A.createSVGPathSegClosePath();m.appendItem(D);m.appendItem(F)}else if(J<
3)return m=false;$(h).remove();element=u;A=null;Ka=false;if(e){svgedit.path.path.matrix&&Za(u,{},svgedit.path.path.matrix.inverse());F=u.getAttribute("d");h=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",h+F);$(u).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();La.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Bb(D))){console.log("Clicked outside canvas");return false}m=A.pathSegList.numberOfItems;
o=A.pathSegList.getItem(m-1);u=o.x;o=o.y;if(D.shiftKey){z=V(u,o,F,z);F=z.x;z=z.y}D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(ab(F),ab(z)):A.createSVGPathSegCurvetoCubicAbs(ab(F),ab(z),D.x1/q,D.y1/q,D.x2/q,D.y2/q);A.pathSegList.appendItem(D);F*=q;z*=q;h.setAttribute("d",["M",F,z,F,z].join(" "));h=svgedit.path.addCtrlGrip("1c1");D=svgedit.path.addCtrlGrip("0c2");u=svgedit.path.getCtrlLine(1);o=svgedit.path.getCtrlLine(2);h.setAttribute("cx",F);h.setAttribute("cy",z);D.setAttribute("cx",
F);D.setAttribute("cy",z);u.setAttribute("x1",F);u.setAttribute("x2",F);u.setAttribute("y1",z);u.setAttribute("y2",z);o.setAttribute("x1",F);o.setAttribute("x2",F);o.setAttribute("y1",z);o.setAttribute("y2",z);h=m;if(e)h+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(h,F,z)}m=true}else{d_attr="M"+F+","+z+" ";A=S({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:K.opacity/2}});h.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));h=e?svgedit.path.path.segs.length:
0;svgedit.path.addPointGrip(h,mouse_x,mouse_y);svgedit.path.first_grip=null}}else if(svgedit.path.path){svgedit.path.path.storeD();u=D.target.id;if(u.substr(0,14)=="pathpointgrip_"){z=svgedit.path.path.cur_pt=parseInt(u.substr(14));svgedit.path.path.dragging=[F,h];u=svgedit.path.path.segs[z];if(D.shiftKey)u.selected?svgedit.path.path.removePtFromSelection(z):svgedit.path.path.addPtsToSelection(z);else{if(svgedit.path.path.selected_pts.length<=1||!u.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(z)}}else if(u.indexOf("ctrlpointgrip_")==
0){svgedit.path.path.dragging=[F,h];D=u.split("_")[1].split("c");z=D[0]-0;m=D=D[1]-0;o=svgedit.path.path.segs[z];svgedit.path.path.selectPt(z,D);if(m==2){E=1;u=o.next}else{E=2;u=o.prev}if(!u)return;D=function(O,X){return Math.sqrt(Math.pow(O.x-X.x,2)+Math.pow(O.y-X.y,2))};z={x:o.item["x"+m],y:o.item["y"+m]};m=m==2?{x:o.item.x,y:o.item.y}:{x:u.item.x,y:u.item.y};o={x:u.item["x"+E],y:u.item["y"+E]};u=D(z,m);D=D(o,m);z=Math.abs(Math.round(Math.atan2(z.y-m.y,z.x-m.x)*(180/Math.PI),0)-Math.round(Math.atan2(o.y-
m.y,o.x-m.x)*(180/Math.PI),0))==180;if(Math.abs(u-D)<5&&z){svgedit.path.setLinkControlPoints(true);svgedit.path.is_linked=true}else{svgedit.path.setLinkControlPoints(false);svgedit.path.is_linked=false}}if(!svgedit.path.path.dragging){if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:F*q,y:h*q,width:0,height:0,display:"inline"},100)}}},mouseMove:function(D,z,F){G=true;var h=!D.altKey;if(Ha==="path"){if(A){var m=A.pathSegList,o=m.numberOfItems-1,u=svgedit.path.addCtrlGrip("1c1"),E=svgedit.path.addCtrlGrip("0c2");
if(l){var H=E.getAttribute("cx")/q||0,J=E.getAttribute("cy")/q||0;u.setAttribute("cx",z);u.setAttribute("cy",F);u.setAttribute("display","inline");D=l[0];u=l[1];m.getItem(o);var O=z/q,X=F/q;H=h?D+(D-O):H;h=h?u+(u-X):J;E.setAttribute("cx",H*q);E.setAttribute("cy",h*q);E.setAttribute("display","inline");E=svgedit.path.getCtrlLine(1);J=svgedit.path.getCtrlLine(2);ma(E,{x1:z,y1:F,x2:D*q,y2:u*q,display:"inline"});ma(J,{x1:H*q,y1:h*q,x2:D*q,y2:u*q,display:"inline"});if(o===0)C=[z,F];else{m=m.getItem(o-
1);z=m.x;F=m.y;if(m.pathSegType===6){z+=z-m.x2;F+=F-m.y2}else if(C){z=C[0]/q;F=C[1]/q}svgedit.path.replacePathSeg(6,o,[D,u,this.lastCtrlPoint[0]/q,this.lastCtrlPoint[1]/q,H,h],A)}}else if(h=this.stretchy){o=m.getItem(o);m=z;u=F;if(D.target.id==="pathpointgrip_0"&&svgedit.path.first_grip){m=svgedit.path.first_grip[0];u=svgedit.path.first_grip[1]}if(o.pathSegType===6)svgedit.path.replacePathSeg(6,1,[z,F,(this.lastCtrlPoint[0]/q||o.x+(o.x-o.x2))*q,(this.lastCtrlPoint[1]/q||o.y+(o.y-o.y2))*q,m,u],h);
else C?svgedit.path.replacePathSeg(6,1,[z,F,C[0],C[1],z,F],h):svgedit.path.replacePathSeg(4,1,[z,F],h)}}}else if(svgedit.path.path.dragging){m=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);D=svgedit.path.getPointFromGrip({x:z,y:F},svgedit.path.path);o=D.x-m.x;m=D.y-m.y;svgedit.path.path.dragging=[z,F];!h||!svgedit.path.is_linked?svgedit.path.setLinkControlPoints(false):svgedit.path.setLinkControlPoints(true);svgedit.path.path.dragctrl?
svgedit.path.path.moveCtrl(o,m):svgedit.path.path.movePts(o,m)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var ba=sa.getBBox(),T=svgedit.path.getGripPt(this);ba=svgedit.math.rectsIntersect(ba,{x:T.x,y:T.y,width:0,height:0});this.select(ba);ba&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(D,z,F,h){var m=pa("ctrlpointgrip_1c1"),o=pa("ctrlpointgrip_0c2");this.lastCtrlPoint=m?[m.getAttribute("cx"),m.getAttribute("cy")]:
[F,h];if(!svgedit.path.first_grip&&o)svgedit.path.first_grip=[o.getAttribute("cx"),o.getAttribute("cy")];if(Ha==="path"){l=null;if(!A){z=pa(aa());Ka=false;C=null}return{keep:true,element:z}}if(svgedit.path.path.dragging){z=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!D.shiftKey&&!G&&svgedit.path.path.selectPt(z)}else if(sa&&sa.getAttribute("display")!="none"){sa.setAttribute("display",
"none");sa.getAttribute("width")<=2&&sa.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=svgedit.path.getPath_(D);Ha="pathedit";xa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(D){var z=D==svgedit.path.path.elem;Ha="select";svgedit.path.path.show(false);k=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();
if(z){M("selected",[D]);qb([D],true)}},addSubPath:function(D){if(D){Ha="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(k===D){La.toEditMode(D);Ha="pathedit"}else k=D},reorient:function(){var D=I[0];if(D)if(na(D)!=0){var z=new Da("Reorient path"),F={d:D.getAttribute("d"),transform:D.getAttribute("transform")};z.addSubCommand(new Ma(D,F));xa();this.resetOrientation(D);wa(z);svgedit.path.getPath_(D).show(false).matrix=null;this.clear();qb([D],true);M("changed",
I)}},clear:function(D){k=null;if(A){var z=pa(aa());$(pa("path_stretch_line")).remove();D&&$(z).remove();$(pa("pathpointgrip_container")).find("*").attr("display","none");A=C=null;Ka=false}else Ha=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(D){if(D==null||D.nodeName!="path")return false;var z=R(D),F=Y(z).matrix;z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var h=z.numberOfItems,m=0;m<h;++m){var o=z.getItem(m),u=
o.pathSegType;if(u!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],X=o["y"+J];if(O!==undefined&&X!==undefined){O=N(O,X,F);E.splice(E.length,0,O.x,O.y)}});svgedit.path.replacePathSeg(u,m,E,D)}}g(D,F)},zoomChange:function(){Ha=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){if(svgedit.path.path){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},
clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var h=D[z];svgedit.path.path.addSeg(h);F.push(h+z);F.push(h+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var z=svgedit.path.path.elem,F=z.pathSegList,h=D[0],m=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=h)o=this.item;if(J<=
h)return true;if(this.type===2){m=J;return false}else if(this.type===1)return m=false});if(m==null)m=svgedit.path.path.segs.length-1;if(m!==false){var u=z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(m==svgedit.path.path.segs.length){F.appendItem(u);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,m);svgedit.path.insertItemBefore(z,u,m)}svgedit.path.path.init().selectPt(m+1)}else if(svgedit.path.path.segs[h].mate){F.removeItem(h);F.removeItem(h);svgedit.path.path.init().selectPt(h-
1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)u=D;else if(D===h)F.removeItem(u);else if(H.pathSegType===1&&h<D){E=D-1;F.removeItem(D);break}}for(D=h-u-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(u),E);z=F.getItem(u);svgedit.path.replacePathSeg(2,u,[z.x,z.y]);D=h;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length;z--;)svgedit.path.path.deleteSeg(D[z]);
var F=function(){var h=svgedit.path.path.elem.pathSegList,m=h.numberOfItems,o=function(H,J){for(;J--;)h.removeItem(H)};if(m<=1)return true;for(;m--;){var u=h.getItem(m);if(u.pathSegType===1){u=h.getItem(m-1);var E=h.getItem(m-2);if(u.pathSegType===2){o(m-1,2);F();break}else if(E.pathSegType===2){o(m-2,3);F();break}}else if(u.pathSegType===2)if(m>0){u=h.getItem(m-1).pathSegType;if(u===2){o(m-1,1);F();break}else if(u===1&&h.numberOfItems-1===m){o(m,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=
1){c.setMode("select");c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var h=z.getItem(0),m=null;D=[];D.push(["M",h.x,",",h.y," C"].join(""));for(var o=1;o<=F-4;o+=3){var u=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(m)if((h=svgedit.path.smoothControlPoints(m,
u,h))&&h.length==2){u=D[D.length-1].split(",");u[2]=h[0].x;u[3]=h[0].y;D[D.length-1]=u.join(",");u=h[1]}D.push([u.x,u.y,E.x,E.y,H.x,H.y].join(","));h=H;m=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];
var h={x:0,y:0};h[D]=z-F.item[D];F.move(h.x,h.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=D.pathSegList,F=z.numberOfItems,h,m=0;m<F;++m){var o=z.getItem(m);if(o.pathSegType===2)h=o;if(o.pathSegType===1){o=z.getItem(m-1);if(o.x!=h.x||o.y!=h.y){z=D.createSVGPathSegLinetoAbs(h.x,h.y);svgedit.path.insertItemBefore(D,z,m);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,h=F.numberOfItems,
m=0,o=0,u="",E=null,H=0;H<h;++H){var J=F.getItem(H),O=J.x||0,X=J.y||0,ba=J.x1||0,T=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});u+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:u+="z";break;case 12:O-=m;case 13:if(z){m+=O;qa="l"}else{O+=m;m=O;qa="L"}ua([[O,o]]);break;case 14:X-=o;case 15:if(z){o+=X;qa="l"}else{X+=
o;o=X;qa="L"}ua([[m,X]]);break;case 2:case 4:case 18:O-=m;X-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){m=E[0];o=E[1]}case 19:if(z){m+=O;o+=X}else{O+=m;X+=o;m=O;o=X}if(W===3)E=[m,o];ua([[O,X]]);break;case 6:O-=m;ba-=m;fa-=m;X-=o;T-=o;ha-=o;case 7:if(z){m+=O;o+=X}else{O+=m;ba+=m;fa+=m;X+=o;T+=o;ha+=o;m=O;o=X}ua([[ba,T],[fa,ha],[O,X]]);break;case 8:O-=m;ba-=m;X-=o;T-=o;case 9:if(z){m+=O;o+=X}else{O+=m;ba+=m;X+=o;T+=o;m=O;o=X}ua([[ba,T],[O,X]]);break;case 10:O-=m;X-=o;case 11:if(z){m+=
O;o+=X}else{O+=m;X+=o;m=O;o=X}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,X]);break;case 16:O-=m;fa-=m;X-=o;ha-=o;case 17:if(z){m+=O;o+=X}else{O+=m;fa+=m;X+=o;ha+=o;m=O;o=X}ua([[fa,ha],[O,X]])}}return u}}}(),yb=this.removeUnusedDefElems=function(){var e=n.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],l=0,C=["fill","stroke","filter","marker-start","marker-mid","marker-end"],A=C.length,G=n.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=
G[z],h=0;h<A;h++)if(F){var m=ja(F.getAttribute(C[h]));m&&k.push(m.substr(1))}(F=ca(F))&&F.indexOf("#")===0&&k.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){C=e[z];A=C.id;if(k.indexOf(A)<0){sb[A]=C;C.parentNode.removeChild(C);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);La.clear(true);$.each(n.childNodes,function(l,C){l&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&n.insertBefore(C,n.firstChild)});
if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(n).find("g:data(gsvg)").each(function(){for(var l=this.attributes,C=l.length,A=0;A<C;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")C--;if(C<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var k=this.svgToString(n,0);e.length&&$(e).each(function(){tb(this)});return k};this.svgToString=function(e,k){var l=[],C=svgedit.utilities.toXml,A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,h=e.childNodes;
for(F=0;F<k;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var m={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!m[O]&&ya[O]!=="xmlns"&&ya[O]!=="xml"){m[O]=true;l.push(" xmlns:"+ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox",
"id","overflow"];F--;){z=D.item(F);var o=C(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var u=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=0;F--){z=D.item(F);o=C(z.nodeValue);if(!(u.indexOf(z.localName)>=0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&
o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");k++;D=false;for(F=0;F<h.length;F++){A=h.item(F);switch(A.nodeType){case 1:l.push("\n");
l.push(this.svgToString(h.item(F),k));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(C(A)+"")}break;case 4:l.push("\n");l.push(Array(k+1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(k+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}k--;if(!D){l.push("\n");for(F=0;F<k;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var l=
document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=l.toDataURL().replace(";base64",C+";base64");Va[e]=C}catch(A){Va[e]=false}Ga=e;k&&k(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Ga=e};this.open=function(){};this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],k={feGaussianBlur:kb.exportNoBlur,
foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(n);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=kb.exportNoText;$.each(k,function(C,A){l.find(C).length&&e.push(A)});k=this.svgCanvasToString();M("exported",{svg:k,issues:e})};this.getSvgString=function(){$a.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 Hb=this.uniquifyElems=
function(e){var k={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(z){if(z.nodeType==1){if(z.id){z.id in k||(k[z.id]={elem:null,attrs:[],hrefs:[]});k[z.id].elem=z}$.each(vb,function(h,m){var o=z.getAttributeNode(m);if(o){var u=svgedit.utilities.getUrlFromAttr(o.value);if(u=u?u.substr(1):null){u in k||(k[u]={elem:null,attrs:[],hrefs:[]});k[u].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=
0)if(F=F.substr(1)){F in k||(k[F]={elem:null,attrs:[],hrefs:[]});k[F].hrefs.push(z)}}});for(var C in k)if(C){var A=k[C].elem;if(A){e=ka();A.id=e;A=k[C].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=k[C].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var l=ca(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName==
"svg")$(this).data("symbol",l).data("ref",l)}})},Ib=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 l=$(n).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1",
"y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=Y(A).matrix;A=N(C.x1,C.y1,G);G=N(C.x2,C.y2,G);C.x1=A.x;C.y1=A.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-l.x)/l.width,y1:(C.y1-l.y)/l.height,x2:(C.x2-l.x)/l.width,y2:(C.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Lb=this.convertToGroup=function(e){e||(e=I[0]);var k=$(e),l=new Da,C;if(k.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();
$(e).removeData("gsvg");C=R(e);var A=d.createSVGTransform();A.setTranslate(l.x,l.y);C.appendItem(A);Ra(e);M("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");A=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}C+=" translate("+(A.x||0)+","+(A.y||0)+")";A=k.prev();l.addSubCommand(new Fa(k[0],k[0].nextSibling,k[0].parentNode));k.remove();G=$(n).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,
z=0;z<D.length;z++)k.appendChild(D[z].cloneNode(true));if(svgedit.browser.isGecko()){D=$(gb()).children("linearGradient,radialGradient,pattern").clone();$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Hb(k);svgedit.browser.isGecko()&&$(gb()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();A.after(k);if(C){if(!G){A=e.nextSibling;C.removeChild(e);l.addSubCommand(new Fa(e,A,C))}l.addSubCommand(new Ia(k))}Gb(k);svgedit.browser.isGecko()?Ib(gb()):Ib(k);svgedit.utilities.walkTreePost(k,
function(F){try{Ra(F)}catch(h){console.log(h)}});$(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()});rb([k]);(e=Db(k,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);this.prepareSvg(k);var l=new Da("Change Source"),C=n.nextSibling,A=d.removeChild(n);l.addSubCommand(new Fa(A,C,d));n=f.adoptNode?f.adoptNode(k.documentElement):
f.importNode(k.documentElement,true);d.appendChild(n);var G=$(n);c.current_drawing_=new svgedit.draw.Drawing(n,v);var D=B().getNonce();D?M("setnonce",D):M("unsetnonce");G.find("image").each(function(){var J=this;Fb(J);var O=ca(this);if(O.indexOf("data:")===0){var X=O.match(/svgedit_url=(.*?);/);if(X){var ba=decodeURIComponent(X[1]);$(new Image).load(function(){J.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",ba)}).attr("src",ba)}}c.embedImage(O)});G.find("svg").each(function(){if(!$(this).closest("defs").length){Hb(this);
var J=this.parentNode;if(J.childNodes.length===1&&J.nodeName==="g"){$(J).data("gsvg",this);J.id=J.id||ka()}else tb(this)}});G.find("linearGradient, radialGradient, pattern").appendTo(gb());Gb(G);Ib(G[0]);svgedit.utilities.walkTreePost(n,function(J){try{Ra(J)}catch(O){console.log(O)}});var z={id:"svgcontent",overflow:p.show_outside_canvas?"visible":"hidden"},F=false;if(G.attr("viewBox")){var h=G.attr("viewBox").split(" ");z.width=h[2];z.height=h[3]}else $.each(["width","height"],function(J,O){var X=
G.attr(O);X||(X="100%");if((X+"").substr(-1)==="%")F=true;else z[O]=Ba(O,X)});xb();G.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});if(F){var m=getStrokedBBox();z.width=m.width+m.x;z.height=m.height+m.y}if(z.width<=0)z.width=200;if(z.height<=0)z.height=200;G.attr(z);this.contentW=z.width;this.contentH=z.height;$("#canvas_width").val(this.contentW);$("#canvas_height").val(this.contentH);var o=$("#canvas_background");
if(o.length){var u=o.attr("fill-opacity");u=u?parseInt(u)*100:100;fill=this.getPaint(o.attr("fill"),u,"canvas")}else fill=this.getPaint("none",100,"canvas");methodDraw.paintBox.canvas.setPaint(fill);l.addSubCommand(new Ia(n));var E=G.attr(["width","height"]);l.addSubCommand(new Ma(d,E));q=1;svgedit.transformlist.resetListMap();xa();svgedit.path.clearData();d.appendChild(ra.selectorParentGroup);wa(l);M("changed",[n])}catch(H){console.log(H);return false}return true};this.getPaint=function(e,k,l){var C=
null;if(e.indexOf("url(#")===0){e=(e=svgCanvas.getRefElem(e))?e.cloneNode(true):$("#"+l+"_color defs *")[0];C={alpha:k};C[e.tagName]=e}else C=e.indexOf("#")===0?{alpha:k,solidColor:e.substr(1)}:{alpha:k,solidColor:"none"};return new $.jGraduate.Paint(C)};this.importSvgString=function(e){try{var k=svgedit.utilities.encode64(e.length+e).substr(0,32),l=false;if(lb[k])if($(lb[k].symbol).parents("#svgroot").length)l=true;var C=new Da("Import SVG");if(l)var A=lb[k].symbol,G=lb[k].xform;else{var D=svgedit.utilities.text2xml(e);
this.prepareSvg(D);var z;z=f.adoptNode?f.adoptNode(D.documentElement):f.importNode(D.documentElement,true);Hb(z);var F=Ba("width",z.getAttribute("width")),h=Ba("height",z.getAttribute("height")),m=z.getAttribute("viewBox"),o=m?m.split(" "):[0,0,F,h];for(e=0;e<4;++e)o[e]=+o[e];n.getAttribute("width");var u=+n.getAttribute("height");G=h>F?"scale("+u/3/o[3]+")":"scale("+u/3/o[2]+")";G="translate(0) "+G+" translate(0)";A=f.createElementNS(b,"symbol");var E=gb();for(svgedit.browser.isGecko()&&$(z).find("linearGradient, radialGradient, pattern").appendTo(E);z.firstChild;)A.appendChild(z.firstChild);
var H=z.attributes;for(z=0;z<H.length;z++){var J=H[z];A.setAttribute(J.nodeName,J.nodeValue)}A.id=ka();lb[k]={symbol:A,xform:G};gb().appendChild(A);C.addSubCommand(new Ia(A))}var O=f.createElementNS(b,"use");O.id=ka();U(O,"#"+A.id);(L||B().getCurrentLayer()).appendChild(O);C.addSubCommand(new Ia(O));xa();O.setAttribute("transform",G);Ra(O);$(O).data("symbol",A).data("ref",A);qb([O]);wa(C);M("changed",[n])}catch(X){console.log(X);return false}return true};var xb=c.identifyLayers=function(){Eb();B().identifyLayers()};
this.createLayer=function(e){var k=new Da("Create Layer");e=B().createLayer(e);k.addSubCommand(new Ia(e));wa(k);xa();M("changed",[e])};this.cloneLayer=function(e){var k=new Da("Duplicate Layer"),l=f.createElementNS(b,"g"),C=f.createElementNS(b,"title");C.textContent=e;l.appendChild(C);C=B().getCurrentLayer();$(C).after(l);C=C.childNodes;for(var A=0;A<C.length;A++){var G=C[A];G.localName!="title"&&l.appendChild(ia(G))}xa();xb();k.addSubCommand(new Ia(l));wa(k);c.setCurrentLayer(e);M("changed",[l])};
this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),k=e.nextSibling,l=e.parentNode;if(e=B().deleteCurrentLayer()){var C=new Da("Delete Layer");C.addSubCommand(new Fa(e,k,l));wa(C);xa();M("changed",[l]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&xa();return e};this.renameCurrentLayer=function(e){var k=B();if(k.current_layer){var l=k.current_layer;if(!c.setCurrentLayer(e)){for(var C=new Da("Rename Layer"),A=0;A<k.getNumLayers();++A)if(k.all_layers[A][1]==
l)break;var G=k.getLayerName(A);k.all_layers[A][0]=svgedit.utilities.toXml(e);var D=l.childNodes.length;for(A=0;A<D;++A){var z=l.childNodes.item(A);if(z&&z.tagName=="title"){for(;z.firstChild;)z.removeChild(z.firstChild);z.textContent=e;C.addSubCommand(new Ma(z,{"#text":G}));wa(C);M("changed",[l]);return true}}}k.current_layer=l}return false};this.setCurrentLayerPosition=function(e){var k=B();if(k.current_layer&&e>=0&&e<k.getNumLayers()){for(var l=0;l<k.getNumLayers();++l)if(k.all_layers[l][1]==k.current_layer)break;
if(l==k.getNumLayers())return false;if(l!=e){var C=null,A=k.current_layer.nextSibling;if(e>l){if(e<k.getNumLayers()-1)C=k.all_layers[e+1][1]}else C=k.all_layers[e][1];n.insertBefore(k.current_layer,C);wa(new Ja(k.current_layer,A,n));xb();c.setCurrentLayer(k.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,k){var l=B(),C=l.getLayerVisibility(e),A=l.setLayerVisibility(e,k);if(A)wa(new Ma(A,{display:C?"inline":"none"},"Layer Visibility"));else return false;if(A==l.getCurrentLayer()){xa();
La.clear()}return true};this.moveSelectedToLayer=function(e){for(var k=null,l=B(),C=0;C<l.getNumLayers();++C)if(l.getLayerName(C)==e){k=l.all_layers[C][1];break}if(!k)return false;e=new Da("Move Elements to Layer");l=I;for(C=l.length;C--;){var A=l[C];if(A){var G=A.nextSibling,D=A.parentNode;k.appendChild(A);e.addSubCommand(new Ja(A,G,D))}}wa(e);return true};this.mergeLayer=function(e){var k=new Da("Merge Layer"),l=B(),C=$(l.current_layer).prev()[0];if(C){for(k.addSubCommand(new Fa(l.current_layer,
l.current_layer.nextSibling,n));l.current_layer.firstChild;){var A=l.current_layer.firstChild;if(A.localName=="title"){k.addSubCommand(new Fa(A,A.nextSibling,l.current_layer));l.current_layer.removeChild(A)}else{var G=A.nextSibling;C.appendChild(A);k.addSubCommand(new Ja(A,G,l.current_layer))}}n.removeChild(l.current_layer);if(!e){xa();xb();M("changed",[n]);wa(k)}l.current_layer=C;return k}};this.mergeAllLayers=function(){var e=new Da("Merge all Layers"),k=B();for(k.current_layer=k.all_layers[k.getNumLayers()-
1][1];$(n).children("g").length>1;)e.addSubCommand(c.mergeLayer(true));xa();xb();M("changed",[n]);wa(e)};var Eb=this.leaveContext=function(){var e=ta.length;if(e){for(var k=0;k<e;k++){var l=ta[k],C=cb(l,"orig_opac");C!==1?l.setAttribute("opacity",C):l.removeAttribute("opacity");l.setAttribute("style","pointer-events: inherit")}ta=[];xa(true);M("contextset",null)}L=null},Kb=this.setContext=function(e){Eb();if(typeof e==="string")e=pa(e);L=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var k=
this.getAttribute("opacity")||1;cb(this,"orig_opac",k);this.setAttribute("opacity",k*0.33);this.setAttribute("style","pointer-events: none");ta.push(this)});xa();M("contextset",L)};this.clear=function(){La.clear();xa();c.clearSvgContentElement();c.current_drawing_=new svgedit.draw.Drawing(n);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();ra.initGroup();sa=ra.getRubberBandBox();M("cleared")};this.linkControlPoints=La.linkControlPoints;this.getContentElem=function(){return n};this.getRootElem=
function(){return d};this.getSelectedElems=function(){return I};var zb=this.getResolution=function(){var e=n.getAttribute("width")/q,k=n.getAttribute("height")/q;return{w:e,h:k,zoom:q}};this.getZoom=function(){return q};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(kb,e.notification)};this.setConfig=function(e){$.extend(p,e)};this.getTitle=function(e){if(e=e||I[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var k=0;k<e.length;k++)if(e[k].nodeName==
"title")return e[k].textContent;return""}};this.setGroupTitle=function(e){var k=I[0];k=$(k).data("gsvg")||k;var l=$(k).children("title"),C=new Da("Set Label");if(e.length)if(l.length){l=l[0];C.addSubCommand(new Ma(l,{"#text":l.textContent}));l.textContent=e}else{l=f.createElementNS(b,"title");l.textContent=e;$(k).prepend(l);C.addSubCommand(new Ia(l))}else{C.addSubCommand(new Fa(l[0],l.nextSibling,k));l.remove()}wa(C)};this.getDocumentTitle=function(){return c.getTitle(n)};this.setDocumentTitle=function(e){for(var k=
n.childNodes,l=false,C="",A=new Da("Change Image Title"),G=0;G<k.length;G++)if(k[G].nodeName=="title"){l=k[G];C=l.textContent;break}if(!l){l=f.createElementNS(b,"title");n.insertBefore(l,n.firstChild)}if(e.length)l.textContent=e;else l.parentNode.removeChild(l);A.addSubCommand(new Ma(l,{"#text":C}));wa(A)};this.getEditorNS=function(e){e&&n.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,k){var l=zb(),C=l.w;l=l.h;var A;
if(e=="fit"){var G=getStrokedBBox();if(G){A=new Da("Fit Canvas to Content");var D=pb();qb(D);var z=[],F=[];$.each(D,function(){z.push(G.x*-1);F.push(G.y*-1)});D=c.moveSelectedElements(z,F,true);A.addSubCommand(D);xa();e=Math.round(G.width);k=Math.round(G.height)}else return false}if(e!=C||k!=l){D=d.suspendRedraw(1E3);A||(A=new Da("Change Image Dimensions"));e=Ba("width",e);k=Ba("height",k);n.setAttribute("width",e);n.setAttribute("height",k);this.contentW=e;this.contentH=k;A.addSubCommand(new Ma(n,
{width:C,height:l}));n.setAttribute("viewBox",[0,0,e/q,k/q].join(" "));A.addSubCommand(new Ma(n,{viewBox:["0 0",C,l].join(" ")}));wa(A);d.unsuspendRedraw(D);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",k+2)}M("changed",[n])}return[e,k]};this.getOffset=function(){return $(n).attr(["x","y"])};this.setBBoxZoom=function(e,k,l){var C=0.85,A=function(G){if(!G)return false;
var D=Math.min(Math.round(k/G.width*100*C)/100,Math.round(l/G.height*100*C)/100);c.setZoom(D);return{zoom:D,bbox:G}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:q*e.factor);return{zoom:q,bbox:e}}return A(e)}switch(e){case "selection":if(!I[0])return;e=$.map(I,function(G){if(G)return G});e=getStrokedBBox(e);break;case "canvas":e=zb();C=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(pb(B().getCurrentLayer()));
for(;e.parentNode&&e.parentNode!==(L||k);)e=e.parentNode;return e};(function(){var e=null,k=null,l=null,C=null,A=null,G={},D={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(z){if(!c.spaceKey){var F=z.button===2;mb=n.querySelector("g").getScreenCTM().inverse();var h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;z.preventDefault();if(F)Ha="select";m=m/q;h=h/q;var o=Bb(z);if(o.tagName==="a"&&o.childNodes.length===1)o=o.firstChild;var u=C=k=m,E=A=l=h;if(p.gridSnapping){m=va(m);h=va(h);k=va(k);
l=va(l)}if(o==ra.selectorParentGroup&&I[0]!=null){o=z.target;var H=cb(o,"type");if(H=="rotate"){Ha="rotate";current_rotate_mode=cb(o,"dir")}else if(H=="resize"){Ha="resize";db=cb(o,"dir")}o=I[0]}Sa=o.getAttribute("transform");H=R(o);switch(Ha){case "select":Ka=true;db="none";if(F)Ka=false;if(o!=d){if(I.indexOf(o)==-1){z.shiftKey||xa(true);qb([o]);wb=o;La.clear()}if(!F)for(F=0;F<I.length;++F)if(I[F]!=null){var J=R(I[F]);J.numberOfItems?J.insertItemBefore(d.createSVGTransform(),0):J.appendItem(d.createSVGTransform())}}else if(!F){xa();
Ha="multiselect";if(sa==null)sa=ra.getRubberBandBox();C*=q;A*=q;ma(sa,{x:C,y:A,width:0,height:0,display:"inline"},100)}break;case "zoom":Ka=true;if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:u*q,y:u*q,width:0,height:0,display:"inline"},100);break;case "resize":Ka=true;k=m;l=h;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var O={};$.each(G,function(X,ba){O[X]=ba/q});G=O;F=na(o)?1:0;if(oa(H)){H.insertItemBefore(d.createSVGTransform(),F);H.insertItemBefore(d.createSVGTransform(),F);H.insertItemBefore(d.createSVGTransform(),
F)}else{H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(m=svgedit.browser.isWebkit())J=function(X){var ba=X.getAttributeNS(null,"stroke");X.removeAttributeNS(null,"stroke");setTimeout(function(){X.setAttributeNS(null,"stroke",ba)},0)};o.style.vectorEffect="non-scaling-stroke";m&&J(o);h=o.getElementsByTagName("*");u=h.length;for(F=0;F<u;F++){h[F].style.vectorEffect="non-scaling-stroke";
m&&J(h[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ka=true;e=u+","+E+" ";J=K.stroke_width==0?1:K.stroke_width;S({element:"polyline",curStyles:true,attr:{points:e,id:ka(),fill:"none",opacity:K.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});D.minx=u;D.maxx=u;D.miny=E;D.maxy=E;break;case "image":Ka=true;J=S({element:"image",attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2,style:"pointer-events:inherit"}});U(J,Ga);Fb(J);break;case "square":case "rect":Ka=true;
k=m;l=h;S({element:"rect",curStyles:true,attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2}});break;case "line":Ka=true;J=K.stroke_width==0?1:K.stroke_width;S({element:"line",curStyles:true,attr:{x1:m,y1:h,x2:m,y2:h,id:ka(),stroke:K.stroke,"stroke-width":J,"stroke-dasharray":K.stroke_dasharray,"stroke-linejoin":K.stroke_linejoin,"stroke-linecap":K.stroke_linecap,"stroke-opacity":K.stroke_opacity,fill:"none",opacity:K.opacity/2,style:"pointer-events:none"}});break;case "circle":Ka=true;S({element:"circle",
curStyles:true,attr:{cx:m,cy:h,r:0,id:ka(),opacity:K.opacity/2}});break;case "ellipse":Ka=true;S({element:"ellipse",curStyles:true,attr:{cx:m,cy:h,rx:0,ry:0,id:ka(),opacity:K.opacity/2}});break;case "text":Ka=true;S({element:"text",curStyles:true,attr:{x:m,y:h,id:ka(),fill:Ua.fill,"stroke-width":Ua.stroke_width,"font-size":Ua.font_size,"font-family":Ua.font_family,"text-anchor":"left","xml:space":"preserve",opacity:K.opacity}});break;case "path":case "pathedit":k*=q;l*=q;La.mouseDown(z,o,k,l);Ka=
true;break;case "textedit":k*=q;l*=q;bb.mouseDown(z,o,k,l);Ka=true;break;case "rotate":Ka=true;c.undoMgr.beginUndoableChange("transform",I);document.getElementById("workarea").className="rotate"}J=ib("mouseDown",{event:z,start_x:k,start_y:l,selectedElements:I},true);$.each(J,function(X,ba){if(ba&&ba.started)Ka=true});if(Ha)document.getElementById("workarea").className=Ha=="resize"?z.target.style.cursor:Ha}}).mousemove(function(z){if(!(z.originalEvent.touches&&z.originalEvent.touches.length>1))if(Ka)if(!(z.button===
1||c.spaceKey)){var F=I[0],h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;var o=pa(aa()),u=x=m/q,E=y=h/q;if(p.gridSnapping){x=va(x);y=va(y)}z.preventDefault();switch(Ha){case "select":if(I[0]!==null){u=x-k;var H=y-l;if(p.gridSnapping){u=va(u);H=va(H)}if(z.shiftKey){var J=V(k,l,x,y);x=J.x;y=J.y}if(u!=0||H!=0){E=I.length;for(var O=0;O<E;++O){F=I[O];if(F==null)break;var X=d.createSVGTransform();o=R(F);if(J){u=J.x-k;H=J.y-l}X.setTranslate(u,H);o.numberOfItems?o.replaceItem(X,0):o.appendItem(X);ra.requestSelector(F).resize()}if(z.altKey)if(!c.addClones){c.addClones=
c.cloneSelectedElements(0,0,X);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(ua){ua.parentNode&&ua.parentNode.removeChild(ua);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",I)}}break;case "multiselect":u*=q;E*=q;ma(sa,{x:Math.min(C,u),y:Math.min(A,E),width:Math.abs(u-C),height:Math.abs(E-A)},100);o=[];u=[];J=ob();E=I.length;for(O=0;O<E;++O){H=J.indexOf(I[O]);if(H==-1)o.push(I[O]);else J[H]=null}E=J.length;for(O=0;O<E;++O)J[O]&&u.push(J[O]);
o.length>0&&c.removeFromSelection(o);u.length>0&&qb(u);break;case "resize":o=R(F);u=(J=oa(o))?G:svgedit.utilities.getBBox(F);E=u.x;O=u.y;var ba=u.width,T=u.height;u=x-k;H=y-l;if(p.gridSnapping){u=va(u);H=va(H);T=va(T);ba=va(ba)}if(X=na(F)){var fa=Math.sqrt(u*u+H*H);H=Math.atan2(H,u)-X*Math.PI/180;u=fa*Math.cos(H);H=fa*Math.sin(H)}if(db.indexOf("n")==-1&&db.indexOf("s")==-1)H=0;if(db.indexOf("e")==-1&&db.indexOf("w")==-1)u=0;var ha=fa=0,W=T?(T+H)/T:1,qa=ba?(ba+u)/ba:1;if(db.indexOf("n")>=0){W=T?(T-
H)/T:1;ha=T}if(db.indexOf("w")>=0){qa=ba?(ba-u)/ba:1;fa=ba}u=d.createSVGTransform();H=d.createSVGTransform();ba=d.createSVGTransform();if(p.gridSnapping){E=va(E);fa=va(fa);O=va(O);ha=va(ha)}u.setTranslate(-(E+fa),-(O+ha));if(z.shiftKey)if(qa==1)qa=W;else W=qa;H.setScale(qa,W);ba.setTranslate(E+fa,O+ha);if(J){J=X?1:0;o.replaceItem(u,2+J);o.replaceItem(H,1+J);o.replaceItem(ba,0+J)}else{J=o.numberOfItems;o.replaceItem(ba,J-3);o.replaceItem(H,J-2);o.replaceItem(u,J-1)}ra.requestSelector(F).resize();M("transition",
I);break;case "zoom":u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-A*q)},100);break;case "text":ma(o,{x:x,y:y},1E3);break;case "line":u=null;window.opera||d.suspendRedraw(1E3);if(p.gridSnapping){x=va(x);y=va(y)}E=x;J=y;if(z.shiftKey){J=V(k,l,E,J);E=J.x;J=J.y}o.setAttributeNS(null,"x2",E);o.setAttributeNS(null,"y2",J);window.opera||d.unsuspendRedraw(u);break;case "foreignObject":case "square":case "rect":case "image":u=Math.abs(x-k);J=Math.abs(y-l);if(Ha==
"square"||z.shiftKey){u=J=Math.max(u,J);E=k<x?k:k-u;O=l<y?l:l-J}else{E=Math.min(k,x);O=Math.min(l,y)}if(z.altKey){u*=2;J*=2;E=k-u/2;O=l-J/2}if(p.gridSnapping){u=va(u);J=va(J);E=va(E);O=va(O)}ma(o,{width:u,height:J,x:E,y:O},1E3);break;case "circle":u=$(o).attr(["cx","cy"]);J=u.cx;E=u.cy;u=Math.sqrt((x-J)*(x-J)+(y-E)*(y-E));if(p.gridSnapping)u=va(u);o.setAttributeNS(null,"r",u);break;case "ellipse":u=$(o).attr(["cx","cy"]);J=Math.abs(k+(x-k)/2);E=Math.abs(l+(y-l)/2);u=null;window.opera||d.suspendRedraw(1E3);
if(p.gridSnapping){x=va(x);J=va(J);y=va(y);E=va(E)}O=Math.abs(k-J);H=Math.abs(l-E);if(z.shiftKey){H=O;E=y>l?l+O:l-O}if(z.altKey){J=k;E=l;O=Math.abs(x-J);H=z.shiftKey?O:Math.abs(y-E)}o.setAttributeNS(null,"rx",O);o.setAttributeNS(null,"ry",H);o.setAttributeNS(null,"cx",J);o.setAttributeNS(null,"cy",E);window.opera||d.unsuspendRedraw(u);break;case "fhellipse":case "fhrect":D.minx=Math.min(u,D.minx);D.maxx=Math.max(u,D.maxx);D.miny=Math.min(E,D.miny);D.maxy=Math.max(E,D.maxy);case "fhpath":e+=+u+","+
E+" ";o.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=q;y*=q;if(p.gridSnapping){x=va(x);y=va(y);k=va(k);l=va(l)}if(z.shiftKey){if(J=svgedit.path.path){o=J.dragging?J.dragging[0]:k;J=J.dragging?J.dragging[1]:l}else{o=k;J=l}J=V(o,J,x,y);x=J.x;y=J.y}if(sa&&sa.getAttribute("display")!=="none"){u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-A*q)},100)}La.mouseMove(z,x,y);break;case "textedit":x*=q;y*=q;bb.mouseMove(m,h);break;case "rotate":u=
svgedit.utilities.getBBox(F);J=u.x+u.width/2;E=u.y+u.height/2;o=ea(F);o=N(J,E,o);J=o.x;E=o.y;o=u.x;O=u.y;if(current_rotate_mode=="nw")o=u.x+u.width;if(current_rotate_mode=="se")O=u.y+u.height;if(current_rotate_mode=="sw"){o=u.x+u.width;O=u.y+u.height}compensation_angle=(Math.atan2(E-O,J-o)*(180/Math.PI)-90)%360;X=(Math.atan2(E-y,J-x)*(180/Math.PI)-90)%360;X+=compensation_angle;if(p.gridSnapping)X=va(X);if(z.shiftKey)X=Math.round(X/45)*45;c.setRotationAngle(X<-180?360+X:X,true);M("transition",I)}ib("mouseMove",
{event:z,mouse_x:m,mouse_y:h,selected:F})}}).click(function(z){z.preventDefault();return false}).dblclick(function(z){var F=z.target.parentNode,h=Bb(z),m=h.tagName;if(F!==L){if(m==="text"&&Ha!=="textedit"){z=N(z.pageX,z.pageY,mb);bb.select(h,z.x,z.y)}if((m==="g"||m==="a")&&na(h)){Db(h);h=I[0];xa(true)}L&&Eb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||h===ra.selectorParentGroup||Kb(h)}}).mouseup(function(z){c.addClones=false;window.removeEventListener("keyup",c.removeClones);I=I.filter(Boolean);
if(z.button!==2){var F=wb;wb=null;if(Ka){var h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;var o=m/q,u=h/q,E=pa(aa()),H=false;Ka=false;switch(Ha){case "resize":case "multiselect":if(sa!=null){sa.setAttribute("display","none");hb=[]}Ha="select";case "select":if(I[0]!=null){if(I.length==1){m=I[0];switch(m.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Xa.fill=m.getAttribute("fill");Xa.fill_opacity=m.getAttribute("fill-opacity");Xa.stroke=m.getAttribute("stroke");Xa.stroke_opacity=
m.getAttribute("stroke-opacity");Xa.stroke_width=m.getAttribute("stroke-width");Xa.stroke_dasharray=m.getAttribute("stroke-dasharray");Xa.stroke_linejoin=m.getAttribute("stroke-linejoin");Xa.stroke_linecap=m.getAttribute("stroke-linecap")}if(m.tagName=="text"){Ua.font_size=m.getAttribute("font-size");Ua.font_family=m.getAttribute("font-family")}ra.requestSelector(m).showGrips(true)}Ea();C=C;A=A;m=Math.abs(u-A);if(m>1||m>1){z=I.length;for(m=0;m<z;++m){if(I[m]==null)break;I[m].firstChild||ra.requestSelector(I[m]).resize()}}else{m=
z.target;if(I[0].nodeName==="path"&&I[1]==null)La.select(I[0]);else z.shiftKey&&F!=m&&c.removeFromSelection([m])}if(svgedit.browser.supportsNonScalingStroke())if(z=I[0]){z.removeAttribute("style");svgedit.utilities.walkTree(z,function(X){X.removeAttribute("style")})}}return;case "zoom":sa!=null&&sa.setAttribute("display","none");M("zoomed",{x:Math.min(C,o),y:Math.min(A,u),width:Math.abs(o-C),height:Math.abs(u-A),factor:z.altKey?0.5:2});return;case "fhpath":F=E.getAttribute("points");u=F.indexOf(",");
if(H=u>=0?F.indexOf(",",u+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)E=La.smoothPolylineIntoPath(E);break;case "line":F=$(E).attr(["x1","x2","y1","y2"]);H=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(E).attr(["width","height"]);H=F.width!=0||F.height!=0||Ha==="image";break;case "circle":H=E.getAttribute("r")!=0;break;case "ellipse":F=$(E).attr(["rx","ry"]);H=F.rx!=null||F.ry!=null;break;case "fhellipse":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"ellipse",
curStyles:true,attr:{cx:(D.minx+D.maxx)/2,cy:(D.miny+D.maxy)/2,rx:(D.maxx-D.minx)/2,ry:(D.maxy-D.miny)/2,id:aa()}});M("changed",[E]);H=true}break;case "fhrect":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"rect",curStyles:true,attr:{x:D.minx,y:D.miny,width:D.maxx-D.minx,height:D.maxy-D.miny,id:aa()}});M("changed",[E]);H=true}break;case "text":H=true;rb([E]);bb.start(E);break;case "path":E=null;Ka=true;F=La.mouseUp(z,E,m,h);E=F.element;H=F.keep;break;case "pathedit":H=true;E=null;La.mouseUp(z);
break;case "textedit":H=false;E=null;bb.mouseUp(z,m,h);break;case "rotate":H=true;E=null;Ha="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||wa(F);Ea();M("changed",I)}m=ib("mouseUp",{event:z,mouse_x:m,mouse_y:h},true);$.each(m,function(X,ba){if(ba){H=ba.keep||H;E=ba.element;Ka=ba.started||Ka}});if(!H&&E!=null){B().releaseId(aa());E.parentNode.removeChild(E);E=null;for(m=z.target;m.parentNode.parentNode.tagName=="g";)m=m.parentNode;if((Ha!="path"||!drawn_path)&&m.parentNode.id!="selectorParentGroup"&&
m.id!="svgcanvas"&&m.id!="svgroot"){c.setMode("select");rb([m],true)}}else if(E!=null){c.addedNew=true;z=0.2;var J;if(false.beginElement&&E.getAttribute("opacity")!=K.opacity){J=$(false).clone().attr({to:K.opacity,dur:z}).appendTo(E);try{J[0].beginElement()}catch(O){}}else z=0;setTimeout(function(){J&&J.remove();E.setAttribute("opacity",K.opacity);E.setAttribute("style","pointer-events:inherit");la(E);if(Ha==="path")La.toEditMode(E);else p.selectNew&&rb([E],true);wa(new Ia(E));M("changed",[E])},z*
1E3)}Sa=null}}});$(a).bind("mousewheel DOMMouseScroll",function(z){if(z.shiftKey){z.preventDefault();mb=n.getScreenCTM().inverse();var F=N(z.pageX,z.pageY,mb);F={x:F.x,y:F.y,width:0,height:0};if(z.wheelDelta)if(z.wheelDelta>=120)F.factor=2;else{if(z.wheelDelta<=-120)F.factor=0.5}else if(z.detail)if(z.detail>0)F.factor=0.5;else if(z.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var Fb=function(e){$(e).click(function(k){k.preventDefault()})},bb=c.textActions=function(){function e(T){var fa=h.value===
"";$(h).focus();if(!arguments.length)if(fa)T=0;else{if(h.selectionEnd!==h.selectionStart)return;T=h.selectionEnd}var ha;ha=E[T];fa||h.setSelectionRange(T,T);m=pa("text_cursor");if(!m){m=document.createElementNS(b,"line");ma(m,{id:"text_cursor",stroke:"#333","stroke-width":1});m=pa("selectorParentGroup").appendChild(m)}u||(u=setInterval(function(){var W=m.getAttribute("display")==="none";m.setAttribute("display",W?"inline":"none")},600));fa=G(ha.x,H.y);ha=G(ha.x,H.y+H.height);ma(m,{x1:fa.x,y1:fa.y,
x2:ha.x,y2:ha.y,visibility:"visible",display:"inline"});o&&o.setAttribute("d","M 0 0")}function k(T,fa,ha){if(T===fa)e(fa);else{ha||h.setSelectionRange(T,fa);o=pa("text_selectblock");if(!o){o=document.createElementNS(b,"path");ma(o,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});pa("selectorParentGroup").appendChild(o)}T=E[T];var W=E[fa];m.setAttribute("visibility","hidden");fa=G(T.x,H.y);ha=G(T.x+(W.x-T.x),H.y);var qa=G(T.x,H.y+H.height);T=G(T.x+(W.x-T.x),H.y+H.height);
ma(o,{d:"M"+fa.x+","+fa.y+" L"+ha.x+","+ha.y+" "+T.x+","+T.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function l(T,fa){var ha=d.createSVGPoint();ha.x=T;ha.y=fa;if(E.length==1)return 0;ha=F.getCharNumAtPosition(ha);if(ha<0){ha=E.length-2;if(T<=E[0].x)ha=0}else if(ha>=E.length-2)ha=E.length-2;var W=E[ha];T>W.x+W.width/2&&ha++;return ha}function C(T,fa,ha){var W=h.selectionStart;T=l(T,fa);k(Math.min(W,T),Math.max(W,T),!ha)}function A(T,fa){var ha={x:T,y:fa};ha.x/=q;ha.y/=q;if(J){var W=N(ha.x,ha.y,J.inverse());
ha.x=W.x;ha.y=W.y}return ha}function G(T,fa){var ha={x:T,y:fa};if(J){var W=N(ha.x,ha.y,J);ha.x=W.x;ha.y=W.y}ha.x*=q;ha.y*=q;return ha}function D(T){k(0,F.textContent.length);$(this).unbind(T)}function z(T){if(ba&&F){var fa=N(T.pageX,T.pageY,mb);fa=A(fa.x*q,fa.y*q);fa=l(fa.x,fa.y);var ha=F.textContent,W=ha.substr(0,fa).replace(/[a-z0-9]+$/i,"").length;ha=ha.substr(fa).match(/^[a-z0-9]+/i);k(W,(ha?ha[0].length:0)+fa);$(T.target).click(D);setTimeout(function(){$(T.target).unbind("click",D)},300)}}var F,
h,m,o,u,E=[],H,J,O,X,ba;return{select:function(T,fa,ha){F=T;bb.toEditMode(fa,ha)},start:function(T){F=T;bb.toEditMode()},mouseDown:function(T,fa,ha,W){T=A(ha,W);h.focus();e(l(T.x,T.y));O=ha;X=W},mouseMove:function(T,fa){var ha=A(T,fa);C(ha.x,ha.y)},mouseUp:function(T,fa,ha){var W=A(fa,ha);C(W.x,W.y,true);T.target!==F&&fa<O+2&&fa>O-2&&ha<X+2&&ha>X-2&&bb.toSelectMode(true)},setCursor:e,toEditMode:function(T,fa){rb([F],false);ba=false;Ha="textedit";ra.requestSelector(F).showGrips(false);ra.requestSelector(F);
bb.init();$(F).css("cursor","text");if(arguments.length){var ha=A(T,fa);e(l(ha.x,ha.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(T){Ha="select";clearInterval(u);u=null;o&&$(o).attr("display","none");m&&$(m).attr("visibility","hidden");$(F).css("cursor","move");if(T){xa();$(F).css("cursor","move");M("selected",[F]);qb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(h).blur();F=false},setInputElem:function(T){h=T},clear:function(){Ha=="textedit"&&bb.toSelectMode()},
init:function(){if(F){if(!F.parentNode){F=I[0];ra.requestSelector(F).showGrips(false)}var T=F.textContent.length,fa=F.getAttribute("transform");H=svgedit.utilities.getBBox(F);J=fa?ea(F):null;E=Array(T);h.focus();$(F).unbind("dblclick",z).dblclick(z);if(!T)var ha={x:H.x+H.width/2,width:0};for(fa=0;fa<T;fa++){var W=F.getStartPositionOfChar(fa);ha=F.getEndPositionOfChar(fa);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*q;W.x-=qa;ha.x-=qa;W.x/=q;ha.x/=q}E[fa]={x:W.x,y:H.y,width:ha.x-
W.x,height:H.height}}E.push({x:ha.x,width:0});k(h.selectionStart,h.selectionEnd,true)}}}}(),La=c.pathActions=function(){var e=false,k,l,C;svgedit.path.Path.prototype.endChanges=function(D){if(svgedit.browser.isWebkit()){var z=this.elem;z.setAttribute("d",La.convertPath(z))}D=new Ma(this.elem,{d:this.last_d},D);wa(D);M("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(D){$.isArray(D)||(D=[D]);for(var z=0;z<D.length;z++){var F=D[z],h=this.segs[F];h.ptgrip&&this.selected_pts.indexOf(F)==
-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();z=this.selected_pts.length;for(D=Array(z);z--;){h=this.segs[this.selected_pts[z]];h.select(true);D[z]=h.ptgrip}La.canDeleteNodes=true;La.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",D)};var A=k=null,G=false;this.lastCtrlPoint=[0,0];return{mouseDown:function(D,z,F,h){if(Ha==="path"){mouse_x=F;mouse_y=h;F=mouse_x/q;z=mouse_y/q;h=pa("path_stretch_line");l=[F,z];if(p.gridSnapping){F=va(F);z=va(z);mouse_x=va(mouse_x);
mouse_y=va(mouse_y)}if(!h){h=document.createElementNS(b,"path");ma(h,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});h=pa("selectorParentGroup").appendChild(h)}h.setAttribute("display","inline");this.stretchy=h;var m=null;if(A){m=A.pathSegList;for(var o=m.numberOfItems,u=6/q,E=false;o;){o--;var H=m.getItem(o),J=H.x;H=H.y;if(F>=J-u&&F<=J+u&&z>=H-u&&z<=H+u){E=true;break}}u=aa();svgedit.path.removePath_(u);u=pa(u);J=m.numberOfItems;if(E){if(o<=1&&J>=2){F=m.getItem(0).x;z=m.getItem(0).y;
o=svgedit.path.first_grip?svgedit.path.first_grip[0]/q:m.getItem(0).x;E=svgedit.path.first_grip?svgedit.path.first_grip[1]/q:m.getItem(0).y;D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(F,z):A.createSVGPathSegCurvetoCubicAbs(F,z,D.x1/q,D.y1/q,o,E);F=A.createSVGPathSegClosePath();m.appendItem(D);m.appendItem(F)}else if(J<3)return m=false;$(h).remove();element=u;A=null;Ka=false;if(e){svgedit.path.path.matrix&&Za(u,{},svgedit.path.path.matrix.inverse());F=u.getAttribute("d");
h=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",h+F);$(u).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();La.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Bb(D))){console.log("Clicked outside canvas");return false}m=A.pathSegList.numberOfItems;o=A.pathSegList.getItem(m-1);u=o.x;o=o.y;if(D.shiftKey){z=V(u,o,F,z);F=z.x;z=z.y}D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(ab(F),
ab(z)):A.createSVGPathSegCurvetoCubicAbs(ab(F),ab(z),D.x1/q,D.y1/q,D.x2/q,D.y2/q);A.pathSegList.appendItem(D);F*=q;z*=q;h.setAttribute("d",["M",F,z,F,z].join(" "));h=svgedit.path.addCtrlGrip("1c1");D=svgedit.path.addCtrlGrip("0c2");u=svgedit.path.getCtrlLine(1);o=svgedit.path.getCtrlLine(2);h.setAttribute("cx",F);h.setAttribute("cy",z);D.setAttribute("cx",F);D.setAttribute("cy",z);u.setAttribute("x1",F);u.setAttribute("x2",F);u.setAttribute("y1",z);u.setAttribute("y2",z);o.setAttribute("x1",F);o.setAttribute("x2",
F);o.setAttribute("y1",z);o.setAttribute("y2",z);h=m;if(e)h+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(h,F,z)}m=true}else{d_attr="M"+F+","+z+" ";A=S({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:K.opacity/2}});h.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));h=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(h,mouse_x,mouse_y);svgedit.path.first_grip=null}}else if(svgedit.path.path){svgedit.path.path.storeD();u=D.target.id;if(u.substr(0,
14)=="pathpointgrip_"){z=svgedit.path.path.cur_pt=parseInt(u.substr(14));svgedit.path.path.dragging=[F,h];u=svgedit.path.path.segs[z];if(D.shiftKey)u.selected?svgedit.path.path.removePtFromSelection(z):svgedit.path.path.addPtsToSelection(z);else{if(svgedit.path.path.selected_pts.length<=1||!u.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(z)}}else if(u.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,h];D=u.split("_")[1].split("c");z=D[0]-0;m=D=D[1]-0;o=
svgedit.path.path.segs[z];svgedit.path.path.selectPt(z,D);if(m==2){E=1;u=o.next}else{E=2;u=o.prev}if(!u)return;D=function(O,X){return Math.sqrt(Math.pow(O.x-X.x,2)+Math.pow(O.y-X.y,2))};z={x:o.item["x"+m],y:o.item["y"+m]};m=m==2?{x:o.item.x,y:o.item.y}:{x:u.item.x,y:u.item.y};o={x:u.item["x"+E],y:u.item["y"+E]};u=D(z,m);D=D(o,m);z=Math.abs(Math.round(Math.atan2(z.y-m.y,z.x-m.x)*(180/Math.PI),0)-Math.round(Math.atan2(o.y-m.y,o.x-m.x)*(180/Math.PI),0))==180;if(Math.abs(u-D)<5&&z){svgedit.path.setLinkControlPoints(true);
svgedit.path.is_linked=true}else{svgedit.path.setLinkControlPoints(false);svgedit.path.is_linked=false}}if(!svgedit.path.path.dragging){if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:F*q,y:h*q,width:0,height:0,display:"inline"},100)}}},mouseMove:function(D,z,F){G=true;var h=!D.altKey;if(Ha==="path"){if(A){var m=A.pathSegList,o=m.numberOfItems-1,u=svgedit.path.addCtrlGrip("1c1"),E=svgedit.path.addCtrlGrip("0c2");if(l){var H=E.getAttribute("cx")/q||0,J=E.getAttribute("cy")/q||0;u.setAttribute("cx",z);
u.setAttribute("cy",F);u.setAttribute("display","inline");D=l[0];u=l[1];m.getItem(o);var O=z/q,X=F/q;H=h?D+(D-O):H;h=h?u+(u-X):J;E.setAttribute("cx",H*q);E.setAttribute("cy",h*q);E.setAttribute("display","inline");E=svgedit.path.getCtrlLine(1);J=svgedit.path.getCtrlLine(2);ma(E,{x1:z,y1:F,x2:D*q,y2:u*q,display:"inline"});ma(J,{x1:H*q,y1:h*q,x2:D*q,y2:u*q,display:"inline"});if(o===0)C=[z,F];else{m=m.getItem(o-1);z=m.x;F=m.y;if(m.pathSegType===6){z+=z-m.x2;F+=F-m.y2}else if(C){z=C[0]/q;F=C[1]/q}svgedit.path.replacePathSeg(6,
o,[D,u,this.lastCtrlPoint[0]/q,this.lastCtrlPoint[1]/q,H,h],A)}}else if(h=this.stretchy){o=m.getItem(o);m=z;u=F;if(D.target.id==="pathpointgrip_0"&&svgedit.path.first_grip){m=svgedit.path.first_grip[0];u=svgedit.path.first_grip[1]}if(o.pathSegType===6)svgedit.path.replacePathSeg(6,1,[z,F,(this.lastCtrlPoint[0]/q||o.x+(o.x-o.x2))*q,(this.lastCtrlPoint[1]/q||o.y+(o.y-o.y2))*q,m,u],h);else C?svgedit.path.replacePathSeg(6,1,[z,F,C[0],C[1],z,F],h):svgedit.path.replacePathSeg(4,1,[z,F],h)}}}else if(svgedit.path.path.dragging){m=
svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);D=svgedit.path.getPointFromGrip({x:z,y:F},svgedit.path.path);o=D.x-m.x;m=D.y-m.y;svgedit.path.path.dragging=[z,F];!h||!svgedit.path.is_linked?svgedit.path.setLinkControlPoints(false):svgedit.path.setLinkControlPoints(true);svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(o,m):svgedit.path.path.movePts(o,m)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||
this.prev){var ba=sa.getBBox(),T=svgedit.path.getGripPt(this);ba=svgedit.math.rectsIntersect(ba,{x:T.x,y:T.y,width:0,height:0});this.select(ba);ba&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(D,z,F,h){var m=pa("ctrlpointgrip_1c1"),o=pa("ctrlpointgrip_0c2");this.lastCtrlPoint=m?[m.getAttribute("cx"),m.getAttribute("cy")]:[F,h];if(!svgedit.path.first_grip&&o)svgedit.path.first_grip=[o.getAttribute("cx"),o.getAttribute("cy")];if(Ha==="path"){l=null;if(!A){z=pa(aa());Ka=false;
C=null}return{keep:true,element:z}}if(svgedit.path.path.dragging){z=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!D.shiftKey&&!G&&svgedit.path.path.selectPt(z)}else if(sa&&sa.getAttribute("display")!="none"){sa.setAttribute("display","none");sa.getAttribute("width")<=2&&sa.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=
svgedit.path.getPath_(D);Ha="pathedit";xa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(D){var z=D==svgedit.path.path.elem;Ha="select";svgedit.path.path.show(false);k=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(z){M("selected",[D]);qb([D],true)}},addSubPath:function(D){if(D){Ha="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(k===
D){La.toEditMode(D);Ha="pathedit"}else k=D},reorient:function(){var D=I[0];if(D)if(na(D)!=0){var z=new Da("Reorient path"),F={d:D.getAttribute("d"),transform:D.getAttribute("transform")};z.addSubCommand(new Ma(D,F));xa();this.resetOrientation(D);wa(z);svgedit.path.getPath_(D).show(false).matrix=null;this.clear();qb([D],true);M("changed",I)}},clear:function(D){k=null;if(A){var z=pa(aa());$(pa("path_stretch_line")).remove();D&&$(z).remove();$(pa("pathpointgrip_container")).find("*").attr("display",
"none");A=C=null;Ka=false}else Ha=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(D){if(D==null||D.nodeName!="path")return false;var z=R(D),F=Y(z).matrix;z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var h=z.numberOfItems,m=0;m<h;++m){var o=z.getItem(m),u=o.pathSegType;if(u!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],X=o["y"+J];if(O!==undefined&&X!==undefined){O=N(O,X,F);E.splice(E.length,0,O.x,O.y)}});
svgedit.path.replacePathSeg(u,m,E,D)}}g(D,F)},zoomChange:function(){Ha=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){if(svgedit.path.path){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var h=D[z];svgedit.path.path.addSeg(h);
F.push(h+z);F.push(h+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var z=svgedit.path.path.elem,F=z.pathSegList,h=D[0],m=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=h)o=this.item;if(J<=h)return true;if(this.type===2){m=J;return false}else if(this.type===1)return m=false});if(m==null)m=svgedit.path.path.segs.length-1;if(m!==false){var u=
z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(m==svgedit.path.path.segs.length){F.appendItem(u);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,m);svgedit.path.insertItemBefore(z,u,m)}svgedit.path.path.init().selectPt(m+1)}else if(svgedit.path.path.segs[h].mate){F.removeItem(h);F.removeItem(h);svgedit.path.path.init().selectPt(h-1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)u=D;else if(D===h)F.removeItem(u);else if(H.pathSegType===
1&&h<D){E=D-1;F.removeItem(D);break}}for(D=h-u-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(u),E);z=F.getItem(u);svgedit.path.replacePathSeg(2,u,[z.x,z.y]);D=h;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length;z--;)svgedit.path.path.deleteSeg(D[z]);var F=function(){var h=svgedit.path.path.elem.pathSegList,m=h.numberOfItems,o=function(H,J){for(;J--;)h.removeItem(H)};if(m<=1)return true;
for(;m--;){var u=h.getItem(m);if(u.pathSegType===1){u=h.getItem(m-1);var E=h.getItem(m-2);if(u.pathSegType===2){o(m-1,2);F();break}else if(E.pathSegType===2){o(m-2,3);F();break}}else if(u.pathSegType===2)if(m>0){u=h.getItem(m-1).pathSegType;if(u===2){o(m-1,1);F();break}else if(u===1&&h.numberOfItems-1===m){o(m,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){c.setMode("select");c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();
if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var h=z.getItem(0),m=null;D=[];D.push(["M",h.x,",",h.y," C"].join(""));for(var o=1;o<=F-4;o+=3){var u=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(m)if((h=svgedit.path.smoothControlPoints(m,u,h))&&h.length==2){u=D[D.length-1].split(",");u[2]=h[0].x;u[3]=h[0].y;D[D.length-1]=u.join(",");u=h[1]}D.push([u.x,
u.y,E.x,E.y,H.x,H.y].join(","));h=H;m=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var h={x:0,y:0};h[D]=z-F.item[D];F.move(h.x,h.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=
D.pathSegList,F=z.numberOfItems,h,m=0;m<F;++m){var o=z.getItem(m);if(o.pathSegType===2)h=o;if(o.pathSegType===1){o=z.getItem(m-1);if(o.x!=h.x||o.y!=h.y){z=D.createSVGPathSegLinetoAbs(h.x,h.y);svgedit.path.insertItemBefore(D,z,m);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,h=F.numberOfItems,m=0,o=0,u="",E=null,H=0;H<h;++H){var J=F.getItem(H),O=J.x||0,X=J.y||0,ba=J.x1||0,T=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,
qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});u+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:u+="z";break;case 12:O-=m;case 13:if(z){m+=O;qa="l"}else{O+=m;m=O;qa="L"}ua([[O,o]]);break;case 14:X-=o;case 15:if(z){o+=X;qa="l"}else{X+=o;o=X;qa="L"}ua([[m,X]]);break;case 2:case 4:case 18:O-=m;X-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){m=E[0];
o=E[1]}case 19:if(z){m+=O;o+=X}else{O+=m;X+=o;m=O;o=X}if(W===3)E=[m,o];ua([[O,X]]);break;case 6:O-=m;ba-=m;fa-=m;X-=o;T-=o;ha-=o;case 7:if(z){m+=O;o+=X}else{O+=m;ba+=m;fa+=m;X+=o;T+=o;ha+=o;m=O;o=X}ua([[ba,T],[fa,ha],[O,X]]);break;case 8:O-=m;ba-=m;X-=o;T-=o;case 9:if(z){m+=O;o+=X}else{O+=m;ba+=m;X+=o;T+=o;m=O;o=X}ua([[ba,T],[O,X]]);break;case 10:O-=m;X-=o;case 11:if(z){m+=O;o+=X}else{O+=m;X+=o;m=O;o=X}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,X]);break;case 16:O-=m;fa-=m;X-=
o;ha-=o;case 17:if(z){m+=O;o+=X}else{O+=m;fa+=m;X+=o;ha+=o;m=O;o=X}ua([[fa,ha],[O,X]])}}return u}}}(),yb=this.removeUnusedDefElems=function(){var e=n.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],l=0,C=["fill","stroke","filter","marker-start","marker-mid","marker-end"],A=C.length,G=n.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=G[z],h=0;h<A;h++)if(F){var m=ja(F.getAttribute(C[h]));m&&k.push(m.substr(1))}(F=ca(F))&&F.indexOf("#")===0&&k.push(F.substr(1))}e=
$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){C=e[z];A=C.id;if(k.indexOf(A)<0){sb[A]=C;C.parentNode.removeChild(C);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);La.clear(true);$.each(n.childNodes,function(l,C){l&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&n.insertBefore(C,n.firstChild)});if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(n).find("g:data(gsvg)").each(function(){for(var l=this.attributes,
C=l.length,A=0;A<C;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")C--;if(C<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var k=this.svgToString(n,0);e.length&&$(e).each(function(){tb(this)});return k};this.svgToString=function(e,k){var l=[],C=svgedit.utilities.toXml,A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,h=e.childNodes;for(F=0;F<k;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,
A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var m={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!m[O]&&ya[O]!=="xmlns"&&ya[O]!=="xml"){m[O]=true;l.push(" xmlns:"+ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){z=D.item(F);var o=C(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||
ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var u=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=0;F--){z=D.item(F);o=C(z.nodeValue);if(!(u.indexOf(z.localName)>=0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);
if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");k++;D=false;for(F=0;F<h.length;F++){A=h.item(F);switch(A.nodeType){case 1:l.push("\n");l.push(this.svgToString(h.item(F),k));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(C(A)+"")}break;case 4:l.push("\n");l.push(Array(k+
1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(k+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}k--;if(!D){l.push("\n");for(F=0;F<k;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+
encodeURIComponent(e);C=l.toDataURL().replace(";base64",C+";base64");Va[e]=C}catch(A){Va[e]=false}Ga=e;k&&k(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Ga=e};this.open=function(){};this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],k={feGaussianBlur:kb.exportNoBlur,foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(n);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=
kb.exportNoText;$.each(k,function(C,A){l.find(C).length&&e.push(A)});k=this.svgCanvasToString();M("exported",{svg:k,issues:e})};this.getSvgString=function(){$a.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 Hb=this.uniquifyElems=function(e){var k={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,
function(z){if(z.nodeType==1){if(z.id){z.id in k||(k[z.id]={elem:null,attrs:[],hrefs:[]});k[z.id].elem=z}$.each(vb,function(h,m){var o=z.getAttributeNode(m);if(o){var u=svgedit.utilities.getUrlFromAttr(o.value);if(u=u?u.substr(1):null){u in k||(k[u]={elem:null,attrs:[],hrefs:[]});k[u].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=0)if(F=F.substr(1)){F in k||(k[F]={elem:null,attrs:[],hrefs:[]});k[F].hrefs.push(z)}}});for(var C in k)if(C){var A=k[C].elem;if(A){e=
ka();A.id=e;A=k[C].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=k[C].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var l=ca(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Ib=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 l=$(n).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=Y(A).matrix;A=N(C.x1,C.y1,G);G=N(C.x2,C.y2,
G);C.x1=A.x;C.y1=A.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-l.x)/l.width,y1:(C.y1-l.y)/l.height,x2:(C.x2-l.x)/l.width,y2:(C.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Lb=this.convertToGroup=function(e){e||(e=I[0]);var k=$(e),l=new Da,C;if(k.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");C=R(e);var A=d.createSVGTransform();A.setTranslate(l.x,l.y);C.appendItem(A);Ra(e);M("selected",
[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");A=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}C+=" translate("+(A.x||0)+","+(A.y||0)+")";A=k.prev();l.addSubCommand(new Fa(k[0],k[0].nextSibling,k[0].parentNode));k.remove();G=$(n).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,z=0;z<D.length;z++)k.appendChild(D[z].cloneNode(true));if(svgedit.browser.isGecko()){D=$(gb()).children("linearGradient,radialGradient,pattern").clone();
$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Hb(k);svgedit.browser.isGecko()&&$(gb()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();A.after(k);if(C){if(!G){A=e.nextSibling;C.removeChild(e);l.addSubCommand(new Fa(e,A,C))}l.addSubCommand(new Ia(k))}Gb(k);svgedit.browser.isGecko()?Ib(gb()):Ib(k);svgedit.utilities.walkTreePost(k,function(F){try{Ra(F)}catch(h){console.log(h)}});$(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()});rb([k]);(e=Db(k,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);this.prepareSvg(k);var l=new Da("Change Source"),C=n.nextSibling,A=d.removeChild(n);l.addSubCommand(new Fa(A,C,d));n=f.adoptNode?f.adoptNode(k.documentElement):f.importNode(k.documentElement,true);d.appendChild(n);var G=$(n);c.current_drawing_=new svgedit.draw.Drawing(n,v);var D=B().getNonce();D?M("setnonce",D):M("unsetnonce");
G.find("image").each(function(){var J=this;Fb(J);var O=ca(this);if(O.indexOf("data:")===0){var X=O.match(/svgedit_url=(.*?);/);if(X){var ba=decodeURIComponent(X[1]);$(new Image).load(function(){J.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",ba)}).attr("src",ba)}}c.embedImage(O)});G.find("svg").each(function(){if(!$(this).closest("defs").length){Hb(this);var J=this.parentNode;if(J.childNodes.length===1&&J.nodeName==="g"){$(J).data("gsvg",this);J.id=J.id||ka()}else tb(this)}});G.find("linearGradient, radialGradient, pattern").appendTo(gb());
Gb(G);Ib(G[0]);svgedit.utilities.walkTreePost(n,function(J){try{Ra(J)}catch(O){console.log(O)}});var z={id:"svgcontent",overflow:p.show_outside_canvas?"visible":"hidden"},F=false;if(G.attr("viewBox")){var h=G.attr("viewBox").split(" ");z.width=h[2];z.height=h[3]}else $.each(["width","height"],function(J,O){var X=G.attr(O);X||(X="100%");if((X+"").substr(-1)==="%")F=true;else z[O]=Ba(O,X)});xb();G.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ka()});if(F){var m=getStrokedBBox();z.width=m.width+m.x;z.height=m.height+m.y}if(z.width<=0)z.width=200;if(z.height<=0)z.height=200;G.attr(z);this.contentW=z.width;this.contentH=z.height;$("#canvas_width").val(this.contentW);$("#canvas_height").val(this.contentH);var o=$("#canvas_background");if(o.length){var u=o.attr("fill-opacity");u=u?parseInt(u)*100:100;fill=this.getPaint(o.attr("fill"),u,"canvas")}else fill=this.getPaint("none",100,"canvas");methodDraw.paintBox.canvas.setPaint(fill);l.addSubCommand(new Ia(n));
var E=G.attr(["width","height"]);l.addSubCommand(new Ma(d,E));q=1;svgedit.transformlist.resetListMap();xa();svgedit.path.clearData();d.appendChild(ra.selectorParentGroup);wa(l);M("changed",[n])}catch(H){console.log(H);return false}return true};this.getPaint=function(e,k,l){var C=null;if(e.indexOf("url(#")===0){e=(e=svgCanvas.getRefElem(e))?e.cloneNode(true):$("#"+l+"_color defs *")[0];C={alpha:k};C[e.tagName]=e}else C=e.indexOf("#")===0?{alpha:k,solidColor:e.substr(1)}:{alpha:k,solidColor:"none"};
return new $.jGraduate.Paint(C)};this.importSvgString=function(e){try{var k=svgedit.utilities.encode64(e.length+e).substr(0,32),l=false;if(lb[k])if($(lb[k].symbol).parents("#svgroot").length)l=true;var C=new Da("Import SVG");if(l)var A=lb[k].symbol,G=lb[k].xform;else{var D=svgedit.utilities.text2xml(e);this.prepareSvg(D);var z;z=f.adoptNode?f.adoptNode(D.documentElement):f.importNode(D.documentElement,true);Hb(z);var F=Ba("width",z.getAttribute("width")),h=Ba("height",z.getAttribute("height")),m=
z.getAttribute("viewBox"),o=m?m.split(" "):[0,0,F,h];for(e=0;e<4;++e)o[e]=+o[e];n.getAttribute("width");var u=+n.getAttribute("height");G=h>F?"scale("+u/3/o[3]+")":"scale("+u/3/o[2]+")";G="translate(0) "+G+" translate(0)";A=f.createElementNS(b,"symbol");var E=gb();for(svgedit.browser.isGecko()&&$(z).find("linearGradient, radialGradient, pattern").appendTo(E);z.firstChild;)A.appendChild(z.firstChild);var H=z.attributes;for(z=0;z<H.length;z++){var J=H[z];A.setAttribute(J.nodeName,J.nodeValue)}A.id=
ka();lb[k]={symbol:A,xform:G};gb().appendChild(A);C.addSubCommand(new Ia(A))}var O=f.createElementNS(b,"use");O.id=ka();U(O,"#"+A.id);(L||B().getCurrentLayer()).appendChild(O);C.addSubCommand(new Ia(O));xa();O.setAttribute("transform",G);Ra(O);$(O).data("symbol",A).data("ref",A);qb([O]);wa(C);M("changed",[n])}catch(X){console.log(X);return false}return true};var xb=c.identifyLayers=function(){Eb();B().identifyLayers()};this.createLayer=function(e){var k=new Da("Create Layer");e=B().createLayer(e);
k.addSubCommand(new Ia(e));wa(k);xa();M("changed",[e])};this.cloneLayer=function(e){var k=new Da("Duplicate Layer"),l=f.createElementNS(b,"g"),C=f.createElementNS(b,"title");C.textContent=e;l.appendChild(C);C=B().getCurrentLayer();$(C).after(l);C=C.childNodes;for(var A=0;A<C.length;A++){var G=C[A];G.localName!="title"&&l.appendChild(ia(G))}xa();xb();k.addSubCommand(new Ia(l));wa(k);c.setCurrentLayer(e);M("changed",[l])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),k=e.nextSibling,
l=e.parentNode;if(e=B().deleteCurrentLayer()){var C=new Da("Delete Layer");C.addSubCommand(new Fa(e,k,l));wa(C);xa();M("changed",[l]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&xa();return e};this.renameCurrentLayer=function(e){var k=B();if(k.current_layer){var l=k.current_layer;if(!c.setCurrentLayer(e)){for(var C=new Da("Rename Layer"),A=0;A<k.getNumLayers();++A)if(k.all_layers[A][1]==l)break;var G=k.getLayerName(A);k.all_layers[A][0]=
svgedit.utilities.toXml(e);var D=l.childNodes.length;for(A=0;A<D;++A){var z=l.childNodes.item(A);if(z&&z.tagName=="title"){for(;z.firstChild;)z.removeChild(z.firstChild);z.textContent=e;C.addSubCommand(new Ma(z,{"#text":G}));wa(C);M("changed",[l]);return true}}}k.current_layer=l}return false};this.setCurrentLayerPosition=function(e){var k=B();if(k.current_layer&&e>=0&&e<k.getNumLayers()){for(var l=0;l<k.getNumLayers();++l)if(k.all_layers[l][1]==k.current_layer)break;if(l==k.getNumLayers())return false;
if(l!=e){var C=null,A=k.current_layer.nextSibling;if(e>l){if(e<k.getNumLayers()-1)C=k.all_layers[e+1][1]}else C=k.all_layers[e][1];n.insertBefore(k.current_layer,C);wa(new Ja(k.current_layer,A,n));xb();c.setCurrentLayer(k.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,k){var l=B(),C=l.getLayerVisibility(e),A=l.setLayerVisibility(e,k);if(A)wa(new Ma(A,{display:C?"inline":"none"},"Layer Visibility"));else return false;if(A==l.getCurrentLayer()){xa();La.clear()}return true};
this.moveSelectedToLayer=function(e){for(var k=null,l=B(),C=0;C<l.getNumLayers();++C)if(l.getLayerName(C)==e){k=l.all_layers[C][1];break}if(!k)return false;e=new Da("Move Elements to Layer");l=I;for(C=l.length;C--;){var A=l[C];if(A){var G=A.nextSibling,D=A.parentNode;k.appendChild(A);e.addSubCommand(new Ja(A,G,D))}}wa(e);return true};this.mergeLayer=function(e){var k=new Da("Merge Layer"),l=B(),C=$(l.current_layer).prev()[0];if(C){for(k.addSubCommand(new Fa(l.current_layer,l.current_layer.nextSibling,
n));l.current_layer.firstChild;){var A=l.current_layer.firstChild;if(A.localName=="title"){k.addSubCommand(new Fa(A,A.nextSibling,l.current_layer));l.current_layer.removeChild(A)}else{var G=A.nextSibling;C.appendChild(A);k.addSubCommand(new Ja(A,G,l.current_layer))}}n.removeChild(l.current_layer);if(!e){xa();xb();M("changed",[n]);wa(k)}l.current_layer=C;return k}};this.mergeAllLayers=function(){var e=new Da("Merge all Layers"),k=B();for(k.current_layer=k.all_layers[k.getNumLayers()-1][1];$(n).children("g").length>
1;)e.addSubCommand(c.mergeLayer(true));xa();xb();M("changed",[n]);wa(e)};var Eb=this.leaveContext=function(){var e=ta.length;if(e){for(var k=0;k<e;k++){var l=ta[k],C=cb(l,"orig_opac");C!==1?l.setAttribute("opacity",C):l.removeAttribute("opacity");l.setAttribute("style","pointer-events: inherit")}ta=[];xa(true);M("contextset",null)}L=null},Kb=this.setContext=function(e){Eb();if(typeof e==="string")e=pa(e);L=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var k=this.getAttribute("opacity")||
1;cb(this,"orig_opac",k);this.setAttribute("opacity",k*0.33);this.setAttribute("style","pointer-events: none");ta.push(this)});xa();M("contextset",L)};this.clear=function(){La.clear();xa();c.clearSvgContentElement();c.current_drawing_=new svgedit.draw.Drawing(n);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();ra.initGroup();sa=ra.getRubberBandBox();M("cleared")};this.linkControlPoints=La.linkControlPoints;this.getContentElem=function(){return n};this.getRootElem=function(){return d};this.getSelectedElems=
function(){return I};var zb=this.getResolution=function(){var e=n.getAttribute("width")/q,k=n.getAttribute("height")/q;return{w:e,h:k,zoom:q}};this.getZoom=function(){return q};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(kb,e.notification)};this.setConfig=function(e){$.extend(p,e)};this.getTitle=function(e){if(e=e||I[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var k=0;k<e.length;k++)if(e[k].nodeName=="title")return e[k].textContent;
return""}};this.setGroupTitle=function(e){var k=I[0];k=$(k).data("gsvg")||k;var l=$(k).children("title"),C=new Da("Set Label");if(e.length)if(l.length){l=l[0];C.addSubCommand(new Ma(l,{"#text":l.textContent}));l.textContent=e}else{l=f.createElementNS(b,"title");l.textContent=e;$(k).prepend(l);C.addSubCommand(new Ia(l))}else{C.addSubCommand(new Fa(l[0],l.nextSibling,k));l.remove()}wa(C)};this.getDocumentTitle=function(){return c.getTitle(n)};this.setDocumentTitle=function(e){for(var k=n.childNodes,
l=false,C="",A=new Da("Change Image Title"),G=0;G<k.length;G++)if(k[G].nodeName=="title"){l=k[G];C=l.textContent;break}if(!l){l=f.createElementNS(b,"title");n.insertBefore(l,n.firstChild)}if(e.length)l.textContent=e;else l.parentNode.removeChild(l);A.addSubCommand(new Ma(l,{"#text":C}));wa(A)};this.getEditorNS=function(e){e&&n.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,k){var l=zb(),C=l.w;l=l.h;var A;if(e=="fit"){var G=
getStrokedBBox();if(G){A=new Da("Fit Canvas to Content");var D=pb();qb(D);var z=[],F=[];$.each(D,function(){z.push(G.x*-1);F.push(G.y*-1)});D=c.moveSelectedElements(z,F,true);A.addSubCommand(D);xa();e=Math.round(G.width);k=Math.round(G.height)}else return false}if(e!=C||k!=l){D=d.suspendRedraw(1E3);A||(A=new Da("Change Image Dimensions"));e=Ba("width",e);k=Ba("height",k);n.setAttribute("width",e);n.setAttribute("height",k);this.contentW=e;this.contentH=k;A.addSubCommand(new Ma(n,{width:C,height:l}));
n.setAttribute("viewBox",[0,0,e/q,k/q].join(" "));A.addSubCommand(new Ma(n,{viewBox:["0 0",C,l].join(" ")}));wa(A);d.unsuspendRedraw(D);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",k+2)}M("changed",[n])}return[e,k]};this.getOffset=function(){return $(n).attr(["x","y"])};this.setBBoxZoom=function(e,k,l){var C=0.85,A=function(G){if(!G)return false;var D=
Math.min(Math.round(k/G.width*100*C)/100,Math.round(l/G.height*100*C)/100);c.setZoom(D);return{zoom:D,bbox:G}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:q*e.factor);return{zoom:q,bbox:e}}return A(e)}switch(e){case "selection":if(!I[0])return;e=$.map(I,function(G){if(G)return G});e=getStrokedBBox(e);break;case "canvas":e=zb();C=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(pb(B().getCurrentLayer()));
break;default:return}return A(e)};this.setZoom=function(e){var k=zb();n.setAttribute("viewBox","0 0 "+k.w/e+" "+k.h/e);q=e;$.each(I,function(l,C){C&&ra.requestSelector(C).resize()});La.zoomChange();ib("zoomChanged",e)};this.getMode=function(){return Ha};this.setMode=function(e){La.clear();bb.clear();$("#workarea").attr("class",e);Xa=I[0]&&I[0].nodeName=="text"?Ua:K;Ha=e};this.getColor=function(e){return Xa[e]};this.setColor=function(e,k,l){K[e]=k;Xa[e+"_paint"]={type:"solidColor"};for(var C=[],A=
I.length;A--;){var G=I[A];if(G)if(G.tagName=="g")svgedit.utilities.walkTree(G,function(D){D.nodeName!="g"&&C.push(D)});else if(e=="fill")G.tagName!="polyline"&&G.tagName!="line"&&C.push(G);else C.push(G)}if(C.length>0)if(l)Ab(e,k,C);else{Ya(e,k,C);M("changed",C)}};var gb=function(){var e=n.getElementsByTagNameNS(b,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(b,"defs");n.firstChild?n.insertBefore(e,n.firstChild.nextSibling):n.appendChild(e)}return e},Nb=this.setGradient=function(e){if(!(!Xa[e+
"_paint"]||Xa[e+"_paint"].type=="solidColor")){var k=c[e+"Grad"],l=Mb(k),C=gb();if(l)k=l;else{k=C.appendChild(f.importNode(k,true));k.id=ka()}c.setColor(e,"url(#"+k.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+k.id+")")}},Mb=function(e){var k=gb();k=$(k).find("linearGradient, radialGradient");for(var l=k.length,C=["r","cx","cy","fx","fy"];l--;){var A=k[l];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=A.getAttribute("x1")||e.getAttribute("y1")!=
@ -394,7 +394,7 @@ a(o).children().clone();if(o.length){o[0].removeAttribute("style");m.append(o)}}
event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});b.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};d=navigator.platform.indexOf("Mac")>=0;var n=navigator.userAgent.indexOf("AppleWebKit")>=0,v=d?"meta+":"ctrl+",B=g.pathActions,q=g.undoMgr,L=svgedit.utilities,Q=curConfig.imgPath+"placeholder.svg",K=a("#workarea"),I=a("#cmenu_canvas"),S=null,R=1,N="toolbars",
ga="";d||a(".shortcut").each(function(){var h=a(this).text();a(this).text(h.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var h=a("#dialog_box"),m=a("#dialog_buttons"),o=function(u,E,H,J){a("#dialog_content").html("<p>"+E.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",u=="prompt");m.empty();var O=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(m);u!="alert"&&a('<input type="button" value="'+
uiStrings.common.cancel+'">').appendTo(m).on("click touchstart",function(){h.hide();H(false)});if(u=="prompt"){var X=a('<input type="text">').prependTo(m);X.val(J||"");X.bind("keydown","return",function(){O.trigger("click touchstart")})}u=="process"&&O.hide();h.show();O.on("click touchstart",function(){h.hide();var ba=u=="prompt"?X.val():true;H&&H(ba)}).focus();u=="prompt"&&X.focus()};a.alert=function(u,E){o("alert",u,E)};a.confirm=function(u,E){o("confirm",u,E)};a.process_cancel=function(u,E){o("process",
u,E)};a.prompt=function(u,E,H){o("prompt",u,H,E)}})();var oa=function(){var h=a(".tool_button_current");if(h.length&&h[0].id!=="tool_select"){h.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},Y=null,V=false,ea=false,Ba="",ja=function(h,m){var o=g.getResolution(),u=K;a("#svgcanvas").position();if(u=g.setBBoxZoom(m,u.width()-15,u.height()-15)){var E=u.zoom;u=u.bbox;if(E<0.0010)wa({value:0.1});
u,E)};a.prompt=function(u,E,H){o("prompt",u,H,E)}})();var oa=function(){var h=a(".tool_button_current");if(h.length&&h[0].id!=="tool_select"){h.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},Y=null,V=false,ea=false,Ba="",ja=function(h,m){var o=g.getResolution(),u=K;a("#svgcanvas").position();if(u=g.setBBoxZoom(m,u.width()-15,u.height()-15)){var E=u.zoom;u=u.bbox;if(E<0.001)wa({value:0.1});
else{typeof animatedZoom!="undefined"&&h.cancelAnimationFrame(animatedZoom);var H=Date.now(),J=E-o.zoom;a("#zoom");var O=o.zoom,X=function(){var ba=(Date.now()-H)/500;ba=Math.pow(ba-1,3)+1;g.setZoom(O+J*ba);G();if(ba<1&&ba>-0.9)h.animatedZoom=requestAnimationFrame(X);else{a("#zoom").val(parseInt(E*100));a("option","#zoom_select").removeAttr("selected");a("option[value="+parseInt(E*100)+"]","#zoom_select").attr("selected","selected")}};X();g.getMode()=="zoom"&&u.width&&oa();xb()}}};a("#cur_context_panel").delegate("a",
"click",function(){var h=a(this);h.attr("data-root")?g.leaveContext():g.setContext(h.text());g.clearSelection();return false});var ca=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},U={},Z=function(h){a.each(h,function(m,o){var u=a(m).children(),E=m+"_show",H=a(E),J=false;u.addClass("tool_button").unbind("click mousedown mouseup").each(function(ba){var T=o[ba];U[T.sel]=T.fn;if(T.isDefault)J=ba;ba=function(fa){var ha=T;if(fa.type==="keydown"){var W=a(ha.parent+"_show").hasClass("tool_button_current"),
qa=a(ha.parent+"_show").attr("data-curopt");a.each(h[T.parent],function(Aa,Ca){if(Ca.sel==qa)ha=!fa.shiftKey||!W?Ca:h[T.parent][Aa+1]||h[T.parent][0]})}if(a(this).hasClass("disabled"))return false;ra(E)&&ha.fn();var ua=ha.icon?a.getSvgIcon(ha.icon,true):a(ha.sel).children().eq(0).clone();ua[0].setAttribute("width",H.width());ua[0].setAttribute("height",H.height());H.children(":not(.flyout_arrow_horiz)").remove();H.append(ua).attr("data-curopt",ha.sel)};a(this).mouseup(ba);T.key&&a(document).bind("keydown",
@ -429,7 +429,7 @@ icon:W.id,key:W.key,isDefault:W.includeWith?W.includeWith.isDefault:0},ub];Na="p
else Qa.bind(Cb,Jb)});Z(fa)});a.each(O,function(){vb(this.elem,this.list,this.callback,{seticon:true})});if(T)H=false;a.svgIcons(T,{w:27,h:27,id_match:false,no_img:!n,fallback:X,placement:ba,callback:function(){w.iconsize&&w.iconsize!="m"&&o();H=true;J()}})}J()});g.textActions.setInputElem(a("#text")[0]);var Ma='<div class="palette_item transparent" data-rgb="none"></div>\t\t\t\t\t\t\t\t<div class="palette_item black" data-rgb="#000000"></div>\t\t\t\t\t\t\t\t<div class="palette_item white" data-rgb="#ffffff"></div>';
["#444444","#482816","#422C10","#3B2F0E","#32320F","#293414","#1F361B","#153723","#0C372C","#083734","#0E353B","#1A333F","#273141","#332D40","#3E2A3C","#462735","#4B252D","#4D2425","#4C261D","#666666","#845335","#7B572D","#6F5C2A","#62612C","#546433","#46673D","#396849","#306856","#2D6862","#33666C","#426373","#535F75","#645A73","#74556D","#805064","#884D58","#8B4D4B","#894F3F","#999999","#C48157","#B8874D","#A98E49","#97944B","#849854","#729C62","#619E73","#559E84","#529D94","#5B9BA2","#6D97AB",
"#8391AE","#9A8AAB","#AF84A3","#BF7E96","#C97A86","#CE7975","#CC7C65","#BBBBBB","#FFB27C","#FABA6F","#E6C36A","#CFCA6D","#B8D078","#A0D58A","#8CD79F","#7DD8B5","#7AD6CA","#84D3DB","#9ACEE6","#B6C7EA","#D3BEE7","#EDB6DC","#FFAFCC","#FFAAB8","#FFA9A2","#FFAC8D","#DDDDDD","#FFE7A2","#FFF093","#FFFA8D","#FFFF91","#EEFF9F","#D1FFB4","#B9FFCE","#A8FFE9","#A4FFFF","#B1FFFF","#CBFFFF","#EDFFFF","#FFF5FF","#FFEBFF","#FFE2FF","#FFDCEC","#FFDBD2","#FFDFB8"].forEach(function(h){Ma+='<div class="palette_item" style="background-color: '+
h+';" data-rgb="'+h+'"></div>'});a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(h){h="rotate("+h+"deg)";Da.css({"-webkit-transform":h,"-moz-transform":h,"-o-transform":h,"-ms-transform":h,transform:h})};var wa=function(h){var m=h.value/100;if(m<0.0010)h.value=0.1;else{h=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/h,y:(o[0].scrollTop+o.height()/2)/h,zoom:m},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",
h+';" data-rgb="'+h+'"></div>'});a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(h){h="rotate("+h+"deg)";Da.css({"-webkit-transform":h,"-moz-transform":h,"-o-transform":h,"-ms-transform":h,transform:h})};var wa=function(h){var m=h.value/100;if(m<0.001)h.value=0.1;else{h=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/h,y:(o[0].scrollTop+o.height()/2)/h,zoom:m},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",
a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);window.opera&&a("<p/>").hide().appendTo("body").remove()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(h){var m=h.getAttribute("data-attr"),
o=h.getAttribute("data-multiplier")||1;o=parseFloat(o);o=h.value*o;if(!svgedit.units.isValidUnit(m,o,Y)){a.alert(uiStrings.notification.invalidAttrValGiven);h.value=Y.getAttribute(m);return false}g.changeSelectedAttributeNoUndo(m,o)};picking=false;a(document).on("mouseup",function(){picking=false});a("#palette").on("mousemove mousedown touchstart touchmove",".palette_item",function(h){h.preventDefault();if(h.type=="mousedown")picking=true;if(picking){var m=a("#tool_stroke").hasClass("active"),o=m?
"stroke":"fill",u=a(this).attr("data-rgb"),E=null,H=true;if(h.type=="mousedown")H=false;if(u==="transparent"||u==="initial"||u==="#none"){u="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:u.substr(1)});b.paintBox[o].setPaint(E);if(m){g.setColor("stroke",u,H);u!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",u,H);u!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}}).bind("contextmenu",function(h){h.preventDefault()});
@ -437,9 +437,9 @@ a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","tab
return true};(function(){var h=null,m=null,o=K[0],u=false,E=false;a("#svgcanvas").on("mousemove mouseup touchend",function(H){if(u!==false){o.scrollLeft-=H.clientX-h;o.scrollTop-=H.clientY-m;h=H.clientX;m=H.clientY;if(H.type==="mouseup"||H.type==="touchend")u=false;return false}}).on("mousedown touchmove",function(H){if(H.button===1||E===true||H.originalEvent.touches&&H.originalEvent.touches.length>=2){u=true;h=H.clientX;m=H.clientY;return false}});a(window).mouseup(function(){u=false});a(document).bind("keydown",
"space",function(H){H.preventDefault();g.spaceKey=E=true}).bind("keyup","space",function(H){H.preventDefault();g.spaceKey=E=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&K.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&K.removeClass("out")})})();var va=a(".menu"),kb=function(h){h.target.style.background="#fff";setTimeout(function(){h.target.style.background="#ddd"},50);setTimeout(function(){h.target.style.background="#fff"},150);setTimeout(function(){h.target.style.background=
"#ddd"},200);setTimeout(function(){h.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(h){kb(h)});a("svg, body").on("mousedown touchstart",function(h){if(!(h.target.nodeName&&h.target.nodeName.toLowerCase()==="input"))if(!a(h.target).hasClass("menu_title")&&!a(h.target).parent().hasClass("menu_title"))!a(h.target).hasClass("disabled")&&a(h.target).hasClass("menu_item")?kb(h):a("#menu_bar").removeClass("active")});
a("#workarea").on("mousewheel",function(h,m,o,u){if(h.altKey){h.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+u*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(h,m,o){if(a(h).length!=0){var u=a(h).find("button"),E=a(h).find("ul").attr("id",
a(h)[0].id+"-list");o||a("#option_lists").append(E);var H=false;o&&a(h).addClass("dropup");E.find("li").bind("mouseup",m);a(window).mouseup(function(){if(!H){u.removeClass("down");E.hide()}H=false});u.bind("mousedown",function(){if(u.hasClass("down")){u.removeClass("down");E.hide()}else{u.addClass("down");if(!o){var J=a(h).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(h,m,o,u){var E=a(h);m=a(m);var H=false,
J=u.dropUp;J&&a(h).addClass("dropup");m.find("li").bind("mouseup",function(){if(u.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");m.hide();m.css({top:0,left:0})}H=false});m.height();a(h).bind("mousedown",function(){var O=a(h).offset();if(J){O.top-=m.height();O.left+=8}else O.top+=a(h).height();a(m).offset(O);if(E.hasClass("down")){E.removeClass("down");
a("#workarea").on("mousewheel",function(h,m,o,u){if(h.altKey||h.ctrlKey){h.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+u*(h.altKey?10:5))).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(h,m,o){if(a(h).length!=0){var u=a(h).find("button"),
E=a(h).find("ul").attr("id",a(h)[0].id+"-list");o||a("#option_lists").append(E);var H=false;o&&a(h).addClass("dropup");E.find("li").bind("mouseup",m);a(window).mouseup(function(){if(!H){u.removeClass("down");E.hide()}H=false});u.bind("mousedown",function(){if(u.hasClass("down")){u.removeClass("down");E.hide()}else{u.addClass("down");if(!o){var J=a(h).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(h,m,o,u){var E=
a(h);m=a(m);var H=false,J=u.dropUp;J&&a(h).addClass("dropup");m.find("li").bind("mouseup",function(){if(u.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");m.hide();m.css({top:0,left:0})}H=false});m.height();a(h).bind("mousedown",function(){var O=a(h).offset();if(J){O.top-=m.height();O.left+=8}else O.top+=a(h).height();a(m).offset(O);if(E.hasClass("down")){E.removeClass("down");
m.hide();m.css({top:0,left:0})}else{E.addClass("down");m.show();H=true;return false}}).hover(function(){H=true}).mouseout(function(){H=false});u.multiclick&&m.mousedown(function(){H=true})};a("#font_family_dropdown").change(function(){var h=this.options[this.selectedIndex].value,m=this.options[this.selectedIndex].text;a("#preview_font").html(m).css("font-family",h);a("#font_family").val(h).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var h=this.id.replace("tool_pos",
"").charAt(0);g.alignSelectedElements(h,"page")})});(function(){var h,m=function(){a(h).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){h=this;N="toolbars";K.mousedown(m)}).blur(function(){N="canvas";K.unbind("mousedown",m);g.getMode()=="textedit"&&a("#text").focus()})})();var cb=function(){ra("#tool_select")&&g.setMode("select")},Ta=function(){ra("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){ra("#tool_line")&&g.setMode("line")},Ga=function(){ra("#tool_rect")&&
g.setMode("rect")},ta=function(){ra("#tool_ellipse")&&g.setMode("ellipse")},$a=function(){ra("#tool_image")&&g.setMode("image")},Ka=function(){ra("#tool_zoom")&&g.setMode("zoom")},Sa=function(){if(ra("#tool_zoom")){yb();oa()}},Ha=function(){ra("#tool_text")&&g.setMode("text")},db=function(){ra("#tool_path")&&g.setMode("path")},lb=function(){if(Y!=null||V)g.deleteSelectedElements();B.getNodePoint()&&B.deletePathNode()},Ua=function(){if(Y!=null||V){xa(a("#edit_menu"));g.cutSelectedElements()}},Xa=function(){if(Y!=

View File

@ -16,8 +16,7 @@
// 2) browser.js
// 3) svgcanvas.js
(function() {
(function() {
document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true);
@ -1914,12 +1913,13 @@
var accumulatedDelta = 0
$('#workarea').on('mousewheel', function(e, delta, deltaX, deltaY){
if (e.altKey) {
if (e.altKey || e.ctrlKey) {
e.preventDefault();
zoom = parseInt($("#zoom").val())
$("#zoom").val(parseInt(zoom + deltaY*10)).change()
$("#zoom").val(parseInt(zoom + deltaY*(e.altKey ? 10 : 5))).change()
}
})
});
$('.menu_title')
.on('mousedown', function() {
$("#tools_shapelib").hide()

View File

@ -2193,7 +2193,7 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
}
#workarea.fhpath {
cursor: url(../images/pencil_cursor.png) 0 20, crosshair;
cursor: url(../images/pencil_cursor.png) 0 16, crosshair;
}
#workarea.rotate * {

View File

@ -341,7 +341,7 @@ button.cancel,input.Cancel,input.cancel,input.jGraduate_Cancel,button.cancel{-we
#workarea.rect,#workarea.line,#workarea.ellipse,#workarea.path,#workarea.shapelib{cursor:crosshair}
#workarea.text{cursor:text}
#workarea.eyedropper{cursor:url(../images/eyedropper.png) 0 16,crosshair}
#workarea.fhpath{cursor:url(../images/pencil_cursor.png) 0 20,crosshair}
#workarea.fhpath{cursor:url(../images/pencil_cursor.png) 0 16,crosshair}
#workarea.rotate *{cursor:url(../images/rotate.png) 12 12,auto}
#workarea.select text,#workarea.multiselect text{cursor:default}
#workarea.n-resize *{cursor:n-resize!important}

View File

@ -1611,7 +1611,7 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
}
#workarea.fhpath {
cursor: url(../images/pencil_cursor.png) 0 20, crosshair;
cursor: url(../images/pencil_cursor.png) 0 16, crosshair;
}
#workarea.rotate * {

View File

@ -241,104 +241,104 @@ $(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":D.points=e.getAt
function(e){if(I[0]!=null)for(var k=I.length,l=0;l<k;++l){var C=I[l];if(C==null)break;ra.releaseSelector(C);I[l]=null}e||M("selected",I)},qb=this.addToSelection=function(e,k){if(e.length!=0){for(var l=0;l<I.length;){if(I[l]==null)break;++l}for(var C=e.length;C--;){var A=e[C];if(A&&svgedit.utilities.getBBox(A)){if(A.tagName==="a"&&A.childNodes.length===1)A=A.firstChild;if(I.indexOf(A)==-1){I[l]=A;l++;A=ra.requestSelector(A);I.length>1&&A.showGrips(false)}}}M("selected",I);k||I.length==1?ra.requestSelector(I[0]).showGrips(true):
ra.requestSelector(I[0]).showGrips(false);for(I.sort(function(G,D){if(G&&D&&G.compareDocumentPosition)return 3-(D.compareDocumentPosition(G)&6);else if(G==null)return 1});I[0]==null;)I.shift(0)}},rb=this.selectOnly=function(e,k){xa(true);qb(e,k)};this.removeFromSelection=function(e){if(I[0]!=null)if(e.length!=0){var k=Array(I.length);j=0;len=I.length;for(var l=0;l<len;++l){var C=I[l];if(C)if(e.indexOf(C)==-1){k[j]=C;j++}else ra.releaseSelector(C)}I=k}};this.selectAllInCurrentLayer=function(){var e=
B().getCurrentLayer();if(e){Ha="select";rb($(L||e).children())}};var Bb=this.getMouseTarget=function(e){if(e==null||e.target==null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var k=B().getCurrentLayer();if([d,a,n,k].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return ra.selectorParentGroup;
for(;e.parentNode&&e.parentNode!==(L||k);)e=e.parentNode;return e};(function(){var e=null,k=null,l=null,C=null,A=null,G={},D={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(z){if(!c.spaceKey){var F=z.button===2;mb=n.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var h=N(z.pageX,z.pageY,mb),m=h.x*(isBotchedZoom?1:q);h=h.y*(isBotchedZoom?1:q);z.preventDefault();if(F)Ha="select";m=m/q;h=h/q;var o=Bb(z);if(o.tagName==="a"&&o.childNodes.length===1)o=o.firstChild;var u=
C=k=m,E=A=l=h;if(p.gridSnapping){m=va(m);h=va(h);k=va(k);l=va(l)}if(o==ra.selectorParentGroup&&I[0]!=null){o=z.target;var H=cb(o,"type");if(H=="rotate"){Ha="rotate";current_rotate_mode=cb(o,"dir")}else if(H=="resize"){Ha="resize";db=cb(o,"dir")}o=I[0]}Sa=o.getAttribute("transform");H=R(o);switch(Ha){case "select":Ka=true;db="none";if(F)Ka=false;if(o!=d){if(I.indexOf(o)==-1){z.shiftKey||xa(true);qb([o]);wb=o;La.clear()}if(!F)for(F=0;F<I.length;++F)if(I[F]!=null){var J=R(I[F]);J.numberOfItems?J.insertItemBefore(d.createSVGTransform(),
0):J.appendItem(d.createSVGTransform())}}else if(!F){xa();Ha="multiselect";if(sa==null)sa=ra.getRubberBandBox();C*=q;A*=q;ma(sa,{x:C,y:A,width:0,height:0,display:"inline"},100)}break;case "zoom":Ka=true;if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:u*q,y:u*q,width:0,height:0,display:"inline"},100);break;case "resize":Ka=true;k=m;l=h;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var O={};$.each(G,function(X,ba){O[X]=ba/q});G=O;F=na(o)?1:0;if(oa(H)){H.insertItemBefore(d.createSVGTransform(),F);
H.insertItemBefore(d.createSVGTransform(),F);H.insertItemBefore(d.createSVGTransform(),F)}else{H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(m=svgedit.browser.isWebkit())J=function(X){var ba=X.getAttributeNS(null,"stroke");X.removeAttributeNS(null,"stroke");setTimeout(function(){X.setAttributeNS(null,"stroke",ba)},0)};o.style.vectorEffect="non-scaling-stroke";m&&J(o);h=o.getElementsByTagName("*");
u=h.length;for(F=0;F<u;F++){h[F].style.vectorEffect="non-scaling-stroke";m&&J(h[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ka=true;e=u+","+E+" ";J=K.stroke_width==0?1:K.stroke_width;S({element:"polyline",curStyles:true,attr:{points:e,id:ka(),fill:"none",opacity:K.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});D.minx=u;D.maxx=u;D.miny=E;D.maxy=E;break;case "image":Ka=true;J=S({element:"image",attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2,style:"pointer-events:inherit"}});
U(J,Ga);Fb(J);break;case "square":case "rect":Ka=true;k=m;l=h;S({element:"rect",curStyles:true,attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2}});break;case "line":Ka=true;J=K.stroke_width==0?1:K.stroke_width;S({element:"line",curStyles:true,attr:{x1:m,y1:h,x2:m,y2:h,id:ka(),stroke:K.stroke,"stroke-width":J,"stroke-dasharray":K.stroke_dasharray,"stroke-linejoin":K.stroke_linejoin,"stroke-linecap":K.stroke_linecap,"stroke-opacity":K.stroke_opacity,fill:"none",opacity:K.opacity/2,style:"pointer-events:none"}});
break;case "circle":Ka=true;S({element:"circle",curStyles:true,attr:{cx:m,cy:h,r:0,id:ka(),opacity:K.opacity/2}});break;case "ellipse":Ka=true;S({element:"ellipse",curStyles:true,attr:{cx:m,cy:h,rx:0,ry:0,id:ka(),opacity:K.opacity/2}});break;case "text":Ka=true;S({element:"text",curStyles:true,attr:{x:m,y:h,id:ka(),fill:Ua.fill,"stroke-width":Ua.stroke_width,"font-size":Ua.font_size,"font-family":Ua.font_family,"text-anchor":"left","xml:space":"preserve",opacity:K.opacity}});break;case "path":case "pathedit":k*=
q;l*=q;La.mouseDown(z,o,k,l);Ka=true;break;case "textedit":k*=q;l*=q;bb.mouseDown(z,o,k,l);Ka=true;break;case "rotate":Ka=true;c.undoMgr.beginUndoableChange("transform",I);document.getElementById("workarea").className="rotate"}J=ib("mouseDown",{event:z,start_x:k,start_y:l,selectedElements:I},true);$.each(J,function(X,ba){if(ba&&ba.started)Ka=true});if(Ha)document.getElementById("workarea").className=Ha=="resize"?z.target.style.cursor:Ha}}).mousemove(function(z){if(!(z.originalEvent.touches&&z.originalEvent.touches.length>
1))if(Ka)if(!(z.button===1||c.spaceKey)){var F=I[0],h=N(z.pageX,z.pageY,mb),m=h.x*(isBotchedZoom?1:q);h=h.y*(isBotchedZoom?1:q);var o=pa(aa()),u=x=m/q,E=y=h/q;if(p.gridSnapping){x=va(x);y=va(y)}z.preventDefault();switch(Ha){case "select":if(I[0]!==null){u=x-k;var H=y-l;if(p.gridSnapping){u=va(u);H=va(H)}if(z.shiftKey){var J=V(k,l,x,y);x=J.x;y=J.y}if(u!=0||H!=0){E=I.length;for(var O=0;O<E;++O){F=I[O];if(F==null)break;var X=d.createSVGTransform();o=R(F);if(J){u=J.x-k;H=J.y-l}X.setTranslate(u,H);o.numberOfItems?
o.replaceItem(X,0):o.appendItem(X);ra.requestSelector(F).resize()}if(z.altKey)if(!c.addClones){c.addClones=c.cloneSelectedElements(0,0,X);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(ua){ua.parentNode&&ua.parentNode.removeChild(ua);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",I)}}break;case "multiselect":u*=q;E*=q;ma(sa,{x:Math.min(C,u),y:Math.min(A,E),width:Math.abs(u-C),height:Math.abs(E-A)},100);o=[];u=[];J=ob();E=I.length;for(O=0;O<
E;++O){H=J.indexOf(I[O]);if(H==-1)o.push(I[O]);else J[H]=null}E=J.length;for(O=0;O<E;++O)J[O]&&u.push(J[O]);o.length>0&&c.removeFromSelection(o);u.length>0&&qb(u);break;case "resize":o=R(F);u=(J=oa(o))?G:svgedit.utilities.getBBox(F);E=u.x;O=u.y;var ba=u.width,T=u.height;u=x-k;H=y-l;if(p.gridSnapping){u=va(u);H=va(H);T=va(T);ba=va(ba)}if(X=na(F)){var fa=Math.sqrt(u*u+H*H);H=Math.atan2(H,u)-X*Math.PI/180;u=fa*Math.cos(H);H=fa*Math.sin(H)}if(db.indexOf("n")==-1&&db.indexOf("s")==-1)H=0;if(db.indexOf("e")==
-1&&db.indexOf("w")==-1)u=0;var ha=fa=0,W=T?(T+H)/T:1,qa=ba?(ba+u)/ba:1;if(db.indexOf("n")>=0){W=T?(T-H)/T:1;ha=T}if(db.indexOf("w")>=0){qa=ba?(ba-u)/ba:1;fa=ba}u=d.createSVGTransform();H=d.createSVGTransform();ba=d.createSVGTransform();if(p.gridSnapping){E=va(E);fa=va(fa);O=va(O);ha=va(ha)}u.setTranslate(-(E+fa),-(O+ha));if(z.shiftKey)if(qa==1)qa=W;else W=qa;H.setScale(qa,W);ba.setTranslate(E+fa,O+ha);if(J){J=X?1:0;o.replaceItem(u,2+J);o.replaceItem(H,1+J);o.replaceItem(ba,0+J)}else{J=o.numberOfItems;
o.replaceItem(ba,J-3);o.replaceItem(H,J-2);o.replaceItem(u,J-1)}ra.requestSelector(F).resize();M("transition",I);break;case "zoom":u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-A*q)},100);break;case "text":ma(o,{x:x,y:y},1E3);break;case "line":u=null;window.opera||d.suspendRedraw(1E3);if(p.gridSnapping){x=va(x);y=va(y)}E=x;J=y;if(z.shiftKey){J=V(k,l,E,J);E=J.x;J=J.y}o.setAttributeNS(null,"x2",E);o.setAttributeNS(null,"y2",J);window.opera||d.unsuspendRedraw(u);
break;case "foreignObject":case "square":case "rect":case "image":u=Math.abs(x-k);J=Math.abs(y-l);if(Ha=="square"||z.shiftKey){u=J=Math.max(u,J);E=k<x?k:k-u;O=l<y?l:l-J}else{E=Math.min(k,x);O=Math.min(l,y)}if(z.altKey){u*=2;J*=2;E=k-u/2;O=l-J/2}if(p.gridSnapping){u=va(u);J=va(J);E=va(E);O=va(O)}ma(o,{width:u,height:J,x:E,y:O},1E3);break;case "circle":u=$(o).attr(["cx","cy"]);J=u.cx;E=u.cy;u=Math.sqrt((x-J)*(x-J)+(y-E)*(y-E));if(p.gridSnapping)u=va(u);o.setAttributeNS(null,"r",u);break;case "ellipse":u=
$(o).attr(["cx","cy"]);J=Math.abs(k+(x-k)/2);E=Math.abs(l+(y-l)/2);u=null;window.opera||d.suspendRedraw(1E3);if(p.gridSnapping){x=va(x);J=va(J);y=va(y);E=va(E)}O=Math.abs(k-J);H=Math.abs(l-E);if(z.shiftKey){H=O;E=y>l?l+O:l-O}if(z.altKey){J=k;E=l;O=Math.abs(x-J);H=z.shiftKey?O:Math.abs(y-E)}o.setAttributeNS(null,"rx",O);o.setAttributeNS(null,"ry",H);o.setAttributeNS(null,"cx",J);o.setAttributeNS(null,"cy",E);window.opera||d.unsuspendRedraw(u);break;case "fhellipse":case "fhrect":D.minx=Math.min(u,
D.minx);D.maxx=Math.max(u,D.maxx);D.miny=Math.min(E,D.miny);D.maxy=Math.max(E,D.maxy);case "fhpath":e+=+u+","+E+" ";o.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=q;y*=q;if(p.gridSnapping){x=va(x);y=va(y);k=va(k);l=va(l)}if(z.shiftKey){if(J=svgedit.path.path){o=J.dragging?J.dragging[0]:k;J=J.dragging?J.dragging[1]:l}else{o=k;J=l}J=V(o,J,x,y);x=J.x;y=J.y}if(sa&&sa.getAttribute("display")!=="none"){u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-
A*q)},100)}La.mouseMove(z,x,y);break;case "textedit":x*=q;y*=q;bb.mouseMove(m,h);break;case "rotate":u=svgedit.utilities.getBBox(F);J=u.x+u.width/2;E=u.y+u.height/2;o=ea(F);o=N(J,E,o);J=o.x;E=o.y;o=u.x;O=u.y;if(current_rotate_mode=="nw")o=u.x+u.width;if(current_rotate_mode=="se")O=u.y+u.height;if(current_rotate_mode=="sw"){o=u.x+u.width;O=u.y+u.height}compensation_angle=(Math.atan2(E-O,J-o)*(180/Math.PI)-90)%360;X=(Math.atan2(E-y,J-x)*(180/Math.PI)-90)%360;X+=compensation_angle;if(p.gridSnapping)X=
va(X);if(z.shiftKey)X=Math.round(X/45)*45;c.setRotationAngle(X<-180?360+X:X,true);M("transition",I)}ib("mouseMove",{event:z,mouse_x:m,mouse_y:h,selected:F})}}).click(function(z){z.preventDefault();return false}).dblclick(function(z){var F=z.target.parentNode,h=Bb(z),m=h.tagName;if(F!==L){if(m==="text"&&Ha!=="textedit"){z=N(z.pageX,z.pageY,mb);bb.select(h,z.x,z.y)}if((m==="g"||m==="a")&&na(h)){Db(h);h=I[0];xa(true)}L&&Eb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||h===ra.selectorParentGroup||
Kb(h)}}).mouseup(function(z){c.addClones=false;window.removeEventListener("keyup",c.removeClones);I=I.filter(Boolean);if(z.button!==2){var F=wb;wb=null;if(Ka){var h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;var o=m/q,u=h/q,E=pa(aa()),H=false;Ka=false;switch(Ha){case "resize":case "multiselect":if(sa!=null){sa.setAttribute("display","none");hb=[]}Ha="select";case "select":if(I[0]!=null){if(I.length==1){m=I[0];switch(m.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Xa.fill=
m.getAttribute("fill");Xa.fill_opacity=m.getAttribute("fill-opacity");Xa.stroke=m.getAttribute("stroke");Xa.stroke_opacity=m.getAttribute("stroke-opacity");Xa.stroke_width=m.getAttribute("stroke-width");Xa.stroke_dasharray=m.getAttribute("stroke-dasharray");Xa.stroke_linejoin=m.getAttribute("stroke-linejoin");Xa.stroke_linecap=m.getAttribute("stroke-linecap")}if(m.tagName=="text"){Ua.font_size=m.getAttribute("font-size");Ua.font_family=m.getAttribute("font-family")}ra.requestSelector(m).showGrips(true)}Ea();
C=(m=svgedit.browser.isGecko())?C*q:C;A=m?A*q:A;m=Math.abs(u-A);if(m>1||m>1){z=I.length;for(m=0;m<z;++m){if(I[m]==null)break;I[m].firstChild||ra.requestSelector(I[m]).resize()}}else{m=z.target;if(I[0].nodeName==="path"&&I[1]==null)La.select(I[0]);else z.shiftKey&&F!=m&&c.removeFromSelection([m])}if(svgedit.browser.supportsNonScalingStroke())if(z=I[0]){z.removeAttribute("style");svgedit.utilities.walkTree(z,function(X){X.removeAttribute("style")})}}return;case "zoom":sa!=null&&sa.setAttribute("display",
"none");M("zoomed",{x:Math.min(C,o),y:Math.min(A,u),width:Math.abs(o-C),height:Math.abs(u-A),factor:z.altKey?0.5:2});return;case "fhpath":F=E.getAttribute("points");u=F.indexOf(",");if(H=u>=0?F.indexOf(",",u+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)E=La.smoothPolylineIntoPath(E);break;case "line":F=$(E).attr(["x1","x2","y1","y2"]);H=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(E).attr(["width","height"]);H=F.width!=0||F.height!=0||Ha==="image";break;
case "circle":H=E.getAttribute("r")!=0;break;case "ellipse":F=$(E).attr(["rx","ry"]);H=F.rx!=null||F.ry!=null;break;case "fhellipse":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"ellipse",curStyles:true,attr:{cx:(D.minx+D.maxx)/2,cy:(D.miny+D.maxy)/2,rx:(D.maxx-D.minx)/2,ry:(D.maxy-D.miny)/2,id:aa()}});M("changed",[E]);H=true}break;case "fhrect":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"rect",curStyles:true,attr:{x:D.minx,y:D.miny,width:D.maxx-D.minx,height:D.maxy-D.miny,id:aa()}});
M("changed",[E]);H=true}break;case "text":H=true;rb([E]);bb.start(E);break;case "path":E=null;Ka=true;F=La.mouseUp(z,E,m,h);E=F.element;H=F.keep;break;case "pathedit":H=true;E=null;La.mouseUp(z);break;case "textedit":H=false;E=null;bb.mouseUp(z,m,h);break;case "rotate":H=true;E=null;Ha="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||wa(F);Ea();M("changed",I)}m=ib("mouseUp",{event:z,mouse_x:m,mouse_y:h},true);$.each(m,function(X,ba){if(ba){H=ba.keep||H;E=ba.element;Ka=ba.started||Ka}});if(!H&&
E!=null){B().releaseId(aa());E.parentNode.removeChild(E);E=null;for(m=z.target;m.parentNode.parentNode.tagName=="g";)m=m.parentNode;if((Ha!="path"||!drawn_path)&&m.parentNode.id!="selectorParentGroup"&&m.id!="svgcanvas"&&m.id!="svgroot"){c.setMode("select");rb([m],true)}}else if(E!=null){c.addedNew=true;z=0.2;var J;if(false.beginElement&&E.getAttribute("opacity")!=K.opacity){J=$(false).clone().attr({to:K.opacity,dur:z}).appendTo(E);try{J[0].beginElement()}catch(O){}}else z=0;setTimeout(function(){J&&
J.remove();E.setAttribute("opacity",K.opacity);E.setAttribute("style","pointer-events:inherit");la(E);if(Ha==="path")La.toEditMode(E);else p.selectNew&&rb([E],true);wa(new Ia(E));M("changed",[E])},z*1E3)}Sa=null}}});$(a).bind("mousewheel DOMMouseScroll",function(z){if(z.shiftKey){z.preventDefault();mb=n.getScreenCTM().inverse();var F=N(z.pageX,z.pageY,mb);F={x:F.x,y:F.y,width:0,height:0};if(z.wheelDelta)if(z.wheelDelta>=120)F.factor=2;else{if(z.wheelDelta<=-120)F.factor=0.5}else if(z.detail)if(z.detail>
0)F.factor=0.5;else if(z.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var Fb=function(e){$(e).click(function(k){k.preventDefault()})},bb=c.textActions=function(){function e(T){var fa=h.value==="";$(h).focus();if(!arguments.length)if(fa)T=0;else{if(h.selectionEnd!==h.selectionStart)return;T=h.selectionEnd}var ha;ha=E[T];fa||h.setSelectionRange(T,T);m=pa("text_cursor");if(!m){m=document.createElementNS(b,"line");ma(m,{id:"text_cursor",stroke:"#333","stroke-width":1});m=pa("selectorParentGroup").appendChild(m)}u||
(u=setInterval(function(){var W=m.getAttribute("display")==="none";m.setAttribute("display",W?"inline":"none")},600));fa=G(ha.x,H.y);ha=G(ha.x,H.y+H.height);ma(m,{x1:fa.x,y1:fa.y,x2:ha.x,y2:ha.y,visibility:"visible",display:"inline"});o&&o.setAttribute("d","M 0 0")}function k(T,fa,ha){if(T===fa)e(fa);else{ha||h.setSelectionRange(T,fa);o=pa("text_selectblock");if(!o){o=document.createElementNS(b,"path");ma(o,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});pa("selectorParentGroup").appendChild(o)}T=
E[T];var W=E[fa];m.setAttribute("visibility","hidden");fa=G(T.x,H.y);ha=G(T.x+(W.x-T.x),H.y);var qa=G(T.x,H.y+H.height);T=G(T.x+(W.x-T.x),H.y+H.height);ma(o,{d:"M"+fa.x+","+fa.y+" L"+ha.x+","+ha.y+" "+T.x+","+T.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function l(T,fa){var ha=d.createSVGPoint();ha.x=T;ha.y=fa;if(E.length==1)return 0;ha=F.getCharNumAtPosition(ha);if(ha<0){ha=E.length-2;if(T<=E[0].x)ha=0}else if(ha>=E.length-2)ha=E.length-2;var W=E[ha];T>W.x+W.width/2&&ha++;return ha}function C(T,
fa,ha){var W=h.selectionStart;T=l(T,fa);k(Math.min(W,T),Math.max(W,T),!ha)}function A(T,fa){var ha={x:T,y:fa};ha.x/=q;ha.y/=q;if(J){var W=N(ha.x,ha.y,J.inverse());ha.x=W.x;ha.y=W.y}return ha}function G(T,fa){var ha={x:T,y:fa};if(J){var W=N(ha.x,ha.y,J);ha.x=W.x;ha.y=W.y}ha.x*=q;ha.y*=q;return ha}function D(T){k(0,F.textContent.length);$(this).unbind(T)}function z(T){if(ba&&F){var fa=N(T.pageX,T.pageY,mb);fa=A(fa.x*q,fa.y*q);fa=l(fa.x,fa.y);var ha=F.textContent,W=ha.substr(0,fa).replace(/[a-z0-9]+$/i,
"").length;ha=ha.substr(fa).match(/^[a-z0-9]+/i);k(W,(ha?ha[0].length:0)+fa);$(T.target).click(D);setTimeout(function(){$(T.target).unbind("click",D)},300)}}var F,h,m,o,u,E=[],H,J,O,X,ba;return{select:function(T,fa,ha){F=T;bb.toEditMode(fa,ha)},start:function(T){F=T;bb.toEditMode()},mouseDown:function(T,fa,ha,W){T=A(ha,W);h.focus();e(l(T.x,T.y));O=ha;X=W},mouseMove:function(T,fa){var ha=A(T,fa);C(ha.x,ha.y)},mouseUp:function(T,fa,ha){var W=A(fa,ha);C(W.x,W.y,true);T.target!==F&&fa<O+2&&fa>O-2&&ha<
X+2&&ha>X-2&&bb.toSelectMode(true)},setCursor:e,toEditMode:function(T,fa){rb([F],false);ba=false;Ha="textedit";ra.requestSelector(F).showGrips(false);ra.requestSelector(F);bb.init();$(F).css("cursor","text");if(arguments.length){var ha=A(T,fa);e(l(ha.x,ha.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(T){Ha="select";clearInterval(u);u=null;o&&$(o).attr("display","none");m&&$(m).attr("visibility","hidden");$(F).css("cursor","move");if(T){xa();$(F).css("cursor","move");M("selected",
[F]);qb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(h).blur();F=false},setInputElem:function(T){h=T},clear:function(){Ha=="textedit"&&bb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=I[0];ra.requestSelector(F).showGrips(false)}var T=F.textContent.length,fa=F.getAttribute("transform");H=svgedit.utilities.getBBox(F);J=fa?ea(F):null;E=Array(T);h.focus();$(F).unbind("dblclick",z).dblclick(z);if(!T)var ha={x:H.x+H.width/2,width:0};for(fa=0;fa<T;fa++){var W=F.getStartPositionOfChar(fa);
ha=F.getEndPositionOfChar(fa);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*q;W.x-=qa;ha.x-=qa;W.x/=q;ha.x/=q}E[fa]={x:W.x,y:H.y,width:ha.x-W.x,height:H.height}}E.push({x:ha.x,width:0});k(h.selectionStart,h.selectionEnd,true)}}}}(),La=c.pathActions=function(){var e=false,k,l,C;svgedit.path.Path.prototype.endChanges=function(D){if(svgedit.browser.isWebkit()){var z=this.elem;z.setAttribute("d",La.convertPath(z))}D=new Ma(this.elem,{d:this.last_d},D);wa(D);M("changed",[this.elem])};
svgedit.path.Path.prototype.addPtsToSelection=function(D){$.isArray(D)||(D=[D]);for(var z=0;z<D.length;z++){var F=D[z],h=this.segs[F];h.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();z=this.selected_pts.length;for(D=Array(z);z--;){h=this.segs[this.selected_pts[z]];h.select(true);D[z]=h.ptgrip}La.canDeleteNodes=true;La.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",D)};var A=k=null,G=false;this.lastCtrlPoint=[0,0];return{mouseDown:function(D,
z,F,h){if(Ha==="path"){mouse_x=F;mouse_y=h;F=mouse_x/q;z=mouse_y/q;h=pa("path_stretch_line");l=[F,z];if(p.gridSnapping){F=va(F);z=va(z);mouse_x=va(mouse_x);mouse_y=va(mouse_y)}if(!h){h=document.createElementNS(b,"path");ma(h,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});h=pa("selectorParentGroup").appendChild(h)}h.setAttribute("display","inline");this.stretchy=h;var m=null;if(A){m=A.pathSegList;for(var o=m.numberOfItems,u=6/q,E=false;o;){o--;var H=m.getItem(o),J=H.x;H=H.y;
if(F>=J-u&&F<=J+u&&z>=H-u&&z<=H+u){E=true;break}}u=aa();svgedit.path.removePath_(u);u=pa(u);J=m.numberOfItems;if(E){if(o<=1&&J>=2){F=m.getItem(0).x;z=m.getItem(0).y;o=svgedit.path.first_grip?svgedit.path.first_grip[0]/q:m.getItem(0).x;E=svgedit.path.first_grip?svgedit.path.first_grip[1]/q:m.getItem(0).y;D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(F,z):A.createSVGPathSegCurvetoCubicAbs(F,z,D.x1/q,D.y1/q,o,E);F=A.createSVGPathSegClosePath();m.appendItem(D);m.appendItem(F)}else if(J<
3)return m=false;$(h).remove();element=u;A=null;Ka=false;if(e){svgedit.path.path.matrix&&Za(u,{},svgedit.path.path.matrix.inverse());F=u.getAttribute("d");h=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",h+F);$(u).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();La.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Bb(D))){console.log("Clicked outside canvas");return false}m=A.pathSegList.numberOfItems;
o=A.pathSegList.getItem(m-1);u=o.x;o=o.y;if(D.shiftKey){z=V(u,o,F,z);F=z.x;z=z.y}D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(ab(F),ab(z)):A.createSVGPathSegCurvetoCubicAbs(ab(F),ab(z),D.x1/q,D.y1/q,D.x2/q,D.y2/q);A.pathSegList.appendItem(D);F*=q;z*=q;h.setAttribute("d",["M",F,z,F,z].join(" "));h=svgedit.path.addCtrlGrip("1c1");D=svgedit.path.addCtrlGrip("0c2");u=svgedit.path.getCtrlLine(1);o=svgedit.path.getCtrlLine(2);h.setAttribute("cx",F);h.setAttribute("cy",z);D.setAttribute("cx",
F);D.setAttribute("cy",z);u.setAttribute("x1",F);u.setAttribute("x2",F);u.setAttribute("y1",z);u.setAttribute("y2",z);o.setAttribute("x1",F);o.setAttribute("x2",F);o.setAttribute("y1",z);o.setAttribute("y2",z);h=m;if(e)h+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(h,F,z)}m=true}else{d_attr="M"+F+","+z+" ";A=S({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:K.opacity/2}});h.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));h=e?svgedit.path.path.segs.length:
0;svgedit.path.addPointGrip(h,mouse_x,mouse_y);svgedit.path.first_grip=null}}else if(svgedit.path.path){svgedit.path.path.storeD();u=D.target.id;if(u.substr(0,14)=="pathpointgrip_"){z=svgedit.path.path.cur_pt=parseInt(u.substr(14));svgedit.path.path.dragging=[F,h];u=svgedit.path.path.segs[z];if(D.shiftKey)u.selected?svgedit.path.path.removePtFromSelection(z):svgedit.path.path.addPtsToSelection(z);else{if(svgedit.path.path.selected_pts.length<=1||!u.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(z)}}else if(u.indexOf("ctrlpointgrip_")==
0){svgedit.path.path.dragging=[F,h];D=u.split("_")[1].split("c");z=D[0]-0;m=D=D[1]-0;o=svgedit.path.path.segs[z];svgedit.path.path.selectPt(z,D);if(m==2){E=1;u=o.next}else{E=2;u=o.prev}if(!u)return;D=function(O,X){return Math.sqrt(Math.pow(O.x-X.x,2)+Math.pow(O.y-X.y,2))};z={x:o.item["x"+m],y:o.item["y"+m]};m=m==2?{x:o.item.x,y:o.item.y}:{x:u.item.x,y:u.item.y};o={x:u.item["x"+E],y:u.item["y"+E]};u=D(z,m);D=D(o,m);z=Math.abs(Math.round(Math.atan2(z.y-m.y,z.x-m.x)*(180/Math.PI),0)-Math.round(Math.atan2(o.y-
m.y,o.x-m.x)*(180/Math.PI),0))==180;if(Math.abs(u-D)<5&&z){svgedit.path.setLinkControlPoints(true);svgedit.path.is_linked=true}else{svgedit.path.setLinkControlPoints(false);svgedit.path.is_linked=false}}if(!svgedit.path.path.dragging){if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:F*q,y:h*q,width:0,height:0,display:"inline"},100)}}},mouseMove:function(D,z,F){G=true;var h=!D.altKey;if(Ha==="path"){if(A){var m=A.pathSegList,o=m.numberOfItems-1,u=svgedit.path.addCtrlGrip("1c1"),E=svgedit.path.addCtrlGrip("0c2");
if(l){var H=E.getAttribute("cx")/q||0,J=E.getAttribute("cy")/q||0;u.setAttribute("cx",z);u.setAttribute("cy",F);u.setAttribute("display","inline");D=l[0];u=l[1];m.getItem(o);var O=z/q,X=F/q;H=h?D+(D-O):H;h=h?u+(u-X):J;E.setAttribute("cx",H*q);E.setAttribute("cy",h*q);E.setAttribute("display","inline");E=svgedit.path.getCtrlLine(1);J=svgedit.path.getCtrlLine(2);ma(E,{x1:z,y1:F,x2:D*q,y2:u*q,display:"inline"});ma(J,{x1:H*q,y1:h*q,x2:D*q,y2:u*q,display:"inline"});if(o===0)C=[z,F];else{m=m.getItem(o-
1);z=m.x;F=m.y;if(m.pathSegType===6){z+=z-m.x2;F+=F-m.y2}else if(C){z=C[0]/q;F=C[1]/q}svgedit.path.replacePathSeg(6,o,[D,u,this.lastCtrlPoint[0]/q,this.lastCtrlPoint[1]/q,H,h],A)}}else if(h=this.stretchy){o=m.getItem(o);m=z;u=F;if(D.target.id==="pathpointgrip_0"&&svgedit.path.first_grip){m=svgedit.path.first_grip[0];u=svgedit.path.first_grip[1]}if(o.pathSegType===6)svgedit.path.replacePathSeg(6,1,[z,F,(this.lastCtrlPoint[0]/q||o.x+(o.x-o.x2))*q,(this.lastCtrlPoint[1]/q||o.y+(o.y-o.y2))*q,m,u],h);
else C?svgedit.path.replacePathSeg(6,1,[z,F,C[0],C[1],z,F],h):svgedit.path.replacePathSeg(4,1,[z,F],h)}}}else if(svgedit.path.path.dragging){m=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);D=svgedit.path.getPointFromGrip({x:z,y:F},svgedit.path.path);o=D.x-m.x;m=D.y-m.y;svgedit.path.path.dragging=[z,F];!h||!svgedit.path.is_linked?svgedit.path.setLinkControlPoints(false):svgedit.path.setLinkControlPoints(true);svgedit.path.path.dragctrl?
svgedit.path.path.moveCtrl(o,m):svgedit.path.path.movePts(o,m)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var ba=sa.getBBox(),T=svgedit.path.getGripPt(this);ba=svgedit.math.rectsIntersect(ba,{x:T.x,y:T.y,width:0,height:0});this.select(ba);ba&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(D,z,F,h){var m=pa("ctrlpointgrip_1c1"),o=pa("ctrlpointgrip_0c2");this.lastCtrlPoint=m?[m.getAttribute("cx"),m.getAttribute("cy")]:
[F,h];if(!svgedit.path.first_grip&&o)svgedit.path.first_grip=[o.getAttribute("cx"),o.getAttribute("cy")];if(Ha==="path"){l=null;if(!A){z=pa(aa());Ka=false;C=null}return{keep:true,element:z}}if(svgedit.path.path.dragging){z=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!D.shiftKey&&!G&&svgedit.path.path.selectPt(z)}else if(sa&&sa.getAttribute("display")!="none"){sa.setAttribute("display",
"none");sa.getAttribute("width")<=2&&sa.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=svgedit.path.getPath_(D);Ha="pathedit";xa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(D){var z=D==svgedit.path.path.elem;Ha="select";svgedit.path.path.show(false);k=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();
if(z){M("selected",[D]);qb([D],true)}},addSubPath:function(D){if(D){Ha="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(k===D){La.toEditMode(D);Ha="pathedit"}else k=D},reorient:function(){var D=I[0];if(D)if(na(D)!=0){var z=new Da("Reorient path"),F={d:D.getAttribute("d"),transform:D.getAttribute("transform")};z.addSubCommand(new Ma(D,F));xa();this.resetOrientation(D);wa(z);svgedit.path.getPath_(D).show(false).matrix=null;this.clear();qb([D],true);M("changed",
I)}},clear:function(D){k=null;if(A){var z=pa(aa());$(pa("path_stretch_line")).remove();D&&$(z).remove();$(pa("pathpointgrip_container")).find("*").attr("display","none");A=C=null;Ka=false}else Ha=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(D){if(D==null||D.nodeName!="path")return false;var z=R(D),F=Y(z).matrix;z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var h=z.numberOfItems,m=0;m<h;++m){var o=z.getItem(m),u=
o.pathSegType;if(u!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],X=o["y"+J];if(O!==undefined&&X!==undefined){O=N(O,X,F);E.splice(E.length,0,O.x,O.y)}});svgedit.path.replacePathSeg(u,m,E,D)}}g(D,F)},zoomChange:function(){Ha=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){if(svgedit.path.path){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},
clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var h=D[z];svgedit.path.path.addSeg(h);F.push(h+z);F.push(h+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var z=svgedit.path.path.elem,F=z.pathSegList,h=D[0],m=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=h)o=this.item;if(J<=
h)return true;if(this.type===2){m=J;return false}else if(this.type===1)return m=false});if(m==null)m=svgedit.path.path.segs.length-1;if(m!==false){var u=z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(m==svgedit.path.path.segs.length){F.appendItem(u);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,m);svgedit.path.insertItemBefore(z,u,m)}svgedit.path.path.init().selectPt(m+1)}else if(svgedit.path.path.segs[h].mate){F.removeItem(h);F.removeItem(h);svgedit.path.path.init().selectPt(h-
1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)u=D;else if(D===h)F.removeItem(u);else if(H.pathSegType===1&&h<D){E=D-1;F.removeItem(D);break}}for(D=h-u-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(u),E);z=F.getItem(u);svgedit.path.replacePathSeg(2,u,[z.x,z.y]);D=h;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length;z--;)svgedit.path.path.deleteSeg(D[z]);
var F=function(){var h=svgedit.path.path.elem.pathSegList,m=h.numberOfItems,o=function(H,J){for(;J--;)h.removeItem(H)};if(m<=1)return true;for(;m--;){var u=h.getItem(m);if(u.pathSegType===1){u=h.getItem(m-1);var E=h.getItem(m-2);if(u.pathSegType===2){o(m-1,2);F();break}else if(E.pathSegType===2){o(m-2,3);F();break}}else if(u.pathSegType===2)if(m>0){u=h.getItem(m-1).pathSegType;if(u===2){o(m-1,1);F();break}else if(u===1&&h.numberOfItems-1===m){o(m,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=
1){c.setMode("select");c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var h=z.getItem(0),m=null;D=[];D.push(["M",h.x,",",h.y," C"].join(""));for(var o=1;o<=F-4;o+=3){var u=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(m)if((h=svgedit.path.smoothControlPoints(m,
u,h))&&h.length==2){u=D[D.length-1].split(",");u[2]=h[0].x;u[3]=h[0].y;D[D.length-1]=u.join(",");u=h[1]}D.push([u.x,u.y,E.x,E.y,H.x,H.y].join(","));h=H;m=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];
var h={x:0,y:0};h[D]=z-F.item[D];F.move(h.x,h.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=D.pathSegList,F=z.numberOfItems,h,m=0;m<F;++m){var o=z.getItem(m);if(o.pathSegType===2)h=o;if(o.pathSegType===1){o=z.getItem(m-1);if(o.x!=h.x||o.y!=h.y){z=D.createSVGPathSegLinetoAbs(h.x,h.y);svgedit.path.insertItemBefore(D,z,m);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,h=F.numberOfItems,
m=0,o=0,u="",E=null,H=0;H<h;++H){var J=F.getItem(H),O=J.x||0,X=J.y||0,ba=J.x1||0,T=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});u+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:u+="z";break;case 12:O-=m;case 13:if(z){m+=O;qa="l"}else{O+=m;m=O;qa="L"}ua([[O,o]]);break;case 14:X-=o;case 15:if(z){o+=X;qa="l"}else{X+=
o;o=X;qa="L"}ua([[m,X]]);break;case 2:case 4:case 18:O-=m;X-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){m=E[0];o=E[1]}case 19:if(z){m+=O;o+=X}else{O+=m;X+=o;m=O;o=X}if(W===3)E=[m,o];ua([[O,X]]);break;case 6:O-=m;ba-=m;fa-=m;X-=o;T-=o;ha-=o;case 7:if(z){m+=O;o+=X}else{O+=m;ba+=m;fa+=m;X+=o;T+=o;ha+=o;m=O;o=X}ua([[ba,T],[fa,ha],[O,X]]);break;case 8:O-=m;ba-=m;X-=o;T-=o;case 9:if(z){m+=O;o+=X}else{O+=m;ba+=m;X+=o;T+=o;m=O;o=X}ua([[ba,T],[O,X]]);break;case 10:O-=m;X-=o;case 11:if(z){m+=
O;o+=X}else{O+=m;X+=o;m=O;o=X}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,X]);break;case 16:O-=m;fa-=m;X-=o;ha-=o;case 17:if(z){m+=O;o+=X}else{O+=m;fa+=m;X+=o;ha+=o;m=O;o=X}ua([[fa,ha],[O,X]])}}return u}}}(),yb=this.removeUnusedDefElems=function(){var e=n.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],l=0,C=["fill","stroke","filter","marker-start","marker-mid","marker-end"],A=C.length,G=n.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=
G[z],h=0;h<A;h++)if(F){var m=ja(F.getAttribute(C[h]));m&&k.push(m.substr(1))}(F=ca(F))&&F.indexOf("#")===0&&k.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){C=e[z];A=C.id;if(k.indexOf(A)<0){sb[A]=C;C.parentNode.removeChild(C);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);La.clear(true);$.each(n.childNodes,function(l,C){l&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&n.insertBefore(C,n.firstChild)});
if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(n).find("g:data(gsvg)").each(function(){for(var l=this.attributes,C=l.length,A=0;A<C;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")C--;if(C<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var k=this.svgToString(n,0);e.length&&$(e).each(function(){tb(this)});return k};this.svgToString=function(e,k){var l=[],C=svgedit.utilities.toXml,A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,h=e.childNodes;
for(F=0;F<k;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var m={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!m[O]&&ya[O]!=="xmlns"&&ya[O]!=="xml"){m[O]=true;l.push(" xmlns:"+ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox",
"id","overflow"];F--;){z=D.item(F);var o=C(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var u=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=0;F--){z=D.item(F);o=C(z.nodeValue);if(!(u.indexOf(z.localName)>=0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&
o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");k++;D=false;for(F=0;F<h.length;F++){A=h.item(F);switch(A.nodeType){case 1:l.push("\n");
l.push(this.svgToString(h.item(F),k));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(C(A)+"")}break;case 4:l.push("\n");l.push(Array(k+1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(k+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}k--;if(!D){l.push("\n");for(F=0;F<k;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var l=
document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=l.toDataURL().replace(";base64",C+";base64");Va[e]=C}catch(A){Va[e]=false}Ga=e;k&&k(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Ga=e};this.open=function(){};this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],k={feGaussianBlur:kb.exportNoBlur,
foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(n);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=kb.exportNoText;$.each(k,function(C,A){l.find(C).length&&e.push(A)});k=this.svgCanvasToString();M("exported",{svg:k,issues:e})};this.getSvgString=function(){$a.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 Hb=this.uniquifyElems=
function(e){var k={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(z){if(z.nodeType==1){if(z.id){z.id in k||(k[z.id]={elem:null,attrs:[],hrefs:[]});k[z.id].elem=z}$.each(vb,function(h,m){var o=z.getAttributeNode(m);if(o){var u=svgedit.utilities.getUrlFromAttr(o.value);if(u=u?u.substr(1):null){u in k||(k[u]={elem:null,attrs:[],hrefs:[]});k[u].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=
0)if(F=F.substr(1)){F in k||(k[F]={elem:null,attrs:[],hrefs:[]});k[F].hrefs.push(z)}}});for(var C in k)if(C){var A=k[C].elem;if(A){e=ka();A.id=e;A=k[C].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=k[C].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var l=ca(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName==
"svg")$(this).data("symbol",l).data("ref",l)}})},Ib=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 l=$(n).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1",
"y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=Y(A).matrix;A=N(C.x1,C.y1,G);G=N(C.x2,C.y2,G);C.x1=A.x;C.y1=A.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-l.x)/l.width,y1:(C.y1-l.y)/l.height,x2:(C.x2-l.x)/l.width,y2:(C.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Lb=this.convertToGroup=function(e){e||(e=I[0]);var k=$(e),l=new Da,C;if(k.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();
$(e).removeData("gsvg");C=R(e);var A=d.createSVGTransform();A.setTranslate(l.x,l.y);C.appendItem(A);Ra(e);M("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");A=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}C+=" translate("+(A.x||0)+","+(A.y||0)+")";A=k.prev();l.addSubCommand(new Fa(k[0],k[0].nextSibling,k[0].parentNode));k.remove();G=$(n).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,
z=0;z<D.length;z++)k.appendChild(D[z].cloneNode(true));if(svgedit.browser.isGecko()){D=$(gb()).children("linearGradient,radialGradient,pattern").clone();$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Hb(k);svgedit.browser.isGecko()&&$(gb()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();A.after(k);if(C){if(!G){A=e.nextSibling;C.removeChild(e);l.addSubCommand(new Fa(e,A,C))}l.addSubCommand(new Ia(k))}Gb(k);svgedit.browser.isGecko()?Ib(gb()):Ib(k);svgedit.utilities.walkTreePost(k,
function(F){try{Ra(F)}catch(h){console.log(h)}});$(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()});rb([k]);(e=Db(k,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);this.prepareSvg(k);var l=new Da("Change Source"),C=n.nextSibling,A=d.removeChild(n);l.addSubCommand(new Fa(A,C,d));n=f.adoptNode?f.adoptNode(k.documentElement):
f.importNode(k.documentElement,true);d.appendChild(n);var G=$(n);c.current_drawing_=new svgedit.draw.Drawing(n,v);var D=B().getNonce();D?M("setnonce",D):M("unsetnonce");G.find("image").each(function(){var J=this;Fb(J);var O=ca(this);if(O.indexOf("data:")===0){var X=O.match(/svgedit_url=(.*?);/);if(X){var ba=decodeURIComponent(X[1]);$(new Image).load(function(){J.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",ba)}).attr("src",ba)}}c.embedImage(O)});G.find("svg").each(function(){if(!$(this).closest("defs").length){Hb(this);
var J=this.parentNode;if(J.childNodes.length===1&&J.nodeName==="g"){$(J).data("gsvg",this);J.id=J.id||ka()}else tb(this)}});G.find("linearGradient, radialGradient, pattern").appendTo(gb());Gb(G);Ib(G[0]);svgedit.utilities.walkTreePost(n,function(J){try{Ra(J)}catch(O){console.log(O)}});var z={id:"svgcontent",overflow:p.show_outside_canvas?"visible":"hidden"},F=false;if(G.attr("viewBox")){var h=G.attr("viewBox").split(" ");z.width=h[2];z.height=h[3]}else $.each(["width","height"],function(J,O){var X=
G.attr(O);X||(X="100%");if((X+"").substr(-1)==="%")F=true;else z[O]=Ba(O,X)});xb();G.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});if(F){var m=getStrokedBBox();z.width=m.width+m.x;z.height=m.height+m.y}if(z.width<=0)z.width=200;if(z.height<=0)z.height=200;G.attr(z);this.contentW=z.width;this.contentH=z.height;$("#canvas_width").val(this.contentW);$("#canvas_height").val(this.contentH);var o=$("#canvas_background");
if(o.length){var u=o.attr("fill-opacity");u=u?parseInt(u)*100:100;fill=this.getPaint(o.attr("fill"),u,"canvas")}else fill=this.getPaint("none",100,"canvas");methodDraw.paintBox.canvas.setPaint(fill);l.addSubCommand(new Ia(n));var E=G.attr(["width","height"]);l.addSubCommand(new Ma(d,E));q=1;svgedit.transformlist.resetListMap();xa();svgedit.path.clearData();d.appendChild(ra.selectorParentGroup);wa(l);M("changed",[n])}catch(H){console.log(H);return false}return true};this.getPaint=function(e,k,l){var C=
null;if(e.indexOf("url(#")===0){e=(e=svgCanvas.getRefElem(e))?e.cloneNode(true):$("#"+l+"_color defs *")[0];C={alpha:k};C[e.tagName]=e}else C=e.indexOf("#")===0?{alpha:k,solidColor:e.substr(1)}:{alpha:k,solidColor:"none"};return new $.jGraduate.Paint(C)};this.importSvgString=function(e){try{var k=svgedit.utilities.encode64(e.length+e).substr(0,32),l=false;if(lb[k])if($(lb[k].symbol).parents("#svgroot").length)l=true;var C=new Da("Import SVG");if(l)var A=lb[k].symbol,G=lb[k].xform;else{var D=svgedit.utilities.text2xml(e);
this.prepareSvg(D);var z;z=f.adoptNode?f.adoptNode(D.documentElement):f.importNode(D.documentElement,true);Hb(z);var F=Ba("width",z.getAttribute("width")),h=Ba("height",z.getAttribute("height")),m=z.getAttribute("viewBox"),o=m?m.split(" "):[0,0,F,h];for(e=0;e<4;++e)o[e]=+o[e];n.getAttribute("width");var u=+n.getAttribute("height");G=h>F?"scale("+u/3/o[3]+")":"scale("+u/3/o[2]+")";G="translate(0) "+G+" translate(0)";A=f.createElementNS(b,"symbol");var E=gb();for(svgedit.browser.isGecko()&&$(z).find("linearGradient, radialGradient, pattern").appendTo(E);z.firstChild;)A.appendChild(z.firstChild);
var H=z.attributes;for(z=0;z<H.length;z++){var J=H[z];A.setAttribute(J.nodeName,J.nodeValue)}A.id=ka();lb[k]={symbol:A,xform:G};gb().appendChild(A);C.addSubCommand(new Ia(A))}var O=f.createElementNS(b,"use");O.id=ka();U(O,"#"+A.id);(L||B().getCurrentLayer()).appendChild(O);C.addSubCommand(new Ia(O));xa();O.setAttribute("transform",G);Ra(O);$(O).data("symbol",A).data("ref",A);qb([O]);wa(C);M("changed",[n])}catch(X){console.log(X);return false}return true};var xb=c.identifyLayers=function(){Eb();B().identifyLayers()};
this.createLayer=function(e){var k=new Da("Create Layer");e=B().createLayer(e);k.addSubCommand(new Ia(e));wa(k);xa();M("changed",[e])};this.cloneLayer=function(e){var k=new Da("Duplicate Layer"),l=f.createElementNS(b,"g"),C=f.createElementNS(b,"title");C.textContent=e;l.appendChild(C);C=B().getCurrentLayer();$(C).after(l);C=C.childNodes;for(var A=0;A<C.length;A++){var G=C[A];G.localName!="title"&&l.appendChild(ia(G))}xa();xb();k.addSubCommand(new Ia(l));wa(k);c.setCurrentLayer(e);M("changed",[l])};
this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),k=e.nextSibling,l=e.parentNode;if(e=B().deleteCurrentLayer()){var C=new Da("Delete Layer");C.addSubCommand(new Fa(e,k,l));wa(C);xa();M("changed",[l]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&xa();return e};this.renameCurrentLayer=function(e){var k=B();if(k.current_layer){var l=k.current_layer;if(!c.setCurrentLayer(e)){for(var C=new Da("Rename Layer"),A=0;A<k.getNumLayers();++A)if(k.all_layers[A][1]==
l)break;var G=k.getLayerName(A);k.all_layers[A][0]=svgedit.utilities.toXml(e);var D=l.childNodes.length;for(A=0;A<D;++A){var z=l.childNodes.item(A);if(z&&z.tagName=="title"){for(;z.firstChild;)z.removeChild(z.firstChild);z.textContent=e;C.addSubCommand(new Ma(z,{"#text":G}));wa(C);M("changed",[l]);return true}}}k.current_layer=l}return false};this.setCurrentLayerPosition=function(e){var k=B();if(k.current_layer&&e>=0&&e<k.getNumLayers()){for(var l=0;l<k.getNumLayers();++l)if(k.all_layers[l][1]==k.current_layer)break;
if(l==k.getNumLayers())return false;if(l!=e){var C=null,A=k.current_layer.nextSibling;if(e>l){if(e<k.getNumLayers()-1)C=k.all_layers[e+1][1]}else C=k.all_layers[e][1];n.insertBefore(k.current_layer,C);wa(new Ja(k.current_layer,A,n));xb();c.setCurrentLayer(k.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,k){var l=B(),C=l.getLayerVisibility(e),A=l.setLayerVisibility(e,k);if(A)wa(new Ma(A,{display:C?"inline":"none"},"Layer Visibility"));else return false;if(A==l.getCurrentLayer()){xa();
La.clear()}return true};this.moveSelectedToLayer=function(e){for(var k=null,l=B(),C=0;C<l.getNumLayers();++C)if(l.getLayerName(C)==e){k=l.all_layers[C][1];break}if(!k)return false;e=new Da("Move Elements to Layer");l=I;for(C=l.length;C--;){var A=l[C];if(A){var G=A.nextSibling,D=A.parentNode;k.appendChild(A);e.addSubCommand(new Ja(A,G,D))}}wa(e);return true};this.mergeLayer=function(e){var k=new Da("Merge Layer"),l=B(),C=$(l.current_layer).prev()[0];if(C){for(k.addSubCommand(new Fa(l.current_layer,
l.current_layer.nextSibling,n));l.current_layer.firstChild;){var A=l.current_layer.firstChild;if(A.localName=="title"){k.addSubCommand(new Fa(A,A.nextSibling,l.current_layer));l.current_layer.removeChild(A)}else{var G=A.nextSibling;C.appendChild(A);k.addSubCommand(new Ja(A,G,l.current_layer))}}n.removeChild(l.current_layer);if(!e){xa();xb();M("changed",[n]);wa(k)}l.current_layer=C;return k}};this.mergeAllLayers=function(){var e=new Da("Merge all Layers"),k=B();for(k.current_layer=k.all_layers[k.getNumLayers()-
1][1];$(n).children("g").length>1;)e.addSubCommand(c.mergeLayer(true));xa();xb();M("changed",[n]);wa(e)};var Eb=this.leaveContext=function(){var e=ta.length;if(e){for(var k=0;k<e;k++){var l=ta[k],C=cb(l,"orig_opac");C!==1?l.setAttribute("opacity",C):l.removeAttribute("opacity");l.setAttribute("style","pointer-events: inherit")}ta=[];xa(true);M("contextset",null)}L=null},Kb=this.setContext=function(e){Eb();if(typeof e==="string")e=pa(e);L=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var k=
this.getAttribute("opacity")||1;cb(this,"orig_opac",k);this.setAttribute("opacity",k*0.33);this.setAttribute("style","pointer-events: none");ta.push(this)});xa();M("contextset",L)};this.clear=function(){La.clear();xa();c.clearSvgContentElement();c.current_drawing_=new svgedit.draw.Drawing(n);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();ra.initGroup();sa=ra.getRubberBandBox();M("cleared")};this.linkControlPoints=La.linkControlPoints;this.getContentElem=function(){return n};this.getRootElem=
function(){return d};this.getSelectedElems=function(){return I};var zb=this.getResolution=function(){var e=n.getAttribute("width")/q,k=n.getAttribute("height")/q;return{w:e,h:k,zoom:q}};this.getZoom=function(){return q};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(kb,e.notification)};this.setConfig=function(e){$.extend(p,e)};this.getTitle=function(e){if(e=e||I[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var k=0;k<e.length;k++)if(e[k].nodeName==
"title")return e[k].textContent;return""}};this.setGroupTitle=function(e){var k=I[0];k=$(k).data("gsvg")||k;var l=$(k).children("title"),C=new Da("Set Label");if(e.length)if(l.length){l=l[0];C.addSubCommand(new Ma(l,{"#text":l.textContent}));l.textContent=e}else{l=f.createElementNS(b,"title");l.textContent=e;$(k).prepend(l);C.addSubCommand(new Ia(l))}else{C.addSubCommand(new Fa(l[0],l.nextSibling,k));l.remove()}wa(C)};this.getDocumentTitle=function(){return c.getTitle(n)};this.setDocumentTitle=function(e){for(var k=
n.childNodes,l=false,C="",A=new Da("Change Image Title"),G=0;G<k.length;G++)if(k[G].nodeName=="title"){l=k[G];C=l.textContent;break}if(!l){l=f.createElementNS(b,"title");n.insertBefore(l,n.firstChild)}if(e.length)l.textContent=e;else l.parentNode.removeChild(l);A.addSubCommand(new Ma(l,{"#text":C}));wa(A)};this.getEditorNS=function(e){e&&n.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,k){var l=zb(),C=l.w;l=l.h;var A;
if(e=="fit"){var G=getStrokedBBox();if(G){A=new Da("Fit Canvas to Content");var D=pb();qb(D);var z=[],F=[];$.each(D,function(){z.push(G.x*-1);F.push(G.y*-1)});D=c.moveSelectedElements(z,F,true);A.addSubCommand(D);xa();e=Math.round(G.width);k=Math.round(G.height)}else return false}if(e!=C||k!=l){D=d.suspendRedraw(1E3);A||(A=new Da("Change Image Dimensions"));e=Ba("width",e);k=Ba("height",k);n.setAttribute("width",e);n.setAttribute("height",k);this.contentW=e;this.contentH=k;A.addSubCommand(new Ma(n,
{width:C,height:l}));n.setAttribute("viewBox",[0,0,e/q,k/q].join(" "));A.addSubCommand(new Ma(n,{viewBox:["0 0",C,l].join(" ")}));wa(A);d.unsuspendRedraw(D);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",k+2)}M("changed",[n])}return[e,k]};this.getOffset=function(){return $(n).attr(["x","y"])};this.setBBoxZoom=function(e,k,l){var C=0.85,A=function(G){if(!G)return false;
var D=Math.min(Math.round(k/G.width*100*C)/100,Math.round(l/G.height*100*C)/100);c.setZoom(D);return{zoom:D,bbox:G}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:q*e.factor);return{zoom:q,bbox:e}}return A(e)}switch(e){case "selection":if(!I[0])return;e=$.map(I,function(G){if(G)return G});e=getStrokedBBox(e);break;case "canvas":e=zb();C=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(pb(B().getCurrentLayer()));
for(;e.parentNode&&e.parentNode!==(L||k);)e=e.parentNode;return e};(function(){var e=null,k=null,l=null,C=null,A=null,G={},D={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(z){if(!c.spaceKey){var F=z.button===2;mb=n.querySelector("g").getScreenCTM().inverse();var h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;z.preventDefault();if(F)Ha="select";m=m/q;h=h/q;var o=Bb(z);if(o.tagName==="a"&&o.childNodes.length===1)o=o.firstChild;var u=C=k=m,E=A=l=h;if(p.gridSnapping){m=va(m);h=va(h);k=va(k);
l=va(l)}if(o==ra.selectorParentGroup&&I[0]!=null){o=z.target;var H=cb(o,"type");if(H=="rotate"){Ha="rotate";current_rotate_mode=cb(o,"dir")}else if(H=="resize"){Ha="resize";db=cb(o,"dir")}o=I[0]}Sa=o.getAttribute("transform");H=R(o);switch(Ha){case "select":Ka=true;db="none";if(F)Ka=false;if(o!=d){if(I.indexOf(o)==-1){z.shiftKey||xa(true);qb([o]);wb=o;La.clear()}if(!F)for(F=0;F<I.length;++F)if(I[F]!=null){var J=R(I[F]);J.numberOfItems?J.insertItemBefore(d.createSVGTransform(),0):J.appendItem(d.createSVGTransform())}}else if(!F){xa();
Ha="multiselect";if(sa==null)sa=ra.getRubberBandBox();C*=q;A*=q;ma(sa,{x:C,y:A,width:0,height:0,display:"inline"},100)}break;case "zoom":Ka=true;if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:u*q,y:u*q,width:0,height:0,display:"inline"},100);break;case "resize":Ka=true;k=m;l=h;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var O={};$.each(G,function(X,ba){O[X]=ba/q});G=O;F=na(o)?1:0;if(oa(H)){H.insertItemBefore(d.createSVGTransform(),F);H.insertItemBefore(d.createSVGTransform(),F);H.insertItemBefore(d.createSVGTransform(),
F)}else{H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());H.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(m=svgedit.browser.isWebkit())J=function(X){var ba=X.getAttributeNS(null,"stroke");X.removeAttributeNS(null,"stroke");setTimeout(function(){X.setAttributeNS(null,"stroke",ba)},0)};o.style.vectorEffect="non-scaling-stroke";m&&J(o);h=o.getElementsByTagName("*");u=h.length;for(F=0;F<u;F++){h[F].style.vectorEffect="non-scaling-stroke";
m&&J(h[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ka=true;e=u+","+E+" ";J=K.stroke_width==0?1:K.stroke_width;S({element:"polyline",curStyles:true,attr:{points:e,id:ka(),fill:"none",opacity:K.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});D.minx=u;D.maxx=u;D.miny=E;D.maxy=E;break;case "image":Ka=true;J=S({element:"image",attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2,style:"pointer-events:inherit"}});U(J,Ga);Fb(J);break;case "square":case "rect":Ka=true;
k=m;l=h;S({element:"rect",curStyles:true,attr:{x:m,y:h,width:0,height:0,id:ka(),opacity:K.opacity/2}});break;case "line":Ka=true;J=K.stroke_width==0?1:K.stroke_width;S({element:"line",curStyles:true,attr:{x1:m,y1:h,x2:m,y2:h,id:ka(),stroke:K.stroke,"stroke-width":J,"stroke-dasharray":K.stroke_dasharray,"stroke-linejoin":K.stroke_linejoin,"stroke-linecap":K.stroke_linecap,"stroke-opacity":K.stroke_opacity,fill:"none",opacity:K.opacity/2,style:"pointer-events:none"}});break;case "circle":Ka=true;S({element:"circle",
curStyles:true,attr:{cx:m,cy:h,r:0,id:ka(),opacity:K.opacity/2}});break;case "ellipse":Ka=true;S({element:"ellipse",curStyles:true,attr:{cx:m,cy:h,rx:0,ry:0,id:ka(),opacity:K.opacity/2}});break;case "text":Ka=true;S({element:"text",curStyles:true,attr:{x:m,y:h,id:ka(),fill:Ua.fill,"stroke-width":Ua.stroke_width,"font-size":Ua.font_size,"font-family":Ua.font_family,"text-anchor":"left","xml:space":"preserve",opacity:K.opacity}});break;case "path":case "pathedit":k*=q;l*=q;La.mouseDown(z,o,k,l);Ka=
true;break;case "textedit":k*=q;l*=q;bb.mouseDown(z,o,k,l);Ka=true;break;case "rotate":Ka=true;c.undoMgr.beginUndoableChange("transform",I);document.getElementById("workarea").className="rotate"}J=ib("mouseDown",{event:z,start_x:k,start_y:l,selectedElements:I},true);$.each(J,function(X,ba){if(ba&&ba.started)Ka=true});if(Ha)document.getElementById("workarea").className=Ha=="resize"?z.target.style.cursor:Ha}}).mousemove(function(z){if(!(z.originalEvent.touches&&z.originalEvent.touches.length>1))if(Ka)if(!(z.button===
1||c.spaceKey)){var F=I[0],h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;var o=pa(aa()),u=x=m/q,E=y=h/q;if(p.gridSnapping){x=va(x);y=va(y)}z.preventDefault();switch(Ha){case "select":if(I[0]!==null){u=x-k;var H=y-l;if(p.gridSnapping){u=va(u);H=va(H)}if(z.shiftKey){var J=V(k,l,x,y);x=J.x;y=J.y}if(u!=0||H!=0){E=I.length;for(var O=0;O<E;++O){F=I[O];if(F==null)break;var X=d.createSVGTransform();o=R(F);if(J){u=J.x-k;H=J.y-l}X.setTranslate(u,H);o.numberOfItems?o.replaceItem(X,0):o.appendItem(X);ra.requestSelector(F).resize()}if(z.altKey)if(!c.addClones){c.addClones=
c.cloneSelectedElements(0,0,X);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(ua){ua.parentNode&&ua.parentNode.removeChild(ua);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",I)}}break;case "multiselect":u*=q;E*=q;ma(sa,{x:Math.min(C,u),y:Math.min(A,E),width:Math.abs(u-C),height:Math.abs(E-A)},100);o=[];u=[];J=ob();E=I.length;for(O=0;O<E;++O){H=J.indexOf(I[O]);if(H==-1)o.push(I[O]);else J[H]=null}E=J.length;for(O=0;O<E;++O)J[O]&&u.push(J[O]);
o.length>0&&c.removeFromSelection(o);u.length>0&&qb(u);break;case "resize":o=R(F);u=(J=oa(o))?G:svgedit.utilities.getBBox(F);E=u.x;O=u.y;var ba=u.width,T=u.height;u=x-k;H=y-l;if(p.gridSnapping){u=va(u);H=va(H);T=va(T);ba=va(ba)}if(X=na(F)){var fa=Math.sqrt(u*u+H*H);H=Math.atan2(H,u)-X*Math.PI/180;u=fa*Math.cos(H);H=fa*Math.sin(H)}if(db.indexOf("n")==-1&&db.indexOf("s")==-1)H=0;if(db.indexOf("e")==-1&&db.indexOf("w")==-1)u=0;var ha=fa=0,W=T?(T+H)/T:1,qa=ba?(ba+u)/ba:1;if(db.indexOf("n")>=0){W=T?(T-
H)/T:1;ha=T}if(db.indexOf("w")>=0){qa=ba?(ba-u)/ba:1;fa=ba}u=d.createSVGTransform();H=d.createSVGTransform();ba=d.createSVGTransform();if(p.gridSnapping){E=va(E);fa=va(fa);O=va(O);ha=va(ha)}u.setTranslate(-(E+fa),-(O+ha));if(z.shiftKey)if(qa==1)qa=W;else W=qa;H.setScale(qa,W);ba.setTranslate(E+fa,O+ha);if(J){J=X?1:0;o.replaceItem(u,2+J);o.replaceItem(H,1+J);o.replaceItem(ba,0+J)}else{J=o.numberOfItems;o.replaceItem(ba,J-3);o.replaceItem(H,J-2);o.replaceItem(u,J-1)}ra.requestSelector(F).resize();M("transition",
I);break;case "zoom":u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-A*q)},100);break;case "text":ma(o,{x:x,y:y},1E3);break;case "line":u=null;window.opera||d.suspendRedraw(1E3);if(p.gridSnapping){x=va(x);y=va(y)}E=x;J=y;if(z.shiftKey){J=V(k,l,E,J);E=J.x;J=J.y}o.setAttributeNS(null,"x2",E);o.setAttributeNS(null,"y2",J);window.opera||d.unsuspendRedraw(u);break;case "foreignObject":case "square":case "rect":case "image":u=Math.abs(x-k);J=Math.abs(y-l);if(Ha==
"square"||z.shiftKey){u=J=Math.max(u,J);E=k<x?k:k-u;O=l<y?l:l-J}else{E=Math.min(k,x);O=Math.min(l,y)}if(z.altKey){u*=2;J*=2;E=k-u/2;O=l-J/2}if(p.gridSnapping){u=va(u);J=va(J);E=va(E);O=va(O)}ma(o,{width:u,height:J,x:E,y:O},1E3);break;case "circle":u=$(o).attr(["cx","cy"]);J=u.cx;E=u.cy;u=Math.sqrt((x-J)*(x-J)+(y-E)*(y-E));if(p.gridSnapping)u=va(u);o.setAttributeNS(null,"r",u);break;case "ellipse":u=$(o).attr(["cx","cy"]);J=Math.abs(k+(x-k)/2);E=Math.abs(l+(y-l)/2);u=null;window.opera||d.suspendRedraw(1E3);
if(p.gridSnapping){x=va(x);J=va(J);y=va(y);E=va(E)}O=Math.abs(k-J);H=Math.abs(l-E);if(z.shiftKey){H=O;E=y>l?l+O:l-O}if(z.altKey){J=k;E=l;O=Math.abs(x-J);H=z.shiftKey?O:Math.abs(y-E)}o.setAttributeNS(null,"rx",O);o.setAttributeNS(null,"ry",H);o.setAttributeNS(null,"cx",J);o.setAttributeNS(null,"cy",E);window.opera||d.unsuspendRedraw(u);break;case "fhellipse":case "fhrect":D.minx=Math.min(u,D.minx);D.maxx=Math.max(u,D.maxx);D.miny=Math.min(E,D.miny);D.maxy=Math.max(E,D.maxy);case "fhpath":e+=+u+","+
E+" ";o.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=q;y*=q;if(p.gridSnapping){x=va(x);y=va(y);k=va(k);l=va(l)}if(z.shiftKey){if(J=svgedit.path.path){o=J.dragging?J.dragging[0]:k;J=J.dragging?J.dragging[1]:l}else{o=k;J=l}J=V(o,J,x,y);x=J.x;y=J.y}if(sa&&sa.getAttribute("display")!=="none"){u*=q;E*=q;ma(sa,{x:Math.min(C*q,u),y:Math.min(A*q,E),width:Math.abs(u-C*q),height:Math.abs(E-A*q)},100)}La.mouseMove(z,x,y);break;case "textedit":x*=q;y*=q;bb.mouseMove(m,h);break;case "rotate":u=
svgedit.utilities.getBBox(F);J=u.x+u.width/2;E=u.y+u.height/2;o=ea(F);o=N(J,E,o);J=o.x;E=o.y;o=u.x;O=u.y;if(current_rotate_mode=="nw")o=u.x+u.width;if(current_rotate_mode=="se")O=u.y+u.height;if(current_rotate_mode=="sw"){o=u.x+u.width;O=u.y+u.height}compensation_angle=(Math.atan2(E-O,J-o)*(180/Math.PI)-90)%360;X=(Math.atan2(E-y,J-x)*(180/Math.PI)-90)%360;X+=compensation_angle;if(p.gridSnapping)X=va(X);if(z.shiftKey)X=Math.round(X/45)*45;c.setRotationAngle(X<-180?360+X:X,true);M("transition",I)}ib("mouseMove",
{event:z,mouse_x:m,mouse_y:h,selected:F})}}).click(function(z){z.preventDefault();return false}).dblclick(function(z){var F=z.target.parentNode,h=Bb(z),m=h.tagName;if(F!==L){if(m==="text"&&Ha!=="textedit"){z=N(z.pageX,z.pageY,mb);bb.select(h,z.x,z.y)}if((m==="g"||m==="a")&&na(h)){Db(h);h=I[0];xa(true)}L&&Eb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||h===ra.selectorParentGroup||Kb(h)}}).mouseup(function(z){c.addClones=false;window.removeEventListener("keyup",c.removeClones);I=I.filter(Boolean);
if(z.button!==2){var F=wb;wb=null;if(Ka){var h=N(z.pageX,z.pageY,mb),m=h.x*q;h=h.y*q;var o=m/q,u=h/q,E=pa(aa()),H=false;Ka=false;switch(Ha){case "resize":case "multiselect":if(sa!=null){sa.setAttribute("display","none");hb=[]}Ha="select";case "select":if(I[0]!=null){if(I.length==1){m=I[0];switch(m.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Xa.fill=m.getAttribute("fill");Xa.fill_opacity=m.getAttribute("fill-opacity");Xa.stroke=m.getAttribute("stroke");Xa.stroke_opacity=
m.getAttribute("stroke-opacity");Xa.stroke_width=m.getAttribute("stroke-width");Xa.stroke_dasharray=m.getAttribute("stroke-dasharray");Xa.stroke_linejoin=m.getAttribute("stroke-linejoin");Xa.stroke_linecap=m.getAttribute("stroke-linecap")}if(m.tagName=="text"){Ua.font_size=m.getAttribute("font-size");Ua.font_family=m.getAttribute("font-family")}ra.requestSelector(m).showGrips(true)}Ea();C=C;A=A;m=Math.abs(u-A);if(m>1||m>1){z=I.length;for(m=0;m<z;++m){if(I[m]==null)break;I[m].firstChild||ra.requestSelector(I[m]).resize()}}else{m=
z.target;if(I[0].nodeName==="path"&&I[1]==null)La.select(I[0]);else z.shiftKey&&F!=m&&c.removeFromSelection([m])}if(svgedit.browser.supportsNonScalingStroke())if(z=I[0]){z.removeAttribute("style");svgedit.utilities.walkTree(z,function(X){X.removeAttribute("style")})}}return;case "zoom":sa!=null&&sa.setAttribute("display","none");M("zoomed",{x:Math.min(C,o),y:Math.min(A,u),width:Math.abs(o-C),height:Math.abs(u-A),factor:z.altKey?0.5:2});return;case "fhpath":F=E.getAttribute("points");u=F.indexOf(",");
if(H=u>=0?F.indexOf(",",u+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)E=La.smoothPolylineIntoPath(E);break;case "line":F=$(E).attr(["x1","x2","y1","y2"]);H=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(E).attr(["width","height"]);H=F.width!=0||F.height!=0||Ha==="image";break;case "circle":H=E.getAttribute("r")!=0;break;case "ellipse":F=$(E).attr(["rx","ry"]);H=F.rx!=null||F.ry!=null;break;case "fhellipse":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"ellipse",
curStyles:true,attr:{cx:(D.minx+D.maxx)/2,cy:(D.miny+D.maxy)/2,rx:(D.maxx-D.minx)/2,ry:(D.maxy-D.miny)/2,id:aa()}});M("changed",[E]);H=true}break;case "fhrect":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){E=S({element:"rect",curStyles:true,attr:{x:D.minx,y:D.miny,width:D.maxx-D.minx,height:D.maxy-D.miny,id:aa()}});M("changed",[E]);H=true}break;case "text":H=true;rb([E]);bb.start(E);break;case "path":E=null;Ka=true;F=La.mouseUp(z,E,m,h);E=F.element;H=F.keep;break;case "pathedit":H=true;E=null;La.mouseUp(z);
break;case "textedit":H=false;E=null;bb.mouseUp(z,m,h);break;case "rotate":H=true;E=null;Ha="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||wa(F);Ea();M("changed",I)}m=ib("mouseUp",{event:z,mouse_x:m,mouse_y:h},true);$.each(m,function(X,ba){if(ba){H=ba.keep||H;E=ba.element;Ka=ba.started||Ka}});if(!H&&E!=null){B().releaseId(aa());E.parentNode.removeChild(E);E=null;for(m=z.target;m.parentNode.parentNode.tagName=="g";)m=m.parentNode;if((Ha!="path"||!drawn_path)&&m.parentNode.id!="selectorParentGroup"&&
m.id!="svgcanvas"&&m.id!="svgroot"){c.setMode("select");rb([m],true)}}else if(E!=null){c.addedNew=true;z=0.2;var J;if(false.beginElement&&E.getAttribute("opacity")!=K.opacity){J=$(false).clone().attr({to:K.opacity,dur:z}).appendTo(E);try{J[0].beginElement()}catch(O){}}else z=0;setTimeout(function(){J&&J.remove();E.setAttribute("opacity",K.opacity);E.setAttribute("style","pointer-events:inherit");la(E);if(Ha==="path")La.toEditMode(E);else p.selectNew&&rb([E],true);wa(new Ia(E));M("changed",[E])},z*
1E3)}Sa=null}}});$(a).bind("mousewheel DOMMouseScroll",function(z){if(z.shiftKey){z.preventDefault();mb=n.getScreenCTM().inverse();var F=N(z.pageX,z.pageY,mb);F={x:F.x,y:F.y,width:0,height:0};if(z.wheelDelta)if(z.wheelDelta>=120)F.factor=2;else{if(z.wheelDelta<=-120)F.factor=0.5}else if(z.detail)if(z.detail>0)F.factor=0.5;else if(z.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var Fb=function(e){$(e).click(function(k){k.preventDefault()})},bb=c.textActions=function(){function e(T){var fa=h.value===
"";$(h).focus();if(!arguments.length)if(fa)T=0;else{if(h.selectionEnd!==h.selectionStart)return;T=h.selectionEnd}var ha;ha=E[T];fa||h.setSelectionRange(T,T);m=pa("text_cursor");if(!m){m=document.createElementNS(b,"line");ma(m,{id:"text_cursor",stroke:"#333","stroke-width":1});m=pa("selectorParentGroup").appendChild(m)}u||(u=setInterval(function(){var W=m.getAttribute("display")==="none";m.setAttribute("display",W?"inline":"none")},600));fa=G(ha.x,H.y);ha=G(ha.x,H.y+H.height);ma(m,{x1:fa.x,y1:fa.y,
x2:ha.x,y2:ha.y,visibility:"visible",display:"inline"});o&&o.setAttribute("d","M 0 0")}function k(T,fa,ha){if(T===fa)e(fa);else{ha||h.setSelectionRange(T,fa);o=pa("text_selectblock");if(!o){o=document.createElementNS(b,"path");ma(o,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});pa("selectorParentGroup").appendChild(o)}T=E[T];var W=E[fa];m.setAttribute("visibility","hidden");fa=G(T.x,H.y);ha=G(T.x+(W.x-T.x),H.y);var qa=G(T.x,H.y+H.height);T=G(T.x+(W.x-T.x),H.y+H.height);
ma(o,{d:"M"+fa.x+","+fa.y+" L"+ha.x+","+ha.y+" "+T.x+","+T.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function l(T,fa){var ha=d.createSVGPoint();ha.x=T;ha.y=fa;if(E.length==1)return 0;ha=F.getCharNumAtPosition(ha);if(ha<0){ha=E.length-2;if(T<=E[0].x)ha=0}else if(ha>=E.length-2)ha=E.length-2;var W=E[ha];T>W.x+W.width/2&&ha++;return ha}function C(T,fa,ha){var W=h.selectionStart;T=l(T,fa);k(Math.min(W,T),Math.max(W,T),!ha)}function A(T,fa){var ha={x:T,y:fa};ha.x/=q;ha.y/=q;if(J){var W=N(ha.x,ha.y,J.inverse());
ha.x=W.x;ha.y=W.y}return ha}function G(T,fa){var ha={x:T,y:fa};if(J){var W=N(ha.x,ha.y,J);ha.x=W.x;ha.y=W.y}ha.x*=q;ha.y*=q;return ha}function D(T){k(0,F.textContent.length);$(this).unbind(T)}function z(T){if(ba&&F){var fa=N(T.pageX,T.pageY,mb);fa=A(fa.x*q,fa.y*q);fa=l(fa.x,fa.y);var ha=F.textContent,W=ha.substr(0,fa).replace(/[a-z0-9]+$/i,"").length;ha=ha.substr(fa).match(/^[a-z0-9]+/i);k(W,(ha?ha[0].length:0)+fa);$(T.target).click(D);setTimeout(function(){$(T.target).unbind("click",D)},300)}}var F,
h,m,o,u,E=[],H,J,O,X,ba;return{select:function(T,fa,ha){F=T;bb.toEditMode(fa,ha)},start:function(T){F=T;bb.toEditMode()},mouseDown:function(T,fa,ha,W){T=A(ha,W);h.focus();e(l(T.x,T.y));O=ha;X=W},mouseMove:function(T,fa){var ha=A(T,fa);C(ha.x,ha.y)},mouseUp:function(T,fa,ha){var W=A(fa,ha);C(W.x,W.y,true);T.target!==F&&fa<O+2&&fa>O-2&&ha<X+2&&ha>X-2&&bb.toSelectMode(true)},setCursor:e,toEditMode:function(T,fa){rb([F],false);ba=false;Ha="textedit";ra.requestSelector(F).showGrips(false);ra.requestSelector(F);
bb.init();$(F).css("cursor","text");if(arguments.length){var ha=A(T,fa);e(l(ha.x,ha.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(T){Ha="select";clearInterval(u);u=null;o&&$(o).attr("display","none");m&&$(m).attr("visibility","hidden");$(F).css("cursor","move");if(T){xa();$(F).css("cursor","move");M("selected",[F]);qb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(h).blur();F=false},setInputElem:function(T){h=T},clear:function(){Ha=="textedit"&&bb.toSelectMode()},
init:function(){if(F){if(!F.parentNode){F=I[0];ra.requestSelector(F).showGrips(false)}var T=F.textContent.length,fa=F.getAttribute("transform");H=svgedit.utilities.getBBox(F);J=fa?ea(F):null;E=Array(T);h.focus();$(F).unbind("dblclick",z).dblclick(z);if(!T)var ha={x:H.x+H.width/2,width:0};for(fa=0;fa<T;fa++){var W=F.getStartPositionOfChar(fa);ha=F.getEndPositionOfChar(fa);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*q;W.x-=qa;ha.x-=qa;W.x/=q;ha.x/=q}E[fa]={x:W.x,y:H.y,width:ha.x-
W.x,height:H.height}}E.push({x:ha.x,width:0});k(h.selectionStart,h.selectionEnd,true)}}}}(),La=c.pathActions=function(){var e=false,k,l,C;svgedit.path.Path.prototype.endChanges=function(D){if(svgedit.browser.isWebkit()){var z=this.elem;z.setAttribute("d",La.convertPath(z))}D=new Ma(this.elem,{d:this.last_d},D);wa(D);M("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(D){$.isArray(D)||(D=[D]);for(var z=0;z<D.length;z++){var F=D[z],h=this.segs[F];h.ptgrip&&this.selected_pts.indexOf(F)==
-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();z=this.selected_pts.length;for(D=Array(z);z--;){h=this.segs[this.selected_pts[z]];h.select(true);D[z]=h.ptgrip}La.canDeleteNodes=true;La.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",D)};var A=k=null,G=false;this.lastCtrlPoint=[0,0];return{mouseDown:function(D,z,F,h){if(Ha==="path"){mouse_x=F;mouse_y=h;F=mouse_x/q;z=mouse_y/q;h=pa("path_stretch_line");l=[F,z];if(p.gridSnapping){F=va(F);z=va(z);mouse_x=va(mouse_x);
mouse_y=va(mouse_y)}if(!h){h=document.createElementNS(b,"path");ma(h,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});h=pa("selectorParentGroup").appendChild(h)}h.setAttribute("display","inline");this.stretchy=h;var m=null;if(A){m=A.pathSegList;for(var o=m.numberOfItems,u=6/q,E=false;o;){o--;var H=m.getItem(o),J=H.x;H=H.y;if(F>=J-u&&F<=J+u&&z>=H-u&&z<=H+u){E=true;break}}u=aa();svgedit.path.removePath_(u);u=pa(u);J=m.numberOfItems;if(E){if(o<=1&&J>=2){F=m.getItem(0).x;z=m.getItem(0).y;
o=svgedit.path.first_grip?svgedit.path.first_grip[0]/q:m.getItem(0).x;E=svgedit.path.first_grip?svgedit.path.first_grip[1]/q:m.getItem(0).y;D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(F,z):A.createSVGPathSegCurvetoCubicAbs(F,z,D.x1/q,D.y1/q,o,E);F=A.createSVGPathSegClosePath();m.appendItem(D);m.appendItem(F)}else if(J<3)return m=false;$(h).remove();element=u;A=null;Ka=false;if(e){svgedit.path.path.matrix&&Za(u,{},svgedit.path.path.matrix.inverse());F=u.getAttribute("d");
h=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",h+F);$(u).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();La.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Bb(D))){console.log("Clicked outside canvas");return false}m=A.pathSegList.numberOfItems;o=A.pathSegList.getItem(m-1);u=o.x;o=o.y;if(D.shiftKey){z=V(u,o,F,z);F=z.x;z=z.y}D=h.pathSegList.getItem(1);D=D.pathSegType===4?A.createSVGPathSegLinetoAbs(ab(F),
ab(z)):A.createSVGPathSegCurvetoCubicAbs(ab(F),ab(z),D.x1/q,D.y1/q,D.x2/q,D.y2/q);A.pathSegList.appendItem(D);F*=q;z*=q;h.setAttribute("d",["M",F,z,F,z].join(" "));h=svgedit.path.addCtrlGrip("1c1");D=svgedit.path.addCtrlGrip("0c2");u=svgedit.path.getCtrlLine(1);o=svgedit.path.getCtrlLine(2);h.setAttribute("cx",F);h.setAttribute("cy",z);D.setAttribute("cx",F);D.setAttribute("cy",z);u.setAttribute("x1",F);u.setAttribute("x2",F);u.setAttribute("y1",z);u.setAttribute("y2",z);o.setAttribute("x1",F);o.setAttribute("x2",
F);o.setAttribute("y1",z);o.setAttribute("y2",z);h=m;if(e)h+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(h,F,z)}m=true}else{d_attr="M"+F+","+z+" ";A=S({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:K.opacity/2}});h.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));h=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(h,mouse_x,mouse_y);svgedit.path.first_grip=null}}else if(svgedit.path.path){svgedit.path.path.storeD();u=D.target.id;if(u.substr(0,
14)=="pathpointgrip_"){z=svgedit.path.path.cur_pt=parseInt(u.substr(14));svgedit.path.path.dragging=[F,h];u=svgedit.path.path.segs[z];if(D.shiftKey)u.selected?svgedit.path.path.removePtFromSelection(z):svgedit.path.path.addPtsToSelection(z);else{if(svgedit.path.path.selected_pts.length<=1||!u.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(z)}}else if(u.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,h];D=u.split("_")[1].split("c");z=D[0]-0;m=D=D[1]-0;o=
svgedit.path.path.segs[z];svgedit.path.path.selectPt(z,D);if(m==2){E=1;u=o.next}else{E=2;u=o.prev}if(!u)return;D=function(O,X){return Math.sqrt(Math.pow(O.x-X.x,2)+Math.pow(O.y-X.y,2))};z={x:o.item["x"+m],y:o.item["y"+m]};m=m==2?{x:o.item.x,y:o.item.y}:{x:u.item.x,y:u.item.y};o={x:u.item["x"+E],y:u.item["y"+E]};u=D(z,m);D=D(o,m);z=Math.abs(Math.round(Math.atan2(z.y-m.y,z.x-m.x)*(180/Math.PI),0)-Math.round(Math.atan2(o.y-m.y,o.x-m.x)*(180/Math.PI),0))==180;if(Math.abs(u-D)<5&&z){svgedit.path.setLinkControlPoints(true);
svgedit.path.is_linked=true}else{svgedit.path.setLinkControlPoints(false);svgedit.path.is_linked=false}}if(!svgedit.path.path.dragging){if(sa==null)sa=ra.getRubberBandBox();ma(sa,{x:F*q,y:h*q,width:0,height:0,display:"inline"},100)}}},mouseMove:function(D,z,F){G=true;var h=!D.altKey;if(Ha==="path"){if(A){var m=A.pathSegList,o=m.numberOfItems-1,u=svgedit.path.addCtrlGrip("1c1"),E=svgedit.path.addCtrlGrip("0c2");if(l){var H=E.getAttribute("cx")/q||0,J=E.getAttribute("cy")/q||0;u.setAttribute("cx",z);
u.setAttribute("cy",F);u.setAttribute("display","inline");D=l[0];u=l[1];m.getItem(o);var O=z/q,X=F/q;H=h?D+(D-O):H;h=h?u+(u-X):J;E.setAttribute("cx",H*q);E.setAttribute("cy",h*q);E.setAttribute("display","inline");E=svgedit.path.getCtrlLine(1);J=svgedit.path.getCtrlLine(2);ma(E,{x1:z,y1:F,x2:D*q,y2:u*q,display:"inline"});ma(J,{x1:H*q,y1:h*q,x2:D*q,y2:u*q,display:"inline"});if(o===0)C=[z,F];else{m=m.getItem(o-1);z=m.x;F=m.y;if(m.pathSegType===6){z+=z-m.x2;F+=F-m.y2}else if(C){z=C[0]/q;F=C[1]/q}svgedit.path.replacePathSeg(6,
o,[D,u,this.lastCtrlPoint[0]/q,this.lastCtrlPoint[1]/q,H,h],A)}}else if(h=this.stretchy){o=m.getItem(o);m=z;u=F;if(D.target.id==="pathpointgrip_0"&&svgedit.path.first_grip){m=svgedit.path.first_grip[0];u=svgedit.path.first_grip[1]}if(o.pathSegType===6)svgedit.path.replacePathSeg(6,1,[z,F,(this.lastCtrlPoint[0]/q||o.x+(o.x-o.x2))*q,(this.lastCtrlPoint[1]/q||o.y+(o.y-o.y2))*q,m,u],h);else C?svgedit.path.replacePathSeg(6,1,[z,F,C[0],C[1],z,F],h):svgedit.path.replacePathSeg(4,1,[z,F],h)}}}else if(svgedit.path.path.dragging){m=
svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);D=svgedit.path.getPointFromGrip({x:z,y:F},svgedit.path.path);o=D.x-m.x;m=D.y-m.y;svgedit.path.path.dragging=[z,F];!h||!svgedit.path.is_linked?svgedit.path.setLinkControlPoints(false):svgedit.path.setLinkControlPoints(true);svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(o,m):svgedit.path.path.movePts(o,m)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||
this.prev){var ba=sa.getBBox(),T=svgedit.path.getGripPt(this);ba=svgedit.math.rectsIntersect(ba,{x:T.x,y:T.y,width:0,height:0});this.select(ba);ba&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(D,z,F,h){var m=pa("ctrlpointgrip_1c1"),o=pa("ctrlpointgrip_0c2");this.lastCtrlPoint=m?[m.getAttribute("cx"),m.getAttribute("cy")]:[F,h];if(!svgedit.path.first_grip&&o)svgedit.path.first_grip=[o.getAttribute("cx"),o.getAttribute("cy")];if(Ha==="path"){l=null;if(!A){z=pa(aa());Ka=false;
C=null}return{keep:true,element:z}}if(svgedit.path.path.dragging){z=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!D.shiftKey&&!G&&svgedit.path.path.selectPt(z)}else if(sa&&sa.getAttribute("display")!="none"){sa.setAttribute("display","none");sa.getAttribute("width")<=2&&sa.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=
svgedit.path.getPath_(D);Ha="pathedit";xa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(D){var z=D==svgedit.path.path.elem;Ha="select";svgedit.path.path.show(false);k=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(z){M("selected",[D]);qb([D],true)}},addSubPath:function(D){if(D){Ha="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(k===
D){La.toEditMode(D);Ha="pathedit"}else k=D},reorient:function(){var D=I[0];if(D)if(na(D)!=0){var z=new Da("Reorient path"),F={d:D.getAttribute("d"),transform:D.getAttribute("transform")};z.addSubCommand(new Ma(D,F));xa();this.resetOrientation(D);wa(z);svgedit.path.getPath_(D).show(false).matrix=null;this.clear();qb([D],true);M("changed",I)}},clear:function(D){k=null;if(A){var z=pa(aa());$(pa("path_stretch_line")).remove();D&&$(z).remove();$(pa("pathpointgrip_container")).find("*").attr("display",
"none");A=C=null;Ka=false}else Ha=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(D){if(D==null||D.nodeName!="path")return false;var z=R(D),F=Y(z).matrix;z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var h=z.numberOfItems,m=0;m<h;++m){var o=z.getItem(m),u=o.pathSegType;if(u!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],X=o["y"+J];if(O!==undefined&&X!==undefined){O=N(O,X,F);E.splice(E.length,0,O.x,O.y)}});
svgedit.path.replacePathSeg(u,m,E,D)}}g(D,F)},zoomChange:function(){Ha=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){if(svgedit.path.path){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var h=D[z];svgedit.path.path.addSeg(h);
F.push(h+z);F.push(h+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var z=svgedit.path.path.elem,F=z.pathSegList,h=D[0],m=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=h)o=this.item;if(J<=h)return true;if(this.type===2){m=J;return false}else if(this.type===1)return m=false});if(m==null)m=svgedit.path.path.segs.length-1;if(m!==false){var u=
z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(m==svgedit.path.path.segs.length){F.appendItem(u);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,m);svgedit.path.insertItemBefore(z,u,m)}svgedit.path.path.init().selectPt(m+1)}else if(svgedit.path.path.segs[h].mate){F.removeItem(h);F.removeItem(h);svgedit.path.path.init().selectPt(h-1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)u=D;else if(D===h)F.removeItem(u);else if(H.pathSegType===
1&&h<D){E=D-1;F.removeItem(D);break}}for(D=h-u-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(u),E);z=F.getItem(u);svgedit.path.replacePathSeg(2,u,[z.x,z.y]);D=h;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length;z--;)svgedit.path.path.deleteSeg(D[z]);var F=function(){var h=svgedit.path.path.elem.pathSegList,m=h.numberOfItems,o=function(H,J){for(;J--;)h.removeItem(H)};if(m<=1)return true;
for(;m--;){var u=h.getItem(m);if(u.pathSegType===1){u=h.getItem(m-1);var E=h.getItem(m-2);if(u.pathSegType===2){o(m-1,2);F();break}else if(E.pathSegType===2){o(m-2,3);F();break}}else if(u.pathSegType===2)if(m>0){u=h.getItem(m-1).pathSegType;if(u===2){o(m-1,1);F();break}else if(u===1&&h.numberOfItems-1===m){o(m,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){c.setMode("select");c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();
if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var h=z.getItem(0),m=null;D=[];D.push(["M",h.x,",",h.y," C"].join(""));for(var o=1;o<=F-4;o+=3){var u=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(m)if((h=svgedit.path.smoothControlPoints(m,u,h))&&h.length==2){u=D[D.length-1].split(",");u[2]=h[0].x;u[3]=h[0].y;D[D.length-1]=u.join(",");u=h[1]}D.push([u.x,
u.y,E.x,E.y,H.x,H.y].join(","));h=H;m=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var h={x:0,y:0};h[D]=z-F.item[D];F.move(h.x,h.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=
D.pathSegList,F=z.numberOfItems,h,m=0;m<F;++m){var o=z.getItem(m);if(o.pathSegType===2)h=o;if(o.pathSegType===1){o=z.getItem(m-1);if(o.x!=h.x||o.y!=h.y){z=D.createSVGPathSegLinetoAbs(h.x,h.y);svgedit.path.insertItemBefore(D,z,m);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,h=F.numberOfItems,m=0,o=0,u="",E=null,H=0;H<h;++H){var J=F.getItem(H),O=J.x||0,X=J.y||0,ba=J.x1||0,T=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,
qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});u+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:u+="z";break;case 12:O-=m;case 13:if(z){m+=O;qa="l"}else{O+=m;m=O;qa="L"}ua([[O,o]]);break;case 14:X-=o;case 15:if(z){o+=X;qa="l"}else{X+=o;o=X;qa="L"}ua([[m,X]]);break;case 2:case 4:case 18:O-=m;X-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){m=E[0];
o=E[1]}case 19:if(z){m+=O;o+=X}else{O+=m;X+=o;m=O;o=X}if(W===3)E=[m,o];ua([[O,X]]);break;case 6:O-=m;ba-=m;fa-=m;X-=o;T-=o;ha-=o;case 7:if(z){m+=O;o+=X}else{O+=m;ba+=m;fa+=m;X+=o;T+=o;ha+=o;m=O;o=X}ua([[ba,T],[fa,ha],[O,X]]);break;case 8:O-=m;ba-=m;X-=o;T-=o;case 9:if(z){m+=O;o+=X}else{O+=m;ba+=m;X+=o;T+=o;m=O;o=X}ua([[ba,T],[O,X]]);break;case 10:O-=m;X-=o;case 11:if(z){m+=O;o+=X}else{O+=m;X+=o;m=O;o=X}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,X]);break;case 16:O-=m;fa-=m;X-=
o;ha-=o;case 17:if(z){m+=O;o+=X}else{O+=m;fa+=m;X+=o;ha+=o;m=O;o=X}ua([[fa,ha],[O,X]])}}return u}}}(),yb=this.removeUnusedDefElems=function(){var e=n.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],l=0,C=["fill","stroke","filter","marker-start","marker-mid","marker-end"],A=C.length,G=n.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=G[z],h=0;h<A;h++)if(F){var m=ja(F.getAttribute(C[h]));m&&k.push(m.substr(1))}(F=ca(F))&&F.indexOf("#")===0&&k.push(F.substr(1))}e=
$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){C=e[z];A=C.id;if(k.indexOf(A)<0){sb[A]=C;C.parentNode.removeChild(C);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);La.clear(true);$.each(n.childNodes,function(l,C){l&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&n.insertBefore(C,n.firstChild)});if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(n).find("g:data(gsvg)").each(function(){for(var l=this.attributes,
C=l.length,A=0;A<C;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")C--;if(C<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var k=this.svgToString(n,0);e.length&&$(e).each(function(){tb(this)});return k};this.svgToString=function(e,k){var l=[],C=svgedit.utilities.toXml,A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,h=e.childNodes;for(F=0;F<k;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,
A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var m={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!m[O]&&ya[O]!=="xmlns"&&ya[O]!=="xml"){m[O]=true;l.push(" xmlns:"+ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){z=D.item(F);var o=C(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||
ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var u=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=0;F--){z=D.item(F);o=C(z.nodeValue);if(!(u.indexOf(z.localName)>=0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);
if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");k++;D=false;for(F=0;F<h.length;F++){A=h.item(F);switch(A.nodeType){case 1:l.push("\n");l.push(this.svgToString(h.item(F),k));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(C(A)+"")}break;case 4:l.push("\n");l.push(Array(k+
1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(k+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}k--;if(!D){l.push("\n");for(F=0;F<k;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+
encodeURIComponent(e);C=l.toDataURL().replace(";base64",C+";base64");Va[e]=C}catch(A){Va[e]=false}Ga=e;k&&k(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Ga=e};this.open=function(){};this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],k={feGaussianBlur:kb.exportNoBlur,foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(n);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=
kb.exportNoText;$.each(k,function(C,A){l.find(C).length&&e.push(A)});k=this.svgCanvasToString();M("exported",{svg:k,issues:e})};this.getSvgString=function(){$a.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 Hb=this.uniquifyElems=function(e){var k={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,
function(z){if(z.nodeType==1){if(z.id){z.id in k||(k[z.id]={elem:null,attrs:[],hrefs:[]});k[z.id].elem=z}$.each(vb,function(h,m){var o=z.getAttributeNode(m);if(o){var u=svgedit.utilities.getUrlFromAttr(o.value);if(u=u?u.substr(1):null){u in k||(k[u]={elem:null,attrs:[],hrefs:[]});k[u].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=0)if(F=F.substr(1)){F in k||(k[F]={elem:null,attrs:[],hrefs:[]});k[F].hrefs.push(z)}}});for(var C in k)if(C){var A=k[C].elem;if(A){e=
ka();A.id=e;A=k[C].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=k[C].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var l=ca(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Ib=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 l=$(n).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=Y(A).matrix;A=N(C.x1,C.y1,G);G=N(C.x2,C.y2,
G);C.x1=A.x;C.y1=A.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-l.x)/l.width,y1:(C.y1-l.y)/l.height,x2:(C.x2-l.x)/l.width,y2:(C.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Lb=this.convertToGroup=function(e){e||(e=I[0]);var k=$(e),l=new Da,C;if(k.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");C=R(e);var A=d.createSVGTransform();A.setTranslate(l.x,l.y);C.appendItem(A);Ra(e);M("selected",
[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");A=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}C+=" translate("+(A.x||0)+","+(A.y||0)+")";A=k.prev();l.addSubCommand(new Fa(k[0],k[0].nextSibling,k[0].parentNode));k.remove();G=$(n).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,z=0;z<D.length;z++)k.appendChild(D[z].cloneNode(true));if(svgedit.browser.isGecko()){D=$(gb()).children("linearGradient,radialGradient,pattern").clone();
$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Hb(k);svgedit.browser.isGecko()&&$(gb()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();A.after(k);if(C){if(!G){A=e.nextSibling;C.removeChild(e);l.addSubCommand(new Fa(e,A,C))}l.addSubCommand(new Ia(k))}Gb(k);svgedit.browser.isGecko()?Ib(gb()):Ib(k);svgedit.utilities.walkTreePost(k,function(F){try{Ra(F)}catch(h){console.log(h)}});$(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()});rb([k]);(e=Db(k,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);this.prepareSvg(k);var l=new Da("Change Source"),C=n.nextSibling,A=d.removeChild(n);l.addSubCommand(new Fa(A,C,d));n=f.adoptNode?f.adoptNode(k.documentElement):f.importNode(k.documentElement,true);d.appendChild(n);var G=$(n);c.current_drawing_=new svgedit.draw.Drawing(n,v);var D=B().getNonce();D?M("setnonce",D):M("unsetnonce");
G.find("image").each(function(){var J=this;Fb(J);var O=ca(this);if(O.indexOf("data:")===0){var X=O.match(/svgedit_url=(.*?);/);if(X){var ba=decodeURIComponent(X[1]);$(new Image).load(function(){J.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",ba)}).attr("src",ba)}}c.embedImage(O)});G.find("svg").each(function(){if(!$(this).closest("defs").length){Hb(this);var J=this.parentNode;if(J.childNodes.length===1&&J.nodeName==="g"){$(J).data("gsvg",this);J.id=J.id||ka()}else tb(this)}});G.find("linearGradient, radialGradient, pattern").appendTo(gb());
Gb(G);Ib(G[0]);svgedit.utilities.walkTreePost(n,function(J){try{Ra(J)}catch(O){console.log(O)}});var z={id:"svgcontent",overflow:p.show_outside_canvas?"visible":"hidden"},F=false;if(G.attr("viewBox")){var h=G.attr("viewBox").split(" ");z.width=h[2];z.height=h[3]}else $.each(["width","height"],function(J,O){var X=G.attr(O);X||(X="100%");if((X+"").substr(-1)==="%")F=true;else z[O]=Ba(O,X)});xb();G.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ka()});if(F){var m=getStrokedBBox();z.width=m.width+m.x;z.height=m.height+m.y}if(z.width<=0)z.width=200;if(z.height<=0)z.height=200;G.attr(z);this.contentW=z.width;this.contentH=z.height;$("#canvas_width").val(this.contentW);$("#canvas_height").val(this.contentH);var o=$("#canvas_background");if(o.length){var u=o.attr("fill-opacity");u=u?parseInt(u)*100:100;fill=this.getPaint(o.attr("fill"),u,"canvas")}else fill=this.getPaint("none",100,"canvas");methodDraw.paintBox.canvas.setPaint(fill);l.addSubCommand(new Ia(n));
var E=G.attr(["width","height"]);l.addSubCommand(new Ma(d,E));q=1;svgedit.transformlist.resetListMap();xa();svgedit.path.clearData();d.appendChild(ra.selectorParentGroup);wa(l);M("changed",[n])}catch(H){console.log(H);return false}return true};this.getPaint=function(e,k,l){var C=null;if(e.indexOf("url(#")===0){e=(e=svgCanvas.getRefElem(e))?e.cloneNode(true):$("#"+l+"_color defs *")[0];C={alpha:k};C[e.tagName]=e}else C=e.indexOf("#")===0?{alpha:k,solidColor:e.substr(1)}:{alpha:k,solidColor:"none"};
return new $.jGraduate.Paint(C)};this.importSvgString=function(e){try{var k=svgedit.utilities.encode64(e.length+e).substr(0,32),l=false;if(lb[k])if($(lb[k].symbol).parents("#svgroot").length)l=true;var C=new Da("Import SVG");if(l)var A=lb[k].symbol,G=lb[k].xform;else{var D=svgedit.utilities.text2xml(e);this.prepareSvg(D);var z;z=f.adoptNode?f.adoptNode(D.documentElement):f.importNode(D.documentElement,true);Hb(z);var F=Ba("width",z.getAttribute("width")),h=Ba("height",z.getAttribute("height")),m=
z.getAttribute("viewBox"),o=m?m.split(" "):[0,0,F,h];for(e=0;e<4;++e)o[e]=+o[e];n.getAttribute("width");var u=+n.getAttribute("height");G=h>F?"scale("+u/3/o[3]+")":"scale("+u/3/o[2]+")";G="translate(0) "+G+" translate(0)";A=f.createElementNS(b,"symbol");var E=gb();for(svgedit.browser.isGecko()&&$(z).find("linearGradient, radialGradient, pattern").appendTo(E);z.firstChild;)A.appendChild(z.firstChild);var H=z.attributes;for(z=0;z<H.length;z++){var J=H[z];A.setAttribute(J.nodeName,J.nodeValue)}A.id=
ka();lb[k]={symbol:A,xform:G};gb().appendChild(A);C.addSubCommand(new Ia(A))}var O=f.createElementNS(b,"use");O.id=ka();U(O,"#"+A.id);(L||B().getCurrentLayer()).appendChild(O);C.addSubCommand(new Ia(O));xa();O.setAttribute("transform",G);Ra(O);$(O).data("symbol",A).data("ref",A);qb([O]);wa(C);M("changed",[n])}catch(X){console.log(X);return false}return true};var xb=c.identifyLayers=function(){Eb();B().identifyLayers()};this.createLayer=function(e){var k=new Da("Create Layer");e=B().createLayer(e);
k.addSubCommand(new Ia(e));wa(k);xa();M("changed",[e])};this.cloneLayer=function(e){var k=new Da("Duplicate Layer"),l=f.createElementNS(b,"g"),C=f.createElementNS(b,"title");C.textContent=e;l.appendChild(C);C=B().getCurrentLayer();$(C).after(l);C=C.childNodes;for(var A=0;A<C.length;A++){var G=C[A];G.localName!="title"&&l.appendChild(ia(G))}xa();xb();k.addSubCommand(new Ia(l));wa(k);c.setCurrentLayer(e);M("changed",[l])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),k=e.nextSibling,
l=e.parentNode;if(e=B().deleteCurrentLayer()){var C=new Da("Delete Layer");C.addSubCommand(new Fa(e,k,l));wa(C);xa();M("changed",[l]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&xa();return e};this.renameCurrentLayer=function(e){var k=B();if(k.current_layer){var l=k.current_layer;if(!c.setCurrentLayer(e)){for(var C=new Da("Rename Layer"),A=0;A<k.getNumLayers();++A)if(k.all_layers[A][1]==l)break;var G=k.getLayerName(A);k.all_layers[A][0]=
svgedit.utilities.toXml(e);var D=l.childNodes.length;for(A=0;A<D;++A){var z=l.childNodes.item(A);if(z&&z.tagName=="title"){for(;z.firstChild;)z.removeChild(z.firstChild);z.textContent=e;C.addSubCommand(new Ma(z,{"#text":G}));wa(C);M("changed",[l]);return true}}}k.current_layer=l}return false};this.setCurrentLayerPosition=function(e){var k=B();if(k.current_layer&&e>=0&&e<k.getNumLayers()){for(var l=0;l<k.getNumLayers();++l)if(k.all_layers[l][1]==k.current_layer)break;if(l==k.getNumLayers())return false;
if(l!=e){var C=null,A=k.current_layer.nextSibling;if(e>l){if(e<k.getNumLayers()-1)C=k.all_layers[e+1][1]}else C=k.all_layers[e][1];n.insertBefore(k.current_layer,C);wa(new Ja(k.current_layer,A,n));xb();c.setCurrentLayer(k.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,k){var l=B(),C=l.getLayerVisibility(e),A=l.setLayerVisibility(e,k);if(A)wa(new Ma(A,{display:C?"inline":"none"},"Layer Visibility"));else return false;if(A==l.getCurrentLayer()){xa();La.clear()}return true};
this.moveSelectedToLayer=function(e){for(var k=null,l=B(),C=0;C<l.getNumLayers();++C)if(l.getLayerName(C)==e){k=l.all_layers[C][1];break}if(!k)return false;e=new Da("Move Elements to Layer");l=I;for(C=l.length;C--;){var A=l[C];if(A){var G=A.nextSibling,D=A.parentNode;k.appendChild(A);e.addSubCommand(new Ja(A,G,D))}}wa(e);return true};this.mergeLayer=function(e){var k=new Da("Merge Layer"),l=B(),C=$(l.current_layer).prev()[0];if(C){for(k.addSubCommand(new Fa(l.current_layer,l.current_layer.nextSibling,
n));l.current_layer.firstChild;){var A=l.current_layer.firstChild;if(A.localName=="title"){k.addSubCommand(new Fa(A,A.nextSibling,l.current_layer));l.current_layer.removeChild(A)}else{var G=A.nextSibling;C.appendChild(A);k.addSubCommand(new Ja(A,G,l.current_layer))}}n.removeChild(l.current_layer);if(!e){xa();xb();M("changed",[n]);wa(k)}l.current_layer=C;return k}};this.mergeAllLayers=function(){var e=new Da("Merge all Layers"),k=B();for(k.current_layer=k.all_layers[k.getNumLayers()-1][1];$(n).children("g").length>
1;)e.addSubCommand(c.mergeLayer(true));xa();xb();M("changed",[n]);wa(e)};var Eb=this.leaveContext=function(){var e=ta.length;if(e){for(var k=0;k<e;k++){var l=ta[k],C=cb(l,"orig_opac");C!==1?l.setAttribute("opacity",C):l.removeAttribute("opacity");l.setAttribute("style","pointer-events: inherit")}ta=[];xa(true);M("contextset",null)}L=null},Kb=this.setContext=function(e){Eb();if(typeof e==="string")e=pa(e);L=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var k=this.getAttribute("opacity")||
1;cb(this,"orig_opac",k);this.setAttribute("opacity",k*0.33);this.setAttribute("style","pointer-events: none");ta.push(this)});xa();M("contextset",L)};this.clear=function(){La.clear();xa();c.clearSvgContentElement();c.current_drawing_=new svgedit.draw.Drawing(n);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();ra.initGroup();sa=ra.getRubberBandBox();M("cleared")};this.linkControlPoints=La.linkControlPoints;this.getContentElem=function(){return n};this.getRootElem=function(){return d};this.getSelectedElems=
function(){return I};var zb=this.getResolution=function(){var e=n.getAttribute("width")/q,k=n.getAttribute("height")/q;return{w:e,h:k,zoom:q}};this.getZoom=function(){return q};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(kb,e.notification)};this.setConfig=function(e){$.extend(p,e)};this.getTitle=function(e){if(e=e||I[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var k=0;k<e.length;k++)if(e[k].nodeName=="title")return e[k].textContent;
return""}};this.setGroupTitle=function(e){var k=I[0];k=$(k).data("gsvg")||k;var l=$(k).children("title"),C=new Da("Set Label");if(e.length)if(l.length){l=l[0];C.addSubCommand(new Ma(l,{"#text":l.textContent}));l.textContent=e}else{l=f.createElementNS(b,"title");l.textContent=e;$(k).prepend(l);C.addSubCommand(new Ia(l))}else{C.addSubCommand(new Fa(l[0],l.nextSibling,k));l.remove()}wa(C)};this.getDocumentTitle=function(){return c.getTitle(n)};this.setDocumentTitle=function(e){for(var k=n.childNodes,
l=false,C="",A=new Da("Change Image Title"),G=0;G<k.length;G++)if(k[G].nodeName=="title"){l=k[G];C=l.textContent;break}if(!l){l=f.createElementNS(b,"title");n.insertBefore(l,n.firstChild)}if(e.length)l.textContent=e;else l.parentNode.removeChild(l);A.addSubCommand(new Ma(l,{"#text":C}));wa(A)};this.getEditorNS=function(e){e&&n.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,k){var l=zb(),C=l.w;l=l.h;var A;if(e=="fit"){var G=
getStrokedBBox();if(G){A=new Da("Fit Canvas to Content");var D=pb();qb(D);var z=[],F=[];$.each(D,function(){z.push(G.x*-1);F.push(G.y*-1)});D=c.moveSelectedElements(z,F,true);A.addSubCommand(D);xa();e=Math.round(G.width);k=Math.round(G.height)}else return false}if(e!=C||k!=l){D=d.suspendRedraw(1E3);A||(A=new Da("Change Image Dimensions"));e=Ba("width",e);k=Ba("height",k);n.setAttribute("width",e);n.setAttribute("height",k);this.contentW=e;this.contentH=k;A.addSubCommand(new Ma(n,{width:C,height:l}));
n.setAttribute("viewBox",[0,0,e/q,k/q].join(" "));A.addSubCommand(new Ma(n,{viewBox:["0 0",C,l].join(" ")}));wa(A);d.unsuspendRedraw(D);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",k+2)}M("changed",[n])}return[e,k]};this.getOffset=function(){return $(n).attr(["x","y"])};this.setBBoxZoom=function(e,k,l){var C=0.85,A=function(G){if(!G)return false;var D=
Math.min(Math.round(k/G.width*100*C)/100,Math.round(l/G.height*100*C)/100);c.setZoom(D);return{zoom:D,bbox:G}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:q*e.factor);return{zoom:q,bbox:e}}return A(e)}switch(e){case "selection":if(!I[0])return;e=$.map(I,function(G){if(G)return G});e=getStrokedBBox(e);break;case "canvas":e=zb();C=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(pb(B().getCurrentLayer()));
break;default:return}return A(e)};this.setZoom=function(e){var k=zb();n.setAttribute("viewBox","0 0 "+k.w/e+" "+k.h/e);q=e;$.each(I,function(l,C){C&&ra.requestSelector(C).resize()});La.zoomChange();ib("zoomChanged",e)};this.getMode=function(){return Ha};this.setMode=function(e){La.clear();bb.clear();$("#workarea").attr("class",e);Xa=I[0]&&I[0].nodeName=="text"?Ua:K;Ha=e};this.getColor=function(e){return Xa[e]};this.setColor=function(e,k,l){K[e]=k;Xa[e+"_paint"]={type:"solidColor"};for(var C=[],A=
I.length;A--;){var G=I[A];if(G)if(G.tagName=="g")svgedit.utilities.walkTree(G,function(D){D.nodeName!="g"&&C.push(D)});else if(e=="fill")G.tagName!="polyline"&&G.tagName!="line"&&C.push(G);else C.push(G)}if(C.length>0)if(l)Ab(e,k,C);else{Ya(e,k,C);M("changed",C)}};var gb=function(){var e=n.getElementsByTagNameNS(b,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(b,"defs");n.firstChild?n.insertBefore(e,n.firstChild.nextSibling):n.appendChild(e)}return e},Nb=this.setGradient=function(e){if(!(!Xa[e+
"_paint"]||Xa[e+"_paint"].type=="solidColor")){var k=c[e+"Grad"],l=Mb(k),C=gb();if(l)k=l;else{k=C.appendChild(f.importNode(k,true));k.id=ka()}c.setColor(e,"url(#"+k.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+k.id+")")}},Mb=function(e){var k=gb();k=$(k).find("linearGradient, radialGradient");for(var l=k.length,C=["r","cx","cy","fx","fy"];l--;){var A=k[l];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=A.getAttribute("x1")||e.getAttribute("y1")!=
@ -394,7 +394,7 @@ a(o).children().clone();if(o.length){o[0].removeAttribute("style");m.append(o)}}
event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});b.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};d=navigator.platform.indexOf("Mac")>=0;var n=navigator.userAgent.indexOf("AppleWebKit")>=0,v=d?"meta+":"ctrl+",B=g.pathActions,q=g.undoMgr,L=svgedit.utilities,Q=curConfig.imgPath+"placeholder.svg",K=a("#workarea"),I=a("#cmenu_canvas"),S=null,R=1,N="toolbars",
ga="";d||a(".shortcut").each(function(){var h=a(this).text();a(this).text(h.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var h=a("#dialog_box"),m=a("#dialog_buttons"),o=function(u,E,H,J){a("#dialog_content").html("<p>"+E.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",u=="prompt");m.empty();var O=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(m);u!="alert"&&a('<input type="button" value="'+
uiStrings.common.cancel+'">').appendTo(m).on("click touchstart",function(){h.hide();H(false)});if(u=="prompt"){var X=a('<input type="text">').prependTo(m);X.val(J||"");X.bind("keydown","return",function(){O.trigger("click touchstart")})}u=="process"&&O.hide();h.show();O.on("click touchstart",function(){h.hide();var ba=u=="prompt"?X.val():true;H&&H(ba)}).focus();u=="prompt"&&X.focus()};a.alert=function(u,E){o("alert",u,E)};a.confirm=function(u,E){o("confirm",u,E)};a.process_cancel=function(u,E){o("process",
u,E)};a.prompt=function(u,E,H){o("prompt",u,H,E)}})();var oa=function(){var h=a(".tool_button_current");if(h.length&&h[0].id!=="tool_select"){h.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},Y=null,V=false,ea=false,Ba="",ja=function(h,m){var o=g.getResolution(),u=K;a("#svgcanvas").position();if(u=g.setBBoxZoom(m,u.width()-15,u.height()-15)){var E=u.zoom;u=u.bbox;if(E<0.0010)wa({value:0.1});
u,E)};a.prompt=function(u,E,H){o("prompt",u,H,E)}})();var oa=function(){var h=a(".tool_button_current");if(h.length&&h[0].id!=="tool_select"){h.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},Y=null,V=false,ea=false,Ba="",ja=function(h,m){var o=g.getResolution(),u=K;a("#svgcanvas").position();if(u=g.setBBoxZoom(m,u.width()-15,u.height()-15)){var E=u.zoom;u=u.bbox;if(E<0.001)wa({value:0.1});
else{typeof animatedZoom!="undefined"&&h.cancelAnimationFrame(animatedZoom);var H=Date.now(),J=E-o.zoom;a("#zoom");var O=o.zoom,X=function(){var ba=(Date.now()-H)/500;ba=Math.pow(ba-1,3)+1;g.setZoom(O+J*ba);G();if(ba<1&&ba>-0.9)h.animatedZoom=requestAnimationFrame(X);else{a("#zoom").val(parseInt(E*100));a("option","#zoom_select").removeAttr("selected");a("option[value="+parseInt(E*100)+"]","#zoom_select").attr("selected","selected")}};X();g.getMode()=="zoom"&&u.width&&oa();xb()}}};a("#cur_context_panel").delegate("a",
"click",function(){var h=a(this);h.attr("data-root")?g.leaveContext():g.setContext(h.text());g.clearSelection();return false});var ca=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},U={},Z=function(h){a.each(h,function(m,o){var u=a(m).children(),E=m+"_show",H=a(E),J=false;u.addClass("tool_button").unbind("click mousedown mouseup").each(function(ba){var T=o[ba];U[T.sel]=T.fn;if(T.isDefault)J=ba;ba=function(fa){var ha=T;if(fa.type==="keydown"){var W=a(ha.parent+"_show").hasClass("tool_button_current"),
qa=a(ha.parent+"_show").attr("data-curopt");a.each(h[T.parent],function(Aa,Ca){if(Ca.sel==qa)ha=!fa.shiftKey||!W?Ca:h[T.parent][Aa+1]||h[T.parent][0]})}if(a(this).hasClass("disabled"))return false;ra(E)&&ha.fn();var ua=ha.icon?a.getSvgIcon(ha.icon,true):a(ha.sel).children().eq(0).clone();ua[0].setAttribute("width",H.width());ua[0].setAttribute("height",H.height());H.children(":not(.flyout_arrow_horiz)").remove();H.append(ua).attr("data-curopt",ha.sel)};a(this).mouseup(ba);T.key&&a(document).bind("keydown",
@ -429,7 +429,7 @@ icon:W.id,key:W.key,isDefault:W.includeWith?W.includeWith.isDefault:0},ub];Na="p
else Qa.bind(Cb,Jb)});Z(fa)});a.each(O,function(){vb(this.elem,this.list,this.callback,{seticon:true})});if(T)H=false;a.svgIcons(T,{w:27,h:27,id_match:false,no_img:!n,fallback:X,placement:ba,callback:function(){w.iconsize&&w.iconsize!="m"&&o();H=true;J()}})}J()});g.textActions.setInputElem(a("#text")[0]);var Ma='<div class="palette_item transparent" data-rgb="none"></div>\t\t\t\t\t\t\t\t<div class="palette_item black" data-rgb="#000000"></div>\t\t\t\t\t\t\t\t<div class="palette_item white" data-rgb="#ffffff"></div>';
["#444444","#482816","#422C10","#3B2F0E","#32320F","#293414","#1F361B","#153723","#0C372C","#083734","#0E353B","#1A333F","#273141","#332D40","#3E2A3C","#462735","#4B252D","#4D2425","#4C261D","#666666","#845335","#7B572D","#6F5C2A","#62612C","#546433","#46673D","#396849","#306856","#2D6862","#33666C","#426373","#535F75","#645A73","#74556D","#805064","#884D58","#8B4D4B","#894F3F","#999999","#C48157","#B8874D","#A98E49","#97944B","#849854","#729C62","#619E73","#559E84","#529D94","#5B9BA2","#6D97AB",
"#8391AE","#9A8AAB","#AF84A3","#BF7E96","#C97A86","#CE7975","#CC7C65","#BBBBBB","#FFB27C","#FABA6F","#E6C36A","#CFCA6D","#B8D078","#A0D58A","#8CD79F","#7DD8B5","#7AD6CA","#84D3DB","#9ACEE6","#B6C7EA","#D3BEE7","#EDB6DC","#FFAFCC","#FFAAB8","#FFA9A2","#FFAC8D","#DDDDDD","#FFE7A2","#FFF093","#FFFA8D","#FFFF91","#EEFF9F","#D1FFB4","#B9FFCE","#A8FFE9","#A4FFFF","#B1FFFF","#CBFFFF","#EDFFFF","#FFF5FF","#FFEBFF","#FFE2FF","#FFDCEC","#FFDBD2","#FFDFB8"].forEach(function(h){Ma+='<div class="palette_item" style="background-color: '+
h+';" data-rgb="'+h+'"></div>'});a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(h){h="rotate("+h+"deg)";Da.css({"-webkit-transform":h,"-moz-transform":h,"-o-transform":h,"-ms-transform":h,transform:h})};var wa=function(h){var m=h.value/100;if(m<0.0010)h.value=0.1;else{h=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/h,y:(o[0].scrollTop+o.height()/2)/h,zoom:m},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",
h+';" data-rgb="'+h+'"></div>'});a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(h){h="rotate("+h+"deg)";Da.css({"-webkit-transform":h,"-moz-transform":h,"-o-transform":h,"-ms-transform":h,transform:h})};var wa=function(h){var m=h.value/100;if(m<0.001)h.value=0.1;else{h=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/h,y:(o[0].scrollTop+o.height()/2)/h,zoom:m},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",
a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);window.opera&&a("<p/>").hide().appendTo("body").remove()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(h){var m=h.getAttribute("data-attr"),
o=h.getAttribute("data-multiplier")||1;o=parseFloat(o);o=h.value*o;if(!svgedit.units.isValidUnit(m,o,Y)){a.alert(uiStrings.notification.invalidAttrValGiven);h.value=Y.getAttribute(m);return false}g.changeSelectedAttributeNoUndo(m,o)};picking=false;a(document).on("mouseup",function(){picking=false});a("#palette").on("mousemove mousedown touchstart touchmove",".palette_item",function(h){h.preventDefault();if(h.type=="mousedown")picking=true;if(picking){var m=a("#tool_stroke").hasClass("active"),o=m?
"stroke":"fill",u=a(this).attr("data-rgb"),E=null,H=true;if(h.type=="mousedown")H=false;if(u==="transparent"||u==="initial"||u==="#none"){u="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:u.substr(1)});b.paintBox[o].setPaint(E);if(m){g.setColor("stroke",u,H);u!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",u,H);u!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}}).bind("contextmenu",function(h){h.preventDefault()});
@ -437,9 +437,9 @@ a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","tab
return true};(function(){var h=null,m=null,o=K[0],u=false,E=false;a("#svgcanvas").on("mousemove mouseup touchend",function(H){if(u!==false){o.scrollLeft-=H.clientX-h;o.scrollTop-=H.clientY-m;h=H.clientX;m=H.clientY;if(H.type==="mouseup"||H.type==="touchend")u=false;return false}}).on("mousedown touchmove",function(H){if(H.button===1||E===true||H.originalEvent.touches&&H.originalEvent.touches.length>=2){u=true;h=H.clientX;m=H.clientY;return false}});a(window).mouseup(function(){u=false});a(document).bind("keydown",
"space",function(H){H.preventDefault();g.spaceKey=E=true}).bind("keyup","space",function(H){H.preventDefault();g.spaceKey=E=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&K.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&K.removeClass("out")})})();var va=a(".menu"),kb=function(h){h.target.style.background="#fff";setTimeout(function(){h.target.style.background="#ddd"},50);setTimeout(function(){h.target.style.background="#fff"},150);setTimeout(function(){h.target.style.background=
"#ddd"},200);setTimeout(function(){h.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(h){kb(h)});a("svg, body").on("mousedown touchstart",function(h){if(!(h.target.nodeName&&h.target.nodeName.toLowerCase()==="input"))if(!a(h.target).hasClass("menu_title")&&!a(h.target).parent().hasClass("menu_title"))!a(h.target).hasClass("disabled")&&a(h.target).hasClass("menu_item")?kb(h):a("#menu_bar").removeClass("active")});
a("#workarea").on("mousewheel",function(h,m,o,u){if(h.altKey){h.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+u*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(h,m,o){if(a(h).length!=0){var u=a(h).find("button"),E=a(h).find("ul").attr("id",
a(h)[0].id+"-list");o||a("#option_lists").append(E);var H=false;o&&a(h).addClass("dropup");E.find("li").bind("mouseup",m);a(window).mouseup(function(){if(!H){u.removeClass("down");E.hide()}H=false});u.bind("mousedown",function(){if(u.hasClass("down")){u.removeClass("down");E.hide()}else{u.addClass("down");if(!o){var J=a(h).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(h,m,o,u){var E=a(h);m=a(m);var H=false,
J=u.dropUp;J&&a(h).addClass("dropup");m.find("li").bind("mouseup",function(){if(u.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");m.hide();m.css({top:0,left:0})}H=false});m.height();a(h).bind("mousedown",function(){var O=a(h).offset();if(J){O.top-=m.height();O.left+=8}else O.top+=a(h).height();a(m).offset(O);if(E.hasClass("down")){E.removeClass("down");
a("#workarea").on("mousewheel",function(h,m,o,u){if(h.altKey||h.ctrlKey){h.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+u*(h.altKey?10:5))).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(h,m,o){if(a(h).length!=0){var u=a(h).find("button"),
E=a(h).find("ul").attr("id",a(h)[0].id+"-list");o||a("#option_lists").append(E);var H=false;o&&a(h).addClass("dropup");E.find("li").bind("mouseup",m);a(window).mouseup(function(){if(!H){u.removeClass("down");E.hide()}H=false});u.bind("mousedown",function(){if(u.hasClass("down")){u.removeClass("down");E.hide()}else{u.addClass("down");if(!o){var J=a(h).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(h,m,o,u){var E=
a(h);m=a(m);var H=false,J=u.dropUp;J&&a(h).addClass("dropup");m.find("li").bind("mouseup",function(){if(u.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");m.hide();m.css({top:0,left:0})}H=false});m.height();a(h).bind("mousedown",function(){var O=a(h).offset();if(J){O.top-=m.height();O.left+=8}else O.top+=a(h).height();a(m).offset(O);if(E.hasClass("down")){E.removeClass("down");
m.hide();m.css({top:0,left:0})}else{E.addClass("down");m.show();H=true;return false}}).hover(function(){H=true}).mouseout(function(){H=false});u.multiclick&&m.mousedown(function(){H=true})};a("#font_family_dropdown").change(function(){var h=this.options[this.selectedIndex].value,m=this.options[this.selectedIndex].text;a("#preview_font").html(m).css("font-family",h);a("#font_family").val(h).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var h=this.id.replace("tool_pos",
"").charAt(0);g.alignSelectedElements(h,"page")})});(function(){var h,m=function(){a(h).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){h=this;N="toolbars";K.mousedown(m)}).blur(function(){N="canvas";K.unbind("mousedown",m);g.getMode()=="textedit"&&a("#text").focus()})})();var cb=function(){ra("#tool_select")&&g.setMode("select")},Ta=function(){ra("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){ra("#tool_line")&&g.setMode("line")},Ga=function(){ra("#tool_rect")&&
g.setMode("rect")},ta=function(){ra("#tool_ellipse")&&g.setMode("ellipse")},$a=function(){ra("#tool_image")&&g.setMode("image")},Ka=function(){ra("#tool_zoom")&&g.setMode("zoom")},Sa=function(){if(ra("#tool_zoom")){yb();oa()}},Ha=function(){ra("#tool_text")&&g.setMode("text")},db=function(){ra("#tool_path")&&g.setMode("path")},lb=function(){if(Y!=null||V)g.deleteSelectedElements();B.getNodePoint()&&B.deletePathNode()},Ua=function(){if(Y!=null||V){xa(a("#edit_menu"));g.cutSelectedElements()}},Xa=function(){if(Y!=

View File

@ -16,8 +16,7 @@
// 2) browser.js
// 3) svgcanvas.js
(function() {
(function() {
document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true);
@ -1914,12 +1913,13 @@
var accumulatedDelta = 0
$('#workarea').on('mousewheel', function(e, delta, deltaX, deltaY){
if (e.altKey) {
if (e.altKey || e.ctrlKey) {
e.preventDefault();
zoom = parseInt($("#zoom").val())
$("#zoom").val(parseInt(zoom + deltaY*10)).change()
$("#zoom").val(parseInt(zoom + deltaY*(e.altKey ? 10 : 5))).change()
}
})
});
$('.menu_title')
.on('mousedown', function() {
$("#tools_shapelib").hide()

View File

@ -2368,13 +2368,14 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
{
if (canvas.spaceKey) return;
var right_click = evt.button === 2;
root_sctm = $('#svgcontent g')[0].getScreenCTM().inverse();
isBotchedZoom = svgedit.browser.isGecko();
root_sctm = svgcontent.querySelector("g").getScreenCTM().inverse();
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ),
mouse_x = pt.x * current_zoom,
mouse_y = pt.y * current_zoom;
evt.preventDefault();
if(right_click) {
@ -2724,7 +2725,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// in this function we do not record any state changes yet (but we do update
// any elements that are still being created, moved or resized on the canvas)
var mouseMove = function(evt) {
if (evt.originalEvent.touches && evt.originalEvent.touches.length > 1) return;
if (evt.originalEvent.touches && evt.originalEvent.touches.length > 1) return;
if (!started) return;
if(evt.button === 1 || canvas.spaceKey) return;
var selected = selectedElements[0],
@ -3273,10 +3274,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
recalculateAllSelectedDimensions();
// if it was being dragged/resized
var isBotchedZoom = svgedit.browser.isGecko();
console.log(current_zoom)
r_start_x = isBotchedZoom ? r_start_x * current_zoom : r_start_x;
r_start_y = isBotchedZoom ? r_start_y * current_zoom : r_start_y;
r_start_x = r_start_x;
r_start_y = r_start_y;
var difference_x = Math.abs(real_x-r_start_x);
var difference_y = Math.abs(real_y-r_start_y);

View File

@ -2193,7 +2193,7 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
}
#workarea.fhpath {
cursor: url(../images/pencil_cursor.png) 0 20, crosshair;
cursor: url(../images/pencil_cursor.png) 0 16, crosshair;
}
#workarea.rotate * {