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

    '+B.window.pickerTitle+'


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

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

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