added gray colors, improved the pen tool

master
Mark MacKay 2012-09-08 21:19:25 -05:00
parent adc3918eb8
commit 721816008d
14 changed files with 288 additions and 268 deletions

View File

@ -314,6 +314,7 @@ svgedit.path.getSegSelector = function(seg, update) {
'display': 'none',
'fill': "none",
'stroke': "#0ff",
'stroke-opacity': 1,
"shape-rendering": "crispEdges",
'stroke-width': 2,
'style':'pointer-events:none',
@ -429,7 +430,8 @@ svgedit.path.Segment.prototype.show = function(y) {
svgedit.path.Segment.prototype.select = function(y) {
if(this.ptgrip) {
this.ptgrip.setAttribute("stroke", y ? "#0FF" : "#00F");
this.ptgrip.setAttribute("stroke", y ? "#4F80FF" : "#4F80FF");
this.ptgrip.setAttribute("fill", y ? "#4F80FF" : "#fff");
this.segsel.setAttribute("display", y ? "inline" : "none");
if(this.ctrlpts) {
this.selectCtrls(y);

View File

@ -287,7 +287,7 @@ html, body {
.palette_item {
height: 20%;
width: 5.4%;
width: 5.2%;
float: left;
cursor: url(images/eyedropper.png) 0 16, crosshair;
}
@ -1872,6 +1872,10 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
cursor: -moz-grab;
}
.draginput input[type="checkbox"], .draginput input[type="checkbox"]:hover, .draginput input[type="checkbox"]:active {
cursor: default;
}
.draginput.active input, .draginput.active input:hover, .draginput.active input:active {
cursor: url(images/dragging.png), move;
cursor: -webkit-grabbing;

View File

@ -330,25 +330,25 @@
Editor.canvas = svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas"), curConfig);
Editor.show_save_warning = false;
Editor.paintBox = {fill: null, stroke:null, canvas:null};
var palette = ["#482816", "#422C10", "#3B2F0E", "#32320F",
var palette = ["#444444", "#482816", "#422C10", "#3B2F0E", "#32320F",
"#293414", "#1F361B", "#153723", "#0C372C",
"#083734", "#0E353B", "#1A333F", "#273141",
"#332D40", "#3E2A3C", "#462735", "#4B252D",
"#4D2425", "#4C261D", "#845335", "#7B572D",
"#4D2425", "#4C261D", "#666666", "#845335", "#7B572D",
"#6F5C2A", "#62612C", "#546433", "#46673D",
"#396849", "#306856", "#2D6862", "#33666C",
"#426373", "#535F75", "#645A73", "#74556D",
"#805064", "#884D58", "#8B4D4B", "#894F3F",
"#C48157", "#B8874D", "#A98E49", "#97944B",
"#999999", "#C48157", "#B8874D", "#A98E49", "#97944B",
"#849854", "#729C62", "#619E73", "#559E84",
"#529D94", "#5B9BA2", "#6D97AB", "#8391AE",
"#9A8AAB", "#AF84A3", "#BF7E96", "#C97A86",
"#CE7975", "#CC7C65", "#FFB27C", "#FABA6F",
"#CE7975", "#CC7C65", "#BBBBBB", "#FFB27C", "#FABA6F",
"#E6C36A", "#CFCA6D", "#B8D078", "#A0D58A",
"#8CD79F", "#7DD8B5", "#7AD6CA", "#84D3DB",
"#9ACEE6", "#B6C7EA", "#D3BEE7", "#EDB6DC",
"#FFAFCC", "#FFAAB8", "#FFA9A2", "#FFAC8D",
"#FFE7A2", "#FFF093", "#FFFA8D", "#FFFF91",
"#DDDDDD", "#FFE7A2", "#FFF093", "#FFFA8D", "#FFFF91",
"#EEFF9F", "#D1FFB4", "#B9FFCE", "#A8FFE9",
"#A4FFFF", "#B1FFFF", "#CBFFFF", "#EDFFFF",
"#FFF5FF", "#FFEBFF", "#FFE2FF", "#FFDCEC",
@ -2183,13 +2183,16 @@
svgCanvas.setMode('path');
}
};
console.log(path.getNodePoint());
// Delete is a contextual tool that only appears in the ribbon if
// an element has been selected
var deleteSelected = function() {
if (selectedElement != null || multiselected) {
svgCanvas.deleteSelectedElements();
}
if (path.getNodePoint()) {
path.deletePathNode();
}
};
var cutSelected = function() {
@ -2290,12 +2293,7 @@
};
var linkControlPoints = function() {
var linked = !$('#tool_node_link').hasClass('checked');
if (linked)
$('#tool_node_link').addClass('checked').find("input").attr("checked", true);
else
$('#tool_node_link').removeClass('checked').find("input").attr("checked", false);
var linked = !$('#tool_node_link').hasClass('checked');
path.linkControlPoints(linked);
}

View File

@ -4682,6 +4682,7 @@ var pathActions = canvas.pathActions = function() {
}
},
getNodePoint: function() {
if (!svgedit.path.path) return;
var sel_pt = svgedit.path.path.selected_pts.length ? svgedit.path.path.selected_pts[0] : 1;
var seg = svgedit.path.path.segs[sel_pt];
@ -4886,7 +4887,7 @@ var pathActions = canvas.pathActions = function() {
// Completely delete a path with 1 or 0 segments
if(svgedit.path.path.elem.pathSegList.numberOfItems <= 1) {
pathActions.toSelectMode(svgedit.path.path.elem);
canvas.setMode("select")
canvas.deleteSelectedElements();
return;
}

View File

@ -131,7 +131,7 @@ html,body{overflow:hidden;width:100%;height:100%}
#ruler_y canvas{margin-top:-16px}
#ruler_x>div,#ruler_y>div{overflow:hidden}
#palette{display:block;position:absolute;z-index:2;left:10px;bottom:5px;width:410px;right:145px;height:30px}
.palette_item{height:20%;width:5.4%;float:left;cursor:url(images/eyedropper.png) 0 16,crosshair}
.palette_item{height:20%;width:5.2%;float:left;cursor:url(images/eyedropper.png) 0 16,crosshair}
.palette_item.transparent,.palette_item.white,.palette_item.black{background:#fff;position:absolute;width:10px;height:10px;left:-10px;top:0}
.palette_item.transparent{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAAVdEVYdENyZWF0aW9uIFRpbWUAOC8yMi8xMg1cp6sAAABESURBVBiVjdBBCgAgCETRr/e/87SJKFPLnfIcQRMIwMBIShIAvgZzoSrfkzrs8WyF1+kX9r3p8AE7nL7kSpSshN+JEQ8GixkF0mSevgAAAABJRU5ErkJggg==)}
.palette_item.black{background:#000;top:10px}
@ -381,6 +381,7 @@ button.cancel,input.Cancel,input.cancel,input.jGraduate_Cancel,button.cancel{-we
#preview_font{font-size:20px;color:#fff;height:70px;line-height:75px;padding:0 0 0 10px;white-space:nowrap;width:100px;overflow:hidden;border-right:solid #2f2f2c 2px;position:relative}
#preview_font:after{content:'';position:absolute;right:0;top:3px;bottom:3px;width:15px;border-right:solid #3f3f3c 10px;background:transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iZzU4MCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMTAwJSIgeTI9IjAlIj48c3RvcCBzdG9wLWNvbG9yPSIjM2YzZjNjIiBzdG9wLW9wYWNpdHk9IjAiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiMzZjNmM2MiIG9mZnNldD0iMC43Ii8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2c1ODApIiAvPjwvc3ZnPg==)}
.draginput input,.draginput input:hover,.draginput input:active{cursor:url(images/drag.png),move;cursor:-webkit-grab;cursor:-moz-grab}
.draginput input[type="checkbox"],.draginput input[type="checkbox"]:hover,.draginput input[type="checkbox"]:active{cursor:default}
.draginput.active input,.draginput.active input:hover,.draginput.active input:active{cursor:url(images/dragging.png),move;cursor:-webkit-grabbing;cursor:-moz-grabbing}
.draginput span{font:11px/130% sans-serif;color:#ccc;display:block;position:absolute;top:5px;left:5px;text-align:left}
.draginput.error{background:#900}

View File

@ -173,25 +173,25 @@ C=u.appendChild(C);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&
svgedit.utilities.getElem("ctrlLine_"+f);if(c)return c;c=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(c,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(c);return c};svgedit.path.getPointGrip=function(f,c){var m=svgedit.path.addPointGrip(f.index);if(c){var u=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(m,{x:u.x-(svgedit.browser.isTouch()?15:2.5),y:u.y-(svgedit.browser.isTouch()?
15:2.5),display:"inline"})}return m};svgedit.path.getControlPoints=function(f){var c=f.item,m=f.index;if(!("x1"in c)||!("x2"in c))return null;var u={};svgedit.path.getGripContainer();for(var C=[svgedit.path.path.segs[m-1].item,c],s=1;s<3;s++){var L=m+"c"+s,Q=u["c"+s+"_line"]=svgedit.path.getCtrlLine(L),K=svgedit.path.getGripPt(f,{x:c["x"+s],y:c["y"+s]}),I=svgedit.path.getGripPt(f,{x:C[s-1].x,y:C[s-1].y});svgedit.utilities.assignAttributes(Q,{x1:K.x,y1:K.y,x2:I.x,y2:I.y,display:"inline"});u["c"+s+
"_line"]=Q;pointGrip=u["c"+s]=svgedit.path.addCtrlGrip(L);svgedit.utilities.assignAttributes(pointGrip,{cx:K.x,cy:K.y,display:"inline"});u["c"+s]=pointGrip}return u};svgedit.path.replacePathSeg=function(f,c,m,u){u=u||svgedit.path.path.elem;f=u["createSVGPathSeg"+g[f]].apply(u,m);if(svgedit.browser.supportsPathReplaceItem())u.pathSegList.replaceItem(f,c);else{m=u.pathSegList;u=m.numberOfItems;for(var C=[],s=0;s<u;s++){var L=m.getItem(s);C.push(L)}m.clear();for(s=0;s<u;s++)s==c?m.appendItem(f):m.appendItem(C[s])}};
svgedit.path.getSegSelector=function(f,c){var m=f.index,u=svgedit.utilities.getElem("segline_"+m);if(!u){var C=svgedit.path.getGripContainer();u=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(u,{id:"segline_"+m,display:"none",fill:"none",stroke:"#0ff","shape-rendering":"crispEdges","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});C.appendChild(u)}if(c){m=f.prev;if(!m){u.setAttribute("display","none");return u}m=svgedit.path.getGripPt(m);
svgedit.path.getSegSelector=function(f,c){var m=f.index,u=svgedit.utilities.getElem("segline_"+m);if(!u){var C=svgedit.path.getGripContainer();u=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(u,{id:"segline_"+m,display:"none",fill:"none",stroke:"#0ff","stroke-opacity":1,"shape-rendering":"crispEdges","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});C.appendChild(u)}if(c){m=f.prev;if(!m){u.setAttribute("display","none");return u}m=svgedit.path.getGripPt(m);
svgedit.path.replacePathSeg(2,0,[m.x,m.y],u);C=svgedit.path.ptObjToArr(f.type,f.item,true);for(var s=0;s<C.length;s+=2){m=svgedit.path.getGripPt(f,{x:C[s],y:C[s+1]});C[s]=m.x;C[s+1]=m.y}svgedit.path.replacePathSeg(f.type,1,C,u)}return u};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,c,m){var u=f.x-m.x,C=f.y-m.y,s=c.x-m.x,L=c.y-m.y;if((u!=0||C!=0)&&(s!=0||L!=0)){f=Math.atan2(C,u);c=Math.atan2(L,s);u=Math.sqrt(u*u+C*C);s=Math.sqrt(s*s+L*L);C=v.getSVGRoot().createSVGPoint();L=
v.getSVGRoot().createSVGPoint();if(f<0)f+=2*Math.PI;if(c<0)c+=2*Math.PI;var Q=Math.abs(f-c),K=Math.abs(Math.PI-Q)/2;if(f-c>0){f=Q<Math.PI?f+K:f-K;c=Q<Math.PI?c-K:c+K}else{f=Q<Math.PI?f-K:f+K;c=Q<Math.PI?c+K:c-K}C.x=u*Math.cos(f)+m.x;C.y=u*Math.sin(f)+m.y;L.x=s*Math.cos(c)+m.x;L.y=s*Math.sin(c)+m.y;return[C,L]}};svgedit.path.Segment=function(f,c){this.selected=false;this.index=f;this.item=c;this.type=c.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=
function(f){for(var c in this.ctrlpts)this.ctrlpts[c].setAttribute("display",f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",
f?"#0FF":"#00F");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var c=svgedit.path.getGripPt(this),m=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,
this.ptgrip.nodeName=="rect"?{x:c.x-m,y:c.y-m}:{cx:c.x,cy:c.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,c){var m=this.item;m=this.ctrlpts?[m.x+=f,m.y+=c,m.x1,m.y1,m.x2+=f,m.y2+=c]:[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.type,this.index,m);if(this.next&&this.next.ctrlpts){m=this.next.item;
m=[m.x,m.y,m.x1+=f,m.y1+=c,m.x2,m.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,m)}if(this.mate){m=this.mate.item;m=[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,m)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var c,m,u;if(f==2){m=1;c=this.next;if(!c)return;u=this.item}else{m=2;c=this.prev;if(!c)return;u=c.item}var C=c.item;C["x"+m]=u.x+(u.x-this.item["x"+f]);C["y"+m]=u.y+(u.y-this.item["y"+
f]);svgedit.path.replacePathSeg(c.type,c.index,[C.x,C.y,C.x1,C.y1,C.x2,C.y2]);c.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,c,m){var u=this.item;u["x"+f]+=c;u["y"+f]+=m;svgedit.path.replacePathSeg(this.type,this.index,[u.x,u.y,u.x1,u.y1,u.x2,u.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,c){svgedit.path.replacePathSeg(f,this.index,c);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);
this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,c=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var m=0;m<c;m++){var u=f.getItem(m);u=new svgedit.path.Segment(m,u);
u.path=this;this.segs.push(u)}f=this.segs;u=null;for(m=0;m<c;m++){var C=f[m],s=m+1>=c?null:f[m+1],L=m-1<0?null:f[m-1];if(C.type===2){if(L&&L.type!==1){s=f[u];s.next=f[u+1];s.next.prev=s;s.addGrip()}u=m}else if(s&&s.type===1){C.next=f[u+1];C.next.prev=C;C.mate=f[u];C.addGrip();if(this.first_seg==null)this.first_seg=C}else if(s){if(C.type!==1){C.addGrip();if(s&&s.type!==2){C.next=s;C.next.prev=C}}}else if(C.type!==1){s=f[u];s.next=f[u+1];s.next.prev=s;s.addGrip();C.addGrip();if(!this.first_seg)this.first_seg=
f[u]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var c=this.segs.length,m=0;m<c;m++)if(f.call(this.segs[m],m)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var c=this.segs[f];if(c.prev){var m=c.prev,u;switch(c.item.pathSegType){case 4:var C=(c.item.x+m.item.x)/2,s=(c.item.y+m.item.y)/2;u=this.elem.createSVGPathSegLinetoAbs(C,s);break;case 6:u=(m.item.x+c.item.x1)/2;var L=(c.item.x1+c.item.x2)/2,Q=(c.item.x2+c.item.x)/2,K=(u+L)/2;L=(L+Q)/2;C=(K+L)/2;var I=(m.item.y+
c.item.y1)/2,S=(c.item.y1+c.item.y2)/2;m=(c.item.y2+c.item.y)/2;var R=(I+S)/2;S=(S+m)/2;s=(R+S)/2;u=this.elem.createSVGPathSegCurvetoCubicAbs(C,s,u,I,K,R);svgedit.path.replacePathSeg(c.type,f,[c.item.x,c.item.y,L,S,Q,m])}svgedit.path.insertItemBefore(this.elem,u,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var c=this.segs[f],m=this.elem.pathSegList;c.show(false);var u=c.next;if(c.mate){var C=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,u.index,C);svgedit.path.replacePathSeg(4,c.index,
C);m.removeItem(c.mate.index)}else{if(!c.prev){C=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,c.next.index,C)}m.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var c=false;svgedit.path.path.eachSeg(function(m){if(m<=f)return true;if(this.type===2)return false;else if(this.type===1){c=true;return false}});return c};svgedit.path.Path.prototype.removePtFromSelection=function(f){var c=this.selected_pts.indexOf(f);if(c!=-1){this.segs[f].select(false);this.selected_pts.splice(c,
1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,c){for(var m=this.selected_pts.length;m--;)this.segs[this.selected_pts[m]].move(f,c)};svgedit.path.Path.prototype.moveCtrl=
function(f,c){var m=this.segs[this.selected_pts[0]];m.moveCtrl(this.dragctrl,f,c);b&&m.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var c=this.selected_pts.length,m;c--;){var u=this.segs[this.selected_pts[c]],C=u.prev;if(C){if(!f){m="Toggle Path Segment Type";f=u.type==6?4:6}f-=0;var s=u.item.x,L=u.item.y,Q=C.item.x;C=C.item.y;var K;switch(f){case 6:if(u.olditem){Q=u.olditem;K=[s,L,Q.x1,Q.y1,Q.x2,Q.y2]}else{K=s-Q;var I=L-C;K=[s,L,Q+K/3,C+I/3,s-K/3,
L-I/3]}break;case 4:K=[s,L];u.olditem=u.item}u.setType(f,K)}}svgedit.path.path.endChanges(m)};svgedit.path.Path.prototype.selectPt=function(f,c){this.clearSelection();f==null&&this.eachSeg(function(m){if(this.prev)f=m});this.addPtsToSelection(f);if(c){this.dragctrl=c;b&&this.segs[f].setLinked(c)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=
null;this.eachSeg(function(c){this.item=f.pathSegList.getItem(c);this.update()});return this};svgedit.path.getPath_=function(f){var c=p[f.id];c||(c=p[f.id]=new svgedit.path.Path(f));return c};svgedit.path.removePath_=function(f){f in p&&delete p[f]};var d=function(f,c,m,u,C,s,L){dx=f-m;dy=c-u;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+L;dx=r*Math.cos(theta)+m;dy=r*Math.sin(theta)+u;dx-=C;dy-=s;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-L;return{x:(r*Math.cos(theta)+C)/1,y:(r*Math.sin(theta)+
s)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,c=svgedit.utilities.getRotationAngle(f,true);if(c){var m=svgedit.utilities.getBBox(f),u=svgedit.path.path.oldbbox,C=u.x+u.width/2;u=u.y+u.height/2;var s=m.x+m.width/2;m=m.y+m.height/2;s=s-C;var L=m-u;m=Math.sqrt(s*s+L*L);L=Math.atan2(L,s)+c;s=m*Math.cos(L)+C;m=m*Math.sin(L)+u;L=f.pathSegList;for(var Q=L.numberOfItems;Q;){Q-=1;var K=L.getItem(Q),I=K.pathSegType;if(I!=1){var S=d(K.x,K.y,C,u,s,m,c);S=[S.x,S.y];if(K.x1!=null&&
K.x2!=null){c_vals1=d(K.x1,K.y1,C,u,s,m,c);c_vals2=d(K.x2,K.y2,C,u,s,m,c);S.splice(S.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(I,Q,S)}}svgedit.utilities.getBBox(f);C=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);C.setRotate(c*180/Math.PI,s,m);f.replaceItem(C,0)}};svgedit.path.clearData=function(){p={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
f?"#4F80FF":"#4F80FF");this.ptgrip.setAttribute("fill",f?"#4F80FF":"#fff");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var c=svgedit.path.getGripPt(this),m=svgedit.browser.isTouch()?
15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:c.x-m,y:c.y-m}:{cx:c.x,cy:c.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,c){var m=this.item;m=this.ctrlpts?[m.x+=f,m.y+=c,m.x1,m.y1,m.x2+=f,m.y2+=c]:[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.type,this.index,
m);if(this.next&&this.next.ctrlpts){m=this.next.item;m=[m.x,m.y,m.x1+=f,m.y1+=c,m.x2,m.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,m)}if(this.mate){m=this.mate.item;m=[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,m)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var c,m,u;if(f==2){m=1;c=this.next;if(!c)return;u=this.item}else{m=2;c=this.prev;if(!c)return;u=c.item}var C=c.item;C["x"+m]=u.x+(u.x-
this.item["x"+f]);C["y"+m]=u.y+(u.y-this.item["y"+f]);svgedit.path.replacePathSeg(c.type,c.index,[C.x,C.y,C.x1,C.y1,C.x2,C.y2]);c.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,c,m){var u=this.item;u["x"+f]+=c;u["y"+f]+=m;svgedit.path.replacePathSeg(this.type,this.index,[u.x,u.y,u.x1,u.y1,u.x2,u.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,c){svgedit.path.replacePathSeg(f,this.index,c);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);
this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,c=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;
for(var m=0;m<c;m++){var u=f.getItem(m);u=new svgedit.path.Segment(m,u);u.path=this;this.segs.push(u)}f=this.segs;u=null;for(m=0;m<c;m++){var C=f[m],s=m+1>=c?null:f[m+1],L=m-1<0?null:f[m-1];if(C.type===2){if(L&&L.type!==1){s=f[u];s.next=f[u+1];s.next.prev=s;s.addGrip()}u=m}else if(s&&s.type===1){C.next=f[u+1];C.next.prev=C;C.mate=f[u];C.addGrip();if(this.first_seg==null)this.first_seg=C}else if(s){if(C.type!==1){C.addGrip();if(s&&s.type!==2){C.next=s;C.next.prev=C}}}else if(C.type!==1){s=f[u];s.next=
f[u+1];s.next.prev=s;s.addGrip();C.addGrip();if(!this.first_seg)this.first_seg=f[u]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var c=this.segs.length,m=0;m<c;m++)if(f.call(this.segs[m],m)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var c=this.segs[f];if(c.prev){var m=c.prev,u;switch(c.item.pathSegType){case 4:var C=(c.item.x+m.item.x)/2,s=(c.item.y+m.item.y)/2;u=this.elem.createSVGPathSegLinetoAbs(C,s);break;case 6:u=(m.item.x+c.item.x1)/2;var L=(c.item.x1+
c.item.x2)/2,Q=(c.item.x2+c.item.x)/2,K=(u+L)/2;L=(L+Q)/2;C=(K+L)/2;var I=(m.item.y+c.item.y1)/2,S=(c.item.y1+c.item.y2)/2;m=(c.item.y2+c.item.y)/2;var R=(I+S)/2;S=(S+m)/2;s=(R+S)/2;u=this.elem.createSVGPathSegCurvetoCubicAbs(C,s,u,I,K,R);svgedit.path.replacePathSeg(c.type,f,[c.item.x,c.item.y,L,S,Q,m])}svgedit.path.insertItemBefore(this.elem,u,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var c=this.segs[f],m=this.elem.pathSegList;c.show(false);var u=c.next;if(c.mate){var C=[u.item.x,u.item.y];
svgedit.path.replacePathSeg(2,u.index,C);svgedit.path.replacePathSeg(4,c.index,C);m.removeItem(c.mate.index)}else{if(!c.prev){C=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,c.next.index,C)}m.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var c=false;svgedit.path.path.eachSeg(function(m){if(m<=f)return true;if(this.type===2)return false;else if(this.type===1){c=true;return false}});return c};svgedit.path.Path.prototype.removePtFromSelection=function(f){var c=this.selected_pts.indexOf(f);
if(c!=-1){this.segs[f].select(false);this.selected_pts.splice(c,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,c){for(var m=this.selected_pts.length;m--;)this.segs[this.selected_pts[m]].move(f,
c)};svgedit.path.Path.prototype.moveCtrl=function(f,c){var m=this.segs[this.selected_pts[0]];m.moveCtrl(this.dragctrl,f,c);b&&m.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var c=this.selected_pts.length,m;c--;){var u=this.segs[this.selected_pts[c]],C=u.prev;if(C){if(!f){m="Toggle Path Segment Type";f=u.type==6?4:6}f-=0;var s=u.item.x,L=u.item.y,Q=C.item.x;C=C.item.y;var K;switch(f){case 6:if(u.olditem){Q=u.olditem;K=[s,L,Q.x1,Q.y1,Q.x2,Q.y2]}else{K=
s-Q;var I=L-C;K=[s,L,Q+K/3,C+I/3,s-K/3,L-I/3]}break;case 4:K=[s,L];u.olditem=u.item}u.setType(f,K)}}svgedit.path.path.endChanges(m)};svgedit.path.Path.prototype.selectPt=function(f,c){this.clearSelection();f==null&&this.eachSeg(function(m){if(this.prev)f=m});this.addPtsToSelection(f);if(c){this.dragctrl=c;b&&this.segs[f].setLinked(c)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=
this.matrix=null;this.eachSeg(function(c){this.item=f.pathSegList.getItem(c);this.update()});return this};svgedit.path.getPath_=function(f){var c=p[f.id];c||(c=p[f.id]=new svgedit.path.Path(f));return c};svgedit.path.removePath_=function(f){f in p&&delete p[f]};var d=function(f,c,m,u,C,s,L){dx=f-m;dy=c-u;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+L;dx=r*Math.cos(theta)+m;dy=r*Math.sin(theta)+u;dx-=C;dy-=s;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-L;return{x:(r*Math.cos(theta)+C)/1,y:(r*
Math.sin(theta)+s)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,c=svgedit.utilities.getRotationAngle(f,true);if(c){var m=svgedit.utilities.getBBox(f),u=svgedit.path.path.oldbbox,C=u.x+u.width/2;u=u.y+u.height/2;var s=m.x+m.width/2;m=m.y+m.height/2;s=s-C;var L=m-u;m=Math.sqrt(s*s+L*L);L=Math.atan2(L,s)+c;s=m*Math.cos(L)+C;m=m*Math.sin(L)+u;L=f.pathSegList;for(var Q=L.numberOfItems;Q;){Q-=1;var K=L.getItem(Q),I=K.pathSegType;if(I!=1){var S=d(K.x,K.y,C,u,s,m,c);S=[S.x,S.y];
if(K.x1!=null&&K.x2!=null){c_vals1=d(K.x1,K.y1,C,u,s,m,c);c_vals2=d(K.x2,K.y2,C,u,s,m,c);S.splice(S.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(I,Q,S)}}svgedit.utilities.getBBox(f);C=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);C.setRotate(c*180/Math.PI,s,m);f.replaceItem(C,0)}};svgedit.path.clearData=function(){p={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(q,g){var b=this.length;if(!b)return a.apply(this,arguments);for(var p=0;p<b;p++){var v=this[p];if(v.namespaceURI==="http://www.w3.org/2000/svg")if(g!==undefined)v.setAttribute(q,g);else if($.isArray(q)){b=q.length;for(p={};b--;){var d=q[b],f=v.getAttribute(d);if(f||f==="0")f=isNaN(f)?f:f-0;p[d]=f}return p}else if(typeof q==="object")for(d in q)v.setAttribute(d,q[d]);else{if((f=v.getAttribute(q))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,
arguments)}return this}})();
$.SvgCanvas=function(a,q){function g(e,h){for(var l=svgedit.utilities.getBBox(e),B=0;B<2;B++){var A=B===0?"fill":"stroke",G=e.getAttribute(A);if(G&&G.indexOf("url(")===0){G=P(G);if(G.tagName==="linearGradient"){var D=G.getAttribute("x1")||0,z=G.getAttribute("y1")||0,F=G.getAttribute("x2")||1,k=G.getAttribute("y2")||0;D=l.width*D+l.x;z=l.height*z+l.y;F=l.width*F+l.x;k=l.height*k+l.y;D=N(D,z,h);k=N(F,k,h);F={};F.x1=(D.x-l.x)/l.width;F.y1=(D.y-l.y)/l.height;F.x2=(k.x-l.x)/l.width;F.y2=(k.y-l.y)/l.height;
@ -289,30 +289,30 @@ this.prev){var O=sa.getBBox(),Y=svgedit.path.getGripPt(this);O=svgedit.math.rect
!D.shiftKey&&!G&&svgedit.path.path.selectPt(F)}else if(sa&&sa.getAttribute("display")!="none"){sa.setAttribute("display","none");sa.getAttribute("width")<=2&&sa.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=svgedit.path.getPath_(D);Ga="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;
Ga="select";svgedit.path.path.show(false);h=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(z){M("selected",[D]);qb([D],true)}},addSubPath:function(D){if(D){Ga="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(h===D){La.toEditMode(D);Ga="pathedit"}else h=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(){h=null;if(A){var D=pa(aa());$(pa("path_stretch_line")).remove();$(D).remove();$(pa("pathpointgrip_container")).find("*").attr("display","none");A=B=null;Ka=false}else Ga=="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=X(z).matrix;
z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var k=z.numberOfItems,n=0;n<k;++n){var o=z.getItem(n),w=o.pathSegType;if(w!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],Y=o["y"+J];if(O!==undefined&&Y!==undefined){O=N(O,Y,F);E.splice(E.length,0,O.x,O.y)}});svgedit.path.replacePathSeg(w,n,E,D)}}g(D,F)},zoomChange:function(){Ga=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:
1];return{x:D.item.x,y:D.item.y,type:D.type}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var k=D[z];svgedit.path.path.addSeg(k);F.push(k+z);F.push(k+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var z=svgedit.path.path.elem,
F=z.pathSegList,k=D[0],n=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=k)o=this.item;if(J<=k)return true;if(this.type===2){n=J;return false}else if(this.type===1)return n=false});if(n==null)n=svgedit.path.path.segs.length-1;if(n!==false){var w=z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(n==svgedit.path.path.segs.length){F.appendItem(w);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,n);svgedit.path.insertItemBefore(z,w,n)}svgedit.path.path.init().selectPt(n+
1)}else if(svgedit.path.path.segs[k].mate){F.removeItem(k);F.removeItem(k);svgedit.path.path.init().selectPt(k-1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)w=D;else if(D===k)F.removeItem(w);else if(H.pathSegType===1&&k<D){E=D-1;F.removeItem(D);break}}for(D=k-w-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(w),E);z=F.getItem(w);svgedit.path.replacePathSeg(2,w,[z.x,z.y]);D=k;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();
z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var k=z.numberOfItems,n=0;n<k;++n){var o=z.getItem(n),w=o.pathSegType;if(w!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],Y=o["y"+J];if(O!==undefined&&Y!==undefined){O=N(O,Y,F);E.splice(E.length,0,O.x,O.y)}});svgedit.path.replacePathSeg(w,n,E,D)}}g(D,F)},zoomChange:function(){Ga=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){if(svgedit.path.path){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?
svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var k=D[z];svgedit.path.path.addSeg(k);F.push(k+z);F.push(k+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===
1){var z=svgedit.path.path.elem,F=z.pathSegList,k=D[0],n=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=k)o=this.item;if(J<=k)return true;if(this.type===2){n=J;return false}else if(this.type===1)return n=false});if(n==null)n=svgedit.path.path.segs.length-1;if(n!==false){var w=z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(n==svgedit.path.path.segs.length){F.appendItem(w);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,n);svgedit.path.insertItemBefore(z,
w,n)}svgedit.path.path.init().selectPt(n+1)}else if(svgedit.path.path.segs[k].mate){F.removeItem(k);F.removeItem(k);svgedit.path.path.init().selectPt(k-1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)w=D;else if(D===k)F.removeItem(w);else if(H.pathSegType===1&&k<D){E=D-1;F.removeItem(D);break}}for(D=k-w-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(w),E);z=F.getItem(w);svgedit.path.replacePathSeg(2,w,[z.x,z.y]);D=k;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();
for(var D=svgedit.path.path.selected_pts,z=D.length;z--;)svgedit.path.path.deleteSeg(D[z]);var F=function(){var k=svgedit.path.path.elem.pathSegList,n=k.numberOfItems,o=function(H,J){for(;J--;)k.removeItem(H)};if(n<=1)return true;for(;n--;){var w=k.getItem(n);if(w.pathSegType===1){w=k.getItem(n-1);var E=k.getItem(n-2);if(w.pathSegType===2){o(n-1,2);F();break}else if(E.pathSegType===2){o(n-2,3);F();break}}else if(w.pathSegType===2)if(n>0){w=k.getItem(n-1).pathSegType;if(w===2){o(n-1,1);F();break}else if(w===
1&&k.numberOfItems-1===n){o(n,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){La.toSelectMode(svgedit.path.path.elem);d.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var k=z.getItem(0),n=null;D=[];D.push(["M",k.x,",",
k.y," C"].join(""));for(var o=1;o<=F-4;o+=3){var w=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(n)if((k=svgedit.path.smoothControlPoints(n,w,k))&&k.length==2){w=D[D.length-1].split(",");w[2]=k[0].x;w[3]=k[0].y;D[D.length-1]=w.join(",");w=k[1]}D.push([w.x,w.y,E.x,E.y,H.x,H.y].join(","));k=H;n=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},
moveNode:function(D,z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var k={x:0,y:0};k[D]=z-F.item[D];F.move(k.x,k.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=D.pathSegList,F=z.numberOfItems,k,n=0;n<F;++n){var o=z.getItem(n);if(o.pathSegType===2)k=o;if(o.pathSegType===1){o=z.getItem(n-1);if(o.x!=k.x||o.y!=k.y){z=D.createSVGPathSegLinetoAbs(k.x,k.y);svgedit.path.insertItemBefore(D,z,n);La.fixEnd(D);
break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,k=F.numberOfItems,n=0,o=0,w="",E=null,H=0;H<k;++H){var J=F.getItem(H),O=J.x||0,Y=J.y||0,da=J.x1||0,V=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});w+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:w+=
"z";break;case 12:O-=n;case 13:if(z){n+=O;qa="l"}else{O+=n;n=O;qa="L"}ua([[O,o]]);break;case 14:Y-=o;case 15:if(z){o+=Y;qa="l"}else{Y+=o;o=Y;qa="L"}ua([[n,Y]]);break;case 2:case 4:case 18:O-=n;Y-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){n=E[0];o=E[1]}case 19:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}if(W===3)E=[n,o];ua([[O,Y]]);break;case 6:O-=n;da-=n;fa-=n;Y-=o;V-=o;ha-=o;case 7:if(z){n+=O;o+=Y}else{O+=n;da+=n;fa+=n;Y+=o;V+=o;ha+=o;n=O;o=Y}ua([[da,V],[fa,ha],[O,Y]]);break;case 8:O-=
n;da-=n;Y-=o;V-=o;case 9:if(z){n+=O;o+=Y}else{O+=n;da+=n;Y+=o;V+=o;n=O;o=Y}ua([[da,V],[O,Y]]);break;case 10:O-=n;Y-=o;case 11:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,Y]);break;case 16:O-=n;fa-=n;Y-=o;ha-=o;case 17:if(z){n+=O;o+=Y}else{O+=n;fa+=n;Y+=o;ha+=o;n=O;o=Y}ua([[fa,ha],[O,Y]])}}return w}}}(),yb=this.removeUnusedDefElems=function(){var e=m.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],l=0,B=["fill","stroke",
"filter","marker-start","marker-mid","marker-end"],A=B.length,G=m.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=G[z],k=0;k<A;k++)if(F){var n=ja(F.getAttribute(B[k]));n&&h.push(n.substr(1))}(F=ba(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){B=e[z];A=B.id;if(h.indexOf(A)<0){sb[A]=B;B.parentNode.removeChild(B);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);
La.clear(true);$.each(m.childNodes,function(l,B){l&&B.nodeType===8&&B.data.indexOf("Created with")>=0&&m.insertBefore(B,m.firstChild)});if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(m).find("g:data(gsvg)").each(function(){for(var l=this.attributes,B=l.length,A=0;A<B;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")B--;if(B<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var h=this.svgToString(m,0);e.length&&$(e).each(function(){tb(this)});return h};this.svgToString=
function(e,h){var l=[],B=svgedit.utilities.toXml,A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,k=e.childNodes;for(F=0;F<h;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var n={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!n[O]&&
ya[O]!=="xmlns"&&ya[O]!=="xml"){n[O]=true;l.push(" xmlns:"+ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){z=D.item(F);var o=B(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var w=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=
0;F--){z=D.item(F);o=B(z.nodeValue);if(!(w.indexOf(z.localName)>=0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);
l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");h++;D=false;for(F=0;F<k.length;F++){A=k.item(F);switch(A.nodeType){case 1:l.push("\n");l.push(this.svgToString(k.item(F),h));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(B(A)+"")}break;case 4:l.push("\n");l.push(Array(h+1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(h+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}h--;if(!D){l.push("\n");
for(F=0;F<h;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var B=";svgedit_url="+encodeURIComponent(e);B=l.toDataURL().replace(";base64",B+";base64");Va[e]=B}catch(A){Va[e]=false}Fa=e;h&&h(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Fa=e};this.open=function(){};
this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],h={feGaussianBlur:kb.exportNoBlur,foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(m);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=kb.exportNoText;$.each(h,function(B,A){l.find(B).length&&e.push(A)});h=this.svgCanvasToString();M("exported",{svg:h,issues:e})};this.getSvgString=function(){$a.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,C()):svgedit.draw.randomizeIds(true,C())};var Hb=this.uniquifyElems=function(e){var h={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(z){if(z.nodeType==1){if(z.id){z.id in h||(h[z.id]={elem:null,attrs:[],hrefs:[]});h[z.id].elem=z}$.each(vb,function(k,n){var o=z.getAttributeNode(n);if(o){var w=svgedit.utilities.getUrlFromAttr(o.value);
if(w=w?w.substr(1):null){w in h||(h[w]={elem:null,attrs:[],hrefs:[]});h[w].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(z)}}});for(var B in h)if(B){var A=h[B].elem;if(A){e=ka();A.id=e;A=h[B].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=h[B].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var h=
$(e);if(e.tagName!=="use")h=h.find("use");h.each(function(){var l=ba(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Ib=this.convertGradients=function(e){var h=$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var l=$(m).find('[fill="url(#'+
this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var B=$(this).attr(["x1","y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=X(A).matrix;A=N(B.x1,B.y1,G);G=N(B.x2,B.y2,G);B.x1=A.x;B.y1=A.y;B.x2=G.x;B.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(B.x1-l.x)/l.width,y1:(B.y1-l.y)/l.height,x2:(B.x2-l.x)/l.width,y2:(B.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},
Lb=this.convertToGroup=function(e){e||(e=I[0]);var h=$(e),l=new Da,B;if(h.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");B=R(e);var A=c.createSVGTransform();A.setTranslate(l.x,l.y);B.appendItem(A);Ra(e);M("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");B=h.attr("transform");A=h.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}B+=" translate("+(A.x||0)+","+(A.y||0)+")";A=h.prev();l.addSubCommand(new Ha(h[0],
1&&k.numberOfItems-1===n){o(n,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){d.setMode("select");d.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var k=z.getItem(0),n=null;D=[];D.push(["M",k.x,",",k.y," C"].join(""));
for(var o=1;o<=F-4;o+=3){var w=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(n)if((k=svgedit.path.smoothControlPoints(n,w,k))&&k.length==2){w=D[D.length-1].split(",");w[2]=k[0].x;w[3]=k[0].y;D[D.length-1]=w.join(",");w=k[1]}D.push([w.x,w.y,E.x,E.y,H.x,H.y].join(","));k=H;n=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,
z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var k={x:0,y:0};k[D]=z-F.item[D];F.move(k.x,k.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=D.pathSegList,F=z.numberOfItems,k,n=0;n<F;++n){var o=z.getItem(n);if(o.pathSegType===2)k=o;if(o.pathSegType===1){o=z.getItem(n-1);if(o.x!=k.x||o.y!=k.y){z=D.createSVGPathSegLinetoAbs(k.x,k.y);svgedit.path.insertItemBefore(D,z,n);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&
D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,k=F.numberOfItems,n=0,o=0,w="",E=null,H=0;H<k;++H){var J=F.getItem(H),O=J.x||0,Y=J.y||0,da=J.x1||0,V=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});w+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:w+="z";break;case 12:O-=
n;case 13:if(z){n+=O;qa="l"}else{O+=n;n=O;qa="L"}ua([[O,o]]);break;case 14:Y-=o;case 15:if(z){o+=Y;qa="l"}else{Y+=o;o=Y;qa="L"}ua([[n,Y]]);break;case 2:case 4:case 18:O-=n;Y-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){n=E[0];o=E[1]}case 19:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}if(W===3)E=[n,o];ua([[O,Y]]);break;case 6:O-=n;da-=n;fa-=n;Y-=o;V-=o;ha-=o;case 7:if(z){n+=O;o+=Y}else{O+=n;da+=n;fa+=n;Y+=o;V+=o;ha+=o;n=O;o=Y}ua([[da,V],[fa,ha],[O,Y]]);break;case 8:O-=n;da-=n;Y-=o;V-=o;case 9:if(z){n+=
O;o+=Y}else{O+=n;da+=n;Y+=o;V+=o;n=O;o=Y}ua([[da,V],[O,Y]]);break;case 10:O-=n;Y-=o;case 11:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,Y]);break;case 16:O-=n;fa-=n;Y-=o;ha-=o;case 17:if(z){n+=O;o+=Y}else{O+=n;fa+=n;Y+=o;ha+=o;n=O;o=Y}ua([[fa,ha],[O,Y]])}}return w}}}(),yb=this.removeUnusedDefElems=function(){var e=m.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],l=0,B=["fill","stroke","filter","marker-start","marker-mid",
"marker-end"],A=B.length,G=m.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=G[z],k=0;k<A;k++)if(F){var n=ja(F.getAttribute(B[k]));n&&h.push(n.substr(1))}(F=ba(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){B=e[z];A=B.id;if(h.indexOf(A)<0){sb[A]=B;B.parentNode.removeChild(B);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);La.clear(true);$.each(m.childNodes,function(l,
B){l&&B.nodeType===8&&B.data.indexOf("Created with")>=0&&m.insertBefore(B,m.firstChild)});if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(m).find("g:data(gsvg)").each(function(){for(var l=this.attributes,B=l.length,A=0;A<B;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")B--;if(B<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var h=this.svgToString(m,0);e.length&&$(e).each(function(){tb(this)});return h};this.svgToString=function(e,h){var l=[],B=svgedit.utilities.toXml,
A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,k=e.childNodes;for(F=0;F<h;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var n={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!n[O]&&ya[O]!=="xmlns"&&ya[O]!=="xml"){n[O]=true;l.push(" xmlns:"+
ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){z=D.item(F);var o=B(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var w=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=0;F--){z=D.item(F);o=B(z.nodeValue);if(!(w.indexOf(z.localName)>=
0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");
h++;D=false;for(F=0;F<k.length;F++){A=k.item(F);switch(A.nodeType){case 1:l.push("\n");l.push(this.svgToString(k.item(F),h));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(B(A)+"")}break;case 4:l.push("\n");l.push(Array(h+1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(h+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}h--;if(!D){l.push("\n");for(F=0;F<h;F++)l.push(" ")}l.push("</");l.push(e.nodeName);
l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var B=";svgedit_url="+encodeURIComponent(e);B=l.toDataURL().replace(";base64",B+";base64");Va[e]=B}catch(A){Va[e]=false}Fa=e;h&&h(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Fa=e};this.open=function(){};this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;
e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],h={feGaussianBlur:kb.exportNoBlur,foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(m);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=kb.exportNoText;$.each(h,function(B,A){l.find(B).length&&e.push(A)});h=this.svgCanvasToString();M("exported",{svg:h,issues:e})};this.getSvgString=function(){$a.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>
0&&arguments[0]==false?svgedit.draw.randomizeIds(false,C()):svgedit.draw.randomizeIds(true,C())};var Hb=this.uniquifyElems=function(e){var h={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(z){if(z.nodeType==1){if(z.id){z.id in h||(h[z.id]={elem:null,attrs:[],hrefs:[]});h[z.id].elem=z}$.each(vb,function(k,n){var o=z.getAttributeNode(n);if(o){var w=svgedit.utilities.getUrlFromAttr(o.value);if(w=w?w.substr(1):null){w in h||(h[w]=
{elem:null,attrs:[],hrefs:[]});h[w].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(z)}}});for(var B in h)if(B){var A=h[B].elem;if(A){e=ka();A.id=e;A=h[B].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=h[B].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var h=$(e);if(e.tagName!=="use")h=
h.find("use");h.each(function(){var l=ba(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Ib=this.convertGradients=function(e){var h=$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var l=$(m).find('[fill="url(#'+this.id+')"],[stroke="url(#'+
this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var B=$(this).attr(["x1","y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=X(A).matrix;A=N(B.x1,B.y1,G);G=N(B.x2,B.y2,G);B.x1=A.x;B.y1=A.y;B.x2=G.x;B.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(B.x1-l.x)/l.width,y1:(B.y1-l.y)/l.height,x2:(B.x2-l.x)/l.width,y2:(B.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Lb=this.convertToGroup=
function(e){e||(e=I[0]);var h=$(e),l=new Da,B;if(h.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");B=R(e);var A=c.createSVGTransform();A.setTranslate(l.x,l.y);B.appendItem(A);Ra(e);M("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");B=h.attr("transform");A=h.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}B+=" translate("+(A.x||0)+","+(A.y||0)+")";A=h.prev();l.addSubCommand(new Ha(h[0],
h[0].nextSibling,h[0].parentNode));h.remove();G=$(m).find("use:data(symbol)").length;h=f.createElementNS(b,"g");for(var D=e.childNodes,z=0;z<D.length;z++)h.appendChild(D[z].cloneNode(true));if(svgedit.browser.isGecko()){D=$(gb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(D)}B&&h.setAttribute("transform",B);B=e.parentNode;Hb(h);svgedit.browser.isGecko()&&$(gb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=ka();A.after(h);if(B){if(!G){A=e.nextSibling;
B.removeChild(e);l.addSubCommand(new Ha(e,A,B))}l.addSubCommand(new Ia(h))}Gb(h);svgedit.browser.isGecko()?Ib(gb()):Ib(h);svgedit.utilities.walkTreePost(h,function(F){try{Ra(F)}catch(k){console.log(k)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});rb([h]);(e=Db(h,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);
this.prepareSvg(h);var l=new Da("Change Source"),B=m.nextSibling,A=c.removeChild(m);l.addSubCommand(new Ha(A,B,c));m=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);c.appendChild(m);var G=$(m);d.current_drawing_=new svgedit.draw.Drawing(m,u);var D=C().getNonce();D?M("setnonce",D):M("unsetnonce");G.find("image").each(function(){var J=this;Fb(J);var O=ba(this);if(O.indexOf("data:")===0){var Y=O.match(/svgedit_url=(.*?);/);if(Y){var da=decodeURIComponent(Y[1]);$(new Image).load(function(){J.setAttributeNS("http://www.w3.org/1999/xlink",
@ -424,84 +424,84 @@ a(Qa);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){var Na=Aa[0].id.r
if(W.isDefault){a("#cur_"+W.list).append(Qa.children().clone());Aa=W.svgicon?W.svgicon:W.id;da["#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("<div>",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa)}var ub=B.getButtonData(Pa.button);if(Pa.isDefault)da["#"+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<ub)Ca.children().eq(Na).before(Qa);else{Ca.append(Qa);ua.reverse()}}V||Qa.append(qa);W.list||a.each(W.events,function(Cb,Jb){if(Cb=="click")if(W.type=="mode"){W.includeWith?Qa.bind(Cb,Jb):Qa.bind(Cb,function(){ra(Qa)&&Jb()});if(W.key){a(document).bind("keydown",W.key,Jb);W.title&&Qa.attr("title",W.title+" ["+W.key+"]")}}else Qa.bind(Cb,Jb);
else Qa.bind(Cb,Jb)});Z(fa)});a.each(O,function(){vb(this.elem,this.list,this.callback,{seticon:true})});if(V)H=false;a.svgIcons(V,{w:27,h:27,id_match:false,no_img:!m,fallback:Y,placement:da,callback:function(){v.iconsize&&v.iconsize!="m"&&o();H=true;J()}})}J()});g.textActions.setInputElem(a("#text")[0]);var Ma='<div class="palette_item transparent" data-rgb="none"></div>\t\t\t\t\t\t\t\t<div class="palette_item black" data-rgb="#000000"></div>\t\t\t\t\t\t\t\t<div class="palette_item white" data-rgb="#ffffff"></div>';
["#482816","#422C10","#3B2F0E","#32320F","#293414","#1F361B","#153723","#0C372C","#083734","#0E353B","#1A333F","#273141","#332D40","#3E2A3C","#462735","#4B252D","#4D2425","#4C261D","#845335","#7B572D","#6F5C2A","#62612C","#546433","#46673D","#396849","#306856","#2D6862","#33666C","#426373","#535F75","#645A73","#74556D","#805064","#884D58","#8B4D4B","#894F3F","#C48157","#B8874D","#A98E49","#97944B","#849854","#729C62","#619E73","#559E84","#529D94","#5B9BA2","#6D97AB","#8391AE","#9A8AAB","#AF84A3",
"#BF7E96","#C97A86","#CE7975","#CC7C65","#FFB27C","#FABA6F","#E6C36A","#CFCA6D","#B8D078","#A0D58A","#8CD79F","#7DD8B5","#7AD6CA","#84D3DB","#9ACEE6","#B6C7EA","#D3BEE7","#EDB6DC","#FFAFCC","#FFAAB8","#FFA9A2","#FFAC8D","#FFE7A2","#FFF093","#FFFA8D","#FFFF91","#EEFF9F","#D1FFB4","#B9FFCE","#A8FFE9","#A4FFFF","#B1FFFF","#CBFFFF","#EDFFFF","#FFF5FF","#FFEBFF","#FFE2FF","#FFDCEC","#FFDBD2","#FFDFB8"].forEach(function(k){Ma+='<div class="palette_item" style="background-color: '+k+';" data-rgb="'+k+'"></div>'});
a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Da.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var n=k.value/100;if(n<0.0010)k.value=0.1;else{k=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/k,y:(o[0].scrollTop+o.height()/2)/k,zoom:n},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());
a("#stroke_style_label").html(this.options[this.selectedIndex].text);window.opera&&a("<p/>").hide().appendTo("body").remove()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k){var n=k.getAttribute("data-attr"),o=k.getAttribute("data-multiplier")||
1;o=parseFloat(o);o=k.value*o;if(!svgedit.units.isValidUnit(n,o,X)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=X.getAttribute(n);return false}g.changeSelectedAttributeNoUndo(n,o)};picking=false;a(document).on("mouseup",function(){picking=false});a("#palette").on("mousemove mousedown touchstart touchmove",".palette_item",function(k){k.preventDefault();if(k.type=="mousedown")picking=true;if(picking){var n=a("#tool_stroke").hasClass("active"),o=n?"stroke":"fill",w=a(this).attr("data-rgb"),
E=null,H=true;if(k.type=="mousedown")H=false;if(w==="transparent"||w==="initial"||w==="#none"){w="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:w.substr(1)});b.paintBox[o].setPaint(E);if(n){g.setColor("stroke",w,H);w!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",w,H);w!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display",
"table-cell");a(this).addClass("expanded");Db()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Db()});var ra=function(k,n){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;var o=o||"normal";n||a(".tools_flyout").fadeOut(o);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=
null,n=null,o=K[0],w=false,E=false;a("#svgcanvas").on("mousemove mouseup touchend",function(H){if(w!==false){o.scrollLeft-=H.clientX-k;o.scrollTop-=H.clientY-n;k=H.clientX;n=H.clientY;if(H.type==="mouseup"||H.type==="touchend")w=false;return false}}).on("mousedown touchmove",function(H){if(H.button===1||E===true||H.originalEvent.touches&&H.originalEvent.touches.length>=2){w=true;k=H.clientX;n=H.clientY;return false}});a(window).mouseup(function(){w=false});a(document).bind("keydown","space",function(H){H.preventDefault();
g.spaceKey=E=true}).bind("keyup","space",function(H){H.preventDefault();g.spaceKey=E=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&K.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&K.removeClass("out")})})();var va=a(".menu"),kb=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=
""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){kb(k)});a("svg, body").on("mousedown touchstart",function(k){if(!(k.target.nodeName&&k.target.nodeName.toLowerCase()==="input"))if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?kb(k):a("#menu_bar").removeClass("active")});a("#workarea").on("mousewheel",
function(k,n,o,w){if(k.altKey){k.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+w*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(k,n,o){if(a(k).length!=0){var w=a(k).find("button"),E=a(k).find("ul").attr("id",a(k)[0].id+"-list");
o||a("#option_lists").append(E);var H=false;o&&a(k).addClass("dropup");E.find("li").bind("mouseup",n);a(window).mouseup(function(){if(!H){w.removeClass("down");E.hide()}H=false});w.bind("mousedown",function(){if(w.hasClass("down")){w.removeClass("down");E.hide()}else{w.addClass("down");if(!o){var J=a(k).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(k,n,o,w){var E=a(k);n=a(n);var H=false,J=w.dropUp;J&&a(k).addClass("dropup");
n.find("li").bind("mouseup",function(){if(w.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");n.hide();n.css({top:0,left:0})}H=false});n.height();a(k).bind("mousedown",function(){var O=a(k).offset();if(J){O.top-=n.height();O.left+=8}else O.top+=a(k).height();a(n).offset(O);if(E.hasClass("down")){E.removeClass("down");n.hide();n.css({top:0,left:0})}else{E.addClass("down");
n.show();H=true;return false}}).hover(function(){H=true}).mouseout(function(){H=false});w.multiclick&&n.mousedown(function(){H=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,n=this.options[this.selectedIndex].text;a("#preview_font").html(n).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,
"page")})});(function(){var k,n=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;N="toolbars";K.mousedown(n)}).blur(function(){N="canvas";K.unbind("mousedown",n);g.getMode()=="textedit"&&a("#text").focus()})})();var cb=function(){ra("#tool_select")&&g.setMode("select")},Ta=function(){ra("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){ra("#tool_line")&&g.setMode("line")},Fa=function(){ra("#tool_rect")&&g.setMode("rect")},ta=function(){ra("#tool_ellipse")&&
g.setMode("ellipse")},$a=function(){ra("#tool_image")&&g.setMode("image")},Ka=function(){ra("#tool_zoom")&&g.setMode("zoom")},Sa=function(){if(ra("#tool_zoom")){yb();oa()}},Ga=function(){ra("#tool_text")&&g.setMode("text")},db=function(){ra("#tool_path")&&g.setMode("path")},lb=function(){if(X!=null||U)g.deleteSelectedElements()},Ua=function(){if(X!=null||U){xa(a("#edit_menu"));g.cutSelectedElements()}},Xa=function(){if(X!=null||U){xa(a("#edit_menu"));g.copySelectedElements()}},wb=function(){xa(a("#edit_menu"));
var k=g.getZoom(),n=(K[0].scrollLeft+K.width()/2)/k-g.contentW;k=(K[0].scrollTop+K.height()/2)/k-g.contentH;g.pasteElements("point",n,k)},sa=function(){if(X!=null){xa(a("#object_menu"));g.moveToTopSelectedElement()}},hb=function(){if(X!=null){xa(a("#object_menu"));g.moveToBottomSelectedElement()}},eb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Up")}},sb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Down")}},ib=function(k){if(X!=null){xa(a("#object_menu"));
g.moveUpDownSelected(k)}},ab=function(){if(X!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).reset(elems[0]);g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");C.toEditMode(elems[0]);g.clearSelection();Ha()}},ob=function(){X!=null&&C.reorient()},pb=function(){if(X!=null||U)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},fb=function(k,n){if(X!=null||
U){if(curConfig.gridSnapping){var o=g.getZoom()*curConfig.snappingStep;k*=o;n*=o}a("input").blur();g.moveSelectedElements(k,n)}},tb=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);C.linkControlPoints(k)},ia=function(){C.getNodePoint()&&C.clonePathNode()},aa=function(){C.getNodePoint()&&C.deletePathNode()},ka=function(){var k=a("#tool_add_subpath"),
n=!k.hasClass("push_button_pressed");n?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");C.addSubPath(n)},M=function(){C.opencloseSubPath()},P=function(){g.cycleElement(1)},ca=function(){g.cycleElement(0)},Ea=function(k,n){if(!(X==null||U)){k||(n*=-1);var o=a("#angle").val()*1+n;g.setRotationAngle(o);Ha()}},Oa=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(n){if(n){oa();g.clear();
g.setResolution(k[0],k[1]);G(true);yb();Ha();ba();g.runExtensions("onNewDocument")}})},Wa=function(){g.setBold(!g.getBold());Ha()},Za=function(){g.setItalic(!g.getItalic());Ha()},nb=function(){if(!d.pngsave){var k=uiStrings.notification.loadingImage;S=window.open("data:text/html;charset=utf-8,<title>"+k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Ra=function(){g.open()},mb=function(){},
xa=function(k){var n=k.prev();n.css({background:"white",color:"black"});setTimeout(function(){n.removeAttr("style")},200)},qb=function(){if(s.getUndoStackSize()>0){xa(a("#edit_menu"));s.undo()}},rb=function(){if(s.getRedoStackSize()>0){xa(a("#edit_menu"));s.redo()}},Bb=function(){if(U){xa(a("#object_menu"));g.groupSelectedElements()}else if(X){xa(a("#object_menu"));g.ungroupSelectedElement()}},Fb=function(){xa(a("#edit_menu"));g.cloneSelectedElements(20,20)},bb=function(){var k=this.id.replace("tool_align",
"").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},La=function(){var k=document.querySelector("#tool_stroke rect");a("#tool_stroke").toggleClass("active");a("#tool_fill").toggleClass("active");var n=document.querySelector("#tool_fill rect"),o=n.getAttribute("fill"),w=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));if(isNaN(k))k=100;n=parseFloat(n.getAttribute("fill-opacity"));if(isNaN(n))n=100;w=ya(w,k,"stroke");o=ya(o,n,"fill");b.paintBox.fill.setPaint(w,
true);b.paintBox.stroke.setPaint(o,true)},yb=function(k){var n=g.getResolution();k=k?n.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);xb();G(true)},Hb=function(){xa(a("#view_menu"));!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");K.toggleClass("wireframe");if(!h){var k=a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");xb()}},Gb=function(){xa(a("#view_menu"));
var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},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(!h){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(K.hasClass("wireframe")?k:"")}},Eb=function(k,n){if(!ea){xa(a("#view_menu"));ea=true;a("#save_output_btns").toggle(!!n);a("#tool_source_back").toggle(!n);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();ba()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();Ya();yb();ba()});oa()}},zb=b.setIcon=function(k,n){var o=typeof n==="string"?a.getSvgIcon(n,true):n.clone();o?a(k).find("img").replaceWith(o):console.log("NOTE: Icon image missing: "+n)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0],
o;for(o in n.style)if(k.test(o))return o.match(k)[0];if("WebkitOpacity"in n.style)return"Webkit";if("KhtmlOpacity"in n.style)return"Khtml";return""}();var Nb=function(k,n){gb.toLowerCase();var o=["top","left","bottom","right"];k.each(function(){for(var w=a(this),E=w.outerWidth()*(n-1),H=w.outerHeight()*(n-1),J=0;J<4;J++){var O=o[J],Y=w.data("orig_margin-"+O);if(Y==null){Y=parseInt(w.css("margin-"+O));w.data("orig_margin-"+O,Y)}Y=Y*n;if(O==="right")Y+=E;else if(O==="bottom")Y+=H;w.css("margin-"+O,
Y)}})},Mb=b.setIconSize=function(k,n){if(!(k==v.size&&!n)){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"),w=1;w=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=R=w;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,w);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();
else o=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(Y,da){if(typeof da==="number")var V=da*w+"px";else if(da[k]||da.all)V=da[k]||da.all;H+=Y+":"+V+";"});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("+w+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/w+");}";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(k){k&&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 k=g.getHref(X);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(n){n&&Ia(n)})});var e=function(k){var n=k[0].id=="stroke_color"?"stroke":
"fill",o=k[0].id=="canvas_color";if(o)n="canvas";var w=b.paintBox[n].paint;k=n=="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:w,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){w=new a.jGraduate.Paint(E);b.paintBox[n].setPaint(w);
g.setPaint(n,w);a("#color_picker").hide()},function(){a("#color_picker").hide()})};c=function(k,n){var o=document.getElementById("canvas_background"),w={color:"fff",opacity:1};if(n=="stroke")w=curConfig.initStroke;if(n=="fill")w=curConfig.initFill;if(n=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))w={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('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
w.color+'" opacity="'+w.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;o=a(k)[0].appendChild(document.importNode(o,true));n==="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:w.color});this.type=n;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,Y=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",Y);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,Y,true)}};this.update=function(E){if(X){var H=this.type;switch(X.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var J=null,O=X.getElementsByTagName("*"),Y=0,da=O.length;Y<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H===
"fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(ya(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*
100);c=b.paintBox.fill.rect.cloneNode(false);c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);
v.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",
function(){e(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");e(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");e(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||
a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a(window).bind("load resize",function(){K.css("line-height",K.height()+"px")});var l=function(){var k=a("#canvas_width"),n=a("#canvas_height"),o=k.val(),w=n.val();if(o!="fit"&&!svgedit.units.isValidUnit("width",o)){a.alert(uiStrings.notification.invalidAttrValGiven);
k.parent().addClass("error");return false}k.parent().removeClass("error");if(w!="fit"&&!svgedit.units.isValidUnit("height",w)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");if(!g.setResolution(o,w)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();k.val(o.w);n.val(o.h);return false}G()};a("#resolution").change(function(){var k=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value==
"content"){k.value="fit";n.value="fit";l();var o=g.getResolution();k.value=o.w;n.value=o.h}else{var w=this.value.split("x");w[0]=parseInt(w[0]);w[1]=parseInt(w[1]);var E=w[0]-k.value,H=w[1]-n.value,J=Date.now(),O=function(Y){Y=(Y-J)/1E3;Y=Math.pow(Y-1,3)+1;k.value=(w[0]-E+Y*E).toFixed(0);n.value=(w[1]-H+Y*H).toFixed(0);l();if(Y>=1){Y=g.getResolution();a("#canvas_width").val(Y.w.toFixed());a("#canvas_height").val(Y.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Y.w+"<span>\u00d7</span></br>"+
Y.h+"</div>")}else requestAnimationFrame(O)};O(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;n.value=100}}});a("#zoom").change(function(){wa(this)});a("input,select").attr("autocomplete","off");var B=function(){var k=[{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:Fa,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:Ga,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:[u+"N",true]},{sel:"#tool_save",fn:function(){if(ea)Kb();else{xa(a("#file_menu"));g.save({images:v.img_save,round_digits:6})}},evt:"mouseup",key:[u+"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:[u+"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:"click"},{sel:"#tool_node_clone",fn:ia,evt:"click"},{sel:"#tool_node_delete",fn:aa,evt:"click"},{sel:"#tool_openclose_path",fn:M,evt:"click"},{sel:"#tool_add_subpath",fn:ka,evt:"click"},{sel:"#tool_move_top",fn:sa,evt:"click",key:u+"shift+up"},{sel:"#tool_move_bottom",fn:hb,evt:"click",key:u+"shift+down"},{sel:"#tool_move_up",fn:eb,evt:"click",key:[u+"up",true]},{sel:"#tool_move_down",
fn:sb,evt:"click",key:[u+"down",true]},{sel:"#tool_topath",fn:ab,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:pb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Fb,evt:"click",key:[u+"D",true]},{sel:"#tool_group",fn:Bb,evt:"click",key:[u+"G",true]},{sel:"#tool_ungroup",fn:Bb,evt:"click",key:u+"shift+G"},{sel:"#tool_unlink_use",fn:Bb,evt:"click"},{sel:"[id^=tool_align]",fn:bb,evt:"click"},{sel:"#tool_undo",fn:qb,evt:"click",key:u+"z"},{sel:"#tool_redo",fn:rb,evt:"click",key:["y",
true]},{sel:"#tool_cut",fn:Ua,evt:"click",key:[u+"x",true]},{sel:"#tool_copy",fn:Xa,evt:"click",key:u+"c"},{sel:"#tool_paste",fn:wb,evt:"click",key:u+"v"},{sel:"#tool_switch",fn:La,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:Wa,evt:"mousedown",key:[u+"B",true]},{sel:"#tool_italic",fn:Za,evt:"mousedown",key:[u+"I",true]},{sel:"#copy_save_done",fn:Ab,evt:"click"},{key:"ctrl+left",fn:function(){Ea(0,1)}},{key:"ctrl+right",fn:function(){Ea(1,1)}},{key:"ctrl+shift+left",fn:function(){Ea(0,5)}},{key:"ctrl+shift+right",
fn:function(){Ea(1,5)}},{key:"shift+O",fn:ca},{key:"shift+P",fn:P},{key:[u+"+",true],fn:function(){yb(2)}},{key:[u+"-",true],fn:function(){yb(0.5)}},{key:["up",true],fn:function(){fb(0,-1)}},{key:["down",true],fn:function(){fb(0,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:u+"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:u+"shift+z",fn:rb},{key:"esc",fn:Ib}],n={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var o=
{};a.each(k,function(w,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,Y=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)Y=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(V,fa){a(document).bind("keydown",fa,function(ha){O();Y&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var da=H.attr("title").split("[")[0]+" ("+J+")";n[J]=E.sel;H.parents("#main_menu").length||H.attr("title",da)}}});Z(o);a(window).bind("keydown","tab",function(w){if(N==="canvas"){w.preventDefault();P()}}).bind("keydown","shift+tab",function(w){if(N==="canvas"){w.preventDefault();ca()}});a("#tool_zoom").dblclick(Sa)},
setTitles:function(){a.each(n,function(o,w){var E=a(w).parents("#main_menu").length;a(w).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,Y){var da=Y.split("+"),V="";if(da.length>1){V=da[0]+"+";Y=da[1]}J+=(O?"/":"")+V+(uiStrings["key_"+Y]||Y)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var w;a.each(k,function(E,H){if(H.sel===o)w=H});return w}}}();B.setAll();b.ready(function(){var k=
curConfig.initTool,n=a("#tools_left, #svg_editor .tools_flyout"),o=n.find("#tool_"+k);k=n.find("#"+k);(o.length?o:k.length?k: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,cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});
a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,
callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var n=k.value;if(n==0&&X&&["line","polyline"].indexOf(X.nodeName)>=0)n=k.value=1;g.setStrokeWidth(n)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value,
true);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,n){var o=k.value-0,w=o+n,E=w>=o;if(n===0)return o;return o>=24?E?Math.round(o*1.1):Math.round(o/1.1):o<=1?E?o*2:o/2:w},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(k,n){val=k.value;a("#blur").val(val);n?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(k){switch(k){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(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();I.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(s.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&
b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();s.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){c=function(k){k.stopPropagation();k.preventDefault();a("#workarea").removeAttr("style");a("#main_menu").hide();var n=null;if(n=k.type=="drop"?k.dataTransfer.files[0]:this.files[0])if(n.type.indexOf("image")!=-1)if(n.type.indexOf("svg")!=-1){k=new FileReader;k.onloadend=function(o){g.importSvgString(o.target.result,
true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};k.readAsText(n)}else alert("sorry, bitmap import is temporalily disabled")};K=a("#workarea");K[0].addEventListener("dragenter",function(k){k.stopPropagation();k.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(k){k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("dragleave",function(k){K.removeAttr("style");k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("drop",c,false);var A=a('<input type="file">').change(function(){var k=this;b.openPrep(function(n){if(n){g.clear();if(k.files.length==1){n=new FileReader;n.onloadend=function(o){q(o.target.result);G()};n.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(A);
c=a('<input type="file">').change(c);a("#tool_import").show().prepend(c)}var G=b.updateCanvas=function(k,n){var o=K.width(),w=K.height(),E=o,H=w,J=g.getZoom(),O=K,Y=a("#svgcanvas"),da={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},V=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*V);w=Math.max(H,g.contentH*J*V);o==E&&w==H?K.css("overflow","hidden"):K.css("overflow","scroll");V=Y.height()/2;var fa=Y.width()/2;Y.width(o).height(w);var ha=w/2,W=o/2,qa=g.updateCanvas(o,w),ua=W/fa;o=o/2-E/2;w=w/2-H/
2;if(n){n.x+=qa.x;n.y+=qa.y}else n={x:W+(da.x-fa)*ua,y:ha+(da.y-V)*ua};if(k)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=w}else{O[0].scrollLeft=n.x-E/2;O[0].scrollTop=n.y-H/2}if(curConfig.showRulers){E=Y;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(Y=0;Y<2;Y++){fa=(da=Y===0)?"x":"y";ua=
da?"width":"height";V=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(w=1;w<Ca;w++){o[ua]=3E4;var Pa=o.cloneNode(true);o.parentNode.appendChild(Pa);Aa[w]=Pa.getContext("2d")}Pa[ua]=fa%3E4;fa=3E4}o[ua]=fa;ua=
O*J;var Qa=50/ua;o=1;for(w=0;w<D.length;w++){o=Ca=D[w];if(Qa<=Ca)break}Qa=o*ua;qa.font="normal 9px 'Lucida Grande', sans-serif";qa.fillStyle="#777";for(var Na=V/ua%o*ua,jb=Na-Qa;Na<ha;Na+=Qa){jb+=Qa;w=Math.round(Na)+0.5;if(da){qa.moveTo(w,15);qa.lineTo(w,0)}else{qa.moveTo(15,w);qa.lineTo(0,w)}Ca=(jb-V)/ua;if(o>=1)w=Math.round(Ca);else{w=(o+"").split(".")[1].length;w=Ca.toFixed(w)-0}if(w!==0&&w!==1E3&&w%1E3===0)w=w/1E3+"K";if(da){qa.fillText(w,Na+2,8);qa.fillStyle="#777"}else{Ca=(w+"").split("");for(w=
0;w<Ca.length;w++){qa.fillText(Ca[w],1,Na+9+w*9);qa.fillStyle="#777"}}Ca=Qa/10;for(w=1;w<10;w++){var ub=Math.round(Na+Ca*w)+0.5;if(Aa&&ub>fa){W++;qa.stroke();if(W>=Aa.length){w=10;Na=ha;continue}qa=Aa[W];Na-=3E4;ub=Math.round(Na+Ca*w)+0.5}var Cb=w%2?12:10;if(da){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(c=0.1;c<1E5;c*=10){D.push(1*c);D.push(2*c);D.push(5*c)}G(true);try{var z=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);
var n=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.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(k.length){for(var o=0;o<k.length;o++)k[o]=n(k[o]);return"["+k.join(",")+"]"}else{o=[];for(var w in k)o.push(n(w)+":"+n(k[w]));return"{"+o.join(",")+"}"}};window.addEventListener("message",
function(k){var n=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+n+";"+z(eval(k.data)),"*")}catch(o){k.source.postMessage("SVGe"+n+";error:"+o.message,"*")}},false)}catch(F){window.embed_error=F}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,n){a.pref("lang",k);a("#lang_select").val(k);if(n){g.runExtensions("langChanged",k);ma();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block",
"#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(o,w){a(w).attr("title",a(o)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(c){p?c():f.push(c)};b.runCallbacks=function(){a.each(f,function(){this()});p=true};b.loadFromString=function(c){b.ready(function(){q(c)})};b.loadFromURL=function(c,m){m||(m={});var u=m.cache,C=m.callback;b.ready(function(){a.ajax({url:c,dataType:"text",
cache:!!u,success:function(s){q(s,C)},error:function(s,L,Q){s.status!=404&&s.responseText?q(s.responseText,C):a.alert(uiStrings.notification.URLloadFail+": \n"+Q+"",C)}})})};b.loadFromDataURI=function(c){b.ready(function(){var m=c.substring(26);q(svgedit.utilities.decode64(m))})};b.addExtension=function(){var c=arguments;a(function(){g&&g.addExtension.apply(this,c)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
["#444444","#482816","#422C10","#3B2F0E","#32320F","#293414","#1F361B","#153723","#0C372C","#083734","#0E353B","#1A333F","#273141","#332D40","#3E2A3C","#462735","#4B252D","#4D2425","#4C261D","#666666","#845335","#7B572D","#6F5C2A","#62612C","#546433","#46673D","#396849","#306856","#2D6862","#33666C","#426373","#535F75","#645A73","#74556D","#805064","#884D58","#8B4D4B","#894F3F","#999999","#C48157","#B8874D","#A98E49","#97944B","#849854","#729C62","#619E73","#559E84","#529D94","#5B9BA2","#6D97AB",
"#8391AE","#9A8AAB","#AF84A3","#BF7E96","#C97A86","#CE7975","#CC7C65","#BBBBBB","#FFB27C","#FABA6F","#E6C36A","#CFCA6D","#B8D078","#A0D58A","#8CD79F","#7DD8B5","#7AD6CA","#84D3DB","#9ACEE6","#B6C7EA","#D3BEE7","#EDB6DC","#FFAFCC","#FFAAB8","#FFA9A2","#FFAC8D","#DDDDDD","#FFE7A2","#FFF093","#FFFA8D","#FFFF91","#EEFF9F","#D1FFB4","#B9FFCE","#A8FFE9","#A4FFFF","#B1FFFF","#CBFFFF","#EDFFFF","#FFF5FF","#FFEBFF","#FFE2FF","#FFDCEC","#FFDBD2","#FFDFB8"].forEach(function(k){Ma+='<div class="palette_item" style="background-color: '+
k+';" data-rgb="'+k+'"></div>'});a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Da.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var n=k.value/100;if(n<0.0010)k.value=0.1;else{k=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/k,y:(o[0].scrollTop+o.height()/2)/k,zoom:n},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",
a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);window.opera&&a("<p/>").hide().appendTo("body").remove()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k){var n=k.getAttribute("data-attr"),
o=k.getAttribute("data-multiplier")||1;o=parseFloat(o);o=k.value*o;if(!svgedit.units.isValidUnit(n,o,X)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=X.getAttribute(n);return false}g.changeSelectedAttributeNoUndo(n,o)};picking=false;a(document).on("mouseup",function(){picking=false});a("#palette").on("mousemove mousedown touchstart touchmove",".palette_item",function(k){k.preventDefault();if(k.type=="mousedown")picking=true;if(picking){var n=a("#tool_stroke").hasClass("active"),o=n?
"stroke":"fill",w=a(this).attr("data-rgb"),E=null,H=true;if(k.type=="mousedown")H=false;if(w==="transparent"||w==="initial"||w==="#none"){w="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:w.substr(1)});b.paintBox[o].setPaint(E);if(n){g.setColor("stroke",w,H);w!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",w,H);w!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}}).bind("contextmenu",function(k){k.preventDefault()});
a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Db()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Db()});var ra=function(k,n){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;var o=o||"normal";n||a(".tools_flyout").fadeOut(o);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");
return true};(function(){var k=null,n=null,o=K[0],w=false,E=false;a("#svgcanvas").on("mousemove mouseup touchend",function(H){if(w!==false){o.scrollLeft-=H.clientX-k;o.scrollTop-=H.clientY-n;k=H.clientX;n=H.clientY;if(H.type==="mouseup"||H.type==="touchend")w=false;return false}}).on("mousedown touchmove",function(H){if(H.button===1||E===true||H.originalEvent.touches&&H.originalEvent.touches.length>=2){w=true;k=H.clientX;n=H.clientY;return false}});a(window).mouseup(function(){w=false});a(document).bind("keydown",
"space",function(H){H.preventDefault();g.spaceKey=E=true}).bind("keyup","space",function(H){H.preventDefault();g.spaceKey=E=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&K.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&K.removeClass("out")})})();var va=a(".menu"),kb=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background=
"#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){kb(k)});a("svg, body").on("mousedown touchstart",function(k){if(!(k.target.nodeName&&k.target.nodeName.toLowerCase()==="input"))if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?kb(k):a("#menu_bar").removeClass("active")});
a("#workarea").on("mousewheel",function(k,n,o,w){if(k.altKey){k.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+w*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(k,n,o){if(a(k).length!=0){var w=a(k).find("button"),E=a(k).find("ul").attr("id",
a(k)[0].id+"-list");o||a("#option_lists").append(E);var H=false;o&&a(k).addClass("dropup");E.find("li").bind("mouseup",n);a(window).mouseup(function(){if(!H){w.removeClass("down");E.hide()}H=false});w.bind("mousedown",function(){if(w.hasClass("down")){w.removeClass("down");E.hide()}else{w.addClass("down");if(!o){var J=a(k).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(k,n,o,w){var E=a(k);n=a(n);var H=false,
J=w.dropUp;J&&a(k).addClass("dropup");n.find("li").bind("mouseup",function(){if(w.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");n.hide();n.css({top:0,left:0})}H=false});n.height();a(k).bind("mousedown",function(){var O=a(k).offset();if(J){O.top-=n.height();O.left+=8}else O.top+=a(k).height();a(n).offset(O);if(E.hasClass("down")){E.removeClass("down");
n.hide();n.css({top:0,left:0})}else{E.addClass("down");n.show();H=true;return false}}).hover(function(){H=true}).mouseout(function(){H=false});w.multiclick&&n.mousedown(function(){H=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,n=this.options[this.selectedIndex].text;a("#preview_font").html(n).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos",
"").charAt(0);g.alignSelectedElements(k,"page")})});(function(){var k,n=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;N="toolbars";K.mousedown(n)}).blur(function(){N="canvas";K.unbind("mousedown",n);g.getMode()=="textedit"&&a("#text").focus()})})();var cb=function(){ra("#tool_select")&&g.setMode("select")},Ta=function(){ra("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){ra("#tool_line")&&g.setMode("line")},Fa=function(){ra("#tool_rect")&&
g.setMode("rect")},ta=function(){ra("#tool_ellipse")&&g.setMode("ellipse")},$a=function(){ra("#tool_image")&&g.setMode("image")},Ka=function(){ra("#tool_zoom")&&g.setMode("zoom")},Sa=function(){if(ra("#tool_zoom")){yb();oa()}},Ga=function(){ra("#tool_text")&&g.setMode("text")},db=function(){ra("#tool_path")&&g.setMode("path")};console.log(C.getNodePoint());var lb=function(){if(X!=null||U)g.deleteSelectedElements();C.getNodePoint()&&C.deletePathNode()},Ua=function(){if(X!=null||U){xa(a("#edit_menu"));
g.cutSelectedElements()}},Xa=function(){if(X!=null||U){xa(a("#edit_menu"));g.copySelectedElements()}},wb=function(){xa(a("#edit_menu"));var k=g.getZoom(),n=(K[0].scrollLeft+K.width()/2)/k-g.contentW;k=(K[0].scrollTop+K.height()/2)/k-g.contentH;g.pasteElements("point",n,k)},sa=function(){if(X!=null){xa(a("#object_menu"));g.moveToTopSelectedElement()}},hb=function(){if(X!=null){xa(a("#object_menu"));g.moveToBottomSelectedElement()}},eb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Up")}},
sb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Down")}},ib=function(k){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected(k)}},ab=function(){if(X!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).reset(elems[0]);g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");C.toEditMode(elems[0]);g.clearSelection();Ha()}},ob=function(){X!=null&&C.reorient()},pb=function(){if(X!=
null||U)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},fb=function(k,n){if(X!=null||U){if(curConfig.gridSnapping){var o=g.getZoom()*curConfig.snappingStep;k*=o;n*=o}a("input").blur();g.moveSelectedElements(k,n)}},tb=function(){var k=!a("#tool_node_link").hasClass("checked");C.linkControlPoints(k)},ia=function(){C.getNodePoint()&&C.clonePathNode()},aa=function(){C.getNodePoint()&&C.deletePathNode()},ka=function(){var k=a("#tool_add_subpath"),n=!k.hasClass("push_button_pressed");
n?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");C.addSubPath(n)},M=function(){C.opencloseSubPath()},P=function(){g.cycleElement(1)},ca=function(){g.cycleElement(0)},Ea=function(k,n){if(!(X==null||U)){k||(n*=-1);var o=a("#angle").val()*1+n;g.setRotationAngle(o);Ha()}},Oa=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(n){if(n){oa();g.clear();g.setResolution(k[0],k[1]);G(true);yb();
Ha();ba();g.runExtensions("onNewDocument")}})},Wa=function(){g.setBold(!g.getBold());Ha()},Za=function(){g.setItalic(!g.getItalic());Ha()},nb=function(){if(!d.pngsave){var k=uiStrings.notification.loadingImage;S=window.open("data:text/html;charset=utf-8,<title>"+k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Ra=function(){g.open()},mb=function(){},xa=function(k){var n=k.prev();n.css({background:"white",
color:"black"});setTimeout(function(){n.removeAttr("style")},200)},qb=function(){if(s.getUndoStackSize()>0){xa(a("#edit_menu"));s.undo()}},rb=function(){if(s.getRedoStackSize()>0){xa(a("#edit_menu"));s.redo()}},Bb=function(){if(U){xa(a("#object_menu"));g.groupSelectedElements()}else if(X){xa(a("#object_menu"));g.ungroupSelectedElement()}},Fb=function(){xa(a("#edit_menu"));g.cloneSelectedElements(20,20)},bb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},
La=function(){var k=document.querySelector("#tool_stroke rect");a("#tool_stroke").toggleClass("active");a("#tool_fill").toggleClass("active");var n=document.querySelector("#tool_fill rect"),o=n.getAttribute("fill"),w=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));if(isNaN(k))k=100;n=parseFloat(n.getAttribute("fill-opacity"));if(isNaN(n))n=100;w=ya(w,k,"stroke");o=ya(o,n,"fill");b.paintBox.fill.setPaint(w,true);b.paintBox.stroke.setPaint(o,true)},yb=function(k){var n=g.getResolution();
k=k?n.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);xb();G(true)},Hb=function(){xa(a("#view_menu"));!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");K.toggleClass("wireframe");if(!h){var k=a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");xb()}},Gb=function(){xa(a("#view_menu"));var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):
a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},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(!h){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(K.hasClass("wireframe")?k:"")}},Eb=function(k,n){if(!ea){xa(a("#view_menu"));ea=true;a("#save_output_btns").toggle(!!n);a("#tool_source_back").toggle(!n);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();ba()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();Ya();yb();ba()});oa()}},zb=b.setIcon=function(k,n){var o=typeof n==="string"?a.getSvgIcon(n,true):n.clone();o?a(k).find("img").replaceWith(o):console.log("NOTE: Icon image missing: "+n)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0],o;for(o in n.style)if(k.test(o))return o.match(k)[0];if("WebkitOpacity"in n.style)return"Webkit";
if("KhtmlOpacity"in n.style)return"Khtml";return""}();var Nb=function(k,n){gb.toLowerCase();var o=["top","left","bottom","right"];k.each(function(){for(var w=a(this),E=w.outerWidth()*(n-1),H=w.outerHeight()*(n-1),J=0;J<4;J++){var O=o[J],Y=w.data("orig_margin-"+O);if(Y==null){Y=parseInt(w.css("margin-"+O));w.data("orig_margin-"+O,Y)}Y=Y*n;if(O==="right")Y+=E;else if(O==="bottom")Y+=H;w.css("margin-"+O,Y)}})},Mb=b.setIconSize=function(k,n){if(!(k==v.size&&!n)){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"),
w=1;w=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=R=w;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,w);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();else o=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(Y,da){if(typeof da==="number")var V=da*w+"px";else if(da[k]||da.all)V=
da[k]||da.all;H+=Y+":"+V+";"});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("+w+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/w+");}";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(k){k&&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 k=g.getHref(X);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(n){n&&Ia(n)})});var e=function(k){var n=k[0].id=="stroke_color"?"stroke":"fill",o=k[0].id=="canvas_color";if(o)n="canvas";var w=b.paintBox[n].paint;k=n=="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:w,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){w=new a.jGraduate.Paint(E);b.paintBox[n].setPaint(w);g.setPaint(n,w);a("#color_picker").hide()},function(){a("#color_picker").hide()})};c=function(k,n){var o=document.getElementById("canvas_background"),w={color:"fff",opacity:1};if(n=="stroke")w=curConfig.initStroke;if(n=="fill")w=curConfig.initFill;if(n=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))w=
{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('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+w.color+'" opacity="'+w.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;o=a(k)[0].appendChild(document.importNode(o,true));n==="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:w.color});this.type=n;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,Y=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",Y);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,Y,true)}};this.update=function(E){if(X){var H=this.type;switch(X.tagName){case "use":case "image":case "foreignObject":return;
case "g":case "a":for(var J=null,O=X.getElementsByTagName("*"),Y=0,da=O.length;Y<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H==="fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(ya(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=
new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);c=b.paintBox.fill.rect.cloneNode(false);c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);v.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){e(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");e(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");e(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){K.css("line-height",K.height()+"px")});var l=function(){var k=a("#canvas_width"),n=a("#canvas_height"),o=k.val(),w=n.val();if(o!="fit"&&!svgedit.units.isValidUnit("width",o)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(w!="fit"&&!svgedit.units.isValidUnit("height",w)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");
if(!g.setResolution(o,w)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();k.val(o.w);n.val(o.h);return false}G()};a("#resolution").change(function(){var k=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";n.value="fit";l();var o=g.getResolution();k.value=o.w;n.value=o.h}else{var w=this.value.split("x");w[0]=parseInt(w[0]);w[1]=parseInt(w[1]);var E=w[0]-k.value,H=w[1]-n.value,J=Date.now(),O=function(Y){Y=(Y-J)/1E3;Y=Math.pow(Y-
1,3)+1;k.value=(w[0]-E+Y*E).toFixed(0);n.value=(w[1]-H+Y*H).toFixed(0);l();if(Y>=1){Y=g.getResolution();a("#canvas_width").val(Y.w.toFixed());a("#canvas_height").val(Y.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Y.w+"<span>\u00d7</span></br>"+Y.h+"</div>")}else requestAnimationFrame(O)};O(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;n.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var B=function(){var k=[{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:Fa,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:Ga,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:[u+"N",true]},{sel:"#tool_save",fn:function(){if(ea)Kb();else{xa(a("#file_menu"));g.save({images:v.img_save,round_digits:6})}},evt:"mouseup",key:[u+"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:[u+"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:"click"},{sel:"#tool_node_clone",fn:ia,evt:"click"},{sel:"#tool_node_delete",fn:aa,evt:"click"},{sel:"#tool_openclose_path",
fn:M,evt:"click"},{sel:"#tool_add_subpath",fn:ka,evt:"click"},{sel:"#tool_move_top",fn:sa,evt:"click",key:u+"shift+up"},{sel:"#tool_move_bottom",fn:hb,evt:"click",key:u+"shift+down"},{sel:"#tool_move_up",fn:eb,evt:"click",key:[u+"up",true]},{sel:"#tool_move_down",fn:sb,evt:"click",key:[u+"down",true]},{sel:"#tool_topath",fn:ab,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:pb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Fb,evt:"click",key:[u+"D",true]},{sel:"#tool_group",fn:Bb,
evt:"click",key:[u+"G",true]},{sel:"#tool_ungroup",fn:Bb,evt:"click",key:u+"shift+G"},{sel:"#tool_unlink_use",fn:Bb,evt:"click"},{sel:"[id^=tool_align]",fn:bb,evt:"click"},{sel:"#tool_undo",fn:qb,evt:"click",key:u+"z"},{sel:"#tool_redo",fn:rb,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:Ua,evt:"click",key:[u+"x",true]},{sel:"#tool_copy",fn:Xa,evt:"click",key:u+"c"},{sel:"#tool_paste",fn:wb,evt:"click",key:u+"v"},{sel:"#tool_switch",fn:La,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:Wa,evt:"mousedown",
key:[u+"B",true]},{sel:"#tool_italic",fn:Za,evt:"mousedown",key:[u+"I",true]},{sel:"#copy_save_done",fn:Ab,evt:"click"},{key:"ctrl+left",fn:function(){Ea(0,1)}},{key:"ctrl+right",fn:function(){Ea(1,1)}},{key:"ctrl+shift+left",fn:function(){Ea(0,5)}},{key:"ctrl+shift+right",fn:function(){Ea(1,5)}},{key:"shift+O",fn:ca},{key:"shift+P",fn:P},{key:[u+"+",true],fn:function(){yb(2)}},{key:[u+"-",true],fn:function(){yb(0.5)}},{key:["up",true],fn:function(){fb(0,-1)}},{key:["down",true],fn:function(){fb(0,
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:u+"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:u+"shift+z",fn:rb},{key:"esc",fn:Ib}],n={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var o={};a.each(k,function(w,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,Y=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)Y=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(V,fa){a(document).bind("keydown",fa,function(ha){O();Y&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var da=H.attr("title").split("[")[0]+" ("+J+")";n[J]=E.sel;H.parents("#main_menu").length||
H.attr("title",da)}}});Z(o);a(window).bind("keydown","tab",function(w){if(N==="canvas"){w.preventDefault();P()}}).bind("keydown","shift+tab",function(w){if(N==="canvas"){w.preventDefault();ca()}});a("#tool_zoom").dblclick(Sa)},setTitles:function(){a.each(n,function(o,w){var E=a(w).parents("#main_menu").length;a(w).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,Y){var da=Y.split("+"),V="";if(da.length>1){V=da[0]+"+";Y=da[1]}J+=(O?
"/":"")+V+(uiStrings["key_"+Y]||Y)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var w;a.each(k,function(E,H){if(H.sel===o)w=H});return w}}}();B.setAll();b.ready(function(){var k=curConfig.initTool,n=a("#tools_left, #svg_editor .tools_flyout"),o=n.find("#tool_"+k);k=n.find("#"+k);(o.length?o:k.length?k: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,
cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var n=k.value;if(n==0&&
X&&["line","polyline"].indexOf(X.nodeName)>=0)n=k.value=1;g.setStrokeWidth(n)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value,true);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,n){var o=k.value-0,w=o+n,E=w>=o;if(n===0)return o;
return o>=24?E?Math.round(o*1.1):Math.round(o/1.1):o<=1?E?o*2:o/2:w},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(k,n){val=k.value;a("#blur").val(val);n?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(k){switch(k){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(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});
a("#cmenu_canvas li").disableContextMenu();I.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(s.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();s.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){c=function(k){k.stopPropagation();k.preventDefault();a("#workarea").removeAttr("style");
a("#main_menu").hide();var n=null;if(n=k.type=="drop"?k.dataTransfer.files[0]:this.files[0])if(n.type.indexOf("image")!=-1)if(n.type.indexOf("svg")!=-1){k=new FileReader;k.onloadend=function(o){g.importSvgString(o.target.result,true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};k.readAsText(n)}else alert("sorry, bitmap import is temporalily disabled")};K=a("#workarea");K[0].addEventListener("dragenter",
function(k){k.stopPropagation();k.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(k){k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("dragleave",function(k){K.removeAttr("style");k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("drop",c,false);var A=a('<input type="file">').change(function(){var k=
this;b.openPrep(function(n){if(n){g.clear();if(k.files.length==1){n=new FileReader;n.onloadend=function(o){q(o.target.result);G()};n.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(A);c=a('<input type="file">').change(c);a("#tool_import").show().prepend(c)}var G=b.updateCanvas=function(k,n){var o=K.width(),w=K.height(),E=o,H=w,J=g.getZoom(),O=K,Y=a("#svgcanvas"),da={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},V=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*V);w=Math.max(H,g.contentH*
J*V);o==E&&w==H?K.css("overflow","hidden"):K.css("overflow","scroll");V=Y.height()/2;var fa=Y.width()/2;Y.width(o).height(w);var ha=w/2,W=o/2,qa=g.updateCanvas(o,w),ua=W/fa;o=o/2-E/2;w=w/2-H/2;if(n){n.x+=qa.x;n.y+=qa.y}else n={x:W+(da.x-fa)*ua,y:ha+(da.y-V)*ua};if(k)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=w}else{O[0].scrollLeft=n.x-E/2;O[0].scrollTop=n.y-H/2}if(curConfig.showRulers){E=Y;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(Y=0;Y<2;Y++){fa=(da=Y===0)?"x":"y";ua=da?"width":"height";V=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(w=1;w<Ca;w++){o[ua]=3E4;var Pa=o.cloneNode(true);o.parentNode.appendChild(Pa);Aa[w]=Pa.getContext("2d")}Pa[ua]=fa%3E4;fa=3E4}o[ua]=fa;ua=O*J;var Qa=50/ua;o=1;for(w=0;w<D.length;w++){o=Ca=D[w];if(Qa<=Ca)break}Qa=o*ua;qa.font="normal 9px 'Lucida Grande', sans-serif";qa.fillStyle="#777";for(var Na=V/ua%o*ua,jb=Na-Qa;Na<ha;Na+=Qa){jb+=Qa;w=Math.round(Na)+0.5;if(da){qa.moveTo(w,15);qa.lineTo(w,0)}else{qa.moveTo(15,w);qa.lineTo(0,w)}Ca=(jb-V)/ua;if(o>=1)w=Math.round(Ca);else{w=(o+"").split(".")[1].length;
w=Ca.toFixed(w)-0}if(w!==0&&w!==1E3&&w%1E3===0)w=w/1E3+"K";if(da){qa.fillText(w,Na+2,8);qa.fillStyle="#777"}else{Ca=(w+"").split("");for(w=0;w<Ca.length;w++){qa.fillText(Ca[w],1,Na+9+w*9);qa.fillStyle="#777"}}Ca=Qa/10;for(w=1;w<10;w++){var ub=Math.round(Na+Ca*w)+0.5;if(Aa&&ub>fa){W++;qa.stroke();if(W>=Aa.length){w=10;Na=ha;continue}qa=Aa[W];Na-=3E4;ub=Math.round(Na+Ca*w)+0.5}var Cb=w%2?12:10;if(da){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(c=0.1;c<1E5;c*=10){D.push(1*c);D.push(2*c);D.push(5*c)}G(true);try{var z=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var n=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.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(k.length){for(var o=
0;o<k.length;o++)k[o]=n(k[o]);return"["+k.join(",")+"]"}else{o=[];for(var w in k)o.push(n(w)+":"+n(k[w]));return"{"+o.join(",")+"}"}};window.addEventListener("message",function(k){var n=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+n+";"+z(eval(k.data)),"*")}catch(o){k.source.postMessage("SVGe"+n+";error:"+o.message,"*")}},false)}catch(F){window.embed_error=F}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,n){a.pref("lang",k);a("#lang_select").val(k);
if(n){g.runExtensions("langChanged",k);ma();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(o,w){a(w).attr("title",a(o)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(c){p?c():f.push(c)};b.runCallbacks=function(){a.each(f,function(){this()});
p=true};b.loadFromString=function(c){b.ready(function(){q(c)})};b.loadFromURL=function(c,m){m||(m={});var u=m.cache,C=m.callback;b.ready(function(){a.ajax({url:c,dataType:"text",cache:!!u,success:function(s){q(s,C)},error:function(s,L,Q){s.status!=404&&s.responseText?q(s.responseText,C):a.alert(uiStrings.notification.URLloadFail+": \n"+Q+"",C)}})})};b.loadFromDataURI=function(c){b.ready(function(){var m=c.substring(26);q(svgedit.utilities.decode64(m))})};b.addExtension=function(){var c=arguments;
a(function(){g&&g.addExtension.apply(this,c)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var q=this.dragCfg.dragAdjust,g=$(this).parent(),b=$(this),p=this.dragCfg.height,v=this.dragCfg.min,d=this.dragCfg.max,f=this.dragCfg.step,c=d-v>0?(d-v)/f:200,m=c/p*f,u=0,C=this.getAttribute("data-attr"),s=svgEditor.canvas,L=svgedit.browser.isTouch(),Q=true,K=c&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(g):false;b.attr("readonly","readonly");K&&!isNaN(this.dragCfg.start)&&K.css("top",this.dragCfg.start*-1/m+p);this.adjustValue=
function(I,S){var R;I=parseFloat(I);R=isNaN(this.value)?this.dragCfg.reset:$.isFunction(this.dragCfg.stepfunc)?this.dragCfg.stepfunc(this,I):Number((Number(this.value)+Number(I)).toFixed(5));if(d!==null)R=Math.min(R,d);if(v!==null)R=Math.max(R,v);K&&this.updateCursor(R);this.value=R;g.attr("data-value",R);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,S)};g.toggleClass("draginput",g.is("label"));this.move=function(I,S,R){if(L)I=I.originalEvent.touches[0];if(u===0)u=S;S=(I.pageY-u)*
-1;u=I.pageY;R=S*m*q;this.adjustValue(R.toFixed(f<1?1:0))};this.stop=function(){var I=s.getSelectedElems();$("body").removeClass("dragging");g.removeClass("active");Q=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");u=0;if(I[0]){I=s.undoMgr.finishUndoableChange();I.isEmpty()||s.undoMgr.addCommandToHistory(I)}this.adjustValue(0,Q)};this.updateCursor=function(){var I=parseFloat(this.value)*-1/m+p;K.css("top",I)};this.launch=function(I){var S=s.getSelectedElems();

View File

@ -869,7 +869,7 @@ html, body {
.palette_item {
height: 20%;
width: 5.4%;
width: 5.2%;
float: left;
cursor: url(images/eyedropper.png) 0 16, crosshair;
}
@ -2454,6 +2454,10 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
cursor: -moz-grab;
}
.draginput input[type="checkbox"], .draginput input[type="checkbox"]:hover, .draginput input[type="checkbox"]:active {
cursor: default;
}
.draginput.active input, .draginput.active input:hover, .draginput.active input:active {
cursor: url(images/dragging.png), move;
cursor: -webkit-grabbing;

View File

@ -314,6 +314,7 @@ svgedit.path.getSegSelector = function(seg, update) {
'display': 'none',
'fill': "none",
'stroke': "#0ff",
'stroke-opacity': 1,
"shape-rendering": "crispEdges",
'stroke-width': 2,
'style':'pointer-events:none',
@ -429,7 +430,8 @@ svgedit.path.Segment.prototype.show = function(y) {
svgedit.path.Segment.prototype.select = function(y) {
if(this.ptgrip) {
this.ptgrip.setAttribute("stroke", y ? "#0FF" : "#00F");
this.ptgrip.setAttribute("stroke", y ? "#4F80FF" : "#4F80FF");
this.ptgrip.setAttribute("fill", y ? "#4F80FF" : "#fff");
this.segsel.setAttribute("display", y ? "inline" : "none");
if(this.ctrlpts) {
this.selectCtrls(y);

View File

@ -287,7 +287,7 @@ html, body {
.palette_item {
height: 20%;
width: 5.4%;
width: 5.2%;
float: left;
cursor: url(images/eyedropper.png) 0 16, crosshair;
}
@ -1872,6 +1872,10 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
cursor: -moz-grab;
}
.draginput input[type="checkbox"], .draginput input[type="checkbox"]:hover, .draginput input[type="checkbox"]:active {
cursor: default;
}
.draginput.active input, .draginput.active input:hover, .draginput.active input:active {
cursor: url(images/dragging.png), move;
cursor: -webkit-grabbing;

View File

@ -330,25 +330,25 @@
Editor.canvas = svgCanvas = new $.SvgCanvas(document.getElementById("svgcanvas"), curConfig);
Editor.show_save_warning = false;
Editor.paintBox = {fill: null, stroke:null, canvas:null};
var palette = ["#482816", "#422C10", "#3B2F0E", "#32320F",
var palette = ["#444444", "#482816", "#422C10", "#3B2F0E", "#32320F",
"#293414", "#1F361B", "#153723", "#0C372C",
"#083734", "#0E353B", "#1A333F", "#273141",
"#332D40", "#3E2A3C", "#462735", "#4B252D",
"#4D2425", "#4C261D", "#845335", "#7B572D",
"#4D2425", "#4C261D", "#666666", "#845335", "#7B572D",
"#6F5C2A", "#62612C", "#546433", "#46673D",
"#396849", "#306856", "#2D6862", "#33666C",
"#426373", "#535F75", "#645A73", "#74556D",
"#805064", "#884D58", "#8B4D4B", "#894F3F",
"#C48157", "#B8874D", "#A98E49", "#97944B",
"#999999", "#C48157", "#B8874D", "#A98E49", "#97944B",
"#849854", "#729C62", "#619E73", "#559E84",
"#529D94", "#5B9BA2", "#6D97AB", "#8391AE",
"#9A8AAB", "#AF84A3", "#BF7E96", "#C97A86",
"#CE7975", "#CC7C65", "#FFB27C", "#FABA6F",
"#CE7975", "#CC7C65", "#BBBBBB", "#FFB27C", "#FABA6F",
"#E6C36A", "#CFCA6D", "#B8D078", "#A0D58A",
"#8CD79F", "#7DD8B5", "#7AD6CA", "#84D3DB",
"#9ACEE6", "#B6C7EA", "#D3BEE7", "#EDB6DC",
"#FFAFCC", "#FFAAB8", "#FFA9A2", "#FFAC8D",
"#FFE7A2", "#FFF093", "#FFFA8D", "#FFFF91",
"#DDDDDD", "#FFE7A2", "#FFF093", "#FFFA8D", "#FFFF91",
"#EEFF9F", "#D1FFB4", "#B9FFCE", "#A8FFE9",
"#A4FFFF", "#B1FFFF", "#CBFFFF", "#EDFFFF",
"#FFF5FF", "#FFEBFF", "#FFE2FF", "#FFDCEC",
@ -2183,13 +2183,16 @@
svgCanvas.setMode('path');
}
};
console.log(path.getNodePoint());
// Delete is a contextual tool that only appears in the ribbon if
// an element has been selected
var deleteSelected = function() {
if (selectedElement != null || multiselected) {
svgCanvas.deleteSelectedElements();
}
if (path.getNodePoint()) {
path.deletePathNode();
}
};
var cutSelected = function() {
@ -2290,12 +2293,7 @@
};
var linkControlPoints = function() {
var linked = !$('#tool_node_link').hasClass('checked');
if (linked)
$('#tool_node_link').addClass('checked').find("input").attr("checked", true);
else
$('#tool_node_link').removeClass('checked').find("input").attr("checked", false);
var linked = !$('#tool_node_link').hasClass('checked');
path.linkControlPoints(linked);
}

View File

@ -4682,6 +4682,7 @@ var pathActions = canvas.pathActions = function() {
}
},
getNodePoint: function() {
if (!svgedit.path.path) return;
var sel_pt = svgedit.path.path.selected_pts.length ? svgedit.path.path.selected_pts[0] : 1;
var seg = svgedit.path.path.segs[sel_pt];
@ -4886,7 +4887,7 @@ var pathActions = canvas.pathActions = function() {
// Completely delete a path with 1 or 0 segments
if(svgedit.path.path.elem.pathSegList.numberOfItems <= 1) {
pathActions.toSelectMode(svgedit.path.path.elem);
canvas.setMode("select")
canvas.deleteSelectedElements();
return;
}

View File

@ -131,7 +131,7 @@ html,body{overflow:hidden;width:100%;height:100%}
#ruler_y canvas{margin-top:-16px}
#ruler_x>div,#ruler_y>div{overflow:hidden}
#palette{display:block;position:absolute;z-index:2;left:10px;bottom:5px;width:410px;right:145px;height:30px}
.palette_item{height:20%;width:5.4%;float:left;cursor:url(images/eyedropper.png) 0 16,crosshair}
.palette_item{height:20%;width:5.2%;float:left;cursor:url(images/eyedropper.png) 0 16,crosshair}
.palette_item.transparent,.palette_item.white,.palette_item.black{background:#fff;position:absolute;width:10px;height:10px;left:-10px;top:0}
.palette_item.transparent{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAAVdEVYdENyZWF0aW9uIFRpbWUAOC8yMi8xMg1cp6sAAABESURBVBiVjdBBCgAgCETRr/e/87SJKFPLnfIcQRMIwMBIShIAvgZzoSrfkzrs8WyF1+kX9r3p8AE7nL7kSpSshN+JEQ8GixkF0mSevgAAAABJRU5ErkJggg==)}
.palette_item.black{background:#000;top:10px}
@ -381,6 +381,7 @@ button.cancel,input.Cancel,input.cancel,input.jGraduate_Cancel,button.cancel{-we
#preview_font{font-size:20px;color:#fff;height:70px;line-height:75px;padding:0 0 0 10px;white-space:nowrap;width:100px;overflow:hidden;border-right:solid #2f2f2c 2px;position:relative}
#preview_font:after{content:'';position:absolute;right:0;top:3px;bottom:3px;width:15px;border-right:solid #3f3f3c 10px;background:transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iZzU4MCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSIwJSIgeTE9IjAlIiB4Mj0iMTAwJSIgeTI9IjAlIj48c3RvcCBzdG9wLWNvbG9yPSIjM2YzZjNjIiBzdG9wLW9wYWNpdHk9IjAiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiMzZjNmM2MiIG9mZnNldD0iMC43Ii8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2c1ODApIiAvPjwvc3ZnPg==)}
.draginput input,.draginput input:hover,.draginput input:active{cursor:url(images/drag.png),move;cursor:-webkit-grab;cursor:-moz-grab}
.draginput input[type="checkbox"],.draginput input[type="checkbox"]:hover,.draginput input[type="checkbox"]:active{cursor:default}
.draginput.active input,.draginput.active input:hover,.draginput.active input:active{cursor:url(images/dragging.png),move;cursor:-webkit-grabbing;cursor:-moz-grabbing}
.draginput span{font:11px/130% sans-serif;color:#ccc;display:block;position:absolute;top:5px;left:5px;text-align:left}
.draginput.error{background:#900}

View File

@ -173,25 +173,25 @@ C=u.appendChild(C);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&
svgedit.utilities.getElem("ctrlLine_"+f);if(c)return c;c=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(c,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(c);return c};svgedit.path.getPointGrip=function(f,c){var m=svgedit.path.addPointGrip(f.index);if(c){var u=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(m,{x:u.x-(svgedit.browser.isTouch()?15:2.5),y:u.y-(svgedit.browser.isTouch()?
15:2.5),display:"inline"})}return m};svgedit.path.getControlPoints=function(f){var c=f.item,m=f.index;if(!("x1"in c)||!("x2"in c))return null;var u={};svgedit.path.getGripContainer();for(var C=[svgedit.path.path.segs[m-1].item,c],s=1;s<3;s++){var L=m+"c"+s,Q=u["c"+s+"_line"]=svgedit.path.getCtrlLine(L),K=svgedit.path.getGripPt(f,{x:c["x"+s],y:c["y"+s]}),I=svgedit.path.getGripPt(f,{x:C[s-1].x,y:C[s-1].y});svgedit.utilities.assignAttributes(Q,{x1:K.x,y1:K.y,x2:I.x,y2:I.y,display:"inline"});u["c"+s+
"_line"]=Q;pointGrip=u["c"+s]=svgedit.path.addCtrlGrip(L);svgedit.utilities.assignAttributes(pointGrip,{cx:K.x,cy:K.y,display:"inline"});u["c"+s]=pointGrip}return u};svgedit.path.replacePathSeg=function(f,c,m,u){u=u||svgedit.path.path.elem;f=u["createSVGPathSeg"+g[f]].apply(u,m);if(svgedit.browser.supportsPathReplaceItem())u.pathSegList.replaceItem(f,c);else{m=u.pathSegList;u=m.numberOfItems;for(var C=[],s=0;s<u;s++){var L=m.getItem(s);C.push(L)}m.clear();for(s=0;s<u;s++)s==c?m.appendItem(f):m.appendItem(C[s])}};
svgedit.path.getSegSelector=function(f,c){var m=f.index,u=svgedit.utilities.getElem("segline_"+m);if(!u){var C=svgedit.path.getGripContainer();u=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(u,{id:"segline_"+m,display:"none",fill:"none",stroke:"#0ff","shape-rendering":"crispEdges","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});C.appendChild(u)}if(c){m=f.prev;if(!m){u.setAttribute("display","none");return u}m=svgedit.path.getGripPt(m);
svgedit.path.getSegSelector=function(f,c){var m=f.index,u=svgedit.utilities.getElem("segline_"+m);if(!u){var C=svgedit.path.getGripContainer();u=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(u,{id:"segline_"+m,display:"none",fill:"none",stroke:"#0ff","stroke-opacity":1,"shape-rendering":"crispEdges","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});C.appendChild(u)}if(c){m=f.prev;if(!m){u.setAttribute("display","none");return u}m=svgedit.path.getGripPt(m);
svgedit.path.replacePathSeg(2,0,[m.x,m.y],u);C=svgedit.path.ptObjToArr(f.type,f.item,true);for(var s=0;s<C.length;s+=2){m=svgedit.path.getGripPt(f,{x:C[s],y:C[s+1]});C[s]=m.x;C[s+1]=m.y}svgedit.path.replacePathSeg(f.type,1,C,u)}return u};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,c,m){var u=f.x-m.x,C=f.y-m.y,s=c.x-m.x,L=c.y-m.y;if((u!=0||C!=0)&&(s!=0||L!=0)){f=Math.atan2(C,u);c=Math.atan2(L,s);u=Math.sqrt(u*u+C*C);s=Math.sqrt(s*s+L*L);C=v.getSVGRoot().createSVGPoint();L=
v.getSVGRoot().createSVGPoint();if(f<0)f+=2*Math.PI;if(c<0)c+=2*Math.PI;var Q=Math.abs(f-c),K=Math.abs(Math.PI-Q)/2;if(f-c>0){f=Q<Math.PI?f+K:f-K;c=Q<Math.PI?c-K:c+K}else{f=Q<Math.PI?f-K:f+K;c=Q<Math.PI?c+K:c-K}C.x=u*Math.cos(f)+m.x;C.y=u*Math.sin(f)+m.y;L.x=s*Math.cos(c)+m.x;L.y=s*Math.sin(c)+m.y;return[C,L]}};svgedit.path.Segment=function(f,c){this.selected=false;this.index=f;this.item=c;this.type=c.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=
function(f){for(var c in this.ctrlpts)this.ctrlpts[c].setAttribute("display",f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",
f?"#0FF":"#00F");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var c=svgedit.path.getGripPt(this),m=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,
this.ptgrip.nodeName=="rect"?{x:c.x-m,y:c.y-m}:{cx:c.x,cy:c.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,c){var m=this.item;m=this.ctrlpts?[m.x+=f,m.y+=c,m.x1,m.y1,m.x2+=f,m.y2+=c]:[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.type,this.index,m);if(this.next&&this.next.ctrlpts){m=this.next.item;
m=[m.x,m.y,m.x1+=f,m.y1+=c,m.x2,m.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,m)}if(this.mate){m=this.mate.item;m=[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,m)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var c,m,u;if(f==2){m=1;c=this.next;if(!c)return;u=this.item}else{m=2;c=this.prev;if(!c)return;u=c.item}var C=c.item;C["x"+m]=u.x+(u.x-this.item["x"+f]);C["y"+m]=u.y+(u.y-this.item["y"+
f]);svgedit.path.replacePathSeg(c.type,c.index,[C.x,C.y,C.x1,C.y1,C.x2,C.y2]);c.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,c,m){var u=this.item;u["x"+f]+=c;u["y"+f]+=m;svgedit.path.replacePathSeg(this.type,this.index,[u.x,u.y,u.x1,u.y1,u.x2,u.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,c){svgedit.path.replacePathSeg(f,this.index,c);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);
this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,c=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var m=0;m<c;m++){var u=f.getItem(m);u=new svgedit.path.Segment(m,u);
u.path=this;this.segs.push(u)}f=this.segs;u=null;for(m=0;m<c;m++){var C=f[m],s=m+1>=c?null:f[m+1],L=m-1<0?null:f[m-1];if(C.type===2){if(L&&L.type!==1){s=f[u];s.next=f[u+1];s.next.prev=s;s.addGrip()}u=m}else if(s&&s.type===1){C.next=f[u+1];C.next.prev=C;C.mate=f[u];C.addGrip();if(this.first_seg==null)this.first_seg=C}else if(s){if(C.type!==1){C.addGrip();if(s&&s.type!==2){C.next=s;C.next.prev=C}}}else if(C.type!==1){s=f[u];s.next=f[u+1];s.next.prev=s;s.addGrip();C.addGrip();if(!this.first_seg)this.first_seg=
f[u]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var c=this.segs.length,m=0;m<c;m++)if(f.call(this.segs[m],m)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var c=this.segs[f];if(c.prev){var m=c.prev,u;switch(c.item.pathSegType){case 4:var C=(c.item.x+m.item.x)/2,s=(c.item.y+m.item.y)/2;u=this.elem.createSVGPathSegLinetoAbs(C,s);break;case 6:u=(m.item.x+c.item.x1)/2;var L=(c.item.x1+c.item.x2)/2,Q=(c.item.x2+c.item.x)/2,K=(u+L)/2;L=(L+Q)/2;C=(K+L)/2;var I=(m.item.y+
c.item.y1)/2,S=(c.item.y1+c.item.y2)/2;m=(c.item.y2+c.item.y)/2;var R=(I+S)/2;S=(S+m)/2;s=(R+S)/2;u=this.elem.createSVGPathSegCurvetoCubicAbs(C,s,u,I,K,R);svgedit.path.replacePathSeg(c.type,f,[c.item.x,c.item.y,L,S,Q,m])}svgedit.path.insertItemBefore(this.elem,u,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var c=this.segs[f],m=this.elem.pathSegList;c.show(false);var u=c.next;if(c.mate){var C=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,u.index,C);svgedit.path.replacePathSeg(4,c.index,
C);m.removeItem(c.mate.index)}else{if(!c.prev){C=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,c.next.index,C)}m.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var c=false;svgedit.path.path.eachSeg(function(m){if(m<=f)return true;if(this.type===2)return false;else if(this.type===1){c=true;return false}});return c};svgedit.path.Path.prototype.removePtFromSelection=function(f){var c=this.selected_pts.indexOf(f);if(c!=-1){this.segs[f].select(false);this.selected_pts.splice(c,
1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,c){for(var m=this.selected_pts.length;m--;)this.segs[this.selected_pts[m]].move(f,c)};svgedit.path.Path.prototype.moveCtrl=
function(f,c){var m=this.segs[this.selected_pts[0]];m.moveCtrl(this.dragctrl,f,c);b&&m.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var c=this.selected_pts.length,m;c--;){var u=this.segs[this.selected_pts[c]],C=u.prev;if(C){if(!f){m="Toggle Path Segment Type";f=u.type==6?4:6}f-=0;var s=u.item.x,L=u.item.y,Q=C.item.x;C=C.item.y;var K;switch(f){case 6:if(u.olditem){Q=u.olditem;K=[s,L,Q.x1,Q.y1,Q.x2,Q.y2]}else{K=s-Q;var I=L-C;K=[s,L,Q+K/3,C+I/3,s-K/3,
L-I/3]}break;case 4:K=[s,L];u.olditem=u.item}u.setType(f,K)}}svgedit.path.path.endChanges(m)};svgedit.path.Path.prototype.selectPt=function(f,c){this.clearSelection();f==null&&this.eachSeg(function(m){if(this.prev)f=m});this.addPtsToSelection(f);if(c){this.dragctrl=c;b&&this.segs[f].setLinked(c)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=
null;this.eachSeg(function(c){this.item=f.pathSegList.getItem(c);this.update()});return this};svgedit.path.getPath_=function(f){var c=p[f.id];c||(c=p[f.id]=new svgedit.path.Path(f));return c};svgedit.path.removePath_=function(f){f in p&&delete p[f]};var d=function(f,c,m,u,C,s,L){dx=f-m;dy=c-u;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+L;dx=r*Math.cos(theta)+m;dy=r*Math.sin(theta)+u;dx-=C;dy-=s;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-L;return{x:(r*Math.cos(theta)+C)/1,y:(r*Math.sin(theta)+
s)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,c=svgedit.utilities.getRotationAngle(f,true);if(c){var m=svgedit.utilities.getBBox(f),u=svgedit.path.path.oldbbox,C=u.x+u.width/2;u=u.y+u.height/2;var s=m.x+m.width/2;m=m.y+m.height/2;s=s-C;var L=m-u;m=Math.sqrt(s*s+L*L);L=Math.atan2(L,s)+c;s=m*Math.cos(L)+C;m=m*Math.sin(L)+u;L=f.pathSegList;for(var Q=L.numberOfItems;Q;){Q-=1;var K=L.getItem(Q),I=K.pathSegType;if(I!=1){var S=d(K.x,K.y,C,u,s,m,c);S=[S.x,S.y];if(K.x1!=null&&
K.x2!=null){c_vals1=d(K.x1,K.y1,C,u,s,m,c);c_vals2=d(K.x2,K.y2,C,u,s,m,c);S.splice(S.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(I,Q,S)}}svgedit.utilities.getBBox(f);C=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);C.setRotate(c*180/Math.PI,s,m);f.replaceItem(C,0)}};svgedit.path.clearData=function(){p={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
f?"#4F80FF":"#4F80FF");this.ptgrip.setAttribute("fill",f?"#4F80FF":"#fff");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var c=svgedit.path.getGripPt(this),m=svgedit.browser.isTouch()?
15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:c.x-m,y:c.y-m}:{cx:c.x,cy:c.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,c){var m=this.item;m=this.ctrlpts?[m.x+=f,m.y+=c,m.x1,m.y1,m.x2+=f,m.y2+=c]:[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.type,this.index,
m);if(this.next&&this.next.ctrlpts){m=this.next.item;m=[m.x,m.y,m.x1+=f,m.y1+=c,m.x2,m.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,m)}if(this.mate){m=this.mate.item;m=[m.x+=f,m.y+=c];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,m)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var c,m,u;if(f==2){m=1;c=this.next;if(!c)return;u=this.item}else{m=2;c=this.prev;if(!c)return;u=c.item}var C=c.item;C["x"+m]=u.x+(u.x-
this.item["x"+f]);C["y"+m]=u.y+(u.y-this.item["y"+f]);svgedit.path.replacePathSeg(c.type,c.index,[C.x,C.y,C.x1,C.y1,C.x2,C.y2]);c.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,c,m){var u=this.item;u["x"+f]+=c;u["y"+f]+=m;svgedit.path.replacePathSeg(this.type,this.index,[u.x,u.y,u.x1,u.y1,u.x2,u.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,c){svgedit.path.replacePathSeg(f,this.index,c);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);
this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,c=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;
for(var m=0;m<c;m++){var u=f.getItem(m);u=new svgedit.path.Segment(m,u);u.path=this;this.segs.push(u)}f=this.segs;u=null;for(m=0;m<c;m++){var C=f[m],s=m+1>=c?null:f[m+1],L=m-1<0?null:f[m-1];if(C.type===2){if(L&&L.type!==1){s=f[u];s.next=f[u+1];s.next.prev=s;s.addGrip()}u=m}else if(s&&s.type===1){C.next=f[u+1];C.next.prev=C;C.mate=f[u];C.addGrip();if(this.first_seg==null)this.first_seg=C}else if(s){if(C.type!==1){C.addGrip();if(s&&s.type!==2){C.next=s;C.next.prev=C}}}else if(C.type!==1){s=f[u];s.next=
f[u+1];s.next.prev=s;s.addGrip();C.addGrip();if(!this.first_seg)this.first_seg=f[u]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var c=this.segs.length,m=0;m<c;m++)if(f.call(this.segs[m],m)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var c=this.segs[f];if(c.prev){var m=c.prev,u;switch(c.item.pathSegType){case 4:var C=(c.item.x+m.item.x)/2,s=(c.item.y+m.item.y)/2;u=this.elem.createSVGPathSegLinetoAbs(C,s);break;case 6:u=(m.item.x+c.item.x1)/2;var L=(c.item.x1+
c.item.x2)/2,Q=(c.item.x2+c.item.x)/2,K=(u+L)/2;L=(L+Q)/2;C=(K+L)/2;var I=(m.item.y+c.item.y1)/2,S=(c.item.y1+c.item.y2)/2;m=(c.item.y2+c.item.y)/2;var R=(I+S)/2;S=(S+m)/2;s=(R+S)/2;u=this.elem.createSVGPathSegCurvetoCubicAbs(C,s,u,I,K,R);svgedit.path.replacePathSeg(c.type,f,[c.item.x,c.item.y,L,S,Q,m])}svgedit.path.insertItemBefore(this.elem,u,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var c=this.segs[f],m=this.elem.pathSegList;c.show(false);var u=c.next;if(c.mate){var C=[u.item.x,u.item.y];
svgedit.path.replacePathSeg(2,u.index,C);svgedit.path.replacePathSeg(4,c.index,C);m.removeItem(c.mate.index)}else{if(!c.prev){C=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,c.next.index,C)}m.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var c=false;svgedit.path.path.eachSeg(function(m){if(m<=f)return true;if(this.type===2)return false;else if(this.type===1){c=true;return false}});return c};svgedit.path.Path.prototype.removePtFromSelection=function(f){var c=this.selected_pts.indexOf(f);
if(c!=-1){this.segs[f].select(false);this.selected_pts.splice(c,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,c){for(var m=this.selected_pts.length;m--;)this.segs[this.selected_pts[m]].move(f,
c)};svgedit.path.Path.prototype.moveCtrl=function(f,c){var m=this.segs[this.selected_pts[0]];m.moveCtrl(this.dragctrl,f,c);b&&m.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var c=this.selected_pts.length,m;c--;){var u=this.segs[this.selected_pts[c]],C=u.prev;if(C){if(!f){m="Toggle Path Segment Type";f=u.type==6?4:6}f-=0;var s=u.item.x,L=u.item.y,Q=C.item.x;C=C.item.y;var K;switch(f){case 6:if(u.olditem){Q=u.olditem;K=[s,L,Q.x1,Q.y1,Q.x2,Q.y2]}else{K=
s-Q;var I=L-C;K=[s,L,Q+K/3,C+I/3,s-K/3,L-I/3]}break;case 4:K=[s,L];u.olditem=u.item}u.setType(f,K)}}svgedit.path.path.endChanges(m)};svgedit.path.Path.prototype.selectPt=function(f,c){this.clearSelection();f==null&&this.eachSeg(function(m){if(this.prev)f=m});this.addPtsToSelection(f);if(c){this.dragctrl=c;b&&this.segs[f].setLinked(c)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=
this.matrix=null;this.eachSeg(function(c){this.item=f.pathSegList.getItem(c);this.update()});return this};svgedit.path.getPath_=function(f){var c=p[f.id];c||(c=p[f.id]=new svgedit.path.Path(f));return c};svgedit.path.removePath_=function(f){f in p&&delete p[f]};var d=function(f,c,m,u,C,s,L){dx=f-m;dy=c-u;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+L;dx=r*Math.cos(theta)+m;dy=r*Math.sin(theta)+u;dx-=C;dy-=s;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-L;return{x:(r*Math.cos(theta)+C)/1,y:(r*
Math.sin(theta)+s)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,c=svgedit.utilities.getRotationAngle(f,true);if(c){var m=svgedit.utilities.getBBox(f),u=svgedit.path.path.oldbbox,C=u.x+u.width/2;u=u.y+u.height/2;var s=m.x+m.width/2;m=m.y+m.height/2;s=s-C;var L=m-u;m=Math.sqrt(s*s+L*L);L=Math.atan2(L,s)+c;s=m*Math.cos(L)+C;m=m*Math.sin(L)+u;L=f.pathSegList;for(var Q=L.numberOfItems;Q;){Q-=1;var K=L.getItem(Q),I=K.pathSegType;if(I!=1){var S=d(K.x,K.y,C,u,s,m,c);S=[S.x,S.y];
if(K.x1!=null&&K.x2!=null){c_vals1=d(K.x1,K.y1,C,u,s,m,c);c_vals2=d(K.x2,K.y2,C,u,s,m,c);S.splice(S.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(I,Q,S)}}svgedit.utilities.getBBox(f);C=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);C.setRotate(c*180/Math.PI,s,m);f.replaceItem(C,0)}};svgedit.path.clearData=function(){p={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(q,g){var b=this.length;if(!b)return a.apply(this,arguments);for(var p=0;p<b;p++){var v=this[p];if(v.namespaceURI==="http://www.w3.org/2000/svg")if(g!==undefined)v.setAttribute(q,g);else if($.isArray(q)){b=q.length;for(p={};b--;){var d=q[b],f=v.getAttribute(d);if(f||f==="0")f=isNaN(f)?f:f-0;p[d]=f}return p}else if(typeof q==="object")for(d in q)v.setAttribute(d,q[d]);else{if((f=v.getAttribute(q))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,
arguments)}return this}})();
$.SvgCanvas=function(a,q){function g(e,h){for(var l=svgedit.utilities.getBBox(e),B=0;B<2;B++){var A=B===0?"fill":"stroke",G=e.getAttribute(A);if(G&&G.indexOf("url(")===0){G=P(G);if(G.tagName==="linearGradient"){var D=G.getAttribute("x1")||0,z=G.getAttribute("y1")||0,F=G.getAttribute("x2")||1,k=G.getAttribute("y2")||0;D=l.width*D+l.x;z=l.height*z+l.y;F=l.width*F+l.x;k=l.height*k+l.y;D=N(D,z,h);k=N(F,k,h);F={};F.x1=(D.x-l.x)/l.width;F.y1=(D.y-l.y)/l.height;F.x2=(k.x-l.x)/l.width;F.y2=(k.y-l.y)/l.height;
@ -289,30 +289,30 @@ this.prev){var O=sa.getBBox(),Y=svgedit.path.getGripPt(this);O=svgedit.math.rect
!D.shiftKey&&!G&&svgedit.path.path.selectPt(F)}else if(sa&&sa.getAttribute("display")!="none"){sa.setAttribute("display","none");sa.getAttribute("width")<=2&&sa.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=svgedit.path.getPath_(D);Ga="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;
Ga="select";svgedit.path.path.show(false);h=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(z){M("selected",[D]);qb([D],true)}},addSubPath:function(D){if(D){Ga="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(h===D){La.toEditMode(D);Ga="pathedit"}else h=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(){h=null;if(A){var D=pa(aa());$(pa("path_stretch_line")).remove();$(D).remove();$(pa("pathpointgrip_container")).find("*").attr("display","none");A=B=null;Ka=false}else Ga=="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=X(z).matrix;
z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var k=z.numberOfItems,n=0;n<k;++n){var o=z.getItem(n),w=o.pathSegType;if(w!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],Y=o["y"+J];if(O!==undefined&&Y!==undefined){O=N(O,Y,F);E.splice(E.length,0,O.x,O.y)}});svgedit.path.replacePathSeg(w,n,E,D)}}g(D,F)},zoomChange:function(){Ga=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:
1];return{x:D.item.x,y:D.item.y,type:D.type}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var k=D[z];svgedit.path.path.addSeg(k);F.push(k+z);F.push(k+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var z=svgedit.path.path.elem,
F=z.pathSegList,k=D[0],n=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=k)o=this.item;if(J<=k)return true;if(this.type===2){n=J;return false}else if(this.type===1)return n=false});if(n==null)n=svgedit.path.path.segs.length-1;if(n!==false){var w=z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(n==svgedit.path.path.segs.length){F.appendItem(w);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,n);svgedit.path.insertItemBefore(z,w,n)}svgedit.path.path.init().selectPt(n+
1)}else if(svgedit.path.path.segs[k].mate){F.removeItem(k);F.removeItem(k);svgedit.path.path.init().selectPt(k-1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)w=D;else if(D===k)F.removeItem(w);else if(H.pathSegType===1&&k<D){E=D-1;F.removeItem(D);break}}for(D=k-w-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(w),E);z=F.getItem(w);svgedit.path.replacePathSeg(2,w,[z.x,z.y]);D=k;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();
z.clear();D.removeAttribute("transform");z=D.pathSegList;for(var k=z.numberOfItems,n=0;n<k;++n){var o=z.getItem(n),w=o.pathSegType;if(w!=1){var E=[];$.each(["",1,2],function(H,J){var O=o["x"+J],Y=o["y"+J];if(O!==undefined&&Y!==undefined){O=N(O,Y,F);E.splice(E.length,0,O.x,O.y)}});svgedit.path.replacePathSeg(w,n,E,D)}}g(D,F)},zoomChange:function(){Ga=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){if(svgedit.path.path){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?
svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,z=D.length,F=[];z--;){var k=D[z];svgedit.path.path.addSeg(k);F.push(k+z);F.push(k+z+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===
1){var z=svgedit.path.path.elem,F=z.pathSegList,k=D[0],n=null,o=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=k)o=this.item;if(J<=k)return true;if(this.type===2){n=J;return false}else if(this.type===1)return n=false});if(n==null)n=svgedit.path.path.segs.length-1;if(n!==false){var w=z.createSVGPathSegLinetoAbs(o.x,o.y),E=z.createSVGPathSegClosePath();if(n==svgedit.path.path.segs.length){F.appendItem(w);F.appendItem(E)}else{svgedit.path.insertItemBefore(z,E,n);svgedit.path.insertItemBefore(z,
w,n)}svgedit.path.path.init().selectPt(n+1)}else if(svgedit.path.path.segs[k].mate){F.removeItem(k);F.removeItem(k);svgedit.path.path.init().selectPt(k-1)}else{for(D=0;D<F.numberOfItems;D++){var H=F.getItem(D);if(H.pathSegType===2)w=D;else if(D===k)F.removeItem(w);else if(H.pathSegType===1&&k<D){E=D-1;F.removeItem(D);break}}for(D=k-w-1;D--;)svgedit.path.insertItemBefore(z,F.getItem(w),E);z=F.getItem(w);svgedit.path.replacePathSeg(2,w,[z.x,z.y]);D=k;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();
for(var D=svgedit.path.path.selected_pts,z=D.length;z--;)svgedit.path.path.deleteSeg(D[z]);var F=function(){var k=svgedit.path.path.elem.pathSegList,n=k.numberOfItems,o=function(H,J){for(;J--;)k.removeItem(H)};if(n<=1)return true;for(;n--;){var w=k.getItem(n);if(w.pathSegType===1){w=k.getItem(n-1);var E=k.getItem(n-2);if(w.pathSegType===2){o(n-1,2);F();break}else if(E.pathSegType===2){o(n-2,3);F();break}}else if(w.pathSegType===2)if(n>0){w=k.getItem(n-1).pathSegType;if(w===2){o(n-1,1);F();break}else if(w===
1&&k.numberOfItems-1===n){o(n,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){La.toSelectMode(svgedit.path.path.elem);d.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var k=z.getItem(0),n=null;D=[];D.push(["M",k.x,",",
k.y," C"].join(""));for(var o=1;o<=F-4;o+=3){var w=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(n)if((k=svgedit.path.smoothControlPoints(n,w,k))&&k.length==2){w=D[D.length-1].split(",");w[2]=k[0].x;w[3]=k[0].y;D[D.length-1]=w.join(",");w=k[1]}D.push([w.x,w.y,E.x,E.y,H.x,H.y].join(","));k=H;n=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},
moveNode:function(D,z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var k={x:0,y:0};k[D]=z-F.item[D];F.move(k.x,k.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=D.pathSegList,F=z.numberOfItems,k,n=0;n<F;++n){var o=z.getItem(n);if(o.pathSegType===2)k=o;if(o.pathSegType===1){o=z.getItem(n-1);if(o.x!=k.x||o.y!=k.y){z=D.createSVGPathSegLinetoAbs(k.x,k.y);svgedit.path.insertItemBefore(D,z,n);La.fixEnd(D);
break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,k=F.numberOfItems,n=0,o=0,w="",E=null,H=0;H<k;++H){var J=F.getItem(H),O=J.x||0,Y=J.y||0,da=J.x1||0,V=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});w+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:w+=
"z";break;case 12:O-=n;case 13:if(z){n+=O;qa="l"}else{O+=n;n=O;qa="L"}ua([[O,o]]);break;case 14:Y-=o;case 15:if(z){o+=Y;qa="l"}else{Y+=o;o=Y;qa="L"}ua([[n,Y]]);break;case 2:case 4:case 18:O-=n;Y-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){n=E[0];o=E[1]}case 19:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}if(W===3)E=[n,o];ua([[O,Y]]);break;case 6:O-=n;da-=n;fa-=n;Y-=o;V-=o;ha-=o;case 7:if(z){n+=O;o+=Y}else{O+=n;da+=n;fa+=n;Y+=o;V+=o;ha+=o;n=O;o=Y}ua([[da,V],[fa,ha],[O,Y]]);break;case 8:O-=
n;da-=n;Y-=o;V-=o;case 9:if(z){n+=O;o+=Y}else{O+=n;da+=n;Y+=o;V+=o;n=O;o=Y}ua([[da,V],[O,Y]]);break;case 10:O-=n;Y-=o;case 11:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,Y]);break;case 16:O-=n;fa-=n;Y-=o;ha-=o;case 17:if(z){n+=O;o+=Y}else{O+=n;fa+=n;Y+=o;ha+=o;n=O;o=Y}ua([[fa,ha],[O,Y]])}}return w}}}(),yb=this.removeUnusedDefElems=function(){var e=m.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],l=0,B=["fill","stroke",
"filter","marker-start","marker-mid","marker-end"],A=B.length,G=m.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=G[z],k=0;k<A;k++)if(F){var n=ja(F.getAttribute(B[k]));n&&h.push(n.substr(1))}(F=ba(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){B=e[z];A=B.id;if(h.indexOf(A)<0){sb[A]=B;B.parentNode.removeChild(B);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);
La.clear(true);$.each(m.childNodes,function(l,B){l&&B.nodeType===8&&B.data.indexOf("Created with")>=0&&m.insertBefore(B,m.firstChild)});if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(m).find("g:data(gsvg)").each(function(){for(var l=this.attributes,B=l.length,A=0;A<B;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")B--;if(B<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var h=this.svgToString(m,0);e.length&&$(e).each(function(){tb(this)});return h};this.svgToString=
function(e,h){var l=[],B=svgedit.utilities.toXml,A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,k=e.childNodes;for(F=0;F<h;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var n={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!n[O]&&
ya[O]!=="xmlns"&&ya[O]!=="xml"){n[O]=true;l.push(" xmlns:"+ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){z=D.item(F);var o=B(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var w=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=
0;F--){z=D.item(F);o=B(z.nodeValue);if(!(w.indexOf(z.localName)>=0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);
l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");h++;D=false;for(F=0;F<k.length;F++){A=k.item(F);switch(A.nodeType){case 1:l.push("\n");l.push(this.svgToString(k.item(F),h));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(B(A)+"")}break;case 4:l.push("\n");l.push(Array(h+1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(h+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}h--;if(!D){l.push("\n");
for(F=0;F<h;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var B=";svgedit_url="+encodeURIComponent(e);B=l.toDataURL().replace(";base64",B+";base64");Va[e]=B}catch(A){Va[e]=false}Fa=e;h&&h(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Fa=e};this.open=function(){};
this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],h={feGaussianBlur:kb.exportNoBlur,foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(m);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=kb.exportNoText;$.each(h,function(B,A){l.find(B).length&&e.push(A)});h=this.svgCanvasToString();M("exported",{svg:h,issues:e})};this.getSvgString=function(){$a.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,C()):svgedit.draw.randomizeIds(true,C())};var Hb=this.uniquifyElems=function(e){var h={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(z){if(z.nodeType==1){if(z.id){z.id in h||(h[z.id]={elem:null,attrs:[],hrefs:[]});h[z.id].elem=z}$.each(vb,function(k,n){var o=z.getAttributeNode(n);if(o){var w=svgedit.utilities.getUrlFromAttr(o.value);
if(w=w?w.substr(1):null){w in h||(h[w]={elem:null,attrs:[],hrefs:[]});h[w].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(z)}}});for(var B in h)if(B){var A=h[B].elem;if(A){e=ka();A.id=e;A=h[B].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=h[B].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var h=
$(e);if(e.tagName!=="use")h=h.find("use");h.each(function(){var l=ba(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Ib=this.convertGradients=function(e){var h=$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var l=$(m).find('[fill="url(#'+
this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var B=$(this).attr(["x1","y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=X(A).matrix;A=N(B.x1,B.y1,G);G=N(B.x2,B.y2,G);B.x1=A.x;B.y1=A.y;B.x2=G.x;B.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(B.x1-l.x)/l.width,y1:(B.y1-l.y)/l.height,x2:(B.x2-l.x)/l.width,y2:(B.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},
Lb=this.convertToGroup=function(e){e||(e=I[0]);var h=$(e),l=new Da,B;if(h.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");B=R(e);var A=c.createSVGTransform();A.setTranslate(l.x,l.y);B.appendItem(A);Ra(e);M("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");B=h.attr("transform");A=h.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}B+=" translate("+(A.x||0)+","+(A.y||0)+")";A=h.prev();l.addSubCommand(new Ha(h[0],
1&&k.numberOfItems-1===n){o(n,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){d.setMode("select");d.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var z=D.points,F=z.numberOfItems;if(F>=4){var k=z.getItem(0),n=null;D=[];D.push(["M",k.x,",",k.y," C"].join(""));
for(var o=1;o<=F-4;o+=3){var w=z.getItem(o),E=z.getItem(o+1),H=z.getItem(o+2);if(n)if((k=svgedit.path.smoothControlPoints(n,w,k))&&k.length==2){w=D[D.length-1].split(",");w[2]=k[0].x;w[3]=k[0].y;D[D.length-1]=w.join(",");w=k[1]}D.push([w.x,w.y,E.x,E.y,H.x,H.y].join(","));k=H;n=E}for(D.push("L");o<F;++o){E=z.getItem(o);D.push([E.x,E.y].join(","))}D=D.join(" ");D=S({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,
z){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var k={x:0,y:0};k[D]=z-F.item[D];F.move(k.x,k.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var z=D.pathSegList,F=z.numberOfItems,k,n=0;n<F;++n){var o=z.getItem(n);if(o.pathSegType===2)k=o;if(o.pathSegType===1){o=z.getItem(n-1);if(o.x!=k.x||o.y!=k.y){z=D.createSVGPathSegLinetoAbs(k.x,k.y);svgedit.path.insertItemBefore(D,z,n);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&
D.setAttribute("d",La.convertPath(D))},convertPath:function(D,z){for(var F=D.pathSegList,k=F.numberOfItems,n=0,o=0,w="",E=null,H=0;H<k;++H){var J=F.getItem(H),O=J.x||0,Y=J.y||0,da=J.x1||0,V=J.y1||0,fa=J.x2||0,ha=J.y2||0,W=J.pathSegType,qa=Oa[W]["to"+(z?"Lower":"Upper")+"Case"](),ua=function(Aa,Ca,Pa){Ca=Ca?" "+Ca.join(" "):"";Pa=Pa?" "+svgedit.units.shortFloat(Pa):"";$.each(Aa,function(Qa,Na){Aa[Qa]=svgedit.units.shortFloat(Na)});w+=qa+Aa.join(" ")+Ca+Pa};switch(W){case 1:w+="z";break;case 12:O-=
n;case 13:if(z){n+=O;qa="l"}else{O+=n;n=O;qa="L"}ua([[O,o]]);break;case 14:Y-=o;case 15:if(z){o+=Y;qa="l"}else{Y+=o;o=Y;qa="L"}ua([[n,Y]]);break;case 2:case 4:case 18:O-=n;Y-=o;case 5:case 3:if(E&&F.getItem(H-1).pathSegType===1&&!z){n=E[0];o=E[1]}case 19:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}if(W===3)E=[n,o];ua([[O,Y]]);break;case 6:O-=n;da-=n;fa-=n;Y-=o;V-=o;ha-=o;case 7:if(z){n+=O;o+=Y}else{O+=n;da+=n;fa+=n;Y+=o;V+=o;ha+=o;n=O;o=Y}ua([[da,V],[fa,ha],[O,Y]]);break;case 8:O-=n;da-=n;Y-=o;V-=o;case 9:if(z){n+=
O;o+=Y}else{O+=n;da+=n;Y+=o;V+=o;n=O;o=Y}ua([[da,V],[O,Y]]);break;case 10:O-=n;Y-=o;case 11:if(z){n+=O;o+=Y}else{O+=n;Y+=o;n=O;o=Y}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[O,Y]);break;case 16:O-=n;fa-=n;Y-=o;ha-=o;case 17:if(z){n+=O;o+=Y}else{O+=n;fa+=n;Y+=o;ha+=o;n=O;o=Y}ua([[fa,ha],[O,Y]])}}return w}}}(),yb=this.removeUnusedDefElems=function(){var e=m.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],l=0,B=["fill","stroke","filter","marker-start","marker-mid",
"marker-end"],A=B.length,G=m.getElementsByTagNameNS(b,"*"),D=G.length,z=0;z<D;z++){for(var F=G[z],k=0;k<A;k++)if(F){var n=ja(F.getAttribute(B[k]));n&&h.push(n.substr(1))}(F=ba(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(z=e.length;z--;){B=e[z];A=B.id;if(h.indexOf(A)<0){sb[A]=B;B.parentNode.removeChild(B);l++}}return l};this.svgCanvasToString=function(){for(;yb()>0;);La.clear(true);$.each(m.childNodes,function(l,
B){l&&B.nodeType===8&&B.data.indexOf("Created with")>=0&&m.insertBefore(B,m.firstChild)});if(L){Eb();rb([L])}$("#canvasGrid").attr("display","none");var e=[];$(m).find("g:data(gsvg)").each(function(){for(var l=this.attributes,B=l.length,A=0;A<B;A++)if(l[A].nodeName=="id"||l[A].nodeName=="style")B--;if(B<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var h=this.svgToString(m,0);e.length&&$(e).each(function(){tb(this)});return h};this.svgToString=function(e,h){var l=[],B=svgedit.utilities.toXml,
A=p.baseUnit,G=RegExp("^-?[\\d\\.]+"+A+"$");if(e){la(e);var D=e.attributes,z,F,k=e.childNodes;for(F=0;F<h;F++)l.push(" ");l.push("<");l.push(e.nodeName);if(e.id==="svgcontent"){F=zb();if(A!=="px"){F.w=svgedit.units.convertUnit(F.w,A)+A;F.h=svgedit.units.convertUnit(F.h,A)+A}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var n={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(H,J){var O=J.namespaceURI;if(O&&!n[O]&&ya[O]!=="xmlns"&&ya[O]!=="xml"){n[O]=true;l.push(" xmlns:"+
ya[O]+'="'+O+'"')}})});F=D.length;for(A=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){z=D.item(F);var o=B(z.nodeValue);if(z.nodeName.indexOf("xmlns:")!==0)if(o!=""&&A.indexOf(z.localName)==-1)if(!z.namespaceURI||ya[z.namespaceURI]){l.push(" ");l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var w=["-moz-math-font-style","_moz-math-font-style"];for(F=D.length-1;F>=0;F--){z=D.item(F);o=B(z.nodeValue);if(!(w.indexOf(z.localName)>=
0))if(o!="")if(o.indexOf("pointer-events")!==0)if(!(z.localName==="class"&&o.indexOf("se_")===0)){l.push(" ");if(z.localName==="d")o=La.convertPath(e,true);if(isNaN(o)){if(G.test(o))o=svgedit.units.shortFloat(o)+A}else o=svgedit.units.shortFloat(o);if($a.apply&&e.nodeName==="image"&&z.localName==="href"&&$a.images&&$a.images==="embed"){var E=Va[o];if(E)o=E}if(!z.namespaceURI||z.namespaceURI==b||ya[z.namespaceURI]){l.push(z.nodeName);l.push('="');l.push(o);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");
h++;D=false;for(F=0;F<k.length;F++){A=k.item(F);switch(A.nodeType){case 1:l.push("\n");l.push(this.svgToString(k.item(F),h));break;case 3:A=A.nodeValue.replace(/^\s+|\s+$/g,"");if(A!=""){D=true;l.push(B(A)+"")}break;case 4:l.push("\n");l.push(Array(h+1).join(" "));l.push("<![CDATA[");l.push(A.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(h+1).join(" "));l.push("<!--");l.push(A.data);l.push("--\>")}}h--;if(!D){l.push("\n");for(F=0;F<h;F++)l.push(" ")}l.push("</");l.push(e.nodeName);
l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=this.height;l.getContext("2d").drawImage(this,0,0);try{var B=";svgedit_url="+encodeURIComponent(e);B=l.toDataURL().replace(";base64",B+";base64");Va[e]=B}catch(A){Va[e]=false}Fa=e;h&&h(Va[e])}).attr("src",e)};this.setGoodImage=function(e){Fa=e};this.open=function(){};this.save=function(e){xa();e&&$.extend($a,e);$a.apply=true;
e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){xa();var e=[],h={feGaussianBlur:kb.exportNoBlur,foreignObject:kb.exportNoforeignObject,"[stroke-dasharray]":kb.exportNoDashArray},l=$(m);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=kb.exportNoText;$.each(h,function(B,A){l.find(B).length&&e.push(A)});h=this.svgCanvasToString();M("exported",{svg:h,issues:e})};this.getSvgString=function(){$a.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>
0&&arguments[0]==false?svgedit.draw.randomizeIds(false,C()):svgedit.draw.randomizeIds(true,C())};var Hb=this.uniquifyElems=function(e){var h={},l=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(z){if(z.nodeType==1){if(z.id){z.id in h||(h[z.id]={elem:null,attrs:[],hrefs:[]});h[z.id].elem=z}$.each(vb,function(k,n){var o=z.getAttributeNode(n);if(o){var w=svgedit.utilities.getUrlFromAttr(o.value);if(w=w?w.substr(1):null){w in h||(h[w]=
{elem:null,attrs:[],hrefs:[]});h[w].attrs.push(o)}}});var F=svgedit.utilities.getHref(z);if(F&&l.indexOf(z.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(z)}}});for(var B in h)if(B){var A=h[B].elem;if(A){e=ka();A.id=e;A=h[B].attrs;for(var G=A.length;G--;){var D=A[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}A=h[B].hrefs;for(G=A.length;G--;)svgedit.utilities.setHref(A[G],"#"+e)}}},Gb=this.setUseData=function(e){var h=$(e);if(e.tagName!=="use")h=
h.find("use");h.each(function(){var l=ba(this).substr(1);if(l=pa(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Ib=this.convertGradients=function(e){var h=$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var l=$(m).find('[fill="url(#'+this.id+')"],[stroke="url(#'+
this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var B=$(this).attr(["x1","y1","x2","y2"]),A=this.gradientTransform.baseVal;if(A&&A.numberOfItems>0){var G=X(A).matrix;A=N(B.x1,B.y1,G);G=N(B.x2,B.y2,G);B.x1=A.x;B.y1=A.y;B.x2=G.x;B.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(B.x1-l.x)/l.width,y1:(B.y1-l.y)/l.height,x2:(B.x2-l.x)/l.width,y2:(B.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Lb=this.convertToGroup=
function(e){e||(e=I[0]);var h=$(e),l=new Da,B;if(h.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");B=R(e);var A=c.createSVGTransform();A.setTranslate(l.x,l.y);B.appendItem(A);Ra(e);M("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");B=h.attr("transform");A=h.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");A.x-=+G[0];A.y-=+G[1]}B+=" translate("+(A.x||0)+","+(A.y||0)+")";A=h.prev();l.addSubCommand(new Ha(h[0],
h[0].nextSibling,h[0].parentNode));h.remove();G=$(m).find("use:data(symbol)").length;h=f.createElementNS(b,"g");for(var D=e.childNodes,z=0;z<D.length;z++)h.appendChild(D[z].cloneNode(true));if(svgedit.browser.isGecko()){D=$(gb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(D)}B&&h.setAttribute("transform",B);B=e.parentNode;Hb(h);svgedit.browser.isGecko()&&$(gb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=ka();A.after(h);if(B){if(!G){A=e.nextSibling;
B.removeChild(e);l.addSubCommand(new Ha(e,A,B))}l.addSubCommand(new Ia(h))}Gb(h);svgedit.browser.isGecko()?Ib(gb()):Ib(h);svgedit.utilities.walkTreePost(h,function(F){try{Ra(F)}catch(k){console.log(k)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});rb([h]);(e=Db(h,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);
this.prepareSvg(h);var l=new Da("Change Source"),B=m.nextSibling,A=c.removeChild(m);l.addSubCommand(new Ha(A,B,c));m=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);c.appendChild(m);var G=$(m);d.current_drawing_=new svgedit.draw.Drawing(m,u);var D=C().getNonce();D?M("setnonce",D):M("unsetnonce");G.find("image").each(function(){var J=this;Fb(J);var O=ba(this);if(O.indexOf("data:")===0){var Y=O.match(/svgedit_url=(.*?);/);if(Y){var da=decodeURIComponent(Y[1]);$(new Image).load(function(){J.setAttributeNS("http://www.w3.org/1999/xlink",
@ -424,84 +424,84 @@ a(Qa);Ca=Aa.parent();if(!Aa.parent().hasClass("tools_flyout")){var Na=Aa[0].id.r
if(W.isDefault){a("#cur_"+W.list).append(Qa.children().clone());Aa=W.svgicon?W.svgicon:W.id;da["#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("<div>",{"class":"flyout_arrow_horiz"}));Aa.before(jb);Ca=na(Na,Aa)}var ub=B.getButtonData(Pa.button);if(Pa.isDefault)da["#"+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<ub)Ca.children().eq(Na).before(Qa);else{Ca.append(Qa);ua.reverse()}}V||Qa.append(qa);W.list||a.each(W.events,function(Cb,Jb){if(Cb=="click")if(W.type=="mode"){W.includeWith?Qa.bind(Cb,Jb):Qa.bind(Cb,function(){ra(Qa)&&Jb()});if(W.key){a(document).bind("keydown",W.key,Jb);W.title&&Qa.attr("title",W.title+" ["+W.key+"]")}}else Qa.bind(Cb,Jb);
else Qa.bind(Cb,Jb)});Z(fa)});a.each(O,function(){vb(this.elem,this.list,this.callback,{seticon:true})});if(V)H=false;a.svgIcons(V,{w:27,h:27,id_match:false,no_img:!m,fallback:Y,placement:da,callback:function(){v.iconsize&&v.iconsize!="m"&&o();H=true;J()}})}J()});g.textActions.setInputElem(a("#text")[0]);var Ma='<div class="palette_item transparent" data-rgb="none"></div>\t\t\t\t\t\t\t\t<div class="palette_item black" data-rgb="#000000"></div>\t\t\t\t\t\t\t\t<div class="palette_item white" data-rgb="#ffffff"></div>';
["#482816","#422C10","#3B2F0E","#32320F","#293414","#1F361B","#153723","#0C372C","#083734","#0E353B","#1A333F","#273141","#332D40","#3E2A3C","#462735","#4B252D","#4D2425","#4C261D","#845335","#7B572D","#6F5C2A","#62612C","#546433","#46673D","#396849","#306856","#2D6862","#33666C","#426373","#535F75","#645A73","#74556D","#805064","#884D58","#8B4D4B","#894F3F","#C48157","#B8874D","#A98E49","#97944B","#849854","#729C62","#619E73","#559E84","#529D94","#5B9BA2","#6D97AB","#8391AE","#9A8AAB","#AF84A3",
"#BF7E96","#C97A86","#CE7975","#CC7C65","#FFB27C","#FABA6F","#E6C36A","#CFCA6D","#B8D078","#A0D58A","#8CD79F","#7DD8B5","#7AD6CA","#84D3DB","#9ACEE6","#B6C7EA","#D3BEE7","#EDB6DC","#FFAFCC","#FFAAB8","#FFA9A2","#FFAC8D","#FFE7A2","#FFF093","#FFFA8D","#FFFF91","#EEFF9F","#D1FFB4","#B9FFCE","#A8FFE9","#A4FFFF","#B1FFFF","#CBFFFF","#EDFFFF","#FFF5FF","#FFEBFF","#FFE2FF","#FFDCEC","#FFDBD2","#FFDFB8"].forEach(function(k){Ma+='<div class="palette_item" style="background-color: '+k+';" data-rgb="'+k+'"></div>'});
a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Da.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var n=k.value/100;if(n<0.0010)k.value=0.1;else{k=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/k,y:(o[0].scrollTop+o.height()/2)/k,zoom:n},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());
a("#stroke_style_label").html(this.options[this.selectedIndex].text);window.opera&&a("<p/>").hide().appendTo("body").remove()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k){var n=k.getAttribute("data-attr"),o=k.getAttribute("data-multiplier")||
1;o=parseFloat(o);o=k.value*o;if(!svgedit.units.isValidUnit(n,o,X)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=X.getAttribute(n);return false}g.changeSelectedAttributeNoUndo(n,o)};picking=false;a(document).on("mouseup",function(){picking=false});a("#palette").on("mousemove mousedown touchstart touchmove",".palette_item",function(k){k.preventDefault();if(k.type=="mousedown")picking=true;if(picking){var n=a("#tool_stroke").hasClass("active"),o=n?"stroke":"fill",w=a(this).attr("data-rgb"),
E=null,H=true;if(k.type=="mousedown")H=false;if(w==="transparent"||w==="initial"||w==="#none"){w="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:w.substr(1)});b.paintBox[o].setPaint(E);if(n){g.setColor("stroke",w,H);w!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",w,H);w!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display",
"table-cell");a(this).addClass("expanded");Db()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Db()});var ra=function(k,n){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;var o=o||"normal";n||a(".tools_flyout").fadeOut(o);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=
null,n=null,o=K[0],w=false,E=false;a("#svgcanvas").on("mousemove mouseup touchend",function(H){if(w!==false){o.scrollLeft-=H.clientX-k;o.scrollTop-=H.clientY-n;k=H.clientX;n=H.clientY;if(H.type==="mouseup"||H.type==="touchend")w=false;return false}}).on("mousedown touchmove",function(H){if(H.button===1||E===true||H.originalEvent.touches&&H.originalEvent.touches.length>=2){w=true;k=H.clientX;n=H.clientY;return false}});a(window).mouseup(function(){w=false});a(document).bind("keydown","space",function(H){H.preventDefault();
g.spaceKey=E=true}).bind("keyup","space",function(H){H.preventDefault();g.spaceKey=E=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&K.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&K.removeClass("out")})})();var va=a(".menu"),kb=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=
""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){kb(k)});a("svg, body").on("mousedown touchstart",function(k){if(!(k.target.nodeName&&k.target.nodeName.toLowerCase()==="input"))if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?kb(k):a("#menu_bar").removeClass("active")});a("#workarea").on("mousewheel",
function(k,n,o,w){if(k.altKey){k.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+w*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(k,n,o){if(a(k).length!=0){var w=a(k).find("button"),E=a(k).find("ul").attr("id",a(k)[0].id+"-list");
o||a("#option_lists").append(E);var H=false;o&&a(k).addClass("dropup");E.find("li").bind("mouseup",n);a(window).mouseup(function(){if(!H){w.removeClass("down");E.hide()}H=false});w.bind("mousedown",function(){if(w.hasClass("down")){w.removeClass("down");E.hide()}else{w.addClass("down");if(!o){var J=a(k).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(k,n,o,w){var E=a(k);n=a(n);var H=false,J=w.dropUp;J&&a(k).addClass("dropup");
n.find("li").bind("mouseup",function(){if(w.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");n.hide();n.css({top:0,left:0})}H=false});n.height();a(k).bind("mousedown",function(){var O=a(k).offset();if(J){O.top-=n.height();O.left+=8}else O.top+=a(k).height();a(n).offset(O);if(E.hasClass("down")){E.removeClass("down");n.hide();n.css({top:0,left:0})}else{E.addClass("down");
n.show();H=true;return false}}).hover(function(){H=true}).mouseout(function(){H=false});w.multiclick&&n.mousedown(function(){H=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,n=this.options[this.selectedIndex].text;a("#preview_font").html(n).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,
"page")})});(function(){var k,n=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;N="toolbars";K.mousedown(n)}).blur(function(){N="canvas";K.unbind("mousedown",n);g.getMode()=="textedit"&&a("#text").focus()})})();var cb=function(){ra("#tool_select")&&g.setMode("select")},Ta=function(){ra("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){ra("#tool_line")&&g.setMode("line")},Fa=function(){ra("#tool_rect")&&g.setMode("rect")},ta=function(){ra("#tool_ellipse")&&
g.setMode("ellipse")},$a=function(){ra("#tool_image")&&g.setMode("image")},Ka=function(){ra("#tool_zoom")&&g.setMode("zoom")},Sa=function(){if(ra("#tool_zoom")){yb();oa()}},Ga=function(){ra("#tool_text")&&g.setMode("text")},db=function(){ra("#tool_path")&&g.setMode("path")},lb=function(){if(X!=null||U)g.deleteSelectedElements()},Ua=function(){if(X!=null||U){xa(a("#edit_menu"));g.cutSelectedElements()}},Xa=function(){if(X!=null||U){xa(a("#edit_menu"));g.copySelectedElements()}},wb=function(){xa(a("#edit_menu"));
var k=g.getZoom(),n=(K[0].scrollLeft+K.width()/2)/k-g.contentW;k=(K[0].scrollTop+K.height()/2)/k-g.contentH;g.pasteElements("point",n,k)},sa=function(){if(X!=null){xa(a("#object_menu"));g.moveToTopSelectedElement()}},hb=function(){if(X!=null){xa(a("#object_menu"));g.moveToBottomSelectedElement()}},eb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Up")}},sb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Down")}},ib=function(k){if(X!=null){xa(a("#object_menu"));
g.moveUpDownSelected(k)}},ab=function(){if(X!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).reset(elems[0]);g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");C.toEditMode(elems[0]);g.clearSelection();Ha()}},ob=function(){X!=null&&C.reorient()},pb=function(){if(X!=null||U)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},fb=function(k,n){if(X!=null||
U){if(curConfig.gridSnapping){var o=g.getZoom()*curConfig.snappingStep;k*=o;n*=o}a("input").blur();g.moveSelectedElements(k,n)}},tb=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);C.linkControlPoints(k)},ia=function(){C.getNodePoint()&&C.clonePathNode()},aa=function(){C.getNodePoint()&&C.deletePathNode()},ka=function(){var k=a("#tool_add_subpath"),
n=!k.hasClass("push_button_pressed");n?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");C.addSubPath(n)},M=function(){C.opencloseSubPath()},P=function(){g.cycleElement(1)},ca=function(){g.cycleElement(0)},Ea=function(k,n){if(!(X==null||U)){k||(n*=-1);var o=a("#angle").val()*1+n;g.setRotationAngle(o);Ha()}},Oa=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(n){if(n){oa();g.clear();
g.setResolution(k[0],k[1]);G(true);yb();Ha();ba();g.runExtensions("onNewDocument")}})},Wa=function(){g.setBold(!g.getBold());Ha()},Za=function(){g.setItalic(!g.getItalic());Ha()},nb=function(){if(!d.pngsave){var k=uiStrings.notification.loadingImage;S=window.open("data:text/html;charset=utf-8,<title>"+k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Ra=function(){g.open()},mb=function(){},
xa=function(k){var n=k.prev();n.css({background:"white",color:"black"});setTimeout(function(){n.removeAttr("style")},200)},qb=function(){if(s.getUndoStackSize()>0){xa(a("#edit_menu"));s.undo()}},rb=function(){if(s.getRedoStackSize()>0){xa(a("#edit_menu"));s.redo()}},Bb=function(){if(U){xa(a("#object_menu"));g.groupSelectedElements()}else if(X){xa(a("#object_menu"));g.ungroupSelectedElement()}},Fb=function(){xa(a("#edit_menu"));g.cloneSelectedElements(20,20)},bb=function(){var k=this.id.replace("tool_align",
"").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},La=function(){var k=document.querySelector("#tool_stroke rect");a("#tool_stroke").toggleClass("active");a("#tool_fill").toggleClass("active");var n=document.querySelector("#tool_fill rect"),o=n.getAttribute("fill"),w=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));if(isNaN(k))k=100;n=parseFloat(n.getAttribute("fill-opacity"));if(isNaN(n))n=100;w=ya(w,k,"stroke");o=ya(o,n,"fill");b.paintBox.fill.setPaint(w,
true);b.paintBox.stroke.setPaint(o,true)},yb=function(k){var n=g.getResolution();k=k?n.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);xb();G(true)},Hb=function(){xa(a("#view_menu"));!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");K.toggleClass("wireframe");if(!h){var k=a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");xb()}},Gb=function(){xa(a("#view_menu"));
var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},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(!h){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(K.hasClass("wireframe")?k:"")}},Eb=function(k,n){if(!ea){xa(a("#view_menu"));ea=true;a("#save_output_btns").toggle(!!n);a("#tool_source_back").toggle(!n);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();ba()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();Ya();yb();ba()});oa()}},zb=b.setIcon=function(k,n){var o=typeof n==="string"?a.getSvgIcon(n,true):n.clone();o?a(k).find("img").replaceWith(o):console.log("NOTE: Icon image missing: "+n)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0],
o;for(o in n.style)if(k.test(o))return o.match(k)[0];if("WebkitOpacity"in n.style)return"Webkit";if("KhtmlOpacity"in n.style)return"Khtml";return""}();var Nb=function(k,n){gb.toLowerCase();var o=["top","left","bottom","right"];k.each(function(){for(var w=a(this),E=w.outerWidth()*(n-1),H=w.outerHeight()*(n-1),J=0;J<4;J++){var O=o[J],Y=w.data("orig_margin-"+O);if(Y==null){Y=parseInt(w.css("margin-"+O));w.data("orig_margin-"+O,Y)}Y=Y*n;if(O==="right")Y+=E;else if(O==="bottom")Y+=H;w.css("margin-"+O,
Y)}})},Mb=b.setIconSize=function(k,n){if(!(k==v.size&&!n)){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"),w=1;w=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=R=w;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,w);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();
else o=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(Y,da){if(typeof da==="number")var V=da*w+"px";else if(da[k]||da.all)V=da[k]||da.all;H+=Y+":"+V+";"});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("+w+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/w+");}";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(k){k&&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 k=g.getHref(X);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(n){n&&Ia(n)})});var e=function(k){var n=k[0].id=="stroke_color"?"stroke":
"fill",o=k[0].id=="canvas_color";if(o)n="canvas";var w=b.paintBox[n].paint;k=n=="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:w,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){w=new a.jGraduate.Paint(E);b.paintBox[n].setPaint(w);
g.setPaint(n,w);a("#color_picker").hide()},function(){a("#color_picker").hide()})};c=function(k,n){var o=document.getElementById("canvas_background"),w={color:"fff",opacity:1};if(n=="stroke")w=curConfig.initStroke;if(n=="fill")w=curConfig.initFill;if(n=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))w={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('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
w.color+'" opacity="'+w.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;o=a(k)[0].appendChild(document.importNode(o,true));n==="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:w.color});this.type=n;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,Y=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",Y);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,Y,true)}};this.update=function(E){if(X){var H=this.type;switch(X.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var J=null,O=X.getElementsByTagName("*"),Y=0,da=O.length;Y<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H===
"fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(ya(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*
100);c=b.paintBox.fill.rect.cloneNode(false);c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);
v.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",
function(){e(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");e(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");e(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||
a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a(window).bind("load resize",function(){K.css("line-height",K.height()+"px")});var l=function(){var k=a("#canvas_width"),n=a("#canvas_height"),o=k.val(),w=n.val();if(o!="fit"&&!svgedit.units.isValidUnit("width",o)){a.alert(uiStrings.notification.invalidAttrValGiven);
k.parent().addClass("error");return false}k.parent().removeClass("error");if(w!="fit"&&!svgedit.units.isValidUnit("height",w)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");if(!g.setResolution(o,w)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();k.val(o.w);n.val(o.h);return false}G()};a("#resolution").change(function(){var k=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value==
"content"){k.value="fit";n.value="fit";l();var o=g.getResolution();k.value=o.w;n.value=o.h}else{var w=this.value.split("x");w[0]=parseInt(w[0]);w[1]=parseInt(w[1]);var E=w[0]-k.value,H=w[1]-n.value,J=Date.now(),O=function(Y){Y=(Y-J)/1E3;Y=Math.pow(Y-1,3)+1;k.value=(w[0]-E+Y*E).toFixed(0);n.value=(w[1]-H+Y*H).toFixed(0);l();if(Y>=1){Y=g.getResolution();a("#canvas_width").val(Y.w.toFixed());a("#canvas_height").val(Y.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Y.w+"<span>\u00d7</span></br>"+
Y.h+"</div>")}else requestAnimationFrame(O)};O(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;n.value=100}}});a("#zoom").change(function(){wa(this)});a("input,select").attr("autocomplete","off");var B=function(){var k=[{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:Fa,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:Ga,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:[u+"N",true]},{sel:"#tool_save",fn:function(){if(ea)Kb();else{xa(a("#file_menu"));g.save({images:v.img_save,round_digits:6})}},evt:"mouseup",key:[u+"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:[u+"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:"click"},{sel:"#tool_node_clone",fn:ia,evt:"click"},{sel:"#tool_node_delete",fn:aa,evt:"click"},{sel:"#tool_openclose_path",fn:M,evt:"click"},{sel:"#tool_add_subpath",fn:ka,evt:"click"},{sel:"#tool_move_top",fn:sa,evt:"click",key:u+"shift+up"},{sel:"#tool_move_bottom",fn:hb,evt:"click",key:u+"shift+down"},{sel:"#tool_move_up",fn:eb,evt:"click",key:[u+"up",true]},{sel:"#tool_move_down",
fn:sb,evt:"click",key:[u+"down",true]},{sel:"#tool_topath",fn:ab,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:pb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Fb,evt:"click",key:[u+"D",true]},{sel:"#tool_group",fn:Bb,evt:"click",key:[u+"G",true]},{sel:"#tool_ungroup",fn:Bb,evt:"click",key:u+"shift+G"},{sel:"#tool_unlink_use",fn:Bb,evt:"click"},{sel:"[id^=tool_align]",fn:bb,evt:"click"},{sel:"#tool_undo",fn:qb,evt:"click",key:u+"z"},{sel:"#tool_redo",fn:rb,evt:"click",key:["y",
true]},{sel:"#tool_cut",fn:Ua,evt:"click",key:[u+"x",true]},{sel:"#tool_copy",fn:Xa,evt:"click",key:u+"c"},{sel:"#tool_paste",fn:wb,evt:"click",key:u+"v"},{sel:"#tool_switch",fn:La,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:Wa,evt:"mousedown",key:[u+"B",true]},{sel:"#tool_italic",fn:Za,evt:"mousedown",key:[u+"I",true]},{sel:"#copy_save_done",fn:Ab,evt:"click"},{key:"ctrl+left",fn:function(){Ea(0,1)}},{key:"ctrl+right",fn:function(){Ea(1,1)}},{key:"ctrl+shift+left",fn:function(){Ea(0,5)}},{key:"ctrl+shift+right",
fn:function(){Ea(1,5)}},{key:"shift+O",fn:ca},{key:"shift+P",fn:P},{key:[u+"+",true],fn:function(){yb(2)}},{key:[u+"-",true],fn:function(){yb(0.5)}},{key:["up",true],fn:function(){fb(0,-1)}},{key:["down",true],fn:function(){fb(0,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:u+"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:u+"shift+z",fn:rb},{key:"esc",fn:Ib}],n={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var o=
{};a.each(k,function(w,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,Y=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)Y=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(V,fa){a(document).bind("keydown",fa,function(ha){O();Y&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var da=H.attr("title").split("[")[0]+" ("+J+")";n[J]=E.sel;H.parents("#main_menu").length||H.attr("title",da)}}});Z(o);a(window).bind("keydown","tab",function(w){if(N==="canvas"){w.preventDefault();P()}}).bind("keydown","shift+tab",function(w){if(N==="canvas"){w.preventDefault();ca()}});a("#tool_zoom").dblclick(Sa)},
setTitles:function(){a.each(n,function(o,w){var E=a(w).parents("#main_menu").length;a(w).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,Y){var da=Y.split("+"),V="";if(da.length>1){V=da[0]+"+";Y=da[1]}J+=(O?"/":"")+V+(uiStrings["key_"+Y]||Y)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var w;a.each(k,function(E,H){if(H.sel===o)w=H});return w}}}();B.setAll();b.ready(function(){var k=
curConfig.initTool,n=a("#tools_left, #svg_editor .tools_flyout"),o=n.find("#tool_"+k);k=n.find("#"+k);(o.length?o:k.length?k: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,cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});
a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,
callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var n=k.value;if(n==0&&X&&["line","polyline"].indexOf(X.nodeName)>=0)n=k.value=1;g.setStrokeWidth(n)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value,
true);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,n){var o=k.value-0,w=o+n,E=w>=o;if(n===0)return o;return o>=24?E?Math.round(o*1.1):Math.round(o/1.1):o<=1?E?o*2:o/2:w},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(k,n){val=k.value;a("#blur").val(val);n?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(k){switch(k){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(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();I.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(s.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&
b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();s.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){c=function(k){k.stopPropagation();k.preventDefault();a("#workarea").removeAttr("style");a("#main_menu").hide();var n=null;if(n=k.type=="drop"?k.dataTransfer.files[0]:this.files[0])if(n.type.indexOf("image")!=-1)if(n.type.indexOf("svg")!=-1){k=new FileReader;k.onloadend=function(o){g.importSvgString(o.target.result,
true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};k.readAsText(n)}else alert("sorry, bitmap import is temporalily disabled")};K=a("#workarea");K[0].addEventListener("dragenter",function(k){k.stopPropagation();k.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(k){k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("dragleave",function(k){K.removeAttr("style");k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("drop",c,false);var A=a('<input type="file">').change(function(){var k=this;b.openPrep(function(n){if(n){g.clear();if(k.files.length==1){n=new FileReader;n.onloadend=function(o){q(o.target.result);G()};n.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(A);
c=a('<input type="file">').change(c);a("#tool_import").show().prepend(c)}var G=b.updateCanvas=function(k,n){var o=K.width(),w=K.height(),E=o,H=w,J=g.getZoom(),O=K,Y=a("#svgcanvas"),da={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},V=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*V);w=Math.max(H,g.contentH*J*V);o==E&&w==H?K.css("overflow","hidden"):K.css("overflow","scroll");V=Y.height()/2;var fa=Y.width()/2;Y.width(o).height(w);var ha=w/2,W=o/2,qa=g.updateCanvas(o,w),ua=W/fa;o=o/2-E/2;w=w/2-H/
2;if(n){n.x+=qa.x;n.y+=qa.y}else n={x:W+(da.x-fa)*ua,y:ha+(da.y-V)*ua};if(k)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=w}else{O[0].scrollLeft=n.x-E/2;O[0].scrollTop=n.y-H/2}if(curConfig.showRulers){E=Y;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(Y=0;Y<2;Y++){fa=(da=Y===0)?"x":"y";ua=
da?"width":"height";V=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(w=1;w<Ca;w++){o[ua]=3E4;var Pa=o.cloneNode(true);o.parentNode.appendChild(Pa);Aa[w]=Pa.getContext("2d")}Pa[ua]=fa%3E4;fa=3E4}o[ua]=fa;ua=
O*J;var Qa=50/ua;o=1;for(w=0;w<D.length;w++){o=Ca=D[w];if(Qa<=Ca)break}Qa=o*ua;qa.font="normal 9px 'Lucida Grande', sans-serif";qa.fillStyle="#777";for(var Na=V/ua%o*ua,jb=Na-Qa;Na<ha;Na+=Qa){jb+=Qa;w=Math.round(Na)+0.5;if(da){qa.moveTo(w,15);qa.lineTo(w,0)}else{qa.moveTo(15,w);qa.lineTo(0,w)}Ca=(jb-V)/ua;if(o>=1)w=Math.round(Ca);else{w=(o+"").split(".")[1].length;w=Ca.toFixed(w)-0}if(w!==0&&w!==1E3&&w%1E3===0)w=w/1E3+"K";if(da){qa.fillText(w,Na+2,8);qa.fillStyle="#777"}else{Ca=(w+"").split("");for(w=
0;w<Ca.length;w++){qa.fillText(Ca[w],1,Na+9+w*9);qa.fillStyle="#777"}}Ca=Qa/10;for(w=1;w<10;w++){var ub=Math.round(Na+Ca*w)+0.5;if(Aa&&ub>fa){W++;qa.stroke();if(W>=Aa.length){w=10;Na=ha;continue}qa=Aa[W];Na-=3E4;ub=Math.round(Na+Ca*w)+0.5}var Cb=w%2?12:10;if(da){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(c=0.1;c<1E5;c*=10){D.push(1*c);D.push(2*c);D.push(5*c)}G(true);try{var z=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);
var n=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.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(k.length){for(var o=0;o<k.length;o++)k[o]=n(k[o]);return"["+k.join(",")+"]"}else{o=[];for(var w in k)o.push(n(w)+":"+n(k[w]));return"{"+o.join(",")+"}"}};window.addEventListener("message",
function(k){var n=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+n+";"+z(eval(k.data)),"*")}catch(o){k.source.postMessage("SVGe"+n+";error:"+o.message,"*")}},false)}catch(F){window.embed_error=F}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,n){a.pref("lang",k);a("#lang_select").val(k);if(n){g.runExtensions("langChanged",k);ma();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block",
"#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(o,w){a(w).attr("title",a(o)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(c){p?c():f.push(c)};b.runCallbacks=function(){a.each(f,function(){this()});p=true};b.loadFromString=function(c){b.ready(function(){q(c)})};b.loadFromURL=function(c,m){m||(m={});var u=m.cache,C=m.callback;b.ready(function(){a.ajax({url:c,dataType:"text",
cache:!!u,success:function(s){q(s,C)},error:function(s,L,Q){s.status!=404&&s.responseText?q(s.responseText,C):a.alert(uiStrings.notification.URLloadFail+": \n"+Q+"",C)}})})};b.loadFromDataURI=function(c){b.ready(function(){var m=c.substring(26);q(svgedit.utilities.decode64(m))})};b.addExtension=function(){var c=arguments;a(function(){g&&g.addExtension.apply(this,c)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
["#444444","#482816","#422C10","#3B2F0E","#32320F","#293414","#1F361B","#153723","#0C372C","#083734","#0E353B","#1A333F","#273141","#332D40","#3E2A3C","#462735","#4B252D","#4D2425","#4C261D","#666666","#845335","#7B572D","#6F5C2A","#62612C","#546433","#46673D","#396849","#306856","#2D6862","#33666C","#426373","#535F75","#645A73","#74556D","#805064","#884D58","#8B4D4B","#894F3F","#999999","#C48157","#B8874D","#A98E49","#97944B","#849854","#729C62","#619E73","#559E84","#529D94","#5B9BA2","#6D97AB",
"#8391AE","#9A8AAB","#AF84A3","#BF7E96","#C97A86","#CE7975","#CC7C65","#BBBBBB","#FFB27C","#FABA6F","#E6C36A","#CFCA6D","#B8D078","#A0D58A","#8CD79F","#7DD8B5","#7AD6CA","#84D3DB","#9ACEE6","#B6C7EA","#D3BEE7","#EDB6DC","#FFAFCC","#FFAAB8","#FFA9A2","#FFAC8D","#DDDDDD","#FFE7A2","#FFF093","#FFFA8D","#FFFF91","#EEFF9F","#D1FFB4","#B9FFCE","#A8FFE9","#A4FFFF","#B1FFFF","#CBFFFF","#EDFFFF","#FFF5FF","#FFEBFF","#FFE2FF","#FFDCEC","#FFDBD2","#FFDFB8"].forEach(function(k){Ma+='<div class="palette_item" style="background-color: '+
k+';" data-rgb="'+k+'"></div>'});a("#palette").append(Ma);var Da=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Da.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var n=k.value/100;if(n<0.0010)k.value=0.1;else{k=g.getZoom();var o=K;ja(window,{width:0,height:0,x:(o[0].scrollLeft+o.width()/2)/k,y:(o[0].scrollTop+o.height()/2)/k,zoom:n},true)}};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",
a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);window.opera&&a("<p/>").hide().appendTo("body").remove()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k){var n=k.getAttribute("data-attr"),
o=k.getAttribute("data-multiplier")||1;o=parseFloat(o);o=k.value*o;if(!svgedit.units.isValidUnit(n,o,X)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=X.getAttribute(n);return false}g.changeSelectedAttributeNoUndo(n,o)};picking=false;a(document).on("mouseup",function(){picking=false});a("#palette").on("mousemove mousedown touchstart touchmove",".palette_item",function(k){k.preventDefault();if(k.type=="mousedown")picking=true;if(picking){var n=a("#tool_stroke").hasClass("active"),o=n?
"stroke":"fill",w=a(this).attr("data-rgb"),E=null,H=true;if(k.type=="mousedown")H=false;if(w==="transparent"||w==="initial"||w==="#none"){w="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:w.substr(1)});b.paintBox[o].setPaint(E);if(n){g.setColor("stroke",w,H);w!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",w,H);w!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}}).bind("contextmenu",function(k){k.preventDefault()});
a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Db()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Db()});var ra=function(k,n){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;var o=o||"normal";n||a(".tools_flyout").fadeOut(o);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");
return true};(function(){var k=null,n=null,o=K[0],w=false,E=false;a("#svgcanvas").on("mousemove mouseup touchend",function(H){if(w!==false){o.scrollLeft-=H.clientX-k;o.scrollTop-=H.clientY-n;k=H.clientX;n=H.clientY;if(H.type==="mouseup"||H.type==="touchend")w=false;return false}}).on("mousedown touchmove",function(H){if(H.button===1||E===true||H.originalEvent.touches&&H.originalEvent.touches.length>=2){w=true;k=H.clientX;n=H.clientY;return false}});a(window).mouseup(function(){w=false});a(document).bind("keydown",
"space",function(H){H.preventDefault();g.spaceKey=E=true}).bind("keyup","space",function(H){H.preventDefault();g.spaceKey=E=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&K.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&K.removeClass("out")})})();var va=a(".menu"),kb=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background=
"#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){kb(k)});a("svg, body").on("mousedown touchstart",function(k){if(!(k.target.nodeName&&k.target.nodeName.toLowerCase()==="input"))if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?kb(k):a("#menu_bar").removeClass("active")});
a("#workarea").on("mousewheel",function(k,n,o,w){if(k.altKey){k.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+w*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");va.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){va.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(k,n,o){if(a(k).length!=0){var w=a(k).find("button"),E=a(k).find("ul").attr("id",
a(k)[0].id+"-list");o||a("#option_lists").append(E);var H=false;o&&a(k).addClass("dropup");E.find("li").bind("mouseup",n);a(window).mouseup(function(){if(!H){w.removeClass("down");E.hide()}H=false});w.bind("mousedown",function(){if(w.hasClass("down")){w.removeClass("down");E.hide()}else{w.addClass("down");if(!o){var J=a(k).offset();E.css({top:J.top,left:J.left-110})}E.show();H=true}}).hover(function(){H=true}).mouseout(function(){H=false})}};var vb=function(k,n,o,w){var E=a(k);n=a(n);var H=false,
J=w.dropUp;J&&a(k).addClass("dropup");n.find("li").bind("mouseup",function(){if(w.seticon){zb("#cur_"+E[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}o.apply(this,arguments)});a(window).mouseup(function(){if(!H){E.removeClass("down");n.hide();n.css({top:0,left:0})}H=false});n.height();a(k).bind("mousedown",function(){var O=a(k).offset();if(J){O.top-=n.height();O.left+=8}else O.top+=a(k).height();a(n).offset(O);if(E.hasClass("down")){E.removeClass("down");
n.hide();n.css({top:0,left:0})}else{E.addClass("down");n.show();H=true;return false}}).hover(function(){H=true}).mouseout(function(){H=false});w.multiclick&&n.mousedown(function(){H=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,n=this.options[this.selectedIndex].text;a("#preview_font").html(n).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos",
"").charAt(0);g.alignSelectedElements(k,"page")})});(function(){var k,n=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;N="toolbars";K.mousedown(n)}).blur(function(){N="canvas";K.unbind("mousedown",n);g.getMode()=="textedit"&&a("#text").focus()})})();var cb=function(){ra("#tool_select")&&g.setMode("select")},Ta=function(){ra("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){ra("#tool_line")&&g.setMode("line")},Fa=function(){ra("#tool_rect")&&
g.setMode("rect")},ta=function(){ra("#tool_ellipse")&&g.setMode("ellipse")},$a=function(){ra("#tool_image")&&g.setMode("image")},Ka=function(){ra("#tool_zoom")&&g.setMode("zoom")},Sa=function(){if(ra("#tool_zoom")){yb();oa()}},Ga=function(){ra("#tool_text")&&g.setMode("text")},db=function(){ra("#tool_path")&&g.setMode("path")};console.log(C.getNodePoint());var lb=function(){if(X!=null||U)g.deleteSelectedElements();C.getNodePoint()&&C.deletePathNode()},Ua=function(){if(X!=null||U){xa(a("#edit_menu"));
g.cutSelectedElements()}},Xa=function(){if(X!=null||U){xa(a("#edit_menu"));g.copySelectedElements()}},wb=function(){xa(a("#edit_menu"));var k=g.getZoom(),n=(K[0].scrollLeft+K.width()/2)/k-g.contentW;k=(K[0].scrollTop+K.height()/2)/k-g.contentH;g.pasteElements("point",n,k)},sa=function(){if(X!=null){xa(a("#object_menu"));g.moveToTopSelectedElement()}},hb=function(){if(X!=null){xa(a("#object_menu"));g.moveToBottomSelectedElement()}},eb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Up")}},
sb=function(){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected("Down")}},ib=function(k){if(X!=null){xa(a("#object_menu"));g.moveUpDownSelected(k)}},ab=function(){if(X!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).reset(elems[0]);g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");C.toEditMode(elems[0]);g.clearSelection();Ha()}},ob=function(){X!=null&&C.reorient()},pb=function(){if(X!=
null||U)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},fb=function(k,n){if(X!=null||U){if(curConfig.gridSnapping){var o=g.getZoom()*curConfig.snappingStep;k*=o;n*=o}a("input").blur();g.moveSelectedElements(k,n)}},tb=function(){var k=!a("#tool_node_link").hasClass("checked");C.linkControlPoints(k)},ia=function(){C.getNodePoint()&&C.clonePathNode()},aa=function(){C.getNodePoint()&&C.deletePathNode()},ka=function(){var k=a("#tool_add_subpath"),n=!k.hasClass("push_button_pressed");
n?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");C.addSubPath(n)},M=function(){C.opencloseSubPath()},P=function(){g.cycleElement(1)},ca=function(){g.cycleElement(0)},Ea=function(k,n){if(!(X==null||U)){k||(n*=-1);var o=a("#angle").val()*1+n;g.setRotationAngle(o);Ha()}},Oa=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(n){if(n){oa();g.clear();g.setResolution(k[0],k[1]);G(true);yb();
Ha();ba();g.runExtensions("onNewDocument")}})},Wa=function(){g.setBold(!g.getBold());Ha()},Za=function(){g.setItalic(!g.getItalic());Ha()},nb=function(){if(!d.pngsave){var k=uiStrings.notification.loadingImage;S=window.open("data:text/html;charset=utf-8,<title>"+k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Ra=function(){g.open()},mb=function(){},xa=function(k){var n=k.prev();n.css({background:"white",
color:"black"});setTimeout(function(){n.removeAttr("style")},200)},qb=function(){if(s.getUndoStackSize()>0){xa(a("#edit_menu"));s.undo()}},rb=function(){if(s.getRedoStackSize()>0){xa(a("#edit_menu"));s.redo()}},Bb=function(){if(U){xa(a("#object_menu"));g.groupSelectedElements()}else if(X){xa(a("#object_menu"));g.ungroupSelectedElement()}},Fb=function(){xa(a("#edit_menu"));g.cloneSelectedElements(20,20)},bb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},
La=function(){var k=document.querySelector("#tool_stroke rect");a("#tool_stroke").toggleClass("active");a("#tool_fill").toggleClass("active");var n=document.querySelector("#tool_fill rect"),o=n.getAttribute("fill"),w=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));if(isNaN(k))k=100;n=parseFloat(n.getAttribute("fill-opacity"));if(isNaN(n))n=100;w=ya(w,k,"stroke");o=ya(o,n,"fill");b.paintBox.fill.setPaint(w,true);b.paintBox.stroke.setPaint(o,true)},yb=function(k){var n=g.getResolution();
k=k?n.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);xb();G(true)},Hb=function(){xa(a("#view_menu"));!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");K.toggleClass("wireframe");if(!h){var k=a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");xb()}},Gb=function(){xa(a("#view_menu"));var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):
a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},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(!h){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(K.hasClass("wireframe")?k:"")}},Eb=function(k,n){if(!ea){xa(a("#view_menu"));ea=true;a("#save_output_btns").toggle(!!n);a("#tool_source_back").toggle(!n);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();ba()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();Ya();yb();ba()});oa()}},zb=b.setIcon=function(k,n){var o=typeof n==="string"?a.getSvgIcon(n,true):n.clone();o?a(k).find("img").replaceWith(o):console.log("NOTE: Icon image missing: "+n)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0],o;for(o in n.style)if(k.test(o))return o.match(k)[0];if("WebkitOpacity"in n.style)return"Webkit";
if("KhtmlOpacity"in n.style)return"Khtml";return""}();var Nb=function(k,n){gb.toLowerCase();var o=["top","left","bottom","right"];k.each(function(){for(var w=a(this),E=w.outerWidth()*(n-1),H=w.outerHeight()*(n-1),J=0;J<4;J++){var O=o[J],Y=w.data("orig_margin-"+O);if(Y==null){Y=parseInt(w.css("margin-"+O));w.data("orig_margin-"+O,Y)}Y=Y*n;if(O==="right")Y+=E;else if(O==="bottom")Y+=H;w.css("margin-"+O,Y)}})},Mb=b.setIconSize=function(k,n){if(!(k==v.size&&!n)){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"),
w=1;w=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=R=w;pa();var E=o.parents(":hidden");E.css("visibility","hidden").show();Nb(o,w);E.css("visibility","visible").hide();o=a("#tool_size_rules");if(o.length)o.empty();else o=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var H="";a.each(cssResizeRules,function(J,O){J="#svg_editor "+J.replace(/,/g,", #svg_editor");H+=J+"{";a.each(O,function(Y,da){if(typeof da==="number")var V=da*w+"px";else if(da[k]||da.all)V=
da[k]||da.all;H+=Y+":"+V+";"});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("+w+");} #svg_editor div.toolset .toolset {"+E+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+E+"transform: scale("+1/w+");}";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(k){k&&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 k=g.getHref(X);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(n){n&&Ia(n)})});var e=function(k){var n=k[0].id=="stroke_color"?"stroke":"fill",o=k[0].id=="canvas_color";if(o)n="canvas";var w=b.paintBox[n].paint;k=n=="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:w,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){w=new a.jGraduate.Paint(E);b.paintBox[n].setPaint(w);g.setPaint(n,w);a("#color_picker").hide()},function(){a("#color_picker").hide()})};c=function(k,n){var o=document.getElementById("canvas_background"),w={color:"fff",opacity:1};if(n=="stroke")w=curConfig.initStroke;if(n=="fill")w=curConfig.initFill;if(n=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))w=
{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('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+w.color+'" opacity="'+w.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;o=a(k)[0].appendChild(document.importNode(o,true));n==="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:w.color});this.type=n;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,Y=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",Y);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,Y,true)}};this.update=function(E){if(X){var H=this.type;switch(X.tagName){case "use":case "image":case "foreignObject":return;
case "g":case "a":for(var J=null,O=X.getElementsByTagName("*"),Y=0,da=O.length;Y<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H==="fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(ya(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=
new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);c=b.paintBox.fill.rect.cloneNode(false);c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);v.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){e(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");e(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");e(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){K.css("line-height",K.height()+"px")});var l=function(){var k=a("#canvas_width"),n=a("#canvas_height"),o=k.val(),w=n.val();if(o!="fit"&&!svgedit.units.isValidUnit("width",o)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(w!="fit"&&!svgedit.units.isValidUnit("height",w)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");
if(!g.setResolution(o,w)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();k.val(o.w);n.val(o.h);return false}G()};a("#resolution").change(function(){var k=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";n.value="fit";l();var o=g.getResolution();k.value=o.w;n.value=o.h}else{var w=this.value.split("x");w[0]=parseInt(w[0]);w[1]=parseInt(w[1]);var E=w[0]-k.value,H=w[1]-n.value,J=Date.now(),O=function(Y){Y=(Y-J)/1E3;Y=Math.pow(Y-
1,3)+1;k.value=(w[0]-E+Y*E).toFixed(0);n.value=(w[1]-H+Y*H).toFixed(0);l();if(Y>=1){Y=g.getResolution();a("#canvas_width").val(Y.w.toFixed());a("#canvas_height").val(Y.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Y.w+"<span>\u00d7</span></br>"+Y.h+"</div>")}else requestAnimationFrame(O)};O(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;n.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var B=function(){var k=[{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:Fa,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:Ga,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:[u+"N",true]},{sel:"#tool_save",fn:function(){if(ea)Kb();else{xa(a("#file_menu"));g.save({images:v.img_save,round_digits:6})}},evt:"mouseup",key:[u+"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:[u+"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:"click"},{sel:"#tool_node_clone",fn:ia,evt:"click"},{sel:"#tool_node_delete",fn:aa,evt:"click"},{sel:"#tool_openclose_path",
fn:M,evt:"click"},{sel:"#tool_add_subpath",fn:ka,evt:"click"},{sel:"#tool_move_top",fn:sa,evt:"click",key:u+"shift+up"},{sel:"#tool_move_bottom",fn:hb,evt:"click",key:u+"shift+down"},{sel:"#tool_move_up",fn:eb,evt:"click",key:[u+"up",true]},{sel:"#tool_move_down",fn:sb,evt:"click",key:[u+"down",true]},{sel:"#tool_topath",fn:ab,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:pb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Fb,evt:"click",key:[u+"D",true]},{sel:"#tool_group",fn:Bb,
evt:"click",key:[u+"G",true]},{sel:"#tool_ungroup",fn:Bb,evt:"click",key:u+"shift+G"},{sel:"#tool_unlink_use",fn:Bb,evt:"click"},{sel:"[id^=tool_align]",fn:bb,evt:"click"},{sel:"#tool_undo",fn:qb,evt:"click",key:u+"z"},{sel:"#tool_redo",fn:rb,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:Ua,evt:"click",key:[u+"x",true]},{sel:"#tool_copy",fn:Xa,evt:"click",key:u+"c"},{sel:"#tool_paste",fn:wb,evt:"click",key:u+"v"},{sel:"#tool_switch",fn:La,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:Wa,evt:"mousedown",
key:[u+"B",true]},{sel:"#tool_italic",fn:Za,evt:"mousedown",key:[u+"I",true]},{sel:"#copy_save_done",fn:Ab,evt:"click"},{key:"ctrl+left",fn:function(){Ea(0,1)}},{key:"ctrl+right",fn:function(){Ea(1,1)}},{key:"ctrl+shift+left",fn:function(){Ea(0,5)}},{key:"ctrl+shift+right",fn:function(){Ea(1,5)}},{key:"shift+O",fn:ca},{key:"shift+P",fn:P},{key:[u+"+",true],fn:function(){yb(2)}},{key:[u+"-",true],fn:function(){yb(0.5)}},{key:["up",true],fn:function(){fb(0,-1)}},{key:["down",true],fn:function(){fb(0,
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:u+"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:u+"shift+z",fn:rb},{key:"esc",fn:Ib}],n={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var o={};a.each(k,function(w,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,Y=false;if(a.isArray(E.key)){J=E.key[0];if(E.key.length>1)Y=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(V,fa){a(document).bind("keydown",fa,function(ha){O();Y&&ha.preventDefault();return false})});if(E.sel&&!E.hidekey&&H.attr("title")){var da=H.attr("title").split("[")[0]+" ("+J+")";n[J]=E.sel;H.parents("#main_menu").length||
H.attr("title",da)}}});Z(o);a(window).bind("keydown","tab",function(w){if(N==="canvas"){w.preventDefault();P()}}).bind("keydown","shift+tab",function(w){if(N==="canvas"){w.preventDefault();ca()}});a("#tool_zoom").dblclick(Sa)},setTitles:function(){a.each(n,function(o,w){var E=a(w).parents("#main_menu").length;a(w).each(function(){var H=E?a(this).text().split(" [")[0]:this.title.split(" [")[0],J="";a.each(o.split("/"),function(O,Y){var da=Y.split("+"),V="";if(da.length>1){V=da[0]+"+";Y=da[1]}J+=(O?
"/":"")+V+(uiStrings["key_"+Y]||Y)});if(E)this.lastChild.textContent=H+" ["+J+"]";else this.title=H+" ["+J+"]"})})},getButtonData:function(o){var w;a.each(k,function(E,H){if(H.sel===o)w=H});return w}}}();B.setAll();b.ready(function(){var k=curConfig.initTool,n=a("#tools_left, #svg_editor .tools_flyout"),o=n.find("#tool_"+k);k=n.find("#"+k);(o.length?o:k.length?k: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,
cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var n=k.value;if(n==0&&
X&&["line","polyline"].indexOf(X.nodeName)>=0)n=k.value=1;g.setStrokeWidth(n)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value,true);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,n){var o=k.value-0,w=o+n,E=w>=o;if(n===0)return o;
return o>=24?E?Math.round(o*1.1):Math.round(o/1.1):o<=1?E?o*2:o/2:w},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(k,n){val=k.value;a("#blur").val(val);n?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(k){switch(k){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(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});
a("#cmenu_canvas li").disableContextMenu();I.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(s.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();s.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){c=function(k){k.stopPropagation();k.preventDefault();a("#workarea").removeAttr("style");
a("#main_menu").hide();var n=null;if(n=k.type=="drop"?k.dataTransfer.files[0]:this.files[0])if(n.type.indexOf("image")!=-1)if(n.type.indexOf("svg")!=-1){k=new FileReader;k.onloadend=function(o){g.importSvgString(o.target.result,true);g.ungroupSelectedElement();g.ungroupSelectedElement();g.groupSelectedElements();g.alignSelectedElements("m","page");g.alignSelectedElements("c","page")};k.readAsText(n)}else alert("sorry, bitmap import is temporalily disabled")};K=a("#workarea");K[0].addEventListener("dragenter",
function(k){k.stopPropagation();k.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(k){k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("dragleave",function(k){K.removeAttr("style");k.stopPropagation();k.preventDefault()},false);K[0].addEventListener("drop",c,false);var A=a('<input type="file">').change(function(){var k=
this;b.openPrep(function(n){if(n){g.clear();if(k.files.length==1){n=new FileReader;n.onloadend=function(o){q(o.target.result);G()};n.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(A);c=a('<input type="file">').change(c);a("#tool_import").show().prepend(c)}var G=b.updateCanvas=function(k,n){var o=K.width(),w=K.height(),E=o,H=w,J=g.getZoom(),O=K,Y=a("#svgcanvas"),da={x:O[0].scrollLeft+E/2,y:O[0].scrollTop+H/2},V=curConfig.canvas_expansion;o=Math.max(E,g.contentW*J*V);w=Math.max(H,g.contentH*
J*V);o==E&&w==H?K.css("overflow","hidden"):K.css("overflow","scroll");V=Y.height()/2;var fa=Y.width()/2;Y.width(o).height(w);var ha=w/2,W=o/2,qa=g.updateCanvas(o,w),ua=W/fa;o=o/2-E/2;w=w/2-H/2;if(n){n.x+=qa.x;n.y+=qa.y}else n={x:W+(da.x-fa)*ua,y:ha+(da.y-V)*ua};if(k)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=w}else{O[0].scrollLeft=n.x-E/2;O[0].scrollTop=n.y-H/2}if(curConfig.showRulers){E=Y;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(Y=0;Y<2;Y++){fa=(da=Y===0)?"x":"y";ua=da?"width":"height";V=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(w=1;w<Ca;w++){o[ua]=3E4;var Pa=o.cloneNode(true);o.parentNode.appendChild(Pa);Aa[w]=Pa.getContext("2d")}Pa[ua]=fa%3E4;fa=3E4}o[ua]=fa;ua=O*J;var Qa=50/ua;o=1;for(w=0;w<D.length;w++){o=Ca=D[w];if(Qa<=Ca)break}Qa=o*ua;qa.font="normal 9px 'Lucida Grande', sans-serif";qa.fillStyle="#777";for(var Na=V/ua%o*ua,jb=Na-Qa;Na<ha;Na+=Qa){jb+=Qa;w=Math.round(Na)+0.5;if(da){qa.moveTo(w,15);qa.lineTo(w,0)}else{qa.moveTo(15,w);qa.lineTo(0,w)}Ca=(jb-V)/ua;if(o>=1)w=Math.round(Ca);else{w=(o+"").split(".")[1].length;
w=Ca.toFixed(w)-0}if(w!==0&&w!==1E3&&w%1E3===0)w=w/1E3+"K";if(da){qa.fillText(w,Na+2,8);qa.fillStyle="#777"}else{Ca=(w+"").split("");for(w=0;w<Ca.length;w++){qa.fillText(Ca[w],1,Na+9+w*9);qa.fillStyle="#777"}}Ca=Qa/10;for(w=1;w<10;w++){var ub=Math.round(Na+Ca*w)+0.5;if(Aa&&ub>fa){W++;qa.stroke();if(W>=Aa.length){w=10;Na=ha;continue}qa=Aa[W];Na-=3E4;ub=Math.round(Na+Ca*w)+0.5}var Cb=w%2?12:10;if(da){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(c=0.1;c<1E5;c*=10){D.push(1*c);D.push(2*c);D.push(5*c)}G(true);try{var z=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var n=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.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(k.length){for(var o=
0;o<k.length;o++)k[o]=n(k[o]);return"["+k.join(",")+"]"}else{o=[];for(var w in k)o.push(n(w)+":"+n(k[w]));return"{"+o.join(",")+"}"}};window.addEventListener("message",function(k){var n=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+n+";"+z(eval(k.data)),"*")}catch(o){k.source.postMessage("SVGe"+n+";error:"+o.message,"*")}},false)}catch(F){window.embed_error=F}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,n){a.pref("lang",k);a("#lang_select").val(k);
if(n){g.runExtensions("langChanged",k);ma();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(o,w){a(w).attr("title",a(o)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(c){p?c():f.push(c)};b.runCallbacks=function(){a.each(f,function(){this()});
p=true};b.loadFromString=function(c){b.ready(function(){q(c)})};b.loadFromURL=function(c,m){m||(m={});var u=m.cache,C=m.callback;b.ready(function(){a.ajax({url:c,dataType:"text",cache:!!u,success:function(s){q(s,C)},error:function(s,L,Q){s.status!=404&&s.responseText?q(s.responseText,C):a.alert(uiStrings.notification.URLloadFail+": \n"+Q+"",C)}})})};b.loadFromDataURI=function(c){b.ready(function(){var m=c.substring(26);q(svgedit.utilities.decode64(m))})};b.addExtension=function(){var c=arguments;
a(function(){g&&g.addExtension.apply(this,c)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var q=this.dragCfg.dragAdjust,g=$(this).parent(),b=$(this),p=this.dragCfg.height,v=this.dragCfg.min,d=this.dragCfg.max,f=this.dragCfg.step,c=d-v>0?(d-v)/f:200,m=c/p*f,u=0,C=this.getAttribute("data-attr"),s=svgEditor.canvas,L=svgedit.browser.isTouch(),Q=true,K=c&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(g):false;b.attr("readonly","readonly");K&&!isNaN(this.dragCfg.start)&&K.css("top",this.dragCfg.start*-1/m+p);this.adjustValue=
function(I,S){var R;I=parseFloat(I);R=isNaN(this.value)?this.dragCfg.reset:$.isFunction(this.dragCfg.stepfunc)?this.dragCfg.stepfunc(this,I):Number((Number(this.value)+Number(I)).toFixed(5));if(d!==null)R=Math.min(R,d);if(v!==null)R=Math.max(R,v);K&&this.updateCursor(R);this.value=R;g.attr("data-value",R);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,S)};g.toggleClass("draginput",g.is("label"));this.move=function(I,S,R){if(L)I=I.originalEvent.touches[0];if(u===0)u=S;S=(I.pageY-u)*
-1;u=I.pageY;R=S*m*q;this.adjustValue(R.toFixed(f<1?1:0))};this.stop=function(){var I=s.getSelectedElems();$("body").removeClass("dragging");g.removeClass("active");Q=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");u=0;if(I[0]){I=s.undoMgr.finishUndoableChange();I.isEmpty()||s.undoMgr.addCommandToHistory(I)}this.adjustValue(0,Q)};this.updateCursor=function(){var I=parseFloat(this.value)*-1/m+p;K.css("top",I)};this.launch=function(I){var S=s.getSelectedElems();

View File

@ -869,7 +869,7 @@ html, body {
.palette_item {
height: 20%;
width: 5.4%;
width: 5.2%;
float: left;
cursor: url(images/eyedropper.png) 0 16, crosshair;
}
@ -2454,6 +2454,10 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1),
cursor: -moz-grab;
}
.draginput input[type="checkbox"], .draginput input[type="checkbox"]:hover, .draginput input[type="checkbox"]:active {
cursor: default;
}
.draginput.active input, .draginput.active input:hover, .draginput.active input:active {
cursor: url(images/dragging.png), move;
cursor: -webkit-grabbing;