diff --git a/editor/extensions/ext-eyedropper.js b/editor/extensions/ext-eyedropper.js index 47ea394..7e4da1c 100644 --- a/editor/extensions/ext-eyedropper.js +++ b/editor/extensions/ext-eyedropper.js @@ -31,20 +31,7 @@ svgEditor.addExtension("eyedropper", function(S) { // if we are in eyedropper mode, we don't want to disable the eye-dropper tool var mode = svgCanvas.getMode(); if (mode == "eyedropper") return; - - var elem = null; var tool = $('#tool_eyedropper'); - - if (opts.elems[0] && - $.inArray(opts.elems[0].nodeName, ['svg', 'g', 'use']) == -1) - { - elem = opts.elems[0]; - tool.removeClass('disabled'); - } - // disable eye-dropper tool - else { - tool.addClass('disabled'); - } } @@ -84,8 +71,8 @@ svgEditor.addExtension("eyedropper", function(S) { id: "tool_eyedropper", type: "mode", title: "Eye Dropper Tool", + position: 8, key: "I", - "class": "disabled", icon: "extensions/eyedropper.png", events: { "click": function() { @@ -94,10 +81,6 @@ svgEditor.addExtension("eyedropper", function(S) { } }], - - // if we have selected an element, grab its paint and enable the eye dropper button - selectedChanged: getStyle, - elementChanged: getStyle, mouseDown: function(opts) { var mode = svgCanvas.getMode(); var e = opts.event; @@ -112,6 +95,14 @@ svgEditor.addExtension("eyedropper", function(S) { currentStyle.strokeLinecap = target.getAttribute("stroke-linecap"); currentStyle.strokeLinejoin = target.getAttribute("stroke-linejoin"); currentStyle.opacity = target.getAttribute("opacity") || 1.0; + opts.selectedElements = opts.selectedElements.filter(Boolean) + if (!opts.selectedElements.length) { //nothing selected, just update colors + var fill = getPaint(currentStyle.fillPaint, currentStyle.fillOpacity*100, "fill"); + var stroke = getPaint(currentStyle.strokePaint, currentStyle.strokeOpacity*100, "stroke"); + svgEditor.paintBox.fill.setPaint(fill) + svgEditor.paintBox.stroke.setPaint(stroke) + return; + } if ($.inArray(opts.selectedElements.nodeName, ['g', 'use']) == -1) { var changes = {}; var change = function(elem, attrname, newvalue) { diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 05f8609..48fc181 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -429,6 +429,15 @@ svgCanvas.setMode('select'); }; + var setEyedropperMode = function() { + var curr = $('.tool_button_current'); + if(curr.length && curr[0].id !== 'tool_eyedropper') { + curr.removeClass('tool_button_current').addClass('tool_button'); + $('#tool_eyedropper').addClass('tool_button_current').removeClass('tool_button'); + } + svgCanvas.setMode('eyedropper'); + } + var togglePathEditMode = function(editmode, elems) { $('#path_node_panel').toggle(editmode); $('#tools_bottom_2,#tools_bottom_3').toggle(!editmode); @@ -1105,7 +1114,7 @@ sel: '#'+id, fn: btn.events.click, icon: btn.id, -// key: btn.key, + //key: btn.key, isDefault: true }, ref_data]; @@ -3337,6 +3346,7 @@ {key: ['alt+shift+left', true], fn: function(){svgCanvas.cloneSelectedElements(-10,0)}}, {key: ['alt+shift+right', true], fn: function(){svgCanvas.cloneSelectedElements(10,0)}}, {key: modKey + 'A', fn: function(){svgCanvas.selectAllInCurrentLayer();}}, + {key: 'I', fn: function(){setEyedropperMode()}}, // Standard shortcuts {key: modKey + 'shift+z', fn: clickRedo}, diff --git a/editor/svgedit.compiled.js b/editor/svgedit.compiled.js index 21a5c24..7760e0e 100644 --- a/editor/svgedit.compiled.js +++ b/editor/svgedit.compiled.js @@ -1,33 +1,33 @@ -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 n=document.createEvent("MouseEvent");n.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(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var c=g.handler,n=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=n.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 W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,Z,pa,qa){var ma;if(pa!==f){W=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=W[3]||"";if(qa===2&&g(pa))pa=pa.replace(da?Y:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=qa===2?pa:qa===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+Z}else da= -W(Z!==f?Z:p[oa][fa]);return da}function s(da,W,Z){if(W===f||typeof W==="boolean"){Z=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?Y:ba,""):W;return o(W,Z)}function b(da,W,Z,pa){if(!g(Z)&&typeof Z!=="object"){pa=Z;Z=W;W=f}return this.each(function(){var qa=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,J,T=a.bbq=a.bbq||{},O,K,Q,V=a.event.special,N="querystring",ia="fragment",oa= -"location",fa="href",ba=/^.*\?|#.*$/g,Y=/^.*\#/,sa,ka={};q[N]=c(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=c(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var Z={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(qa,ma){var na=ma.split("="),Aa=l(na[0]),Fa=Z,Ia= -0,Ca=Aa.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(W)na=na&&!isNaN(na)?+na:na==="undefined"?f:pa[na]!==f?pa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,Z,pa,qa){var ma;if(pa!==f){W=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=W[3]||"";if(qa===2&&g(pa))pa=pa.replace(da?Y:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=qa===2?pa:qa===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+Z}else da= +W(Z!==f?Z:p[oa][fa]);return da}function s(da,W,Z){if(W===f||typeof W==="boolean"){Z=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?Y:ba,""):W;return o(W,Z)}function c(da,W,Z,pa){if(!g(Z)&&typeof Z!=="object"){pa=Z;Z=W;W=f}return this.each(function(){var qa=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},O,J,Q,V=a.event.special,N="querystring",ia="fragment",oa= +"location",fa="href",ba=/^.*\?|#.*$/g,Y=/^.*\#/,sa,ka={};q[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var Z={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(qa,ma){var na=ma.split("="),Aa=l(na[0]),Fa=Z,Ia= +0,Ca=Aa.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(W)na=na&&!isNaN(na)?+na:na==="undefined"?f:pa[na]!==f?pa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia').hide().insertAfter("body")[0].contentWindow; -K=function(){return c(T.document[b][f])};O=function(Q,V){if(Q!==V){var N=T.document;N.open().close();N[b].hash="#"+Q}};O(c())}}var o={},J,T,O,K;o.start=function(){if(!J){var Q=c();O||B();(function V(){var N=c(),ia=K(Q);if(N!==Q){O(Q=N,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;J=setTimeout(V,a.hashchangeDelay)})()}};o.stop=function(){if(!T){J&&clearTimeout(J);J=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,W){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(W&&Z)){V++;if(V<50)setTimeout(s,20);else{f();Q=true}return}Q=true}J=a(T.firstChild).children();if(n.no_img)setTimeout(function(){K||b()},500);else{Z=oa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} -function b(da,W){if(!K){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(W){var pa=n.fallback_path?n.fallback_path:"";a.each(W,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:pa+Na,width:B,height:o,alt:"icon"});ka(za,Ka)})}else for(var qa=J.length,ma=0;ma').hide().insertAfter("body")[0].contentWindow; +J=function(){return b(T.document[c][f])};O=function(Q,V){if(Q!==V){var N=T.document;N.open().close();N[c].hash="#"+Q}};O(b())}}var o={},K,T,O,J;o.start=function(){if(!K){var Q=b();O||B();(function V(){var N=b(),ia=J(Q);if(N!==Q){O(Q=N,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[c][f]=p[c][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(V,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(b,n){function s(da,W){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(W&&Z)){V++;if(V<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||c()},500);else{Z=oa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){c(true)}).error(function(){c()})}} +function c(da,W){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(W){var pa=n.fallback_path?n.fallback_path:"";a.each(W,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:pa+Na,width:B,height:o,alt:"icon"});ka(za,Ka)})}else for(var qa=K.length,ma=0;ma0&&!da)ya=g(ya,za,true);sa(a(this),ya,Na)})});if(!W){da&&Z.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);K=true;n.callback&&n.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,n)}else n.fallback&&b(false,n.fallback)} +src:na})}else na=g(a(Fa),ma);ka(na,Aa)}n.placement&&a.each(n.placement,function(Ka,Na){p[Na]&&a(Ka).each(function(za){var ya=p[Na].clone();if(za>0&&!da)ya=g(ya,za,true);sa(a(this),ya,Na)})});if(!W){da&&Z.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)} function d(da){if(window.btoa)return window.btoa(da);var W=Array(Math.floor((da.length+2)/3)*4),Z,pa,qa,ma,na,Aa,Fa=0,Ia=0;do{Z=da.charCodeAt(Fa++);pa=da.charCodeAt(Fa++);qa=da.charCodeAt(Fa++);ma=Z>>2;Z=(Z&3)<<4|pa>>4;na=(pa&15)<<2|qa>>6;Aa=qa&63;if(isNaN(pa))na=Aa=64;else if(isNaN(qa))Aa=64;W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na); -W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&N.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s); -s(0,true)}catch(ba){f()}}else{var Y=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){T=Y.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=Y.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,Z,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",Z);(Z=da.attr("class"))&&W.attr("class", +W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&N.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s); +s(0,true)}catch(ba){f()}}else{var Y=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){T=Y.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=Y.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,Z,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",Z);(Z=da.attr("class"))&&W.attr("class", "svg_icon "+Z);da.replaceWith(W)}else da.append(W);ia&&setTimeout(function(){W.removeAttr("style")},1)},ka=function(da,W){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,W,true);p[W]=da};g=function(da,W){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var pa=da[0].getElementsByTagName("*"),qa=pa.length;Z.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+W+ma;na="url(#"+na+")";var Aa="url(#"+ma+")";for(ma= -0;ma=0;jQuery.fn.jGraduate=function(c){var n= +0;ma=0;jQuery.fn.jGraduate=function(b){var n= arguments;return this.each(function(){function s(la,ca,ja,M,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},Y);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else Y.appendChild(ea);if(ja===null)ja=1;R=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)"},qb);var Ga= -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},qb);$(Ga).mousedown(function(Pa){b(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")|| +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},qb);$(Ga).mousedown(function(Pa){c(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")|| 1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+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(Ua){db=Ua.val("hex")?"#"+Ua.val("hex"):"none";Ya=Ua.val("a")!==null?Ua.val("a")/256:1;Pa.setAttribute("fill",db);Pa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color", db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(Y).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity", -db===null?1:db)}Pa.before(ea);return false}});M&&b(Ga);return ea}function b(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform", +db===null?1:db)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform", la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var M=0;$(Y).find("stop").each(function(){var R=this.getAttribute("offset"), -ea=$(this);if(R
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var V=$(J+"> .jGraduate_colPick"),N=$(J+"> .jGraduate_gradPick");N.html('

    '+B.window.pickerTitle+'

  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var V=$(K+"> .jGraduate_colPick"),N=$(K+"> .jGraduate_gradPick");N.html('

    '+B.window.pickerTitle+'


    ');var ia=256,oa=ia-0,fa=ia-0,ba,Y,sa,ka={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],W=a("svg",{id:o+"_jgraduate_svg",width:ia,height:ia,xmlns:p.svg},da);ba=ba||q.paint.type;var Z=Y=q.paint[ba],pa=q.paint.alpha,qa=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!qa){Y.id=o+"_lg_jgraduate_grad"; -Z=Y=W.appendChild(Y)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!qa){Y.id=o+"_rg_jgraduate_grad";Z=Y=W.appendChild(Y)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(qa){Z=Y=$("#"+o+"_lg_jgraduate_grad")[0];K=q.paint[ba];s(0,"#"+K,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+K,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){K.substr(na,2);var Aa=(255-parseInt(K.substr(na,2),16)).toString(16); -if(Aa.length<2)Aa=0+Aa;ma+=Aa}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||"#"+K,"opac"in B.newstop?B.newstop.opac:1)}K=parseFloat(Z.getAttribute("x1")||0);ma=parseFloat(Z.getAttribute("y1")||0);na=parseFloat(Z.getAttribute("x2")||1);Aa=parseFloat(Z.getAttribute("y2")||0);var Fa=parseFloat(Z.getAttribute("cx")||0.5),Ia=parseFloat(Z.getAttribute("cy")||0.5),Ca=parseFloat(Z.getAttribute("fx")||Fa),Ka=parseFloat(Z.getAttribute("fy")|| -Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:oa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":pa/100},W);var Na=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:K*ia}).data("coord","start").appendTo(da),za=Na.clone().text(2).css({top:Aa*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa* -ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(J+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=Y.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"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> +Z=Y=W.appendChild(Y)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!qa){Y.id=o+"_rg_jgraduate_grad";Z=Y=W.appendChild(Y)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(qa){Z=Y=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){J.substr(na,2);var Aa=(255-parseInt(J.substr(na,2),16)).toString(16); +if(Aa.length<2)Aa=0+Aa;ma+=Aa}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||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(Z.getAttribute("x1")||0);ma=parseFloat(Z.getAttribute("y1")||0);na=parseFloat(Z.getAttribute("x2")||1);Aa=parseFloat(Z.getAttribute("y2")||0);var Fa=parseFloat(Z.getAttribute("cx")||0.5),Ia=parseFloat(Z.getAttribute("cy")||0.5),Ca=parseFloat(Z.getAttribute("fx")||Fa),Ka=parseFloat(Z.getAttribute("fy")|| +Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:oa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":pa/100},W);var Na=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:J*ia}).data("coord","start").appendTo(da),za=Na.clone().text(2).css({top:Aa*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa* +ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=Y.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"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"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")Y.setAttribute(ca,this.value);var R=M?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:za,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16, height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Da)});qb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb= N.find(".jGraduate_spreadMethod").change(function(){Y.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/oa;ja=ja/fa;var M=Za.data("coord"),R=Y;switch(M){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca); @@ -49,56 +49,56 @@ o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr 1)N=Math.round((1-ta.d)*100)}}}N={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(Y.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:N},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:pa}};$.each(N,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(M){var R= ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&Y.setAttribute("r",M/100);R=Math.pow(M/100,0.4)/2*145;break;case "opacity":q.paint.alpha=M;sa.setAttribute("fill-opacity",M/100);R=M*1.45;break;case "ellip":fb=La=1;if(M===0){R=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else fb=-(M/100)-1;R=145*((M+100)/ 2)/100;ea&&d();break;case "angle":Va=M;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.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;Y.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break; -case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(N=(q.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];K=q.paint.solidColor=="none"?"":q.paint.solidColor+N;qa||(K=wa[0].getAttribute("stop-color")); -$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:K,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;T()},null,function(){O()});var wb=$(J+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.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(Y!==ca){var ja= -$(Y).find("stop");$(ca).empty().append(ja);Y=ca;ca=sb.val();Y.setAttribute("spreadMethod",ca)}jb=la==="rg"&&Y.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(J+" .jGraduate_gradPick").hide();$(J+" .jGraduate_colPick").show()}});$(J+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(J+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb= -$(J+" .jGraduate_tab_radgrad");break;default:Bb=$(J+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.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 n=$(this),s=$(n).offset(),b=$("#"+g.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2|| -g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.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();l=a.height()-b.height();if(B>d-15)B=d-15; -if(o>l-30)o=l-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})});$(n).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(","),n=0;n=0,s=p.indexOf("Gecko/")>=0,b=p.indexOf("MSIE")>=0,f=p.indexOf("Chrome/")>=0,d=p.indexOf("Windows")>=0,l=p.indexOf("Macintosh")>= -0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,J=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(oa,0);return true}catch(ba){}return false}(),T=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(oa, -0);return true}catch(ba){}return false}(),O=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);fa.setAttribute("x",5);oa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(oa);return fa===0}(),K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg", +case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(N=(q.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+N;qa||(J=wa[0].getAttribute("stop-color")); +$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,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;T()},null,function(){O()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current"); +$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .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(Y!==ca){var ja= +$(Y).find("stop");$(ca).empty().append(ja);Y=ca;ca=sb.val();Y.setAttribute("spreadMethod",ca)}jb=la==="rg"&&Y.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb= +$(K+" .jGraduate_tab_radgrad");break;default:Bb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.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,b){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),c=$("#"+g.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2|| +g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.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()-c.width();l=a.height()-c.height();if(B>d-15)B=d-15; +if(o>l-30)o=l-30;if(svgedit.browser.isTouch())o-=c.height()/2;p.unbind("click");c.css({top:o,left:B}).fadeIn(g.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover"); +break;case 40:if(c.find("LI.hover").length==0)c.find("LI:first").addClass("hover");else{c.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:first").addClass("hover")}break;case 13:c.find("LI.hover A").trigger("click");break;case 27:p.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){p.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1), +$(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");c.fadeOut(g.outSpeed);return false})},0)};if($.browser.mozilla)$("#"+g.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+g.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+g.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})});$(n).add($("UL.contextMenu")).bind("contextmenu", +function(){return false})});return $(this)},disableContextMenuItems:function(g){if(g==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(g!=undefined)for(var b=g.split(","),n=0;n=0,s=p.indexOf("Gecko/")>=0,c=p.indexOf("MSIE")>=0,f=p.indexOf("Chrome/")>=0,d=p.indexOf("Windows")>=0,l=p.indexOf("Macintosh")>= +0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(oa,0);return true}catch(ba){}return false}(),T=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(oa, +0);return true}catch(ba){}return false}(),O=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);fa.setAttribute("x",5);oa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(oa);return fa===0}(),J=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(oa);return fa.height>4&&fa.height<5}(),Q=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.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 Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(fa);Y.appendChild(ba);oa.appendChild(Y);fa=Y.getBBox();document.documentElement.removeChild(oa);return fa.width==15}(),V=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the latest version in which the problems have been fixed."); -return oa}(),N=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("style","vector-effect:non-scaling-stroke");return oa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();oa.appendItem(fa);return oa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return n};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 q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return J};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return K}; -svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return V};svgedit.browser.supportsNonScalingStroke=function(){return N};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 n=0;n=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,n){var s=null;if(n>=0)if(n=0){this._removeFromOtherLists(c);s=this._xforms[n]=c;this._list._update()}return s};this.removeItem=function(c){if(c=0){for(var n=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,n,s){var b={x:p,y:g},f={x:p+c,y:g};c={x:p+c,y:g+n};p={x:p,y:g+n};g=svgedit.math.transformPoint;b=g(b.x,b.y,s);var d=n=b.x,l=b.y,q=b.y;f=g(f.x,f.y,s);n=Math.min(n,f.x);d=Math.max(d,f.x); -l=Math.min(l,f.y);q=Math.max(q,f.y);p=g(p.x,p.y,s);n=Math.min(n,p.x);d=Math.max(d,p.x);l=Math.min(l,p.y);q=Math.max(q,p.y);c=g(c.x,c.y,s);n=Math.min(n,c.x);d=Math.max(d,c.x);l=Math.min(l,c.y);q=Math.max(q,c.y);return{tl:b,tr:f,bl:p,br:c,aabox:{x:n,y:l,width:d-n,height:q-l}}};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 n=c;c=g; -g=n}n=a.createSVGMatrix();for(g=g;g<=c;++g){var s=g>=0&&g=0)return this._xforms[b];throw{code:1};};this.insertItemBefore=function(b,n){var s=null;if(n>=0)if(n=0){this._removeFromOtherLists(b);s=this._xforms[n]=b;this._list._update()}return s};this.removeItem=function(b){if(b=0){for(var n=this._xforms[b],s=Array(this.numberOfItems- +1),c=0;c1;)b=p[g-1].multiply(b);if(Math.abs(b.a)<1.0E-14)b.a=0;if(Math.abs(b.b)<1.0E-14)b.b=0;if(Math.abs(b.c)<1.0E-14)b.c=0;if(Math.abs(b.d)< +1.0E-14)b.d=0;if(Math.abs(b.e)<1.0E-14)b.e=0;if(Math.abs(b.f)<1.0E-14)b.f=0;return b};svgedit.math.hasMatrixTransform=function(p){if(!p)return false;for(var g=p.numberOfItems;g--;){var b=p.getItem(g);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(p,g,b,n,s){var c={x:p,y:g},f={x:p+b,y:g};b={x:p+b,y:g+n};p={x:p,y:g+n};g=svgedit.math.transformPoint;c=g(c.x,c.y,s);var d=n=c.x,l=c.y,q=c.y;f=g(f.x,f.y,s);n=Math.min(n,f.x);d=Math.max(d,f.x); +l=Math.min(l,f.y);q=Math.max(q,f.y);p=g(p.x,p.y,s);n=Math.min(n,p.x);d=Math.max(d,p.x);l=Math.min(l,p.y);q=Math.max(q,p.y);b=g(b.x,b.y,s);n=Math.min(n,b.x);d=Math.max(d,b.x);l=Math.min(l,b.y);q=Math.max(q,b.y);return{tl:c,tr:f,bl:p,br:b,aabox:{x:n,y:l,width:d-n,height:q-l}}};svgedit.math.transformListToTransform=function(p,g,b){if(p==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());g=g==undefined?0:g;b=b==undefined?p.numberOfItems-1:b;g=parseInt(g);b=parseInt(b);if(g>b){var n=b;b=g; +g=n}n=a.createSVGMatrix();for(g=g;g<=b;++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,n={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;n.em=f.width;n.ex=f.height;n["in"]=b;n.cm=b/2.54;n.mm=b/25.4;n.pt=b/72;n.pc=b/6;n["%"]=0};svgedit.units.getTypeMap=function(){return n};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/n[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,q=0;q=0?d*l:p.indexOf(b)>=0?d*q:d*Math.sqrt(l*l+q*q)/Math.sqrt(2)}else{l=f.substr(-2);d=f.substr(0,f.length-2);return d*n[l]}};svgedit.units.isValidUnit=function(b,f,d){var l=false;if(g.indexOf(b)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(n,function(o){if(!l)if(RegExp("^-?[\\d\\.]+"+o+"$").test(f))l=true})}else l=true;else if(b=="id"){b=false;try{var q=c.getElement(f); -b=q==null||q===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 q=$(d).children().clone().attr("visibility","hidden");$(s).append(q);l=q.filter("line, path")}else l=$(b).find("line, path");var B=false;if(l.length){l.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,n=null,s=null;svgedit.utilities.init=function(b){g=b;c=b.getDOMDocument();n=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,q,B,o,J,T=0,O=0;do{d=b.charCodeAt(T++);l=b.charCodeAt(T++);q=b.charCodeAt(T++);B=d>>2;d=(d&3)<<4|l>>4;o=(l&15)<<2|q>>6;J=q&63;if(isNaN(l))o=J=64;else if(isNaN(q))J=64;f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(o);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(J)}while(T< -b.length);return f.join("")};svgedit.utilities.decode64=function(b){if(window.atob)return window.atob(b);var f="",d,l,q="",B,o="",J=0;b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(J++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(J++));B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(J++));o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(J++)); -d=d<<2|l>>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+=String.fromCharCode(l);if(o!=64)f+=String.fromCharCode(q)}while(J127)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(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 l=f.getItem(0), -q=[l.x,l.y];for(l=0;l=0?d*l:p.indexOf(c)>=0?d*q:d*Math.sqrt(l*l+q*q)/Math.sqrt(2)}else{l=f.substr(-2);d=f.substr(0,f.length-2);return d*n[l]}};svgedit.units.isValidUnit=function(c,f,d){var l=false;if(g.indexOf(c)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(n,function(o){if(!l)if(RegExp("^-?[\\d\\.]+"+o+"$").test(f))l=true})}else l=true;else if(c=="id"){c=false;try{var q=b.getElement(f); +c=q==null||q===d}catch(B){}return c}else l=true;return l}})();svgedit=svgedit||{}; +(function(){function a(c){if(svgedit.browser.supportsHVLineContainerBBox())try{return c.getBBox()}catch(f){}var d=$.data(c,"ref"),l=null;if(d){var q=$(d).children().clone().attr("visibility","hidden");$(s).append(q);l=q.filter("line, path")}else l=$(c).find("line, path");var B=false;if(l.length){l.each(function(){var o=this.getBBox();if(!o.width||!o.height)B=true});if(B){c=d?q:$(c).children();ret=getStrokedBBox(c)}else ret=c.getBBox()}else ret=c.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,b=null,n=null,s=null;svgedit.utilities.init=function(c){g=c;b=c.getDOMDocument();n=c.getDOMContainer();s=c.getSVGRoot()};svgedit.utilities.toXml=function(c){return $("

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

    ").html(c).text()};svgedit.utilities.encode64=function(c){c=svgedit.utilities.convertToXMLReferences(c);if(window.btoa)return window.btoa(c); +var f=Array(Math.floor((c.length+2)/3)*4),d,l,q,B,o,K,T=0,O=0;do{d=c.charCodeAt(T++);l=c.charCodeAt(T++);q=c.charCodeAt(T++);B=d>>2;d=(d&3)<<4|l>>4;o=(l&15)<<2|q>>6;K=q&63;if(isNaN(l))o=K=64;else if(isNaN(q))K=64;f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(o);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(K)}while(T< +c.length);return f.join("")};svgedit.utilities.decode64=function(c){if(window.atob)return window.atob(c);var f="",d,l,q="",B,o="",K=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++)); +d=d<<2|l>>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+=String.fromCharCode(l);if(o!=64)f+=String.fromCharCode(q)}while(K127)f+="&#"+l+";"}return f};svgedit.utilities.text2xml=function(c){if(c.indexOf("=0)c=c.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var f;try{var d=window.DOMParser? +new DOMParser:new ActiveXObject("Microsoft.XMLDOM");d.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{f=d.loadXML?d.loadXML(c)?d:false:d.parseFromString(c,"text/xml")}catch(q){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(c){return{x:c.x,y:c.y,width:c.width,height:c.height}};svgedit.utilities.walkTree=function(c,f){if(c&&c.nodeType==1){f(c);for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),f)}}; +svgedit.utilities.walkTreePost=function(c,f){if(c&&c.nodeType==1){for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),f);f(c)}};svgedit.utilities.getUrlFromAttr=function(c){if(c)if(c.indexOf('url("')===0)return c.substring(5,c.indexOf('"',6));else if(c.indexOf("url('")===0)return c.substring(5,c.indexOf("'",6));else if(c.indexOf("url(")===0)return c.substring(4,c.indexOf(")"));return null};svgedit.utilities.getHref=function(c){return c.getAttributeNS("http://www.w3.org/1999/xlink", +"href")};svgedit.utilities.setHref=function(c,f){c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(c){c=g.getSVGContent().documentElement;var f=c.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:c.insertBefore(c.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),c.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(c){var f=c.pathSegList,d=f.numberOfItems;c=[[],[]];var l=f.getItem(0), +q=[l.x,l.y];for(l=0;l= -0){var l=d.split(":");b[l[1]]=p[l[0]]}else b[d]=d=="xmlns"?"http://www.w3.org/2000/xmlns/":null});c[n]=b});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(n){if(n.nodeType==3){n.nodeValue=n.nodeValue.replace(/^\s+|\s+$/g,"");n.nodeValue.length||n.parentNode.removeChild(n)}if(n.nodeType==1){var s=n.parentNode;if(n.ownerDocument&&s){var b=g[n.nodeName],f=c[n.nodeName];if(b!=undefined){for(var d=[],l=n.attributes.length;l--;){var q=n.attributes.item(l),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]);n.removeAttributeNS(J,o)}if(svgedit.browser.isGecko())switch(B){case "transform":case "gradientTransform":case "patternTransform":o=q.nodeValue.replace(/(\d)-/g,"$1 -");n.setAttribute(B,o)}if(B=="style"){q=q.nodeValue.split(";");for(B=q.length;B--;){o=q[B].split(":");b.indexOf(o[0])>=0&&n.setAttribute(o[0], +"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},b={};$.each(g,function(n,s){var c={};$.each(s,function(f,d){if(d.indexOf(":")>= +0){var l=d.split(":");c[l[1]]=p[l[0]]}else c[d]=d=="xmlns"?"http://www.w3.org/2000/xmlns/":null});b[n]=c});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(n){if(n.nodeType==3){n.nodeValue=n.nodeValue.replace(/^\s+|\s+$/g,"");n.nodeValue.length||n.parentNode.removeChild(n)}if(n.nodeType==1){var s=n.parentNode;if(n.ownerDocument&&s){var c=g[n.nodeName],f=b[n.nodeName];if(c!=undefined){for(var d=[],l=n.attributes.length;l--;){var q=n.attributes.item(l),B=q.nodeName, +o=q.localName,K=q.namespaceURI;if(!(f.hasOwnProperty(o)&&K==f[o]&&K!="http://www.w3.org/2000/xmlns/")&&!(K=="http://www.w3.org/2000/xmlns/"&&a[q.nodeValue])){B.indexOf("se:")==0&&d.push([B,q.nodeValue]);n.removeAttributeNS(K,o)}if(svgedit.browser.isGecko())switch(B){case "transform":case "gradientTransform":case "patternTransform":o=q.nodeValue.replace(/(\d)-/g,"$1 -");n.setAttribute(B,o)}if(B=="style"){q=q.nodeValue.split(";");for(B=q.length;B--;){o=q[B].split(":");c.indexOf(o[0])>=0&&n.setAttribute(o[0], o[1])}n.removeAttribute("style")}}$.each(d,function(T,O){n.setAttributeNS("http://svg-edit.googlecode.com",O[0],O[1])});if((l=svgedit.utilities.getHref(n))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(n.nodeName)>=0)if(l[0]!="#"){svgedit.utilities.setHref(n,"");n.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(n.nodeName=="use"&&!svgedit.utilities.getHref(n))s.removeChild(n);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start", -"mask","stroke"],function(T,O){var K=n.getAttribute(O);if(K)if((K=svgedit.utilities.getUrlFromAttr(K))&&K[0]!=="#"){n.setAttribute(O,"");n.removeAttribute(O)}});for(l=n.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(n.childNodes.item(l))}}else{for(b=[];n.hasChildNodes();)b.push(s.insertBefore(n.firstChild,n));s.removeChild(n);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,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= +"mask","stroke"],function(T,O){var J=n.getAttribute(O);if(J)if((J=svgedit.utilities.getUrlFromAttr(J))&&J[0]!=="#"){n.setAttribute(O,"");n.removeAttribute(O)}});for(l=n.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(n.childNodes.item(l))}}else{for(c=[];n.hasChildNodes();)c.push(s.insertBefore(n.firstChild,n));s.removeChild(n);for(l=c.length;l--;)svgedit.sanitize.sanitizeSvg(c[l])}}}}})();svgedit=svgedit||{}; +(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,p,g,b){this.elem=a;this.text=b?"Move "+a.tagName+" to "+b:"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"}; +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,b){this.elem=a;this.text=b||"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= +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 b in p)this.newValues[b]=b=="#text"?a.textContent:b=="#href"?svgedit.utilities.getHref(a):a.getAttribute(b)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText= function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var p=false,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= +this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],p=this.stack.length;p--;)for(var g=this.stack[p].elements(),b=g.length;b--;)a.indexOf(g[b])==-1&&a.push(g[b]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer= -1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText(): ""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}; -svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,p){for(var g=++this.undoChangeStackPointer,c=p.length,n=Array(c),s=Array(c);c--;){var b=p[c];if(b!=null){s[c]=b;n[c]=b.getAttribute(a)}}this.undoableChangeStack[g]= -{attrName:a,oldValues:n,elements:s}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,p=this.undoableChangeStack[a],g=p.elements.length,c=p.attrName,n=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)&&n.addSubCommand(new svgedit.history.ChangeElementCommand(s,b,c))}}this.undoableChangeStack[a]=null;return n}})();svgedit=svgedit||{}; -(function(){if(!svgedit.select)svgedit.select={};var a,p,g;svgedit.select.Selector=function(c,n){this.id=c;this.selectedElement=n;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));svgedit.browser.isTouch()&&this.selectorRect.setAttribute("stroke-opacity", -0.3);this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(c){this.locked=true;this.selectedElement=c;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(c){var n=[];c=Math.round(c/45);if(c<0)c+=8;for(var s in g.selectorGrips)n.push(s);for(;c>0;){n.push(n.shift());c--}c=0;for(s in g.selectorGrips){g.selectorGrips[s].setAttribute("style", -"cursor:"+n[c]+"-resize");c++}};svgedit.select.Selector.prototype.showGrips=function(c){g.selectorGripsGroup.setAttribute("display",c?"inline":"none");var n=this.selectedElement;this.hasGrips=c;if(n&&c){this.selectorGroup.appendChild(g.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(n))}};svgedit.select.Selector.prototype.resize=function(){var c=this.selectorRect,n=g,s=n.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 q=b.tagName;if(q==="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(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;l*=d;d=svgedit.math.transformBox(q*d,o*d,J*d,B*d,f);f=d.aabox;q=f.x-l;o=f.y-l;J=f.width+l*2;var T=f.height+l*2;f=q+J/2;B=o+T/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;T=q.y;var O=q.x,K=q.y;q=Math.min;o=Math.max;J=q(J,q(d.tr.x,q(d.bl.x,d.br.x)))-l;T=q(T,q(d.tr.y,q(d.bl.y,d.br.y)))-l;O=o(O,o(d.tr.x,o(d.bl.x,d.br.x)))+l;K=o(K,o(d.tr.y,o(d.bl.y,d.br.y)))+l;q=J;o=T;J=O-J;T=K-T}l=a.svgRoot().suspendRedraw(100);c.setAttribute("d", -"M"+q+","+o+" L"+(q+J)+","+o+" "+(q+J)+","+(o+T)+" "+q+","+(o+T)+"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+T].map(Math.round),se:[q+J,o+T].map(Math.round),n:[q+J/2,o].map(Math.round),w:[q,o+T/2].map(Math.round),e:[q+J,o+T/2].map(Math.round),s:[q+J/2,o+T].map(Math.round)};for(var Q in this.gripCoords){c=this.gripCoords[Q]; -s[Q].setAttribute("x",c[0]);s[Q].setAttribute("y",c[1])}this.rotateCoords={nw:[q,o],ne:[q+J+8,o],sw:[q,o+T+8],se:[q+J+8,o+T+8]};for(Q in this.rotateCoords){c=this.rotateCoords[Q];n.rotateGrips[Q].setAttribute("cx",c[0]);n.rotateGrips[Q].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}; +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,b=p.length,n=Array(b),s=Array(b);b--;){var c=p[b];if(c!=null){s[b]=c;n[b]=c.getAttribute(a)}}this.undoableChangeStack[g]= +{attrName:a,oldValues:n,elements:s}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,p=this.undoableChangeStack[a],g=p.elements.length,b=p.attrName,n=new svgedit.history.BatchCommand("Change "+b);g--;){var s=p.elements[g];if(s!=null){var c={};c[b]=p.oldValues[g];c[b]!=s.getAttribute(b)&&n.addSubCommand(new svgedit.history.ChangeElementCommand(s,c,b))}}this.undoableChangeStack[a]=null;return n}})();svgedit=svgedit||{}; +(function(){if(!svgedit.select)svgedit.select={};var a,p,g;svgedit.select.Selector=function(b,n){this.id=b;this.selectedElement=n;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));svgedit.browser.isTouch()&&this.selectorRect.setAttribute("stroke-opacity", +0.3);this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(b){this.locked=true;this.selectedElement=b;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(b){var n=[];b=Math.round(b/45);if(b<0)b+=8;for(var s in g.selectorGrips)n.push(s);for(;b>0;){n.push(n.shift());b--}b=0;for(s in g.selectorGrips){g.selectorGrips[s].setAttribute("style", +"cursor:"+n[b]+"-resize");b++}};svgedit.select.Selector.prototype.showGrips=function(b){g.selectorGripsGroup.setAttribute("display",b?"inline":"none");var n=this.selectedElement;this.hasGrips=b;if(n&&b){this.selectorGroup.appendChild(g.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(n))}};svgedit.select.Selector.prototype.resize=function(){var b=this.selectorRect,n=g,s=n.selectorGrips,c=this.selectedElement,f=c.getAttribute("stroke-width"),d=a.currentZoom(),l=1/d;if(c.getAttribute("stroke")!== +"none"&&!isNaN(f))l+=f/2;var q=c.tagName;if(q==="text")l+=2/d;f=svgedit.transformlist.getTransformList(c);f=svgedit.math.transformListToTransform(f).matrix;f.e*=d;f.f*=d;var B=svgedit.utilities.getBBox(c);if(q==="g"&&!$.data(c,"gsvg"))if(q=a.getStrokedBBox(c.childNodes))B=q;q=B.x;var o=B.y,K=B.width;B=B.height;l*=d;d=svgedit.math.transformBox(q*d,o*d,K*d,B*d,f);f=d.aabox;q=f.x-l;o=f.y-l;K=f.width+l*2;var T=f.height+l*2;f=q+K/2;B=o+T/2;if(c=svgedit.utilities.getRotationAngle(c)){q=a.svgRoot().createSVGTransform(); +q.setRotate(-c,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;K=q.x;T=q.y;var O=q.x,J=q.y;q=Math.min;o=Math.max;K=q(K,q(d.tr.x,q(d.bl.x,d.br.x)))-l;T=q(T,q(d.tr.y,q(d.bl.y,d.br.y)))-l;O=o(O,o(d.tr.x,o(d.bl.x,d.br.x)))+l;J=o(J,o(d.tr.y,o(d.bl.y,d.br.y)))+l;q=K;o=T;K=O-K;T=J-T}l=a.svgRoot().suspendRedraw(100);b.setAttribute("d", +"M"+q+","+o+" L"+(q+K)+","+o+" "+(q+K)+","+(o+T)+" "+q+","+(o+T)+"z");this.selectorGroup.setAttribute("transform",c?"rotate("+[c,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+K,o].map(Math.round),sw:[q,o+T].map(Math.round),se:[q+K,o+T].map(Math.round),n:[q+K/2,o].map(Math.round),w:[q,o+T/2].map(Math.round),e:[q+K,o+T/2].map(Math.round),s:[q+K/2,o+T].map(Math.round)};for(var Q in this.gripCoords){b=this.gripCoords[Q]; +s[Q].setAttribute("x",b[0]);s[Q].setAttribute("y",b[1])}this.rotateCoords={nw:[q,o],ne:[q+K+8,o],sw:[q,o+T+8],se:[q+K+8,o+T+8]};for(Q in this.rotateCoords){b=this.rotateCoords[Q];n.rotateGrips[Q].setAttribute("cx",b[0]);n.rotateGrips[Q].setAttribute("cy",b[1])}a.svgRoot().unsuspendRedraw(l)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null}; this.selectorGripsGroup=null;this.rotateGrips={nw:null,ne:null,se:null,sw:null};this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup); -a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var c in this.rotateGrips){var n=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(n,"dir",c);$.data(n,"type","rotate");this.rotateGrips[c]=this.selectorGripsGroup.appendChild(n)}for(c in this.selectorGrips){n=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()){n.setAttribute("width",30.5);n.setAttribute("height",30.5);n.setAttribute("fill-opacity",0.3)}$.data(n,"dir",c);$.data(n,"type","resize");this.selectorGrips[c]=this.selectorGripsGroup.appendChild(n)}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"}});n=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"}}),l=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"url(#checkerPattern)",style:"pointer-events:none"}});c.appendChild(n);n.appendChild(s);s.appendChild(b);s.appendChild(f);s.appendChild(d);c.appendChild(l);a.svgRoot().insertBefore(c,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(c){if(c==null)return null;var n=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=n||"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,n=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();n=true}else this.obj_num++;for(var s=this.getId();this.getElem_(s);){if(n){this.obj_num=c;n=false}this.obj_num++;s=this.getId()}if(n)this.obj_num=c;return s};svgedit.draw.Drawing.prototype.releaseId=function(c){var n=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof c!="string"||c.indexOf(n)!=0)return false;c=parseInt(c.substr(n.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 n=0;n=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,n=[],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;s element";this.svgElem_=b;this.obj_num=0;this.idPrefix=n||"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(b){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+b):$(this.svgElem_).find("[id="+b+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_}; +svgedit.draw.Drawing.prototype.setNonce=function(b){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",b);this.nonce_=b};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var b= +this.obj_num,n=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();n=true}else this.obj_num++;for(var s=this.getId();this.getElem_(s);){if(n){this.obj_num=b;n=false}this.obj_num++;s=this.getId()}if(n)this.obj_num=b;return s};svgedit.draw.Drawing.prototype.releaseId=function(b){var n=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof b!="string"||b.indexOf(n)!=0)return false;b=parseInt(b.substr(n.length));if(typeof b!="number"||b<=0||this.releasedNums.indexOf(b)!=-1)return false; +this.releasedNums.push(b);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(b){for(var n=0;n=0&&b1){var b=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return b}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var b=this.svgElem_.childNodes.length,n=[],s=[],c=null,f=false,d=0;d0||!f){for(d=1;s.indexOf("Layer "+d)>=0;)d++;s="Layer "+d;c=b.createElementNS("http://www.w3.org/2000/svg","g");f=b.createElementNS("http://www.w3.org/2000/svg","title");f.textContent=s; +c.appendChild(f);for(f=0;f1))for(var s=0;s0){f=T0){f=T 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],J=l-1<0?null:f[l-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=l}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,l=0;l=d?null:f[l+1],K=l-1<0?null:f[l-1];if(B.type===2){if(K&&K.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=l}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,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:n.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 q="svg_";b.setIdPrefix= -function(e){q=e};b.current_drawing_=new svgedit.draw.Drawing(l,q);var B=b.getCurrentDrawing=function(){return b.current_drawing_},o=1,J=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text, -{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=T.shape,K=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(c,e.element);if(m)(J||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin, -"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},V=b.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ia=b.matrixMultiply=svgedit.math.matrixMultiply,oa=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=b.transformListToTransform=svgedit.math.transformListToTransform, -ba=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=b.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return K}, -getSVGContent:function(){return l}});var ka=b.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=b.getHref=svgedit.utilities.getHref,W=b.setHref=svgedit.utilities.setHref,Z=svgedit.utilities.getPathBBox;b.getBBox=svgedit.utilities.getBBox;var pa=b.getRotationAngle=svgedit.utilities.getRotationAngle,qa=b.getElem=svgedit.utilities.getElem,ma=b.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,Aa=svgedit.sanitize.getNSMap(),Fa=b.sanitizeSvg=svgedit.sanitize.sanitizeSvg, -Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,za=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)b.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();b.pathActions.clear();M("changed",z);z=h.type();m=e==m.AFTER_APPLY;if(z== -Ia.type()){m=m?h.newParent:h.oldParent;m==l&&b.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&b.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m= -z.parentNode;var w=z.nextSibling;m.removeChild(z);m.insertBefore(z,w)}}}}}});var ya=function(e){b.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return b.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(e){return b.getStrokedBBox([e])}});var Ha=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return d}}); +H=H.cloneNode(true);$(H).attr(F);H.id=ja();lb().appendChild(H);e.setAttribute(w,"url(#"+H.id+")")}}}}var b="http://www.w3.org/2000/svg",n={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};p&&$.extend(n,p);var s=n.dimensions,c=this,f=a.ownerDocument,d=f.importNode(svgedit.utilities.text2xml('').documentElement, +true);a.appendChild(d);var l=f.createElementNS(b,"svg");(c.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:n.show_outside_canvas?"visible":"hidden",xmlns:b,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(d);var e=f.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var q="svg_";c.setIdPrefix= +function(e){q=e};c.current_drawing_=new svgedit.draw.Drawing(l,q);var B=c.getCurrentDrawing=function(){return c.current_drawing_},o=1,K=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text, +{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=T.shape,J=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(b,e.element);if(m)(K||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin, +"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},V=c.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ia=c.matrixMultiply=svgedit.math.matrixMultiply,oa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=c.transformListToTransform=svgedit.math.transformListToTransform, +ba=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J}, +getSVGContent:function(){return l}});var ka=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,W=c.setHref=svgedit.utilities.setHref,Z=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var pa=c.getRotationAngle=svgedit.utilities.getRotationAngle,qa=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,Aa=svgedit.sanitize.getNSMap(),Fa=c.sanitizeSvg=svgedit.sanitize.sanitizeSvg, +Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,za=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)c.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();c.pathActions.clear();M("changed",z);z=h.type();m=e==m.AFTER_APPLY;if(z== +Ia.type()){m=m?h.newParent:h.oldParent;m==l&&c.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&c.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&c.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m= +z.parentNode;var w=z.nextSibling;m.removeChild(z);m.insertBefore(z,w)}}}}}});var ya=function(e){c.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return c.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(e){return c.getStrokedBBox([e])}});var Ha=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return d}}); svgedit.utilities.snapToGrid=function(e){var h=n.snappingStep,m=n.baseUnit;if(m!=="px")h*=svgedit.units.getTypeMap()[m];return e=Math.round(e/h)*h};var wa=svgedit.utilities.snapToGrid,qb={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"],ib=$.data, -Wa=function(e){var h=$(e).attr($a),m;for(m in h){var z=h[m];if(z&&z.indexOf("url(")===0){z=ka(z).substr(1);if(!qa(z)){lb().appendChild(Ab[z]);delete Ab[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(m=e.length;h=0)E=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)E=G=b.convertToPath(I,true)}if(!G){var v=I.cloneNode(true),C=document.createElementNS(c,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(v);E=svgedit.utilities.bboxToObj(C.getBBox());D.removeChild(C)}}return E}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)}); +false;if(["ellipse","path","line","polyline","polygon"].indexOf(I.tagName)>=0)E=G=c.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)E=G=c.convertToPath(I,true)}if(!G){var v=I.cloneNode(true),C=document.createElementNS(b,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(v);E=svgedit.utilities.bboxToObj(C.getBBox());D.removeChild(C)}}return E}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)}); if(m==null)return null;var z=m.x+m.width,w=m.y+m.height,H=m.x,A=m.y,u=function(I){var E=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(E))G+=E/2;return G},F=[];$.each(e,function(I,E){var G=h(E);if(G){var L=u(E);H=Math.min(H,G.x-L);A=Math.min(A,G.y-L);F.push(G)}});m.x=H;m.y=A;$.each(e,function(I,E){var G=F[I];if(G&&E.nodeType==1){var L=u(E);z=Math.max(z,G.x+G.width+L);w=Math.max(w,G.y+G.height+L)}});m.width=z-H;m.height=w-A;return m};var ub=this.getVisibleElements=function(e){e|| -(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Bb=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg", +(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Bb=this.groupSvgElem=function(e){var h=document.createElementNS(b,"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,w){w.localName!="-moz-math-font-style"&&h.setAttributeNS(w.namespaceURI,w.nodeName,w.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=Ja.convertPath(e);h.setAttribute("d",m)}$.each(e.childNodes,function(z,w){switch(w.nodeType){case 1:h.appendChild(la(w));break;case 3:h.textContent=w.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"&&pb(h);h.id=ja();return h},ca,ja,M;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};M=e.call=function(m,z){if(h[m])return h[m](this,z)};e.bind=function(m,z){var w=h[m];h[m]=z;return w}})(b);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(c,"path");for(var h=0,m=e.length;h -0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=N(H,A,fa(w).matrix);A=d.createSVGTransform();A.setRotate(e,H.x,H.y);w.numberOfItems?w.insertItemBefore(A,0):w.appendItem(A)}else w.numberOfItems==0&&m.removeAttribute("transform");if(!h){w=m.getAttribute("transform");m.setAttribute("transform",z);gb("transform",w,K);M("changed",K)}qa("pathpointgrip_container");m=Ha.requestSelector(K[0]);m.resize();m.updateGripCursors(e)};var Ga=this.recalculateAllSelectedDimensions=function(){for(var e=new za(kb== -"none"?"position":"size"),h=K.length;h--;){var m=Ua(K[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);M("changed",K)}},Pa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke", +else if($(e).data("symbol")){e=$(e).data("symbol");$(h).data("ref",e).data("symbol",e)}else h.tagName=="image"&&pb(h);h.id=ja();return h},ca,ja,M;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};M=e.call=function(m,z){if(h[m])return h[m](this,z)};e.bind=function(m,z){var w=h[m];h[m]=z;return w}})(c);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(b,"path");for(var h=0,m=e.length;h +0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=N(H,A,fa(w).matrix);A=d.createSVGTransform();A.setRotate(e,H.x,H.y);w.numberOfItems?w.insertItemBefore(A,0):w.appendItem(A)}else w.numberOfItems==0&&m.removeAttribute("transform");if(!h){w=m.getAttribute("transform");m.setAttribute("transform",z);gb("transform",w,J);M("changed",J)}qa("pathpointgrip_container");m=Ha.requestSelector(J[0]);m.resize();m.updateGripCursors(e)};var Ga=this.recalculateAllSelectedDimensions=function(){for(var e=new za(kb== +"none"?"position":"size"),h=J.length;h--;){var m=Ua(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);M("changed",J)}},Pa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke", u=e.getAttribute(A);if(u&&u.indexOf("url(")===0)if(m.a<0||m.d<0){u=R(u).cloneNode(true);if(m.a<0){var F=u.getAttribute("x1"),I=u.getAttribute("x2");u.setAttribute("x1",-(F-1));u.setAttribute("x2",-(I-1))}if(m.d<0){F=u.getAttribute("y1");I=u.getAttribute("y2");u.setAttribute("y1",-(F-1));u.setAttribute("y2",-(I-1))}u.id=ja();lb().appendChild(u);e.setAttribute(A,"url(#"+u.id+")")}}H=e.tagName;if(H==="g"||H==="text"||H==="use")if(m.a==1&&m.b==0&&m.c==0&&m.d==1&&(m.e!=0||m.f!=0)){A=fa(e).matrix;A=ia(A.inverse(), m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=V(e);u=d.createSVGTransform();u.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(u)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=V(e);u=d.createSVGTransform();u.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(u)}else{A=N(h.x,h.y,m);h.width=m.a*h.width;h.height=m.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)}w(); break;case "ellipse":H=N(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;h.rx=m.a*h.rx;h.ry=m.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);w();break;case "circle":H=N(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;H=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);h.r=Math.min((H.tr.x-H.tl.x)/2,(H.bl.y-H.tl.y)/2);if(h.r)h.r=Math.abs(h.r);w();break;case "line":A=N(h.x1,h.y1,m);F=N(h.x2,h.y2,m);h.x1=A.x;h.y1=A.y;h.x2=F.x;h.y2=F.y;case "text":m=e.querySelectorAll("tspan");for(H=m.length;H--;){A=sa("x",e.getAttribute("x")); @@ -231,52 +231,52 @@ $(e).attr(z);$.each(A,function(ha,Ta){A[ha]=sa(ha,Ta)})}else if(H)A={x:$(H).attr h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var v=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=V(U);if(S){z=fa(S).matrix;H=pa(U);var X=Va,aa=[];Va=U.getAttribute("transform");if(H||oa(S)){var ga= d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);aa.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var ra=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(ra);aa.push(Ba);aa.push(Oa);aa.push(ra)}m.addSubCommand(Ua(U));Va=X}}}h.removeItem(k-1);h.removeItem(k- 2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){X=U.getAttribute("clip-path");if(k.indexOf(X)===-1){nb(X,H,z);k.push(X)}}X=Va;Va=U.getAttribute("transform"); -if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=X}}}k=[];Va=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform"); +if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(b,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=X}}}k=[];Va=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform"); if(S=V(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=X;X=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(X)&&U.setAttribute("stroke-width",X*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+v.e,y:G.y+v.f}; G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(w,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform");S=V(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C, 0):S.appendItem(C);m.addSubCommand(Ua(U));Va=X}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=pa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k== 4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;v=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,v,X);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(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){w=e.points;F=w.numberOfItems; A.points=Array(F);for(I=0;I1&&w.showGrips(false)}}}M("selected",K);h||K.length==1?Ha.requestSelector(K[0]).showGrips(true):Ha.requestSelector(K[0]).showGrips(false);for(K.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3- -(A.compareDocumentPosition(H)&6);else if(H==null)return 1});K[0]==null;)K.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(K[0]!=null)if(e.length!=0){var h=Array(K.length);j=0;len=K.length;for(var m=0;m=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(J||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z= +3&&H){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(H,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,u));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m1&&w.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3- +(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m=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 Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z= null,w=null,H={},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;rb=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);u.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(u);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G== -Ha.selectorParentGroup&&K[0]!=null){G=u.target;var v=ib(G,"type");if(v=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(v=="resize"){Ea="resize";kb=ib(G,"dir")}G=K[0]}Va=G.getAttribute("transform");v=V(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(K.indexOf(G)==-1){u.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(u.button=== -1||b.spaceKey)){var F=K[0],I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}u.preventDefault();switch(Ea){case "select":if(K[0]!==null){L=x-h;var v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v)}if(u.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||v!=0){C=K.length;for(k=0;k0&&b.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var X=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=X*Math.cos(v);v=X*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+v)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/ +true;break;case "textedit":h*=o;m*=o;hb.mouseDown(u,G,h,m);La=true;break;case "rotate":La=true;c.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}C=ob("mouseDown",{event:u,start_x:h,start_y:m,selectedElements:J},true);$.each(C,function(P,U){if(U&&U.started)La=true});if(Ea)document.getElementById("workarea").className=Ea=="resize"?u.target.style.cursor:Ea}}).mousemove(function(u){if(!(u.originalEvent.touches&&u.originalEvent.touches.length>1))if(La)if(!(u.button=== +1||c.spaceKey)){var F=J[0],I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}u.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v)}if(u.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||v!=0){C=J.length;for(k=0;k0&&c.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var X=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=X*Math.cos(v);v=X*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+v)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/ U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;X=P}L=d.createSVGTransform();v=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);X=wa(X);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+X),-(k+aa));if(u.shiftKey)if(ra==1)ra=ga;else ga=ra;v.setScale(ra,ga);P.setTranslate(C+X,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(v,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(v,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition", -K);break;case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(u.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea== +J);break;case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(u.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea== "square"||u.shiftKey){L=D=Math.max(L,D);C=hm?m+k:m-k}if(u.altKey){D=h;C=m;k=Math.abs(x-D);v=u.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",v);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);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(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+ k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(u.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L= -svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=Y(F);G=N(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);M("transition",K)}ob("mouseMove", -{event:u,mouse_x:E,mouse_y:I,selected:F})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var F=u.target.parentNode;if(F!==J){var I=Ib(u),E=I.tagName;if(E==="text"&&Ea!=="textedit"){u=N(u.pageX,u.pageY,rb);hb.select(I,u.x,u.y)}if((E==="g"||E==="a")&&pa(I)){Mb(I);I=K[0];Qa(true)}J&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(u){b.addClones=false;window.removeEventListener("keyup",b.removeClones); -if(u.button!==2){var F=Cb;Cb=null;if(La){var I=N(u.pageX,u.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(K[0]!=null){if(K[1]==null){E=K[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity= -E.getAttribute("stroke-opacity");bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){u=K.length;for(E=0;E=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);v=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);v=F.width!=0||F.height!=0||Ea==="image";break;case "circle":v=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);v=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({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()}});M("changed",[k]);v=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);v=true}break;case "text":v=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(u,k,E,I);k=F.element;v=F.keep;break;case "pathedit":v=true;k=null;Ja.mouseUp(u); -break;case "textedit":v=false;k=null;hb.mouseUp(u,E,I);break;case "rotate":v=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",K)}E=ob("mouseUp",{event:u,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){v=U.keep||v;k=U.element;La=U.started||La}});if(!v&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=u.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&& -E.id!="svgcanvas"&&E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;u=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=O.opacity){C=$(false).clone().attr({to:O.opacity,dur:u}).appendTo(k);try{C[0].beginElement()}catch(D){}}else u=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",O.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},u* -1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);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&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var X=I.value=== -"";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];X||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,v.y);aa=H(aa.x,v.y+v.height);ma(E,{x1:X.x,y1:X.y,x2:aa.x, -y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,aa){if(S===X)e(X);else{aa||I.setSelectionRange(S,X);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];E.setAttribute("visibility","hidden");X=H(S.x,v.y);aa=H(S.x+(ga.x-S.x),v.y);var ra=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+ +break;case "textedit":v=false;k=null;hb.mouseUp(u,E,I);break;case "rotate":v=true;k=null;Ea="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:u,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){v=U.keep||v;k=U.element;La=U.started||La}});if(!v&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=u.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&& +E.id!="svgcanvas"&&E.id!="svgroot"){c.setMode("select");xb([E],true)}}else if(k!=null){c.addedNew=true;u=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=O.opacity){C=$(false).clone().attr({to:O.opacity,dur:u}).appendTo(k);try{C[0].beginElement()}catch(D){}}else u=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",O.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},u* +1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);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&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=c.textActions=function(){function e(S){var X=I.value=== +"";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];X||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(b,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,v.y);aa=H(aa.x,v.y+v.height);ma(E,{x1:X.x,y1:X.y,x2:aa.x, +y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,aa){if(S===X)e(X);else{aa||I.setSelectionRange(S,X);G=qa("text_selectblock");if(!G){G=document.createElementNS(b,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];E.setAttribute("visibility","hidden");X=H(S.x,v.y);aa=H(S.x+(ga.x-S.x),v.y);var ra=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+ X.x+","+X.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}function m(S,X){var aa=d.createSVGPoint();aa.x=S;aa.y=X;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,X,aa){var ga=I.selectionStart;S=m(S,X);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,X){var aa={x:S,y:X};aa.x/=o;aa.y/=o;if(C){var ga=N(aa.x,aa.y,C.inverse());aa.x= ga.x;aa.y=ga.y}return aa}function H(S,X){var aa={x:S,y:X};if(C){var ga=N(aa.x,aa.y,C);aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function u(S){if(U&&F){var X=N(S.pageX,S.pageY,rb);X=w(X.x*o,X.y*o);X=m(X.x,X.y);var aa=F.textContent,ga=aa.substr(0,X).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(X).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+X);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L, k=[],v,C,D,P,U;return{select:function(S,X,aa){F=S;hb.toEditMode(X,aa)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,X,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,X){var aa=w(S,X);z(aa.x,aa.y)},mouseUp:function(S,X,aa){var ga=w(X,aa);z(ga.x,ga.y,true);S.target!==F&&XD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa= -w(S,X);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=K[0];Ha.requestSelector(F).showGrips(false)}var S= -F.textContent.length,X=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=X?Y(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var aa={x:v.x+v.width/2,width:0};for(X=0;X=0&&this.selected_pts.push(F)}this.selected_pts.sort();u=this.selected_pts.length; -for(A=Array(u);u--;){I=this.segs[this.selected_pts[u]];I.select(true);A[u]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,u,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;u=mouse_y/o;F=qa("path_stretch_line");m=[I,u];if(n.gridSnapping){I=wa(I);u=wa(u);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5", +w(S,X);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S= +F.textContent.length,X=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=X?Y(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var aa={x:v.x+v.width/2,width:0};for(X=0;X=0&&this.selected_pts.push(F)}this.selected_pts.sort();u=this.selected_pts.length; +for(A=Array(u);u--;){I=this.segs[this.selected_pts[u]];I.select(true);A[u]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,u,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;u=mouse_y/o;F=qa("path_stretch_line");m=[I,u];if(n.gridSnapping){I=wa(I);u=wa(u);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(b,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5", fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var v=E.getItem(G),C=v.x;v=v.y;if(I>=C-L&&I<=C+L&&u>=v-L&&u<=v+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;u=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,u):w.createSVGPathSegCurvetoCubicAbs(I,u,A.x1/o,A.y1/o, I,u);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E=false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(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();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a, Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,u);I=A.x;u=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(u)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(u),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;u*=o;F.setAttribute("d",["M",I,u,I,u].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,u)}}else{d_attr= @@ -287,134 +287,134 @@ o,y1:v*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[u,F];else{I=I.getItem(A-1) 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-E.x;E=L.y-E.y;svgedit.path.path.dragging=[u,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ta.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D, {x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(A,u){if(Ea==="path"){m=null;if(!w){u=qa(ca());La=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();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ta&&ta.getAttribute("display")!= "none"){ta.setAttribute("display","none");ta.getAttribute("width")<=2&&ta.getAttribute("height")<=2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="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;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&& -svgedit.path.recalcRotatedPath();if(u){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea="path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=K[0];if(A)if(pa(A)!=0){var u=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};u.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(u);svgedit.path.getPath_(A).show(false).matrix=null; -this.clear();vb([A],true);M("changed",K)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="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=V(A),F=fa(u).matrix;u.clear();A.removeAttribute("transform");u=A.pathSegList;for(var I=u.numberOfItems, +svgedit.path.recalcRotatedPath();if(u){M("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea="path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(pa(A)!=0){var u=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};u.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(u);svgedit.path.getPath_(A).show(false).matrix=null; +this.clear();vb([A],true);M("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="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=V(A),F=fa(u).matrix;u.clear();A.removeAttribute("transform");u=A.pathSegList;for(var I=u.numberOfItems, E=0;E0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<= -1){Ja.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 I=u.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=u.getItem(G),k=u.getItem(G+1),v=u.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E, +1){Ja.toSelectMode(svgedit.path.path.elem);c.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 I=u.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=u.getItem(G),k=u.getItem(G+1),v=u.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E, L,I))&&I.length==2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,v.x,v.y].join(","));I=v;E=k}for(A.push("L");G0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(J){Jb();xb([J])}var e= +E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;X-=E;P-=G;aa-=G;case 17:if(u){E+=D;G+=P}else{D+=E;X+=E;P+=G;aa+=G;E=D;G=P}Oa([[X,aa],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(b,"*"),A=H.length,u=0;u0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e= [];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w=0;F--){u=A.item(F);G=z(u.nodeValue);if(!(L.indexOf(u.localName)>=0))if(G!="")if(G.indexOf("pointer-events")!==0)if(!(u.localName==="class"&&G.indexOf("se_")===0)){m.push(" ");if(u.localName==="d")G=Ja.convertPath(e,true);if(isNaN(G)){if(H.test(G))G= -svgedit.units.shortFloat(G)+w}else G=svgedit.units.shortFloat(G);if(fb.apply&&e.nodeName==="image"&&u.localName==="href"&&fb.images&&fb.images==="embed"){var k=Sa[G];if(k)G=k}if(!u.namespaceURI||u.namespaceURI==c||Aa[u.namespaceURI]){m.push(u.nodeName);m.push('="');m.push(G);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");h++;A=false;for(F=0;F");h++;A=false;for(F=0;F");break;case 8:m.push("\n");m.push(Array(h+1).join(" "));m.push("