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

    '+A.window.pickerTitle+'


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

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

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