diff --git a/.DS_Store b/.DS_Store index 2f3b997..a5808c0 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/editor/.DS_Store b/editor/.DS_Store index ce2c8dd..4717fd8 100644 Binary files a/editor/.DS_Store and b/editor/.DS_Store differ diff --git a/editor/extensions/ext-eyedropper.js b/editor/extensions/ext-eyedropper.js index 12a39b3..47ea394 100644 --- a/editor/extensions/ext-eyedropper.js +++ b/editor/extensions/ext-eyedropper.js @@ -51,7 +51,6 @@ svgEditor.addExtension("eyedropper", function(S) { var getPaint = function(color, opac, type) { // update the editor's fill paint var opts = null; - console.log(color); if (color.indexOf("url(#") === 0) { var refElem = svgCanvas.getRefElem(color); if(refElem) { @@ -87,6 +86,7 @@ svgEditor.addExtension("eyedropper", function(S) { title: "Eye Dropper Tool", key: "I", "class": "disabled", + icon: "extensions/eyedropper.png", events: { "click": function() { svgCanvas.setMode("eyedropper"); @@ -130,7 +130,6 @@ svgEditor.addExtension("eyedropper", function(S) { if (currentStyle.strokeLinecap) change(element, "stroke-linecap", currentStyle.strokeLinecap); if (currentStyle.strokeLinejoin) change(element, "stroke-linejoin", currentStyle.strokeLinejoin); batchCmd.addSubCommand(new ChangeElementCommand(element, changes)); - console.log(changes); changes = {}; }); var fill = getPaint(currentStyle.fillPaint, currentStyle.fillOpacity*100, "fill") diff --git a/editor/extensions/ext-shapes.js b/editor/extensions/ext-shapes.js index 42666c1..2455b0b 100644 --- a/editor/extensions/ext-shapes.js +++ b/editor/extensions/ext-shapes.js @@ -155,7 +155,7 @@ svgEditor.addExtension("shapes", function() { type: "mode_flyout", // _flyout position: 6, title: "Shape library", - fallback: "extensions/ext-shapes.png", + icon: "extensions/ext-shapes.png", events: { "click": function() { canv.setMode(mode_id); diff --git a/editor/extensions/ext-shapes.png b/editor/extensions/ext-shapes.png new file mode 100644 index 0000000..3f62167 Binary files /dev/null and b/editor/extensions/ext-shapes.png differ diff --git a/editor/images/align-bottom.png b/editor/images/align-bottom.png index a2243be..6426d11 100644 Binary files a/editor/images/align-bottom.png and b/editor/images/align-bottom.png differ diff --git a/editor/images/align-center.png b/editor/images/align-center.png index 41b9f98..4f3c95d 100644 Binary files a/editor/images/align-center.png and b/editor/images/align-center.png differ diff --git a/editor/images/align-left.png b/editor/images/align-left.png index 4d80d3e..15e0091 100644 Binary files a/editor/images/align-left.png and b/editor/images/align-left.png differ diff --git a/editor/images/align-middle.png b/editor/images/align-middle.png index 79b3ffd..4b6c8ae 100644 Binary files a/editor/images/align-middle.png and b/editor/images/align-middle.png differ diff --git a/editor/images/align-right.png b/editor/images/align-right.png index 232cbf7..213420d 100644 Binary files a/editor/images/align-right.png and b/editor/images/align-right.png differ diff --git a/editor/images/align-top.png b/editor/images/align-top.png index df59a3a..26656dd 100644 Binary files a/editor/images/align-top.png and b/editor/images/align-top.png differ diff --git a/editor/images/eyedropper_tool.png b/editor/images/eyedropper_tool.png new file mode 100644 index 0000000..9ef8ff3 Binary files /dev/null and b/editor/images/eyedropper_tool.png differ diff --git a/editor/svg-editor.html b/editor/svg-editor.html index 59c88ca..a689936 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -52,6 +52,7 @@ + @@ -101,6 +102,8 @@ $(function(){ @@ -108,8 +111,8 @@ $(function(){ diff --git a/editor/svg-editor.js b/editor/svg-editor.js index bf9814e..e918348 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -240,11 +240,11 @@ 'spapelib':'shapelib.png', 'node_delete':'node_delete.png', 'align_left':'align-left.png', - 'align_center':'align-center', - 'align_right':'align-right', - 'align_top':'align-top', - 'align_middle':'align-middle', - 'align_bottom':'align-bottom', + 'align_center':'align-center.png', + 'align_right':'align-right.png', + 'align_top':'align-top.png', + 'align_middle':'align-middle.png', + 'align_bottom':'align-bottom.png', 'arrow_right':'flyouth.png', 'arrow_down':'dropdown.gif' }, @@ -1005,17 +1005,16 @@ var icon; var id = btn.id; var num = i; - // Give button a unique ID while($('#'+id).length) { id = btn.id + '_' + (++num); } - if(!svgicons) { icon = (btn.type == "menu") ? "" : $(''); } else { fallback_obj[id] = btn.icon; - var svgicon = btn.svgicon?btn.svgicon:btn.id; + var svgicon = btn.svgicon ? btn.svgicon : btn.id; + console.log(svgicon); if(btn.type == 'app_menu') { placement_obj['#' + id + ' > div'] = svgicon; } else { @@ -1391,6 +1390,7 @@ //hack to show the proper multialign box if (multiselected) { + multiselected = multiselected.filter(Boolean) elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null if (elem) $("#tools_top").addClass("multiselected") } @@ -1534,20 +1534,14 @@ }); if(el_name == 'text') { + var font_family = elem.getAttribute("font-family"); + var select = document.getElementById("font_family_dropdown"); + select.selectedIndex = 3 + $('#text_panel').css("display", "inline"); - if (svgCanvas.getItalic()) { - $('#tool_italic').addClass('push_button_pressed').removeClass('tool_button'); - } - else { - $('#tool_italic').removeClass('push_button_pressed').addClass('tool_button'); - } - if (svgCanvas.getBold()) { - $('#tool_bold').addClass('push_button_pressed').removeClass('tool_button'); - } - else { - $('#tool_bold').removeClass('push_button_pressed').addClass('tool_button'); - } - $('#font_family').val(elem.getAttribute("font-family")); + $('#tool_italic').toggleClass('active', svgCanvas.getItalic()) + $('#tool_bold').toggleClass('active', svgCanvas.getBold()) + $('#font_family').val(font_family); $('#font_size').val(elem.getAttribute("font-size")); $('#text').val(elem.textContent); if (svgCanvas.addedNew) { @@ -1889,17 +1883,12 @@ top.exports.setEditorFocus(); } } - if (!$(e.target).hasClass("menu_title") && !$(e.target).parent().hasClass("menu_title")) { - if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) { - blinker(e); - return; - } - else { - $('#menu_bar').removeClass('active') - } - - } - + if (e.target.nodeName.toLowerCase() === "input") return false; + if (!$(e.target).hasClass("menu_title") && !$(e.target).parent().hasClass("menu_title")) { + if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) blinker(e) + else $('#menu_bar').removeClass('active') + + } } diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index b51a118..e328e0c 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2216,13 +2216,8 @@ var addToSelection = this.addToSelection = function(elemsToAdd, showGrips) { } } call("selected", selectedElements); - - if (showGrips || selectedElements.length == 1) { - selectorManager.requestSelector(selectedElements[0]).showGrips(true); - } - else { - selectorManager.requestSelector(selectedElements[0]).showGrips(false); - } + if (showGrips || selectedElements.length == 1) selectorManager.requestSelector(selectedElements[0]).showGrips(true) + else selectorManager.requestSelector(selectedElements[0]).showGrips(false); // make sure the elements are in the correct order // See: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition @@ -2801,16 +2796,17 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // alt drag = create a clone and save the reference if(evt.altKey) { //clone doesn't exist yet - if (!canvas.addClone) { - canvas.addClone = canvas.cloneSelectedElements(0,0, xform); - canvas.removeClone = function(){ - parent = canvas.addClone.parentNode - if (parent) { - parent.removeChild(canvas.addClone) - canvas.addClone = false; + if (!canvas.addClones) { + canvas.addClones = canvas.cloneSelectedElements(0,0, xform); + canvas.removeClones = function(){ + if (canvas.addClones) { + canvas.addClones.forEach(function(clone){ + if (clone.parentNode) clone.parentNode.removeChild(clone) + canvas.addClones = false; + }) } } - window.addEventListener("keyup", canvas.removeClone) + window.addEventListener("keyup", canvas.removeClones) } } @@ -3209,8 +3205,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // this is done in when we recalculate the selected dimensions() var mouseUp = function(evt) { - canvas.addClone = false; - window.removeEventListener("keyup", canvas.removeClone) + canvas.addClones = false; + window.removeEventListener("keyup", canvas.removeClones) if(evt.button === 2) return; var tempJustSelected = justSelected; @@ -3887,9 +3883,11 @@ var textActions = canvas.textActions = function() { }, setCursor: setCursor, toEditMode: function(x, y) { + selectOnly([curtext], false) allow_dbl = false; current_mode = "textedit"; - selectorManager.requestSelector(curtext).showGrips(false); + //selectorManager.requestSelector(curtext).showGrips(false); + // Make selector group accept clicks var sel = selectorManager.requestSelector(curtext).selectorRect; @@ -8582,21 +8580,28 @@ this.cloneSelectedElements = function(x,y, drag) { // note that we loop in the reverse way because of the way elements are added // to the selectedElements array (top-first) var i = copiedElements.length; + clones = [] while (i--) { // clone each element and replace it within copiedElements var elem = copiedElements[i] var clone = copyElem(copiedElements[i]); - if (drag) clone.setAttribute("transform", ""); + if (drag) { + //removed the dragged transform until that moment + tlist = getTransformList(clone) + tlist.removeItem(drag) + recalculateDimensions(clone) + } (current_group || getCurrentDrawing().getCurrentLayer()).appendChild(clone); + clones.push(clone) batchCmd.addSubCommand(new InsertElementCommand(clone)); } if (!batchCmd.isEmpty()) { addToSelection(copiedElements.reverse()); // Need to reverse for correct selection-adding - this.moveSelectedElements(x,y,false); + if (!drag) this.moveSelectedElements(x,y,false); addCommandToHistory(batchCmd); } - return clone + return clones }; // Function: alignSelectedElements diff --git a/editor/svgedit.compiled.js b/editor/svgedit.compiled.js index 9123b18..61f8012 100644 --- a/editor/svgedit.compiled.js +++ b/editor/svgedit.compiled.js @@ -1,18 +1,18 @@ 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 V=d.call(arguments,1);return function(){return da.apply(this,V.concat(d.call(arguments)))}}function n(da,V,Z,oa,qa){var ma;if(oa!==f){V=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=V[3]||"";if(qa===2&&g(oa))oa=oa.replace(da?W:ba,"");else{ma=o(V[2]);oa=g(oa)?o[da?ia:O](oa):oa;oa=qa===2?oa:qa===1?a.extend({},oa,ma):a.extend({},ma,oa);oa=q(oa);if(da)oa=oa.replace(sa,l)}da=V[1]+(da?"#":oa||!V[1]?"?":"")+oa+Z}else da= -V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,Y=a.event.special,O="querystring",ia="fragment",pa= +V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,X=a.event.special,O="querystring",ia="fragment",pa= "location",fa="href",ba=/^.*\?|#.*$/g,W=/^.*\#/,sa,ka={};q[O]=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,V){var Z={},oa={"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(V)na=na&&!isNaN(na)?+na:na==="undefined"?f:oa[na]!==f?oa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia').hide().insertAfter("body")[0].contentWindow; -J=function(){return c(T.document[b][f])};M=function(Q,Y){if(Q!==Y){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function Y(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(Y,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){Y++;if(Y<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} +J=function(){return c(T.document[b][f])};M=function(Q,X){if(Q!==X){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function X(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(X,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){X++;if(X<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} function b(da,V){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(V){var oa=n.fallback_path?n.fallback_path:"";a.each(V,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:oa+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(!V){da&&Z.remove();fa&&fa.remove();M&&M.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=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)} function d(da){if(window.btoa)return window.btoa(da);var V=Array(Math.floor((da.length+2)/3)*4),Z,oa,qa,ma,na,Aa,Fa=0,Ia=0;do{Z=da.charCodeAt(Fa++);oa=da.charCodeAt(Fa++);qa=da.charCodeAt(Fa++);ma=Z>>2;Z=(Z&3)<<4|oa>>4;na=(oa&15)<<2|qa>>6;Aa=qa&63;if(isNaN(oa))na=Aa=64;else if(isNaN(qa))Aa=64;V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na); -V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&O.indexOf("Chrome/");var pa="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); +V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&O.indexOf("Chrome/");var pa="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 W=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){T=W.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=W.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,V,Z,oa){ia&&V.css("visibility","hidden");if(n.replace){oa&&V.attr("id",Z);(Z=da.attr("class"))&&V.attr("class", "svg_icon "+Z);da.replaceWith(V)}else da.append(V);ia&&setTimeout(function(){V.removeAttr("style")},1)},ka=function(da,V){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,V,true);p[V]=da};g=function(da,V){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var oa=da[0].getElementsByTagName("*"),qa=oa.length;Z.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+V+ma;na="url(#"+na+")";var Aa="url(#"+ma+")";for(ma= 0;ma=0;jQuery.fn.jGraduate=function(c){var n= arguments;return this.each(function(){function s(la,ca,ja,N,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},W);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else W.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(Oa){b(this);Ra=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Oa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Oa=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(Xa){db=Xa.val("hex")?"#"+Xa.val("hex"):"none";Ya=Xa.val("a")!==null?Xa.val("a")/256:1;Oa.setAttribute("fill",db);Oa.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()})});$(W).find("stop").each(function(){var Oa=$(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)}Oa.before(ea);return false}});N&&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()}Ra=null}function d(){var la=Ua?"rotate("+Ua+","+Ea+","+kb+") ":"";fb===1&&La===1?W.removeAttribute("gradientTransform"):W.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");Ra.setAttribute("transform",ja);$.data(Ra,"bg").setAttribute("transform",ja);$.data(Ra,"stop").setAttribute("offset",(ca-10)/ia);var N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"), +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")|| +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()})});$(W).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}});N&&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?W.removeAttribute("gradientTransform"):W.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 N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"), ea=$(this);if(R
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var Y=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('

    '+B.window.pickerTitle+'

    ');var X=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('

    '+B.window.pickerTitle+'


    ").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=W.getAttribute(ca),N=isNaN(ca[1]);ja||(ja=N?"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(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?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,Va,Ra,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"},Va),va,fb=1,La=1,Ua=0,Ea=Fa,kb=Ia;Va=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16, -height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Va).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()}});$(Va).mouseover(function(){Va.appendChild(Da)});qb=a("g",{},Va);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var sb= +1)this.value=1;if(!(ca[0]==="f"&&!jb))if(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?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= O.find(".jGraduate_spreadMethod").change(function(){W.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/pa;ja=ja/fa;var N=Za.data("coord"),R=W;switch(N){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); -ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=W.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){W.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=W.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na99.5)N=99.5;if(N>0)La=1-N/100;else fb=-(N/100)-1;R=145*((N+100)/ -2)/100;ea&&d();break;case "angle":Ua=N;R=Ua/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;W.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;Ua=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(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color")); -$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});Y.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active: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(){M()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current"); +2)/100;ea&&d();break;case "angle":Va=N;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;W.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(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color")); +$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});X.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(){M()});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(W!==ca){var ja= -$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.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 Ab;switch(q.paint.type){case "linearGradient":Ab=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Ab= -$(K+" .jGraduate_tab_radgrad");break;default:Ab=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Ab.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,c){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var 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|| +$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.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,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(K){switch(K.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), @@ -64,10 +64,10 @@ function(){return false})});return $(this)},disableContextMenuItems:function(g){ 0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(pa,0);return true}catch(ba){}return false}(),T=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(pa, 0);return true}catch(ba){}return false}(),M=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);fa.setAttribute("x",5);pa.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(pa);return fa===0}(),J=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");pa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(pa);return fa.height>4&&fa.height<5}(),Q=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);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 W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),Y=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.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."); +document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),X=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.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 pa}(),O=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("style","vector-effect:non-scaling-stroke");return pa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();pa.appendItem(fa);return pa.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 K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J}; -svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return Y};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{}; +svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return X};svgedit.browser.supportsNonScalingStroke=function(){return O};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>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+= 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 element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l=d?null:f[l+1],K=l-1<0?null:f[l-1];if(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=0)D=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)D=G=b.convertToPath(I,true)}if(!G){var u=I.cloneNode(true),C=document.createElementNS(c,"g"),E=I.parentNode;E.appendChild(C);C.appendChild(u);D=svgedit.utilities.bboxToObj(C.getBBox());E.removeChild(C)}}return D}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,v=function(I){var D=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(D))G+=D/2;return G},F=[];$.each(e,function(I,D){var G=h(D);if(G){var L=v(D);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,D){var G=F[I];if(G&&D.nodeType==1){var L=v(D);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()},Ab=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg", +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 u=I.cloneNode(true),C=document.createElementNS(c,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(u);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,v=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=v(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=v(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)[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,N;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};N=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 +e[h];z.setAttribute("d",Ja.convertPath(z));Ja.fixEnd(z)}};var R=this.getRefElem=function(e){return qa(ka(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var m=J[0],z=m.getAttribute("transform"),w=svgedit.utilities.getBBox(m),H=w.x+w.width/2,A=w.y+w.height/2;w=X(m);w.numberOfItems> 0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=O(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);N("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=Xa(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",J)}},Oa=[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", +"none"?"position":"size"),h=J.length;h--;){var m=Ua(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("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", v=e.getAttribute(A);if(v&&v.indexOf("url(")===0)if(m.a<0||m.d<0){v=R(v).cloneNode(true);if(m.a<0){var F=v.getAttribute("x1"),I=v.getAttribute("x2");v.setAttribute("x1",-(F-1));v.setAttribute("x2",-(I-1))}if(m.d<0){F=v.getAttribute("y1");I=v.getAttribute("y2");v.setAttribute("y1",-(F-1));v.setAttribute("y2",-(I-1))}v.id=ja();lb().appendChild(v);e.setAttribute(A,"url(#"+v.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=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(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(); +m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(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=O(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=O(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=O(h.x1,h.y1,m);F=O(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")); -v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var D={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)D.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)D.y=h.y-(F-I);if(D.x||D.y)ma(m[H],D,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type=== +v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var E={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)E.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)E.y=h.y-(F-I);if(E.x||E.y)ma(m[H],E,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type=== 1)svgedit.math.isIdentity(z.matrix)&&h.removeItem(m);else z.type===4&&z.angle===0&&h.removeItem(m)}if(h.numberOfItems===1&&oa(e))return null}if(!h||h.numberOfItems==0){e.removeAttribute("transform");return null}if(h){m=h.numberOfItems;for(var w=[];m--;){z=h.getItem(m);if(z.type===1)w.push([z.matrix,m]);else if(w.length)w=[]}if(w.length===2){m=d.createSVGTransformFromMatrix(ia(w[1][0],w[0][0]));h.removeItem(w[0][1]);h.removeItem(w[1][1]);h.insertItemBefore(m,w[1][1])}m=h.numberOfItems;if(m>=2&&h.getItem(m- 2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new za("Transform");var A={},v=null;z=[];switch(e.tagName){case "line":z=["x1","y1", -"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":v={};v.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I1.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;var C=h.getItem(k-3).matrix,E=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(D=F.length;D--;){var U=F.item(D);z=H=0;if(U.nodeType==1){var S=Y(U);if(S){z=fa(S).matrix;H=oa(U);var X=Ua,aa=[];Ua=U.getAttribute("transform");if(H||pa(S)){var ga= -d.createSVGTransform();ga.setMatrix(ia(C,E,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,E,P,z,H.inverse());var ra=d.createSVGTransform(),Ta=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Ta.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Ta);S.appendItem(ra);aa.push(Ba);aa.push(Ta);aa.push(ra)}m.addSubCommand(Xa(U));Ua=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;D=F.length;for(k=[];D--;){U=F.item(D);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=Ua;Ua=U.getAttribute("transform"); -if(S=Y(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Xa(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){E=S.item(C);if(U==da(E)){P=d.createSVGTransform();P.setTranslate(-H,-z);Y(E).insertItemBefore(P,0);m.addSubCommand(Xa(E))}}Ua=X}}}k=[];Ua=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform"); -if(S=Y(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Xa(U));Ua=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+u.e,y:G.y+u.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;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,u,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform");S=Y(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C, -0):S.appendItem(C);m.addSubCommand(Xa(U));Ua=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=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(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;u=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,u,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.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;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=X(U);if(S){z=fa(S).matrix;H=oa(U);var Y=Va,aa=[];Va=U.getAttribute("transform");if(H||pa(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=Y}}}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")){Y=U.getAttribute("clip-path");if(k.indexOf(Y)===-1){nb(Y,H,z);k.push(Y)}}Y=Va;Va=U.getAttribute("transform"); +if(S=X(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);X(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=Y}}}k=[];Va=Y}}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){Y=Va;Va=U.getAttribute("transform"); +if(S=X(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=Y;Y=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(Y)&&U.setAttribute("stroke-width",Y*((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+u.e,y:G.y+u.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;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,u,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){Y=Va;Va=U.getAttribute("transform");S=X(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C, +0):S.appendItem(C);m.addSubCommand(Ua(U));Va=Y}}}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=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(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;u=h.getItem(0).matrix;Y=fa(h,1).matrix;w=Y.inverse();z=ia(w,u,Y);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)}}}N("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)}},Bb=this.selectOnly=function(e,h){Pa(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(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";D=D/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=D,k=w=m=I;if(n.gridSnapping){D=wa(D);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type"); -if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Ua=G.getAttribute("transform");u=Y(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Pa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);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&&J[0]!=null){G=v.target;var u=ib(G,"type"); +if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=X(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(v.button===1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY, -rb),D=I.x*o;I=I.y*o;var G=qa(ca()),L=x=D/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k0&&b.removeFromSelection(G);L.length>0&&vb(L); -break;case "resize":G=Y(F);L=(E=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var X=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=X*Math.cos(u);u=X*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;X=P}L= -d.createSVGTransform();u=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(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+X,k+aa);if(E){E=S?1:0;G.replaceItem(L,2+E);G.replaceItem(u,1+E);G.replaceItem(P,0+E)}else{E=G.numberOfItems;G.replaceItem(P,E-3);G.replaceItem(u,E-2);G.replaceItem(L,E-1)}Ha.requestSelector(F).resize();N("transition",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)}E=x;C=y;if(v.shiftKey){C=ba(h,m,E,C);E=C.x;C=C.y}G.setAttributeNS(null,"x2",E);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);E=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=E=Math.max(L,E);C=hm?m+k:m-k}if(v.altKey){E=h;C=m;k=Math.abs(x-E);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",E);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(v.shiftKey){if(E=svgedit.path.path){G=E.dragging?E.dragging[0]:h;E=E.dragging?E.dragging[1]:m}else{G=h;E=m}C=ba(G,E,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(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(D,I);break;case "rotate":L=svgedit.utilities.getBBox(F);E=L.x+L.width/ -2;C=L.y+L.height/2;G=W(F);G=O(E,C,G);E=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,E-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,E-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:D,mouse_y:I,selected:F})}}).click(function(v){v.preventDefault(); -return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),D=I.tagName;if(D==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((D==="g"||D==="a")&&oa(I)){Mb(I);I=J[0];Pa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClone=false;window.removeEventListener("keyup",b.removeClone);if(v.button!==2){var F=Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y* -o;var G=D/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");bb.stroke_opacity=D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width"); -bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(D=0;D=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"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=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()}});N("changed",[k]);u=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()}});N("changed",[k]);u=true}break;case "text":u=true;Bb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,D,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u=false;k=null;hb.mouseUp(v,D,I);break;case "rotate":u=true;k=null;Ea="select"; -F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}D=ob("mouseUp",{event:v,mouse_x:D,mouse_y:I},true);$.each(D,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(D=v.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Ea!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&D.id!="svgcanvas"&&D.id!="svgroot"){b.setMode("select");Bb([D],true)}}else if(k!=null){b.addedNew= -true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(E){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&Bb([k],true);ya(new Ca(k));N("changed",[k])},v*1E3)}Ua=null}}});$(a).bind("mousewheel DOMMouseScroll",function(v){if(v.shiftKey){v.preventDefault(); -rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("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);D=qa("text_cursor");if(!D){D=document.createElementNS(c,"line");ma(D,{id:"text_cursor",stroke:"#333","stroke-width":1});D=qa("selectorParentGroup").appendChild(D)}L||(L=setInterval(function(){var ga=D.getAttribute("display")==="none";D.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(D,{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];D.setAttribute("visibility","hidden");X=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.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=O(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=O(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 v(S){if(U&&F){var X=O(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,D,G,L,k=[],u,C,E,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));E=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&&XE-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){U=false;Ea="textedit";Ha.requestSelector(F).showGrips(false);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");D&&$(D).attr("visibility","hidden");$(F).css("cursor","move");if(S){Pa();$(F).css("cursor","move");N("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=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length, -X=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);C=X?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(X=0;X=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I= -this.segs[this.selected_pts[v]];I.select(true);A[v]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);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",fill:"none"}); -F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var D=null;if(w){D=w.pathSegList;for(var G=D.numberOfItems,L=6/o,k=false;G;){G--;var u=D.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=D.numberOfItems;if(k){if(G<=1&&C>=2){I=D.getItem(0).x;v=D.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath(); -D.appendItem(A);D.appendItem(I)}else if(C<3)return D=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}D=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(D-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=D;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true, -attr:{d:d_attr,id:ja(),opacity:M.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];D=svgedit.path.path.segs[v];if(A.shiftKey)D.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v); -else{if(svgedit.path.path.selected_pts.length<=1||!D.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems- -1;if(m){var D=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");D.setAttribute("cx",v);D.setAttribute("cy",F);D.setAttribute("display","inline");D=m[0];var L=m[1];I.getItem(A);var k=D+(D-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:D*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:D*o,y2:L*o,display:"inline"}); -if(A===0)z=[v,F];else{I=I.getItem(A-1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[D,L,v,F,k,u],w)}}else if(D=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],D);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],D):svgedit.path.replacePathSeg(4,1,[v,F],D)}}}else if(svgedit.path.path.dragging){D=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0], -y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-D.x;D=L.y-D.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,D):svgedit.path.path.movePts(A,D)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var E=ta.getBBox(),P=svgedit.path.getGripPt(this);E=svgedit.math.rectsIntersect(E,{x:P.x,y:P.y,width:0,height:0});this.select(E);E&&svgedit.path.path.selected_pts.push(this.index)}})}}, -mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}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";Pa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Pa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("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(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Pa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("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 v=Y(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,D=0;D0){L=I.getItem(D-1).pathSegType;if(L===2){G(D-1,1);F();break}else if(L===1&&I.numberOfItems-1===D){G(D,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 v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),D=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(D)if((I=svgedit.path.smoothControlPoints(D,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,u.x,u.y].join(","));I=u;D=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(K){Jb();Bb([K])}var e= -[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w0&&b.removeFromSelection(G); +L.length>0&&vb(L);break;case "resize":G=X(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra= +P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();N("transition",J);break;case "zoom":L*=o;k*=o;ma(ua, +{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(v.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"||v.shiftKey){L=D=Math.max(L, +D);C=hm?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);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(v.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(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{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(v,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=W(F);G=O(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(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:E, +mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones);if(v.button!==2){var F= +Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[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){v=J.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"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=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()}});N("changed",[k]);u=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()}});N("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u= +false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.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;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.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));N("changed",[k])},v*1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll", +function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value==="";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!== +I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||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));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d", +"")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);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[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}} +function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;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,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(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 v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F= +S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&YD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,Y);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");N("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=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F); +C=Y?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]= +I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);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",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 u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+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;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);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,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:M.opacity/ +2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<= +1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"), +G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A- +1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]}, +svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,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=ua.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,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}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(ua&&ua.getAttribute("display")!="none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.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 v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("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(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("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 v=X(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.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 v=A.points,F=v.numberOfItems;if(F>=4){var I=v.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=v.getItem(G),k=v.getItem(G+1),u=v.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,u.x,u.y].join(","));I=u;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(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--){v=A.item(F);G=z(v.nodeValue);if(!(L.indexOf(v.localName)>=0))if(G!="")if(G.indexOf("pointer-events")!==0)if(!(v.localName==="class"&&G.indexOf("se_")===0)){m.push(" ");if(v.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"&&v.localName==="href"&&fb.images&&fb.images==="embed"){var k=Ra[G];if(k)G=k}if(!v.namespaceURI||v.namespaceURI==c||Aa[v.namespaceURI]){m.push(v.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(" @@ -101,6 +102,8 @@ $(function(){ @@ -108,8 +111,8 @@ $(function(){ diff --git a/method-draw/svg-editor.js b/method-draw/svg-editor.js index bf9814e..e918348 100644 --- a/method-draw/svg-editor.js +++ b/method-draw/svg-editor.js @@ -240,11 +240,11 @@ 'spapelib':'shapelib.png', 'node_delete':'node_delete.png', 'align_left':'align-left.png', - 'align_center':'align-center', - 'align_right':'align-right', - 'align_top':'align-top', - 'align_middle':'align-middle', - 'align_bottom':'align-bottom', + 'align_center':'align-center.png', + 'align_right':'align-right.png', + 'align_top':'align-top.png', + 'align_middle':'align-middle.png', + 'align_bottom':'align-bottom.png', 'arrow_right':'flyouth.png', 'arrow_down':'dropdown.gif' }, @@ -1005,17 +1005,16 @@ var icon; var id = btn.id; var num = i; - // Give button a unique ID while($('#'+id).length) { id = btn.id + '_' + (++num); } - if(!svgicons) { icon = (btn.type == "menu") ? "" : $(''); } else { fallback_obj[id] = btn.icon; - var svgicon = btn.svgicon?btn.svgicon:btn.id; + var svgicon = btn.svgicon ? btn.svgicon : btn.id; + console.log(svgicon); if(btn.type == 'app_menu') { placement_obj['#' + id + ' > div'] = svgicon; } else { @@ -1391,6 +1390,7 @@ //hack to show the proper multialign box if (multiselected) { + multiselected = multiselected.filter(Boolean) elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null if (elem) $("#tools_top").addClass("multiselected") } @@ -1534,20 +1534,14 @@ }); if(el_name == 'text') { + var font_family = elem.getAttribute("font-family"); + var select = document.getElementById("font_family_dropdown"); + select.selectedIndex = 3 + $('#text_panel').css("display", "inline"); - if (svgCanvas.getItalic()) { - $('#tool_italic').addClass('push_button_pressed').removeClass('tool_button'); - } - else { - $('#tool_italic').removeClass('push_button_pressed').addClass('tool_button'); - } - if (svgCanvas.getBold()) { - $('#tool_bold').addClass('push_button_pressed').removeClass('tool_button'); - } - else { - $('#tool_bold').removeClass('push_button_pressed').addClass('tool_button'); - } - $('#font_family').val(elem.getAttribute("font-family")); + $('#tool_italic').toggleClass('active', svgCanvas.getItalic()) + $('#tool_bold').toggleClass('active', svgCanvas.getBold()) + $('#font_family').val(font_family); $('#font_size').val(elem.getAttribute("font-size")); $('#text').val(elem.textContent); if (svgCanvas.addedNew) { @@ -1889,17 +1883,12 @@ top.exports.setEditorFocus(); } } - if (!$(e.target).hasClass("menu_title") && !$(e.target).parent().hasClass("menu_title")) { - if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) { - blinker(e); - return; - } - else { - $('#menu_bar').removeClass('active') - } - - } - + if (e.target.nodeName.toLowerCase() === "input") return false; + if (!$(e.target).hasClass("menu_title") && !$(e.target).parent().hasClass("menu_title")) { + if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) blinker(e) + else $('#menu_bar').removeClass('active') + + } } diff --git a/method-draw/svgcanvas.js b/method-draw/svgcanvas.js index b51a118..e328e0c 100644 --- a/method-draw/svgcanvas.js +++ b/method-draw/svgcanvas.js @@ -2216,13 +2216,8 @@ var addToSelection = this.addToSelection = function(elemsToAdd, showGrips) { } } call("selected", selectedElements); - - if (showGrips || selectedElements.length == 1) { - selectorManager.requestSelector(selectedElements[0]).showGrips(true); - } - else { - selectorManager.requestSelector(selectedElements[0]).showGrips(false); - } + if (showGrips || selectedElements.length == 1) selectorManager.requestSelector(selectedElements[0]).showGrips(true) + else selectorManager.requestSelector(selectedElements[0]).showGrips(false); // make sure the elements are in the correct order // See: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition @@ -2801,16 +2796,17 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // alt drag = create a clone and save the reference if(evt.altKey) { //clone doesn't exist yet - if (!canvas.addClone) { - canvas.addClone = canvas.cloneSelectedElements(0,0, xform); - canvas.removeClone = function(){ - parent = canvas.addClone.parentNode - if (parent) { - parent.removeChild(canvas.addClone) - canvas.addClone = false; + if (!canvas.addClones) { + canvas.addClones = canvas.cloneSelectedElements(0,0, xform); + canvas.removeClones = function(){ + if (canvas.addClones) { + canvas.addClones.forEach(function(clone){ + if (clone.parentNode) clone.parentNode.removeChild(clone) + canvas.addClones = false; + }) } } - window.addEventListener("keyup", canvas.removeClone) + window.addEventListener("keyup", canvas.removeClones) } } @@ -3209,8 +3205,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // this is done in when we recalculate the selected dimensions() var mouseUp = function(evt) { - canvas.addClone = false; - window.removeEventListener("keyup", canvas.removeClone) + canvas.addClones = false; + window.removeEventListener("keyup", canvas.removeClones) if(evt.button === 2) return; var tempJustSelected = justSelected; @@ -3887,9 +3883,11 @@ var textActions = canvas.textActions = function() { }, setCursor: setCursor, toEditMode: function(x, y) { + selectOnly([curtext], false) allow_dbl = false; current_mode = "textedit"; - selectorManager.requestSelector(curtext).showGrips(false); + //selectorManager.requestSelector(curtext).showGrips(false); + // Make selector group accept clicks var sel = selectorManager.requestSelector(curtext).selectorRect; @@ -8582,21 +8580,28 @@ this.cloneSelectedElements = function(x,y, drag) { // note that we loop in the reverse way because of the way elements are added // to the selectedElements array (top-first) var i = copiedElements.length; + clones = [] while (i--) { // clone each element and replace it within copiedElements var elem = copiedElements[i] var clone = copyElem(copiedElements[i]); - if (drag) clone.setAttribute("transform", ""); + if (drag) { + //removed the dragged transform until that moment + tlist = getTransformList(clone) + tlist.removeItem(drag) + recalculateDimensions(clone) + } (current_group || getCurrentDrawing().getCurrentLayer()).appendChild(clone); + clones.push(clone) batchCmd.addSubCommand(new InsertElementCommand(clone)); } if (!batchCmd.isEmpty()) { addToSelection(copiedElements.reverse()); // Need to reverse for correct selection-adding - this.moveSelectedElements(x,y,false); + if (!drag) this.moveSelectedElements(x,y,false); addCommandToHistory(batchCmd); } - return clone + return clones }; // Function: alignSelectedElements diff --git a/method-draw/svgedit.compiled.js b/method-draw/svgedit.compiled.js index 9123b18..61f8012 100644 --- a/method-draw/svgedit.compiled.js +++ b/method-draw/svgedit.compiled.js @@ -1,18 +1,18 @@ 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 V=d.call(arguments,1);return function(){return da.apply(this,V.concat(d.call(arguments)))}}function n(da,V,Z,oa,qa){var ma;if(oa!==f){V=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=V[3]||"";if(qa===2&&g(oa))oa=oa.replace(da?W:ba,"");else{ma=o(V[2]);oa=g(oa)?o[da?ia:O](oa):oa;oa=qa===2?oa:qa===1?a.extend({},oa,ma):a.extend({},ma,oa);oa=q(oa);if(da)oa=oa.replace(sa,l)}da=V[1]+(da?"#":oa||!V[1]?"?":"")+oa+Z}else da= -V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,Y=a.event.special,O="querystring",ia="fragment",pa= +V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,X=a.event.special,O="querystring",ia="fragment",pa= "location",fa="href",ba=/^.*\?|#.*$/g,W=/^.*\#/,sa,ka={};q[O]=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,V){var Z={},oa={"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(V)na=na&&!isNaN(na)?+na:na==="undefined"?f:oa[na]!==f?oa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia').hide().insertAfter("body")[0].contentWindow; -J=function(){return c(T.document[b][f])};M=function(Q,Y){if(Q!==Y){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function Y(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(Y,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){Y++;if(Y<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} +J=function(){return c(T.document[b][f])};M=function(Q,X){if(Q!==X){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function X(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(X,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){X++;if(X<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} function b(da,V){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(V){var oa=n.fallback_path?n.fallback_path:"";a.each(V,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:oa+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(!V){da&&Z.remove();fa&&fa.remove();M&&M.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=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)} function d(da){if(window.btoa)return window.btoa(da);var V=Array(Math.floor((da.length+2)/3)*4),Z,oa,qa,ma,na,Aa,Fa=0,Ia=0;do{Z=da.charCodeAt(Fa++);oa=da.charCodeAt(Fa++);qa=da.charCodeAt(Fa++);ma=Z>>2;Z=(Z&3)<<4|oa>>4;na=(oa&15)<<2|qa>>6;Aa=qa&63;if(isNaN(oa))na=Aa=64;else if(isNaN(qa))Aa=64;V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na); -V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&O.indexOf("Chrome/");var pa="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); +V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa-1&&O.indexOf("Chrome/");var pa="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 W=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){T=W.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=W.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,V,Z,oa){ia&&V.css("visibility","hidden");if(n.replace){oa&&V.attr("id",Z);(Z=da.attr("class"))&&V.attr("class", "svg_icon "+Z);da.replaceWith(V)}else da.append(V);ia&&setTimeout(function(){V.removeAttr("style")},1)},ka=function(da,V){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,V,true);p[V]=da};g=function(da,V){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var oa=da[0].getElementsByTagName("*"),qa=oa.length;Z.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+V+ma;na="url(#"+na+")";var Aa="url(#"+ma+")";for(ma= 0;ma=0;jQuery.fn.jGraduate=function(c){var n= arguments;return this.each(function(){function s(la,ca,ja,N,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},W);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else W.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(Oa){b(this);Ra=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Oa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Oa=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(Xa){db=Xa.val("hex")?"#"+Xa.val("hex"):"none";Ya=Xa.val("a")!==null?Xa.val("a")/256:1;Oa.setAttribute("fill",db);Oa.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()})});$(W).find("stop").each(function(){var Oa=$(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)}Oa.before(ea);return false}});N&&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()}Ra=null}function d(){var la=Ua?"rotate("+Ua+","+Ea+","+kb+") ":"";fb===1&&La===1?W.removeAttribute("gradientTransform"):W.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");Ra.setAttribute("transform",ja);$.data(Ra,"bg").setAttribute("transform",ja);$.data(Ra,"stop").setAttribute("offset",(ca-10)/ia);var N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"), +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")|| +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()})});$(W).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}});N&&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?W.removeAttribute("gradientTransform"):W.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 N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"), ea=$(this);if(R
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var Y=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('

    '+B.window.pickerTitle+'

    ');var X=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('

    '+B.window.pickerTitle+'


    ").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=W.getAttribute(ca),N=isNaN(ca[1]);ja||(ja=N?"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(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?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,Va,Ra,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"},Va),va,fb=1,La=1,Ua=0,Ea=Fa,kb=Ia;Va=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16, -height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Va).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()}});$(Va).mouseover(function(){Va.appendChild(Da)});qb=a("g",{},Va);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var sb= +1)this.value=1;if(!(ca[0]==="f"&&!jb))if(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?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= O.find(".jGraduate_spreadMethod").change(function(){W.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/pa;ja=ja/fa;var N=Za.data("coord"),R=W;switch(N){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); -ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=W.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){W.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=W.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na99.5)N=99.5;if(N>0)La=1-N/100;else fb=-(N/100)-1;R=145*((N+100)/ -2)/100;ea&&d();break;case "angle":Ua=N;R=Ua/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;W.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;Ua=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(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color")); -$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});Y.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active: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(){M()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current"); +2)/100;ea&&d();break;case "angle":Va=N;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;W.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(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color")); +$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});X.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(){M()});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(W!==ca){var ja= -$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.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 Ab;switch(q.paint.type){case "linearGradient":Ab=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Ab= -$(K+" .jGraduate_tab_radgrad");break;default:Ab=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Ab.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,c){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var 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|| +$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.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,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(K){switch(K.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), @@ -64,10 +64,10 @@ function(){return false})});return $(this)},disableContextMenuItems:function(g){ 0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(pa,0);return true}catch(ba){}return false}(),T=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(pa, 0);return true}catch(ba){}return false}(),M=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);fa.setAttribute("x",5);pa.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(pa);return fa===0}(),J=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg", "svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");pa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(pa);return fa.height>4&&fa.height<5}(),Q=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);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 W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),Y=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.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."); +document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),X=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.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 pa}(),O=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("style","vector-effect:non-scaling-stroke");return pa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();pa.appendItem(fa);return pa.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 K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J}; -svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return Y};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{}; +svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return X};svgedit.browser.supportsNonScalingStroke=function(){return O};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>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+= 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 element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l=d?null:f[l+1],K=l-1<0?null:f[l-1];if(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=0)D=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)D=G=b.convertToPath(I,true)}if(!G){var u=I.cloneNode(true),C=document.createElementNS(c,"g"),E=I.parentNode;E.appendChild(C);C.appendChild(u);D=svgedit.utilities.bboxToObj(C.getBBox());E.removeChild(C)}}return D}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,v=function(I){var D=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(D))G+=D/2;return G},F=[];$.each(e,function(I,D){var G=h(D);if(G){var L=v(D);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,D){var G=F[I];if(G&&D.nodeType==1){var L=v(D);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()},Ab=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg", +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 u=I.cloneNode(true),C=document.createElementNS(c,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(u);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,v=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=v(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=v(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)[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,N;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};N=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 +e[h];z.setAttribute("d",Ja.convertPath(z));Ja.fixEnd(z)}};var R=this.getRefElem=function(e){return qa(ka(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var m=J[0],z=m.getAttribute("transform"),w=svgedit.utilities.getBBox(m),H=w.x+w.width/2,A=w.y+w.height/2;w=X(m);w.numberOfItems> 0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=O(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);N("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=Xa(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",J)}},Oa=[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", +"none"?"position":"size"),h=J.length;h--;){var m=Ua(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("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", v=e.getAttribute(A);if(v&&v.indexOf("url(")===0)if(m.a<0||m.d<0){v=R(v).cloneNode(true);if(m.a<0){var F=v.getAttribute("x1"),I=v.getAttribute("x2");v.setAttribute("x1",-(F-1));v.setAttribute("x2",-(I-1))}if(m.d<0){F=v.getAttribute("y1");I=v.getAttribute("y2");v.setAttribute("y1",-(F-1));v.setAttribute("y2",-(I-1))}v.id=ja();lb().appendChild(v);e.setAttribute(A,"url(#"+v.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=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(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(); +m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(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=O(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=O(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=O(h.x1,h.y1,m);F=O(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")); -v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var D={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)D.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)D.y=h.y-(F-I);if(D.x||D.y)ma(m[H],D,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type=== +v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var E={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)E.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)E.y=h.y-(F-I);if(E.x||E.y)ma(m[H],E,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type=== 1)svgedit.math.isIdentity(z.matrix)&&h.removeItem(m);else z.type===4&&z.angle===0&&h.removeItem(m)}if(h.numberOfItems===1&&oa(e))return null}if(!h||h.numberOfItems==0){e.removeAttribute("transform");return null}if(h){m=h.numberOfItems;for(var w=[];m--;){z=h.getItem(m);if(z.type===1)w.push([z.matrix,m]);else if(w.length)w=[]}if(w.length===2){m=d.createSVGTransformFromMatrix(ia(w[1][0],w[0][0]));h.removeItem(w[0][1]);h.removeItem(w[1][1]);h.insertItemBefore(m,w[1][1])}m=h.numberOfItems;if(m>=2&&h.getItem(m- 2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new za("Transform");var A={},v=null;z=[];switch(e.tagName){case "line":z=["x1","y1", -"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":v={};v.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I1.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;var C=h.getItem(k-3).matrix,E=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(D=F.length;D--;){var U=F.item(D);z=H=0;if(U.nodeType==1){var S=Y(U);if(S){z=fa(S).matrix;H=oa(U);var X=Ua,aa=[];Ua=U.getAttribute("transform");if(H||pa(S)){var ga= -d.createSVGTransform();ga.setMatrix(ia(C,E,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,E,P,z,H.inverse());var ra=d.createSVGTransform(),Ta=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Ta.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Ta);S.appendItem(ra);aa.push(Ba);aa.push(Ta);aa.push(ra)}m.addSubCommand(Xa(U));Ua=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;D=F.length;for(k=[];D--;){U=F.item(D);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=Ua;Ua=U.getAttribute("transform"); -if(S=Y(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Xa(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){E=S.item(C);if(U==da(E)){P=d.createSVGTransform();P.setTranslate(-H,-z);Y(E).insertItemBefore(P,0);m.addSubCommand(Xa(E))}}Ua=X}}}k=[];Ua=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform"); -if(S=Y(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Xa(U));Ua=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+u.e,y:G.y+u.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;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,u,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform");S=Y(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C, -0):S.appendItem(C);m.addSubCommand(Xa(U));Ua=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=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(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;u=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,u,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.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;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=X(U);if(S){z=fa(S).matrix;H=oa(U);var Y=Va,aa=[];Va=U.getAttribute("transform");if(H||pa(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=Y}}}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")){Y=U.getAttribute("clip-path");if(k.indexOf(Y)===-1){nb(Y,H,z);k.push(Y)}}Y=Va;Va=U.getAttribute("transform"); +if(S=X(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);X(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=Y}}}k=[];Va=Y}}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){Y=Va;Va=U.getAttribute("transform"); +if(S=X(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=Y;Y=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(Y)&&U.setAttribute("stroke-width",Y*((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+u.e,y:G.y+u.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;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,u,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){Y=Va;Va=U.getAttribute("transform");S=X(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C, +0):S.appendItem(C);m.addSubCommand(Ua(U));Va=Y}}}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=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(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;u=h.getItem(0).matrix;Y=fa(h,1).matrix;w=Y.inverse();z=ia(w,u,Y);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)}}}N("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)}},Bb=this.selectOnly=function(e,h){Pa(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(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";D=D/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=D,k=w=m=I;if(n.gridSnapping){D=wa(D);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type"); -if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Ua=G.getAttribute("transform");u=Y(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Pa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);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&&J[0]!=null){G=v.target;var u=ib(G,"type"); +if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=X(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F1))if(La)if(!(v.button===1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY, -rb),D=I.x*o;I=I.y*o;var G=qa(ca()),L=x=D/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k0&&b.removeFromSelection(G);L.length>0&&vb(L); -break;case "resize":G=Y(F);L=(E=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var X=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=X*Math.cos(u);u=X*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;X=P}L= -d.createSVGTransform();u=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(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+X,k+aa);if(E){E=S?1:0;G.replaceItem(L,2+E);G.replaceItem(u,1+E);G.replaceItem(P,0+E)}else{E=G.numberOfItems;G.replaceItem(P,E-3);G.replaceItem(u,E-2);G.replaceItem(L,E-1)}Ha.requestSelector(F).resize();N("transition",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)}E=x;C=y;if(v.shiftKey){C=ba(h,m,E,C);E=C.x;C=C.y}G.setAttributeNS(null,"x2",E);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);E=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=E=Math.max(L,E);C=hm?m+k:m-k}if(v.altKey){E=h;C=m;k=Math.abs(x-E);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",E);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(v.shiftKey){if(E=svgedit.path.path){G=E.dragging?E.dragging[0]:h;E=E.dragging?E.dragging[1]:m}else{G=h;E=m}C=ba(G,E,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(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(D,I);break;case "rotate":L=svgedit.utilities.getBBox(F);E=L.x+L.width/ -2;C=L.y+L.height/2;G=W(F);G=O(E,C,G);E=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,E-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,E-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:D,mouse_y:I,selected:F})}}).click(function(v){v.preventDefault(); -return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),D=I.tagName;if(D==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((D==="g"||D==="a")&&oa(I)){Mb(I);I=J[0];Pa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClone=false;window.removeEventListener("keyup",b.removeClone);if(v.button!==2){var F=Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y* -o;var G=D/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");bb.stroke_opacity=D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width"); -bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(D=0;D=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"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=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()}});N("changed",[k]);u=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()}});N("changed",[k]);u=true}break;case "text":u=true;Bb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,D,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u=false;k=null;hb.mouseUp(v,D,I);break;case "rotate":u=true;k=null;Ea="select"; -F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}D=ob("mouseUp",{event:v,mouse_x:D,mouse_y:I},true);$.each(D,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(D=v.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Ea!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&D.id!="svgcanvas"&&D.id!="svgroot"){b.setMode("select");Bb([D],true)}}else if(k!=null){b.addedNew= -true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(E){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&Bb([k],true);ya(new Ca(k));N("changed",[k])},v*1E3)}Ua=null}}});$(a).bind("mousewheel DOMMouseScroll",function(v){if(v.shiftKey){v.preventDefault(); -rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("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);D=qa("text_cursor");if(!D){D=document.createElementNS(c,"line");ma(D,{id:"text_cursor",stroke:"#333","stroke-width":1});D=qa("selectorParentGroup").appendChild(D)}L||(L=setInterval(function(){var ga=D.getAttribute("display")==="none";D.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(D,{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];D.setAttribute("visibility","hidden");X=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.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=O(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=O(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 v(S){if(U&&F){var X=O(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,D,G,L,k=[],u,C,E,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));E=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&&XE-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){U=false;Ea="textedit";Ha.requestSelector(F).showGrips(false);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");D&&$(D).attr("visibility","hidden");$(F).css("cursor","move");if(S){Pa();$(F).css("cursor","move");N("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=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length, -X=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);C=X?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(X=0;X=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I= -this.segs[this.selected_pts[v]];I.select(true);A[v]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);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",fill:"none"}); -F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var D=null;if(w){D=w.pathSegList;for(var G=D.numberOfItems,L=6/o,k=false;G;){G--;var u=D.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=D.numberOfItems;if(k){if(G<=1&&C>=2){I=D.getItem(0).x;v=D.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath(); -D.appendItem(A);D.appendItem(I)}else if(C<3)return D=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}D=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(D-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=D;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true, -attr:{d:d_attr,id:ja(),opacity:M.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];D=svgedit.path.path.segs[v];if(A.shiftKey)D.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v); -else{if(svgedit.path.path.selected_pts.length<=1||!D.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems- -1;if(m){var D=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");D.setAttribute("cx",v);D.setAttribute("cy",F);D.setAttribute("display","inline");D=m[0];var L=m[1];I.getItem(A);var k=D+(D-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:D*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:D*o,y2:L*o,display:"inline"}); -if(A===0)z=[v,F];else{I=I.getItem(A-1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[D,L,v,F,k,u],w)}}else if(D=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],D);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],D):svgedit.path.replacePathSeg(4,1,[v,F],D)}}}else if(svgedit.path.path.dragging){D=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0], -y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-D.x;D=L.y-D.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,D):svgedit.path.path.movePts(A,D)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var E=ta.getBBox(),P=svgedit.path.getGripPt(this);E=svgedit.math.rectsIntersect(E,{x:P.x,y:P.y,width:0,height:0});this.select(E);E&&svgedit.path.path.selected_pts.push(this.index)}})}}, -mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}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";Pa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Pa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("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(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Pa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("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 v=Y(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,D=0;D0){L=I.getItem(D-1).pathSegType;if(L===2){G(D-1,1);F();break}else if(L===1&&I.numberOfItems-1===D){G(D,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 v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),D=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(D)if((I=svgedit.path.smoothControlPoints(D,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,u.x,u.y].join(","));I=u;D=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(K){Jb();Bb([K])}var e= -[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w0&&b.removeFromSelection(G); +L.length>0&&vb(L);break;case "resize":G=X(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra= +P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();N("transition",J);break;case "zoom":L*=o;k*=o;ma(ua, +{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(v.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"||v.shiftKey){L=D=Math.max(L, +D);C=hm?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);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(v.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(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{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(v,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=W(F);G=O(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(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:E, +mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones);if(v.button!==2){var F= +Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[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){v=J.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"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=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()}});N("changed",[k]);u=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()}});N("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u= +false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.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;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.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));N("changed",[k])},v*1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll", +function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value==="";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!== +I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||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));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d", +"")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);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[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}} +function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;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,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(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 v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F= +S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&YD-2&&aaP-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,Y);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");N("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=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F); +C=Y?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]= +I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);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",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 u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+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;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);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,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:M.opacity/ +2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<= +1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"), +G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A- +1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]}, +svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,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=ua.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,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}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(ua&&ua.getAttribute("display")!="none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.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 v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("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(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("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 v=X(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.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 v=A.points,F=v.numberOfItems;if(F>=4){var I=v.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=v.getItem(G),k=v.getItem(G+1),u=v.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,u.x,u.y].join(","));I=u;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(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--){v=A.item(F);G=z(v.nodeValue);if(!(L.indexOf(v.localName)>=0))if(G!="")if(G.indexOf("pointer-events")!==0)if(!(v.localName==="class"&&G.indexOf("se_")===0)){m.push(" ");if(v.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"&&v.localName==="href"&&fb.images&&fb.images==="embed"){var k=Ra[G];if(k)G=k}if(!v.namespaceURI||v.namespaceURI==c||Aa[v.namespaceURI]){m.push(v.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("