function touchHandler(a){var p=a.changedTouches,g=p[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(p.length<2){g.target.dispatchEvent(m);a.preventDefault()}};(function(a){function p(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="",k={};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)k[d+b]= true;else{k[d+f]=true;k[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")k[a.hotkeys.shiftNums[f]]=true}b=0;for(f=m.length;b","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function c(da){var X=d.call(arguments,1);return function(){return da.apply(this,X.concat(d.call(arguments)))}}function m(da,X,Z,oa,ra){var ma;if(oa!==f){X=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=X[3]||"";if(ra===2&&g(oa))oa=oa.replace(da?W:ba,"");else{ma=o(X[2]);oa=g(oa)?o[da?ia:P](oa):oa;oa=ra===2?oa:ra===1?a.extend({},oa,ma):a.extend({},ma,oa);oa=q(oa);if(da)oa=oa.replace(ta,k)}da=X[1]+(da?"#":oa||!X[1]?"?":"")+oa+Z}else da= X(Z!==f?Z:p[qa][ga]);return da}function s(da,X,Z){if(X===f||typeof X==="boolean"){Z=X;X=q[da?ia:P]()}else X=g(X)?X.replace(da?W:ba,""):X;return o(X,Z)}function b(da,X,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=X;X=f}return this.each(function(){var ra=a(this),ma=X||S()[(this.nodeName||"").toLowerCase()]||"",na=ma&&ra.attr(ma)||"";ra.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,k=decodeURIComponent,q=a.param,B,o,J,U=a.bbq=a.bbq||{},M,I,S,Y=a.event.special,P="querystring",ia="fragment",qa= "location",ga="href",ba=/^.*\?|#.*$/g,W=/^.*\#/,ta,ka={};q[P]=c(m,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=c(m,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);ta=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,X){var Z={},oa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ra,ma){var na=ma.split("="),Ca=k(na[0]),Ga=Z,Ja= 0,Da=Ca.split("]["),La=Da.length-1;if(/\[/.test(Da[0])&&/\]$/.test(Da[La])){Da[La]=Da[La].replace(/\]$/,"");Da=Da.shift().split("[").concat(Da);La=Da.length-1}else La=0;if(na.length===2){na=k(na[1]);if(X)na=na&&!isNaN(na)?+na:na==="undefined"?f:oa[na]!==f?oa[na]:na;if(La)for(;Ja<=La;Ja++){Ca=Da[Ja]===""?Ga.length:Da[Ja];Ga=Ga[Ca]=Ja').hide().insertAfter("body")[0].contentWindow; I=function(){return c(U.document[b][f])};M=function(S,Y){if(S!==Y){var P=U.document;P.open().close();P[b].hash="#"+S}};M(c())}}var o={},J,U,M,I;o.start=function(){if(!J){var S=c();M||B();(function Y(){var P=c(),ia=I(S);if(P!==S){M(S=P,ia);a(p).trigger("hashchange")}else if(ia!==S)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;J=setTimeout(Y,a.hashchangeDelay)})()}};o.stop=function(){if(!U){J&&clearTimeout(J);J=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,m){function s(da,X){if(da!=="ajax"){if(S)return;var Z=(U=ga[0].contentDocument)&&U.getElementById("svg_eof");if(!Z&&!(X&&Z)){Y++;if(Y<50)setTimeout(s,20);else{f();S=true}return}S=true}J=a(U.firstChild).children();if(m.no_img)setTimeout(function(){I||b()},500);else{Z=qa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} function b(da,X){if(!I){if(m.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(X){var oa=m.fallback_path?m.fallback_path:"";a.each(X,function(La,Oa){a("#"+La);var Ba=a(new Image).attr({"class":"svg_icon",src:oa+Oa,width:B,height:o,alt:"icon"});ka(Ba,La)})}else for(var ra=J.length,ma=0;ma0&&!da)za=g(za,Ba,true);ta(a(this),za,Oa)})});if(!X){da&&Z.remove();ga&&ga.remove();M&&M.remove()}m.resize&&a.resizeSvgIcons(m.resize);I=true;m.callback&&m.callback(p)}}function f(){if(c.indexOf(".svgz")!=-1){var da=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,m)}else m.fallback&&b(false,m.fallback)} function d(da){if(window.btoa)return window.btoa(da);var X=Array(Math.floor((da.length+2)/3)*4),Z,oa,ra,ma,na,Ca,Ga=0,Ja=0;do{Z=da.charCodeAt(Ga++);oa=da.charCodeAt(Ga++);ra=da.charCodeAt(Ga++);ma=Z>>2;Z=(Z&3)<<4|oa>>4;na=(oa&15)<<2|ra>>6;Ca=ra&63;if(isNaN(oa))na=Ca=64;else if(isNaN(ra))Ca=64;X[Ja++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);X[Ja++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);X[Ja++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na); X[Ja++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Ca)}while(Ga-1&&P.indexOf("Chrome/");var qa="data:image/svg+xml;charset=utf-8;base64,";if(m.svgz){var ga=a('').appendTo("body").hide();try{U=ga[0].contentDocument;ga.load(s); s(0,true)}catch(ba){f()}}else{var W=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){U=W.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){U=W.parseFromString(da.responseText,"text/xml");U.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var ta=function(da,X,Z,oa){ia&&X.css("visibility","hidden");if(m.replace){oa&&X.attr("id",Z);(Z=da.attr("class"))&&X.attr("class", "svg_icon "+Z);da.replaceWith(X)}else da.append(X);ia&&setTimeout(function(){X.removeAttr("style")},1)},ka=function(da,X){if(m.id_match===undefined||m.id_match!==false)ta(holder,da,X,true);p[X]=da};g=function(da,X){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var oa=da[0].getElementsByTagName("*"),ra=oa.length;Z.each(function(ma){var na=this.id;a(U).find("#"+na);this.id=ma="x"+na+X+ma;na="url(#"+na+")";var Ca="url(#"+ma+")";for(ma= 0;ma=0;jQuery.fn.jGraduate=function(c){var m= arguments;return this.each(function(){function s(la,ca,ja,O,T){var ea=T||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},W);if(T){ca=T.getAttribute("stop-color");ja=T.getAttribute("stop-opacity");la=T.getAttribute("offset")}else W.appendChild(ea);if(ja===null)ja=1;T=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+la*ia)+", 26)"},rb);var Ha= a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},rb);$(Ha).mousedown(function(Pa){b(this);Sa=jb;S.mousemove(k).mouseup(f);wa=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",T).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Xa=+ea.getAttribute("stop-opacity")|| 1,fb=ea.getAttribute("stop-color")||1,ob=(parseFloat(Xa)*255).toString(16);ob.length<2;)ob="0"+ob;ca=fb.substr(1)+ob;$("#"+o+"_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:ca,alphaSupport:true}},function(Wa){fb=Wa.val("hex")?"#"+Wa.val("hex"):"none";Xa=Wa.val("a")!==null?Wa.val("a")/256:1;Pa.setAttribute("fill",fb);Pa.setAttribute("fill-opacity",Xa);ea.setAttribute("stop-color", fb);ea.setAttribute("stop-opacity",Xa);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(W).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Xa=this.getAttribute("stop-color"),fb=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Xa);Ha.setAttribute("fill",Xa);ea.setAttribute("stop-opacity",fb===null?1:fb);Ha.setAttribute("fill-opacity", fb===null?1:fb)}Pa.before(ea);return false}});O&&b(Ha);return ea}function b(la){jb&&jb.setAttribute("stroke","#000");la.setAttribute("stroke","blue");jb=la;jb.parentNode.appendChild(jb)}function f(){S.unbind("mousemove",k);if(Ea.getAttribute("display")!=="none"){Ea.setAttribute("display","none");var la=$(jb),ca=la.data("stop");la=la.data("bg");$([jb,ca,la]).remove()}Sa=null}function d(){var la=Ta?"rotate("+Ta+","+Fa+","+lb+") ":"";hb===1&&Ma===1?W.removeAttribute("gradientTransform"):W.setAttribute("gradientTransform", la+"translate("+-Fa*(hb-1)+","+-lb*(Ma-1)+") scale("+hb+","+Ma+")")}function k(la){var ca=la.pageX-wa.left;la=la.pageY-wa.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Ea.setAttribute("display","block");Ea.setAttribute("transform",ja)}else Ea.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var O=0;$(W).find("stop").each(function(){var T=this.getAttribute("offset"), ea=$(this);if(T
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var Y=$(J+"> .jGraduate_colPick"),P=$(J+"> .jGraduate_gradPick");P.html('

    '+B.window.pickerTitle+'


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