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

    '+C.window.pickerTitle+'


    ');var ga=256,oa=ga-0,X=ga-0,U,ea,Ba,ja={};$(".jGraduate_SliderBar").width(145);var ba=$("#"+s+"_jGraduate_GradContainer")[0],T=a("svg",{id:s+"_jgraduate_svg",width:ga,height:ga,xmlns:q.svg},ba);U=U||u.paint.type;var Z=ea=u.paint[U],na=u.paint.alpha,pa=U==="solidColor";switch(U){case "solidColor":case "linearGradient":if(!pa){ea.id=s+"_lg_jgraduate_grad"; Z=ea=T.appendChild(ea)}a("radialGradient",{id:s+"_rg_jgraduate_grad"},T);if(U==="linearGradient")break;case "radialGradient":if(!pa){ea.id=s+"_rg_jgraduate_grad";Z=ea=T.appendChild(ea)}a("linearGradient",{id:s+"_lg_jgraduate_grad"},T)}if(pa){Z=ea=$("#"+s+"_lg_jgraduate_grad")[0];I=u.paint[U];v(0,"#"+I,1);var ma=typeof C.newstop;if(ma==="string")switch(C.newstop){case "same":v(1,"#"+I,1);break;case "inverse":ma="";for(var la=0;la<6;la+=2){I.substr(la,2);var ya=(255-parseInt(I.substr(la,2),16)).toString(16); if(ya.length<2)ya=0+ya;ma+=ya}v(1,"#"+ma,1);break;case "white":v(1,"#ffffff",1);break;case "black":v(1,"#000000",1)}else if(ma==="object")v(1,C.newstop.color||"#"+I,"opac"in C.newstop?C.newstop.opac:1)}I=parseFloat(Z.getAttribute("x1")||0);ma=parseFloat(Z.getAttribute("y1")||0);la=parseFloat(Z.getAttribute("x2")||1);ya=parseFloat(Z.getAttribute("y2")||0);var za=parseFloat(Z.getAttribute("cx")||0.5),Ja=parseFloat(Z.getAttribute("cy")||0.5),Ia=parseFloat(Z.getAttribute("fx")||za),Ha=parseFloat(Z.getAttribute("fy")|| Ja);Ba=a("rect",{id:s+"_jgraduate_rect",x:0,y:0,width:oa,height:X,fill:"url(#"+s+"_jgraduate_grad)","fill-opacity":na/100},T);var Ma=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ga,left:I*ga}).data("coord","start").appendTo(ba),Da=Ma.clone().text(2).css({top:ya*ga,left:la*ga}).attr("title","End stop").data("coord","end").appendTo(ba),wa=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ja*ga,left:za* ga}).data("coord","center").appendTo(ba),ra=wa.clone().text("F").css({top:Ha*ga,left:Ia*ga,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ba);ra[0].id=s+"_jGraduate_focusCoord";$(L+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,aa){var ka=ea.getAttribute(aa),M=isNaN(aa[1]);ka||(ka=M?"0.5":aa==="x2"?"1.0":"0.0");ja[aa]=$("#"+s+"_jGraduate_"+aa).val(ka).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value> 1)this.value=1;if(!(aa[0]==="f"&&!eb))if(M&&U==="radialGradient"||!M&&U==="linearGradient")ea.setAttribute(aa,this.value);var P=M?aa[0]==="c"?wa:ra:aa[1]==="1"?Ma:Da,ca=aa.indexOf("x")>=0?"left":"top";P.css(ca,this.value*ga)}).change()});var va,kb,vb=$("#"+s+"_jGraduate_StopSlider"),cb,Ta,Va,Fa=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Ta),ta,$a=1,Ka=1,Sa=0,Ga=za,db=Ja;Ta=a("svg",{width:"100%",height:45},vb[0]);ba=a("pattern",{width:16, height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Ta);a("image",{width:16,height:16},ba).setAttributeNS(q.xlink,"xlink:href",C.images.clientPath+"map-opacity.png");$(Ta).on("click touchstart",function(ia){ta=vb.offset();if(ia.target.tagName!=="path"){var aa=ia.pageX-ta.left-8;aa=aa<10?10:aa>ga+10?ga+10:aa;v(aa/ga,0,0,true);ia.stopPropagation()}});$(Ta).mouseover(function(){Ta.appendChild(Fa)});kb=a("g",{},Ta);a("line",{x1:10,y1:15,x2:ga+10,y2:15,"stroke-width":2,stroke:"#000"},Ta);var lb= N.find(".jGraduate_spreadMethod").change(function(){ea.setAttribute("spreadMethod",$(this).val())}),Ua=null,Xa=function(ia){var aa=ia.pageX-hb.left,ka=ia.pageY-hb.top;aa=aa<0?0:aa>ga?ga:aa;ka=ka<0?0:ka>ga?ga:ka;Ua.css("left",aa).css("top",ka);aa=aa/oa;ka=ka/X;var M=Ua.data("coord"),P=ea;switch(M){case "start":ja.x1.val(aa);ja.y1.val(ka);P.setAttribute("x1",aa);P.setAttribute("y1",ka);break;case "end":ja.x2.val(aa);ja.y2.val(ka);P.setAttribute("x2",aa);P.setAttribute("y2",ka);break;case "center":ja.cx.val(aa); ja.cy.val(ka);P.setAttribute("cx",aa);P.setAttribute("cy",ka);Ga=aa;db=ka;c();break;case "focus":ja.fx.val(aa);ja.fy.val(ka);P.setAttribute("fx",aa);P.setAttribute("fy",ka);c()}ia.preventDefault()},wb=function(){Ua=null;S.unbind("mousemove",Xa).unbind("mouseup",wb)};va=ea.getElementsByTagNameNS(q.svg,"stop");if(sa<2){for(;sa<2;){ea.appendChild(document.createElementNS(q.svg,"stop"));++sa}va=ea.getElementsByTagNameNS(q.svg,"stop")}var sa=va.length;for(la=0;la99.5)M=99.5;if(M>0)Ka=1-M/100;else $a=-(M/100)-1;P=145*((M+100)/ 2)/100;ca&&c();break;case "angle":Sa=M;P=Sa/180;P+=0.5;P*=145;ca&&c()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var ob=function(ia){var aa=ia.pageX-ab.offset.left-parseInt(ab.parent.css("border-left-width"));if(aa>145)aa=145;if(aa<=0)aa=0;var ka=aa-5;aa/=145;switch(ab.type){case "radius":aa=Math.pow(aa*2,2.5);if(aa>0.98&&aa<1.02)aa=1;if(aa<=0.01)aa=0.01;ea.setAttribute("r",aa);break;case "opacity":u.paint.alpha=parseInt(aa*100);Ba.setAttribute("fill-opacity",aa);break; case "ellip":Ka=$a=1;if(aa<0.5){aa/=0.5;$a=aa<=0?0.01:aa}else if(aa>0.5){aa/=0.5;aa=2-aa;Ka=aa<=0?0.01:aa}c();aa-=1;if(Ka===aa+1)aa=Math.abs(aa);break;case "angle":aa-=0.5;Sa=aa*=180;c();aa/=100}ab.elem.css({"margin-left":ka});aa=Math.round(aa*100);ab.input.val(aa);ia.preventDefault()},pb=function(){S.unbind("mousemove",ob).unbind("mouseup",pb);ab=null};for(N=(u.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];I=u.paint.solidColor=="none"?"":u.paint.solidColor+N;pa||(I=va[0].getAttribute("stop-color")); $.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});R.jPicker({window:{title:C.window.pickerTitle},images:{clientPath:C.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){u.paint.type="solidColor";u.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;u.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";u.paint.radialGradient=null;Q()},null,function(){K()});var fb=$(L+" .jGraduate_tabs li");fb.on("click touchstart",function(){fb.removeClass("jGraduate_tab_current"); $(this).addClass("jGraduate_tab_current");$(L+" > div").hide();var ia=$(this).attr("data-type");$(L+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+s+"_jgraduate_rect")[0].setAttribute("fill","url(#"+s+"_"+ia+"_jgraduate_grad)");U=ia==="lg"?"linearGradient":"radialGradient";$("#"+s+"_jGraduate_OpacInput").val(u.paint.alpha).change();var aa=$("#"+s+"_"+ia+"_jgraduate_grad")[0];if(ea!==aa){var ka= $(ea).find("stop");$(aa).empty().append(ka);ea=aa;aa=lb.val();ea.setAttribute("spreadMethod",aa)}eb=ia==="rg"&&ea.getAttribute("fx")!=null&&!(za==Ia&&Ja==Ha);$("#"+s+"_jGraduate_focusCoord").toggle(eb);if(eb)$("#"+s+"_jGraduate_match_ctr")[0].checked=false}else{$(L+" .jGraduate_gradPick").hide();$(L+" .jGraduate_colPick").show()}});$(L+" > div").hide();fb.removeClass("jGraduate_tab_current");var tb;switch(u.paint.type){case "linearGradient":tb=$(L+" .jGraduate_tab_lingrad");break;case "radialGradient":tb= $(L+" .jGraduate_tab_radgrad");break;default:tb=$(L+" .jGraduate_tab_color")}u.show();setTimeout(function(){tb.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),q=$(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 p=$(this),v=$(p).offset(),d=$("#"+g.menu);d.addClass("contextMenu");$(this).bind("mousedown",function(c){$(this).on("mouseup",function(m){var u=$(this);u.unbind("mouseup");$(".contextMenu").hide();if(c.button===2|| g.allowLeft||c.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(m,c,u)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(c){var m=$(this);m.unbind("mouseup");f(c,c,m)});var f=function(c,m,u){if(typeof m=="undefined")m=c;c.stopPropagation();if(p.hasClass("disabled")||m.altKey)return false;var C=c.pageX,s=c.pageY;if(svgedit.browser.isTouch()){C=c.originalEvent.touches[0].pageX;s=c.originalEvent.touches[0].pageY}c=a.width()-d.width();m=a.height()-d.height();if(C>c-15)C=c-15; if(s>m-30)s=m-30;if(svgedit.browser.isTouch())s-=d.height()/2;q.unbind("click");d.css({top:s,left:C}).fadeIn(g.inSpeed);d.find("A").mouseover(function(){d.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){d.find("LI.hover").removeClass("hover")});q.keypress(function(L){switch(L.keyCode){case 38:if(d.find("LI.hover").length){d.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");d.find("LI.hover").length||d.find("LI:last").addClass("hover")}else d.find("LI:last").addClass("hover"); break;case 40:if(d.find("LI.hover").length==0)d.find("LI:first").addClass("hover");else{d.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");d.find("LI.hover").length||d.find("LI:first").addClass("hover")}break;case 13:d.find("LI.hover A").trigger("click");break;case 27:q.trigger("click")}});d.find("A").unbind("mouseup");d.find("LI:not(.disabled) A").mouseup(function(){q.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1), $(u),{x:C-v.left,y:s-v.top,docX:C,docY:s});return false});setTimeout(function(){q.click(function(){q.unbind("click").unbind("keypress");d.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})});$(p).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(","),p=0;p=0,v=q.indexOf("Gecko/")>=0,d=q.indexOf("MSIE")>=0,f=q.indexOf("Chrome/")>=0,c=q.indexOf("Windows")>=0,m=q.indexOf("Macintosh")>= 0,u="ontouchstart"in window,C=!!g.querySelector,s=!!document.evaluate,L=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var X=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{X.replaceItem(oa,0);return true}catch(U){}return false}(),Q=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var X=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{X.insertItemBefore(oa, 0);return true}catch(U){}return false}(),K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),X=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);X.setAttribute("x",5);oa.appendChild(X);var U=document.createElementNS("http://www.w3.org/2000/svg","text");U.textContent="a";X.appendChild(U);X=U.getStartPositionOfChar(0);X=X.x;document.documentElement.removeChild(oa);return X===0}(),I=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(oa);var X=document.createElementNS("http://www.w3.org/2000/svg","path");X.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(X);X=X.getBBox();document.documentElement.removeChild(oa);return X.height>4&&X.height<5}(),S=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var X=document.createElementNS("http://www.w3.org/2000/svg","path");X.setAttribute("d","M0,0 10,0");var U=document.createElementNS("http://www.w3.org/2000/svg", "path");U.setAttribute("d","M5,0 15,0");var ea=document.createElementNS("http://www.w3.org/2000/svg","g");ea.appendChild(X);ea.appendChild(U);oa.appendChild(ea);X=ea.getBBox();document.documentElement.removeChild(oa);return X.width==15}(),R=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"}(),ga=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,X=g.createSVGTransform();oa.appendItem(X);return oa.getItem(0)==X}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return p};svgedit.browser.isGecko=function(){return v}; svgedit.browser.isIE=function(){return d};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return c};svgedit.browser.isMac=function(){return m};svgedit.browser.isTouch=function(){return u};svgedit.browser.supportsSelectors=function(){return C};svgedit.browser.supportsXpath=function(){return s};svgedit.browser.supportsPathReplaceItem=function(){return L};svgedit.browser.supportsPathInsertItemBefore=function(){return Q};svgedit.browser.supportsPathBBox=function(){return I}; svgedit.browser.supportsHVLineContainerBBox=function(){return S};svgedit.browser.supportsGoodTextCharPos=function(){return K};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return R};svgedit.browser.supportsNonScalingStroke=function(){return N};svgedit.browser.supportsNativeTransformLists=function(){return ga}}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"),q={};svgedit.transformlist.SVGTransformList=function(g){this._elem=g||null;this._xforms=[];this._update=function(){var b="";a.createSVGMatrix();for(var p=0;p=0)return this._xforms[b];throw{code:1};};this.insertItemBefore=function(b,p){var v=null;if(p>=0)if(p=0){this._removeFromOtherLists(b);v=this._xforms[p]=b;this._list._update()}return v};this.removeItem=function(b){if(b=0){for(var p=this._xforms[b],v=Array(this.numberOfItems- 1),d=0;d1;)b=q[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(q){if(!q)return false;for(var g=q.numberOfItems;g--;){var b=q.getItem(g);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(q,g,b,p,v){var d={x:q,y:g},f={x:q+b,y:g};b={x:q+b,y:g+p};q={x:q,y:g+p};g=svgedit.math.transformPoint;d=g(d.x,d.y,v);var c=p=d.x,m=d.y,u=d.y;f=g(f.x,f.y,v);p=Math.min(p,f.x);c=Math.max(c,f.x); m=Math.min(m,f.y);u=Math.max(u,f.y);q=g(q.x,q.y,v);p=Math.min(p,q.x);c=Math.max(c,q.x);m=Math.min(m,q.y);u=Math.max(u,q.y);b=g(b.x,b.y,v);p=Math.min(p,b.x);c=Math.max(c,b.x);m=Math.min(m,b.y);u=Math.max(u,b.y);return{tl:d,tr:f,bl:q,br:b,aabox:{x:p,y:m,width:c-p,height:u-m}}};svgedit.math.transformListToTransform=function(q,g,b){if(q==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());g=g==undefined?0:g;b=b==undefined?q.numberOfItems-1:b;g=parseInt(g);b=parseInt(b);if(g>b){var p=b;b=g; g=p}p=a.createSVGMatrix();for(g=g;g<=b;++g){var v=g>=0&&gq.x&&g.yq.y}})();svgedit=svgedit||{}; (function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],q=["y","y1","cy","ry","height"],g=$.merge(["r","radius"],a);$.merge(g,q);var b,p={px:1};svgedit.units.init=function(d){b=d;d=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(d);var f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("width","1em");f.setAttribute("height","1ex");f.setAttribute("x","1in");d.appendChild(f);f=f.getBBox();document.body.removeChild(d); d=f.x;p.em=f.width;p.ex=f.height;p["in"]=d;p.cm=d/2.54;p.mm=d/25.4;p.pt=d/72;p.pc=d/6;p["%"]=0};svgedit.units.getTypeMap=function(){return p};svgedit.units.shortFloat=function(d){var f=b.getRoundDigits();if(isNaN(d)){if($.isArray(d))return svgedit.units.shortFloat(d[0])+","+svgedit.units.shortFloat(d[1])}else return+(+d).toFixed(f);return parseFloat(d).toFixed(f)-0};svgedit.units.convertUnit=function(d,f){f=f||b.getBaseUnit();return svgedit.unit.shortFloat(d/p[f])};svgedit.units.setUnitAttr=function(d, f,c){isNaN(c)||d.getAttribute(f);d.setAttribute(f,c)};var v={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(d){var f=d.tagName,c=b.getBaseUnit();if(f=v[f])for(var m=f.length,u=0;u=0?c*m:q.indexOf(d)>=0?c*u:c*Math.sqrt(m*m+u*u)/Math.sqrt(2)}else{m=f.substr(-2);c=f.substr(0,f.length-2);return c*p[m]}};svgedit.units.isValidUnit=function(d,f,c){var m=false;if(g.indexOf(d)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(p,function(s){if(!m)if(RegExp("^-?[\\d\\.]+"+s+"$").test(f))m=true})}else m=true;else if(d=="id"){d=false;try{var u=b.getElement(f); d=u==null||u===c}catch(C){}return d}else m=true;return m}})();svgedit=svgedit||{}; (function(){function a(d){if(svgedit.browser.supportsHVLineContainerBBox())try{return d.getBBox()}catch(f){}var c=$.data(d,"ref"),m=null;if(c){var u=$(c).children().clone().attr("visibility","hidden");$(v).append(u);m=u.filter("line, path")}else m=$(d).find("line, path");var C=false;if(m.length){m.each(function(){var s=this.getBBox();if(!s.width||!s.height)C=true});if(C){d=c?u:$(d).children();ret=getStrokedBBox(d)}else ret=d.getBBox()}else ret=d.getBBox();c&&u.remove();return ret}if(!svgedit.utilities)svgedit.utilities= {};var q="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),g=null,b=null,p=null,v=null;svgedit.utilities.init=function(d){g=d;b=d.getDOMDocument();p=d.getDOMContainer();v=d.getSVGRoot()};svgedit.utilities.toXml=function(d){return $("

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

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