diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 17e0846..73bbe92 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1544,6 +1544,7 @@ $('#font_family').val(font_family); $('#font_size').val(elem.getAttribute("font-size")); $('#text').val(elem.textContent); + $('#preview_font').text(font_family.split(",")[0]).css('font-family', font_family); if (svgCanvas.addedNew) { // Timeout needed for IE9 setTimeout(function() { diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index e328e0c..c7bdaa0 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2374,10 +2374,10 @@ var getMouseTarget = this.getMouseTarget = function(evt) { var right_click = evt.button === 2; root_sctm = svgcontent.getScreenCTM().inverse(); - + isBotchedZoom = svgedit.browser.isGecko(); var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ), - mouse_x = pt.x * current_zoom, - mouse_y = pt.y * current_zoom; + mouse_x = pt.x * (isBotchedZoom ? 1 : current_zoom), + mouse_y = pt.y * (isBotchedZoom ? 1 : current_zoom); evt.preventDefault(); @@ -2733,8 +2733,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) { if(evt.button === 1 || canvas.spaceKey) return; var selected = selectedElements[0], pt = transformPoint( evt.pageX, evt.pageY, root_sctm ), - mouse_x = pt.x * current_zoom, - mouse_y = pt.y * current_zoom, + mouse_x = pt.x * (isBotchedZoom ? 1 : current_zoom), + mouse_y = pt.y * (isBotchedZoom ? 1 : current_zoom), shape = getElem(getId()); var real_x = x = mouse_x / current_zoom; diff --git a/editor/svgedit.compiled.js b/editor/svgedit.compiled.js index c89ba37..9369ce1 100644 --- a/editor/svgedit.compiled.js +++ b/editor/svgedit.compiled.js @@ -242,62 +242,62 @@ A.points=Array(F);for(I=0;I1&&w.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3- (A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z= -null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type"); -if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=V(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(v.button===1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY, -rb),E=I.x*o;I=I.y*o;var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k0&&b.removeFromSelection(G); -L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra= -P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition",J);break;case "zoom":L*=o;k*=o;ma(ua, -{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(v.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=D=Math.max(L, -D);C=hm?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+k+" ";G.setAttributeNS(null, -"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L=svgedit.utilities.getBBox(F); -D=L.x+L.width/2;C=L.y+L.height/2;G=X(F);G=O(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove",{event:v,mouse_x:E, -mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones);if(v.button!==2){var F= -Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity=E.getAttribute("stroke-opacity"); -bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(E=0;E=0?F.indexOf(",", -G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"ellipse",curStyles:true, -attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u= -false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&&E.id!="svgcanvas"&& -E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=N.opacity){C=$(false).clone().attr({to:N.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",N.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},v*1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll", -function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value==="";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!== -I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d", -"")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}} -function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(aa.x,aa.y,C); -aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F= -S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&YD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea= -"select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F); -C=Y?X(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]= -I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display", -"inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E= -false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems; -G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=R({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:N.opacity/ -2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<= -1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"), -G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A- -1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]}, -svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ua.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D,{x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}}, -mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!="none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<= -2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea= -"path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);M("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove(); -$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=V(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,E=0;E0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ja.toSelectMode(svgedit.path.path.elem); -b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E,L,I))&&I.length== -2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;E=k}for(A.push("L");G1)){var F=v.button===2;rb=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var I=O(v.pageX,v.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G== +Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type");if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=V(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(v.button=== +1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k0&&b.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/ +U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition", +J);break;case "zoom":L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(v.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea== +"square"||v.shiftKey){L=D=Math.max(L,D);C=hm?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+ +k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L= +svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=X(F);G=O(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove", +{event:v,mouse_x:E,mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones); +if(v.button!==2){var F=Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity= +E.getAttribute("stroke-opacity");bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(E=0;E=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"ellipse", +curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v); +break;case "textedit":u=false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&& +E.id!="svgcanvas"&&E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=N.opacity){C=$(false).clone().attr({to:N.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",N.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},v* +1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value=== +"";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x, +y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+ +Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x= +ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(aa.x,aa.y,C);aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L, +k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&YD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa= +w(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S= +F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);C=Y?X(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length; +for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5", +fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o, +I,v);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E=false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a, +Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr= +"M"+I+","+v+" ";w=R({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:N.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v): +svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<=1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I= +w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k* +o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A-1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E= +svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ua.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D, +{x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!= +"none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<=2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&& +svgedit.path.recalcRotatedPath();if(v){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea="path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null; +this.clear();vb([A],true);M("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=V(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems, +E=0;E0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<= +1){Ja.toSelectMode(svgedit.path.path.elem);b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E, +L,I))&&I.length==2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;E=k}for(A.push("L");G0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e= @@ -407,7 +407,7 @@ var aa,ga;if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){a a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);yb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(u){P=a("#seg_type");if(D){u.x=svgedit.units.convertUnit(u.x);u.y=svgedit.units.convertUnit(u.y)}a("#path_node_x").val(Math.round(u.x));a("#path_node_y").val(Math.round(u.y));u.type?P.val(u.type).removeAttr("disabled"):P.val(4).attr("disabled","disabled")}return}D=null;if(ra==="a"){D=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show(); D=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!D);D&&a("#link_url").val(D);D={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var ra=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();ra=="path"&&a("#path_panel").show();if(D[ra]){D=D[ra];a("#"+ra+"_panel").show();ra=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide(); a.each(D,function(Oa,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!=="px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Ta=document.getElementById(ra+"_"+Ba);Ta.value=Math.round(ha)||0;Ta.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Ta)});if(ra=="text"){D=k.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active", -g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show(); +g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);a("#preview_font").text(D.split(",")[0]).css("font-family",D);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show(); a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(u); V.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,u){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";X=u.length==1||u[1]==null?u[0]:null;sa=u.length>=2&&u[1]!=null?u:false;if(X!=null)if(!C){if(X!=null)switch(X.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=X.getElementsByTagName("*"),U=0,S=P.length;U1&&w.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3- (A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z= -null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type"); -if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=V(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(v.button===1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY, -rb),E=I.x*o;I=I.y*o;var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k0&&b.removeFromSelection(G); -L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra= -P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition",J);break;case "zoom":L*=o;k*=o;ma(ua, -{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(v.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=D=Math.max(L, -D);C=hm?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+k+" ";G.setAttributeNS(null, -"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L=svgedit.utilities.getBBox(F); -D=L.x+L.width/2;C=L.y+L.height/2;G=X(F);G=O(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove",{event:v,mouse_x:E, -mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones);if(v.button!==2){var F= -Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity=E.getAttribute("stroke-opacity"); -bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(E=0;E=0?F.indexOf(",", -G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"ellipse",curStyles:true, -attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u= -false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&&E.id!="svgcanvas"&& -E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=N.opacity){C=$(false).clone().attr({to:N.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",N.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},v*1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll", -function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value==="";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!== -I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d", -"")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}} -function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(aa.x,aa.y,C); -aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F= -S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&YD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea= -"select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F); -C=Y?X(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]= -I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display", -"inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E= -false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems; -G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=R({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:N.opacity/ -2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<= -1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"), -G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A- -1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]}, -svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ua.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D,{x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}}, -mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!="none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<= -2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea= -"path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);M("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove(); -$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=V(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,E=0;E0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ja.toSelectMode(svgedit.path.path.elem); -b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E,L,I))&&I.length== -2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;E=k}for(A.push("L");G1)){var F=v.button===2;rb=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var I=O(v.pageX,v.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G== +Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type");if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=V(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(v.button=== +1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k0&&b.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/ +U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition", +J);break;case "zoom":L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(v.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea== +"square"||v.shiftKey){L=D=Math.max(L,D);C=hm?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+ +k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L= +svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=X(F);G=O(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove", +{event:v,mouse_x:E,mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones); +if(v.button!==2){var F=Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity= +E.getAttribute("stroke-opacity");bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(E=0;E=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"ellipse", +curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=R({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v); +break;case "textedit":u=false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&& +E.id!="svgcanvas"&&E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=N.opacity){C=$(false).clone().attr({to:N.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",N.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},v* +1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value=== +"";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x, +y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+ +Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x= +ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(aa.x,aa.y,C);aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L, +k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&YD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa= +w(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S= +F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);C=Y?X(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length; +for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5", +fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o, +I,v);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E=false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a, +Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr= +"M"+I+","+v+" ";w=R({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:N.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v): +svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<=1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I= +w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k* +o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A-1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E= +svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ua.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D, +{x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!= +"none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<=2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&& +svgedit.path.recalcRotatedPath();if(v){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea="path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null; +this.clear();vb([A],true);M("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=V(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems, +E=0;E0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<= +1){Ja.toSelectMode(svgedit.path.path.elem);b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E, +L,I))&&I.length==2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;E=k}for(A.push("L");G0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e= @@ -407,7 +407,7 @@ var aa,ga;if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){a a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);yb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(u){P=a("#seg_type");if(D){u.x=svgedit.units.convertUnit(u.x);u.y=svgedit.units.convertUnit(u.y)}a("#path_node_x").val(Math.round(u.x));a("#path_node_y").val(Math.round(u.y));u.type?P.val(u.type).removeAttr("disabled"):P.val(4).attr("disabled","disabled")}return}D=null;if(ra==="a"){D=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show(); D=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!D);D&&a("#link_url").val(D);D={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var ra=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();ra=="path"&&a("#path_panel").show();if(D[ra]){D=D[ra];a("#"+ra+"_panel").show();ra=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide(); a.each(D,function(Oa,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!=="px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Ta=document.getElementById(ra+"_"+Ba);Ta.value=Math.round(ha)||0;Ta.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Ta)});if(ra=="text"){D=k.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active", -g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show(); +g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);a("#preview_font").text(D.split(",")[0]).css("font-family",D);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show(); a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(u); V.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,u){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";X=u.length==1||u[1]==null?u[0]:null;sa=u.length>=2&&u[1]!=null?u:false;if(X!=null)if(!C){if(X!=null)switch(X.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=X.getElementsByTagName("*"),U=0,S=P.length;U