From 053b6a87313695661b9eebfd2de679a719b07f95 Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Wed, 4 Jul 2012 09:42:50 -0500 Subject: [PATCH] added zoom with scrollwheel and alt key --- Makefile | 1 + editor/mousewheel.js | 84 +++ editor/svg-editor.html | 1 + editor/svg-editor.js | 41 +- editor/svgedit.compiled.js | 1088 ++++++++++++++++++------------------ 5 files changed, 664 insertions(+), 551 deletions(-) create mode 100644 editor/mousewheel.js diff --git a/Makefile b/Makefile index 7dc42f5..415024d 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ JS_FILES=\ locale/locale.js \ jquery-ui/jquery-ui-1.8.17.custom.min.js \ jgraduate/jpicker.min.js \ + mousewheel.js \ CSS_FILES=\ jgraduate/css/jPicker.css \ diff --git a/editor/mousewheel.js b/editor/mousewheel.js new file mode 100644 index 0000000..f1d5f72 --- /dev/null +++ b/editor/mousewheel.js @@ -0,0 +1,84 @@ +/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) + * Licensed under the MIT License (LICENSE.txt). + * + * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. + * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * Thanks to: Seamus Leahy for adding deltaX and deltaY + * + * Version: 3.0.6 + * + * Requires: 1.2.2+ + */ + +(function($) { + +var types = ['DOMMouseScroll', 'mousewheel']; + +if ($.event.fixHooks) { + for ( var i=types.length; i; ) { + $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; + } +} + +$.event.special.mousewheel = { + setup: function() { + if ( this.addEventListener ) { + for ( var i=types.length; i; ) { + this.addEventListener( types[--i], handler, false ); + } + } else { + this.onmousewheel = handler; + } + }, + + teardown: function() { + if ( this.removeEventListener ) { + for ( var i=types.length; i; ) { + this.removeEventListener( types[--i], handler, false ); + } + } else { + this.onmousewheel = null; + } + } +}; + +$.fn.extend({ + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } +}); + + +function handler(event) { + var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; + event = $.event.fix(orgEvent); + event.type = "mousewheel"; + + // Old school scrollwheel delta + if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; } + if ( orgEvent.detail ) { delta = -orgEvent.detail/3; } + + // New school multidimensional scroll (touchpads) deltas + deltaY = delta; + + // Gecko + if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { + deltaY = 0; + deltaX = -1*delta; + } + + // Webkit + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } + + // Add event and delta to the front of the arguments + args.unshift(event, delta, deltaX, deltaY); + + return ($.event.dispatch || $.event.handle).apply(this, args); +} + +})(jQuery); \ No newline at end of file diff --git a/editor/svg-editor.html b/editor/svg-editor.html index a4677b9..4f8a715 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -48,6 +48,7 @@ + diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 59c7a10..913e2f0 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -2072,8 +2072,26 @@ $('input').blur(); } } + + + $('.menu_item').live('click', function(e){blinker(e)}); $("svg, body").on('click', function(e){closer(e)}); + var accumulatedDelta = 0 + var zoomSteps = [6, 12, 16, 33, 50, 66, 100, 150, 200, 300, 400, 600, 800, 1200] + $('#workarea').on('mousewheel', function(e, delta, deltaX, deltaY){ + if (e.altKey) { + e.preventDefault(); + var currentZoom = svgCanvas.getZoom()*100; + var arr_length = zoomSteps.length; + for (i=0; i 0) zoom = (zoomSteps[i] <= currentZoom) ? zoomSteps[max] : zoom; + if (deltaY < 0) zoom = (zoomSteps[i] < currentZoom) ? zoomSteps[i] : zoom; + } + if (zoom) changeZoom({value: zoom}); + } + }) $('.menu_title').on('click', function() {$("#menu_bar").toggleClass('active');}); $('.menu_title').on('mouseover', function() { menus.removeClass('open'); @@ -2695,6 +2713,13 @@ updateWireFrame(); } + var minimizeModal = function() { + + if (window.self != window.top) { //we're in an iframe + top.exports.setEditorFocus(false); + } + } + var clickRulers = function() { var rulers = !$('#tool_rulers').hasClass('push_button_pressed'); if (rulers) { @@ -4057,7 +4082,7 @@ {key: modKey + 'z', fn: clickUndo}, {key: modKey + 'shift+z', fn: clickRedo}, {key: modKey + 'y', fn: clickRedo}, - + {key: 'esc', fn: minimizeModal}, {key: modKey+'x', fn: cutSelected}, {key: modKey+'c', fn: copySelected}, {key: modKey+'v', fn: pasteInCenter} @@ -4498,13 +4523,13 @@ var title_show = document.getElementById("title_show"); var offset_x = 66; var offset_y = 48; - $("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers", function(e){ - e.stopPropagation(); - ruler_x_cursor.style.left = (e.pageX-offset_x+workarea.scrollLeft) + "px"; - ruler_y_cursor.style.top = (e.pageY-offset_y+workarea.scrollTop) + "px"; - var title = e.target.getAttribute("title"); - if (typeof title != 'undefined' && title) title_show.innerHTML(title); - }) + if (svgedit.browser.isTouch()) { + $("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers", function(e){ + e.stopPropagation(); + ruler_x_cursor.style.left = (e.pageX-offset_x+workarea.scrollLeft) + "px"; + ruler_y_cursor.style.top = (e.pageY-offset_y+workarea.scrollTop) + "px"; + }) + } if(!zoom) zoom = svgCanvas.getZoom(); if(!scanvas) scanvas = $("#svgcanvas"); diff --git a/editor/svgedit.compiled.js b/editor/svgedit.compiled.js index 6911d35..cac4166 100644 --- a/editor/svgedit.compiled.js +++ b/editor/svgedit.compiled.js @@ -1,109 +1,110 @@ -(function(a){function n(f){if(typeof f.data==="string"){var c=f.handler,m=f.data.toLowerCase().split(" ");f.handler=function(p){if(!(this!==p.target&&(/textarea|select/i.test(p.target.nodeName)||p.target.type==="text"))){var b=p.type!=="keypress"&&a.hotkeys.specialKeys[p.which],d=String.fromCharCode(p.which).toLowerCase(),e="",l={};if(p.altKey&&b!=="alt")e+="alt+";if(p.ctrlKey&&b!=="ctrl")e+="ctrl+";if(p.metaKey&&!p.ctrlKey&&b!=="meta")e+="meta+";if(p.shiftKey&&b!=="shift")e+="shift+";if(b)l[e+b]= +(function(a){function n(f){if(typeof f.data==="string"){var c=f.handler,m=f.data.toLowerCase().split(" ");f.handler=function(o){if(!(this!==o.target&&(/textarea|select/i.test(o.target.nodeName)||o.target.type==="text"))){var b=o.type!=="keypress"&&a.hotkeys.specialKeys[o.which],d=String.fromCharCode(o.which).toLowerCase(),e="",l={};if(o.altKey&&b!=="alt")e+="alt+";if(o.ctrlKey&&b!=="ctrl")e+="ctrl+";if(o.metaKey&&!o.ctrlKey&&b!=="meta")e+="meta+";if(o.shiftKey&&b!=="shift")e+="shift+";if(b)l[e+b]= true;else{l[e+d]=true;l[e+a.hotkeys.shiftNums[d]]=true;if(e==="shift+")l[a.hotkeys.shiftNums[d]]=true}b=0;for(d=m.length;b","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:n}})})(jQuery);(function(a,n){function f(ba){return typeof ba==="string"}function c(ba){var S=e.call(arguments,1);return function(){return ba.apply(this,S.concat(e.call(arguments)))}}function m(ba,S,U,ra,la){var ma;if(ra!==d){S=U.match(ba?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);U=S[3]||"";if(la===2&&f(ra))ra=ra.replace(ba?ea:ca,"");else{ma=o(S[2]);ra=f(ra)?o[ba?fa:O](ra):ra;ra=la===2?ra:la===1?a.extend({},ra,ma):a.extend({},ma,ra);ra=u(ra);if(ba)ra=ra.replace(qa,l)}ba=S[1]+(ba?"#":ra||!S[1]?"?":"")+ra+U}else ba= -S(U!==d?U:n[sa][ja]);return ba}function p(ba,S,U){if(S===d||typeof S==="boolean"){U=S;S=u[ba?fa:O]()}else S=f(S)?S.replace(ba?ea:ca,""):S;return o(S,U)}function b(ba,S,U,ra){if(!f(U)&&typeof U!=="object"){ra=U;U=S;S=d}return this.each(function(){var la=a(this),ma=S||da()[(this.nodeName||"").toLowerCase()]||"",Y=ma&&la.attr(ma)||"";la.attr(ma,u[ba](Y,U,ra))})}var d,e=Array.prototype.slice,l=decodeURIComponent,u=a.param,z,o,L,T=a.bbq=a.bbq||{},N,J,da,V=a.event.special,O="querystring",fa="fragment", -sa="location",ja="href",ca=/^.*\?|#.*$/g,ea=/^.*\#/,qa,pa={};u[O]=c(m,0,function(ba){return ba.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});u[fa]=z=c(m,1,function(ba){return ba.replace(/^[^#]*#?(.*)$/,"$1")});z.noEscape=function(ba){ba=ba||"";ba=a.map(ba.split(""),encodeURIComponent);qa=RegExp(ba.join("|"),"g")};z.noEscape(",/");a.deparam=o=function(ba,S){var U={},ra={"true":true,"false":false,"null":null};a.each(ba.replace(/\+/g," ").split("&"),function(la,ma){var Y=ma.split("="),za=l(Y[0]),Ia=U, -Qa=0,La=za.split("]["),Ua=La.length-1;if(/\[/.test(La[0])&&/\]$/.test(La[Ua])){La[Ua]=La[Ua].replace(/\]$/,"");La=La.shift().split("[").concat(La);Ua=La.length-1}else Ua=0;if(Y.length===2){Y=l(Y[1]);if(S)Y=Y&&!isNaN(Y)?+Y:Y==="undefined"?d:ra[Y]!==d?ra[Y]:Y;if(Ua)for(;Qa<=Ua;Qa++){za=La[Qa]===""?Ia.length:La[Qa];Ia=Ia[za]=Qa').hide().insertAfter("body")[0].contentWindow; -J=function(){return c(T.document[b][d])};N=function(da,V){if(da!==V){var O=T.document;O.open().close();O[b].hash="#"+da}};N(c())}}var o={},L,T,N,J;o.start=function(){if(!L){var da=c();N||z();(function V(){var O=c(),fa=J(da);if(O!==da){N(da=O,fa);a(n).trigger("hashchange")}else if(fa!==da)n[b][d]=n[b][d].replace(/#.*/,"")+"#"+fa;L=setTimeout(V,a.hashchangeDelay)})()}};o.stop=function(){if(!T){L&&clearTimeout(L);L=0}};return o}()})(jQuery,this);(function(a){var n={},f;a.svgIcons=function(c,m){function p(ba,S){if(ba!=="ajax"){if(da)return;var U=(T=ja[0].contentDocument)&&T.getElementById("svg_eof");if(!U&&!(S&&U)){V++;if(V<50)setTimeout(p,20);else{d();da=true}return}da=true}L=a(T.firstChild).children();if(m.no_img)setTimeout(function(){J||b()},500);else{U=sa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";N=a(new Image).attr({src:U,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} -function b(ba,S){if(!J){if(m.no_img)ba=false;if(ba){var U=a(document.createElement("div"));U.hide().appendTo("body")}if(S){var ra=m.fallback_path?m.fallback_path:"";a.each(S,function(Ua,Wa){a("#"+Ua);var Ma=a(new Image).attr({"class":"svg_icon",src:ra+Wa,width:z,height:o,alt:"icon"});pa(Ma,Ua)})}else for(var la=L.length,ma=0;ma0&&!ba)Ga=f(Ga,Ma,true);qa(a(this),Ga,Wa)})});if(!S){ba&&U.remove();ja&&ja.remove();N&&N.remove()}m.resize&&a.resizeSvgIcons(m.resize);J=true;m.callback&&m.callback(n)}}function d(){if(c.indexOf(".svgz")!=-1){var ba=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(ba,m)}else m.fallback&&b(false,m.fallback)}function e(ba){if(window.btoa)return window.btoa(ba); -var S=Array(Math.floor((ba.length+2)/3)*4),U,ra,la,ma,Y,za,Ia=0,Qa=0;do{U=ba.charCodeAt(Ia++);ra=ba.charCodeAt(Ia++);la=ba.charCodeAt(Ia++);ma=U>>2;U=(U&3)<<4|ra>>4;Y=(ra&15)<<2|la>>6;za=la&63;if(isNaN(ra))Y=za=64;else if(isNaN(la))za=64;S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(U);S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Y);S[Qa++]= -"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(za)}while(Ia-1&&O.indexOf("Chrome/");var sa="data:image/svg+xml;charset=utf-8;base64,";if(m.svgz){var ja=a('').appendTo("body").hide();try{T=ja[0].contentDocument;ja.load(p); -p(0,true)}catch(ca){d()}}else{var ea=new DOMParser;a.ajax({url:c,dataType:"string",success:function(ba){if(ba){T=ea.parseFromString(ba,"text/xml");a(function(){p("ajax")})}else a(d)},error:function(ba){if(window.opera)a(function(){d()});else if(ba.responseText){T=ea.parseFromString(ba.responseText,"text/xml");T.childNodes.length||a(d);a(function(){p("ajax")})}else a(d)}})}var qa=function(ba,S,U,ra){fa&&S.css("visibility","hidden");if(m.replace){ra&&S.attr("id",U);(U=ba.attr("class"))&&S.attr("class", +106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:n}})})(jQuery);(function(a,n){function f(ba){return typeof ba==="string"}function c(ba){var S=e.call(arguments,1);return function(){return ba.apply(this,S.concat(e.call(arguments)))}}function m(ba,S,U,ra,la){var ma;if(ra!==d){S=U.match(ba?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);U=S[3]||"";if(la===2&&f(ra))ra=ra.replace(ba?ea:ca,"");else{ma=p(S[2]);ra=f(ra)?p[ba?fa:O](ra):ra;ra=la===2?ra:la===1?a.extend({},ra,ma):a.extend({},ma,ra);ra=u(ra);if(ba)ra=ra.replace(qa,l)}ba=S[1]+(ba?"#":ra||!S[1]?"?":"")+ra+U}else ba= +S(U!==d?U:n[sa][ia]);return ba}function o(ba,S,U){if(S===d||typeof S==="boolean"){U=S;S=u[ba?fa:O]()}else S=f(S)?S.replace(ba?ea:ca,""):S;return p(S,U)}function b(ba,S,U,ra){if(!f(U)&&typeof U!=="object"){ra=U;U=S;S=d}return this.each(function(){var la=a(this),ma=S||da()[(this.nodeName||"").toLowerCase()]||"",Y=ma&&la.attr(ma)||"";la.attr(ma,u[ba](Y,U,ra))})}var d,e=Array.prototype.slice,l=decodeURIComponent,u=a.param,z,p,L,T=a.bbq=a.bbq||{},N,K,da,V=a.event.special,O="querystring",fa="fragment", +sa="location",ia="href",ca=/^.*\?|#.*$/g,ea=/^.*\#/,qa,pa={};u[O]=c(m,0,function(ba){return ba.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});u[fa]=z=c(m,1,function(ba){return ba.replace(/^[^#]*#?(.*)$/,"$1")});z.noEscape=function(ba){ba=ba||"";ba=a.map(ba.split(""),encodeURIComponent);qa=RegExp(ba.join("|"),"g")};z.noEscape(",/");a.deparam=p=function(ba,S){var U={},ra={"true":true,"false":false,"null":null};a.each(ba.replace(/\+/g," ").split("&"),function(la,ma){var Y=ma.split("="),za=l(Y[0]),Ka=U, +Qa=0,Ma=za.split("]["),Sa=Ma.length-1;if(/\[/.test(Ma[0])&&/\]$/.test(Ma[Sa])){Ma[Sa]=Ma[Sa].replace(/\]$/,"");Ma=Ma.shift().split("[").concat(Ma);Sa=Ma.length-1}else Sa=0;if(Y.length===2){Y=l(Y[1]);if(S)Y=Y&&!isNaN(Y)?+Y:Y==="undefined"?d:ra[Y]!==d?ra[Y]:Y;if(Sa)for(;Qa<=Sa;Qa++){za=Ma[Qa]===""?Ka.length:Ma[Qa];Ka=Ka[za]=Qa').hide().insertAfter("body")[0].contentWindow; +K=function(){return c(T.document[b][d])};N=function(da,V){if(da!==V){var O=T.document;O.open().close();O[b].hash="#"+da}};N(c())}}var p={},L,T,N,K;p.start=function(){if(!L){var da=c();N||z();(function V(){var O=c(),fa=K(da);if(O!==da){N(da=O,fa);a(n).trigger("hashchange")}else if(fa!==da)n[b][d]=n[b][d].replace(/#.*/,"")+"#"+fa;L=setTimeout(V,a.hashchangeDelay)})()}};p.stop=function(){if(!T){L&&clearTimeout(L);L=0}};return p}()})(jQuery,this);(function(a){var n={},f;a.svgIcons=function(c,m){function o(ba,S){if(ba!=="ajax"){if(da)return;var U=(T=ia[0].contentDocument)&&T.getElementById("svg_eof");if(!U&&!(S&&U)){V++;if(V<50)setTimeout(o,20);else{d();da=true}return}da=true}L=a(T.firstChild).children();if(m.no_img)setTimeout(function(){K||b()},500);else{U=sa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";N=a(new Image).attr({src:U,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}} +function b(ba,S){if(!K){if(m.no_img)ba=false;if(ba){var U=a(document.createElement("div"));U.hide().appendTo("body")}if(S){var ra=m.fallback_path?m.fallback_path:"";a.each(S,function(Sa,Ya){a("#"+Sa);var Na=a(new Image).attr({"class":"svg_icon",src:ra+Ya,width:z,height:p,alt:"icon"});pa(Na,Sa)})}else for(var la=L.length,ma=0;ma0&&!ba)Ia=f(Ia,Na,true);qa(a(this),Ia,Ya)})});if(!S){ba&&U.remove();ia&&ia.remove();N&&N.remove()}m.resize&&a.resizeSvgIcons(m.resize);K=true;m.callback&&m.callback(n)}}function d(){if(c.indexOf(".svgz")!=-1){var ba=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(ba,m)}else m.fallback&&b(false,m.fallback)}function e(ba){if(window.btoa)return window.btoa(ba); +var S=Array(Math.floor((ba.length+2)/3)*4),U,ra,la,ma,Y,za,Ka=0,Qa=0;do{U=ba.charCodeAt(Ka++);ra=ba.charCodeAt(Ka++);la=ba.charCodeAt(Ka++);ma=U>>2;U=(U&3)<<4|ra>>4;Y=(ra&15)<<2|la>>6;za=la&63;if(isNaN(ra))Y=za=64;else if(isNaN(la))za=64;S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(U);S[Qa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Y);S[Qa++]= +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(za)}while(Ka-1&&O.indexOf("Chrome/");var sa="data:image/svg+xml;charset=utf-8;base64,";if(m.svgz){var ia=a('').appendTo("body").hide();try{T=ia[0].contentDocument;ia.load(o); +o(0,true)}catch(ca){d()}}else{var ea=new DOMParser;a.ajax({url:c,dataType:"string",success:function(ba){if(ba){T=ea.parseFromString(ba,"text/xml");a(function(){o("ajax")})}else a(d)},error:function(ba){if(window.opera)a(function(){d()});else if(ba.responseText){T=ea.parseFromString(ba.responseText,"text/xml");T.childNodes.length||a(d);a(function(){o("ajax")})}else a(d)}})}var qa=function(ba,S,U,ra){fa&&S.css("visibility","hidden");if(m.replace){ra&&S.attr("id",U);(U=ba.attr("class"))&&S.attr("class", "svg_icon "+U);ba.replaceWith(S)}else ba.append(S);fa&&setTimeout(function(){S.removeAttr("style")},1)},pa=function(ba,S){if(m.id_match===undefined||m.id_match!==false)qa(holder,ba,S,true);n[S]=ba};f=function(ba,S){var U=ba.find("defs");if(!U.length)return ba;U=fa?U.find("*").filter(function(){return!!this.id}):U.find("[id]");var ra=ba[0].getElementsByTagName("*"),la=ra.length;U.each(function(ma){var Y=this.id;a(T).find("#"+Y);this.id=ma="x"+Y+S+ma;Y="url(#"+Y+")";var za="url(#"+ma+")";for(ma=0;ma< -la;ma++){var Ia=ra[ma];Ia.getAttribute("fill")===Y&&Ia.setAttribute("fill",za);Ia.getAttribute("stroke")===Y&&Ia.setAttribute("stroke",za);Ia.getAttribute("filter")===Y&&Ia.setAttribute("filter",za)}});return ba}};a.getSvgIcon=function(c,m){var p=n[c];if(m&&p)p=f(p,0,true).clone(true);return p};a.resizeSvgIcons=function(c){var m=!a(".svg_icon:first").length;a.each(c,function(p,b){var d=a.isArray(b),e=d?b[0]:b,l=d?b[1]:b;if(m)p=p.replace(/\.svg_icon/g,"svg");a(p).each(function(){this.setAttribute("width", -e);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=e+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(c,m,p){c=document.createElementNS(n.svg,c);if(f)for(var b in m)c.setAttribute(b,m[b]);else for(b in m){var d=m[b],e=c[b];if(e&&e.constructor==="SVGLength")e.baseVal.value=d;else c.setAttribute(b,d)}p&&p.appendChild(c);return c}var n={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(c){c=c||{};this.alpha=isNaN(c.alpha)?100:c.alpha;if(c.copy){this.type= +la;ma++){var Ka=ra[ma];Ka.getAttribute("fill")===Y&&Ka.setAttribute("fill",za);Ka.getAttribute("stroke")===Y&&Ka.setAttribute("stroke",za);Ka.getAttribute("filter")===Y&&Ka.setAttribute("filter",za)}});return ba}};a.getSvgIcon=function(c,m){var o=n[c];if(m&&o)o=f(o,0,true).clone(true);return o};a.resizeSvgIcons=function(c){var m=!a(".svg_icon:first").length;a.each(c,function(o,b){var d=a.isArray(b),e=d?b[0]:b,l=d?b[1]:b;if(m)o=o.replace(/\.svg_icon/g,"svg");a(o).each(function(){this.setAttribute("width", +e);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=e+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(c,m,o){c=document.createElementNS(n.svg,c);if(f)for(var b in m)c.setAttribute(b,m[b]);else for(b in m){var d=m[b],e=c[b];if(e&&e.constructor==="SVGLength")e.baseVal.value=d;else c.setAttribute(b,d)}o&&o.appendChild(c);return c}var n={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(c){c=c||{};this.alpha=isNaN(c.alpha)?100:c.alpha;if(c.copy){this.type= c.copy.type;this.alpha=c.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=c.copy.solidColor;break;case "linearGradient":this.linearGradient=c.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=c.copy.radialGradient.cloneNode(true)}}else if(c.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=c.linearGradient.cloneNode(true)}else if(c.radialGradient){this.type= "radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=c.radialGradient.cloneNode(true)}else if(c.solidColor){this.type="solidColor";this.solidColor=c.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var f=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(c){var m= -arguments;return this.each(function(){function p(na,Z,ta,M,I){var X=I||a("stop",{"stop-color":Z,"stop-opacity":ta,offset:na},ea);if(I){Z=I.getAttribute("stop-color");ta=I.getAttribute("stop-opacity");na=I.getAttribute("offset")}else ea.appendChild(X);if(ta===null)ta=1;I=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+na*fa)+", 26)"},Gb);var Na= -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:Z,"fill-opacity":ta,transform:"translate("+(10+na*fa)+", 26)",stroke:"#000","stroke-width":1.5},Gb);$(Na).mousedown(function(Xa){b(this);Sa=lb;da.mousemove(l).mouseup(d);Ea=Nb.offset();Xa.preventDefault();return false}).data("stop",X).data("bg",I).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Xa=this,db=+X.getAttribute("stop-opacity")|| -1,tb=X.getAttribute("stop-color")||1,xb=(parseFloat(db)*255).toString(16);xb.length<2;)xb="0"+xb;Z=tb.substr(1)+xb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:z.images.clientPath},color:{active:Z,alphaSupport:true}},function(Hb){tb=Hb.val("hex")?"#"+Hb.val("hex"):"none";db=Hb.val("a")!==null?Hb.val("a")/256:1;Xa.setAttribute("fill",tb);Xa.setAttribute("fill-opacity",db);X.setAttribute("stop-color", -tb);X.setAttribute("stop-opacity",db);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(ea).find("stop").each(function(){var Xa=$(this);if(+this.getAttribute("offset")>na){if(!Z){var db=this.getAttribute("stop-color"),tb=this.getAttribute("stop-opacity");X.setAttribute("stop-color",db);Na.setAttribute("fill",db);X.setAttribute("stop-opacity",tb===null?1:tb);Na.setAttribute("fill-opacity", -tb===null?1:tb)}Xa.before(X);return false}});M&&b(Na);return X}function b(na){lb&&lb.setAttribute("stroke","#000");na.setAttribute("stroke","blue");lb=na;lb.parentNode.appendChild(lb)}function d(){da.unbind("mousemove",l);if(Ja.getAttribute("display")!=="none"){Ja.setAttribute("display","none");var na=$(lb),Z=na.data("stop");na=na.data("bg");$([lb,Z,na]).remove()}Sa=null}function e(){var na=$a?"rotate("+$a+","+Ka+","+mb+") ":"";Za===1&&Ra===1?ea.removeAttribute("gradientTransform"):ea.setAttribute("gradientTransform", -na+"translate("+-Ka*(Za-1)+","+-mb*(Ra-1)+") scale("+Za+","+Ra+")")}function l(na){var Z=na.pageX-Ea.left;na=na.pageY-Ea.top;Z=Z<10?10:Z>fa+10?fa+10:Z;var ta="translate("+Z+", 26)";if(na<-60||na>130){Ja.setAttribute("display","block");Ja.setAttribute("transform",ta)}else Ja.setAttribute("display","none");Sa.setAttribute("transform",ta);$.data(Sa,"bg").setAttribute("transform",ta);$.data(Sa,"stop").setAttribute("offset",(Z-10)/fa);var M=0;$(ea).find("stop").each(function(){var I=this.getAttribute("offset"), -X=$(this);if(I
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var V=$(L+"> .jGraduate_colPick"),O=$(L+"> .jGraduate_gradPick");O.html('

    '+z.window.pickerTitle+'


    ');var fa=256,sa=fa-0,ja=fa-0,ca,ea,qa,pa={};$(".jGraduate_SliderBar").width(145);var ba=$("#"+o+"_jGraduate_GradContainer")[0],S=a("svg",{id:o+"_jgraduate_svg",width:fa,height:fa,xmlns:n.svg},ba);ca=ca||u.paint.type;var U=ea=u.paint[ca],ra=u.paint.alpha,la=ca==="solidColor";switch(ca){case "solidColor":case "linearGradient":if(!la){ea.id=o+"_lg_jgraduate_grad"; -U=ea=S.appendChild(ea)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},S);if(ca==="linearGradient")break;case "radialGradient":if(!la){ea.id=o+"_rg_jgraduate_grad";U=ea=S.appendChild(ea)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},S)}if(la){U=ea=$("#"+o+"_lg_jgraduate_grad")[0];J=u.paint[ca];p(0,"#"+J,1);var ma=typeof z.newstop;if(ma==="string")switch(z.newstop){case "same":p(1,"#"+J,1);break;case "inverse":ma="";for(var Y=0;Y<6;Y+=2){J.substr(Y,2);var za=(255-parseInt(J.substr(Y,2),16)).toString(16); -if(za.length<2)za=0+za;ma+=za}p(1,"#"+ma,1);break;case "white":p(1,"#ffffff",1);break;case "black":p(1,"#000000",1)}else if(ma==="object")p(1,z.newstop.color||"#"+J,"opac"in z.newstop?z.newstop.opac:1)}J=parseFloat(U.getAttribute("x1")||0);ma=parseFloat(U.getAttribute("y1")||0);Y=parseFloat(U.getAttribute("x2")||1);za=parseFloat(U.getAttribute("y2")||0);var Ia=parseFloat(U.getAttribute("cx")||0.5),Qa=parseFloat(U.getAttribute("cy")||0.5),La=parseFloat(U.getAttribute("fx")||Ia),Ua=parseFloat(U.getAttribute("fy")|| -Qa);qa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:sa,height:ja,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":ra/100},S);var Wa=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*fa,left:J*fa}).data("coord","start").appendTo(ba),Ma=Wa.clone().text(2).css({top:za*fa,left:Y*fa}).attr("title","End stop").data("coord","end").appendTo(ba),Ga=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Qa*fa,left:Ia* -fa}).data("coord","center").appendTo(ba),Oa=Ga.clone().text("F").css({top:Ua*fa,left:La*fa,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ba);Oa[0].id=o+"_jGraduate_focusCoord";$(L+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(na,Z){var ta=ea.getAttribute(Z),M=isNaN(Z[1]);ta||(ta=M?"0.5":Z==="x2"?"1.0":"0.0");pa[Z]=$("#"+o+"_jGraduate_"+Z).val(ta).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value> -1)this.value=1;if(!(Z[0]==="f"&&!nb))if(M&&ca==="radialGradient"||!M&&ca==="linearGradient")ea.setAttribute(Z,this.value);var I=M?Z[0]==="c"?Ga:Oa:Z[1]==="1"?Wa:Ma,X=Z.indexOf("x")>=0?"left":"top";I.css(X,this.value*fa)}).change()});var Fa,Gb,Nb=$("#"+o+"_jGraduate_StopSlider"),lb,ab,Sa,Ja=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},ab),Ea,Za=1,Ra=1,$a=0,Ka=Ia,mb=Qa;ab=a("svg",{width:"100%",height:45},Nb[0]);ba=a("pattern",{width:16, -height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ab);a("image",{width:16,height:16},ba).setAttributeNS(n.xlink,"xlink:href",z.images.clientPath+"map-opacity.png");$(ab).click(function(na){Ea=Nb.offset();if(na.target.tagName!=="path"){var Z=na.pageX-Ea.left-8;Z=Z<10?10:Z>fa+10?fa+10:Z;p(Z/fa,0,0,true);na.stopPropagation()}});$(ab).mouseover(function(){ab.appendChild(Ja)});Gb=a("g",{},ab);a("line",{x1:10,y1:15,x2:fa+10,y2:15,"stroke-width":2,stroke:"#000"},ab);var Ab=O.find(".jGraduate_spreadMethod").change(function(){ea.setAttribute("spreadMethod", -$(this).val())}),cb=null,jb=function(na){var Z=na.pageX-wb.left,ta=na.pageY-wb.top;Z=Z<0?0:Z>fa?fa:Z;ta=ta<0?0:ta>fa?fa:ta;cb.css("left",Z).css("top",ta);Z/=sa;ta/=ja;var M=cb.data("coord"),I=ea;switch(M){case "start":pa.x1.val(Z);pa.y1.val(ta);I.setAttribute("x1",Z);I.setAttribute("y1",ta);break;case "end":pa.x2.val(Z);pa.y2.val(ta);I.setAttribute("x2",Z);I.setAttribute("y2",ta);break;case "center":pa.cx.val(Z);pa.cy.val(ta);I.setAttribute("cx",Z);I.setAttribute("cy",ta);Ka=Z;mb=ta;e();break;case "focus":pa.fx.val(Z); -pa.fy.val(ta);I.setAttribute("fx",Z);I.setAttribute("fy",ta);e()}na.preventDefault()},kb=function(){cb=null;da.unbind("mousemove",jb).unbind("mouseup",kb)};Fa=ea.getElementsByTagNameNS(n.svg,"stop");if(Ca<2){for(;Ca<2;){ea.appendChild(document.createElementNS(n.svg,"stop"));++Ca}Fa=ea.getElementsByTagNameNS(n.svg,"stop")}var Ca=Fa.length;for(Y=0;Y99.5)M=99.5;if(M>0)Ra=1-M/100;else Za=-(M/100)-1;I=145*((M+100)/2)/100;X&&e();break;case "angle":$a=M;I=$a/180;I+=0.5;I*=145;X&&e()}if(I>145)I=145;else if(I<0)I=0;ta.css({"margin-left":I-5})}).change()});var Cb=function(na){var Z=na.pageX- -ob.offset.left-parseInt(ob.parent.css("border-left-width"));if(Z>145)Z=145;if(Z<=0)Z=0;var ta=Z-5;Z/=145;switch(ob.type){case "radius":Z=Math.pow(Z*2,2.5);if(Z>0.98&&Z<1.02)Z=1;if(Z<=0.01)Z=0.01;ea.setAttribute("r",Z);break;case "opacity":u.paint.alpha=parseInt(Z*100);qa.setAttribute("fill-opacity",Z);break;case "ellip":Ra=Za=1;if(Z<0.5){Z/=0.5;Za=Z<=0?0.01:Z}else if(Z>0.5){Z/=0.5;Z=2-Z;Ra=Z<=0?0.01:Z}e();Z-=1;if(Ra===Z+1)Z=Math.abs(Z);break;case "angle":Z-=0.5;$a=Z*=180;e();Z/=100}ob.elem.css({"margin-left":ta}); -Z=Math.round(Z*100);ob.input.val(Z);na.preventDefault()},Kb=function(){da.unbind("mousemove",Cb).unbind("mouseup",Kb);ob=null};for(O=(u.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=u.paint.solidColor=="none"?"":u.paint.solidColor+O;la||(J=Fa[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:z.window.pickerTitle},images:{clientPath:z.images.clientPath},color:{active:J,alphaSupport:true}}, -function(na){u.paint.type="solidColor";u.paint.alpha=na.val("ahex")?Math.round(na.val("a")/255*100):100;u.paint.solidColor=na.val("hex")?na.val("hex"):"none";u.paint.radialGradient=null;T()},null,function(){N()});var Ib=$(L+" .jGraduate_tabs li");Ib.click(function(){Ib.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current");$(L+" > div").hide();var na=$(this).attr("data-type");$(L+" .jGraduate_gradPick").show();if(na==="rg"||na==="lg"){$(".jGraduate_"+na+"_field").show();$(".jGraduate_"+ -(na==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+na+"_jgraduate_grad)");ca=na==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(u.paint.alpha).change();var Z=$("#"+o+"_"+na+"_jgraduate_grad")[0];if(ea!==Z){var ta=$(ea).find("stop");$(Z).empty().append(ta);ea=Z;Z=Ab.val();ea.setAttribute("spreadMethod",Z)}nb=na==="rg"&&ea.getAttribute("fx")!=null&&!(Ia==La&&Qa==Ua);$("#"+o+"_jGraduate_focusCoord").toggle(nb);if(nb)$("#"+ -o+"_jGraduate_match_ctr")[0].checked=false}else{$(L+" .jGraduate_gradPick").hide();$(L+" .jGraduate_colPick").show()}});$(L+" > div").hide();Ib.removeClass("jGraduate_tab_current");var Rb;switch(u.paint.type){case "linearGradient":Rb=$(L+" .jGraduate_tab_lingrad");break;case "radialGradient":Rb=$(L+" .jGraduate_tab_radgrad");break;default:Rb=$(L+" .jGraduate_tab_color")}u.show();setTimeout(function(){Rb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();$.fn.SpinButton=function(a){function n(f,c){for(var m=f[c],p=document.body;(f=f.offsetParent)&&f!=p;)if(!$.browser.msie||f.currentStyle.position!="relative")m+=f[c];return m}return this.each(function(){this.repeating=false;this.spinCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&a.step?Number(a.step):1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,upClass:a&&a.upClass?a.upClass:"up",downClass:a&&a.downClass? +arguments;return this.each(function(){function o(na,aa,ta,M,I){var X=I||a("stop",{"stop-color":aa,"stop-opacity":ta,offset:na},ea);if(I){aa=I.getAttribute("stop-color");ta=I.getAttribute("stop-opacity");na=I.getAttribute("offset")}else ea.appendChild(X);if(ta===null)ta=1;I=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+na*fa)+", 26)"},Gb);var Oa= +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:aa,"fill-opacity":ta,transform:"translate("+(10+na*fa)+", 26)",stroke:"#000","stroke-width":1.5},Gb);$(Oa).mousedown(function(Wa){b(this);Xa=ob;da.mousemove(l).mouseup(d);Fa=Pb.offset();Wa.preventDefault();return false}).data("stop",X).data("bg",I).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Wa=this,fb=+X.getAttribute("stop-opacity")|| +1,tb=X.getAttribute("stop-color")||1,wb=(parseFloat(fb)*255).toString(16);wb.length<2;)wb="0"+wb;aa=tb.substr(1)+wb;$("#"+p+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:z.images.clientPath},color:{active:aa,alphaSupport:true}},function(Hb){tb=Hb.val("hex")?"#"+Hb.val("hex"):"none";fb=Hb.val("a")!==null?Hb.val("a")/256:1;Wa.setAttribute("fill",tb);Wa.setAttribute("fill-opacity",fb);X.setAttribute("stop-color", +tb);X.setAttribute("stop-opacity",fb);$("div.jGraduate_LightBox").hide();$("#"+p+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+p+"_jGraduate_stopPicker").hide()})});$(ea).find("stop").each(function(){var Wa=$(this);if(+this.getAttribute("offset")>na){if(!aa){var fb=this.getAttribute("stop-color"),tb=this.getAttribute("stop-opacity");X.setAttribute("stop-color",fb);Oa.setAttribute("fill",fb);X.setAttribute("stop-opacity",tb===null?1:tb);Oa.setAttribute("fill-opacity", +tb===null?1:tb)}Wa.before(X);return false}});M&&b(Oa);return X}function b(na){ob&&ob.setAttribute("stroke","#000");na.setAttribute("stroke","blue");ob=na;ob.parentNode.appendChild(ob)}function d(){da.unbind("mousemove",l);if(La.getAttribute("display")!=="none"){La.setAttribute("display","none");var na=$(ob),aa=na.data("stop");na=na.data("bg");$([ob,aa,na]).remove()}Xa=null}function e(){var na=$a?"rotate("+$a+","+Ja+","+pb+") ":"";Za===1&&Ra===1?ea.removeAttribute("gradientTransform"):ea.setAttribute("gradientTransform", +na+"translate("+-Ja*(Za-1)+","+-pb*(Ra-1)+") scale("+Za+","+Ra+")")}function l(na){var aa=na.pageX-Fa.left;na=na.pageY-Fa.top;aa=aa<10?10:aa>fa+10?fa+10:aa;var ta="translate("+aa+", 26)";if(na<-60||na>130){La.setAttribute("display","block");La.setAttribute("transform",ta)}else La.setAttribute("display","none");Xa.setAttribute("transform",ta);$.data(Xa,"bg").setAttribute("transform",ta);$.data(Xa,"stop").setAttribute("offset",(aa-10)/fa);var M=0;$(ea).find("stop").each(function(){var I=this.getAttribute("offset"), +X=$(this);if(I
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var V=$(L+"> .jGraduate_colPick"),O=$(L+"> .jGraduate_gradPick");O.html('

    '+z.window.pickerTitle+'


    ');var fa=256,sa=fa-0,ia=fa-0,ca,ea,qa,pa={};$(".jGraduate_SliderBar").width(145);var ba=$("#"+p+"_jGraduate_GradContainer")[0],S=a("svg",{id:p+"_jgraduate_svg",width:fa,height:fa,xmlns:n.svg},ba);ca=ca||u.paint.type;var U=ea=u.paint[ca],ra=u.paint.alpha,la=ca==="solidColor";switch(ca){case "solidColor":case "linearGradient":if(!la){ea.id=p+"_lg_jgraduate_grad"; +U=ea=S.appendChild(ea)}a("radialGradient",{id:p+"_rg_jgraduate_grad"},S);if(ca==="linearGradient")break;case "radialGradient":if(!la){ea.id=p+"_rg_jgraduate_grad";U=ea=S.appendChild(ea)}a("linearGradient",{id:p+"_lg_jgraduate_grad"},S)}if(la){U=ea=$("#"+p+"_lg_jgraduate_grad")[0];K=u.paint[ca];o(0,"#"+K,1);var ma=typeof z.newstop;if(ma==="string")switch(z.newstop){case "same":o(1,"#"+K,1);break;case "inverse":ma="";for(var Y=0;Y<6;Y+=2){K.substr(Y,2);var za=(255-parseInt(K.substr(Y,2),16)).toString(16); +if(za.length<2)za=0+za;ma+=za}o(1,"#"+ma,1);break;case "white":o(1,"#ffffff",1);break;case "black":o(1,"#000000",1)}else if(ma==="object")o(1,z.newstop.color||"#"+K,"opac"in z.newstop?z.newstop.opac:1)}K=parseFloat(U.getAttribute("x1")||0);ma=parseFloat(U.getAttribute("y1")||0);Y=parseFloat(U.getAttribute("x2")||1);za=parseFloat(U.getAttribute("y2")||0);var Ka=parseFloat(U.getAttribute("cx")||0.5),Qa=parseFloat(U.getAttribute("cy")||0.5),Ma=parseFloat(U.getAttribute("fx")||Ka),Sa=parseFloat(U.getAttribute("fy")|| +Qa);qa=a("rect",{id:p+"_jgraduate_rect",x:0,y:0,width:sa,height:ia,fill:"url(#"+p+"_jgraduate_grad)","fill-opacity":ra/100},S);var Ya=$("
    ").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*fa,left:K*fa}).data("coord","start").appendTo(ba),Na=Ya.clone().text(2).css({top:za*fa,left:Y*fa}).attr("title","End stop").data("coord","end").appendTo(ba),Ia=$("
    ").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Qa*fa,left:Ka* +fa}).data("coord","center").appendTo(ba),Pa=Ia.clone().text("F").css({top:Sa*fa,left:Ma*fa,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ba);Pa[0].id=p+"_jGraduate_focusCoord";$(L+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(na,aa){var ta=ea.getAttribute(aa),M=isNaN(aa[1]);ta||(ta=M?"0.5":aa==="x2"?"1.0":"0.0");pa[aa]=$("#"+p+"_jGraduate_"+aa).val(ta).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value> +1)this.value=1;if(!(aa[0]==="f"&&!mb))if(M&&ca==="radialGradient"||!M&&ca==="linearGradient")ea.setAttribute(aa,this.value);var I=M?aa[0]==="c"?Ia:Pa:aa[1]==="1"?Ya:Na,X=aa.indexOf("x")>=0?"left":"top";I.css(X,this.value*fa)}).change()});var Ga,Gb,Pb=$("#"+p+"_jGraduate_StopSlider"),ob,ab,Xa,La=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},ab),Fa,Za=1,Ra=1,$a=0,Ja=Ka,pb=Qa;ab=a("svg",{width:"100%",height:45},Pb[0]);ba=a("pattern",{width:16, +height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ab);a("image",{width:16,height:16},ba).setAttributeNS(n.xlink,"xlink:href",z.images.clientPath+"map-opacity.png");$(ab).click(function(na){Fa=Pb.offset();if(na.target.tagName!=="path"){var aa=na.pageX-Fa.left-8;aa=aa<10?10:aa>fa+10?fa+10:aa;o(aa/fa,0,0,true);na.stopPropagation()}});$(ab).mouseover(function(){ab.appendChild(La)});Gb=a("g",{},ab);a("line",{x1:10,y1:15,x2:fa+10,y2:15,"stroke-width":2,stroke:"#000"},ab);var Cb=O.find(".jGraduate_spreadMethod").change(function(){ea.setAttribute("spreadMethod", +$(this).val())}),db=null,hb=function(na){var aa=na.pageX-xb.left,ta=na.pageY-xb.top;aa=aa<0?0:aa>fa?fa:aa;ta=ta<0?0:ta>fa?fa:ta;db.css("left",aa).css("top",ta);aa/=sa;ta/=ia;var M=db.data("coord"),I=ea;switch(M){case "start":pa.x1.val(aa);pa.y1.val(ta);I.setAttribute("x1",aa);I.setAttribute("y1",ta);break;case "end":pa.x2.val(aa);pa.y2.val(ta);I.setAttribute("x2",aa);I.setAttribute("y2",ta);break;case "center":pa.cx.val(aa);pa.cy.val(ta);I.setAttribute("cx",aa);I.setAttribute("cy",ta);Ja=aa;pb=ta; +e();break;case "focus":pa.fx.val(aa);pa.fy.val(ta);I.setAttribute("fx",aa);I.setAttribute("fy",ta);e()}na.preventDefault()},ib=function(){db=null;da.unbind("mousemove",hb).unbind("mouseup",ib)};Ga=ea.getElementsByTagNameNS(n.svg,"stop");if(Da<2){for(;Da<2;){ea.appendChild(document.createElementNS(n.svg,"stop"));++Da}Ga=ea.getElementsByTagNameNS(n.svg,"stop")}var Da=Ga.length;for(Y=0;Y99.5)M=99.5;if(M>0)Ra=1-M/100;else Za=-(M/100)-1;I=145*((M+100)/2)/100;X&&e();break;case "angle":$a=M;I=$a/180;I+=0.5;I*=145;X&&e()}if(I>145)I= +145;else if(I<0)I=0;ta.css({"margin-left":I-5})}).change()});var Eb=function(na){var aa=na.pageX-nb.offset.left-parseInt(nb.parent.css("border-left-width"));if(aa>145)aa=145;if(aa<=0)aa=0;var ta=aa-5;aa/=145;switch(nb.type){case "radius":aa=Math.pow(aa*2,2.5);if(aa>0.98&&aa<1.02)aa=1;if(aa<=0.01)aa=0.01;ea.setAttribute("r",aa);break;case "opacity":u.paint.alpha=parseInt(aa*100);qa.setAttribute("fill-opacity",aa);break;case "ellip":Ra=Za=1;if(aa<0.5){aa/=0.5;Za=aa<=0?0.01:aa}else if(aa>0.5){aa/=0.5; +aa=2-aa;Ra=aa<=0?0.01:aa}e();aa-=1;if(Ra===aa+1)aa=Math.abs(aa);break;case "angle":aa-=0.5;$a=aa*=180;e();aa/=100}nb.elem.css({"margin-left":ta});aa=Math.round(aa*100);nb.input.val(aa);na.preventDefault()},Kb=function(){da.unbind("mousemove",Eb).unbind("mouseup",Kb);nb=null};for(O=(u.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];K=u.paint.solidColor=="none"?"":u.paint.solidColor+O;la||(K=Ga[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true, +effects:{type:"show",speed:0}});V.jPicker({window:{title:z.window.pickerTitle},images:{clientPath:z.images.clientPath},color:{active:K,alphaSupport:true}},function(na){u.paint.type="solidColor";u.paint.alpha=na.val("ahex")?Math.round(na.val("a")/255*100):100;u.paint.solidColor=na.val("hex")?na.val("hex"):"none";u.paint.radialGradient=null;T()},null,function(){N()});var Ib=$(L+" .jGraduate_tabs li");Ib.click(function(){Ib.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current"); +$(L+" > div").hide();var na=$(this).attr("data-type");$(L+" .jGraduate_gradPick").show();if(na==="rg"||na==="lg"){$(".jGraduate_"+na+"_field").show();$(".jGraduate_"+(na==="lg"?"rg":"lg")+"_field").hide();$("#"+p+"_jgraduate_rect")[0].setAttribute("fill","url(#"+p+"_"+na+"_jgraduate_grad)");ca=na==="lg"?"linearGradient":"radialGradient";$("#"+p+"_jGraduate_OpacInput").val(u.paint.alpha).change();var aa=$("#"+p+"_"+na+"_jgraduate_grad")[0];if(ea!==aa){var ta=$(ea).find("stop");$(aa).empty().append(ta); +ea=aa;aa=Cb.val();ea.setAttribute("spreadMethod",aa)}mb=na==="rg"&&ea.getAttribute("fx")!=null&&!(Ka==Ma&&Qa==Sa);$("#"+p+"_jGraduate_focusCoord").toggle(mb);if(mb)$("#"+p+"_jGraduate_match_ctr")[0].checked=false}else{$(L+" .jGraduate_gradPick").hide();$(L+" .jGraduate_colPick").show()}});$(L+" > div").hide();Ib.removeClass("jGraduate_tab_current");var Qb;switch(u.paint.type){case "linearGradient":Qb=$(L+" .jGraduate_tab_lingrad");break;case "radialGradient":Qb=$(L+" .jGraduate_tab_radgrad");break; +default:Qb=$(L+" .jGraduate_tab_color")}u.show();setTimeout(function(){Qb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();$.fn.SpinButton=function(a){function n(f,c){for(var m=f[c],o=document.body;(f=f.offsetParent)&&f!=o;)if(!$.browser.msie||f.currentStyle.position!="relative")m+=f[c];return m}return this.each(function(){this.repeating=false;this.spinCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&a.step?Number(a.step):1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,upClass:a&&a.upClass?a.upClass:"up",downClass:a&&a.downClass? a.downClass:"down",reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.spinCfg.smallStep=a&&a.smallStep?a.smallStep:this.spinCfg.step/2;this.adjustValue=function(f){f=isNaN(this.value)?this.spinCfg.reset:$.isFunction(this.spinCfg.stepfunc)?this.spinCfg.stepfunc(this,f):Number((Number(this.value)+Number(f)).toFixed(5));if(this.spinCfg.min!== -null)f=Math.max(f,this.spinCfg.min);if(this.spinCfg.max!==null)f=Math.min(f,this.spinCfg.max);this.value=f;$.isFunction(this.spinCfg.callback)&&this.spinCfg.callback(this)};$(this).addClass(a&&a.spinClass?a.spinClass:"spin-button").mousemove(function(f){var c=f.pageX||f.x,m=f.pageY||f.y;f=f.target||f.srcElement;var p=svgEditor.tool_scale||1,b=$(f).height()/2;c=c>n(f,"offsetLeft")+f.offsetWidth*p-this.spinCfg._btn_width?mn(f,"offsetLeft")+f.offsetWidth*o-this.spinCfg._btn_width?m=120)this.adjustValue(this.spinCfg.step);else f.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step);f.preventDefault()}).change(function(){this.adjustValue(0)});this.addEventListener&&this.addEventListener("DOMMouseScroll",function(f){if(f.detail>0)this.adjustValue(-this.spinCfg.step);else f.detail<0&&this.adjustValue(this.spinCfg.step);f.preventDefault()},false)})};function touchHandler(a){var n=a.changedTouches,f=n[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var m=document.createEvent("MouseEvent");m.initMouseEvent(c,true,true,window,1,f.screenX,f.screenY,f.clientX,f.clientY,false,false,false,false,0,null);if(n.length<2){f.target.dispatchEvent(m);a.preventDefault()}};jQuery&&function(){var a=$(window),n=$(document);$.extend($.fn,{contextMenu:function(f,c){if(f.menu==undefined)return false;if(f.inSpeed==undefined)f.inSpeed=150;if(f.outSpeed==undefined)f.outSpeed=75;if(f.inSpeed==0)f.inSpeed=-1;if(f.outSpeed==0)f.outSpeed=-1;$(this).each(function(){var m=$(this),p=$(m).offset(),b=$("#"+f.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).mouseup(function(e){var l=$(this);l.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||f.allowLeft|| -d.ctrlKey&&svgedit.browser.isMac()){e.stopPropagation();if(m.hasClass("disabled"))return false;var u=e.pageX,z=e.pageY;e=a.width()-b.width();var o=a.height()-b.height();if(u>e-15)u=e-15;if(z>o-30)z=o-30;n.unbind("click");b.css({top:z,left:u}).fadeIn(f.inSpeed);b.find("A").mouseover(function(){b.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){b.find("LI.hover").removeClass("hover")});n.keypress(function(L){switch(L.keyCode){case 38:if(b.find("LI.hover").length){b.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover"); +function(f){if(f.wheelDelta>=120)this.adjustValue(this.spinCfg.step);else f.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step);f.preventDefault()}).change(function(){this.adjustValue(0)});this.addEventListener&&this.addEventListener("DOMMouseScroll",function(f){if(f.detail>0)this.adjustValue(-this.spinCfg.step);else f.detail<0&&this.adjustValue(this.spinCfg.step);f.preventDefault()},false)})};function touchHandler(a){var n=a.changedTouches,f=n[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var m=document.createEvent("MouseEvent");m.initMouseEvent(c,true,true,window,1,f.screenX,f.screenY,f.clientX,f.clientY,false,false,false,false,0,null);if(n.length<2){f.target.dispatchEvent(m);a.preventDefault()}};jQuery&&function(){var a=$(window),n=$(document);$.extend($.fn,{contextMenu:function(f,c){if(f.menu==undefined)return false;if(f.inSpeed==undefined)f.inSpeed=150;if(f.outSpeed==undefined)f.outSpeed=75;if(f.inSpeed==0)f.inSpeed=-1;if(f.outSpeed==0)f.outSpeed=-1;$(this).each(function(){var m=$(this),o=$(m).offset(),b=$("#"+f.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).mouseup(function(e){var l=$(this);l.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||f.allowLeft|| +d.ctrlKey&&svgedit.browser.isMac()){e.stopPropagation();if(m.hasClass("disabled"))return false;var u=e.pageX,z=e.pageY;e=a.width()-b.width();var p=a.height()-b.height();if(u>e-15)u=e-15;if(z>p-30)z=p-30;n.unbind("click");b.css({top:z,left:u}).fadeIn(f.inSpeed);b.find("A").mouseover(function(){b.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){b.find("LI.hover").removeClass("hover")});n.keypress(function(L){switch(L.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:n.trigger("click")}});b.find("A").unbind("mouseup");b.find("LI:not(.disabled) A").mouseup(function(){n.unbind("click").unbind("keypress"); -$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),$(l),{x:u-p.left,y:z-p.top,docX:u,docY:z});return false});setTimeout(function(){n.click(function(){n.unbind("click").unbind("keypress");b.fadeOut(f.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+f.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+f.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+f.menu).each(function(){$(this).bind("mousedown.disableTextSelect", +$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),$(l),{x:u-o.left,y:z-o.top,docX:u,docY:z});return false});setTimeout(function(){n.click(function(){n.unbind("click").unbind("keypress");b.fadeOut(f.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+f.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+f.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+f.menu).each(function(){$(this).bind("mousedown.disableTextSelect", function(){return false})});$(m).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(f){if(f==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(f!=undefined)for(var c=f.split(","),m=0;m=0,p=n.indexOf("Gecko/")>=0,b=n.indexOf("MSIE")>=0,d=n.indexOf("Chrome/")>=0,e=n.indexOf("Windows")>=0,l=n.indexOf("Macintosh")>= -0,u="ontouchstart"in window,z=!!f.querySelector,o=!!document.evaluate,L=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","path");sa.setAttribute("d","M0,0 10,10");var ja=sa.pathSegList;sa=sa.createSVGPathSegLinetoAbs(5,5);try{ja.replaceItem(sa,0);return true}catch(ca){}return false}(),T=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","path");sa.setAttribute("d","M0,0 10,10");var ja=sa.pathSegList;sa=sa.createSVGPathSegLinetoAbs(5,5);try{ja.insertItemBefore(sa, -0);return true}catch(ca){}return false}(),N=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","svg"),ja=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(sa);ja.setAttribute("x",5);sa.appendChild(ja);var ca=document.createElementNS("http://www.w3.org/2000/svg","text");ca.textContent="a";ja.appendChild(ca);ja=ca.getStartPositionOfChar(0).x;document.documentElement.removeChild(sa);return ja===0}(),J=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg", -"svg");document.documentElement.appendChild(sa);var ja=document.createElementNS("http://www.w3.org/2000/svg","path");ja.setAttribute("d","M0,0 C0,0 10,10 10,0");sa.appendChild(ja);ja=ja.getBBox();document.documentElement.removeChild(sa);return ja.height>4&&ja.height<5}(),da=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(sa);var ja=document.createElementNS("http://www.w3.org/2000/svg","path");ja.setAttribute("d","M0,0 10,0");var ca= -document.createElementNS("http://www.w3.org/2000/svg","path");ca.setAttribute("d","M5,0 15,0");var ea=document.createElementNS("http://www.w3.org/2000/svg","g");ea.appendChild(ja);ea.appendChild(ca);sa.appendChild(ea);ja=ea.getBBox();document.documentElement.removeChild(sa);return ja.width==15}(),V=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","rect");sa.setAttribute("x",0.1);(sa=sa.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 sa}(),O=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","rect");sa.setAttribute("style","vector-effect:non-scaling-stroke");return sa.style.vectorEffect==="non-scaling-stroke"}(),fa=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,ja=f.createSVGTransform();sa.appendItem(ja);return sa.getItem(0)==ja}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return m};svgedit.browser.isGecko=function(){return p}; -svgedit.browser.isIE=function(){return b};svgedit.browser.isChrome=function(){return d};svgedit.browser.isWindows=function(){return e};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return u};svgedit.browser.supportsSelectors=function(){return z};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return L};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J}; +(function(){if(!svgedit.browser)svgedit.browser={};var a=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;svgedit.browser.supportsSvg=function(){return a};if(svgedit.browser.supportsSvg()){var n=navigator.userAgent,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),c=!!window.opera,m=n.indexOf("AppleWebKit")>=0,o=n.indexOf("Gecko/")>=0,b=n.indexOf("MSIE")>=0,d=n.indexOf("Chrome/")>=0,e=n.indexOf("Windows")>=0,l=n.indexOf("Macintosh")>= +0,u="ontouchstart"in window,z=!!f.querySelector,p=!!document.evaluate,L=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","path");sa.setAttribute("d","M0,0 10,10");var ia=sa.pathSegList;sa=sa.createSVGPathSegLinetoAbs(5,5);try{ia.replaceItem(sa,0);return true}catch(ca){}return false}(),T=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","path");sa.setAttribute("d","M0,0 10,10");var ia=sa.pathSegList;sa=sa.createSVGPathSegLinetoAbs(5,5);try{ia.insertItemBefore(sa, +0);return true}catch(ca){}return false}(),N=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","svg"),ia=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(sa);ia.setAttribute("x",5);sa.appendChild(ia);var ca=document.createElementNS("http://www.w3.org/2000/svg","text");ca.textContent="a";ia.appendChild(ca);ia=ca.getStartPositionOfChar(0).x;document.documentElement.removeChild(sa);return ia===0}(),K=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg", +"svg");document.documentElement.appendChild(sa);var ia=document.createElementNS("http://www.w3.org/2000/svg","path");ia.setAttribute("d","M0,0 C0,0 10,10 10,0");sa.appendChild(ia);ia=ia.getBBox();document.documentElement.removeChild(sa);return ia.height>4&&ia.height<5}(),da=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(sa);var ia=document.createElementNS("http://www.w3.org/2000/svg","path");ia.setAttribute("d","M0,0 10,0");var ca= +document.createElementNS("http://www.w3.org/2000/svg","path");ca.setAttribute("d","M5,0 15,0");var ea=document.createElementNS("http://www.w3.org/2000/svg","g");ea.appendChild(ia);ea.appendChild(ca);sa.appendChild(ea);ia=ea.getBBox();document.documentElement.removeChild(sa);return ia.width==15}(),V=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","rect");sa.setAttribute("x",0.1);(sa=sa.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 sa}(),O=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","rect");sa.setAttribute("style","vector-effect:non-scaling-stroke");return sa.style.vectorEffect==="non-scaling-stroke"}(),fa=function(){var sa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,ia=f.createSVGTransform();sa.appendItem(ia);return sa.getItem(0)==ia}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return m};svgedit.browser.isGecko=function(){return o}; +svgedit.browser.isIE=function(){return b};svgedit.browser.isChrome=function(){return d};svgedit.browser.isWindows=function(){return e};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return u};svgedit.browser.supportsSelectors=function(){return z};svgedit.browser.supportsXpath=function(){return p};svgedit.browser.supportsPathReplaceItem=function(){return L};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return K}; svgedit.browser.supportsHVLineContainerBBox=function(){return da};svgedit.browser.supportsGoodTextCharPos=function(){return N};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return V};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return fa}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{}; -(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),n={};svgedit.transformlist.SVGTransformList=function(f){this._elem=f||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();for(var m=0;m=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,m){var p=null;if(m>=0)if(m=0){this._removeFromOtherLists(c);p=this._xforms[m]=c;this._list._update()}return p};this.removeItem=function(c){if(c=0){for(var m=this._xforms[c],p=Array(this.numberOfItems- -1),b=0;b=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,m){var o=null;if(m>=0)if(m=0){this._removeFromOtherLists(c);o=this._xforms[m]=c;this._list._update()}return o};this.removeItem=function(c){if(c=0){for(var m=this._xforms[c],o=Array(this.numberOfItems- +1),b=0;b1;)c=n[f-1].multiply(c);if(Math.abs(c.a)<1.0E-14)c.a=0;if(Math.abs(c.b)<1.0E-14)c.b=0;if(Math.abs(c.c)<1.0E-14)c.c=0;if(Math.abs(c.d)< -1.0E-14)c.d=0;if(Math.abs(c.e)<1.0E-14)c.e=0;if(Math.abs(c.f)<1.0E-14)c.f=0;return c};svgedit.math.hasMatrixTransform=function(n){if(!n)return false;for(var f=n.numberOfItems;f--;){var c=n.getItem(f);if(c.type==1&&!svgedit.math.isIdentity(c.matrix))return true}return false};svgedit.math.transformBox=function(n,f,c,m,p){var b={x:n,y:f},d={x:n+c,y:f};c={x:n+c,y:f+m};n={x:n,y:f+m};f=svgedit.math.transformPoint;b=f(b.x,b.y,p);var e=m=b.x,l=b.y,u=b.y;d=f(d.x,d.y,p);m=Math.min(m,d.x);e=Math.max(e,d.x); -l=Math.min(l,d.y);u=Math.max(u,d.y);n=f(n.x,n.y,p);m=Math.min(m,n.x);e=Math.max(e,n.x);l=Math.min(l,n.y);u=Math.max(u,n.y);c=f(c.x,c.y,p);m=Math.min(m,c.x);e=Math.max(e,c.x);l=Math.min(l,c.y);u=Math.max(u,c.y);return{tl:b,tr:d,bl:n,br:c,aabox:{x:m,y:l,width:e-m,height:u-l}}};svgedit.math.transformListToTransform=function(n,f,c){if(n==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());f=f==undefined?0:f;c=c==undefined?n.numberOfItems-1:c;f=parseInt(f);c=parseInt(c);if(f>c){var m=c;c=f; -f=m}m=a.createSVGMatrix();for(f=f;f<=c;++f){var p=f>=0&&fc){var m=c;c=f; +f=m}m=a.createSVGMatrix();for(f=f;f<=c;++f){var o=f>=0&&fn.x&&f.yn.y}})();svgedit=svgedit||{}; (function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],n=["y","y1","cy","ry","height"],f=$.merge(["r","radius"],a);$.merge(f,n);var c,m={px:1};svgedit.units.init=function(b){c=b;b=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(b);var d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("width","1em");d.setAttribute("height","1ex");d.setAttribute("x","1in");b.appendChild(d);d=d.getBBox();document.body.removeChild(b); b=d.x;m.em=d.width;m.ex=d.height;m["in"]=b;m.cm=b/2.54;m.mm=b/25.4;m.pt=b/72;m.pc=b/6;m["%"]=0};svgedit.units.getTypeMap=function(){return m};svgedit.units.shortFloat=function(b){var d=c.getRoundDigits();if(isNaN(b)){if($.isArray(b))return svgedit.units.shortFloat(b[0])+","+svgedit.units.shortFloat(b[1])}else return+(+b).toFixed(d);return parseFloat(b).toFixed(d)-0};svgedit.units.convertUnit=function(b,d){d=d||c.getBaseUnit();return svgedit.unit.shortFloat(b/m[d])};svgedit.units.setUnitAttr=function(b, -d,e){isNaN(e)||b.getAttribute(d);b.setAttribute(d,e)};var p={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(b){var d=b.tagName,e=c.getBaseUnit();if(d=p[d])for(var l=d.length,u=0;u=0?e*l:n.indexOf(b)>=0?e*u:e*Math.sqrt(l*l+u*u)/Math.sqrt(2)}else{l=d.substr(-2);e=d.substr(0,d.length-2);return e*m[l]}};svgedit.units.isValidUnit=function(b,d,e){var l=false;if(f.indexOf(b)>=0)if(isNaN(d)){d=d.toLowerCase();$.each(m,function(o){if(!l)if(RegExp("^-?[\\d\\.]+"+o+"$").test(d))l=true})}else l=true;else if(b=="id"){b=false;try{var u=c.getElement(d); +d,e){isNaN(e)||b.getAttribute(d);b.setAttribute(d,e)};var o={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(b){var d=b.tagName,e=c.getBaseUnit();if(d=o[d])for(var l=d.length,u=0;u=0?e*l:n.indexOf(b)>=0?e*u:e*Math.sqrt(l*l+u*u)/Math.sqrt(2)}else{l=d.substr(-2);e=d.substr(0,d.length-2);return e*m[l]}};svgedit.units.isValidUnit=function(b,d,e){var l=false;if(f.indexOf(b)>=0)if(isNaN(d)){d=d.toLowerCase();$.each(m,function(p){if(!l)if(RegExp("^-?[\\d\\.]+"+p+"$").test(d))l=true})}else l=true;else if(b=="id"){b=false;try{var u=c.getElement(d); b=u==null||u===e}catch(z){}return b}else l=true;return l}})();svgedit=svgedit||{}; -(function(){function a(b){if(svgedit.browser.supportsHVLineContainerBBox())try{return b.getBBox()}catch(d){}var e=$.data(b,"ref"),l=null;if(e){var u=$(e).children().clone().attr("visibility","hidden");$(p).append(u);l=u.filter("line, path")}else l=$(b).find("line, path");var z=false;if(l.length){l.each(function(){var o=this.getBBox();if(!o.width||!o.height)z=true});if(z){b=e?u:$(b).children();ret=getStrokedBBox(b)}else ret=b.getBBox()}else ret=b.getBBox();e&&u.remove();return ret}if(!svgedit.utilities)svgedit.utilities= -{};var n="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),f=null,c=null,m=null,p=null;svgedit.utilities.init=function(b){f=b;c=b.getDOMDocument();m=b.getDOMContainer();p=b.getSVGRoot()};svgedit.utilities.toXml=function(b){return $("

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

    ").html(b).text()};svgedit.utilities.encode64=function(b){b=svgedit.utilities.convertToXMLReferences(b);if(window.btoa)return window.btoa(b); -var d=Array(Math.floor((b.length+2)/3)*4),e,l,u,z,o,L,T=0,N=0;do{e=b.charCodeAt(T++);l=b.charCodeAt(T++);u=b.charCodeAt(T++);z=e>>2;e=(e&3)<<4|l>>4;o=(l&15)<<2|u>>6;L=u&63;if(isNaN(l))o=L=64;else if(isNaN(u))L=64;d[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(z);d[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e);d[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(o);d[N++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(L)}while(T< -b.length);return d.join("")};svgedit.utilities.decode64=function(b){if(window.atob)return window.atob(b);var d="",e,l,u="",z,o="",L=0;b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(L++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(L++));z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(L++));o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(L++)); -e=e<<2|l>>4;l=(l&15)<<4|z>>2;u=(z&3)<<6|o;d+=String.fromCharCode(e);if(z!=64)d+=String.fromCharCode(l);if(o!=64)d+=String.fromCharCode(u)}while(L127)d+="&#"+l+";"}return d};svgedit.utilities.text2xml=function(b){if(b.indexOf("=0)b=b.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var d;try{var e=window.DOMParser? +(function(){function a(b){if(svgedit.browser.supportsHVLineContainerBBox())try{return b.getBBox()}catch(d){}var e=$.data(b,"ref"),l=null;if(e){var u=$(e).children().clone().attr("visibility","hidden");$(o).append(u);l=u.filter("line, path")}else l=$(b).find("line, path");var z=false;if(l.length){l.each(function(){var p=this.getBBox();if(!p.width||!p.height)z=true});if(z){b=e?u:$(b).children();ret=getStrokedBBox(b)}else ret=b.getBBox()}else ret=b.getBBox();e&&u.remove();return ret}if(!svgedit.utilities)svgedit.utilities= +{};var n="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),f=null,c=null,m=null,o=null;svgedit.utilities.init=function(b){f=b;c=b.getDOMDocument();m=b.getDOMContainer();o=b.getSVGRoot()};svgedit.utilities.toXml=function(b){return $("

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

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