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

    '+A.window.pickerTitle+'


    ');var ha=256,pa=ha-0,fa=ha-0,T,Z,ua,ja={};$(".jGraduate_SliderBar").width(145);var da=$("#"+p+"_jGraduate_GradContainer")[0],V=a("svg",{id:p+"_jgraduate_svg",width:ha,height:ha,xmlns:q.svg},da);T=T||v.paint.type;var X=Z=v.paint[T],oa=v.paint.alpha,qa=T==="solidColor";switch(T){case "solidColor":case "linearGradient":if(!qa){Z.id=p+"_lg_jgraduate_grad"; X=Z=V.appendChild(Z)}a("radialGradient",{id:p+"_rg_jgraduate_grad"},V);if(T==="linearGradient")break;case "radialGradient":if(!qa){Z.id=p+"_rg_jgraduate_grad";X=Z=V.appendChild(Z)}a("linearGradient",{id:p+"_lg_jgraduate_grad"},V)}if(qa){X=Z=$("#"+p+"_lg_jgraduate_grad")[0];I=v.paint[T];u(0,"#"+I,1);var ma=typeof A.newstop;if(ma==="string")switch(A.newstop){case "same":u(1,"#"+I,1);break;case "inverse":ma="";for(var la=0;la<6;la+=2){I.substr(la,2);var wa=(255-parseInt(I.substr(la,2),16)).toString(16); if(wa.length<2)wa=0+wa;ma+=wa}u(1,"#"+ma,1);break;case "white":u(1,"#ffffff",1);break;case "black":u(1,"#000000",1)}else if(ma==="object")u(1,A.newstop.color||"#"+I,"opac"in A.newstop?A.newstop.opac:1)}I=parseFloat(X.getAttribute("x1")||0);ma=parseFloat(X.getAttribute("y1")||0);la=parseFloat(X.getAttribute("x2")||1);wa=parseFloat(X.getAttribute("y2")||0);var Ha=parseFloat(X.getAttribute("cx")||0.5),Ba=parseFloat(X.getAttribute("cy")||0.5),Ia=parseFloat(X.getAttribute("fx")||Ha),Ka=parseFloat(X.getAttribute("fy")|| Ba);ua=a("rect",{id:p+"_jgraduate_rect",x:0,y:0,width:pa,height:fa,fill:"url(#"+p+"_jgraduate_grad)","fill-opacity":oa/100},V);var Ja=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ha,left:I*ha}).data("coord","start").appendTo(da),Ea=Ja.clone().text(2).css({top:wa*ha,left:la*ha}).attr("title","End stop").data("coord","end").appendTo(da),va=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ba*ha,left:Ha* ha}).data("coord","center").appendTo(da),Ga=va.clone().text("F").css({top:Ka*ha,left:Ia*ha,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ga[0].id=p+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,ca){var ka=Z.getAttribute(ca),M=isNaN(ca[1]);ka||(ka=M?"0.5":ca==="x2"?"1.0":"0.0");ja[ca]=$("#"+p+"_jGraduate_"+ca).val(ka).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"&&!gb))if(M&&T==="radialGradient"||!M&&T==="linearGradient")Z.setAttribute(ca,this.value);var P=M?ca[0]==="c"?va:Ga:ca[1]==="1"?Ja:Ea,ea=ca.indexOf("x")>=0?"left":"top";P.css(ea,this.value*ha)}).change()});var ta,Ua,ub=$("#"+p+"_jGraduate_StopSlider"),fb,Va,Xa,Ca=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Va),sa,db=1,La=1,Ta=0,Da=Ha,hb=Ba;Va=a("svg",{width:"100%",height:45},ub[0]);da=a("pattern",{width:16, height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},da).setAttributeNS(q.xlink,"xlink:href",A.images.clientPath+"map-opacity.png");$(Va).on("click touchstart",function(ia){sa=ub.offset();if(ia.target.tagName!=="path"){var ca=ia.pageX-sa.left-8;ca=ca<10?10:ca>ha+10?ha+10:ca;u(ca/ha,0,0,true);ia.stopPropagation()}});$(Va).mouseover(function(){Va.appendChild(Ca)});Ua=a("g",{},Va);a("line",{x1:10,y1:15,x2:ha+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var qb= N.find(".jGraduate_spreadMethod").change(function(){Z.setAttribute("spreadMethod",$(this).val())}),Ya=null,Za=function(ia){var ca=ia.pageX-kb.left,ka=ia.pageY-kb.top;ca=ca<0?0:ca>ha?ha:ca;ka=ka<0?0:ka>ha?ha:ka;Ya.css("left",ca).css("top",ka);ca=ca/pa;ka=ka/fa;var M=Ya.data("coord"),P=Z;switch(M){case "start":ja.x1.val(ca);ja.y1.val(ka);P.setAttribute("x1",ca);P.setAttribute("y1",ka);break;case "end":ja.x2.val(ca);ja.y2.val(ka);P.setAttribute("x2",ca);P.setAttribute("y2",ka);break;case "center":ja.cx.val(ca); ja.cy.val(ka);P.setAttribute("cx",ca);P.setAttribute("cy",ka);Da=ca;hb=ka;d();break;case "focus":ja.fx.val(ca);ja.fy.val(ka);P.setAttribute("fx",ca);P.setAttribute("fy",ka);d()}ia.preventDefault()},vb=function(){Ya=null;Q.unbind("mousemove",Za).unbind("mouseup",vb)};ta=Z.getElementsByTagNameNS(q.svg,"stop");if(ra<2){for(;ra<2;){Z.appendChild(document.createElementNS(q.svg,"stop"));++ra}ta=Z.getElementsByTagNameNS(q.svg,"stop")}var ra=ta.length;for(la=0;la99.5)M=99.5;if(M>0)La=1-M/100;else db=-(M/100)-1;P=145*((M+100)/ 2)/100;ea&&d();break;case "angle":Ta=M;P=Ta/180;P+=0.5;P*=145;ea&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var nb=function(ia){var ca=ia.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ka=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;Z.setAttribute("r",ca);break;case "opacity":v.paint.alpha=parseInt(ca*100);ua.setAttribute("fill-opacity",ca);break; case "ellip":La=db=1;if(ca<0.5){ca/=0.5;db=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;Ta=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ka});ca=Math.round(ca*100);eb.input.val(ca);ia.preventDefault()},rb=function(){Q.unbind("mousemove",nb).unbind("mouseup",rb);eb=null};for(N=(v.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];I=v.paint.solidColor=="none"?"":v.paint.solidColor+N;qa||(I=ta[0].getAttribute("stop-color")); $.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});U.jPicker({window:{title:A.window.pickerTitle},images:{clientPath:A.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){v.paint.type="solidColor";v.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;v.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";v.paint.radialGradient=null;R()},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 ia=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+p+"_jgraduate_rect")[0].setAttribute("fill","url(#"+p+"_"+ia+"_jgraduate_grad)");T=ia==="lg"?"linearGradient":"radialGradient";$("#"+p+"_jGraduate_OpacInput").val(v.paint.alpha).change();var ca=$("#"+p+"_"+ia+"_jgraduate_grad")[0];if(Z!==ca){var ka= $(Z).find("stop");$(ca).empty().append(ka);Z=ca;ca=qb.val();Z.setAttribute("spreadMethod",ca)}gb=ia==="rg"&&Z.getAttribute("fx")!=null&&!(Ha==Ia&&Ba==Ka);$("#"+p+"_jGraduate_focusCoord").toggle(gb);if(gb)$("#"+p+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var xb;switch(v.paint.type){case "linearGradient":xb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":xb= $(K+" .jGraduate_tab_radgrad");break;default:xb=$(K+" .jGraduate_tab_color")}v.show();setTimeout(function(){xb.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(h,b){if(h.menu==undefined)return false;if(h.inSpeed==undefined)h.inSpeed=150;if(h.outSpeed==undefined)h.outSpeed=75;if(h.inSpeed==0)h.inSpeed=-1;if(h.outSpeed==0)h.outSpeed=-1;$(this).each(function(){var n=$(this),u=$(n).offset(),c=$("#"+h.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var v=$(this);v.unbind("mouseup");$(".contextMenu").hide();if(d.button===2|| h.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||g(l,d,v)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");g(d,d,l)});var g=function(d,l,v){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var A=d.pageX,p=d.pageY;if(svgedit.browser.isTouch()){A=d.originalEvent.touches[0].pageX;p=d.originalEvent.touches[0].pageY}d=a.width()-c.width();l=a.height()-c.height();if(A>d-15)A=d-15; if(p>l-30)p=l-30;if(svgedit.browser.isTouch())p-=c.height()/2;q.unbind("click");c.css({top:p,left:A}).fadeIn(h.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});q.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:q.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){q.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1), $(v),{x:A-u.left,y:p-u.top,docX:A,docY:p});return false});setTimeout(function(){q.click(function(){q.unbind("click").unbind("keypress");c.fadeOut(h.outSpeed);return false})},0)};if($.browser.mozilla)$("#"+h.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+h.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+h.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})});$(n).add($("UL.contextMenu")).bind("contextmenu", function(){return false})});return $(this)},disableContextMenuItems:function(h){if(h==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(h!=undefined)for(var b=h.split(","),n=0;n=0,u=q.indexOf("Gecko/")>=0,c=q.indexOf("MSIE")>=0,g=q.indexOf("Chrome/")>=0,d=q.indexOf("Windows")>=0,l=q.indexOf("Macintosh")>= 0,v="ontouchstart"in window,A=!!h.querySelector,p=!!document.evaluate,K=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(pa,0);return true}catch(T){}return false}(),R=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(pa, 0);return true}catch(T){}return false}(),O=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);fa.setAttribute("x",5);pa.appendChild(fa);var T=document.createElementNS("http://www.w3.org/2000/svg","text");T.textContent="a";fa.appendChild(T);fa=T.getStartPositionOfChar(0);fa=fa.x;document.documentElement.removeChild(pa);return fa===0}(),I=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");pa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(pa);return fa.height>4&&fa.height<5}(),Q=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 10,0");var T= document.createElementNS("http://www.w3.org/2000/svg","path");T.setAttribute("d","M5,0 15,0");var Z=document.createElementNS("http://www.w3.org/2000/svg","g");Z.appendChild(fa);Z.appendChild(T);pa.appendChild(Z);fa=Z.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),U=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.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 pa}(),N=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("style","vector-effect:non-scaling-stroke");return pa.style.vectorEffect==="non-scaling-stroke"}(),ha=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=h.createSVGTransform();pa.appendItem(fa);return pa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return u}; svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return g};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return v};svgedit.browser.supportsSelectors=function(){return A};svgedit.browser.supportsXpath=function(){return p};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return R};svgedit.browser.supportsPathBBox=function(){return I}; svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return U};svgedit.browser.supportsNonScalingStroke=function(){return N};svgedit.browser.supportsNativeTransformLists=function(){return ha}}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(h){this._elem=h||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 u=null;if(n>=0)if(n=0){this._removeFromOtherLists(b);u=this._xforms[n]=b;this._list._update()}return u};this.removeItem=function(b){if(b=0){for(var n=this._xforms[b],u=Array(this.numberOfItems- 1),c=0;c1;)b=q[h-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 h=q.numberOfItems;h--;){var b=q.getItem(h);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(q,h,b,n,u){var c={x:q,y:h},g={x:q+b,y:h};b={x:q+b,y:h+n};q={x:q,y:h+n};h=svgedit.math.transformPoint;c=h(c.x,c.y,u);var d=n=c.x,l=c.y,v=c.y;g=h(g.x,g.y,u);n=Math.min(n,g.x);d=Math.max(d,g.x); l=Math.min(l,g.y);v=Math.max(v,g.y);q=h(q.x,q.y,u);n=Math.min(n,q.x);d=Math.max(d,q.x);l=Math.min(l,q.y);v=Math.max(v,q.y);b=h(b.x,b.y,u);n=Math.min(n,b.x);d=Math.max(d,b.x);l=Math.min(l,b.y);v=Math.max(v,b.y);return{tl:c,tr:g,bl:q,br:b,aabox:{x:n,y:l,width:d-n,height:v-l}}};svgedit.math.transformListToTransform=function(q,h,b){if(q==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());h=h==undefined?0:h;b=b==undefined?q.numberOfItems-1:b;h=parseInt(h);b=parseInt(b);if(h>b){var n=b;b=h; h=n}n=a.createSVGMatrix();for(h=h;h<=b;++h){var u=h>=0&&hq.x&&h.yq.y}})();svgedit=svgedit||{}; (function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],q=["y","y1","cy","ry","height"],h=$.merge(["r","radius"],a);$.merge(h,q);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 g=document.createElementNS("http://www.w3.org/2000/svg","rect");g.setAttribute("width","1em");g.setAttribute("height","1ex");g.setAttribute("x","1in");c.appendChild(g);g=g.getBBox();document.body.removeChild(c); c=g.x;n.em=g.width;n.ex=g.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 g=b.getRoundDigits();if(isNaN(c)){if($.isArray(c))return svgedit.units.shortFloat(c[0])+","+svgedit.units.shortFloat(c[1])}else return+(+c).toFixed(g);return parseFloat(c).toFixed(g)-0};svgedit.units.convertUnit=function(c,g){g=g||b.getBaseUnit();return svgedit.unit.shortFloat(c/n[g])};svgedit.units.setUnitAttr=function(c, g,d){isNaN(d)||c.getAttribute(g);c.setAttribute(g,d)};var u={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 g=c.tagName,d=b.getBaseUnit();if(g=u[g])for(var l=g.length,v=0;v=0?d*l:q.indexOf(c)>=0?d*v:d*Math.sqrt(l*l+v*v)/Math.sqrt(2)}else{l=g.substr(-2);d=g.substr(0,g.length-2);return d*n[l]}};svgedit.units.isValidUnit=function(c,g,d){var l=false;if(h.indexOf(c)>=0)if(isNaN(g)){g=g.toLowerCase();$.each(n,function(p){if(!l)if(RegExp("^-?[\\d\\.]+"+p+"$").test(g))l=true})}else l=true;else if(c=="id"){c=false;try{var v=b.getElement(g); c=v==null||v===d}catch(A){}return c}else l=true;return l}})();svgedit=svgedit||{}; (function(){function a(c){if(svgedit.browser.supportsHVLineContainerBBox())try{return c.getBBox()}catch(g){}var d=$.data(c,"ref"),l=null;if(d){var v=$(d).children().clone().attr("visibility","hidden");$(u).append(v);l=v.filter("line, path")}else l=$(c).find("line, path");var A=false;if(l.length){l.each(function(){var p=this.getBBox();if(!p.width||!p.height)A=true});if(A){c=d?v:$(c).children();ret=getStrokedBBox(c)}else ret=c.getBBox()}else ret=c.getBBox();d&&v.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(","),h=null,b=null,n=null,u=null;svgedit.utilities.init=function(c){h=c;b=c.getDOMDocument();n=c.getDOMContainer();u=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 g=Array(Math.floor((c.length+2)/3)*4),d,l,v,A,p,K,R=0,O=0;do{d=c.charCodeAt(R++);l=c.charCodeAt(R++);v=c.charCodeAt(R++);A=d>>2;d=(d&3)<<4|l>>4;p=(l&15)<<2|v>>6;K=v&63;if(isNaN(l))p=K=64;else if(isNaN(v))K=64;g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(A);g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(p);g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(K)}while(R< c.length);return g.join("")};svgedit.utilities.decode64=function(c){if(window.atob)return window.atob(c);var g="",d,l,v="",A,p="",K=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++)); d=d<<2|l>>4;l=(l&15)<<4|A>>2;v=(A&3)<<6|p;g+=String.fromCharCode(d);if(A!=64)g+=String.fromCharCode(l);if(p!=64)g+=String.fromCharCode(v)}while(K127)g+="&#"+l+";"}return g};svgedit.utilities.text2xml=function(c){if(c.indexOf("=0)c=c.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var g;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{g=d.loadXML?d.loadXML(c)?d:false:d.parseFromString(c,"text/xml")}catch(v){throw Error("Error parsing XML string");}return g};svgedit.utilities.bboxToObj=function(c){return{x:c.x,y:c.y,width:c.width,height:c.height}};svgedit.utilities.walkTree=function(c,g){if(c&&c.nodeType==1){g(c);for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),g)}}; svgedit.utilities.walkTreePost=function(c,g){if(c&&c.nodeType==1){for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),g);g(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,g){c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",g)};svgedit.utilities.findDefs=function(c){c=h.getSVGContent().documentElement;var g=c.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return g=g.length>0?g[0]:c.insertBefore(c.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),c.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(c){var g=c.pathSegList,d=g.numberOfItems;c=[[],[]];var l=g.getItem(0), v=[l.x,l.y];for(l=0;l= 0){var l=d.split(":");c[l[1]]=q[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 u=n.parentNode;if(n.ownerDocument&&u){var c=h[n.nodeName],g=b[n.nodeName];if(c!=undefined){for(var d=[],l=n.attributes.length;l--;){var v=n.attributes.item(l),A=v.nodeName, p=v.localName,K=v.namespaceURI;if(!(g.hasOwnProperty(p)&&K==g[p]&&K!="http://www.w3.org/2000/xmlns/")&&!(K=="http://www.w3.org/2000/xmlns/"&&a[v.nodeValue])){A.indexOf("se:")==0&&d.push([A,v.nodeValue]);n.removeAttributeNS(K,p)}if(svgedit.browser.isGecko())switch(A){case "transform":case "gradientTransform":case "patternTransform":p=v.nodeValue.replace(/(\d)-/g,"$1 -");n.setAttribute(A,p)}if(A=="style"){v=v.nodeValue.split(";");for(A=v.length;A--;){p=v[A].split(":");c.indexOf(p[0])>=0&&n.setAttribute(p[0], p[1])}n.removeAttribute("style")}}$.each(d,function(R,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))u.removeChild(n);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start", "mask","stroke"],function(R,O){var I=n.getAttribute(O);if(I)if((I=svgedit.utilities.getUrlFromAttr(I))&&I[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(u.insertBefore(n.firstChild,n));u.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,q,h,b){this.elem=a;this.text=b?"Move "+a.tagName+" to "+b:"Move "+a.tagName;this.oldNextSibling=q;this.oldParent=h;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,h,b){this.elem=a;this.text=b||"Delete "+a.tagName;this.nextSibling=q;this.parent=h;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,h){this.elem=a;this.text=h?"Change "+a.tagName+" "+h:"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,h;for(h in this.newValues){if(this.newValues[h])if(h=="#text")this.elem.textContent=this.newValues[h];else h=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[h]):this.elem.setAttribute(h,this.newValues[h]);else if(h=="#text")this.elem.textContent="";else{this.elem.setAttribute(h,"");this.elem.removeAttribute(h)}if(h== "transform")q=true}if(!q)if(q=svgedit.utilities.getRotationAngle(this.elem)){h=elem.getBBox();q=["rotate(",q," ",h.x+h.width/2,",",h.y+h.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,h;for(h in this.oldValues){if(this.oldValues[h])if(h== "#text")this.elem.textContent=this.oldValues[h];else h=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[h]):this.elem.setAttribute(h,this.oldValues[h]);else if(h=="#text")this.elem.textContent="";else this.elem.removeAttribute(h);if(h=="transform")q=true}if(!q)if(q=svgedit.utilities.getRotationAngle(this.elem)){h=this.elem.getBBox();q=["rotate(",q," ",h.x+h.width/2,",",h.y+h.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,h=0;h=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 h=this.stack[q].elements(),b=h.length;b--;)a.indexOf(h[b])==-1&&a.push(h[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 h=++this.undoChangeStackPointer,b=q.length,n=Array(b),u=Array(b);b--;){var c=q[b];if(c!=null){u[b]=c;n[b]=c.getAttribute(a)}}this.undoableChangeStack[h]= {attrName:a,oldValues:n,elements:u}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,q=this.undoableChangeStack[a],h=q.elements.length,b=q.attrName,n=new svgedit.history.BatchCommand("Change "+b);h--;){var u=q.elements[h];if(u!=null){var c={};c[b]=q.oldValues[h];c[b]!=u.getAttribute(b)&&n.addSubCommand(new svgedit.history.ChangeElementCommand(u,c,b))}}this.undoableChangeStack[a]=null;return n}})();svgedit=svgedit||{}; (function(){if(!svgedit.select)svgedit.select={};var a,q,h;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 u in h.selectorGrips)n.push(u);for(;b>0;){n.push(n.shift());b--}b=0;for(u in h.selectorGrips){h.selectorGrips[u].setAttribute("style", "cursor:"+n[b]+"-resize");b++}};svgedit.select.Selector.prototype.showGrips=function(b){h.selectorGripsGroup.setAttribute("display",b?"inline":"none");var n=this.selectedElement;this.hasGrips=b;if(n&&b){this.selectorGroup.appendChild(h.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(n))}};svgedit.select.Selector.prototype.resize=function(){var b=this.selectorRect,n=h,u=n.selectorGrips,c=this.selectedElement,g=c.getAttribute("stroke-width"),d=a.currentZoom(),l=1/d;if(c.getAttribute("stroke")!== "none"&&!isNaN(g))l+=g/2;var v=c.tagName;if(v==="text")l+=2/d;g=svgedit.transformlist.getTransformList(c);g=svgedit.math.transformListToTransform(g).matrix;g.e*=d;g.f*=d;var A=svgedit.utilities.getBBox(c);if(v==="g"&&!$.data(c,"gsvg"))if(v=a.getStrokedBBox(c.childNodes))A=v;v=A.x;var p=A.y,K=A.width;A=A.height;l*=d;d=svgedit.math.transformBox(v*d,p*d,K*d,A*d,g);g=d.aabox;v=g.x-l;p=g.y-l;K=g.width+l*2;var R=g.height+l*2;g=v+K/2;A=p+R/2;if(c=svgedit.utilities.getRotationAngle(c)){v=a.svgRoot().createSVGTransform(); v.setRotate(-c,g,A);v=v.matrix;d.tl=svgedit.math.transformPoint(d.tl.x,d.tl.y,v);d.tr=svgedit.math.transformPoint(d.tr.x,d.tr.y,v);d.bl=svgedit.math.transformPoint(d.bl.x,d.bl.y,v);d.br=svgedit.math.transformPoint(d.br.x,d.br.y,v);v=d.tl;K=v.x;R=v.y;var O=v.x,I=v.y;v=Math.min;p=Math.max;K=v(K,v(d.tr.x,v(d.bl.x,d.br.x)))-l;R=v(R,v(d.tr.y,v(d.bl.y,d.br.y)))-l;O=p(O,p(d.tr.x,p(d.bl.x,d.br.x)))+l;I=p(I,p(d.tr.y,p(d.bl.y,d.br.y)))+l;v=K;p=R;K=O-K;R=I-R}l=a.svgRoot().suspendRedraw(100);b.setAttribute("d", "M"+v+","+p+" L"+(v+K)+","+p+" "+(v+K)+","+(p+R)+" "+v+","+(p+R)+"z");this.selectorGroup.setAttribute("transform",c?"rotate("+[c,g,A].join(",")+")":"");if(svgedit.browser.isTouch()){v-=15.75;p-=15.75}else{v-=4;p-=4}this.gripCoords={nw:[v,p].map(Math.round),ne:[v+K,p].map(Math.round),sw:[v,p+R].map(Math.round),se:[v+K,p+R].map(Math.round),n:[v+K/2,p].map(Math.round),w:[v,p+R/2].map(Math.round),e:[v+K,p+R/2].map(Math.round),s:[v+K/2,p+R].map(Math.round)};for(var Q in this.gripCoords){b=this.gripCoords[Q]; u[Q].setAttribute("x",b[0]);u[Q].setAttribute("y",b[1])}this.rotateCoords={nw:[v,p],ne:[v+K+8,p],sw:[v,p+R+8],se:[v+K+8,p+R+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("+q.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=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"}});n=a.createSVGElement({element:"defs",attr:{id:"placeholder_defs"}});var u=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"}}),g=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(u);u.appendChild(c);u.appendChild(g);u.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 u=0;u element";this.svgElem_=b;this.obj_num=0;this.idPrefix=n||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_= "";var u=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(u&&h!=q.NEVER_RANDOMIZE)this.nonce_=u;else h==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,n=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();n=true}else this.obj_num++;for(var u=this.getId();this.getElem_(u);){if(n){this.obj_num=b;n=false}this.obj_num++;u=this.getId()}if(n)this.obj_num=b;return u};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=[],u=[],c=null,g=false,d=0;d0||!g){for(d=1;u.indexOf("Layer "+d)>=0;)d++;u="Layer "+d;c=b.createElementNS("http://www.w3.org/2000/svg","g");g=b.createElementNS("http://www.w3.org/2000/svg","title");g.textContent=u; c.appendChild(g);for(g=0;g1))for(var u=0;u0){g=R element";this.elem=g;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 g=this.elem.pathSegList,d=g.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l=d?null:g[l+1],K=l-1<0?null:g[l-1];if(A.type===2){if(K&&K.type!==1){p=g[v];p.next=g[v+1];p.next.prev=p;p.addGrip()}v=l}else if(p&&p.type===1){A.next=g[v+1];A.next.prev=A;A.mate=g[v];A.addGrip();if(this.first_seg==null)this.first_seg=A}else if(p){if(A.type!==1){A.addGrip();if(p&&p.type!==2){A.next=p;A.next.prev=A}}}else if(A.type!==1){p=g[v];p.next=g[v+1];p.next.prev=p;p.addGrip();A.addGrip();if(!this.first_seg)this.first_seg= g[v]}}return this};svgedit.path.Path.prototype.eachSeg=function(g){for(var d=this.segs.length,l=0;l').documentElement, true);a.appendChild(d);var l=g.createElementNS(b,"svg");(c.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:u[0],height:u[1],x:u[0],y:u[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=g.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var v="svg_";c.setIdPrefix= function(e){v=e};c.current_drawing_=new svgedit.draw.Drawing(l,v);var A=c.getCurrentDrawing=function(){return c.current_drawing_},p=1,K=null,R={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}};R.text=$.extend(true,{},R.shape);$.extend(R.text, {fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=R.shape,I=Array(1),Q=this.addSvgElementFromJson=function(e){var k=svgedit.utilities.getElem(e.attr.id),m=A().getCurrentLayer();if(k&&e.element!=k.tagName){m.removeChild(k);k=null}if(!k){k=g.createElementNS(b,e.element);if(m)(K||m).appendChild(k)}e.curStyles&&svgedit.utilities.assignAttributes(k,{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(k,e.attr,100);svgedit.utilities.cleanupElement(k);return k},U=c.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ha=c.matrixMultiply=svgedit.math.matrixMultiply,pa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=c.transformListToTransform=svgedit.math.transformListToTransform, T=svgedit.math.snapToAngle,Z=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/p},getWidth:function(){return l.getAttribute("width")/p},getRoundDigits:function(){return db.round_digits}});var ua=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return g},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return I}, getSVGContent:function(){return l}});var ja=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,V=c.setHref=svgedit.utilities.setHref,X=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var oa=c.getRotationAngle=svgedit.utilities.getRotationAngle,qa=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,la=this.cleanupElement=svgedit.utilities.cleanupElement,wa=svgedit.sanitize.getNSMap(),Ha=c.sanitizeSvg=svgedit.sanitize.sanitizeSvg, Ba=svgedit.history.MoveElementCommand,Ia=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Ja=svgedit.history.ChangeElementCommand,Ea=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,k){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 B=k.elements();c.pathActions.clear();M("changed",B);B=k.type();m=e==m.AFTER_APPLY;if(B== Ba.type()){m=m?k.newParent:k.oldParent;m==l&&c.identifyLayers()}else if(B==Ia.type()||B==Ka.type()){k.parent==l&&c.identifyLayers();if(B==Ia.type())m&&Va(k.elem);else m||Va(k.elem);k.elem.tagName==="use"&&zb(k.elem)}else if(B==Ja.type()){k.elem.tagName=="title"&&k.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?k.newValues:k.oldValues;m.stdDeviation&&c.setBlurOffsets(k.elem.parentNode,m.stdDeviation);if(k.elem.tagName==="use"&&svgedit.browser.isWebkit()){B=k.elem;if(!B.getAttribute("x")&&!B.getAttribute("y")){m= B.parentNode;var z=B.nextSibling;m.removeChild(B);m.insertBefore(B,z)}}}}}});var va=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 p},getStrokedBBox:function(e){return c.getStrokedBBox([e])}});var Ga=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return p},getSVGRoot:function(){return d}}); svgedit.utilities.snapToGrid=function(e){var k=n.snappingStep,m=n.baseUnit;if(m!=="px")k*=svgedit.units.getTypeMap()[m];return e=Math.round(e/k)*k};var ta=svgedit.utilities.snapToGrid,Ua={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"},ub=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],fb=$.data, Va=function(e){var k=$(e).attr(ub),m;for(m in k){var B=k[m];if(B&&B.indexOf("url(")===0){B=ja(B).substr(1);if(!qa(B)){jb().appendChild(tb[B]);delete tb[B]}}}e=e.getElementsByTagName("*");if(e.length){k=0;for(m=e.length;k=0)F=f=c.convertToPath(J,true);else if(J.tagName=="rect"){var o=J.getAttribute("rx"),s=J.getAttribute("ry");if(o||s)F=f=c.convertToPath(J,true)}if(!f){var D=J.cloneNode(true),G=document.createElementNS(b,"g"),L=J.parentNode;L.appendChild(G);G.appendChild(D);F=svgedit.utilities.bboxToObj(G.getBBox());L.removeChild(G)}}return F}catch(W){console.log(J,W);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=k(this)}); if(m==null)return null;var B=m.x+m.width,z=m.y+m.height,H=m.x,C=m.y,w=function(J){var F=J.getAttribute("stroke-width"),f=0;if(J.getAttribute("stroke")!="none"&&!isNaN(F))f+=F/2;return f},E=[];$.each(e,function(J,F){var f=k(F);if(f){var o=w(F);H=Math.min(H,f.x-o);C=Math.min(C,f.y-o);E.push(f)}});m.x=H;m.y=C;$.each(e,function(J,F){var f=E[J];if(f&&F.nodeType==1){var o=w(F);B=Math.max(B,f.x+f.width+o);z=Math.max(z,f.y+f.height+o)}});m.width=B-H;m.height=z-C;return m};var rb=this.getVisibleElements=function(e){e|| (e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var k=[];$(e).children().each(function(m,B){try{B.getBBox()&&k.push(B)}catch(z){}});return k.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var k=[];$(e).children().each(function(m,B){try{B.getBBox()&&k.push({elem:B,bbox:getStrokedBBox([B])})}catch(z){}});return k.reverse()},xb=this.groupSvgElem=function(e){var k=document.createElementNS(b,"g");e.parentNode.replaceChild(k,e);$(k).append(e).data("gsvg", e)[0].id=ka()},ia=function(e){var k=document.createElementNS(e.namespaceURI,e.nodeName);k.removeAttribute("id");$.each(e.attributes,function(B,z){z.localName!="-moz-math-font-style"&&k.setAttributeNS(z.namespaceURI,z.nodeName,z.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=Ma.convertPath(e);k.setAttribute("d",m)}$.each(e.childNodes,function(B,z){switch(z.nodeType){case 1:k.appendChild(ia(z));break;case 3:k.textContent=z.nodeValue}});if($(e).data("gsvg"))$(k).data("gsvg",k.firstChild); else if($(e).data("symbol")){e=$(e).data("symbol");$(k).data("ref",e).data("symbol",e)}else k.tagName=="image"&&Eb(k);k.id=ka();return k},ca,ka,M;(function(e){var k={};ca=e.getId=function(){return A().getId()};ka=e.getNextId=function(){return A().getNextId()};M=e.call=function(m,B){if(k[m])return k[m](this,B)};e.bind=function(m,B){var z=k[m];k[m]=B;return z}})(c);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(b,"path");for(var k=0,m=e.length;k0&&z.getItem(0).type==4&&z.removeItem(0);if(e!=0){H=N(H,C,fa(z).matrix);C=d.createSVGTransform();C.setRotate(e,H.x,H.y);z.numberOfItems?z.insertItemBefore(C,0):z.appendItem(C)}else z.numberOfItems==0&&m.removeAttribute("transform");if(!k){z=m.getAttribute("transform");m.setAttribute("transform",B);ib("transform",z,I);M("changed",I)}qa("pathpointgrip_container");m=Ga.requestSelector(I[0]);m.resize();m.updateGripCursors(e)}};var Fa=this.recalculateAllSelectedDimensions=function(){for(var e= new Ea(hb=="none"?"position":"size"),k=I.length;k--;){var m=Sa(I[k]);m&&e.addSubCommand(m)}if(!e.isEmpty()){va(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"],Ra=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},cb=this.remapElement=function(e,k,m){var B=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",z=function(){if(B)for(var f in k)k[f]=ta(k[f]);ma(e,k,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var C=H===0? "fill":"stroke",w=e.getAttribute(C);if(w&&w.indexOf("url(")===0)if(m.a<0||m.d<0){w=P(w).cloneNode(true);if(m.a<0){var E=w.getAttribute("x1"),J=w.getAttribute("x2");w.setAttribute("x1",-(E-1));w.setAttribute("x2",-(J-1))}if(m.d<0){E=w.getAttribute("y1");J=w.getAttribute("y2");w.setAttribute("y1",-(E-1));w.setAttribute("y2",-(J-1))}w.id=ka();jb().appendChild(w);e.setAttribute(C,"url(#"+w.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)){C=fa(e).matrix; C=ha(C.inverse(),m,C);k.x=parseFloat(k.x)+C.e;k.y=parseFloat(k.y)+C.f}else{C=U(e);w=d.createSVGTransform();w.setMatrix(ha(fa(C).matrix,m));C.clear();C.appendItem(w)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){C=U(e);w=d.createSVGTransform();w.setMatrix(ha(fa(C).matrix,m));C.clear();C.appendItem(w)}else{C=N(k.x,k.y,m);k.width=m.a*k.width;k.height=m.d*k.height;k.x=C.x+Math.min(0,k.width);k.y=C.y+Math.min(0,k.height);k.width=Math.abs(k.width);k.height=Math.abs(k.height)}z(); break;case "ellipse":H=N(k.cx,k.cy,m);k.cx=H.x;k.cy=H.y;k.rx=m.a*k.rx;k.ry=m.d*k.ry;k.rx=Math.abs(k.rx);k.ry=Math.abs(k.ry);z();break;case "circle":H=N(k.cx,k.cy,m);k.cx=H.x;k.cy=H.y;H=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);k.r=Math.min((H.tr.x-H.tl.x)/2,(H.bl.y-H.tl.y)/2);if(k.r)k.r=Math.abs(k.r);z();break;case "line":C=N(k.x1,k.y1,m);E=N(k.x2,k.y2,m);k.x1=C.x;k.y1=C.y;k.x2=E.x;k.y2=E.y;case "text":m=e.querySelectorAll("tspan");for(H=m.length;H--;){C=ua("x",e.getAttribute("x")); w=ua("x",m[H].getAttribute("x"));E=ua("y",e.getAttribute("y"));J=ua("y",m[H].getAttribute("y"));var F={};if(!isNaN(C)&&!isNaN(w)&&C!=0&&w!=0&&k.x)F.x=k.x-(C-w);if(!isNaN(E)&&!isNaN(J)&&E!=0&&J!=0&&k.y)F.y=k.y-(E-J);if(F.x||F.y)ma(m[H],F,1E3,true)}z();break;case "use":z();break;case "g":(z=$(e).data("gsvg"))&&ma(z,k,1E3,true);break;case "polyline":case "polygon":z=k.points.length;for(H=0;H0){for(var m=k.numberOfItems;m--;){var B=k.getItem(m);if(B.type===0)k.removeItem(m);else if(B.type=== 1)svgedit.math.isIdentity(B.matrix)&&k.removeItem(m);else B.type===4&&B.angle===0&&k.removeItem(m)}if(k.numberOfItems===1&&oa(e))return null}if(!k||k.numberOfItems==0){e.removeAttribute("transform");return null}if(k){m=k.numberOfItems;for(var z=[];m--;){B=k.getItem(m);if(B.type===1)z.push([B.matrix,m]);else if(z.length)z=[]}if(z.length===2){m=d.createSVGTransformFromMatrix(ha(z[1][0],z[0][0]));k.removeItem(z[0][1]);k.removeItem(z[1][1]);k.insertItemBefore(m,z[1][1])}m=k.numberOfItems;if(m>=2&&k.getItem(m- 2).type===1&&k.getItem(m-1).type===2){z=d.createSVGTransform();B=ha(k.getItem(m-2).matrix,k.getItem(m-1).matrix);z.setMatrix(B);k.removeItem(m-2);k.removeItem(m-2);k.appendItem(z)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(k.numberOfItems===1&&k.getItem(0).type===1||k.numberOfItems===2&&k.getItem(0).type===1&&k.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new Ea("Transform");var C={},w=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":w={};w.points=e.getAttribute("points");z=e.points;var E=z.numberOfItems;C.points=Array(E);for(var J=0;J1.0E-10?Math.sin(J)/(1-Math.cos(J)):2/J;for(J=0;J=3&&k.getItem(s-2).type==3&&k.getItem(s-3).type==2&&k.getItem(s-1).type==2){J=3;var G=k.getItem(s-3).matrix,L=k.getItem(s-2).matrix,W=k.getItem(s-1).matrix;E=e.childNodes;for(F=E.length;F--;){var ba=E.item(F);B=H=0;if(ba.nodeType==1){var S=U(ba);if(S){B=fa(S).matrix;H=oa(ba);var Y=Ta,aa=[];Ta=ba.getAttribute("transform");if(H||pa(S)){var na= d.createSVGTransform();na.setMatrix(ha(G,L,W,B));S.clear();S.appendItem(na);aa.push(na)}else{H=ha(B.inverse(),W,B);na=d.createSVGMatrix();na.e=-H.e;na.f=-H.f;B=ha(na.inverse(),B.inverse(),G,L,W,B,H.inverse());var za=d.createSVGTransform(),ga=d.createSVGTransform(),Aa=d.createSVGTransform();za.setTranslate(H.e,H.f);ga.setScale(B.a,B.d);Aa.setTranslate(na.e,na.f);S.appendItem(Aa);S.appendItem(ga);S.appendItem(za);aa.push(Aa);aa.push(ga);aa.push(za)}m.addSubCommand(Sa(ba));Ta=Y}}}k.removeItem(s-1);k.removeItem(s- 2);k.removeItem(s-3)}else if(s>=3&&k.getItem(s-1).type==1){J=3;B=fa(k).matrix;na=d.createSVGTransform();na.setMatrix(B);k.clear();k.appendItem(na)}else if((s==1||s>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){J=2;H=fa(k).matrix;k.removeItem(0);B=fa(k).matrix.inverse();B=ha(B,H);H=B.e;B=B.f;if(H!=0||B!=0){E=e.childNodes;F=E.length;for(s=[];F--;){ba=E.item(F);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){Y=ba.getAttribute("clip-path");if(s.indexOf(Y)===-1){pb(Y,H,B);s.push(Y)}}Y=Ta;Ta=ba.getAttribute("transform"); if(S=U(ba)){G=d.createSVGTransform();G.setTranslate(H,B);S.numberOfItems?S.insertItemBefore(G,0):S.appendItem(G);m.addSubCommand(Sa(ba));S=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(G=S.length;G--;){L=S.item(G);if(ba==da(L)){W=d.createSVGTransform();W.setTranslate(-H,-B);U(L).insertItemBefore(W,0);m.addSubCommand(Sa(L))}}Ta=Y}}}s=[];Ta=Y}}else if(s==1&&k.getItem(0).type==1&&!z){J=1;B=k.getItem(0).matrix;E=e.childNodes;for(F=E.length;F--;){ba=E.item(F);if(ba.nodeType==1){Y=Ta;Ta=ba.getAttribute("transform"); if(S=U(ba)){H=ha(B,fa(S).matrix);s=d.createSVGTransform();s.setMatrix(H);S.clear();S.appendItem(s,0);m.addSubCommand(Sa(ba));Ta=Y;Y=ba.getAttribute("stroke-width");ba.getAttribute("stroke")!=="none"&&!isNaN(Y)&&ba.setAttribute("stroke-width",Y*((Math.abs(H.a)+Math.abs(H.d))/2))}}}k.clear()}else{if(z){f=d.createSVGTransform();f.setRotate(z,o.x,o.y);k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(J==2){if(z){o={x:f.x+D.e,y:f.y+ D.f};f=d.createSVGTransform();f.setRotate(z,o.x,o.y);k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}}else if(J==3){B=fa(k).matrix;D=d.createSVGTransform();D.setRotate(z,f.x,f.y);D=D.matrix;f=d.createSVGTransform();f.setRotate(z,o.x,o.y);o=f.matrix.inverse();Y=B.inverse();o=ha(Y,o,D,B);H=o.e;B=o.f;if(H!=0||B!=0){E=e.childNodes;for(F=E.length;F--;){ba=E.item(F);if(ba.nodeType==1){Y=Ta;Ta=ba.getAttribute("transform");S=U(ba);G=d.createSVGTransform();G.setTranslate(H,B);S.numberOfItems?S.insertItemBefore(G, 0):S.appendItem(G);m.addSubCommand(Sa(ba));Ta=Y}}}if(z)k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}}else{z=svgedit.utilities.getBBox(e);if(!z&&e.tagName!="path")return null;B=d.createSVGMatrix();if(H=oa(e)){f={x:z.x+z.width/2,y:z.y+z.height/2};o=N(z.x+z.width/2,z.y+z.height/2,fa(k).matrix);J=H*Math.PI/180;E=Math.abs(J)>1.0E-10?Math.sin(J)/(1-Math.cos(J)):2/J;for(J=0;J=3&&k.getItem(s-2).type==3&&k.getItem(s-3).type==2&&k.getItem(s-1).type==2){J=3;B=fa(k,s-3,s-1).matrix;k.removeItem(s-1);k.removeItem(s-2);k.removeItem(s-3)}else if(s== 4&&k.getItem(s-1).type==1){J=3;B=fa(k).matrix;na=d.createSVGTransform();na.setMatrix(B);k.clear();k.appendItem(na);B=d.createSVGMatrix()}else if((s==1||s>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){J=2;D=k.getItem(0).matrix;Y=fa(k,1).matrix;z=Y.inverse();B=ha(z,D,Y);k.removeItem(0)}else if(s==1&&k.getItem(0).type==1&&!H){B=fa(k).matrix;switch(e.tagName){case "line":C=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":C.points=e.getAttribute("points");if(C.points){z=e.points;E=z.numberOfItems; C.points=Array(E);for(J=0;J1&&z.showGrips(false)}}}M("selected",I);k||I.length==1?Ga.requestSelector(I[0]).showGrips(true):Ga.requestSelector(I[0]).showGrips(false);for(I.sort(function(H,C){if(H&&C&&H.compareDocumentPosition)return 3- (C.compareDocumentPosition(H)&6);else if(H==null)return 1});I[0]==null;)I.shift(0)}},ab=this.selectOnly=function(e,k){Qa(true);sb(e,k)};this.removeFromSelection=function(e){if(I[0]!=null)if(e.length!=0){var k=Array(I.length);j=0;len=I.length;for(var m=0;m=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var k=A().getCurrentLayer();if([d,a,l,k].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ga.selectorParentGroup;for(;e.parentNode!==(K||k);)e=e.parentNode;return e};(function(){var e=null,k=null,m=null,B= null,z=null,H={},C={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(w){if(!(w.originalEvent.touches&&w.originalEvent.touches>1)){var E=w.button===2;ob=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var J=N(w.pageX,w.pageY,ob),F=J.x*(isBotchedZoom?1:p);J=J.y*(isBotchedZoom?1:p);w.preventDefault();if(E)Da="select";F=F/p;J=J/p;var f=Fb(w);if(f.tagName==="a"&&f.childNodes.length===1)f=f.firstChild;var o=B=k=F,s=z=m=J;if(n.gridSnapping){F=ta(F);J=ta(J);k=ta(k);m=ta(m)}if(f== Ga.selectorParentGroup&&I[0]!=null){f=w.target;var D=fb(f,"type");if(D=="rotate"){Da="rotate";current_rotate_mode=fb(f,"dir")}else if(D=="resize"){Da="resize";hb=fb(f,"dir")}f=I[0]}Ta=f.getAttribute("transform");D=U(f);switch(Da){case "select":La=true;hb="none";if(E)La=false;if(f!=d){if(I.indexOf(f)==-1){w.shiftKey||Qa(true);sb([f]);vb=f;Ma.clear()}if(!E)for(E=0;E1))if(La)if(!(w.button=== 1||c.spaceKey)){var E=I[0],J=N(w.pageX,w.pageY,ob),F=J.x*(isBotchedZoom?1:p);J=J.y*(isBotchedZoom?1:p);var f=qa(ca()),o=x=F/p,s=y=J/p;if(n.gridSnapping){x=ta(x);y=ta(y)}w.preventDefault();switch(Da){case "select":if(I[0]!==null){o=x-k;var D=y-m;if(n.gridSnapping){o=ta(o);D=ta(D)}if(w.shiftKey){var G=T(k,m,x,y);x=G.x;y=G.y}if(o!=0||D!=0){s=I.length;for(var L=0;L0&&c.removeFromSelection(f);o.length>0&&sb(o);break;case "resize":f=U(E);o=(G=pa(f))?H:svgedit.utilities.getBBox(E);s=o.x;L=o.y;var ba=o.width,S=o.height;o=x-k;D=y-m;if(n.gridSnapping){o=ta(o);D=ta(D);S=ta(S);ba=ta(ba)}if(W=oa(E)){var Y=Math.sqrt(o*o+D*D);D=Math.atan2(D,o)-W*Math.PI/180;o=Y*Math.cos(D);D=Y*Math.sin(D)}if(hb.indexOf("n")==-1&&hb.indexOf("s")==-1)D=0;if(hb.indexOf("e")==-1&&hb.indexOf("w")== -1)o=0;var aa=Y=0,na=S?(S+D)/S:1,za=ba?(ba+o)/ba:1;if(hb.indexOf("n")>=0){na=S?(S-D)/S:1;aa=S}if(hb.indexOf("w")>=0){za=ba?(ba-o)/ba:1;Y=ba}o=d.createSVGTransform();D=d.createSVGTransform();ba=d.createSVGTransform();if(n.gridSnapping){s=ta(s);Y=ta(Y);L=ta(L);aa=ta(aa)}o.setTranslate(-(s+Y),-(L+aa));if(w.shiftKey)if(za==1)za=na;else na=za;D.setScale(za,na);ba.setTranslate(s+Y,L+aa);if(G){G=W?1:0;f.replaceItem(o,2+G);f.replaceItem(D,1+G);f.replaceItem(ba,0+G)}else{G=f.numberOfItems;f.replaceItem(ba, G-3);f.replaceItem(D,G-2);f.replaceItem(o,G-1)}Ga.requestSelector(E).resize();M("transition",I);break;case "zoom":o*=p;s*=p;ma(ra,{x:Math.min(B*p,o),y:Math.min(z*p,s),width:Math.abs(o-B*p),height:Math.abs(s-z*p)},100);break;case "text":ma(f,{x:x,y:y},1E3);break;case "line":o=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=ta(x);y=ta(y)}s=x;G=y;if(w.shiftKey){G=T(k,m,s,G);s=G.x;G=G.y}f.setAttributeNS(null,"x2",s);f.setAttributeNS(null,"y2",G);window.opera||d.unsuspendRedraw(o);break;case "foreignObject":case "square":case "rect":case "image":o= Math.abs(x-k);G=Math.abs(y-m);if(Da=="square"||w.shiftKey){o=G=Math.max(o,G);s=km?m+L:m-L}if(w.altKey){G=k;s=m;L=Math.abs(x-G);D=w.shiftKey?L:Math.abs(y-s)}f.setAttributeNS(null,"rx",L);f.setAttributeNS(null,"ry",D);f.setAttributeNS(null,"cx",G);f.setAttributeNS(null,"cy",s);window.opera||d.unsuspendRedraw(o);break;case "fhellipse":case "fhrect":C.minx=Math.min(o,C.minx);C.maxx=Math.max(o,C.maxx);C.miny=Math.min(s,C.miny);C.maxy= Math.max(s,C.maxy);case "fhpath":e+=+o+","+s+" ";f.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=p;y*=p;if(n.gridSnapping){x=ta(x);y=ta(y);k=ta(k);m=ta(m)}if(w.shiftKey){if(G=svgedit.path.path){f=G.dragging?G.dragging[0]:k;G=G.dragging?G.dragging[1]:m}else{f=k;G=m}G=T(f,G,x,y);x=G.x;y=G.y}if(ra&&ra.getAttribute("display")!=="none"){o*=p;s*=p;ma(ra,{x:Math.min(B*p,o),y:Math.min(z*p,s),width:Math.abs(o-B*p),height:Math.abs(s-z*p)},100)}Ma.mouseMove(w,x,y);break;case "textedit":x*= p;y*=p;bb.mouseMove(F,J);break;case "rotate":o=svgedit.utilities.getBBox(E);G=o.x+o.width/2;s=o.y+o.height/2;f=Z(E);f=N(G,s,f);G=f.x;s=f.y;f=o.x;L=o.y;if(current_rotate_mode=="nw")f=o.x+o.width;if(current_rotate_mode=="se")L=o.y+o.height;if(current_rotate_mode=="sw"){f=o.x+o.width;L=o.y+o.height}compensation_angle=(Math.atan2(s-L,G-f)*(180/Math.PI)-90)%360;W=(Math.atan2(s-y,G-x)*(180/Math.PI)-90)%360;W+=compensation_angle;if(n.gridSnapping)W=ta(W);if(w.shiftKey)W=Math.round(W/45)*45;c.setRotationAngle(W< -180?360+W:W,true);M("transition",I)}lb("mouseMove",{event:w,mouse_x:F,mouse_y:J,selected:E})}}).click(function(w){w.preventDefault();return false}).dblclick(function(w){var E=w.target.parentNode;if(E!==K){var J=Fb(w),F=J.tagName;if(F==="text"&&Da!=="textedit"){w=N(w.pageX,w.pageY,ob);bb.select(J,w.x,w.y)}if((F==="g"||F==="a")&&oa(J)){Gb(J);J=I[0];Qa(true)}K&&Hb();E.tagName!=="g"&&E.tagName!=="a"||E===A().getCurrentLayer()||J===Ga.selectorParentGroup||Kb(J)}}).mouseup(function(w){c.addClones=false; window.removeEventListener("keyup",c.removeClones);I=I.filter(Boolean);if(w.button!==2){var E=vb;vb=null;if(La){var J=N(w.pageX,w.pageY,ob),F=J.x*p;J=J.y*p;var f=F/p,o=J/p,s=qa(ca()),D=false;La=false;switch(Da){case "resize":case "multiselect":if(ra!=null){ra.setAttribute("display","none");kb=[]}Da="select";case "select":if(I[0]!=null){if(I.length==1){F=I[0];switch(F.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Za.fill=F.getAttribute("fill");Za.fill_opacity=F.getAttribute("fill-opacity"); Za.stroke=F.getAttribute("stroke");Za.stroke_opacity=F.getAttribute("stroke-opacity");Za.stroke_width=F.getAttribute("stroke-width");Za.stroke_dasharray=F.getAttribute("stroke-dasharray");Za.stroke_linejoin=F.getAttribute("stroke-linejoin");Za.stroke_linecap=F.getAttribute("stroke-linecap")}if(F.tagName=="text"){Ya.font_size=F.getAttribute("font-size");Ya.font_family=F.getAttribute("font-family")}Ga.requestSelector(F).showGrips(true)}Fa();if(f!=B||o!=z){w=I.length;for(F=0;F=0?E.indexOf(",",f+1)>=0:E.indexOf(" ",E.indexOf(" ")+1)>=0)s=Ma.smoothPolylineIntoPath(s);break;case "line":E=$(s).attr(["x1","x2","y1","y2"]);D=E.x1!=E.x2||E.y1!=E.y2;break;case "foreignObject":case "square":case "rect":case "image":E=$(s).attr(["width","height"]);D=E.width!=0||E.height!=0||Da==="image";break;case "circle":D=s.getAttribute("r")!=0;break;case "ellipse":E=$(s).attr(["rx","ry"]);D=E.rx!=null||E.ry!=null;break;case "fhellipse":if(C.maxx- C.minx>0&&C.maxy-C.miny>0){s=Q({element:"ellipse",curStyles:true,attr:{cx:(C.minx+C.maxx)/2,cy:(C.miny+C.maxy)/2,rx:(C.maxx-C.minx)/2,ry:(C.maxy-C.miny)/2,id:ca()}});M("changed",[s]);D=true}break;case "fhrect":if(C.maxx-C.minx>0&&C.maxy-C.miny>0){s=Q({element:"rect",curStyles:true,attr:{x:C.minx,y:C.miny,width:C.maxx-C.minx,height:C.maxy-C.miny,id:ca()}});M("changed",[s]);D=true}break;case "text":D=true;ab([s]);bb.start(s);break;case "path":s=null;La=true;E=Ma.mouseUp(w,s,F,J);s=E.element;D=E.keep; break;case "pathedit":D=true;s=null;Ma.mouseUp(w);break;case "textedit":D=false;s=null;bb.mouseUp(w,F,J);break;case "rotate":D=true;s=null;Da="select";E=c.undoMgr.finishUndoableChange();E.isEmpty()||va(E);Fa();M("changed",I)}F=lb("mouseUp",{event:w,mouse_x:F,mouse_y:J},true);$.each(F,function(W,ba){if(ba){D=ba.keep||D;s=ba.element;La=ba.started||La}});if(!D&&s!=null){A().releaseId(ca());s.parentNode.removeChild(s);s=null;for(F=w.target;F.parentNode.parentNode.tagName=="g";)F=F.parentNode;if((Da!= "path"||!drawn_path)&&F.parentNode.id!="selectorParentGroup"&&F.id!="svgcanvas"&&F.id!="svgroot"){c.setMode("select");ab([F],true)}}else if(s!=null){c.addedNew=true;w=0.2;var G;if(false.beginElement&&s.getAttribute("opacity")!=O.opacity){G=$(false).clone().attr({to:O.opacity,dur:w}).appendTo(s);try{G[0].beginElement()}catch(L){}}else w=0;setTimeout(function(){G&&G.remove();s.setAttribute("opacity",O.opacity);s.setAttribute("style","pointer-events:inherit");la(s);if(Da==="path")Ma.toEditMode(s);else n.selectNew&& ab([s],true);va(new Ia(s));M("changed",[s])},w*1E3)}Ta=null}}});$(a).bind("mousewheel DOMMouseScroll",function(w){if(w.shiftKey){w.preventDefault();ob=l.getScreenCTM().inverse();var E=N(w.pageX,w.pageY,ob);E={x:E.x,y:E.y,width:0,height:0};if(w.wheelDelta)if(w.wheelDelta>=120)E.factor=2;else{if(w.wheelDelta<=-120)E.factor=0.5}else if(w.detail)if(w.detail>0)E.factor=0.5;else if(w.detail<0)E.factor=2;E.factor&&M("zoomed",E)}})})();var Eb=function(e){$(e).click(function(k){k.preventDefault()})},bb=c.textActions= function(){function e(S){var Y=J.value==="";$(J).focus();if(!arguments.length)if(Y)S=0;else{if(J.selectionEnd!==J.selectionStart)return;S=J.selectionEnd}var aa;aa=s[S];Y||J.setSelectionRange(S,S);F=qa("text_cursor");if(!F){F=document.createElementNS(b,"line");ma(F,{id:"text_cursor",stroke:"#333","stroke-width":1});F=qa("selectorParentGroup").appendChild(F)}o||(o=setInterval(function(){var na=F.getAttribute("display")==="none";F.setAttribute("display",na?"inline":"none")},600));Y=H(aa.x,D.y);aa=H(aa.x, D.y+D.height);ma(F,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});f&&f.setAttribute("d","M 0 0")}function k(S,Y,aa){if(S===Y)e(Y);else{aa||J.setSelectionRange(S,Y);f=qa("text_selectblock");if(!f){f=document.createElementNS(b,"path");ma(f,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(f)}S=s[S];var na=s[Y];F.setAttribute("visibility","hidden");Y=H(S.x,D.y);aa=H(S.x+(na.x-S.x),D.y);var za=H(S.x,D.y+D.height); S=H(S.x+(na.x-S.x),D.y+D.height);ma(f,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+za.x+","+za.y+"z",display:"inline"})}}function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(s.length==1)return 0;aa=E.getCharNumAtPosition(aa);if(aa<0){aa=s.length-2;if(S<=s[0].x)aa=0}else if(aa>=s.length-2)aa=s.length-2;var na=s[aa];S>na.x+na.width/2&&aa++;return aa}function B(S,Y,aa){var na=J.selectionStart;S=m(S,Y);k(Math.min(na,S),Math.max(na,S),!aa)}function z(S,Y){var aa={x:S,y:Y};aa.x/=p;aa.y/= p;if(G){var na=N(aa.x,aa.y,G.inverse());aa.x=na.x;aa.y=na.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(G){var na=N(aa.x,aa.y,G);aa.x=na.x;aa.y=na.y}aa.x*=p;aa.y*=p;return aa}function C(S){k(0,E.textContent.length);$(this).unbind(S)}function w(S){if(ba&&E){var Y=N(S.pageX,S.pageY,ob);Y=z(Y.x*p,Y.y*p);Y=m(Y.x,Y.y);var aa=E.textContent,na=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);k(na,(aa?aa[0].length:0)+Y);$(S.target).click(C);setTimeout(function(){$(S.target).unbind("click", C)},300)}}var E,J,F,f,o,s=[],D,G,L,W,ba;return{select:function(S,Y,aa){E=S;bb.toEditMode(Y,aa)},start:function(S){E=S;bb.toEditMode()},mouseDown:function(S,Y,aa,na){S=z(aa,na);J.focus();e(m(S.x,S.y));L=aa;W=na},mouseMove:function(S,Y){var aa=z(S,Y);B(aa.x,aa.y)},mouseUp:function(S,Y,aa){var na=z(Y,aa);B(na.x,na.y,true);S.target!==E&&YL-2&&aaW-2&&bb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){ab([E],false);ba=false;Da="textedit";Ga.requestSelector(E).showGrips(false); Ga.requestSelector(E);bb.init();$(E).css("cursor","text");if(arguments.length){var aa=z(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(S){Da="select";clearInterval(o);o=null;f&&$(f).attr("display","none");F&&$(F).attr("visibility","hidden");$(E).css("cursor","move");if(S){Qa();$(E).css("cursor","move");M("selected",[E]);sb([E],true)}E&&!E.textContent.length&&c.deleteSelectedElements();$(J).blur();E=false},setInputElem:function(S){J=S},clear:function(){Da== "textedit"&&bb.toSelectMode()},init:function(){if(E){if(!E.parentNode){E=I[0];Ga.requestSelector(E).showGrips(false)}var S=E.textContent.length,Y=E.getAttribute("transform");D=svgedit.utilities.getBBox(E);G=Y?Z(E):null;s=Array(S);J.focus();$(E).unbind("dblclick",w).dblclick(w);if(!S)var aa={x:D.x+D.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(E)}this.selected_pts.sort();w=this.selected_pts.length;for(C=Array(w);w--;){J=this.segs[this.selected_pts[w]];J.select(true);C[w]=J.ptgrip}Ma.canDeleteNodes=true;Ma.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",C)};var z=k=null,H=false;return{mouseDown:function(C,w,E,J){if(Da==="path"){mouse_x=E;mouse_y=J;J=mouse_x/p;w=mouse_y/p;E=qa("path_stretch_line");m=[J,w];if(n.gridSnapping){J=ta(J);w=ta(w);mouse_x= ta(mouse_x);mouse_y=ta(mouse_y)}if(!E){E=document.createElementNS(b,"path");ma(E,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});E=qa("selectorParentGroup").appendChild(E)}E.setAttribute("display","inline");var F=null;if(z){F=z.pathSegList;for(var f=F.numberOfItems,o=6/p,s=false;f;){f--;var D=F.getItem(f),G=D.x;D=D.y;if(J>=G-o&&J<=G+o&&w>=D-o&&w<=D+o){s=true;break}}o=ca();svgedit.path.removePath_(o);o=qa(o);G=F.numberOfItems;if(s){if(f<=1&&G>=2){J=F.getItem(0).x;w=F.getItem(0).y; C=E.pathSegList.getItem(1);C=C.pathSegType===4?z.createSVGPathSegLinetoAbs(J,w):z.createSVGPathSegCurvetoCubicAbs(J,w,C.x1/p,C.y1/p,J,w);J=z.createSVGPathSegClosePath();F.appendItem(C);F.appendItem(J)}else if(G<3)return F=false;$(E).remove();element=o;z=null;La=false;if(e){svgedit.path.path.matrix&&cb(o,{},svgedit.path.path.matrix.inverse());E=o.getAttribute("d");C=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",C+E);$(o).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath(); svgedit.path.path.init();Ma.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Fb(C))){console.log("Clicked outside canvas");return false}F=z.pathSegList.numberOfItems;f=z.pathSegList.getItem(F-1);o=f.x;f=f.y;if(C.shiftKey){C=T(o,f,J,w);J=C.x;w=C.y}C=E.pathSegList.getItem(1);C=C.pathSegType===4?z.createSVGPathSegLinetoAbs(eb(J),eb(w)):z.createSVGPathSegCurvetoCubicAbs(eb(J),eb(w),C.x1/p,C.y1/p,C.x2/p,C.y2/p);z.pathSegList.appendItem(C);J*=p;w*=p;E.setAttribute("d", ["M",J,w,J,w].join(" "));E=F;if(e)E+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(E,J,w)}}else{d_attr="M"+J+","+w+" ";z=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:O.opacity/2}});E.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));E=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(E,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();o=C.target.id;if(o.substr(0,14)=="pathpointgrip_"){w=svgedit.path.path.cur_pt=parseInt(o.substr(14)); svgedit.path.path.dragging=[E,J];F=svgedit.path.path.segs[w];if(C.shiftKey)F.selected?svgedit.path.path.removePtFromSelection(w):svgedit.path.path.addPtsToSelection(w);else{if(svgedit.path.path.selected_pts.length<=1||!F.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(w)}}else if(o.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[E,J];C=o.split("_")[1].split("c");w=C[0]-0;svgedit.path.path.selectPt(w,C[1]-0)}if(!svgedit.path.path.dragging){if(ra==null)ra=Ga.getRubberBandBox(); ma(ra,{x:E*p,y:J*p,width:0,height:0,display:"inline"},100)}}},mouseMove:function(C,w,E){H=true;if(Da==="path"){if(z){var J=z.pathSegList;C=J.numberOfItems-1;if(m){var F=svgedit.path.addCtrlGrip("1c1"),f=svgedit.path.addCtrlGrip("0c2");f.getAttribute("cx");f.getAttribute("cy");F.setAttribute("cx",w);F.setAttribute("cy",E);F.setAttribute("display","inline");F=m[0];var o=m[1];J.getItem(C);var s=F+(F-w/p),D=o+(o-E/p);f.setAttribute("cx",s*p);f.setAttribute("cy",D*p);f.setAttribute("display","inline"); f=svgedit.path.getCtrlLine(1);var G=svgedit.path.getCtrlLine(2);ma(f,{x1:w,y1:E,x2:F*p,y2:o*p,display:"inline"});ma(G,{x1:s*p,y1:D*p,x2:F*p,y2:o*p,display:"inline"});if(C===0)B=[w,E];else{J=J.getItem(C-1);w=J.x;E=J.y;if(J.pathSegType===6){w+=w-J.x2;E+=E-J.y2}else if(B){w=B[0]/p;E=B[1]/p}svgedit.path.replacePathSeg(6,C,[F,o,w,E,s,D],z)}}else if(F=qa("path_stretch_line")){C=J.getItem(C);if(C.pathSegType===6)svgedit.path.replacePathSeg(6,1,[w,E,(C.x+(C.x-C.x2))*p,(C.y+(C.y-C.y2))*p,w,E],F);else B?svgedit.path.replacePathSeg(6, 1,[w,E,B[0],B[1],w,E],F):svgedit.path.replacePathSeg(4,1,[w,E],F)}}}else if(svgedit.path.path.dragging){F=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);o=svgedit.path.getPointFromGrip({x:w,y:E},svgedit.path.path);C=o.x-F.x;F=o.y-F.y;svgedit.path.path.dragging=[w,E];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(C,F):svgedit.path.path.movePts(C,F)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next|| this.prev){var L=ra.getBBox(),W=svgedit.path.getGripPt(this);L=svgedit.math.rectsIntersect(L,{x:W.x,y:W.y,width:0,height:0});this.select(L);L&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(C,w){if(Da==="path"){m=null;if(!z){w=qa(ca());La=false;B=null}return{keep:true,element:w}}if(svgedit.path.path.dragging){var E=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)"); !C.shiftKey&&!H&&svgedit.path.path.selectPt(E)}else if(ra&&ra.getAttribute("display")!="none"){ra.setAttribute("display","none");ra.getAttribute("width")<=2&&ra.getAttribute("height")<=2&&Ma.toSelectMode(C.target)}else Ma.toSelectMode(C.target);H=false},toEditMode:function(C){svgedit.path.path=svgedit.path.getPath_(C);Da="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(C){var w=C==svgedit.path.path.elem; Da="select";svgedit.path.path.show(false);k=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(w){M("selected",[C]);sb([C],true)}},addSubPath:function(C){if(C){Da="path";e=true}else{Ma.clear(true);Ma.toEditMode(svgedit.path.path.elem)}},select:function(C){if(k===C){Ma.toEditMode(C);Da="pathedit"}else k=C},reorient:function(){var C=I[0];if(C)if(oa(C)!=0){var w=new Ea("Reorient path"),E={d:C.getAttribute("d"),transform:C.getAttribute("transform")};w.addSubCommand(new Ja(C,E)); Qa();this.resetOrientation(C);va(w);svgedit.path.getPath_(C).show(false).matrix=null;this.clear();sb([C],true);M("changed",I)}},clear:function(){k=null;if(z){var C=qa(ca());$(qa("path_stretch_line")).remove();$(C).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");z=B=null;La=false}else Da=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(C){if(C==null||C.nodeName!="path")return false;var w=U(C),E=fa(w).matrix; w.clear();C.removeAttribute("transform");w=C.pathSegList;for(var J=w.numberOfItems,F=0;F0){o=J.getItem(F-1).pathSegType;if(o===2){f(F-1,1);E();break}else if(o=== 1&&J.numberOfItems-1===F){f(F,1);E();break}}}return false};E();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ma.toSelectMode(svgedit.path.path.elem);c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){C=$(svgedit.path.path.elem);C.attr("d",C.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(C){var w=C.points,E=w.numberOfItems;if(E>=4){var J=w.getItem(0),F=null;C=[];C.push(["M",J.x,",", J.y," C"].join(""));for(var f=1;f<=E-4;f+=3){var o=w.getItem(f),s=w.getItem(f+1),D=w.getItem(f+2);if(F)if((J=svgedit.path.smoothControlPoints(F,o,J))&&J.length==2){o=C[C.length-1].split(",");o[2]=J[0].x;o[3]=J[0].y;C[C.length-1]=o.join(",");o=J[1]}C.push([o.x,o.y,s.x,s.y,D.x,D.y].join(","));J=D;F=s}for(C.push("L");f0;);Ma.clear(true); $.each(l.childNodes,function(m,B){m&&B.nodeType===8&&B.data.indexOf("Created with")>=0&&l.insertBefore(B,l.firstChild)});if(K){Hb();ab([K])}$("#canvasGrid").attr("display","none");var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,B=m.length,z=0;z=0;E--){w=C.item(E); f=B(w.nodeValue);if(!(o.indexOf(w.localName)>=0))if(f!="")if(f.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&f.indexOf("se_")===0)){m.push(" ");if(w.localName==="d")f=Ma.convertPath(e,true);if(isNaN(f)){if(H.test(f))f=svgedit.units.shortFloat(f)+z}else f=svgedit.units.shortFloat(f);if(db.apply&&e.nodeName==="image"&&w.localName==="href"&&db.images&&db.images==="embed"){var s=Xa[f];if(s)f=s}if(!w.namespaceURI||w.namespaceURI==b||wa[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(f); m.push('"')}}}}if(e.hasChildNodes()){m.push(">");k++;C=false;for(E=0;E");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("