From 83b5981524f5f0b0405746f5298f15683c05f64b Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Fri, 5 Dec 2014 10:53:34 -0600 Subject: [PATCH] Fix canvas size infinite loop (issue 24) --- editor/.DS_Store | Bin 21508 -> 15364 bytes editor/method-draw.compiled.js | 146 ++++++++++++++-------------- editor/src/method-draw.js | 6 +- method-draw/method-draw.compiled.js | 146 ++++++++++++++-------------- method-draw/src/method-draw.js | 6 +- 5 files changed, 152 insertions(+), 152 deletions(-) diff --git a/editor/.DS_Store b/editor/.DS_Store index c887e8d71a086fee01a47b23bd8cc840344a1578..c939b84d42c8c9eb81686d560e3bc95c4747fe44 100644 GIT binary patch delta 48 ucmZo!!PrtU!JkofW58~CM*ht_3RSF|_o+%SO`a#7xtU#~9+_wGmm2_=0)m=o=c.convertToPath(h,true);else if(h.tagName=="rect"){var u=h.getAttribute("rx"),E=h.getAttribute("ry");if(u||E)m=o=c.convertToPath(h,true)}if(!o){var H=h.cloneNode(true),J=document.createElementNS(b, -"g"),O=h.parentNode;O.appendChild(J);J.appendChild(H);m=svgedit.utilities.bboxToObj(J.getBBox());O.removeChild(J)}}return m}catch(W){console.log(h,W)}},l;$.each(e,function(){if(!l)if(this.parentNode)l=k(this)});if(l==null)return null;var C=l.x+l.width,A=l.y+l.height,G=l.x,D=l.y,z=function(h){var m=h.getAttribute("stroke-width"),o=0;if(h.getAttribute("stroke")!="none"&&!isNaN(m))o+=m/2;return o},F=[];$.each(e,function(h,m){var o=k(m);if(o){var u=z(m);G=Math.min(G,o.x-u);D=Math.min(D,o.y-u);F.push(o)}}); +"g"),O=h.parentNode;O.appendChild(J);J.appendChild(H);m=svgedit.utilities.bboxToObj(J.getBBox());O.removeChild(J)}}return m}catch(X){console.log(h,X)}},l;$.each(e,function(){if(!l)if(this.parentNode)l=k(this)});if(l==null)return null;var C=l.x+l.width,A=l.y+l.height,G=l.x,D=l.y,z=function(h){var m=h.getAttribute("stroke-width"),o=0;if(h.getAttribute("stroke")!="none"&&!isNaN(m))o+=m/2;return o},F=[];$.each(e,function(h,m){var o=k(m);if(o){var u=z(m);G=Math.min(G,o.x-u);D=Math.min(D,o.y-u);F.push(o)}}); l.x=G;l.y=D;$.each(e,function(h,m){var o=F[h];if(o&&m.nodeType==1){var u=z(m);C=Math.max(C,o.x+o.width+u);A=Math.max(A,o.y+o.height+u)}});l.width=C-G;l.height=A-D;return l};var pb=this.getVisibleElements=function(e){e||(e=$(n).children());e.find("#canvas_background").length&&e.splice(0,1);var k=[];$(e).children().each(function(l,C){try{C.getBBox()&&k.push(C)}catch(A){}});return k.reverse()},fb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(n).children());var k=[];$(e).children().each(function(l, C){try{C.getBBox()&&k.push({elem:C,bbox:getStrokedBBox([C])})}catch(A){}});return k.reverse()},tb=this.groupSvgElem=function(e){var k=document.createElementNS(b,"g");e.parentNode.replaceChild(k,e);$(k).append(e).data("gsvg",e)[0].id=ka()},ia=function(e){var k=document.createElementNS(e.namespaceURI,e.nodeName);k.removeAttribute("id");$.each(e.attributes,function(C,A){A.localName!="-moz-math-font-style"&&k.setAttributeNS(A.namespaceURI,A.nodeName,A.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName== "path"){var l=La.convertPath(e);k.setAttribute("d",l)}$.each(e.childNodes,function(C,A){switch(A.nodeType){case 1:k.appendChild(ia(A));break;case 3:k.textContent=A.nodeValue}});if($(e).data("gsvg"))$(k).data("gsvg",k.firstChild);else if($(e).data("symbol")){e=$(e).data("symbol");$(k).data("ref",e).data("symbol",e)}else k.tagName=="image"&&Fb(k);k.id=ka();return k},aa,ka,M;(function(e){var k={};aa=e.getId=function(){return B().getId()};ka=e.getNextId=function(){return B().getNextId()};M=e.call=function(l, @@ -227,15 +227,15 @@ null)return null;var k=R(e);if(k&&k.numberOfItems>0){for(var l=k.numberOfItems;l A[0][0]));k.removeItem(A[0][1]);k.removeItem(A[1][1]);k.insertItemBefore(l,A[1][1])}l=k.numberOfItems;if(l>=2&&k.getItem(l-2).type===1&&k.getItem(l-1).type===2){A=d.createSVGTransform();C=ga(k.getItem(l-2).matrix,k.getItem(l-1).matrix);A.setMatrix(C);k.removeItem(l-2);k.removeItem(l-2);k.appendItem(A)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(k.numberOfItems===1&&k.getItem(0).type===1||k.numberOfItems===2&&k.getItem(0).type===1&&k.getItem(0).type=== 4)return null}var G=$(e).data("gsvg");l=new Da("Transform");var D={},z=null;C=[];switch(e.tagName){case "line":C=["x1","y1","x2","y2"];break;case "circle":C=["cx","cy","r"];break;case "ellipse":C=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":C=["width","height","x","y"];break;case "use":case "text":case "tspan":C=["x","y"];break;case "polygon":case "polyline":z={};z.points=e.getAttribute("points");A=e.points;var F=A.numberOfItems;D.points=Array(F);for(var h=0;h1.0E-10?Math.sin(h)/(1-Math.cos(h)):2/h;for(h=0;h=3&&k.getItem(E-2).type==3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;var J=k.getItem(E-3).matrix,O=k.getItem(E-2).matrix,W=k.getItem(E-1).matrix;F=e.childNodes;for(m=F.length;m--;){var ba=F.item(m);C=G=0;if(ba.nodeType== -1){var T=R(ba);if(T){C=Y(T).matrix;G=na(ba);var fa=Sa,ha=[];Sa=ba.getAttribute("transform");if(G||oa(T)){var X=d.createSVGTransform();X.setMatrix(ga(J,O,W,C));T.clear();T.appendItem(X);ha.push(X)}else{G=ga(C.inverse(),W,C);X=d.createSVGMatrix();X.e=-G.e;X.f=-G.f;C=ga(X.inverse(),C.inverse(),J,O,W,C,G.inverse());var qa=d.createSVGTransform(),ua=d.createSVGTransform(),Aa=d.createSVGTransform();qa.setTranslate(G.e,G.f);ua.setScale(C.a,C.d);Aa.setTranslate(X.e,X.f);T.appendItem(Aa);T.appendItem(ua);T.appendItem(qa); -ha.push(Aa);ha.push(ua);ha.push(qa)}l.addSubCommand(Ra(ba));Sa=fa}}}k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E>=3&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;X=d.createSVGTransform();X.setMatrix(C);k.clear();k.appendItem(X)}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;G=Y(k).matrix;k.removeItem(0);C=Y(k).matrix.inverse();C=ga(C,G);G=C.e;C=C.f;if(G!=0||C!=0){F=e.childNodes;m=F.length;for(E=[];m--;){ba=F.item(m);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){fa= -ba.getAttribute("clip-path");if(E.indexOf(fa)===-1){nb(fa,G,C);E.push(fa)}}fa=Sa;Sa=ba.getAttribute("transform");if(T=R(ba)){J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);l.addSubCommand(Ra(ba));T=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(J=T.length;J--;){O=T.item(J);if(ba==ca(O)){W=d.createSVGTransform();W.setTranslate(-G,-C);R(O).insertItemBefore(W,0);l.addSubCommand(Ra(O))}}Sa=fa}}}E=[];Sa=fa}}else if(E==1&&k.getItem(0).type==1&&!A){h= +if(A=na(e)){h=A*Math.PI/180;F=Math.abs(h)>1.0E-10?Math.sin(h)/(1-Math.cos(h)):2/h;for(h=0;h=3&&k.getItem(E-2).type==3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;var J=k.getItem(E-3).matrix,O=k.getItem(E-2).matrix,X=k.getItem(E-1).matrix;F=e.childNodes;for(m=F.length;m--;){var ba=F.item(m);C=G=0;if(ba.nodeType== +1){var T=R(ba);if(T){C=Y(T).matrix;G=na(ba);var fa=Sa,ha=[];Sa=ba.getAttribute("transform");if(G||oa(T)){var W=d.createSVGTransform();W.setMatrix(ga(J,O,X,C));T.clear();T.appendItem(W);ha.push(W)}else{G=ga(C.inverse(),X,C);W=d.createSVGMatrix();W.e=-G.e;W.f=-G.f;C=ga(W.inverse(),C.inverse(),J,O,X,C,G.inverse());var qa=d.createSVGTransform(),ua=d.createSVGTransform(),Aa=d.createSVGTransform();qa.setTranslate(G.e,G.f);ua.setScale(C.a,C.d);Aa.setTranslate(W.e,W.f);T.appendItem(Aa);T.appendItem(ua);T.appendItem(qa); +ha.push(Aa);ha.push(ua);ha.push(qa)}l.addSubCommand(Ra(ba));Sa=fa}}}k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E>=3&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;W=d.createSVGTransform();W.setMatrix(C);k.clear();k.appendItem(W)}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;G=Y(k).matrix;k.removeItem(0);C=Y(k).matrix.inverse();C=ga(C,G);G=C.e;C=C.f;if(G!=0||C!=0){F=e.childNodes;m=F.length;for(E=[];m--;){ba=F.item(m);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){fa= +ba.getAttribute("clip-path");if(E.indexOf(fa)===-1){nb(fa,G,C);E.push(fa)}}fa=Sa;Sa=ba.getAttribute("transform");if(T=R(ba)){J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);l.addSubCommand(Ra(ba));T=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(J=T.length;J--;){O=T.item(J);if(ba==ca(O)){X=d.createSVGTransform();X.setTranslate(-G,-C);R(O).insertItemBefore(X,0);l.addSubCommand(Ra(O))}}Sa=fa}}}E=[];Sa=fa}}else if(E==1&&k.getItem(0).type==1&&!A){h= 1;C=k.getItem(0).matrix;F=e.childNodes;for(m=F.length;m--;){ba=F.item(m);if(ba.nodeType==1){fa=Sa;Sa=ba.getAttribute("transform");if(T=R(ba)){G=ga(C,Y(T).matrix);E=d.createSVGTransform();E.setMatrix(G);T.clear();T.appendItem(E,0);l.addSubCommand(Ra(ba));Sa=fa;fa=ba.getAttribute("stroke-width");ba.getAttribute("stroke")!=="none"&&!isNaN(fa)&&ba.setAttribute("stroke-width",fa*((Math.abs(G.a)+Math.abs(G.d))/2))}}}k.clear()}else{if(A){o=d.createSVGTransform();o.setRotate(A,u.x,u.y);k.numberOfItems?k.insertItemBefore(o, 0):k.appendItem(o)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(h==2){if(A){u={x:o.x+H.e,y:o.y+H.f};o=d.createSVGTransform();o.setRotate(A,u.x,u.y);k.numberOfItems?k.insertItemBefore(o,0):k.appendItem(o)}}else if(h==3){C=Y(k).matrix;H=d.createSVGTransform();H.setRotate(A,o.x,o.y);H=H.matrix;o=d.createSVGTransform();o.setRotate(A,u.x,u.y);u=o.matrix.inverse();fa=C.inverse();u=ga(fa,u,H,C);G=u.e;C=u.f;if(G!=0||C!=0){F=e.childNodes;for(m=F.length;m--;){ba=F.item(m);if(ba.nodeType== 1){fa=Sa;Sa=ba.getAttribute("transform");T=R(ba);J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);l.addSubCommand(Ra(ba));Sa=fa}}}if(A)k.numberOfItems?k.insertItemBefore(o,0):k.appendItem(o)}}else{A=svgedit.utilities.getBBox(e);if(!A&&e.tagName!="path")return null;C=d.createSVGMatrix();if(G=na(e)){o={x:A.x+A.width/2,y:A.y+A.height/2};u=N(A.x+A.width/2,A.y+A.height/2,Y(k).matrix);h=G*Math.PI/180;F=Math.abs(h)>1.0E-10?Math.sin(h)/(1-Math.cos(h)):2/ h;for(h=0;h=3&&k.getItem(E-2).type== -3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;C=Y(k,E-3,E-1).matrix;k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E==4&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;X=d.createSVGTransform();X.setMatrix(C);k.clear();k.appendItem(X);C=d.createSVGMatrix()}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;H=k.getItem(0).matrix;fa=Y(k,1).matrix;A=fa.inverse();C=ga(A,H,fa);k.removeItem(0)}else if(E==1&&k.getItem(0).type==1&&!G){C=Y(k).matrix;switch(e.tagName){case "line":D= +3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;C=Y(k,E-3,E-1).matrix;k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E==4&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;W=d.createSVGTransform();W.setMatrix(C);k.clear();k.appendItem(W);C=d.createSVGMatrix()}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;H=k.getItem(0).matrix;fa=Y(k,1).matrix;A=fa.inverse();C=ga(A,H,fa);k.removeItem(0)}else if(E==1&&k.getItem(0).type==1&&!G){C=Y(k).matrix;switch(e.tagName){case "line":D= $(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":D.points=e.getAttribute("points");if(D.points){A=e.points;F=A.numberOfItems;D.points=Array(F);for(h=0;h1&&A.showGrips(false)}}}M("selected",I);k||I.length==1?ra.requestSelector(I[0]).showGrips(true): @@ -243,38 +243,38 @@ ra.requestSelector(I[0]).showGrips(false);for(I.sort(function(G,D){if(G&&D&&G.co 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 -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;O0&&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(W=na(F)){var fa=Math.sqrt(u*u+H*H);H=Math.atan2(H,u)-W*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,X=T?(T+H)/T:1,qa=ba?(ba+u)/ba:1;if(db.indexOf("n")>=0){X=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=X;else X=qa;H.setScale(qa,X);ba.setTranslate(E+fa,O+ha);if(J){J=W?1:0;o.replaceItem(u,2+J);o.replaceItem(H,1+J);o.replaceItem(ba,0+J)}else{J=o.numberOfItems; +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;O0&&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=kl?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;W=(Math.atan2(E-y,J-x)*(180/Math.PI)-90)%360;W+=compensation_angle;if(p.gridSnapping)W= -va(W);if(z.shiftKey)W=Math.round(W/45)*45;c.setRotationAngle(W<-180?360+W:W,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|| +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;m1||m>1){z=I.length;for(m=0;m=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(W,ba){if(ba){H=ba.keep||H;E=ba.element;Ka=ba.started||Ka}});if(!H&& +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 X=m.getAttribute("display")==="none";m.setAttribute("display",X?"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 X=E[fa];m.setAttribute("visibility","hidden");fa=G(T.x,H.y);ha=G(T.x+(X.x-T.x),H.y);var qa=G(T.x,H.y+H.height);T=G(T.x+(X.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 X=E[ha];T>X.x+X.width/2&&ha++;return ha}function C(T, -fa,ha){var X=h.selectionStart;T=l(T,fa);k(Math.min(X,T),Math.max(X,T),!ha)}function A(T,fa){var ha={x:T,y:fa};ha.x/=q;ha.y/=q;if(J){var X=N(ha.x,ha.y,J.inverse());ha.x=X.x;ha.y=X.y}return ha}function G(T,fa){var ha={x:T,y:fa};if(J){var X=N(ha.x,ha.y,J);ha.x=X.x;ha.y=X.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,X=ha.substr(0,fa).replace(/[a-z0-9]+$/i, -"").length;ha=ha.substr(fa).match(/^[a-z0-9]+/i);k(X,(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,W,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,X){T=A(ha,X);h.focus();e(l(T.x,T.y));O=ha;W=X},mouseMove:function(T,fa){var ha=A(T,fa);C(ha.x,ha.y)},mouseUp:function(T,fa,ha){var X=A(fa,ha);C(X.x,X.y,true);T.target!==F&&faO-2&&ha< -W+2&&ha>W-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=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&&faO-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=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< @@ -282,9 +282,9 @@ if(F>=J-u&&F<=J+u&&z>=H-u&&z<=H+u){E=true;break}}u=aa();svgedit.path.removePath_ 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,W){return Math.sqrt(Math.pow(O.x-W.x,2)+Math.pow(O.y-W.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- +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,W=F/q;H=h?D+(D-O):H;h=h?u+(u-W):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- +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")]: @@ -292,7 +292,7 @@ svgedit.path.path.moveCtrl(o,m):svgedit.path.path.movePts(o,m)}else{svgedit.path "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=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");o0;);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;AF?"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=0&&e=0){var z=getStrokedBBox([D]);c.moveSelectedElements((e==="x"?k-z.x:0)*q,(e==="y"?k-z.y:0)*q,true)}else{z=e==="#text"?D.textContent:D.getAttribute(e);if(z==null)z="";if(z!==String(k)){if(e=="#text"){svgedit.utilities.getBBox(D);D.textContent=k}else e=="#href"?U(D,k):D.setAttribute(e,k);I.indexOf(D)>=0&&setTimeout(function(){D.parentNode&& ra.requestSelector(D).resize()},0);z=na(D);if(z!=0&&e!="transform")for(var F=R(D),h=F.numberOfItems;h--;)if(F.getItem(h).type==4){F.removeItem(h);var m=svgedit.utilities.getBBox(D),o=N(m.x+m.width/2,m.y+m.height/2,Y(F).matrix);m=o.x;o=o.y;var u=d.createSVGTransform();u.setRotate(z,m,o);F.insertItemBefore(u,h);break}}}}}d.unsuspendRedraw(C)},Ya=this.changeSelectedAttribute=function(e,k,l){l=l||I;c.undoMgr.beginUndoableChange(e,l);Ab(e,k,l);e=c.undoMgr.finishUndoableChange();e.isEmpty()||wa(e)};this.deleteSelectedElements= function(){for(var e=new Da("Delete Elements"),k=I.length,l=[],C=0;C1)l=arguments[1];break;default:e="g";k="Group Elements"}k=new Da(k);var C=S({element:e,attr:{id:ka()}});e==="a"&&U(C,l);k.addSubCommand(new Ia(C));for(l=I.length;l--;){var A=I[l];if(A!=null){if(A.parentNode.tagName==="a"&&A.parentNode.childNodes.length===1)A=A.parentNode;var G=A.nextSibling,D=A.parentNode;C.appendChild(A); k.addSubCommand(new Ja(A,G,D))}}k.isEmpty()||wa(k);rb([C],true)};var Db=this.pushGroupProperties=function(e,k){var l=e.childNodes,C=l.length,A=e.getAttribute("transform"),G=R(e),D=Y(G).matrix,z=new Da("Push group properties"),F=0,h=na(e),m=$(e).attr(["filter","opacity"]),o,u;for(F=0;F=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("

"+E.replace(/\n/g,"

")+"

").toggleClass("prompt",u=="prompt");m.empty();var O=a('').appendTo(m);u!="alert"&&a('').appendTo(m).on("click touchstart",function(){h.hide();H(false)});if(u=="prompt"){var W=a('').prependTo(m);W.val(J||"");W.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"?W.val():true;H&&H(ba)}).focus();u=="prompt"&&W.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", +uiStrings.common.cancel+'">').appendTo(m).on("click touchstart",function(){h.hide();H(false)});if(u=="prompt"){var X=a('').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}); -else{typeof animatedZoom!="undefined"&&h.cancelAnimationFrame(animatedZoom);var H=Date.now(),J=E-o.zoom;a("#zoom");var O=o.zoom,W=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(W);else{a("#zoom").val(parseInt(E*100));a("option","#zoom_select").removeAttr("selected");a("option[value="+parseInt(E*100)+"]","#zoom_select").attr("selected","selected")}};W();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 X=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||!X?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", -T.key[0]+" shift+"+T.key[0],ba)});if(J)H.attr("data-curopt",o[J].sel);else H.attr("data-curopt")||H.attr("data-curopt",o[0].sel);var O,W=a(E).position();a(m).css({left:W.left+34,top:W.top+77});H.mousedown(function(ba){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&ra(E,false);if(H.hasClass("disabled"))return false;var T=a(m),fa=W.left+34,ha=T.width()*-1,X=T.data("shown_popop")?200:0;O=setTimeout(function(){H.data("isLibrary")?T.css("left", -fa).show():T.css("left",ha).show().animate({left:fa},50);T.data("shown_popop",true)},X);ba.preventDefault()}).mouseup(function(){clearTimeout(O);var ba=a(this).attr("data-curopt");if(H.data("isLibrary")&&a(E.replace("_show","")).is(":visible"))ra(E,true);else ra(E)&&ba in U&&U[ba]()})});ma()},na=function(h,m){return a("
",{"class":"tools_flyout",id:h}).appendTo("#svg_editor").append(m)},pa=function(){a(".tools_flyout").each(function(){var h=a("#"+this.id+"_show"),m=h.offset();h=h.outerWidth(); +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", +T.key[0]+" shift+"+T.key[0],ba)});if(J)H.attr("data-curopt",o[J].sel);else H.attr("data-curopt")||H.attr("data-curopt",o[0].sel);var O,X=a(E).position();a(m).css({left:X.left+34,top:X.top+77});H.mousedown(function(ba){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&ra(E,false);if(H.hasClass("disabled"))return false;var T=a(m),fa=X.left+34,ha=T.width()*-1,W=T.data("shown_popop")?200:0;O=setTimeout(function(){H.data("isLibrary")?T.css("left", +fa).show():T.css("left",ha).show().animate({left:fa},50);T.data("shown_popop",true)},W);ba.preventDefault()}).mouseup(function(){clearTimeout(O);var ba=a(this).attr("data-curopt");if(H.data("isLibrary")&&a(E.replace("_show","")).is(":visible"))ra(E,true);else ra(E)&&ba in U&&U[ba]()})});ma()},na=function(h,m){return a("
",{"class":"tools_flyout",id:h}).appendTo("#svg_editor").append(m)},pa=function(){a(".tools_flyout").each(function(){var h=a("#"+this.id+"_show"),m=h.offset();h=h.outerWidth(); a(this).css({left:(m.left+h)*R,top:m.top})})},ma=function(){a(".tools_flyout").each(function(){var h=a("#"+this.id+"_show");if(!h.data("isLibrary")){var m=[];a(this).children().each(function(){m.push(this.title)});h[0].title=m.join(" / ")}})},la,ya=function(h,m,o){var u=null;if(h.indexOf("url(#")===0){h=(h=g.getRefElem(h))?h.cloneNode(true):a("#"+o+"_color defs *")[0];u={alpha:m};u[h.tagName]=h}else u=h.indexOf("#")===0?{alpha:m,solidColor:h.substr(1)}:{alpha:m,solidColor:"none"};return new a.jGraduate.Paint(u)}, za=g.getResolution();if(curConfig.baseUnit!=="px"){za.w=svgedit.units.convertUnit(za.w)+curConfig.baseUnit;za.h=svgedit.units.convertUnit(za.h)+curConfig.baseUnit}var Ja=function(h){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:za.w+2,height:za.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:h||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};document.getElementById("canvas_background")|| Ja();document.getElementById("canvas_background").getAttribute("fill");var Ia=b.setImageURL=function(h){h||(h=Q);g.setImageURL(h);a("#image_url").val(h)},Fa=function(){var h=Y;if(h!=null&&!h.parentNode)h=null;if(V&&V[0]!=null&&!V[0].parentNode)V=false;var m=g.getCurrentDrawing().getCurrentLayerName(),o=g.getMode(),u=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,E=o=="pathedit";if(E){a(".context_panel").hide();a("#path_node_panel").show();a("#stroke_panel").hide();m=B.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button"); a("#tool_node_delete").toggleClass("disabled",!B.canDeleteNodes);zb("#tool_openclose_path",B.closed_subpath?"open_path":"close_path");if(m){E=a("#seg_type");if(u){m.x=svgedit.units.convertUnit(m.x);m.y=svgedit.units.convertUnit(m.y)}a("#path_node_x").val(Math.round(m.x));a("#path_node_y").val(Math.round(m.y));if(m.type){E.val(m.type).removeAttr("disabled");a("#seg_type_label").html(m.type==4?"Straight":"Curve")}else E.val(4).attr("disabled","disabled")}a("#tools_top").removeClass("multiselected"); a("#stroke_panel").hide();a("#canvas_panel").hide()}else{var H=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");if(V){V=V.filter(Boolean);(h=g.elementsAreSame(V)?V[0]:null)&&a("#tools_top").addClass("multiselected")}if(!h&&!V){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(h!=null){a("#stroke_panel").show();var J=h.nodeName,O=g.getRotationAngle(h); -a("#angle").val(Math.round(O));O=g.getBlur(h);a("#blur").val(O);if(!E&&o!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var W,ba;if(["g","polyline","path"].indexOf(J)>=0)if(o=g.getStrokedBBox([h])){W=o.x;ba=o.y}if(u){W=svgedit.units.convertUnit(W);ba=svgedit.units.convertUnit(ba)}a("#"+J+"_x").val(Math.round(W));a("#"+J+"_y").val(Math.round(ba));if(J==="polyline"){a("#path_x").val(Math.round(W));a("#path_y").val(Math.round(ba))}["image","text","path","g","use"].indexOf(J)== +a("#angle").val(Math.round(O));O=g.getBlur(h);a("#blur").val(O);if(!E&&o!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var X,ba;if(["g","polyline","path"].indexOf(J)>=0)if(o=g.getStrokedBBox([h])){X=o.x;ba=o.y}if(u){X=svgedit.units.convertUnit(X);ba=svgedit.units.convertUnit(ba)}a("#"+J+"_x").val(Math.round(X));a("#"+J+"_y").val(Math.round(ba));if(J==="polyline"){a("#path_x").val(Math.round(X));a("#path_y").val(Math.round(ba))}["image","text","path","g","use"].indexOf(J)== -1&&a(".action_path_convert_selected").removeClass("disabled");J==="path"&&a(".action_path_selected").removeClass("disabled")}u=null;if(T==="a"){u=g.getHref(h);a("#g_panel").show()}if(h.parentNode.tagName==="a")if(!a(h).siblings().length){a("#a_panel").show();u=g.getHref(h.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!u);u&&a("#link_url").val(u);u={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 T=h.tagName;a(h).data("gsvg")&&a("#g_panel").show();if(T=="path"||T=="polyline")a("#path_panel").show();if(u[T]){u=u[T];a("#"+T+"_panel").show();T=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(u,function(fa,ha){var X=h.getAttribute(ha);if(curConfig.baseUnit!=="px"&&h[ha])X=svgedit.units.convertUnit(h[ha].baseVal.value);var qa=document.getElementById(T+"_"+ha);qa.value=Math.round(X)||0;qa.getAttribute("data-cursor")=== +"y1","x2","y2"],text:["x","y"],use:[],path:[]};var T=h.tagName;a(h).data("gsvg")&&a("#g_panel").show();if(T=="path"||T=="polyline")a("#path_panel").show();if(u[T]){u=u[T];a("#"+T+"_panel").show();T=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(u,function(fa,ha){var W=h.getAttribute(ha);if(curConfig.baseUnit!=="px"&&h[ha])W=svgedit.units.convertUnit(h[ha].baseVal.value);var qa=document.getElementById(T+"_"+ha);qa.value=Math.round(W)||0;qa.getAttribute("data-cursor")=== "true"&&a.fn.dragInput.updateCursor(qa)});if(T=="text"){u=h.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(u);a("#font_size").val(h.getAttribute("font-size"));a("#text").val(h.textContent);a("#preview_font").text(u.split(",")[0].replace(/'/g,"")).css("font-family",u);g.addedNew&&setTimeout(function(){a("#text").focus().select()}, 100)}else if(T=="image")Ia(g.getHref(h));else if(T==="g"||T==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}H[(T==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");H[(T==="g"||!V?"dis":"en")+"ableContextMenuItems"]("#group")}if(V){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");H.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}h||H.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back"); q.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");q.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(h&&!E||V){a("#selLayerNames").removeAttr("disabled").val(m);I.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(h,m){var o=g.getMode();o==="select"&& @@ -418,15 +418,15 @@ if(u){V=m.length>=2&&m[1]!=null?m:null;if(!V)switch(o){case "rotate":o=g.getRota {elems:m})});g.bind("saved",function(h,m){b.show_save_warning=false;m='\n'+m;var o=navigator.userAgent;if(~o.indexOf("MSIE"))Eb(0,true);else{var u=h.open("data:image/svg+xml;base64,"+L.encode64(m)),E=a.pref("save_notice_done");if(E!=="all"){var H=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(o.indexOf("Gecko/")!==-1)if(m.indexOf("",{id:"export_canvas"}).hide().appendTo("body");var u=a("#export_canvas")[0];u.width=g.contentW;u.height=g.contentH;canvg(u,m.svg,{renderCallback:function(){var E=u.toDataURL("image/png");S.location.href=E;if(a.pref("export_notice_done")!=="all"){E=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(o.length)E+="\n\n"+uiStrings.notification.noteTheseIssues+ "\n \u2022 "+o.join("\n \u2022 ");a.pref("export_notice_done","all");S.alert(E)}}})});g.bind("zoomed",ja);g.bind("contextset",function(h,m){var o="";if(m){var u="";o=''+g.getCurrentDrawing().getCurrentLayerName()+"";a(m).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){u+=" > "+this.id;o+=this!==m?' > '+this.id+"":" > "+this.id}});Ba=u}else Ba=null;a("#cur_context_panel").toggle(!!m).html(o)});g.bind("extension_added",function(h,m){function o(){if(la){clearTimeout(la); -la=null}E||(la=setTimeout(function(){E=true;Mb(w.iconsize)},50))}var u=false,E=false,H=true,J=function(){if(m.callback&&!u&&H){u=true;m.callback()}},O=[];m.context_tools&&a.each(m.context_tools,function(ha,X){var qa=X.container_id?' id="'+X.container_id+'"':"",ua=a("#"+X.panel);ua.length||(ua=a("
",{id:X.panel}).appendTo("#tools_top").hide());switch(X.type){case "tool_button":var Aa='
'+X.id+"
",Ca=a(Aa).appendTo(ua);X.events&&a.each(X.events,function(Na,jb){a(Ca).bind(Na, -jb)});break;case "select":Aa="";var Pa=a(Aa).appendTo(ua).find("select");a.each(X.events,function(Na,jb){a(Pa).bind(Na,jb)});break;case "button-select":Aa='';qa=a('
    ').appendTo("#option_lists"); -X.colnum&&qa.addClass("optcols"+X.colnum);a(Aa).appendTo(ua).children();O.push({elem:"#"+X.id,list:"#"+X.id+"_opts",title:X.title,callback:X.events.change,cur:"#cur_"+X.id});break;case "input":Aa="'+X.label+':';var Qa=a(Aa).appendTo(ua).find("input");X.spindata&&Qa.SpinButton(X.spindata);X.events&&a.each(X.events,function(Na,jb){Qa.bind(Na, -jb)})}});if(m.buttons){var W={},ba={},T=m.svgicons,fa={};a.each(m.buttons,function(ha,X){for(var qa,ua=X.id,Aa=ha;a("#"+ua).length;)ua=X.id+"_"+ ++Aa;if(T){W[ua]=X.icon;Aa=X.svgicon?X.svgicon:X.id;if(X.type=="app_menu")ba["#"+ua+" > div"]=Aa;else ba["#"+ua]=Aa}else qa=X.type=="menu"?"":a('');var Ca,Pa;switch(X.type){case "mode_flyout":case "mode":Ca="tool_button";if(X.cls)Ca+=" "+X.cls;Pa="#tools_left";break;case "context":Ca="tool_button";Pa="#"+X.panel;a(Pa).length||a("
    ", -{id:X.panel}).appendTo("#tools_top");break;case "menu":Ca="menu_item tool_button";Pa="#"+(X.after||X.panel);break;case "app_menu":Ca="";Pa=X.parent||"#main_menu ul";a(Pa).length||a("
    ",{id:X.panel}).appendTo("#tools_top")}var Qa=a(X.list||X.type=="app_menu"?"
  • ":"
    ").attr("id",ua).attr("title",X.title).addClass(Ca);if(!X.includeWith&&!X.list){if("position"in X)a(Pa).children().eq(X.position).before(Qa);else X.type!="menu"||!X.after?Qa.appendTo(Pa):a(Pa).after(Qa);if(X.type=="mode_flyout"){Aa= -a(Qa);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){var Na=Aa[0].id.replace("tool_","tools_"),jb=Aa.clone().attr("id",Na+"_show").append(a("
    ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa);Ca.data("isLibrary",true);jb.data("isLibrary",true)}ba["#"+Na+"_show"]=X.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:X.events.click,icon:X.id,isDefault:true},ub]}else if(X.type=="app_menu"||X.type=="menu")Qa.append(X.title)}else if(X.list){Qa.addClass("push_button");a("#"+X.list+"_opts").append(Qa); -if(X.isDefault){a("#cur_"+X.list).append(Qa.children().clone());Aa=X.svgicon?X.svgicon:X.id;ba["#cur_"+X.list]=Aa}}else if(X.includeWith){Pa=X.includeWith;Aa=a(Pa.button);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){Na=Aa[0].id.replace("tool_","tools_");jb=Aa.clone().attr("id",Na+"_show").append(a("
    ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa)}var ub=C.getButtonData(Pa.button);if(Pa.isDefault)ba["#"+Na+"_show"]=X.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:X.events.click, -icon:X.id,key:X.key,isDefault:X.includeWith?X.includeWith.isDefault:0},ub];Na="position"in Pa?Pa.position:"last";ub=Ca.children().length;if(!isNaN(Na)&&Na>=0&&Na",{id:W.panel}).appendTo("#tools_top").hide());switch(W.type){case "tool_button":var Aa='
    '+W.id+"
    ",Ca=a(Aa).appendTo(ua);W.events&&a.each(W.events,function(Na,jb){a(Ca).bind(Na, +jb)});break;case "select":Aa="";var Pa=a(Aa).appendTo(ua).find("select");a.each(W.events,function(Na,jb){a(Pa).bind(Na,jb)});break;case "button-select":Aa='';qa=a('
      ').appendTo("#option_lists"); +W.colnum&&qa.addClass("optcols"+W.colnum);a(Aa).appendTo(ua).children();O.push({elem:"#"+W.id,list:"#"+W.id+"_opts",title:W.title,callback:W.events.change,cur:"#cur_"+W.id});break;case "input":Aa="'+W.label+':';var Qa=a(Aa).appendTo(ua).find("input");W.spindata&&Qa.SpinButton(W.spindata);W.events&&a.each(W.events,function(Na,jb){Qa.bind(Na, +jb)})}});if(m.buttons){var X={},ba={},T=m.svgicons,fa={};a.each(m.buttons,function(ha,W){for(var qa,ua=W.id,Aa=ha;a("#"+ua).length;)ua=W.id+"_"+ ++Aa;if(T){X[ua]=W.icon;Aa=W.svgicon?W.svgicon:W.id;if(W.type=="app_menu")ba["#"+ua+" > div"]=Aa;else ba["#"+ua]=Aa}else qa=W.type=="menu"?"":a('');var Ca,Pa;switch(W.type){case "mode_flyout":case "mode":Ca="tool_button";if(W.cls)Ca+=" "+W.cls;Pa="#tools_left";break;case "context":Ca="tool_button";Pa="#"+W.panel;a(Pa).length||a("
      ", +{id:W.panel}).appendTo("#tools_top");break;case "menu":Ca="menu_item tool_button";Pa="#"+(W.after||W.panel);break;case "app_menu":Ca="";Pa=W.parent||"#main_menu ul";a(Pa).length||a("
      ",{id:W.panel}).appendTo("#tools_top")}var Qa=a(W.list||W.type=="app_menu"?"
    • ":"
      ").attr("id",ua).attr("title",W.title).addClass(Ca);if(!W.includeWith&&!W.list){if("position"in W)a(Pa).children().eq(W.position).before(Qa);else W.type!="menu"||!W.after?Qa.appendTo(Pa):a(Pa).after(Qa);if(W.type=="mode_flyout"){Aa= +a(Qa);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){var Na=Aa[0].id.replace("tool_","tools_"),jb=Aa.clone().attr("id",Na+"_show").append(a("
      ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa);Ca.data("isLibrary",true);jb.data("isLibrary",true)}ba["#"+Na+"_show"]=W.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:W.events.click,icon:W.id,isDefault:true},ub]}else if(W.type=="app_menu"||W.type=="menu")Qa.append(W.title)}else if(W.list){Qa.addClass("push_button");a("#"+W.list+"_opts").append(Qa); +if(W.isDefault){a("#cur_"+W.list).append(Qa.children().clone());Aa=W.svgicon?W.svgicon:W.id;ba["#cur_"+W.list]=Aa}}else if(W.includeWith){Pa=W.includeWith;Aa=a(Pa.button);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){Na=Aa[0].id.replace("tool_","tools_");jb=Aa.clone().attr("id",Na+"_show").append(a("
      ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa)}var ub=C.getButtonData(Pa.button);if(Pa.isDefault)ba["#"+Na+"_show"]=W.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:W.events.click, +icon:W.id,key:W.key,isDefault:W.includeWith?W.includeWith.isDefault:0},ub];Na="position"in Pa?Pa.position:"last";ub=Ca.children().length;if(!isNaN(Na)&&Na>=0&&Na
      '});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", @@ -454,23 +454,23 @@ a("#tool_fill").toggleClass("active");var m=document.querySelector("#tool_fill r h},Ib=function(){window.self!=window.top&&top.exit_fullscreen()},Lb=function(){xa(a("#view_menu"));if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},xb=function(){if(!k){var h="#workarea.wireframe #svgcontent * { stroke-width: "+ 1/g.getZoom()+"px; }";a("#wireframe_rules").text(K.hasClass("wireframe")?h:"")}},Eb=function(h,m){if(!ea){xa(a("#view_menu"));ea=true;a("#save_output_btns").toggle(!!m);a("#tool_source_back").toggle(!m);var o=ga=g.getSvgString();a("#svg_source_textarea").val(o);a("#svg_source_editor").fadeIn();a("#svg_source_textarea").focus().select()}},Kb=function(){if(ea){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();Ya();yb();ca()}else a.confirm(uiStrings.notification.QerrorsRevertToSource, function(h){if(!h)return false;g.clearSelection();Ya();yb();ca()});oa()}},zb=b.setIcon=function(h,m){var o=typeof m==="string"?a.getSvgIcon(m,true):m.clone();o?a(h).find("img").replaceWith(o):console.log("NOTE: Icon image missing: "+m)},gb;gb=function(){var h=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,m=document.getElementsByTagName("script")[0],o;for(o in m.style)if(h.test(o))return o.match(h)[0];if("WebkitOpacity"in m.style)return"Webkit";if("KhtmlOpacity"in m.style)return"Khtml";return""}();var Nb= -function(h,m){gb.toLowerCase();var o=["top","left","bottom","right"];h.each(function(){for(var u=a(this),E=u.outerWidth()*(m-1),H=u.outerHeight()*(m-1),J=0;J<4;J++){var O=o[J],W=u.data("orig_margin-"+O);if(W==null){W=parseInt(u.css("margin-"+O));u.data("orig_margin-"+O,W)}W=W*m;if(O==="right")W+=E;else if(O==="bottom")W+=H;u.css("margin-"+O,W)}})},Mb=b.setIconSize=function(h,m){if(!(h==w.size&&!m)){var o=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"), -u=1;u=typeof h=="number"?h:{s:0.75,m:1,l:1.25,xl:1.5}[h];b.tool_scale=R=u;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,u);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();else o=a('').appendTo("head");if(h!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(W,ba){if(typeof ba==="number")var T=ba*u+"px";else if(ba[h]||ba.all)T= -ba[h]||ba.all;H+=W+":"+T+";"});H+="}"});E="-"+gb.toLowerCase()+"-";H+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+E+"transform: scale("+u+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/u+");}";o.text(H)}pa()}},Ab=function(){a("#dialog_box").hide(); +function(h,m){gb.toLowerCase();var o=["top","left","bottom","right"];h.each(function(){for(var u=a(this),E=u.outerWidth()*(m-1),H=u.outerHeight()*(m-1),J=0;J<4;J++){var O=o[J],X=u.data("orig_margin-"+O);if(X==null){X=parseInt(u.css("margin-"+O));u.data("orig_margin-"+O,X)}X=X*m;if(O==="right")X+=E;else if(O==="bottom")X+=H;u.css("margin-"+O,X)}})},Mb=b.setIconSize=function(h,m){if(!(h==w.size&&!m)){var o=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"), +u=1;u=typeof h=="number"?h:{s:0.75,m:1,l:1.25,xl:1.5}[h];b.tool_scale=R=u;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,u);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();else o=a('').appendTo("head");if(h!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(X,ba){if(typeof ba==="number")var T=ba*u+"px";else if(ba[h]||ba.all)T= +ba[h]||ba.all;H+=X+":"+T+";"});H+="}"});E="-"+gb.toLowerCase()+"-";H+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+E+"transform: scale("+u+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/u+");}";o.text(H)}pa()}},Ab=function(){a("#dialog_box").hide(); if(ea){if(ea)ga!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(h){h&&Ya()}):Ya();Db()}else Ba&&g.leaveContext()},Ya=function(){a("#svg_source_editor").hide();ea=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var Db=a.noop;a(window).resize(function(){G()});(function(){K.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=K[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=K[0].scrollTop})})(); a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var h=g.getHref(Y);h=h.indexOf("data:")===0?"":h;a.prompt(uiStrings.notification.enterNewImgURL,h,function(m){m&&Ia(m)})});var e=function(h){var m=h[0].id=="stroke_color"?"stroke":"fill",o=h[0].id=="canvas_color";if(o)m="canvas";var u=b.paintBox[m].paint;h=m=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";o=o?{right:175,top:50}:{left:50,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker", containment:"window"}).removeAttr("style").css(o).jGraduate({paint:u,window:{pickerTitle:h},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){u=new a.jGraduate.Paint(E);b.paintBox[m].setPaint(u);g.setPaint(m,u);a("#color_picker").hide()},function(){a("#color_picker").hide()})};d=function(h,m){var o=document.getElementById("canvas_background"),u={color:"fff",opacity:1};if(m=="stroke")u=curConfig.initStroke;if(m=="fill")u=curConfig.initFill;if(m=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))u= {color:("0"+parseInt(o[1],10).toString(16)).slice(-2)+("0"+parseInt(o[2],10).toString(16)).slice(-2)+("0"+parseInt(o[3],10).toString(16)).slice(-2),opacity:1};o=(new DOMParser).parseFromString('\t\t\t\t\t',"text/xml").documentElement;o=a(h)[0].appendChild(document.importNode(o,true));m==="canvas"?o.setAttribute("width",60.5): -o.setAttribute("width","100%");this.rect=o.firstChild;this.defs=o.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:u.color});this.type=m;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,W=E.alpha/100;switch(O){case "solidColor":J=E[O]=="none"||E[O]=="one"?"none":"#"+E[O];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(E[O]);J="url(#"+(this.grad.id="gradbox_"+ -this.type)+")"}this.rect.setAttribute("fill",J);this.rect.setAttribute("opacity",W);if(this.type=="canvas")if(O=document.getElementById("canvas_background")){za=g.getResolution();O.setAttribute("x",-1);O.setAttribute("y",-1);O.setAttribute("width",za.w+2);O.setAttribute("height",za.h+2);J.indexOf("url")==-1&&O.setAttribute("fill",J)}else Ja(J);if(H){g.setColor(this.type,J,true);g.setPaintOpacity(this.type,W,true)}};this.update=function(E){if(Y){var H=this.type;switch(Y.tagName){case "use":case "image":case "foreignObject":return; -case "g":case "a":for(var J=null,O=Y.getElementsByTagName("*"),W=0,ba=O.length;W=1){W=g.getResolution();a("#canvas_width").val(W.w.toFixed());a("#canvas_height").val(W.h.toFixed());a("#resolution_label").html("
      "+W.w+"\u00d7
      "+W.h+"
      ")}else requestAnimationFrame(O)};O(Date.now())}else{a("#resolution_label").html("Custom");h.removeAttribute("readonly");h.focus();h.select();if(h.value=="fit"){h.value=100;m.value=100}}});a("#zoom").change(function(){wa(this)}); +if(!g.setResolution(o,u)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();h.val(o.w);m.val(o.h);return false}G()};a("#resolution").change(function(){var h=a("#canvas_width")[0],m=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){h.value="fit";m.value="fit";l();var o=g.getResolution();h.value=o.w;m.value=o.h}else{var u=this.value.split("x");u[0]=parseInt(u[0]);u[1]=parseInt(u[1]);var E=u[0]-h.value,H=u[1]-m.value,J=Date.now(),O=function(){var X=(Date.now()- +J)/1E3;X=Math.pow(X-1,3)+1;h.value=(u[0]-E+X*E).toFixed(0);m.value=(u[1]-H+X*H).toFixed(0);l();if(X>=1){X=g.getResolution();a("#canvas_width").val(X.w.toFixed());a("#canvas_height").val(X.h.toFixed());a("#resolution_label").html("
      "+X.w+"\u00d7
      "+X.h+"
      ")}else requestAnimationFrame(O)};O()}else{a("#resolution_label").html("Custom");h.removeAttribute("readonly");h.focus();h.select();if(h.value=="fit"){h.value=100;m.value=100}}});a("#zoom").change(function(){wa(this)}); a("input,select").attr("autocomplete","off");var C=function(){var h=[{sel:"#tool_select",fn:cb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Ta,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Va,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ga,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ta,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:db,evt:"click",key:["P",true]},{sel:"#tool_text",fn:Ha,evt:"click",key:["T",true]},{sel:"#tool_image",fn:$a,evt:"mouseup"}, {sel:"#tool_zoom",fn:Ka,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Oa,evt:"mouseup",key:[v+"N",true]},{sel:"#tool_save",fn:function(){if(ea)Kb();else{xa(a("#file_menu"));g.save({images:w.img_save,round_digits:6})}},evt:"mouseup",key:[v+"S",true]},{sel:"#tool_export",fn:nb,evt:"mouseup"},{sel:"#tool_open",fn:Ra,evt:"mouseup"},{sel:"#tool_import",fn:mb,evt:"mouseup"},{sel:"#tool_source",fn:Eb,evt:"click",key:[v+"U",true]},{sel:"#tool_wireframe",fn:Hb,evt:"click"},{sel:"#tool_snap",fn:Gb,evt:"click"}, {sel:"#tool_rulers",fn:Lb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:Ab,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Kb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:lb,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:ob,evt:"click"},{sel:"#tool_node_link",fn:tb,evt:"change"},{sel:"#tool_node_clone",fn:ia,evt:"click"},{sel:"#tool_node_delete",fn:aa,evt:"click"},{sel:"#tool_openclose_path", @@ -480,9 +480,9 @@ key:[v+"B",true]},{sel:"#tool_italic",fn:Za,evt:"mousedown",key:[v+"I",true]},{s 1)}},{key:["left",true],fn:function(){fb(-1,0)}},{key:["right",true],fn:function(){fb(1,0)}},{key:"shift+up",fn:function(){fb(0,-10)}},{key:"shift+down",fn:function(){fb(0,10)}},{key:"shift+left",fn:function(){fb(-10,0)}},{key:"shift+right",fn:function(){fb(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1, 0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:v+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var o=a(".tool_button_current");if(o.length&&o[0].id!=="tool_eyedropper"){o.removeClass("tool_button_current").addClass("tool_button"); a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},{key:v+"shift+z",fn:rb},{key:"esc",fn:Ib}],m={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var o={};a.each(h,function(u,E){if(E.sel){var H=a(E.sel);if(H.length==0)return true;if(E.evt){if(svgedit.browser.isTouch()&&E.evt==="click")E.evt="mousedown";H[E.evt](E.fn)}if(E.parent&&a(E.parent+"_show").length!=0){var J=a(E.parent);J.length||(J=na(E.parent.substr(1))); -J.append(H);a.isArray(o[E.parent])||(o[E.parent]=[]);o[E.parent].push(E)}}if(E.key){var O=E.fn,W=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)W=E.key[1]}else J=E.key;J+="";svgedit.browser.isMac&&J.indexOf("+")!=-1&&J.split("+")[0]=="ctrl"&&J.replace("ctrl","cmd");a.each(J.split("/"),function(T,fa){a(document).bind("keydown",fa,function(ha){O();W&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var ba=H.attr("title").split("[")[0]+" ("+J+")";m[J]=E.sel;H.parents("#main_menu").length|| -H.attr("title",ba)}}});Z(o);a(window).bind("keydown","tab",function(u){if(N==="canvas"){u.preventDefault();P()}}).bind("keydown","shift+tab",function(u){if(N==="canvas"){u.preventDefault();da()}});a("#tool_zoom").dblclick(Sa)},setTitles:function(){a.each(m,function(o,u){var E=a(u).parents("#main_menu").length;a(u).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,W){var ba=W.split("+"),T="";if(ba.length>1){T=ba[0]+"+";W=ba[1]}J+=(O? -"/":"")+T+(uiStrings["key_"+W]||W)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var u;a.each(h,function(E,H){if(H.sel===o)u=H});return u}}}();C.setAll();b.ready(function(){var h=curConfig.initTool,m=a("#tools_left, #svg_editor .tools_flyout"),o=m.find("#tool_"+h);h=m.find("#"+h);(o.length?o:h.length?h:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)}); +J.append(H);a.isArray(o[E.parent])||(o[E.parent]=[]);o[E.parent].push(E)}}if(E.key){var O=E.fn,X=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)X=E.key[1]}else J=E.key;J+="";svgedit.browser.isMac&&J.indexOf("+")!=-1&&J.split("+")[0]=="ctrl"&&J.replace("ctrl","cmd");a.each(J.split("/"),function(T,fa){a(document).bind("keydown",fa,function(ha){O();X&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var ba=H.attr("title").split("[")[0]+" ("+J+")";m[J]=E.sel;H.parents("#main_menu").length|| +H.attr("title",ba)}}});Z(o);a(window).bind("keydown","tab",function(u){if(N==="canvas"){u.preventDefault();P()}}).bind("keydown","shift+tab",function(u){if(N==="canvas"){u.preventDefault();da()}});a("#tool_zoom").dblclick(Sa)},setTitles:function(){a.each(m,function(o,u){var E=a(u).parents("#main_menu").length;a(u).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,X){var ba=X.split("+"),T="";if(ba.length>1){T=ba[0]+"+";X=ba[1]}J+=(O? +"/":"")+T+(uiStrings["key_"+X]||X)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var u;a.each(h,function(E,H){if(H.sel===o)u=H});return u}}}();C.setAll();b.ready(function(){var h=curConfig.initTool,m=a("#tools_left, #svg_editor .tools_flyout"),o=m.find("#tool_"+h);h=m.find("#"+h);(o.length?o:h.length?h:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)}); a("#canvas_height").dragInput({min:10,max:null,step:10,callback:l,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:l,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null, step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1, max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute, @@ -493,14 +493,14 @@ Y&&["line","polyline"].indexOf(Y.nodeName)>=0)m=h.value=1;g.setStrokeWidth(m)},c return o>=24?E?Math.round(o*1.1):Math.round(o/1.1):o<=1?E?o*2:o/2:u},dragAdjust:0.15});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(h,m){val=h.value;a("#blur").val(val);m?g.setBlur(val,true):g.setBlurNoUndo(val)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(h){switch(h){case "delete":lb();break;case "cut":Ua(); break;case "copy":Xa();break;case "paste":g.pasteElements();break;case "paste_in_place":g.pasteElements("in_place");break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":sa();break;case "move_up":ib("Up");break;case "move_down":ib("Down");break;case "move_back":hb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(h)&&svgedit.contextmenu.getCustomHandler(h).call()}});a(".contextMenu li").mousedown(function(h){h.preventDefault()}); a("#cmenu_canvas li").disableContextMenu();I.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(q.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(h){a("#main_menu").hide();q.getUndoStackSize()===0?h(true):a.confirm(uiStrings.notification.QwantToOpen,h)};if(window.FileReader){d=function(h){h.stopPropagation();h.preventDefault();a("#workarea").removeAttr("style"); -a("#main_menu").hide();var m=null;if(m=h.type=="drop"?h.dataTransfer.files[0]:this.files[0])if(m.type.indexOf("image")!=-1)if(m.type.indexOf("svg")!=-1){h=new FileReader;h.onloadend=function(o){g.importSvgString(o.target.result,true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};h.readAsText(m)}else{h=new FileReader;h.onloadend=function(o){insertNewImage=function(J,O){var W=g.addSvgElementFromJson({element:"image", -attr:{x:0,y:0,width:J,height:O,id:g.getNextId(),style:"pointer-events:inherit"}});g.setHref(W,o.target.result);g.selectOnly([W]);g.alignSelectedElements("m","page");g.alignSelectedElements("c","page");Fa()};var u=100,E=100,H=new Image;H.src=o.target.result;document.body.appendChild(H);H.onload=function(){u=H.offsetWidth;E=H.offsetHeight;insertNewImage(u,E);document.body.removeChild(H)}};h.readAsDataURL(m)}};K=a("#workarea");K[0].addEventListener("dragenter",function(h){h.stopPropagation();h.preventDefault(); +a("#main_menu").hide();var m=null;if(m=h.type=="drop"?h.dataTransfer.files[0]:this.files[0])if(m.type.indexOf("image")!=-1)if(m.type.indexOf("svg")!=-1){h=new FileReader;h.onloadend=function(o){g.importSvgString(o.target.result,true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};h.readAsText(m)}else{h=new FileReader;h.onloadend=function(o){insertNewImage=function(J,O){var X=g.addSvgElementFromJson({element:"image", +attr:{x:0,y:0,width:J,height:O,id:g.getNextId(),style:"pointer-events:inherit"}});g.setHref(X,o.target.result);g.selectOnly([X]);g.alignSelectedElements("m","page");g.alignSelectedElements("c","page");Fa()};var u=100,E=100,H=new Image;H.src=o.target.result;document.body.appendChild(H);H.onload=function(){u=H.offsetWidth;E=H.offsetHeight;insertNewImage(u,E);document.body.removeChild(H)}};h.readAsDataURL(m)}};K=a("#workarea");K[0].addEventListener("dragenter",function(h){h.stopPropagation();h.preventDefault(); K.css({"-webkit-transform":"scale3d(1.1,1.1,1)","-moz-transform":"scale3d(1.1,1.1,1)","-o-transform":"scale(1.1)","-ms-transform":"scale3d(1.1,1.1,1)",transform:"scale3d(1.1,1.1,1)"})},false);K[0].addEventListener("dragover",function(h){h.stopPropagation();h.preventDefault()},false);K[0].addEventListener("dragleave",function(h){K.removeAttr("style");h.stopPropagation();h.preventDefault()},false);K[0].addEventListener("drop",d,false);var A=a('').change(function(){var h=this;b.openPrep(function(m){if(m){g.clear(); -if(h.files.length==1){m=new FileReader;m.onloadend=function(o){s(o.target.result);G()};m.readAsText(h.files[0])}}})});a("#tool_open").show().prepend(A);d=a('').change(d);a("#tool_import").show().prepend(d)}var G=b.updateCanvas=function(h,m){var o=K.width(),u=K.height(),E=o,H=u,J=g.getZoom(),O=K,W=a("#svgcanvas"),ba={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},T=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*T);u=Math.max(H,g.contentH*J*T);o==E&&u==H?K.css("overflow","hidden"): -K.css("overflow","scroll");T=W.height()/2;var fa=W.width()/2;W.width(o).height(u);var ha=u/2,X=o/2,qa=g.updateCanvas(o,u),ua=X/fa;o=o/2-E/2;u=u/2-H/2;if(m){m.x+=qa.x;m.y+=qa.y}else m={x:X+(ba.x-fa)*ua,y:ha+(ba.y-T)*ua};if(h)if(g.contentW>O.width()){K[0].scrollLeft=qa.x-10;K[0].scrollTop=qa.y-10}else{O[0].scrollLeft=o;O[0].scrollTop=u}else{O[0].scrollLeft=m.x-E/2;O[0].scrollTop=m.y-H/2}if(curConfig.showRulers){E=W;J=J;document.getElementById("workarea");document.getElementById("title_show");J||(J= -g.getZoom());E||(E=a("#svgcanvas"));H=g.getContentElem();O=svgedit.units.getTypeMap()[curConfig.baseUnit];for(W=0;W<2;W++){fa=(ba=W===0)?"x":"y";ua=ba?"width":"height";T=H.getAttribute(fa)-0;fa=a("#ruler_"+fa+" canvas:first");$hcanv=fa.clone();fa.replaceWith($hcanv);o=$hcanv[0];ha=fa=E[ua]()*2;o.parentNode.style[ua]=ha+"px";X=0;var Aa;qa=o.getContext("2d");qa.fillStyle="rgb(200,0,0)";qa.fillRect(0,0,o.width,o.height);$hcanv.siblings().remove();if(fa>=3E4){var Ca=parseInt(fa/3E4)+1;Aa=Array(Ca);Aa[0]= +if(h.files.length==1){m=new FileReader;m.onloadend=function(o){s(o.target.result);G()};m.readAsText(h.files[0])}}})});a("#tool_open").show().prepend(A);d=a('').change(d);a("#tool_import").show().prepend(d)}var G=b.updateCanvas=function(h,m){var o=K.width(),u=K.height(),E=o,H=u,J=g.getZoom(),O=K,X=a("#svgcanvas"),ba={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},T=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*T);u=Math.max(H,g.contentH*J*T);o==E&&u==H?K.css("overflow","hidden"): +K.css("overflow","scroll");T=X.height()/2;var fa=X.width()/2;X.width(o).height(u);var ha=u/2,W=o/2,qa=g.updateCanvas(o,u),ua=W/fa;o=o/2-E/2;u=u/2-H/2;if(m){m.x+=qa.x;m.y+=qa.y}else m={x:W+(ba.x-fa)*ua,y:ha+(ba.y-T)*ua};if(h)if(g.contentW>O.width()){K[0].scrollLeft=qa.x-10;K[0].scrollTop=qa.y-10}else{O[0].scrollLeft=o;O[0].scrollTop=u}else{O[0].scrollLeft=m.x-E/2;O[0].scrollTop=m.y-H/2}if(curConfig.showRulers){E=X;J=J;document.getElementById("workarea");document.getElementById("title_show");J||(J= +g.getZoom());E||(E=a("#svgcanvas"));H=g.getContentElem();O=svgedit.units.getTypeMap()[curConfig.baseUnit];for(X=0;X<2;X++){fa=(ba=X===0)?"x":"y";ua=ba?"width":"height";T=H.getAttribute(fa)-0;fa=a("#ruler_"+fa+" canvas:first");$hcanv=fa.clone();fa.replaceWith($hcanv);o=$hcanv[0];ha=fa=E[ua]()*2;o.parentNode.style[ua]=ha+"px";W=0;var Aa;qa=o.getContext("2d");qa.fillStyle="rgb(200,0,0)";qa.fillRect(0,0,o.width,o.height);$hcanv.siblings().remove();if(fa>=3E4){var Ca=parseInt(fa/3E4)+1;Aa=Array(Ca);Aa[0]= qa;for(u=1;u=1)u=Math.round(Ca);else{u=(o+"").split(".")[1].length; -u=Ca.toFixed(u)-0}if(u!==0&&u!==1E3&&u%1E3===0)u=u/1E3+"K";if(ba){qa.fillText(u,Na+2,8);qa.fillStyle="#777"}else{Ca=(u+"").split("");for(u=0;ufa){X++;qa.stroke();if(X>=Aa.length){u=10;Na=ha;continue}qa=Aa[X];Na-=3E4;ub=Math.round(Na+Ca*u)+0.5}var Cb=u%2?12:10;if(ba){qa.moveTo(ub,15);qa.lineTo(ub,Cb)}else{qa.moveTo(15,ub);qa.lineTo(Cb,ub)}}}qa.strokeStyle="#666";qa.stroke()}K.scroll()}}, +u=Ca.toFixed(u)-0}if(u!==0&&u!==1E3&&u%1E3===0)u=u/1E3+"K";if(ba){qa.fillText(u,Na+2,8);qa.fillStyle="#777"}else{Ca=(u+"").split("");for(u=0;ufa){W++;qa.stroke();if(W>=Aa.length){u=10;Na=ha;continue}qa=Aa[W];Na-=3E4;ub=Math.round(Na+Ca*u)+0.5}var Cb=u%2?12:10;if(ba){qa.moveTo(ub,15);qa.lineTo(ub,Cb)}else{qa.moveTo(15,ub);qa.lineTo(Cb,ub)}}}qa.strokeStyle="#666";qa.stroke()}K.scroll()}}, D=[];for(d=0.1;d<1E5;d*=10){D.push(1*d);D.push(2*d);D.push(5*d)}G(true);try{var z=function(h){if(window.JSON&&JSON.stringify)return JSON.stringify(h);var m=arguments.callee;if(typeof h=="boolean"||typeof h=="number")return h+"";else if(typeof h=="string")return'"'+h.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(E){return"\\u"+("0000"+E.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(h.length){for(var o= 0;o=0)m=o=c.convertToPath(h,true);else if(h.tagName=="rect"){var u=h.getAttribute("rx"),E=h.getAttribute("ry");if(u||E)m=o=c.convertToPath(h,true)}if(!o){var H=h.cloneNode(true),J=document.createElementNS(b, -"g"),O=h.parentNode;O.appendChild(J);J.appendChild(H);m=svgedit.utilities.bboxToObj(J.getBBox());O.removeChild(J)}}return m}catch(W){console.log(h,W)}},l;$.each(e,function(){if(!l)if(this.parentNode)l=k(this)});if(l==null)return null;var C=l.x+l.width,A=l.y+l.height,G=l.x,D=l.y,z=function(h){var m=h.getAttribute("stroke-width"),o=0;if(h.getAttribute("stroke")!="none"&&!isNaN(m))o+=m/2;return o},F=[];$.each(e,function(h,m){var o=k(m);if(o){var u=z(m);G=Math.min(G,o.x-u);D=Math.min(D,o.y-u);F.push(o)}}); +"g"),O=h.parentNode;O.appendChild(J);J.appendChild(H);m=svgedit.utilities.bboxToObj(J.getBBox());O.removeChild(J)}}return m}catch(X){console.log(h,X)}},l;$.each(e,function(){if(!l)if(this.parentNode)l=k(this)});if(l==null)return null;var C=l.x+l.width,A=l.y+l.height,G=l.x,D=l.y,z=function(h){var m=h.getAttribute("stroke-width"),o=0;if(h.getAttribute("stroke")!="none"&&!isNaN(m))o+=m/2;return o},F=[];$.each(e,function(h,m){var o=k(m);if(o){var u=z(m);G=Math.min(G,o.x-u);D=Math.min(D,o.y-u);F.push(o)}}); l.x=G;l.y=D;$.each(e,function(h,m){var o=F[h];if(o&&m.nodeType==1){var u=z(m);C=Math.max(C,o.x+o.width+u);A=Math.max(A,o.y+o.height+u)}});l.width=C-G;l.height=A-D;return l};var pb=this.getVisibleElements=function(e){e||(e=$(n).children());e.find("#canvas_background").length&&e.splice(0,1);var k=[];$(e).children().each(function(l,C){try{C.getBBox()&&k.push(C)}catch(A){}});return k.reverse()},fb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(n).children());var k=[];$(e).children().each(function(l, C){try{C.getBBox()&&k.push({elem:C,bbox:getStrokedBBox([C])})}catch(A){}});return k.reverse()},tb=this.groupSvgElem=function(e){var k=document.createElementNS(b,"g");e.parentNode.replaceChild(k,e);$(k).append(e).data("gsvg",e)[0].id=ka()},ia=function(e){var k=document.createElementNS(e.namespaceURI,e.nodeName);k.removeAttribute("id");$.each(e.attributes,function(C,A){A.localName!="-moz-math-font-style"&&k.setAttributeNS(A.namespaceURI,A.nodeName,A.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName== "path"){var l=La.convertPath(e);k.setAttribute("d",l)}$.each(e.childNodes,function(C,A){switch(A.nodeType){case 1:k.appendChild(ia(A));break;case 3:k.textContent=A.nodeValue}});if($(e).data("gsvg"))$(k).data("gsvg",k.firstChild);else if($(e).data("symbol")){e=$(e).data("symbol");$(k).data("ref",e).data("symbol",e)}else k.tagName=="image"&&Fb(k);k.id=ka();return k},aa,ka,M;(function(e){var k={};aa=e.getId=function(){return B().getId()};ka=e.getNextId=function(){return B().getNextId()};M=e.call=function(l, @@ -227,15 +227,15 @@ null)return null;var k=R(e);if(k&&k.numberOfItems>0){for(var l=k.numberOfItems;l A[0][0]));k.removeItem(A[0][1]);k.removeItem(A[1][1]);k.insertItemBefore(l,A[1][1])}l=k.numberOfItems;if(l>=2&&k.getItem(l-2).type===1&&k.getItem(l-1).type===2){A=d.createSVGTransform();C=ga(k.getItem(l-2).matrix,k.getItem(l-1).matrix);A.setMatrix(C);k.removeItem(l-2);k.removeItem(l-2);k.appendItem(A)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(k.numberOfItems===1&&k.getItem(0).type===1||k.numberOfItems===2&&k.getItem(0).type===1&&k.getItem(0).type=== 4)return null}var G=$(e).data("gsvg");l=new Da("Transform");var D={},z=null;C=[];switch(e.tagName){case "line":C=["x1","y1","x2","y2"];break;case "circle":C=["cx","cy","r"];break;case "ellipse":C=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":C=["width","height","x","y"];break;case "use":case "text":case "tspan":C=["x","y"];break;case "polygon":case "polyline":z={};z.points=e.getAttribute("points");A=e.points;var F=A.numberOfItems;D.points=Array(F);for(var h=0;h1.0E-10?Math.sin(h)/(1-Math.cos(h)):2/h;for(h=0;h=3&&k.getItem(E-2).type==3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;var J=k.getItem(E-3).matrix,O=k.getItem(E-2).matrix,W=k.getItem(E-1).matrix;F=e.childNodes;for(m=F.length;m--;){var ba=F.item(m);C=G=0;if(ba.nodeType== -1){var T=R(ba);if(T){C=Y(T).matrix;G=na(ba);var fa=Sa,ha=[];Sa=ba.getAttribute("transform");if(G||oa(T)){var X=d.createSVGTransform();X.setMatrix(ga(J,O,W,C));T.clear();T.appendItem(X);ha.push(X)}else{G=ga(C.inverse(),W,C);X=d.createSVGMatrix();X.e=-G.e;X.f=-G.f;C=ga(X.inverse(),C.inverse(),J,O,W,C,G.inverse());var qa=d.createSVGTransform(),ua=d.createSVGTransform(),Aa=d.createSVGTransform();qa.setTranslate(G.e,G.f);ua.setScale(C.a,C.d);Aa.setTranslate(X.e,X.f);T.appendItem(Aa);T.appendItem(ua);T.appendItem(qa); -ha.push(Aa);ha.push(ua);ha.push(qa)}l.addSubCommand(Ra(ba));Sa=fa}}}k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E>=3&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;X=d.createSVGTransform();X.setMatrix(C);k.clear();k.appendItem(X)}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;G=Y(k).matrix;k.removeItem(0);C=Y(k).matrix.inverse();C=ga(C,G);G=C.e;C=C.f;if(G!=0||C!=0){F=e.childNodes;m=F.length;for(E=[];m--;){ba=F.item(m);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){fa= -ba.getAttribute("clip-path");if(E.indexOf(fa)===-1){nb(fa,G,C);E.push(fa)}}fa=Sa;Sa=ba.getAttribute("transform");if(T=R(ba)){J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);l.addSubCommand(Ra(ba));T=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(J=T.length;J--;){O=T.item(J);if(ba==ca(O)){W=d.createSVGTransform();W.setTranslate(-G,-C);R(O).insertItemBefore(W,0);l.addSubCommand(Ra(O))}}Sa=fa}}}E=[];Sa=fa}}else if(E==1&&k.getItem(0).type==1&&!A){h= +if(A=na(e)){h=A*Math.PI/180;F=Math.abs(h)>1.0E-10?Math.sin(h)/(1-Math.cos(h)):2/h;for(h=0;h=3&&k.getItem(E-2).type==3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;var J=k.getItem(E-3).matrix,O=k.getItem(E-2).matrix,X=k.getItem(E-1).matrix;F=e.childNodes;for(m=F.length;m--;){var ba=F.item(m);C=G=0;if(ba.nodeType== +1){var T=R(ba);if(T){C=Y(T).matrix;G=na(ba);var fa=Sa,ha=[];Sa=ba.getAttribute("transform");if(G||oa(T)){var W=d.createSVGTransform();W.setMatrix(ga(J,O,X,C));T.clear();T.appendItem(W);ha.push(W)}else{G=ga(C.inverse(),X,C);W=d.createSVGMatrix();W.e=-G.e;W.f=-G.f;C=ga(W.inverse(),C.inverse(),J,O,X,C,G.inverse());var qa=d.createSVGTransform(),ua=d.createSVGTransform(),Aa=d.createSVGTransform();qa.setTranslate(G.e,G.f);ua.setScale(C.a,C.d);Aa.setTranslate(W.e,W.f);T.appendItem(Aa);T.appendItem(ua);T.appendItem(qa); +ha.push(Aa);ha.push(ua);ha.push(qa)}l.addSubCommand(Ra(ba));Sa=fa}}}k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E>=3&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;W=d.createSVGTransform();W.setMatrix(C);k.clear();k.appendItem(W)}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;G=Y(k).matrix;k.removeItem(0);C=Y(k).matrix.inverse();C=ga(C,G);G=C.e;C=C.f;if(G!=0||C!=0){F=e.childNodes;m=F.length;for(E=[];m--;){ba=F.item(m);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){fa= +ba.getAttribute("clip-path");if(E.indexOf(fa)===-1){nb(fa,G,C);E.push(fa)}}fa=Sa;Sa=ba.getAttribute("transform");if(T=R(ba)){J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);l.addSubCommand(Ra(ba));T=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(J=T.length;J--;){O=T.item(J);if(ba==ca(O)){X=d.createSVGTransform();X.setTranslate(-G,-C);R(O).insertItemBefore(X,0);l.addSubCommand(Ra(O))}}Sa=fa}}}E=[];Sa=fa}}else if(E==1&&k.getItem(0).type==1&&!A){h= 1;C=k.getItem(0).matrix;F=e.childNodes;for(m=F.length;m--;){ba=F.item(m);if(ba.nodeType==1){fa=Sa;Sa=ba.getAttribute("transform");if(T=R(ba)){G=ga(C,Y(T).matrix);E=d.createSVGTransform();E.setMatrix(G);T.clear();T.appendItem(E,0);l.addSubCommand(Ra(ba));Sa=fa;fa=ba.getAttribute("stroke-width");ba.getAttribute("stroke")!=="none"&&!isNaN(fa)&&ba.setAttribute("stroke-width",fa*((Math.abs(G.a)+Math.abs(G.d))/2))}}}k.clear()}else{if(A){o=d.createSVGTransform();o.setRotate(A,u.x,u.y);k.numberOfItems?k.insertItemBefore(o, 0):k.appendItem(o)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(h==2){if(A){u={x:o.x+H.e,y:o.y+H.f};o=d.createSVGTransform();o.setRotate(A,u.x,u.y);k.numberOfItems?k.insertItemBefore(o,0):k.appendItem(o)}}else if(h==3){C=Y(k).matrix;H=d.createSVGTransform();H.setRotate(A,o.x,o.y);H=H.matrix;o=d.createSVGTransform();o.setRotate(A,u.x,u.y);u=o.matrix.inverse();fa=C.inverse();u=ga(fa,u,H,C);G=u.e;C=u.f;if(G!=0||C!=0){F=e.childNodes;for(m=F.length;m--;){ba=F.item(m);if(ba.nodeType== 1){fa=Sa;Sa=ba.getAttribute("transform");T=R(ba);J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);l.addSubCommand(Ra(ba));Sa=fa}}}if(A)k.numberOfItems?k.insertItemBefore(o,0):k.appendItem(o)}}else{A=svgedit.utilities.getBBox(e);if(!A&&e.tagName!="path")return null;C=d.createSVGMatrix();if(G=na(e)){o={x:A.x+A.width/2,y:A.y+A.height/2};u=N(A.x+A.width/2,A.y+A.height/2,Y(k).matrix);h=G*Math.PI/180;F=Math.abs(h)>1.0E-10?Math.sin(h)/(1-Math.cos(h)):2/ h;for(h=0;h=3&&k.getItem(E-2).type== -3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;C=Y(k,E-3,E-1).matrix;k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E==4&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;X=d.createSVGTransform();X.setMatrix(C);k.clear();k.appendItem(X);C=d.createSVGMatrix()}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;H=k.getItem(0).matrix;fa=Y(k,1).matrix;A=fa.inverse();C=ga(A,H,fa);k.removeItem(0)}else if(E==1&&k.getItem(0).type==1&&!G){C=Y(k).matrix;switch(e.tagName){case "line":D= +3&&k.getItem(E-3).type==2&&k.getItem(E-1).type==2){h=3;C=Y(k,E-3,E-1).matrix;k.removeItem(E-1);k.removeItem(E-2);k.removeItem(E-3)}else if(E==4&&k.getItem(E-1).type==1){h=3;C=Y(k).matrix;W=d.createSVGTransform();W.setMatrix(C);k.clear();k.appendItem(W);C=d.createSVGMatrix()}else if((E==1||E>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){h=2;H=k.getItem(0).matrix;fa=Y(k,1).matrix;A=fa.inverse();C=ga(A,H,fa);k.removeItem(0)}else if(E==1&&k.getItem(0).type==1&&!G){C=Y(k).matrix;switch(e.tagName){case "line":D= $(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":D.points=e.getAttribute("points");if(D.points){A=e.points;F=A.numberOfItems;D.points=Array(F);for(h=0;h1&&A.showGrips(false)}}}M("selected",I);k||I.length==1?ra.requestSelector(I[0]).showGrips(true): @@ -243,38 +243,38 @@ ra.requestSelector(I[0]).showGrips(false);for(I.sort(function(G,D){if(G&&D&&G.co 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 -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;O0&&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(W=na(F)){var fa=Math.sqrt(u*u+H*H);H=Math.atan2(H,u)-W*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,X=T?(T+H)/T:1,qa=ba?(ba+u)/ba:1;if(db.indexOf("n")>=0){X=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=X;else X=qa;H.setScale(qa,X);ba.setTranslate(E+fa,O+ha);if(J){J=W?1:0;o.replaceItem(u,2+J);o.replaceItem(H,1+J);o.replaceItem(ba,0+J)}else{J=o.numberOfItems; +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;O0&&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=kl?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;W=(Math.atan2(E-y,J-x)*(180/Math.PI)-90)%360;W+=compensation_angle;if(p.gridSnapping)W= -va(W);if(z.shiftKey)W=Math.round(W/45)*45;c.setRotationAngle(W<-180?360+W:W,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|| +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;m1||m>1){z=I.length;for(m=0;m=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(W,ba){if(ba){H=ba.keep||H;E=ba.element;Ka=ba.started||Ka}});if(!H&& +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 X=m.getAttribute("display")==="none";m.setAttribute("display",X?"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 X=E[fa];m.setAttribute("visibility","hidden");fa=G(T.x,H.y);ha=G(T.x+(X.x-T.x),H.y);var qa=G(T.x,H.y+H.height);T=G(T.x+(X.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 X=E[ha];T>X.x+X.width/2&&ha++;return ha}function C(T, -fa,ha){var X=h.selectionStart;T=l(T,fa);k(Math.min(X,T),Math.max(X,T),!ha)}function A(T,fa){var ha={x:T,y:fa};ha.x/=q;ha.y/=q;if(J){var X=N(ha.x,ha.y,J.inverse());ha.x=X.x;ha.y=X.y}return ha}function G(T,fa){var ha={x:T,y:fa};if(J){var X=N(ha.x,ha.y,J);ha.x=X.x;ha.y=X.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,X=ha.substr(0,fa).replace(/[a-z0-9]+$/i, -"").length;ha=ha.substr(fa).match(/^[a-z0-9]+/i);k(X,(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,W,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,X){T=A(ha,X);h.focus();e(l(T.x,T.y));O=ha;W=X},mouseMove:function(T,fa){var ha=A(T,fa);C(ha.x,ha.y)},mouseUp:function(T,fa,ha){var X=A(fa,ha);C(X.x,X.y,true);T.target!==F&&faO-2&&ha< -W+2&&ha>W-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=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&&faO-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=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< @@ -282,9 +282,9 @@ if(F>=J-u&&F<=J+u&&z>=H-u&&z<=H+u){E=true;break}}u=aa();svgedit.path.removePath_ 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,W){return Math.sqrt(Math.pow(O.x-W.x,2)+Math.pow(O.y-W.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- +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,W=F/q;H=h?D+(D-O):H;h=h?u+(u-W):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- +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")]: @@ -292,7 +292,7 @@ svgedit.path.path.moveCtrl(o,m):svgedit.path.path.movePts(o,m)}else{svgedit.path "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=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");o0;);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;AF?"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=0&&e=0){var z=getStrokedBBox([D]);c.moveSelectedElements((e==="x"?k-z.x:0)*q,(e==="y"?k-z.y:0)*q,true)}else{z=e==="#text"?D.textContent:D.getAttribute(e);if(z==null)z="";if(z!==String(k)){if(e=="#text"){svgedit.utilities.getBBox(D);D.textContent=k}else e=="#href"?U(D,k):D.setAttribute(e,k);I.indexOf(D)>=0&&setTimeout(function(){D.parentNode&& ra.requestSelector(D).resize()},0);z=na(D);if(z!=0&&e!="transform")for(var F=R(D),h=F.numberOfItems;h--;)if(F.getItem(h).type==4){F.removeItem(h);var m=svgedit.utilities.getBBox(D),o=N(m.x+m.width/2,m.y+m.height/2,Y(F).matrix);m=o.x;o=o.y;var u=d.createSVGTransform();u.setRotate(z,m,o);F.insertItemBefore(u,h);break}}}}}d.unsuspendRedraw(C)},Ya=this.changeSelectedAttribute=function(e,k,l){l=l||I;c.undoMgr.beginUndoableChange(e,l);Ab(e,k,l);e=c.undoMgr.finishUndoableChange();e.isEmpty()||wa(e)};this.deleteSelectedElements= function(){for(var e=new Da("Delete Elements"),k=I.length,l=[],C=0;C1)l=arguments[1];break;default:e="g";k="Group Elements"}k=new Da(k);var C=S({element:e,attr:{id:ka()}});e==="a"&&U(C,l);k.addSubCommand(new Ia(C));for(l=I.length;l--;){var A=I[l];if(A!=null){if(A.parentNode.tagName==="a"&&A.parentNode.childNodes.length===1)A=A.parentNode;var G=A.nextSibling,D=A.parentNode;C.appendChild(A); k.addSubCommand(new Ja(A,G,D))}}k.isEmpty()||wa(k);rb([C],true)};var Db=this.pushGroupProperties=function(e,k){var l=e.childNodes,C=l.length,A=e.getAttribute("transform"),G=R(e),D=Y(G).matrix,z=new Da("Push group properties"),F=0,h=na(e),m=$(e).attr(["filter","opacity"]),o,u;for(F=0;F=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("

      "+E.replace(/\n/g,"

      ")+"

      ").toggleClass("prompt",u=="prompt");m.empty();var O=a('').appendTo(m);u!="alert"&&a('').appendTo(m).on("click touchstart",function(){h.hide();H(false)});if(u=="prompt"){var W=a('').prependTo(m);W.val(J||"");W.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"?W.val():true;H&&H(ba)}).focus();u=="prompt"&&W.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", +uiStrings.common.cancel+'">').appendTo(m).on("click touchstart",function(){h.hide();H(false)});if(u=="prompt"){var X=a('').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}); -else{typeof animatedZoom!="undefined"&&h.cancelAnimationFrame(animatedZoom);var H=Date.now(),J=E-o.zoom;a("#zoom");var O=o.zoom,W=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(W);else{a("#zoom").val(parseInt(E*100));a("option","#zoom_select").removeAttr("selected");a("option[value="+parseInt(E*100)+"]","#zoom_select").attr("selected","selected")}};W();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 X=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||!X?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", -T.key[0]+" shift+"+T.key[0],ba)});if(J)H.attr("data-curopt",o[J].sel);else H.attr("data-curopt")||H.attr("data-curopt",o[0].sel);var O,W=a(E).position();a(m).css({left:W.left+34,top:W.top+77});H.mousedown(function(ba){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&ra(E,false);if(H.hasClass("disabled"))return false;var T=a(m),fa=W.left+34,ha=T.width()*-1,X=T.data("shown_popop")?200:0;O=setTimeout(function(){H.data("isLibrary")?T.css("left", -fa).show():T.css("left",ha).show().animate({left:fa},50);T.data("shown_popop",true)},X);ba.preventDefault()}).mouseup(function(){clearTimeout(O);var ba=a(this).attr("data-curopt");if(H.data("isLibrary")&&a(E.replace("_show","")).is(":visible"))ra(E,true);else ra(E)&&ba in U&&U[ba]()})});ma()},na=function(h,m){return a("
      ",{"class":"tools_flyout",id:h}).appendTo("#svg_editor").append(m)},pa=function(){a(".tools_flyout").each(function(){var h=a("#"+this.id+"_show"),m=h.offset();h=h.outerWidth(); +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", +T.key[0]+" shift+"+T.key[0],ba)});if(J)H.attr("data-curopt",o[J].sel);else H.attr("data-curopt")||H.attr("data-curopt",o[0].sel);var O,X=a(E).position();a(m).css({left:X.left+34,top:X.top+77});H.mousedown(function(ba){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&ra(E,false);if(H.hasClass("disabled"))return false;var T=a(m),fa=X.left+34,ha=T.width()*-1,W=T.data("shown_popop")?200:0;O=setTimeout(function(){H.data("isLibrary")?T.css("left", +fa).show():T.css("left",ha).show().animate({left:fa},50);T.data("shown_popop",true)},W);ba.preventDefault()}).mouseup(function(){clearTimeout(O);var ba=a(this).attr("data-curopt");if(H.data("isLibrary")&&a(E.replace("_show","")).is(":visible"))ra(E,true);else ra(E)&&ba in U&&U[ba]()})});ma()},na=function(h,m){return a("
      ",{"class":"tools_flyout",id:h}).appendTo("#svg_editor").append(m)},pa=function(){a(".tools_flyout").each(function(){var h=a("#"+this.id+"_show"),m=h.offset();h=h.outerWidth(); a(this).css({left:(m.left+h)*R,top:m.top})})},ma=function(){a(".tools_flyout").each(function(){var h=a("#"+this.id+"_show");if(!h.data("isLibrary")){var m=[];a(this).children().each(function(){m.push(this.title)});h[0].title=m.join(" / ")}})},la,ya=function(h,m,o){var u=null;if(h.indexOf("url(#")===0){h=(h=g.getRefElem(h))?h.cloneNode(true):a("#"+o+"_color defs *")[0];u={alpha:m};u[h.tagName]=h}else u=h.indexOf("#")===0?{alpha:m,solidColor:h.substr(1)}:{alpha:m,solidColor:"none"};return new a.jGraduate.Paint(u)}, za=g.getResolution();if(curConfig.baseUnit!=="px"){za.w=svgedit.units.convertUnit(za.w)+curConfig.baseUnit;za.h=svgedit.units.convertUnit(za.h)+curConfig.baseUnit}var Ja=function(h){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:za.w+2,height:za.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:h||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};document.getElementById("canvas_background")|| Ja();document.getElementById("canvas_background").getAttribute("fill");var Ia=b.setImageURL=function(h){h||(h=Q);g.setImageURL(h);a("#image_url").val(h)},Fa=function(){var h=Y;if(h!=null&&!h.parentNode)h=null;if(V&&V[0]!=null&&!V[0].parentNode)V=false;var m=g.getCurrentDrawing().getCurrentLayerName(),o=g.getMode(),u=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,E=o=="pathedit";if(E){a(".context_panel").hide();a("#path_node_panel").show();a("#stroke_panel").hide();m=B.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button"); a("#tool_node_delete").toggleClass("disabled",!B.canDeleteNodes);zb("#tool_openclose_path",B.closed_subpath?"open_path":"close_path");if(m){E=a("#seg_type");if(u){m.x=svgedit.units.convertUnit(m.x);m.y=svgedit.units.convertUnit(m.y)}a("#path_node_x").val(Math.round(m.x));a("#path_node_y").val(Math.round(m.y));if(m.type){E.val(m.type).removeAttr("disabled");a("#seg_type_label").html(m.type==4?"Straight":"Curve")}else E.val(4).attr("disabled","disabled")}a("#tools_top").removeClass("multiselected"); a("#stroke_panel").hide();a("#canvas_panel").hide()}else{var H=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");if(V){V=V.filter(Boolean);(h=g.elementsAreSame(V)?V[0]:null)&&a("#tools_top").addClass("multiselected")}if(!h&&!V){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(h!=null){a("#stroke_panel").show();var J=h.nodeName,O=g.getRotationAngle(h); -a("#angle").val(Math.round(O));O=g.getBlur(h);a("#blur").val(O);if(!E&&o!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var W,ba;if(["g","polyline","path"].indexOf(J)>=0)if(o=g.getStrokedBBox([h])){W=o.x;ba=o.y}if(u){W=svgedit.units.convertUnit(W);ba=svgedit.units.convertUnit(ba)}a("#"+J+"_x").val(Math.round(W));a("#"+J+"_y").val(Math.round(ba));if(J==="polyline"){a("#path_x").val(Math.round(W));a("#path_y").val(Math.round(ba))}["image","text","path","g","use"].indexOf(J)== +a("#angle").val(Math.round(O));O=g.getBlur(h);a("#blur").val(O);if(!E&&o!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var X,ba;if(["g","polyline","path"].indexOf(J)>=0)if(o=g.getStrokedBBox([h])){X=o.x;ba=o.y}if(u){X=svgedit.units.convertUnit(X);ba=svgedit.units.convertUnit(ba)}a("#"+J+"_x").val(Math.round(X));a("#"+J+"_y").val(Math.round(ba));if(J==="polyline"){a("#path_x").val(Math.round(X));a("#path_y").val(Math.round(ba))}["image","text","path","g","use"].indexOf(J)== -1&&a(".action_path_convert_selected").removeClass("disabled");J==="path"&&a(".action_path_selected").removeClass("disabled")}u=null;if(T==="a"){u=g.getHref(h);a("#g_panel").show()}if(h.parentNode.tagName==="a")if(!a(h).siblings().length){a("#a_panel").show();u=g.getHref(h.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!u);u&&a("#link_url").val(u);u={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 T=h.tagName;a(h).data("gsvg")&&a("#g_panel").show();if(T=="path"||T=="polyline")a("#path_panel").show();if(u[T]){u=u[T];a("#"+T+"_panel").show();T=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(u,function(fa,ha){var X=h.getAttribute(ha);if(curConfig.baseUnit!=="px"&&h[ha])X=svgedit.units.convertUnit(h[ha].baseVal.value);var qa=document.getElementById(T+"_"+ha);qa.value=Math.round(X)||0;qa.getAttribute("data-cursor")=== +"y1","x2","y2"],text:["x","y"],use:[],path:[]};var T=h.tagName;a(h).data("gsvg")&&a("#g_panel").show();if(T=="path"||T=="polyline")a("#path_panel").show();if(u[T]){u=u[T];a("#"+T+"_panel").show();T=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(u,function(fa,ha){var W=h.getAttribute(ha);if(curConfig.baseUnit!=="px"&&h[ha])W=svgedit.units.convertUnit(h[ha].baseVal.value);var qa=document.getElementById(T+"_"+ha);qa.value=Math.round(W)||0;qa.getAttribute("data-cursor")=== "true"&&a.fn.dragInput.updateCursor(qa)});if(T=="text"){u=h.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(u);a("#font_size").val(h.getAttribute("font-size"));a("#text").val(h.textContent);a("#preview_font").text(u.split(",")[0].replace(/'/g,"")).css("font-family",u);g.addedNew&&setTimeout(function(){a("#text").focus().select()}, 100)}else if(T=="image")Ia(g.getHref(h));else if(T==="g"||T==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}H[(T==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");H[(T==="g"||!V?"dis":"en")+"ableContextMenuItems"]("#group")}if(V){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");H.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}h||H.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back"); q.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");q.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(h&&!E||V){a("#selLayerNames").removeAttr("disabled").val(m);I.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(h,m){var o=g.getMode();o==="select"&& @@ -418,15 +418,15 @@ if(u){V=m.length>=2&&m[1]!=null?m:null;if(!V)switch(o){case "rotate":o=g.getRota {elems:m})});g.bind("saved",function(h,m){b.show_save_warning=false;m='\n'+m;var o=navigator.userAgent;if(~o.indexOf("MSIE"))Eb(0,true);else{var u=h.open("data:image/svg+xml;base64,"+L.encode64(m)),E=a.pref("save_notice_done");if(E!=="all"){var H=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(o.indexOf("Gecko/")!==-1)if(m.indexOf("",{id:"export_canvas"}).hide().appendTo("body");var u=a("#export_canvas")[0];u.width=g.contentW;u.height=g.contentH;canvg(u,m.svg,{renderCallback:function(){var E=u.toDataURL("image/png");S.location.href=E;if(a.pref("export_notice_done")!=="all"){E=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(o.length)E+="\n\n"+uiStrings.notification.noteTheseIssues+ "\n \u2022 "+o.join("\n \u2022 ");a.pref("export_notice_done","all");S.alert(E)}}})});g.bind("zoomed",ja);g.bind("contextset",function(h,m){var o="";if(m){var u="";o=''+g.getCurrentDrawing().getCurrentLayerName()+"";a(m).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){u+=" > "+this.id;o+=this!==m?' > '+this.id+"":" > "+this.id}});Ba=u}else Ba=null;a("#cur_context_panel").toggle(!!m).html(o)});g.bind("extension_added",function(h,m){function o(){if(la){clearTimeout(la); -la=null}E||(la=setTimeout(function(){E=true;Mb(w.iconsize)},50))}var u=false,E=false,H=true,J=function(){if(m.callback&&!u&&H){u=true;m.callback()}},O=[];m.context_tools&&a.each(m.context_tools,function(ha,X){var qa=X.container_id?' id="'+X.container_id+'"':"",ua=a("#"+X.panel);ua.length||(ua=a("
      ",{id:X.panel}).appendTo("#tools_top").hide());switch(X.type){case "tool_button":var Aa='
      '+X.id+"
      ",Ca=a(Aa).appendTo(ua);X.events&&a.each(X.events,function(Na,jb){a(Ca).bind(Na, -jb)});break;case "select":Aa="";var Pa=a(Aa).appendTo(ua).find("select");a.each(X.events,function(Na,jb){a(Pa).bind(Na,jb)});break;case "button-select":Aa='';qa=a('
        ').appendTo("#option_lists"); -X.colnum&&qa.addClass("optcols"+X.colnum);a(Aa).appendTo(ua).children();O.push({elem:"#"+X.id,list:"#"+X.id+"_opts",title:X.title,callback:X.events.change,cur:"#cur_"+X.id});break;case "input":Aa="'+X.label+':';var Qa=a(Aa).appendTo(ua).find("input");X.spindata&&Qa.SpinButton(X.spindata);X.events&&a.each(X.events,function(Na,jb){Qa.bind(Na, -jb)})}});if(m.buttons){var W={},ba={},T=m.svgicons,fa={};a.each(m.buttons,function(ha,X){for(var qa,ua=X.id,Aa=ha;a("#"+ua).length;)ua=X.id+"_"+ ++Aa;if(T){W[ua]=X.icon;Aa=X.svgicon?X.svgicon:X.id;if(X.type=="app_menu")ba["#"+ua+" > div"]=Aa;else ba["#"+ua]=Aa}else qa=X.type=="menu"?"":a('');var Ca,Pa;switch(X.type){case "mode_flyout":case "mode":Ca="tool_button";if(X.cls)Ca+=" "+X.cls;Pa="#tools_left";break;case "context":Ca="tool_button";Pa="#"+X.panel;a(Pa).length||a("
        ", -{id:X.panel}).appendTo("#tools_top");break;case "menu":Ca="menu_item tool_button";Pa="#"+(X.after||X.panel);break;case "app_menu":Ca="";Pa=X.parent||"#main_menu ul";a(Pa).length||a("
        ",{id:X.panel}).appendTo("#tools_top")}var Qa=a(X.list||X.type=="app_menu"?"
      • ":"
        ").attr("id",ua).attr("title",X.title).addClass(Ca);if(!X.includeWith&&!X.list){if("position"in X)a(Pa).children().eq(X.position).before(Qa);else X.type!="menu"||!X.after?Qa.appendTo(Pa):a(Pa).after(Qa);if(X.type=="mode_flyout"){Aa= -a(Qa);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){var Na=Aa[0].id.replace("tool_","tools_"),jb=Aa.clone().attr("id",Na+"_show").append(a("
        ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa);Ca.data("isLibrary",true);jb.data("isLibrary",true)}ba["#"+Na+"_show"]=X.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:X.events.click,icon:X.id,isDefault:true},ub]}else if(X.type=="app_menu"||X.type=="menu")Qa.append(X.title)}else if(X.list){Qa.addClass("push_button");a("#"+X.list+"_opts").append(Qa); -if(X.isDefault){a("#cur_"+X.list).append(Qa.children().clone());Aa=X.svgicon?X.svgicon:X.id;ba["#cur_"+X.list]=Aa}}else if(X.includeWith){Pa=X.includeWith;Aa=a(Pa.button);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){Na=Aa[0].id.replace("tool_","tools_");jb=Aa.clone().attr("id",Na+"_show").append(a("
        ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa)}var ub=C.getButtonData(Pa.button);if(Pa.isDefault)ba["#"+Na+"_show"]=X.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:X.events.click, -icon:X.id,key:X.key,isDefault:X.includeWith?X.includeWith.isDefault:0},ub];Na="position"in Pa?Pa.position:"last";ub=Ca.children().length;if(!isNaN(Na)&&Na>=0&&Na",{id:W.panel}).appendTo("#tools_top").hide());switch(W.type){case "tool_button":var Aa='
        '+W.id+"
        ",Ca=a(Aa).appendTo(ua);W.events&&a.each(W.events,function(Na,jb){a(Ca).bind(Na, +jb)});break;case "select":Aa="";var Pa=a(Aa).appendTo(ua).find("select");a.each(W.events,function(Na,jb){a(Pa).bind(Na,jb)});break;case "button-select":Aa='';qa=a('
          ').appendTo("#option_lists"); +W.colnum&&qa.addClass("optcols"+W.colnum);a(Aa).appendTo(ua).children();O.push({elem:"#"+W.id,list:"#"+W.id+"_opts",title:W.title,callback:W.events.change,cur:"#cur_"+W.id});break;case "input":Aa="'+W.label+':';var Qa=a(Aa).appendTo(ua).find("input");W.spindata&&Qa.SpinButton(W.spindata);W.events&&a.each(W.events,function(Na,jb){Qa.bind(Na, +jb)})}});if(m.buttons){var X={},ba={},T=m.svgicons,fa={};a.each(m.buttons,function(ha,W){for(var qa,ua=W.id,Aa=ha;a("#"+ua).length;)ua=W.id+"_"+ ++Aa;if(T){X[ua]=W.icon;Aa=W.svgicon?W.svgicon:W.id;if(W.type=="app_menu")ba["#"+ua+" > div"]=Aa;else ba["#"+ua]=Aa}else qa=W.type=="menu"?"":a('');var Ca,Pa;switch(W.type){case "mode_flyout":case "mode":Ca="tool_button";if(W.cls)Ca+=" "+W.cls;Pa="#tools_left";break;case "context":Ca="tool_button";Pa="#"+W.panel;a(Pa).length||a("
          ", +{id:W.panel}).appendTo("#tools_top");break;case "menu":Ca="menu_item tool_button";Pa="#"+(W.after||W.panel);break;case "app_menu":Ca="";Pa=W.parent||"#main_menu ul";a(Pa).length||a("
          ",{id:W.panel}).appendTo("#tools_top")}var Qa=a(W.list||W.type=="app_menu"?"
        • ":"
          ").attr("id",ua).attr("title",W.title).addClass(Ca);if(!W.includeWith&&!W.list){if("position"in W)a(Pa).children().eq(W.position).before(Qa);else W.type!="menu"||!W.after?Qa.appendTo(Pa):a(Pa).after(Qa);if(W.type=="mode_flyout"){Aa= +a(Qa);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){var Na=Aa[0].id.replace("tool_","tools_"),jb=Aa.clone().attr("id",Na+"_show").append(a("
          ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa);Ca.data("isLibrary",true);jb.data("isLibrary",true)}ba["#"+Na+"_show"]=W.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:W.events.click,icon:W.id,isDefault:true},ub]}else if(W.type=="app_menu"||W.type=="menu")Qa.append(W.title)}else if(W.list){Qa.addClass("push_button");a("#"+W.list+"_opts").append(Qa); +if(W.isDefault){a("#cur_"+W.list).append(Qa.children().clone());Aa=W.svgicon?W.svgicon:W.id;ba["#cur_"+W.list]=Aa}}else if(W.includeWith){Pa=W.includeWith;Aa=a(Pa.button);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){Na=Aa[0].id.replace("tool_","tools_");jb=Aa.clone().attr("id",Na+"_show").append(a("
          ",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa)}var ub=C.getButtonData(Pa.button);if(Pa.isDefault)ba["#"+Na+"_show"]=W.id;ua=fa["#"+Ca[0].id]=[{sel:"#"+ua,fn:W.events.click, +icon:W.id,key:W.key,isDefault:W.includeWith?W.includeWith.isDefault:0},ub];Na="position"in Pa?Pa.position:"last";ub=Ca.children().length;if(!isNaN(Na)&&Na>=0&&Na
          '});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", @@ -454,23 +454,23 @@ a("#tool_fill").toggleClass("active");var m=document.querySelector("#tool_fill r h},Ib=function(){window.self!=window.top&&top.exit_fullscreen()},Lb=function(){xa(a("#view_menu"));if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},xb=function(){if(!k){var h="#workarea.wireframe #svgcontent * { stroke-width: "+ 1/g.getZoom()+"px; }";a("#wireframe_rules").text(K.hasClass("wireframe")?h:"")}},Eb=function(h,m){if(!ea){xa(a("#view_menu"));ea=true;a("#save_output_btns").toggle(!!m);a("#tool_source_back").toggle(!m);var o=ga=g.getSvgString();a("#svg_source_textarea").val(o);a("#svg_source_editor").fadeIn();a("#svg_source_textarea").focus().select()}},Kb=function(){if(ea){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();Ya();yb();ca()}else a.confirm(uiStrings.notification.QerrorsRevertToSource, function(h){if(!h)return false;g.clearSelection();Ya();yb();ca()});oa()}},zb=b.setIcon=function(h,m){var o=typeof m==="string"?a.getSvgIcon(m,true):m.clone();o?a(h).find("img").replaceWith(o):console.log("NOTE: Icon image missing: "+m)},gb;gb=function(){var h=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,m=document.getElementsByTagName("script")[0],o;for(o in m.style)if(h.test(o))return o.match(h)[0];if("WebkitOpacity"in m.style)return"Webkit";if("KhtmlOpacity"in m.style)return"Khtml";return""}();var Nb= -function(h,m){gb.toLowerCase();var o=["top","left","bottom","right"];h.each(function(){for(var u=a(this),E=u.outerWidth()*(m-1),H=u.outerHeight()*(m-1),J=0;J<4;J++){var O=o[J],W=u.data("orig_margin-"+O);if(W==null){W=parseInt(u.css("margin-"+O));u.data("orig_margin-"+O,W)}W=W*m;if(O==="right")W+=E;else if(O==="bottom")W+=H;u.css("margin-"+O,W)}})},Mb=b.setIconSize=function(h,m){if(!(h==w.size&&!m)){var o=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"), -u=1;u=typeof h=="number"?h:{s:0.75,m:1,l:1.25,xl:1.5}[h];b.tool_scale=R=u;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,u);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();else o=a('').appendTo("head");if(h!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(W,ba){if(typeof ba==="number")var T=ba*u+"px";else if(ba[h]||ba.all)T= -ba[h]||ba.all;H+=W+":"+T+";"});H+="}"});E="-"+gb.toLowerCase()+"-";H+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+E+"transform: scale("+u+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/u+");}";o.text(H)}pa()}},Ab=function(){a("#dialog_box").hide(); +function(h,m){gb.toLowerCase();var o=["top","left","bottom","right"];h.each(function(){for(var u=a(this),E=u.outerWidth()*(m-1),H=u.outerHeight()*(m-1),J=0;J<4;J++){var O=o[J],X=u.data("orig_margin-"+O);if(X==null){X=parseInt(u.css("margin-"+O));u.data("orig_margin-"+O,X)}X=X*m;if(O==="right")X+=E;else if(O==="bottom")X+=H;u.css("margin-"+O,X)}})},Mb=b.setIconSize=function(h,m){if(!(h==w.size&&!m)){var o=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"), +u=1;u=typeof h=="number"?h:{s:0.75,m:1,l:1.25,xl:1.5}[h];b.tool_scale=R=u;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,u);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();else o=a('').appendTo("head");if(h!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(X,ba){if(typeof ba==="number")var T=ba*u+"px";else if(ba[h]||ba.all)T= +ba[h]||ba.all;H+=X+":"+T+";"});H+="}"});E="-"+gb.toLowerCase()+"-";H+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+E+"transform: scale("+u+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/u+");}";o.text(H)}pa()}},Ab=function(){a("#dialog_box").hide(); if(ea){if(ea)ga!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(h){h&&Ya()}):Ya();Db()}else Ba&&g.leaveContext()},Ya=function(){a("#svg_source_editor").hide();ea=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var Db=a.noop;a(window).resize(function(){G()});(function(){K.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=K[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=K[0].scrollTop})})(); a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var h=g.getHref(Y);h=h.indexOf("data:")===0?"":h;a.prompt(uiStrings.notification.enterNewImgURL,h,function(m){m&&Ia(m)})});var e=function(h){var m=h[0].id=="stroke_color"?"stroke":"fill",o=h[0].id=="canvas_color";if(o)m="canvas";var u=b.paintBox[m].paint;h=m=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";o=o?{right:175,top:50}:{left:50,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker", containment:"window"}).removeAttr("style").css(o).jGraduate({paint:u,window:{pickerTitle:h},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){u=new a.jGraduate.Paint(E);b.paintBox[m].setPaint(u);g.setPaint(m,u);a("#color_picker").hide()},function(){a("#color_picker").hide()})};d=function(h,m){var o=document.getElementById("canvas_background"),u={color:"fff",opacity:1};if(m=="stroke")u=curConfig.initStroke;if(m=="fill")u=curConfig.initFill;if(m=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))u= {color:("0"+parseInt(o[1],10).toString(16)).slice(-2)+("0"+parseInt(o[2],10).toString(16)).slice(-2)+("0"+parseInt(o[3],10).toString(16)).slice(-2),opacity:1};o=(new DOMParser).parseFromString('\t\t\t\t\t',"text/xml").documentElement;o=a(h)[0].appendChild(document.importNode(o,true));m==="canvas"?o.setAttribute("width",60.5): -o.setAttribute("width","100%");this.rect=o.firstChild;this.defs=o.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:u.color});this.type=m;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,W=E.alpha/100;switch(O){case "solidColor":J=E[O]=="none"||E[O]=="one"?"none":"#"+E[O];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(E[O]);J="url(#"+(this.grad.id="gradbox_"+ -this.type)+")"}this.rect.setAttribute("fill",J);this.rect.setAttribute("opacity",W);if(this.type=="canvas")if(O=document.getElementById("canvas_background")){za=g.getResolution();O.setAttribute("x",-1);O.setAttribute("y",-1);O.setAttribute("width",za.w+2);O.setAttribute("height",za.h+2);J.indexOf("url")==-1&&O.setAttribute("fill",J)}else Ja(J);if(H){g.setColor(this.type,J,true);g.setPaintOpacity(this.type,W,true)}};this.update=function(E){if(Y){var H=this.type;switch(Y.tagName){case "use":case "image":case "foreignObject":return; -case "g":case "a":for(var J=null,O=Y.getElementsByTagName("*"),W=0,ba=O.length;W=1){W=g.getResolution();a("#canvas_width").val(W.w.toFixed());a("#canvas_height").val(W.h.toFixed());a("#resolution_label").html("
          "+W.w+"\u00d7
          "+W.h+"
          ")}else requestAnimationFrame(O)};O(Date.now())}else{a("#resolution_label").html("Custom");h.removeAttribute("readonly");h.focus();h.select();if(h.value=="fit"){h.value=100;m.value=100}}});a("#zoom").change(function(){wa(this)}); +if(!g.setResolution(o,u)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();h.val(o.w);m.val(o.h);return false}G()};a("#resolution").change(function(){var h=a("#canvas_width")[0],m=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){h.value="fit";m.value="fit";l();var o=g.getResolution();h.value=o.w;m.value=o.h}else{var u=this.value.split("x");u[0]=parseInt(u[0]);u[1]=parseInt(u[1]);var E=u[0]-h.value,H=u[1]-m.value,J=Date.now(),O=function(){var X=(Date.now()- +J)/1E3;X=Math.pow(X-1,3)+1;h.value=(u[0]-E+X*E).toFixed(0);m.value=(u[1]-H+X*H).toFixed(0);l();if(X>=1){X=g.getResolution();a("#canvas_width").val(X.w.toFixed());a("#canvas_height").val(X.h.toFixed());a("#resolution_label").html("
          "+X.w+"\u00d7
          "+X.h+"
          ")}else requestAnimationFrame(O)};O()}else{a("#resolution_label").html("Custom");h.removeAttribute("readonly");h.focus();h.select();if(h.value=="fit"){h.value=100;m.value=100}}});a("#zoom").change(function(){wa(this)}); a("input,select").attr("autocomplete","off");var C=function(){var h=[{sel:"#tool_select",fn:cb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Ta,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Va,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ga,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ta,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:db,evt:"click",key:["P",true]},{sel:"#tool_text",fn:Ha,evt:"click",key:["T",true]},{sel:"#tool_image",fn:$a,evt:"mouseup"}, {sel:"#tool_zoom",fn:Ka,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Oa,evt:"mouseup",key:[v+"N",true]},{sel:"#tool_save",fn:function(){if(ea)Kb();else{xa(a("#file_menu"));g.save({images:w.img_save,round_digits:6})}},evt:"mouseup",key:[v+"S",true]},{sel:"#tool_export",fn:nb,evt:"mouseup"},{sel:"#tool_open",fn:Ra,evt:"mouseup"},{sel:"#tool_import",fn:mb,evt:"mouseup"},{sel:"#tool_source",fn:Eb,evt:"click",key:[v+"U",true]},{sel:"#tool_wireframe",fn:Hb,evt:"click"},{sel:"#tool_snap",fn:Gb,evt:"click"}, {sel:"#tool_rulers",fn:Lb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:Ab,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Kb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:lb,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:ob,evt:"click"},{sel:"#tool_node_link",fn:tb,evt:"change"},{sel:"#tool_node_clone",fn:ia,evt:"click"},{sel:"#tool_node_delete",fn:aa,evt:"click"},{sel:"#tool_openclose_path", @@ -480,9 +480,9 @@ key:[v+"B",true]},{sel:"#tool_italic",fn:Za,evt:"mousedown",key:[v+"I",true]},{s 1)}},{key:["left",true],fn:function(){fb(-1,0)}},{key:["right",true],fn:function(){fb(1,0)}},{key:"shift+up",fn:function(){fb(0,-10)}},{key:"shift+down",fn:function(){fb(0,10)}},{key:"shift+left",fn:function(){fb(-10,0)}},{key:"shift+right",fn:function(){fb(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1, 0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:v+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var o=a(".tool_button_current");if(o.length&&o[0].id!=="tool_eyedropper"){o.removeClass("tool_button_current").addClass("tool_button"); a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},{key:v+"shift+z",fn:rb},{key:"esc",fn:Ib}],m={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var o={};a.each(h,function(u,E){if(E.sel){var H=a(E.sel);if(H.length==0)return true;if(E.evt){if(svgedit.browser.isTouch()&&E.evt==="click")E.evt="mousedown";H[E.evt](E.fn)}if(E.parent&&a(E.parent+"_show").length!=0){var J=a(E.parent);J.length||(J=na(E.parent.substr(1))); -J.append(H);a.isArray(o[E.parent])||(o[E.parent]=[]);o[E.parent].push(E)}}if(E.key){var O=E.fn,W=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)W=E.key[1]}else J=E.key;J+="";svgedit.browser.isMac&&J.indexOf("+")!=-1&&J.split("+")[0]=="ctrl"&&J.replace("ctrl","cmd");a.each(J.split("/"),function(T,fa){a(document).bind("keydown",fa,function(ha){O();W&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var ba=H.attr("title").split("[")[0]+" ("+J+")";m[J]=E.sel;H.parents("#main_menu").length|| -H.attr("title",ba)}}});Z(o);a(window).bind("keydown","tab",function(u){if(N==="canvas"){u.preventDefault();P()}}).bind("keydown","shift+tab",function(u){if(N==="canvas"){u.preventDefault();da()}});a("#tool_zoom").dblclick(Sa)},setTitles:function(){a.each(m,function(o,u){var E=a(u).parents("#main_menu").length;a(u).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,W){var ba=W.split("+"),T="";if(ba.length>1){T=ba[0]+"+";W=ba[1]}J+=(O? -"/":"")+T+(uiStrings["key_"+W]||W)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var u;a.each(h,function(E,H){if(H.sel===o)u=H});return u}}}();C.setAll();b.ready(function(){var h=curConfig.initTool,m=a("#tools_left, #svg_editor .tools_flyout"),o=m.find("#tool_"+h);h=m.find("#"+h);(o.length?o:h.length?h:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)}); +J.append(H);a.isArray(o[E.parent])||(o[E.parent]=[]);o[E.parent].push(E)}}if(E.key){var O=E.fn,X=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)X=E.key[1]}else J=E.key;J+="";svgedit.browser.isMac&&J.indexOf("+")!=-1&&J.split("+")[0]=="ctrl"&&J.replace("ctrl","cmd");a.each(J.split("/"),function(T,fa){a(document).bind("keydown",fa,function(ha){O();X&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var ba=H.attr("title").split("[")[0]+" ("+J+")";m[J]=E.sel;H.parents("#main_menu").length|| +H.attr("title",ba)}}});Z(o);a(window).bind("keydown","tab",function(u){if(N==="canvas"){u.preventDefault();P()}}).bind("keydown","shift+tab",function(u){if(N==="canvas"){u.preventDefault();da()}});a("#tool_zoom").dblclick(Sa)},setTitles:function(){a.each(m,function(o,u){var E=a(u).parents("#main_menu").length;a(u).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,X){var ba=X.split("+"),T="";if(ba.length>1){T=ba[0]+"+";X=ba[1]}J+=(O? +"/":"")+T+(uiStrings["key_"+X]||X)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var u;a.each(h,function(E,H){if(H.sel===o)u=H});return u}}}();C.setAll();b.ready(function(){var h=curConfig.initTool,m=a("#tools_left, #svg_editor .tools_flyout"),o=m.find("#tool_"+h);h=m.find("#"+h);(o.length?o:h.length?h:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)}); a("#canvas_height").dragInput({min:10,max:null,step:10,callback:l,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:l,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null, step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1, max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute, @@ -493,14 +493,14 @@ Y&&["line","polyline"].indexOf(Y.nodeName)>=0)m=h.value=1;g.setStrokeWidth(m)},c return o>=24?E?Math.round(o*1.1):Math.round(o/1.1):o<=1?E?o*2:o/2:u},dragAdjust:0.15});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(h,m){val=h.value;a("#blur").val(val);m?g.setBlur(val,true):g.setBlurNoUndo(val)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(h){switch(h){case "delete":lb();break;case "cut":Ua(); break;case "copy":Xa();break;case "paste":g.pasteElements();break;case "paste_in_place":g.pasteElements("in_place");break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":sa();break;case "move_up":ib("Up");break;case "move_down":ib("Down");break;case "move_back":hb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(h)&&svgedit.contextmenu.getCustomHandler(h).call()}});a(".contextMenu li").mousedown(function(h){h.preventDefault()}); a("#cmenu_canvas li").disableContextMenu();I.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(q.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(h){a("#main_menu").hide();q.getUndoStackSize()===0?h(true):a.confirm(uiStrings.notification.QwantToOpen,h)};if(window.FileReader){d=function(h){h.stopPropagation();h.preventDefault();a("#workarea").removeAttr("style"); -a("#main_menu").hide();var m=null;if(m=h.type=="drop"?h.dataTransfer.files[0]:this.files[0])if(m.type.indexOf("image")!=-1)if(m.type.indexOf("svg")!=-1){h=new FileReader;h.onloadend=function(o){g.importSvgString(o.target.result,true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};h.readAsText(m)}else{h=new FileReader;h.onloadend=function(o){insertNewImage=function(J,O){var W=g.addSvgElementFromJson({element:"image", -attr:{x:0,y:0,width:J,height:O,id:g.getNextId(),style:"pointer-events:inherit"}});g.setHref(W,o.target.result);g.selectOnly([W]);g.alignSelectedElements("m","page");g.alignSelectedElements("c","page");Fa()};var u=100,E=100,H=new Image;H.src=o.target.result;document.body.appendChild(H);H.onload=function(){u=H.offsetWidth;E=H.offsetHeight;insertNewImage(u,E);document.body.removeChild(H)}};h.readAsDataURL(m)}};K=a("#workarea");K[0].addEventListener("dragenter",function(h){h.stopPropagation();h.preventDefault(); +a("#main_menu").hide();var m=null;if(m=h.type=="drop"?h.dataTransfer.files[0]:this.files[0])if(m.type.indexOf("image")!=-1)if(m.type.indexOf("svg")!=-1){h=new FileReader;h.onloadend=function(o){g.importSvgString(o.target.result,true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};h.readAsText(m)}else{h=new FileReader;h.onloadend=function(o){insertNewImage=function(J,O){var X=g.addSvgElementFromJson({element:"image", +attr:{x:0,y:0,width:J,height:O,id:g.getNextId(),style:"pointer-events:inherit"}});g.setHref(X,o.target.result);g.selectOnly([X]);g.alignSelectedElements("m","page");g.alignSelectedElements("c","page");Fa()};var u=100,E=100,H=new Image;H.src=o.target.result;document.body.appendChild(H);H.onload=function(){u=H.offsetWidth;E=H.offsetHeight;insertNewImage(u,E);document.body.removeChild(H)}};h.readAsDataURL(m)}};K=a("#workarea");K[0].addEventListener("dragenter",function(h){h.stopPropagation();h.preventDefault(); K.css({"-webkit-transform":"scale3d(1.1,1.1,1)","-moz-transform":"scale3d(1.1,1.1,1)","-o-transform":"scale(1.1)","-ms-transform":"scale3d(1.1,1.1,1)",transform:"scale3d(1.1,1.1,1)"})},false);K[0].addEventListener("dragover",function(h){h.stopPropagation();h.preventDefault()},false);K[0].addEventListener("dragleave",function(h){K.removeAttr("style");h.stopPropagation();h.preventDefault()},false);K[0].addEventListener("drop",d,false);var A=a('').change(function(){var h=this;b.openPrep(function(m){if(m){g.clear(); -if(h.files.length==1){m=new FileReader;m.onloadend=function(o){s(o.target.result);G()};m.readAsText(h.files[0])}}})});a("#tool_open").show().prepend(A);d=a('').change(d);a("#tool_import").show().prepend(d)}var G=b.updateCanvas=function(h,m){var o=K.width(),u=K.height(),E=o,H=u,J=g.getZoom(),O=K,W=a("#svgcanvas"),ba={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},T=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*T);u=Math.max(H,g.contentH*J*T);o==E&&u==H?K.css("overflow","hidden"): -K.css("overflow","scroll");T=W.height()/2;var fa=W.width()/2;W.width(o).height(u);var ha=u/2,X=o/2,qa=g.updateCanvas(o,u),ua=X/fa;o=o/2-E/2;u=u/2-H/2;if(m){m.x+=qa.x;m.y+=qa.y}else m={x:X+(ba.x-fa)*ua,y:ha+(ba.y-T)*ua};if(h)if(g.contentW>O.width()){K[0].scrollLeft=qa.x-10;K[0].scrollTop=qa.y-10}else{O[0].scrollLeft=o;O[0].scrollTop=u}else{O[0].scrollLeft=m.x-E/2;O[0].scrollTop=m.y-H/2}if(curConfig.showRulers){E=W;J=J;document.getElementById("workarea");document.getElementById("title_show");J||(J= -g.getZoom());E||(E=a("#svgcanvas"));H=g.getContentElem();O=svgedit.units.getTypeMap()[curConfig.baseUnit];for(W=0;W<2;W++){fa=(ba=W===0)?"x":"y";ua=ba?"width":"height";T=H.getAttribute(fa)-0;fa=a("#ruler_"+fa+" canvas:first");$hcanv=fa.clone();fa.replaceWith($hcanv);o=$hcanv[0];ha=fa=E[ua]()*2;o.parentNode.style[ua]=ha+"px";X=0;var Aa;qa=o.getContext("2d");qa.fillStyle="rgb(200,0,0)";qa.fillRect(0,0,o.width,o.height);$hcanv.siblings().remove();if(fa>=3E4){var Ca=parseInt(fa/3E4)+1;Aa=Array(Ca);Aa[0]= +if(h.files.length==1){m=new FileReader;m.onloadend=function(o){s(o.target.result);G()};m.readAsText(h.files[0])}}})});a("#tool_open").show().prepend(A);d=a('').change(d);a("#tool_import").show().prepend(d)}var G=b.updateCanvas=function(h,m){var o=K.width(),u=K.height(),E=o,H=u,J=g.getZoom(),O=K,X=a("#svgcanvas"),ba={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},T=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*T);u=Math.max(H,g.contentH*J*T);o==E&&u==H?K.css("overflow","hidden"): +K.css("overflow","scroll");T=X.height()/2;var fa=X.width()/2;X.width(o).height(u);var ha=u/2,W=o/2,qa=g.updateCanvas(o,u),ua=W/fa;o=o/2-E/2;u=u/2-H/2;if(m){m.x+=qa.x;m.y+=qa.y}else m={x:W+(ba.x-fa)*ua,y:ha+(ba.y-T)*ua};if(h)if(g.contentW>O.width()){K[0].scrollLeft=qa.x-10;K[0].scrollTop=qa.y-10}else{O[0].scrollLeft=o;O[0].scrollTop=u}else{O[0].scrollLeft=m.x-E/2;O[0].scrollTop=m.y-H/2}if(curConfig.showRulers){E=X;J=J;document.getElementById("workarea");document.getElementById("title_show");J||(J= +g.getZoom());E||(E=a("#svgcanvas"));H=g.getContentElem();O=svgedit.units.getTypeMap()[curConfig.baseUnit];for(X=0;X<2;X++){fa=(ba=X===0)?"x":"y";ua=ba?"width":"height";T=H.getAttribute(fa)-0;fa=a("#ruler_"+fa+" canvas:first");$hcanv=fa.clone();fa.replaceWith($hcanv);o=$hcanv[0];ha=fa=E[ua]()*2;o.parentNode.style[ua]=ha+"px";W=0;var Aa;qa=o.getContext("2d");qa.fillStyle="rgb(200,0,0)";qa.fillRect(0,0,o.width,o.height);$hcanv.siblings().remove();if(fa>=3E4){var Ca=parseInt(fa/3E4)+1;Aa=Array(Ca);Aa[0]= qa;for(u=1;u=1)u=Math.round(Ca);else{u=(o+"").split(".")[1].length; -u=Ca.toFixed(u)-0}if(u!==0&&u!==1E3&&u%1E3===0)u=u/1E3+"K";if(ba){qa.fillText(u,Na+2,8);qa.fillStyle="#777"}else{Ca=(u+"").split("");for(u=0;ufa){X++;qa.stroke();if(X>=Aa.length){u=10;Na=ha;continue}qa=Aa[X];Na-=3E4;ub=Math.round(Na+Ca*u)+0.5}var Cb=u%2?12:10;if(ba){qa.moveTo(ub,15);qa.lineTo(ub,Cb)}else{qa.moveTo(15,ub);qa.lineTo(Cb,ub)}}}qa.strokeStyle="#666";qa.stroke()}K.scroll()}}, +u=Ca.toFixed(u)-0}if(u!==0&&u!==1E3&&u%1E3===0)u=u/1E3+"K";if(ba){qa.fillText(u,Na+2,8);qa.fillStyle="#777"}else{Ca=(u+"").split("");for(u=0;ufa){W++;qa.stroke();if(W>=Aa.length){u=10;Na=ha;continue}qa=Aa[W];Na-=3E4;ub=Math.round(Na+Ca*u)+0.5}var Cb=u%2?12:10;if(ba){qa.moveTo(ub,15);qa.lineTo(ub,Cb)}else{qa.moveTo(15,ub);qa.lineTo(Cb,ub)}}}qa.strokeStyle="#666";qa.stroke()}K.scroll()}}, D=[];for(d=0.1;d<1E5;d*=10){D.push(1*d);D.push(2*d);D.push(5*d)}G(true);try{var z=function(h){if(window.JSON&&JSON.stringify)return JSON.stringify(h);var m=arguments.callee;if(typeof h=="boolean"||typeof h=="number")return h+"";else if(typeof h=="string")return'"'+h.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(E){return"\\u"+("0000"+E.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(h.length){for(var o= 0;o