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

    '+B.window.pickerTitle+'


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