function touchHandler(a){var p=a.changedTouches,g=p[0],b="";switch(a.type){case "touchstart":b="mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(b,true,true,window,1,g.screenX,g.screenY,g.clientX,g.clientY,false,false,false,false,0,null);if(p.length<2){g.target.dispatchEvent(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var b=g.handler,n=g.data.toLowerCase().split(" ");g.handler=function(s){if(!(this!==s.target&&(/textarea|select/i.test(s.target.nodeName)||s.target.type==="text"))){var c=s.type!=="keypress"&&a.hotkeys.specialKeys[s.which],f=String.fromCharCode(s.which).toLowerCase(),d="",l={};if(s.altKey&&c!=="alt")d+="alt+";if(s.ctrlKey&&c!=="ctrl")d+="ctrl+";if(s.metaKey&&!s.ctrlKey&&c!=="meta")d+="meta+";if(s.shiftKey&&c!=="shift")d+="shift+";if(c)l[d+c]= true;else{l[d+f]=true;l[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[f]]=true}c=0;for(f=n.length;c","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,Z,pa,qa){var ma;if(pa!==f){W=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=W[3]||"";if(qa===2&&g(pa))pa=pa.replace(da?Y:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=qa===2?pa:qa===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+Z}else da= W(Z!==f?Z:p[oa][fa]);return da}function s(da,W,Z){if(W===f||typeof W==="boolean"){Z=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?Y:ba,""):W;return o(W,Z)}function c(da,W,Z,pa){if(!g(Z)&&typeof Z!=="object"){pa=Z;Z=W;W=f}return this.each(function(){var qa=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},O,J,Q,V=a.event.special,N="querystring",ia="fragment",oa= "location",fa="href",ba=/^.*\?|#.*$/g,Y=/^.*\#/,sa,ka={};q[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var Z={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(qa,ma){var na=ma.split("="),Aa=l(na[0]),Fa=Z,Ia= 0,Ca=Aa.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(W)na=na&&!isNaN(na)?+na:na==="undefined"?f:pa[na]!==f?pa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia').hide().insertAfter("body")[0].contentWindow; J=function(){return b(T.document[c][f])};O=function(Q,V){if(Q!==V){var N=T.document;N.open().close();N[c].hash="#"+Q}};O(b())}}var o={},K,T,O,J;o.start=function(){if(!K){var Q=b();O||B();(function V(){var N=b(),ia=J(Q);if(N!==Q){O(Q=N,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[c][f]=p[c][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(V,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(b,n){function s(da,W){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(W&&Z)){V++;if(V<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||c()},500);else{Z=oa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){c(true)}).error(function(){c()})}} function c(da,W){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(W){var pa=n.fallback_path?n.fallback_path:"";a.each(W,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:pa+Na,width:B,height:o,alt:"icon"});ka(za,Ka)})}else for(var qa=K.length,ma=0;ma0&&!da)ya=g(ya,za,true);sa(a(this),ya,Na)})});if(!W){da&&Z.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)} function d(da){if(window.btoa)return window.btoa(da);var W=Array(Math.floor((da.length+2)/3)*4),Z,pa,qa,ma,na,Aa,Fa=0,Ia=0;do{Z=da.charCodeAt(Fa++);pa=da.charCodeAt(Fa++);qa=da.charCodeAt(Fa++);ma=Z>>2;Z=(Z&3)<<4|pa>>4;na=(pa&15)<<2|qa>>6;Aa=qa&63;if(isNaN(pa))na=Aa=64;else if(isNaN(qa))Aa=64;W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na); W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&N.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s); s(0,true)}catch(ba){f()}}else{var Y=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){T=Y.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=Y.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,Z,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",Z);(Z=da.attr("class"))&&W.attr("class", "svg_icon "+Z);da.replaceWith(W)}else da.append(W);ia&&setTimeout(function(){W.removeAttr("style")},1)},ka=function(da,W){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,W,true);p[W]=da};g=function(da,W){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var pa=da[0].getElementsByTagName("*"),qa=pa.length;Z.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+W+ma;na="url(#"+na+")";var Aa="url(#"+ma+")";for(ma= 0;ma=0;jQuery.fn.jGraduate=function(b){var n= arguments;return this.each(function(){function s(la,ca,ja,M,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},Y);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else Y.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga= a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Pa){c(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")|| 1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Ua){db=Ua.val("hex")?"#"+Ua.val("hex"):"none";Ya=Ua.val("a")!==null?Ua.val("a")/256:1;Pa.setAttribute("fill",db);Pa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color", db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(Y).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity", db===null?1:db)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform", la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var M=0;$(Y).find("stop").each(function(){var R=this.getAttribute("offset"), ea=$(this);if(R
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var V=$(K+"> .jGraduate_colPick"),N=$(K+"> .jGraduate_gradPick");N.html('

    '+B.window.pickerTitle+'


    ');var ia=256,oa=ia-0,fa=ia-0,ba,Y,sa,ka={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],W=a("svg",{id:o+"_jgraduate_svg",width:ia,height:ia,xmlns:p.svg},da);ba=ba||q.paint.type;var Z=Y=q.paint[ba],pa=q.paint.alpha,qa=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!qa){Y.id=o+"_lg_jgraduate_grad"; Z=Y=W.appendChild(Y)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!qa){Y.id=o+"_rg_jgraduate_grad";Z=Y=W.appendChild(Y)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(qa){Z=Y=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){J.substr(na,2);var Aa=(255-parseInt(J.substr(na,2),16)).toString(16); if(Aa.length<2)Aa=0+Aa;ma+=Aa}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(Z.getAttribute("x1")||0);ma=parseFloat(Z.getAttribute("y1")||0);na=parseFloat(Z.getAttribute("x2")||1);Aa=parseFloat(Z.getAttribute("y2")||0);var Fa=parseFloat(Z.getAttribute("cx")||0.5),Ia=parseFloat(Z.getAttribute("cy")||0.5),Ca=parseFloat(Z.getAttribute("fx")||Fa),Ka=parseFloat(Z.getAttribute("fy")|| Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:oa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":pa/100},W);var Na=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:J*ia}).data("coord","start").appendTo(da),za=Na.clone().text(2).css({top:Aa*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa* ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=Y.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value> 1)this.value=1;if(!(ca[0]==="f"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")Y.setAttribute(ca,this.value);var R=M?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:za,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16, height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Da)});qb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb= N.find(".jGraduate_spreadMethod").change(function(){Y.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/oa;ja=ja/fa;var M=Za.data("coord"),R=Y;switch(M){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca); ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=Y.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na99.5)M=99.5;if(M>0)La=1-M/100;else fb=-(M/100)-1;R=145*((M+100)/ 2)/100;ea&&d();break;case "angle":Va=M;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;Y.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break; case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(N=(q.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+N;qa||(J=wa[0].getAttribute("stop-color")); $.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){O()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current"); $(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(Y!==ca){var ja= $(Y).find("stop");$(ca).empty().append(ja);Y=ca;ca=sb.val();Y.setAttribute("spreadMethod",ca)}jb=la==="rg"&&Y.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb= $(K+" .jGraduate_tab_radgrad");break;default:Bb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,b){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),c=$("#"+g.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2|| g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var B=d.pageX,o=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;o=d.originalEvent.touches[0].pageY}d=a.width()-c.width();l=a.height()-c.height();if(B>d-15)B=d-15; if(o>l-30)o=l-30;if(svgedit.browser.isTouch())o-=c.height()/2;p.unbind("click");c.css({top:o,left:B}).fadeIn(g.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover"); break;case 40:if(c.find("LI.hover").length==0)c.find("LI:first").addClass("hover");else{c.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:first").addClass("hover")}break;case 13:c.find("LI.hover A").trigger("click");break;case 27:p.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){p.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1), $(q),{x:B-s.left,y:o-s.top,docX:B,docY:o});return false});setTimeout(function(){p.click(function(){p.unbind("click").unbind("keypress");c.fadeOut(g.outSpeed);return false})},0)};if($.browser.mozilla)$("#"+g.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+g.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+g.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})});$(n).add($("UL.contextMenu")).bind("contextmenu", function(){return false})});return $(this)},disableContextMenuItems:function(g){if(g==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(g!=undefined)for(var b=g.split(","),n=0;n=0,s=p.indexOf("Gecko/")>=0,c=p.indexOf("MSIE")>=0,f=p.indexOf("Chrome/")>=0,d=p.indexOf("Windows")>=0,l=p.indexOf("Macintosh")>= 0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(oa,0);return true}catch(ba){}return false}(),T=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(oa, 0);return true}catch(ba){}return false}(),O=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);fa.setAttribute("x",5);oa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(oa);return fa===0}(),J=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(oa);return fa.height>4&&fa.height<5}(),Q=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 10,0");var ba= document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(fa);Y.appendChild(ba);oa.appendChild(Y);fa=Y.getBBox();document.documentElement.removeChild(oa);return fa.width==15}(),V=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the latest version in which the problems have been fixed."); return oa}(),N=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("style","vector-effect:non-scaling-stroke");return oa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();oa.appendItem(fa);return oa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return s}; svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J}; svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return V};svgedit.browser.supportsNonScalingStroke=function(){return N};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{}; (function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),p={};svgedit.transformlist.SVGTransformList=function(g){this._elem=g||null;this._xforms=[];this._update=function(){var b="";a.createSVGMatrix();for(var n=0;n=0)return this._xforms[b];throw{code:1};};this.insertItemBefore=function(b,n){var s=null;if(n>=0)if(n=0){this._removeFromOtherLists(b);s=this._xforms[n]=b;this._list._update()}return s};this.removeItem=function(b){if(b=0){for(var n=this._xforms[b],s=Array(this.numberOfItems- 1),c=0;c1;)b=p[g-1].multiply(b);if(Math.abs(b.a)<1.0E-14)b.a=0;if(Math.abs(b.b)<1.0E-14)b.b=0;if(Math.abs(b.c)<1.0E-14)b.c=0;if(Math.abs(b.d)< 1.0E-14)b.d=0;if(Math.abs(b.e)<1.0E-14)b.e=0;if(Math.abs(b.f)<1.0E-14)b.f=0;return b};svgedit.math.hasMatrixTransform=function(p){if(!p)return false;for(var g=p.numberOfItems;g--;){var b=p.getItem(g);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(p,g,b,n,s){var c={x:p,y:g},f={x:p+b,y:g};b={x:p+b,y:g+n};p={x:p,y:g+n};g=svgedit.math.transformPoint;c=g(c.x,c.y,s);var d=n=c.x,l=c.y,q=c.y;f=g(f.x,f.y,s);n=Math.min(n,f.x);d=Math.max(d,f.x); l=Math.min(l,f.y);q=Math.max(q,f.y);p=g(p.x,p.y,s);n=Math.min(n,p.x);d=Math.max(d,p.x);l=Math.min(l,p.y);q=Math.max(q,p.y);b=g(b.x,b.y,s);n=Math.min(n,b.x);d=Math.max(d,b.x);l=Math.min(l,b.y);q=Math.max(q,b.y);return{tl:c,tr:f,bl:p,br:b,aabox:{x:n,y:l,width:d-n,height:q-l}}};svgedit.math.transformListToTransform=function(p,g,b){if(p==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());g=g==undefined?0:g;b=b==undefined?p.numberOfItems-1:b;g=parseInt(g);b=parseInt(b);if(g>b){var n=b;b=g; g=n}n=a.createSVGMatrix();for(g=g;g<=b;++g){var s=g>=0&&gp.x&&g.yp.y}})();svgedit=svgedit||{}; (function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],p=["y","y1","cy","ry","height"],g=$.merge(["r","radius"],a);$.merge(g,p);var b,n={px:1};svgedit.units.init=function(c){b=c;c=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(c);var f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("width","1em");f.setAttribute("height","1ex");f.setAttribute("x","1in");c.appendChild(f);f=f.getBBox();document.body.removeChild(c); c=f.x;n.em=f.width;n.ex=f.height;n["in"]=c;n.cm=c/2.54;n.mm=c/25.4;n.pt=c/72;n.pc=c/6;n["%"]=0};svgedit.units.getTypeMap=function(){return n};svgedit.units.shortFloat=function(c){var f=b.getRoundDigits();if(isNaN(c)){if($.isArray(c))return svgedit.units.shortFloat(c[0])+","+svgedit.units.shortFloat(c[1])}else return+(+c).toFixed(f);return parseFloat(c).toFixed(f)-0};svgedit.units.convertUnit=function(c,f){f=f||b.getBaseUnit();return svgedit.unit.shortFloat(c/n[f])};svgedit.units.setUnitAttr=function(c, f,d){isNaN(d)||c.getAttribute(f);c.setAttribute(f,d)};var s={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(c){var f=c.tagName,d=b.getBaseUnit();if(f=s[f])for(var l=f.length,q=0;q=0?d*l:p.indexOf(c)>=0?d*q:d*Math.sqrt(l*l+q*q)/Math.sqrt(2)}else{l=f.substr(-2);d=f.substr(0,f.length-2);return d*n[l]}};svgedit.units.isValidUnit=function(c,f,d){var l=false;if(g.indexOf(c)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(n,function(o){if(!l)if(RegExp("^-?[\\d\\.]+"+o+"$").test(f))l=true})}else l=true;else if(c=="id"){c=false;try{var q=b.getElement(f); c=q==null||q===d}catch(B){}return c}else l=true;return l}})();svgedit=svgedit||{}; (function(){function a(c){if(svgedit.browser.supportsHVLineContainerBBox())try{return c.getBBox()}catch(f){}var d=$.data(c,"ref"),l=null;if(d){var q=$(d).children().clone().attr("visibility","hidden");$(s).append(q);l=q.filter("line, path")}else l=$(c).find("line, path");var B=false;if(l.length){l.each(function(){var o=this.getBBox();if(!o.width||!o.height)B=true});if(B){c=d?q:$(c).children();ret=getStrokedBBox(c)}else ret=c.getBBox()}else ret=c.getBBox();d&&q.remove();return ret}if(!svgedit.utilities)svgedit.utilities= {};var p="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),g=null,b=null,n=null,s=null;svgedit.utilities.init=function(c){g=c;b=c.getDOMDocument();n=c.getDOMContainer();s=c.getSVGRoot()};svgedit.utilities.toXml=function(c){return $("

    ").text(c).html()};svgedit.utilities.fromXml=function(c){return $("

    ").html(c).text()};svgedit.utilities.encode64=function(c){c=svgedit.utilities.convertToXMLReferences(c);if(window.btoa)return window.btoa(c); var f=Array(Math.floor((c.length+2)/3)*4),d,l,q,B,o,K,T=0,O=0;do{d=c.charCodeAt(T++);l=c.charCodeAt(T++);q=c.charCodeAt(T++);B=d>>2;d=(d&3)<<4|l>>4;o=(l&15)<<2|q>>6;K=q&63;if(isNaN(l))o=K=64;else if(isNaN(q))K=64;f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(o);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(K)}while(T< c.length);return f.join("")};svgedit.utilities.decode64=function(c){if(window.atob)return window.atob(c);var f="",d,l,q="",B,o="",K=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++)); d=d<<2|l>>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+=String.fromCharCode(l);if(o!=64)f+=String.fromCharCode(q)}while(K127)f+="&#"+l+";"}return f};svgedit.utilities.text2xml=function(c){if(c.indexOf("=0)c=c.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var f;try{var d=window.DOMParser? new DOMParser:new ActiveXObject("Microsoft.XMLDOM");d.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{f=d.loadXML?d.loadXML(c)?d:false:d.parseFromString(c,"text/xml")}catch(q){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(c){return{x:c.x,y:c.y,width:c.width,height:c.height}};svgedit.utilities.walkTree=function(c,f){if(c&&c.nodeType==1){f(c);for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),f)}}; svgedit.utilities.walkTreePost=function(c,f){if(c&&c.nodeType==1){for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),f);f(c)}};svgedit.utilities.getUrlFromAttr=function(c){if(c)if(c.indexOf('url("')===0)return c.substring(5,c.indexOf('"',6));else if(c.indexOf("url('")===0)return c.substring(5,c.indexOf("'",6));else if(c.indexOf("url(")===0)return c.substring(4,c.indexOf(")"));return null};svgedit.utilities.getHref=function(c){return c.getAttributeNS("http://www.w3.org/1999/xlink", "href")};svgedit.utilities.setHref=function(c,f){c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(c){c=g.getSVGContent().documentElement;var f=c.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:c.insertBefore(c.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),c.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(c){var f=c.pathSegList,d=f.numberOfItems;c=[[],[]];var l=f.getItem(0), q=[l.x,l.y];for(l=0;l= 0){var l=d.split(":");c[l[1]]=p[l[0]]}else c[d]=d=="xmlns"?"http://www.w3.org/2000/xmlns/":null});b[n]=c});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(n){if(n.nodeType==3){n.nodeValue=n.nodeValue.replace(/^\s+|\s+$/g,"");n.nodeValue.length||n.parentNode.removeChild(n)}if(n.nodeType==1){var s=n.parentNode;if(n.ownerDocument&&s){var c=g[n.nodeName],f=b[n.nodeName];if(c!=undefined){for(var d=[],l=n.attributes.length;l--;){var q=n.attributes.item(l),B=q.nodeName, o=q.localName,K=q.namespaceURI;if(!(f.hasOwnProperty(o)&&K==f[o]&&K!="http://www.w3.org/2000/xmlns/")&&!(K=="http://www.w3.org/2000/xmlns/"&&a[q.nodeValue])){B.indexOf("se:")==0&&d.push([B,q.nodeValue]);n.removeAttributeNS(K,o)}if(svgedit.browser.isGecko())switch(B){case "transform":case "gradientTransform":case "patternTransform":o=q.nodeValue.replace(/(\d)-/g,"$1 -");n.setAttribute(B,o)}if(B=="style"){q=q.nodeValue.split(";");for(B=q.length;B--;){o=q[B].split(":");c.indexOf(o[0])>=0&&n.setAttribute(o[0], o[1])}n.removeAttribute("style")}}$.each(d,function(T,O){n.setAttributeNS("http://svg-edit.googlecode.com",O[0],O[1])});if((l=svgedit.utilities.getHref(n))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(n.nodeName)>=0)if(l[0]!="#"){svgedit.utilities.setHref(n,"");n.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(n.nodeName=="use"&&!svgedit.utilities.getHref(n))s.removeChild(n);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start", "mask","stroke"],function(T,O){var J=n.getAttribute(O);if(J)if((J=svgedit.utilities.getUrlFromAttr(J))&&J[0]!=="#"){n.setAttribute(O,"");n.removeAttribute(O)}});for(l=n.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(n.childNodes.item(l))}}else{for(c=[];n.hasChildNodes();)c.push(s.insertBefore(n.firstChild,n));s.removeChild(n);for(l=c.length;l--;)svgedit.sanitize.sanitizeSvg(c[l])}}}}})();svgedit=svgedit||{}; (function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,p,g,b){this.elem=a;this.text=b?"Move "+a.tagName+" to "+b:"Move "+a.tagName;this.oldNextSibling=p;this.oldParent=g;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};svgedit.history.MoveElementCommand.prototype.type= svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,p){this.elem=a;this.text=p||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type=function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type= svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,p,g,b){this.elem=a;this.text=b||"Delete "+a.tagName;this.nextSibling=p;this.parent=g;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"}; svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]}; svgedit.history.ChangeElementCommand=function(a,p,g){this.elem=a;this.text=g?"Change "+a.tagName+" "+g:"Change "+a.tagName;this.newValues={};this.oldValues=p;for(var b in p)this.newValues[b]=b=="#text"?a.textContent:b=="#href"?svgedit.utilities.getHref(a):a.getAttribute(b)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText= function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var p=false,g;for(g in this.newValues){if(this.newValues[g])if(g=="#text")this.elem.textContent=this.newValues[g];else g=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[g]):this.elem.setAttribute(g,this.newValues[g]);else if(g=="#text")this.elem.textContent="";else{this.elem.setAttribute(g,"");this.elem.removeAttribute(g)}if(g== "transform")p=true}if(!p)if(p=svgedit.utilities.getRotationAngle(this.elem)){g=elem.getBBox();p=["rotate(",p," ",g.x+g.width/2,",",g.y+g.height/2,")"].join("");p!=elem.getAttribute("transform")&&elem.setAttribute("transform",p)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var p=false,g;for(g in this.oldValues){if(this.oldValues[g])if(g== "#text")this.elem.textContent=this.oldValues[g];else g=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[g]):this.elem.setAttribute(g,this.oldValues[g]);else if(g=="#text")this.elem.textContent="";else this.elem.removeAttribute(g);if(g=="transform")p=true}if(!p)if(p=svgedit.utilities.getRotationAngle(this.elem)){g=this.elem.getBBox();p=["rotate(",p," ",g.x+g.width/2,",",g.y+g.height/2,")"].join("");p!=this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",p)}svgedit.transformlist.removeElementFromListMap(this.elem); a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command";this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply= function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);for(var p=this.stack.length,g=0;g=0;p--)this.stack[p].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],p=this.stack.length;p--;)for(var g=this.stack[p].elements(),b=g.length;b--;)a.indexOf(g[b])==-1&&a.push(g[b]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer= -1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText(): ""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}; svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,p){for(var g=++this.undoChangeStackPointer,b=p.length,n=Array(b),s=Array(b);b--;){var c=p[b];if(c!=null){s[b]=c;n[b]=c.getAttribute(a)}}this.undoableChangeStack[g]= {attrName:a,oldValues:n,elements:s}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,p=this.undoableChangeStack[a],g=p.elements.length,b=p.attrName,n=new svgedit.history.BatchCommand("Change "+b);g--;){var s=p.elements[g];if(s!=null){var c={};c[b]=p.oldValues[g];c[b]!=s.getAttribute(b)&&n.addSubCommand(new svgedit.history.ChangeElementCommand(s,c,b))}}this.undoableChangeStack[a]=null;return n}})();svgedit=svgedit||{}; (function(){if(!svgedit.select)svgedit.select={};var a,p,g;svgedit.select.Selector=function(b,n){this.id=b;this.selectedElement=n;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));svgedit.browser.isTouch()&&this.selectorRect.setAttribute("stroke-opacity", 0.3);this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(b){this.locked=true;this.selectedElement=b;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(b){var n=[];b=Math.round(b/45);if(b<0)b+=8;for(var s in g.selectorGrips)n.push(s);for(;b>0;){n.push(n.shift());b--}b=0;for(s in g.selectorGrips){g.selectorGrips[s].setAttribute("style", "cursor:"+n[b]+"-resize");b++}};svgedit.select.Selector.prototype.showGrips=function(b){g.selectorGripsGroup.setAttribute("display",b?"inline":"none");var n=this.selectedElement;this.hasGrips=b;if(n&&b){this.selectorGroup.appendChild(g.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(n))}};svgedit.select.Selector.prototype.resize=function(){var b=this.selectorRect,n=g,s=n.selectorGrips,c=this.selectedElement,f=c.getAttribute("stroke-width"),d=a.currentZoom(),l=1/d;if(c.getAttribute("stroke")!== "none"&&!isNaN(f))l+=f/2;var q=c.tagName;if(q==="text")l+=2/d;f=svgedit.transformlist.getTransformList(c);f=svgedit.math.transformListToTransform(f).matrix;f.e*=d;f.f*=d;var B=svgedit.utilities.getBBox(c);if(q==="g"&&!$.data(c,"gsvg"))if(q=a.getStrokedBBox(c.childNodes))B=q;q=B.x;var o=B.y,K=B.width;B=B.height;l*=d;d=svgedit.math.transformBox(q*d,o*d,K*d,B*d,f);f=d.aabox;q=f.x-l;o=f.y-l;K=f.width+l*2;var T=f.height+l*2;f=q+K/2;B=o+T/2;if(c=svgedit.utilities.getRotationAngle(c)){q=a.svgRoot().createSVGTransform(); q.setRotate(-c,f,B);q=q.matrix;d.tl=svgedit.math.transformPoint(d.tl.x,d.tl.y,q);d.tr=svgedit.math.transformPoint(d.tr.x,d.tr.y,q);d.bl=svgedit.math.transformPoint(d.bl.x,d.bl.y,q);d.br=svgedit.math.transformPoint(d.br.x,d.br.y,q);q=d.tl;K=q.x;T=q.y;var O=q.x,J=q.y;q=Math.min;o=Math.max;K=q(K,q(d.tr.x,q(d.bl.x,d.br.x)))-l;T=q(T,q(d.tr.y,q(d.bl.y,d.br.y)))-l;O=o(O,o(d.tr.x,o(d.bl.x,d.br.x)))+l;J=o(J,o(d.tr.y,o(d.bl.y,d.br.y)))+l;q=K;o=T;K=O-K;T=J-T}l=a.svgRoot().suspendRedraw(100);b.setAttribute("d", "M"+q+","+o+" L"+(q+K)+","+o+" "+(q+K)+","+(o+T)+" "+q+","+(o+T)+"z");this.selectorGroup.setAttribute("transform",c?"rotate("+[c,f,B].join(",")+")":"");if(svgedit.browser.isTouch()){q-=15.75;o-=15.75}else{q-=4;o-=4}this.gripCoords={nw:[q,o].map(Math.round),ne:[q+K,o].map(Math.round),sw:[q,o+T].map(Math.round),se:[q+K,o+T].map(Math.round),n:[q+K/2,o].map(Math.round),w:[q,o+T/2].map(Math.round),e:[q+K,o+T/2].map(Math.round),s:[q+K/2,o+T].map(Math.round)};for(var Q in this.gripCoords){b=this.gripCoords[Q]; s[Q].setAttribute("x",b[0]);s[Q].setAttribute("y",b[1])}this.rotateCoords={nw:[q,o],ne:[q+K+8,o],sw:[q,o+T+8],se:[q+K+8,o+T+8]};for(Q in this.rotateCoords){b=this.rotateCoords[Q];n.rotateGrips[Q].setAttribute("cx",b[0]);n.rotateGrips[Q].setAttribute("cy",b[1])}a.svgRoot().unsuspendRedraw(l)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null}; this.selectorGripsGroup=null;this.rotateGrips={nw:null,ne:null,se:null,sw:null};this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup); a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var b in this.rotateGrips){var n=a.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate_"+b,fill:"#000",r:8,stroke:"#000","fill-opacity":0,"stroke-opacity":0,"stroke-width":0,style:"cursor:url("+p.imgPath+"rotate.png) 12 12, auto;"}});$.data(n,"dir",b);$.data(n,"type","rotate");this.rotateGrips[b]=this.selectorGripsGroup.appendChild(n)}for(b in this.selectorGrips){n=a.createSVGElement({element:"rect", attr:{id:"selectorGrip_resize_"+b,width:8,height:8,fill:"#4F80FF",stroke:"rgba(0,0,0,0)","stroke-width":1,style:"cursor:"+b+"-resize","pointer-events":"all"}});if(svgedit.browser.isTouch()){n.setAttribute("width",30.5);n.setAttribute("height",30.5);n.setAttribute("fill-opacity",0.3)}$.data(n,"dir",b);$.data(n,"type","resize");this.selectorGrips[b]=this.selectorGripsGroup.appendChild(n)}if(!$("#canvasBackground").length){b=p.dimensions;b=a.createSVGElement({element:"svg",attr:{id:"canvasBackground", width:b[0],height:b[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});n=a.createSVGElement({element:"defs",attr:{id:"placeholder_defs"}});var s=a.createSVGElement({element:"pattern",attr:{id:"checkerPattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:20,height:20,viewBox:"0 0 10 10"}}),c=a.createSVGElement({element:"rect",attr:{x:0,y:0,width:10,height:10,fill:"#fff"}}),f=a.createSVGElement({element:"rect",attr:{x:0,y:0,width:5,height:5,fill:"#eee"}}), d=a.createSVGElement({element:"rect",attr:{x:5,y:5,width:5,height:5,fill:"#eee"}}),l=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"url(#checkerPattern)",style:"pointer-events:none"}});b.appendChild(n);n.appendChild(s);s.appendChild(c);s.appendChild(f);s.appendChild(d);b.appendChild(l);a.svgRoot().insertBefore(b,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(b){if(b==null)return null;var n=this.selectors.length; if(typeof this.selectorMap[b.id]=="object"){this.selectorMap[b.id].locked=true;return this.selectorMap[b.id]}for(var s=0;s element";this.svgElem_=b;this.obj_num=0;this.idPrefix=n||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_= "";var s=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(s&&g!=p.NEVER_RANDOMIZE)this.nonce_=s;else g==p.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(b){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+b):$(this.svgElem_).find("[id="+b+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_}; svgedit.draw.Drawing.prototype.setNonce=function(b){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",b);this.nonce_=b};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var b= this.obj_num,n=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();n=true}else this.obj_num++;for(var s=this.getId();this.getElem_(s);){if(n){this.obj_num=b;n=false}this.obj_num++;s=this.getId()}if(n)this.obj_num=b;return s};svgedit.draw.Drawing.prototype.releaseId=function(b){var n=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof b!="string"||b.indexOf(n)!=0)return false;b=parseInt(b.substr(n.length));if(typeof b!="number"||b<=0||this.releasedNums.indexOf(b)!=-1)return false; this.releasedNums.push(b);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(b){for(var n=0;n=0&&b1){var b=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return b}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var b=this.svgElem_.childNodes.length,n=[],s=[],c=null,f=false,d=0;d0||!f){for(d=1;s.indexOf("Layer "+d)>=0;)d++;s="Layer "+d;c=b.createElementNS("http://www.w3.org/2000/svg","g");f=b.createElementNS("http://www.w3.org/2000/svg","title");f.textContent=s; c.appendChild(f);for(f=0;f1))for(var s=0;s0){f=T 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,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l=d?null:f[l+1],K=l-1<0?null:f[l-1];if(B.type===2){if(K&&K.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=l}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d= this.segs.length,l=0;l').documentElement, true);a.appendChild(d);var l=f.createElementNS(b,"svg");(c.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:n.show_outside_canvas?"visible":"hidden",xmlns:b,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(d);var e=f.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var q="svg_";c.setIdPrefix= function(e){q=e};c.current_drawing_=new svgedit.draw.Drawing(l,q);var B=c.getCurrentDrawing=function(){return c.current_drawing_},o=1,K=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text, {fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=T.shape,J=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(b,e.element);if(m)(K||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin, "stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},V=c.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ia=c.matrixMultiply=svgedit.math.matrixMultiply,oa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=c.transformListToTransform=svgedit.math.transformListToTransform, ba=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J}, getSVGContent:function(){return l}});var ka=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,W=c.setHref=svgedit.utilities.setHref,Z=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var pa=c.getRotationAngle=svgedit.utilities.getRotationAngle,qa=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,Aa=svgedit.sanitize.getNSMap(),Fa=c.sanitizeSvg=svgedit.sanitize.sanitizeSvg, Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,za=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)c.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();c.pathActions.clear();M("changed",z);z=h.type();m=e==m.AFTER_APPLY;if(z== Ia.type()){m=m?h.newParent:h.oldParent;m==l&&c.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&c.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&c.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m= z.parentNode;var w=z.nextSibling;m.removeChild(z);m.insertBefore(z,w)}}}}}});var ya=function(e){c.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return c.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(e){return c.getStrokedBBox([e])}});var Ha=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return d}}); svgedit.utilities.snapToGrid=function(e){var h=n.snappingStep,m=n.baseUnit;if(m!=="px")h*=svgedit.units.getTypeMap()[m];return e=Math.round(e/h)*h};var wa=svgedit.utilities.snapToGrid,qb={exportNoBlur:"Blurred elements will appear as un-blurred",exportNoforeignObject:"foreignObject elements will not appear",exportNoDashArray:"Strokes will appear filled",exportNoText:"Text may not appear as expected"},$a=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ib=$.data, Wa=function(e){var h=$(e).attr($a),m;for(m in h){var z=h[m];if(z&&z.indexOf("url(")===0){z=ka(z).substr(1);if(!qa(z)){lb().appendChild(Ab[z]);delete Ab[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(m=e.length;h=0)E=G=c.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)E=G=c.convertToPath(I,true)}if(!G){var v=I.cloneNode(true),C=document.createElementNS(b,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(v);E=svgedit.utilities.bboxToObj(C.getBBox());D.removeChild(C)}}return E}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)}); if(m==null)return null;var z=m.x+m.width,w=m.y+m.height,H=m.x,A=m.y,u=function(I){var E=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(E))G+=E/2;return G},F=[];$.each(e,function(I,E){var G=h(E);if(G){var L=u(E);H=Math.min(H,G.x-L);A=Math.min(A,G.y-L);F.push(G)}});m.x=H;m.y=A;$.each(e,function(I,E){var G=F[I];if(G&&E.nodeType==1){var L=u(E);z=Math.max(z,G.x+G.width+L);w=Math.max(w,G.y+G.height+L)}});m.width=z-H;m.height=w-A;return m};var ub=this.getVisibleElements=function(e){e|| (e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Bb=this.groupSvgElem=function(e){var h=document.createElementNS(b,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg", e)[0].id=ja()},la=function(e){var h=document.createElementNS(e.namespaceURI,e.nodeName);h.removeAttribute("id");$.each(e.attributes,function(z,w){w.localName!="-moz-math-font-style"&&h.setAttributeNS(w.namespaceURI,w.nodeName,w.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=Ja.convertPath(e);h.setAttribute("d",m)}$.each(e.childNodes,function(z,w){switch(w.nodeType){case 1:h.appendChild(la(w));break;case 3:h.textContent=w.nodeValue}});if($(e).data("gsvg"))$(h).data("gsvg",h.firstChild); else if($(e).data("symbol")){e=$(e).data("symbol");$(h).data("ref",e).data("symbol",e)}else h.tagName=="image"&&pb(h);h.id=ja();return h},ca,ja,M;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};M=e.call=function(m,z){if(h[m])return h[m](this,z)};e.bind=function(m,z){var w=h[m];h[m]=z;return w}})(c);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(b,"path");for(var h=0,m=e.length;h 0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=N(H,A,fa(w).matrix);A=d.createSVGTransform();A.setRotate(e,H.x,H.y);w.numberOfItems?w.insertItemBefore(A,0):w.appendItem(A)}else w.numberOfItems==0&&m.removeAttribute("transform");if(!h){w=m.getAttribute("transform");m.setAttribute("transform",z);gb("transform",w,J);M("changed",J)}qa("pathpointgrip_container");m=Ha.requestSelector(J[0]);m.resize();m.updateGripCursors(e)};var Ga=this.recalculateAllSelectedDimensions=function(){for(var e=new za(kb== "none"?"position":"size"),h=J.length;h--;){var m=Ua(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);M("changed",J)}},Pa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke", u=e.getAttribute(A);if(u&&u.indexOf("url(")===0)if(m.a<0||m.d<0){u=R(u).cloneNode(true);if(m.a<0){var F=u.getAttribute("x1"),I=u.getAttribute("x2");u.setAttribute("x1",-(F-1));u.setAttribute("x2",-(I-1))}if(m.d<0){F=u.getAttribute("y1");I=u.getAttribute("y2");u.setAttribute("y1",-(F-1));u.setAttribute("y2",-(I-1))}u.id=ja();lb().appendChild(u);e.setAttribute(A,"url(#"+u.id+")")}}H=e.tagName;if(H==="g"||H==="text"||H==="use")if(m.a==1&&m.b==0&&m.c==0&&m.d==1&&(m.e!=0||m.f!=0)){A=fa(e).matrix;A=ia(A.inverse(), m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=V(e);u=d.createSVGTransform();u.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(u)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=V(e);u=d.createSVGTransform();u.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(u)}else{A=N(h.x,h.y,m);h.width=m.a*h.width;h.height=m.d*h.height;h.x=A.x+Math.min(0,h.width);h.y=A.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}w(); break;case "ellipse":H=N(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;h.rx=m.a*h.rx;h.ry=m.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);w();break;case "circle":H=N(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;H=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);h.r=Math.min((H.tr.x-H.tl.x)/2,(H.bl.y-H.tl.y)/2);if(h.r)h.r=Math.abs(h.r);w();break;case "line":A=N(h.x1,h.y1,m);F=N(h.x2,h.y2,m);h.x1=A.x;h.y1=A.y;h.x2=F.x;h.y2=F.y;case "text":m=e.querySelectorAll("tspan");for(H=m.length;H--;){A=sa("x",e.getAttribute("x")); u=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var E={};if(!isNaN(A)&&!isNaN(u)&&A!=0&&u!=0&&h.x)E.x=h.x-(A-u);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)E.y=h.y-(F-I);if(E.x||E.y)ma(m[H],E,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type=== 1)svgedit.math.isIdentity(z.matrix)&&h.removeItem(m);else z.type===4&&z.angle===0&&h.removeItem(m)}if(h.numberOfItems===1&&pa(e))return null}if(!h||h.numberOfItems==0){e.removeAttribute("transform");return null}if(h){m=h.numberOfItems;for(var w=[];m--;){z=h.getItem(m);if(z.type===1)w.push([z.matrix,m]);else if(w.length)w=[]}if(w.length===2){m=d.createSVGTransformFromMatrix(ia(w[1][0],w[0][0]));h.removeItem(w[0][1]);h.removeItem(w[1][1]);h.insertItemBefore(m,w[1][1])}m=h.numberOfItems;if(m>=2&&h.getItem(m- 2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new za("Transform");var A={},u=null;z=[];switch(e.tagName){case "line":z=["x1","y1", "x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":u={};u.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=V(U);if(S){z=fa(S).matrix;H=pa(U);var X=Va,aa=[];Va=U.getAttribute("transform");if(H||oa(S)){var ga= d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);aa.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var ra=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(ra);aa.push(Ba);aa.push(Oa);aa.push(ra)}m.addSubCommand(Ua(U));Va=X}}}h.removeItem(k-1);h.removeItem(k- 2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){X=U.getAttribute("clip-path");if(k.indexOf(X)===-1){nb(X,H,z);k.push(X)}}X=Va;Va=U.getAttribute("transform"); if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(b,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=X}}}k=[];Va=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform"); if(S=V(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=X;X=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(X)&&U.setAttribute("stroke-width",X*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+v.e,y:G.y+v.f}; G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(w,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform");S=V(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C, 0):S.appendItem(C);m.addSubCommand(Ua(U));Va=X}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=pa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k== 4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;v=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,v,X);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems; A.points=Array(F);for(I=0;I1&&w.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3- (A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z= null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(u){if(!(u.originalEvent.touches&&u.originalEvent.touches>1)){var F=u.button===2;rb=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);u.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(u);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G== Ha.selectorParentGroup&&J[0]!=null){G=u.target;var v=ib(G,"type");if(v=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(v=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");v=V(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){u.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(u.button=== 1||c.spaceKey)){var F=J[0],I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}u.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v)}if(u.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||v!=0){C=J.length;for(k=0;k0&&c.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var X=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=X*Math.cos(v);v=X*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+v)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/ U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;X=P}L=d.createSVGTransform();v=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);X=wa(X);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+X),-(k+aa));if(u.shiftKey)if(ra==1)ra=ga;else ga=ra;v.setScale(ra,ga);P.setTranslate(C+X,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(v,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(v,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition", J);break;case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(u.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea== "square"||u.shiftKey){L=D=Math.max(L,D);C=hm?m+k:m-k}if(u.altKey){D=h;C=m;k=Math.abs(x-D);v=u.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",v);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+ k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(u.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L= svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=Y(F);G=N(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove", {event:u,mouse_x:E,mouse_y:I,selected:F})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var F=u.target.parentNode;if(F!==K){var I=Ib(u),E=I.tagName;if(E==="text"&&Ea!=="textedit"){u=N(u.pageX,u.pageY,rb);hb.select(I,u.x,u.y)}if((E==="g"||E==="a")&&pa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(u){c.addClones=false;window.removeEventListener("keyup",c.removeClones); if(u.button!==2){var F=Cb;Cb=null;if(La){var I=N(u.pageX,u.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity= E.getAttribute("stroke-opacity");bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(E=0;E=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);v=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);v=F.width!=0||F.height!=0||Ea==="image";break;case "circle":v=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);v=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse", curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);v=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);v=true}break;case "text":v=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(u,k,E,I);k=F.element;v=F.keep;break;case "pathedit":v=true;k=null;Ja.mouseUp(u); break;case "textedit":v=false;k=null;hb.mouseUp(u,E,I);break;case "rotate":v=true;k=null;Ea="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:u,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){v=U.keep||v;k=U.element;La=U.started||La}});if(!v&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=u.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&& E.id!="svgcanvas"&&E.id!="svgroot"){c.setMode("select");xb([E],true)}}else if(k!=null){c.addedNew=true;u=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=O.opacity){C=$(false).clone().attr({to:O.opacity,dur:u}).appendTo(k);try{C[0].beginElement()}catch(D){}}else u=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",O.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},u* 1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(u.wheelDelta)if(u.wheelDelta>=120)F.factor=2;else{if(u.wheelDelta<=-120)F.factor=0.5}else if(u.detail)if(u.detail>0)F.factor=0.5;else if(u.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=c.textActions=function(){function e(S){var X=I.value=== "";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];X||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(b,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,v.y);aa=H(aa.x,v.y+v.height);ma(E,{x1:X.x,y1:X.y,x2:aa.x, y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,aa){if(S===X)e(X);else{aa||I.setSelectionRange(S,X);G=qa("text_selectblock");if(!G){G=document.createElementNS(b,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];E.setAttribute("visibility","hidden");X=H(S.x,v.y);aa=H(S.x+(ga.x-S.x),v.y);var ra=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+ X.x+","+X.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}function m(S,X){var aa=d.createSVGPoint();aa.x=S;aa.y=X;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,X,aa){var ga=I.selectionStart;S=m(S,X);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,X){var aa={x:S,y:X};aa.x/=o;aa.y/=o;if(C){var ga=N(aa.x,aa.y,C.inverse());aa.x= ga.x;aa.y=ga.y}return aa}function H(S,X){var aa={x:S,y:X};if(C){var ga=N(aa.x,aa.y,C);aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function u(S){if(U&&F){var X=N(S.pageX,S.pageY,rb);X=w(X.x*o,X.y*o);X=m(X.x,X.y);var aa=F.textContent,ga=aa.substr(0,X).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(X).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+X);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L, k=[],v,C,D,P,U;return{select:function(S,X,aa){F=S;hb.toEditMode(X,aa)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,X,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,X){var aa=w(S,X);z(aa.x,aa.y)},mouseUp:function(S,X,aa){var ga=w(X,aa);z(ga.x,ga.y,true);S.target!==F&&XD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa= w(S,X);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S= F.textContent.length,X=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=X?Y(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var aa={x:v.x+v.width/2,width:0};for(X=0;X=0&&this.selected_pts.push(F)}this.selected_pts.sort();u=this.selected_pts.length; for(A=Array(u);u--;){I=this.segs[this.selected_pts[u]];I.select(true);A[u]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,u,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;u=mouse_y/o;F=qa("path_stretch_line");m=[I,u];if(n.gridSnapping){I=wa(I);u=wa(u);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(b,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5", fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var v=E.getItem(G),C=v.x;v=v.y;if(I>=C-L&&I<=C+L&&u>=v-L&&u<=v+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;u=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,u):w.createSVGPathSegCurvetoCubicAbs(I,u,A.x1/o,A.y1/o, I,u);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E=false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a, Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,u);I=A.x;u=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(u)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(u),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;u*=o;F.setAttribute("d",["M",I,u,I,u].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,u)}}else{d_attr= "M"+I+","+u+" ";w=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:O.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){u=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[u];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(u): svgedit.path.path.addPtsToSelection(u);else{if(svgedit.path.path.selected_pts.length<=1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(u)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");u=A[0]-0;svgedit.path.path.selectPt(u,A[1]-0)}if(!svgedit.path.path.dragging){if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,u,F){H=true;if(Ea==="path"){if(w){var I= w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",u);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-u/o),v=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",v*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:u,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k* o,y1:v*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[u,F];else{I=I.getItem(A-1);u=I.x;F=I.y;if(I.pathSegType===6){u+=u-I.x2;F+=F-I.y2}else if(z){u=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,u,F,k,v],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[u,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,u,F],E);else z?svgedit.path.replacePathSeg(6,1,[u,F,z[0],z[1],u,F],E):svgedit.path.replacePathSeg(4,1,[u,F],E)}}}else if(svgedit.path.path.dragging){E= svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:u,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[u,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ta.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D, {x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(A,u){if(Ea==="path"){m=null;if(!w){u=qa(ca());La=false;z=null}return{keep:true,element:u}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ta&&ta.getAttribute("display")!= "none"){ta.setAttribute("display","none");ta.getAttribute("width")<=2&&ta.getAttribute("height")<=2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var u=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&& svgedit.path.recalcRotatedPath();if(u){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea="path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(pa(A)!=0){var u=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};u.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(u);svgedit.path.getPath_(A).show(false).matrix=null; this.clear();vb([A],true);M("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var u=V(A),F=fa(u).matrix;u.clear();A.removeAttribute("transform");u=A.pathSegList;for(var I=u.numberOfItems, E=0;E0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<= 1){Ja.toSelectMode(svgedit.path.path.elem);c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var u=A.points,F=u.numberOfItems;if(F>=4){var I=u.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=u.getItem(G),k=u.getItem(G+1),v=u.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E, L,I))&&I.length==2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,v.x,v.y].join(","));I=v;E=k}for(A.push("L");G0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e= [];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w=0;F--){u=A.item(F);G=z(u.nodeValue);if(!(L.indexOf(u.localName)>=0))if(G!="")if(G.indexOf("pointer-events")!==0)if(!(u.localName==="class"&&G.indexOf("se_")===0)){m.push(" ");if(u.localName==="d")G=Ja.convertPath(e,true);if(isNaN(G)){if(H.test(G))G= svgedit.units.shortFloat(G)+w}else G=svgedit.units.shortFloat(G);if(fb.apply&&e.nodeName==="image"&&u.localName==="href"&&fb.images&&fb.images==="embed"){var k=Sa[G];if(k)G=k}if(!u.namespaceURI||u.namespaceURI==b||Aa[u.namespaceURI]){m.push(u.nodeName);m.push('="');m.push(G);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");h++;A=false;for(F=0;F");break;case 8:m.push("\n");m.push(Array(h+1).join(" "));m.push("