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],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=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 U=d.call(arguments,1);return function(){return da.apply(this,U.concat(d.call(arguments)))}}function n(da,U,Y,oa,pa){var la;if(oa!==f){U=Y.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Y=U[3]||"";if(pa===2&&h(oa))oa=oa.replace(da?V:aa,"");else{la=p(U[2]);oa=h(oa)?p[da?ha:M](oa):oa;oa=pa===2?oa:pa===1?a.extend({},oa,la):a.extend({},la,oa);oa=s(oa);if(da)oa=oa.replace(ra,l)}da=U[1]+(da?"#":oa||!U[1]?"?":"")+oa+Y}else da= U(Y!==f?Y:q[na][fa]);return da}function u(da,U,Y){if(U===f||typeof U==="boolean"){Y=U;U=s[da?ha:M]()}else U=h(U)?U.replace(da?V:aa,""):U;return p(U,Y)}function c(da,U,Y,oa){if(!h(Y)&&typeof Y!=="object"){oa=Y;Y=U;U=f}return this.each(function(){var pa=a(this),la=U||P()[(this.nodeName||"").toLowerCase()]||"",ma=la&&pa.attr(la)||"";pa.attr(la,s[da](ma,Y,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,s=a.param,C,p,L,R=a.bbq=a.bbq||{},O,K,P,T=a.event.special,M="querystring",ha="fragment",na= "location",fa="href",aa=/^.*\?|#.*$/g,V=/^.*\#/,ra,ia={};s[M]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});s[ha]=C=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});C.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);ra=RegExp(da.join("|"),"g")};C.noEscape(",/");a.deparam=p=function(da,U){var Y={},oa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(pa,la){var ma=la.split("="),Ba=l(ma[0]),Ea=Y,Ia= 0,za=Ba.split("]["),Ka=za.length-1;if(/\[/.test(za[0])&&/\]$/.test(za[Ka])){za[Ka]=za[Ka].replace(/\]$/,"");za=za.shift().split("[").concat(za);Ka=za.length-1}else Ka=0;if(ma.length===2){ma=l(ma[1]);if(U)ma=ma&&!isNaN(ma)?+ma:ma==="undefined"?f:oa[ma]!==f?oa[ma]:ma;if(Ka)for(;Ia<=Ka;Ia++){Ba=za[Ia]===""?Ea.length:za[Ia];Ea=Ea[Ba]=Ia').hide().insertAfter("body")[0].contentWindow; K=function(){return b(R.document[c][f])};O=function(P,T){if(P!==T){var M=R.document;M.open().close();M[c].hash="#"+P}};O(b())}}var p={},L,R,O,K;p.start=function(){if(!L){var P=b();O||C();(function T(){var M=b(),ha=K(P);if(M!==P){O(P=M,ha);a(q).trigger("hashchange")}else if(ha!==P)q[c][f]=q[c][f].replace(/#.*/,"")+"#"+ha;L=setTimeout(T,a.hashchangeDelay)})()}};p.stop=function(){if(!R){L&&clearTimeout(L);L=0}};return p}()})(jQuery,this);(function(a){var q={},h;a.svgIcons=function(b,n){function u(da,U){if(da!=="ajax"){if(P)return;var Y=(R=fa[0].contentDocument)&&R.getElementById("svg_eof");if(!Y&&!(U&&Y)){T++;if(T<50)setTimeout(u,20);else{f();P=true}return}P=true}L=a(R.firstChild).children();if(n.no_img)setTimeout(function(){K||c()},500);else{Y=na+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:Y,width:0,height:0}).appendTo("body").load(function(){c(true)}).error(function(){c()})}} function c(da,U){if(!K){if(n.no_img)da=false;if(da){var Y=a(document.createElement("div"));Y.hide().appendTo("body")}if(U){var oa=n.fallback_path?n.fallback_path:"";a.each(U,function(Ka,Na){a("#"+Ka);var Aa=a(new Image).attr({"class":"svg_icon",src:oa+Na,width:C,height:p,alt:"icon"});ia(Aa,Ka)})}else for(var pa=L.length,la=0;la0&&!da)ya=h(ya,Aa,true);ra(a(this),ya,Na)})});if(!U){da&&Y.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);K=true;n.callback&&n.callback(q)}}function f(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)} function d(da){if(window.btoa)return window.btoa(da);var U=Array(Math.floor((da.length+2)/3)*4),Y,oa,pa,la,ma,Ba,Ea=0,Ia=0;do{Y=da.charCodeAt(Ea++);oa=da.charCodeAt(Ea++);pa=da.charCodeAt(Ea++);la=Y>>2;Y=(Y&3)<<4|oa>>4;ma=(oa&15)<<2|pa>>6;Ba=pa&63;if(isNaN(oa))ma=Ba=64;else if(isNaN(pa))Ba=64;U[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(la);U[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Y);U[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma); U[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Ba)}while(Ea-1&&M.indexOf("Chrome/");var na="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(aa){f()}}else{var V=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){R=V.parseFromString(da,"text/xml");a(function(){u("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){R=V.parseFromString(da.responseText,"text/xml");R.childNodes.length||a(f);a(function(){u("ajax")})}else a(f)}})}var ra=function(da,U,Y,oa){ha&&U.css("visibility","hidden");if(n.replace){oa&&U.attr("id",Y);(Y=da.attr("class"))&&U.attr("class", "svg_icon "+Y);da.replaceWith(U)}else da.append(U);ha&&setTimeout(function(){U.removeAttr("style")},1)},ia=function(da,U){if(n.id_match===undefined||n.id_match!==false)ra(holder,da,U,true);q[U]=da};h=function(da,U){var Y=da.find("defs");if(!Y.length)return da;Y=ha?Y.find("*").filter(function(){return!!this.id}):Y.find("[id]");var oa=da[0].getElementsByTagName("*"),pa=oa.length;Y.each(function(la){var ma=this.id;a(R).find("#"+ma);this.id=la="x"+ma+U+la;ma="url(#"+ma+")";var Ba="url(#"+la+")";for(la= 0;la=0;jQuery.fn.jGraduate=function(b){var n= arguments;return this.each(function(){function u(ja,ba,ka,N,Q){var ea=Q||a("stop",{"stop-color":ba,"stop-opacity":ka,offset:ja},V);if(Q){ba=Q.getAttribute("stop-color");ka=Q.getAttribute("stop-opacity");ja=Q.getAttribute("offset")}else V.appendChild(ea);if(ka===null)ka=1;Q=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+ja*ha)+", 26)"},nb);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:ba,"fill-opacity":ka,transform:"translate("+(10+ja*ha)+", 26)",stroke:"#000","stroke-width":1.5},nb);$(Fa).mousedown(function(Oa){c(this);Wa=fb;P.mousemove(l).mouseup(f);wa=Ya.offset();Oa.preventDefault();return false}).data("stop",ea).data("bg",Q).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Oa=this,Va=+ea.getAttribute("stop-opacity")|| 1,$a=ea.getAttribute("stop-color")||1,qb=(parseFloat(Va)*255).toString(16);qb.length<2;)qb="0"+qb;ba=$a.substr(1)+qb;$("#"+p+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:C.images.clientPath},color:{active:ba,alphaSupport:true}},function(Qa){$a=Qa.val("hex")?"#"+Qa.val("hex"):"none";Va=Qa.val("a")!==null?Qa.val("a")/256:1;Oa.setAttribute("fill",$a);Oa.setAttribute("fill-opacity",Va);ea.setAttribute("stop-color", $a);ea.setAttribute("stop-opacity",Va);$("div.jGraduate_LightBox").hide();$("#"+p+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+p+"_jGraduate_stopPicker").hide()})});$(V).find("stop").each(function(){var Oa=$(this);if(+this.getAttribute("offset")>ja){if(!ba){var Va=this.getAttribute("stop-color"),$a=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Va);Fa.setAttribute("fill",Va);ea.setAttribute("stop-opacity",$a===null?1:$a);Fa.setAttribute("fill-opacity", $a===null?1:$a)}Oa.before(ea);return false}});N&&c(Fa);return ea}function c(ja){fb&&fb.setAttribute("stroke","#000");ja.setAttribute("stroke","blue");fb=ja;fb.parentNode.appendChild(fb)}function f(){P.unbind("mousemove",l);if(Ca.getAttribute("display")!=="none"){Ca.setAttribute("display","none");var ja=$(fb),ba=ja.data("stop");ja=ja.data("bg");$([fb,ba,ja]).remove()}Wa=null}function d(){var ja=Ra?"rotate("+Ra+","+Da+","+gb+") ":"";db===1&&La===1?V.removeAttribute("gradientTransform"):V.setAttribute("gradientTransform", ja+"translate("+-Da*(db-1)+","+-gb*(La-1)+") scale("+db+","+La+")")}function l(ja){var ba=ja.pageX-wa.left;ja=ja.pageY-wa.top;ba=ba<10?10:ba>ha+10?ha+10:ba;var ka="translate("+ba+", 26)";if(ja<-60||ja>130){Ca.setAttribute("display","block");Ca.setAttribute("transform",ka)}else Ca.setAttribute("display","none");Wa.setAttribute("transform",ka);$.data(Wa,"bg").setAttribute("transform",ka);$.data(Wa,"stop").setAttribute("offset",(ba-10)/ha);var N=0;$(V).find("stop").each(function(){var Q=this.getAttribute("offset"), ea=$(this);if(Q
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var T=$(L+"> .jGraduate_colPick"),M=$(L+"> .jGraduate_gradPick");M.html('

    '+C.window.pickerTitle+'


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