fix for selecting canvas

master
Mark MacKay 2012-07-28 12:53:50 -05:00
parent b55a4b296e
commit ce6e174d05
7 changed files with 408 additions and 370 deletions

View File

@ -540,11 +540,7 @@
// called when we've selected a different element
var selectedChanged = function(window,elems) {
//check if anything is a polyline
//polyline = elems.filter(function(el){ return el && el.nodeName == "polyline" })
//if (polyline.length) {svgCanvas.convertToPath();}
var mode = svgCanvas.getMode();
if(mode === "select") setSelectMode();
var is_node = (mode == "pathedit");
@ -552,13 +548,28 @@
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
elems = elems.filter(Boolean)
multiselected = (elems.length >= 2) ? elems : false;
if (svgCanvas.elementsAreSame(multiselected)) selectedElement = multiselected[0]
if (selectedElement != null) {
if (!is_node) {
$('#multiselected_panel').hide()
updateToolbar();
}
}
if (multiselected.length) {//multiselected elements are the same
$('#tools_top').addClass('multiselected')
}
}
else if (multiselected.length) {
$('.context_panel').hide()
$('#tools_top').removeClass('multiselected')
$('#multiselected_panel').show()
}
else {
$('.context_panel').hide()
$('#canvas_panel').show()
$('#tools_top').removeClass('multiselected')
}
togglePathEditMode(is_node, elems);
svgCanvas.runExtensions("selectedChanged", {
elems: elems,
@ -1399,7 +1410,7 @@
elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null
if (elem) $("#tools_top").addClass("multiselected")
}
if (!elem && !multiselected) {
$("#tools_top").removeClass("multiselected")
$("#stroke_panel").hide();

View File

@ -7623,7 +7623,7 @@ this.setLinkURL = function(val) {
};
// Function selectedAreSame
// Function elementAreSame
// Checks if all the selected Elements are the same type
//
// Parameters:

View File

@ -1,8 +1,8 @@
function touchHandler(a){var p=a.changedTouches,g=p[0],b="";switch(a.type){case "touchstart":b="mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(b,true,true,window,1,g.screenX,g.screenY,g.clientX,g.clientY,false,false,false,false,0,null);if(p.length<2){g.target.dispatchEvent(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var b=g.handler,n=g.data.toLowerCase().split(" ");g.handler=function(s){if(!(this!==s.target&&(/textarea|select/i.test(s.target.nodeName)||s.target.type==="text"))){var c=s.type!=="keypress"&&a.hotkeys.specialKeys[s.which],f=String.fromCharCode(s.which).toLowerCase(),d="",l={};if(s.altKey&&c!=="alt")d+="alt+";if(s.ctrlKey&&c!=="ctrl")d+="ctrl+";if(s.metaKey&&!s.ctrlKey&&c!=="meta")d+="meta+";if(s.shiftKey&&c!=="shift")d+="shift+";if(c)l[d+c]=
true;else{l[d+f]=true;l[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[f]]=true}c=0;for(f=n.length;c<f;c++)if(l[n[c]])return b.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
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:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,aa,pa,ra){var ma;if(pa!==f){W=aa.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);aa=W[3]||"";if(ra===2&&g(pa))pa=pa.replace(da?Y:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=ra===2?pa:ra===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+
aa}else da=W(aa!==f?aa:p[oa][fa]);return da}function s(da,W,aa){if(W===f||typeof W==="boolean"){aa=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?Y:ba,""):W;return o(W,aa)}function c(da,W,aa,pa){if(!g(aa)&&typeof aa!=="object"){pa=aa;aa=W;W=f}return this.each(function(){var ra=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&ra.attr(ma)||"";ra.attr(ma,q[da](na,aa,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},O,J,Q,V=a.event.special,N="querystring",
ia="fragment",oa="location",fa="href",ba=/^.*\?|#.*$/g,Y=/^.*\#/,sa,ka={};q[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var aa={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ra,ma){var na=ma.split("="),
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:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,aa,pa,ra){var ma;if(pa!==f){W=aa.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);aa=W[3]||"";if(ra===2&&g(pa))pa=pa.replace(da?X:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=ra===2?pa:ra===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+
aa}else da=W(aa!==f?aa:p[oa][fa]);return da}function s(da,W,aa){if(W===f||typeof W==="boolean"){aa=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?X:ba,""):W;return o(W,aa)}function c(da,W,aa,pa){if(!g(aa)&&typeof aa!=="object"){pa=aa;aa=W;W=f}return this.each(function(){var ra=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&ra.attr(ma)||"";ra.attr(ma,q[da](na,aa,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},O,J,Q,V=a.event.special,N="querystring",
ia="fragment",oa="location",fa="href",ba=/^.*\?|#.*$/g,X=/^.*\#/,sa,ka={};q[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var aa={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ra,ma){var na=ma.split("="),
za=l(na[0]),Fa=aa,Ia=0,Ca=za.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(W)na=na&&!isNaN(na)?+na:na==="undefined"?f:pa[na]!==f?pa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){za=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[za]=Ia<Ka?Fa[za]||(Ca[Ia+1]&&isNaN(Ca[Ia+1])?{}:[]):na}else if(a.isArray(aa[za]))aa[za].push(na);else aa[za]=aa[za]!==f?[aa[za],na]:na}else if(za)aa[za]=
W?f:""});return aa};o[N]=b(s,0);o[ia]=K=b(s,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(ka,da)})({a:fa,base:fa,iframe:"src",img:"src",input:"src",form:"action",link:fa,script:"src"});Q=a.elemUrlAttr;a.fn[N]=b(c,N);a.fn[ia]=b(c,ia);T.pushState=O=function(da,W){if(g(da)&&/^#/.test(da)&&W===f)W=2;var aa=da!==f;aa=B(p[oa][fa],aa?da:{},aa?W:2);p[oa][fa]=aa+(/#/.test(aa)?"":"#")};T.getState=J=function(da,W){return da===f||typeof da==="boolean"?K(da):K(W)[da]};T.removeState=function(da){var W=
{};if(da!==f){W=J();a.each(a.isArray(da)?da:arguments,function(aa,pa){delete W[pa]})}O(W,2)};V.hashchange=a.extend(V.hashchange,{add:function(da){function W(pa){var ra=pa[ia]=B();pa.getState=function(ma,na){return ma===f||typeof ma==="boolean"?o(ra,ma):o(ra,na)[ma]};aa.apply(this,arguments)}var aa;if(a.isFunction(da)){aa=da;return W}else{aa=da.handler;da.handler=W}}})})(jQuery,this);
@ -13,19 +13,19 @@ function c(da,W){if(!J){if(n.no_img)da=false;if(da){var aa=a(document.createElem
src:na})}else na=g(a(Fa),ma);ka(na,za)}n.placement&&a.each(n.placement,function(Ka,Na){p[Na]&&a(Ka).each(function(Aa){var ya=p[Na].clone();if(Aa>0&&!da)ya=g(ya,Aa,true);sa(a(this),ya,Na)})});if(!W){da&&aa.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)}
function d(da){if(window.btoa)return window.btoa(da);var W=Array(Math.floor((da.length+2)/3)*4),aa,pa,ra,ma,na,za,Fa=0,Ia=0;do{aa=da.charCodeAt(Fa++);pa=da.charCodeAt(Fa++);ra=da.charCodeAt(Fa++);ma=aa>>2;aa=(aa&3)<<4|pa>>4;na=(pa&15)<<2|ra>>6;za=ra&63;if(isNaN(pa))na=za=64;else if(isNaN(ra))za=64;W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(aa);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na);
W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(za)}while(Fa<da.length);return W.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,T,O,J=false,Q=false,V=0,N=navigator.userAgent,ia=!!window.opera;N.indexOf("Safari/")>-1&&N.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+b+'" type=image/svg+xml>').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s);
s(0,true)}catch(ba){f()}}else{var Y=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){T=Y.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=Y.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,aa,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",aa);(aa=da.attr("class"))&&W.attr("class",
s(0,true)}catch(ba){f()}}else{var X=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){T=X.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=X.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,aa,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",aa);(aa=da.attr("class"))&&W.attr("class",
"svg_icon "+aa);da.replaceWith(W)}else da.append(W);ia&&setTimeout(function(){W.removeAttr("style")},1)},ka=function(da,W){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,W,true);p[W]=da};g=function(da,W){var aa=da.find("defs");if(!aa.length)return da;aa=ia?aa.find("*").filter(function(){return!!this.id}):aa.find("[id]");var pa=da[0].getElementsByTagName("*"),ra=pa.length;aa.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+W+ma;na="url(#"+na+")";var za="url(#"+ma+")";
for(ma=0;ma<ra;ma++){var Fa=pa[ma];Fa.getAttribute("fill")===na&&Fa.setAttribute("fill",za);Fa.getAttribute("stroke")===na&&Fa.setAttribute("stroke",za);Fa.getAttribute("filter")===na&&Fa.setAttribute("filter",za)}});return da}};a.getSvgIcon=function(b,n){var s=p[b];if(n&&s)s=g(s,0,true).clone(true);return s};a.resizeSvgIcons=function(b){var n=!a(".svg_icon:first").length;a.each(b,function(s,c){var f=a.isArray(c),d=f?c[0]:c,l=f?c[1]:c;if(n)s=s.replace(/\.svg_icon/g,"svg");a(s).each(function(){this.setAttribute("width",
d);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=d+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(b,n,s){b=document.createElementNS(p.svg,b);if(g)for(var c in n)b.setAttribute(c,n[c]);else for(c in n){var f=n[c],d=b[c];if(d&&d.constructor==="SVGLength")d.baseVal.value=f;else b.setAttribute(c,f)}s&&s.appendChild(b);return b}var p={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(b){b=b||{};this.alpha=isNaN(b.alpha)?100:b.alpha;if(b.copy){this.type=
b.copy.type;this.alpha=b.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=b.copy.solidColor;break;case "linearGradient":this.linearGradient=b.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=b.copy.radialGradient.cloneNode(true)}}else if(b.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=b.linearGradient.cloneNode(true)}else if(b.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=b.radialGradient.cloneNode(true)}else if(b.solidColor){this.type="solidColor";this.solidColor=b.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 g=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(b){var n=
arguments;return this.each(function(){function s(la,ca,ja,M,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},Y);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else Y.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga=
arguments;return this.each(function(){function s(la,ca,ja,M,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},X);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else X.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Pa){c(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")||
1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Ua){db=Ua.val("hex")?"#"+Ua.val("hex"):"none";Ya=Ua.val("a")!==null?Ua.val("a")/256:1;Pa.setAttribute("fill",db);Pa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color",
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(Y).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var M=0;$(Y).find("stop").each(function(){var R=this.getAttribute("offset"),
ea=$(this);if(R<M){ea.prev().before(ea);wa=$(Y).find("stop")}M=R})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var T=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},O=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(X).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?X.removeAttribute("gradientTransform"):X.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var M=0;$(X).find("stop").each(function(){var R=this.getAttribute("offset"),
ea=$(this);if(R<M){ea.prev().before(ea);wa=$(X).find("stop")}M=R})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var T=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},O=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
q.hide()};$.extend(true,q,{paint:new $.jGraduate.Paint({copy:B.paint}),okCallback:$.isFunction(n[1])&&n[1]||null,cancelCallback:$.isFunction(n[2])&&n[2]||null});q.position();var J=null,Q=$(window);if(q.paint.type=="none")q.paint=$.jGraduate.Paint({solidColor:"ffffff"});q.addClass("jGraduate_Picker");q.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var V=$(K+"> .jGraduate_colPick"),N=$(K+"> .jGraduate_gradPick");N.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
o+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_y1" size="3" title="Enter starting y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">End Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
@ -34,25 +34,25 @@ o+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'
o+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+o+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+o+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+
o+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+o+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+o+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+B.images.clientPath+
'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba&nbsp;</label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+o+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+o+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
o+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+o+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ia=256,oa=ia-0,fa=ia-0,ba,Y,sa,ka={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],W=a("svg",{id:o+"_jgraduate_svg",width:ia,height:ia,xmlns:p.svg},da);ba=ba||q.paint.type;var aa=Y=q.paint[ba],pa=q.paint.alpha,ra=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!ra){Y.id=o+"_lg_jgraduate_grad";
aa=Y=W.appendChild(Y)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!ra){Y.id=o+"_rg_jgraduate_grad";aa=Y=W.appendChild(Y)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(ra){aa=Y=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){J.substr(na,2);var za=(255-parseInt(J.substr(na,2),16)).toString(16);
o+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+o+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ia=256,oa=ia-0,fa=ia-0,ba,X,sa,ka={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],W=a("svg",{id:o+"_jgraduate_svg",width:ia,height:ia,xmlns:p.svg},da);ba=ba||q.paint.type;var aa=X=q.paint[ba],pa=q.paint.alpha,ra=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!ra){X.id=o+"_lg_jgraduate_grad";
aa=X=W.appendChild(X)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!ra){X.id=o+"_rg_jgraduate_grad";aa=X=W.appendChild(X)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(ra){aa=X=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){J.substr(na,2);var za=(255-parseInt(J.substr(na,2),16)).toString(16);
if(za.length<2)za=0+za;ma+=za}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(aa.getAttribute("x1")||0);ma=parseFloat(aa.getAttribute("y1")||0);na=parseFloat(aa.getAttribute("x2")||1);za=parseFloat(aa.getAttribute("y2")||0);var Fa=parseFloat(aa.getAttribute("cx")||0.5),Ia=parseFloat(aa.getAttribute("cy")||0.5),Ca=parseFloat(aa.getAttribute("fx")||Fa),Ka=parseFloat(aa.getAttribute("fy")||
Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:oa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":pa/100},W);var Na=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:J*ia}).data("coord","start").appendTo(da),Aa=Na.clone().text(2).css({top:za*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa*
ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=Y.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")Y.setAttribute(ca,this.value);var R=M?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:Aa,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=X.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")X.setAttribute(ca,this.value);var R=M?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:Aa,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Da)});qb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb=
N.find(".jGraduate_spreadMethod").change(function(){Y.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/oa;ja=ja/fa;var M=Za.data("coord"),R=Y;switch(M){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca);
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=Y.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na<ta;na++)s(0,0,0,0,wa[na]);sb.val(Y.getAttribute("spreadMethod")||
"pad");var mb,jb=false;sa.setAttribute("fill-opacity",pa/100);$("#"+o+" div.grad_coord").mousedown(function(la){la.preventDefault();Za=$(this);Za.offset();mb=Za.parent().offset();Q.mousemove(bb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=Y.cloneNode(true);q.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){O()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ka.fx.val("");ka.fy.val("")}$("#"+
o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=Y;if(jb){var ca=Ab||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{Ab=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=Y.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var eb;pa=N=0;if(ba==="radialGradient"){W=Y.gradientTransform.baseVal;if(W.numberOfItems===2){ta=W.getItem(0);W=W.getItem(1);if(ta.type===2&&W.type===3){ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==1)N=Math.round((1-ta.d)*100)}}else if(W.numberOfItems===3){da=W.getItem(0);ta=W.getItem(1);W=W.getItem(2);if(da.type===4&&ta.type===2&&W.type===3){pa=Math.round(da.angle);ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)N=Math.round((1-ta.d)*100)}}}N={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(Y.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:N},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:pa}};$.each(N,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(M){var R=
ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&Y.setAttribute("r",M/100);R=Math.pow(M/100,0.4)/2*145;break;case "opacity":q.paint.alpha=M;sa.setAttribute("fill-opacity",M/100);R=M*1.45;break;case "ellip":fb=La=1;if(M===0){R=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else fb=-(M/100)-1;R=145*((M+100)/
2)/100;ea&&d();break;case "angle":Va=M;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;Y.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
N.find(".jGraduate_spreadMethod").change(function(){X.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/oa;ja=ja/fa;var M=Za.data("coord"),R=X;switch(M){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca);
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=X.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){X.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=X.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na<ta;na++)s(0,0,0,0,wa[na]);sb.val(X.getAttribute("spreadMethod")||
"pad");var mb,jb=false;sa.setAttribute("fill-opacity",pa/100);$("#"+o+" div.grad_coord").mousedown(function(la){la.preventDefault();Za=$(this);Za.offset();mb=Za.parent().offset();Q.mousemove(bb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=X.cloneNode(true);q.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){O()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ka.fx.val("");ka.fy.val("")}$("#"+
o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=X;if(jb){var ca=Ab||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{Ab=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=X.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){X.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=X.getElementsByTagNameNS(p.svg,"stop")}var eb;pa=N=0;if(ba==="radialGradient"){W=X.gradientTransform.baseVal;if(W.numberOfItems===2){ta=W.getItem(0);W=W.getItem(1);if(ta.type===2&&W.type===3){ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==1)N=Math.round((1-ta.d)*100)}}else if(W.numberOfItems===3){da=W.getItem(0);ta=W.getItem(1);W=W.getItem(2);if(da.type===4&&ta.type===2&&W.type===3){pa=Math.round(da.angle);ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)N=Math.round((1-ta.d)*100)}}}N={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(X.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:N},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:pa}};$.each(N,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(M){var R=
ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&X.setAttribute("r",M/100);R=Math.pow(M/100,0.4)/2*145;break;case "opacity":q.paint.alpha=M;sa.setAttribute("fill-opacity",M/100);R=M*1.45;break;case "ellip":fb=La=1;if(M===0){R=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else fb=-(M/100)-1;R=145*((M+100)/
2)/100;ea&&d();break;case "angle":Va=M;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;X.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(N=(q.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+N;ra||(J=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){O()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current");
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(Y!==ca){var ja=
$(Y).find("stop");$(ca).empty().append(ja);Y=ca;ca=sb.val();Y.setAttribute("spreadMethod",ca)}jb=la==="rg"&&Y.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb=
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(X!==ca){var ja=
$(X).find("stop");$(ca).empty().append(ja);X=ca;ca=sb.val();X.setAttribute("spreadMethod",ca)}jb=la==="rg"&&X.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb=
$(K+" .jGraduate_tab_radgrad");break;default:Bb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,b){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),c=$("#"+g.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var B=d.pageX,o=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;o=d.originalEvent.touches[0].pageY}d=a.width()-c.width();l=a.height()-c.height();if(B>d-15)B=d-15;
if(o>l-30)o=l-30;if(svgedit.browser.isTouch())o-=c.height()/2;p.unbind("click");c.css({top:o,left:B}).fadeIn(g.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
@ -64,7 +64,7 @@ function(){return false})});return $(this)},disableContextMenuItems:function(g){
0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(oa,0);return true}catch(ba){}return false}(),T=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(oa,
0);return true}catch(ba){}return false}(),O=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);fa.setAttribute("x",5);oa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(oa);return fa===0}(),J=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(oa);return fa.height>4&&fa.height<5}(),Q=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 10,0");var ba=
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(fa);Y.appendChild(ba);oa.appendChild(Y);fa=Y.getBBox();document.documentElement.removeChild(oa);return fa.width==15}(),V=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var X=document.createElementNS("http://www.w3.org/2000/svg","g");X.appendChild(fa);X.appendChild(ba);oa.appendChild(X);fa=X.getBBox();document.documentElement.removeChild(oa);return fa.width==15}(),V=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
return oa}(),N=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("style","vector-effect:non-scaling-stroke");return oa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();oa.appendItem(fa);return oa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return s};
svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return V};svgedit.browser.supportsNonScalingStroke=function(){return N};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
@ -200,7 +200,7 @@ true);a.appendChild(d);var l=f.createElementNS(b,"svg");(c.clearSvgContentElemen
function(e){q=e};c.current_drawing_=new svgedit.draw.Drawing(l,q);var B=c.getCurrentDrawing=function(){return c.current_drawing_},o=1,K=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=T.shape,J=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(b,e.element);if(m)(K||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,
"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},V=c.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ia=c.matrixMultiply=svgedit.math.matrixMultiply,oa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=c.transformListToTransform=svgedit.math.transformListToTransform,
ba=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
ba=svgedit.math.snapToAngle,X=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
getSVGContent:function(){return l}});var ka=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,W=c.setHref=svgedit.utilities.setHref,aa=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var pa=c.getRotationAngle=svgedit.utilities.getRotationAngle,ra=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,za=svgedit.sanitize.getNSMap(),Fa=c.sanitizeSvg=
svgedit.sanitize.sanitizeSvg,Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,Aa=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)c.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();c.pathActions.clear();M("changed",z);z=h.type();
m=e==m.AFTER_APPLY;if(z==Ia.type()){m=m?h.newParent:h.oldParent;m==l&&c.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&c.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&c.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&
@ -228,17 +228,17 @@ case 11:case 10:m+=u.r1+","+u.r2+" "+u.angle+" "+ +u.largeArcFlag+" "+ +u.sweepF
2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new Aa("Transform");var A={},u=null;z=[];switch(e.tagName){case "line":z=["x1","y1",
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":u={};u.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I<F;++I){var E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}break;case "path":u={};u.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
$(e).attr(z);$.each(A,function(ha,Ta){A[ha]=sa(ha,Ta)})}else if(H)A={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(u==null){u=$.extend(true,{},A);$.each(u,function(ha,Ta){u[ha]=sa(ha,Ta)})}u.transform=Va?Va:"";if(e.tagName=="g"&&!H||e.tagName=="a"){w=svgedit.utilities.getBBox(e);var G={x:w.x+w.width/2,y:w.y+w.height/2},L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);z=d.createSVGMatrix();if(w=pa(e)){I=w*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var v=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=V(U);if(S){z=fa(S).matrix;H=pa(U);var X=Va,Z=[];Va=U.getAttribute("transform");if(H||oa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);Z.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var qa=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();qa.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(qa);Z.push(Ba);Z.push(Oa);Z.push(qa)}m.addSubCommand(Ua(U));Va=X}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){X=U.getAttribute("clip-path");if(k.indexOf(X)===-1){nb(X,H,z);k.push(X)}}X=Va;Va=U.getAttribute("transform");
if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(b,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=X}}}k=[];Va=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform");
if(S=V(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=X;X=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(X)&&U.setAttribute("stroke-width",X*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+v.e,y:G.y+v.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(w,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform");S=V(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Ua(U));Va=X}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=pa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((v=e.getAttribute("fill"))&&v.indexOf("url(")===0){v=R(v);X="pattern";if(v.tagName!==X)X="gradient";if(v.getAttribute(X+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=V(v);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";v.setAttribute(X+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;v=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,v,X);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var v=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=V(U);if(S){z=fa(S).matrix;H=pa(U);var Y=Va,Z=[];Va=U.getAttribute("transform");if(H||oa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);Z.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var qa=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();qa.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(qa);Z.push(Ba);Z.push(Oa);Z.push(qa)}m.addSubCommand(Ua(U));Va=Y}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){Y=U.getAttribute("clip-path");if(k.indexOf(Y)===-1){nb(Y,H,z);k.push(Y)}}Y=Va;Va=U.getAttribute("transform");
if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(b,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=Y}}}k=[];Va=Y}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");
if(S=V(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=Y;Y=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(Y)&&U.setAttribute("stroke-width",Y*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+v.e,y:G.y+v.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(w,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,v,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");S=V(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Ua(U));Va=Y}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=pa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((v=e.getAttribute("fill"))&&v.indexOf("url(")===0){v=R(v);Y="pattern";if(v.tagName!==Y)Y="gradient";if(v.getAttribute(Y+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=V(v);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";v.setAttribute(Y+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;v=h.getItem(0).matrix;Y=fa(h,1).matrix;w=Y.inverse();z=ia(w,v,Y);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
A.points=Array(F);for(I=0;I<F;++I){E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}}case "path":A.d=e.getAttribute("d");I=1;h.clear()}}else{I=4;if(H){G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)db(e,A,z);if(I==2){if(H){oa(h)||(L={x:G.x+z.e,y:G.y+z.f});G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==
3&&H){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(H,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,u));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||M("selected",
3&&H){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(H,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,v,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,u));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||M("selected",
J)},vb=this.addToSelection=function(e,h){if(e.length!=0){for(var m=0;m<J.length;){if(J[m]==null)break;++m}for(var z=e.length;z--;){var w=e[z];if(w&&svgedit.utilities.getBBox(w)){if(w.tagName==="a"&&w.childNodes.length===1)w=w.firstChild;if(J.indexOf(w)==-1){J[m]=w;m++;w=Ha.requestSelector(w);J.length>1&&w.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3-
(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m<len;++m){var z=J[m];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ea="select";xb($(K||e).children())}};var Ib=this.getMouseTarget=function(e){if(e==
null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z=
@ -252,13 +252,13 @@ curStyles:true,attr:{cx:E,cy:I,r:0,id:ja(),opacity:O.opacity/2}});break;case "el
true;break;case "textedit":h*=o;m*=o;hb.mouseDown(u,G,h,m);La=true;break;case "rotate":La=true;c.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}C=ob("mouseDown",{event:u,start_x:h,start_y:m,selectedElements:J},true);$.each(C,function(P,U){if(U&&U.started)La=true});if(Ea)document.getElementById("workarea").className=Ea=="resize"?u.target.style.cursor:Ea}}).mousemove(function(u){if(!(u.originalEvent.touches&&u.originalEvent.touches.length>1))if(La)if(!(u.button===
1||c.spaceKey)){var F=J[0],I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=ra(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}u.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v)}if(u.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||v!=0){C=J.length;for(k=0;k<C;++k){F=J[k];if(F==null)break;var D=d.createSVGTransform();G=V(F);D.setTranslate(L,v);G.numberOfItems?G.replaceItem(D,0):G.appendItem(D);Ha.requestSelector(F).resize()}if(u.altKey)if(!c.addClones){c.addClones=
c.cloneSelectedElements(0,0,D);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(Oa){Oa.parentNode&&Oa.parentNode.removeChild(Oa);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",J)}}break;case "multiselect":L*=o;k*=o;ma(ta,{x:Math.min(z,L),y:Math.min(w,k),width:Math.abs(L-z),height:Math.abs(k-w)},100);G=[];L=[];D=tb();C=J.length;for(k=0;k<C;++k){v=D.indexOf(J[k]);if(v==-1)G.push(J[k]);else D[v]=null}C=D.length;for(k=0;k<C;++k)D[k]&&L.push(D[k]);
G.length>0&&c.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var X=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=X*Math.cos(v);v=X*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var Z=X=0,ga=U?(U+v)/U:1,qa=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/
U:1;Z=U}if(kb.indexOf("w")>=0){qa=P?(P-L)/P:1;X=P}L=d.createSVGTransform();v=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);X=wa(X);k=wa(k);Z=wa(Z)}L.setTranslate(-(C+X),-(k+Z));if(u.shiftKey)if(qa==1)qa=ga;else ga=qa;v.setScale(qa,ga);P.setTranslate(C+X,k+Z);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(v,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(v,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition",J);break;
G.length>0&&c.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var Y=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=Y*Math.cos(v);v=Y*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var Z=Y=0,ga=U?(U+v)/U:1,qa=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/
U:1;Z=U}if(kb.indexOf("w")>=0){qa=P?(P-L)/P:1;Y=P}L=d.createSVGTransform();v=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);Z=wa(Z)}L.setTranslate(-(C+Y),-(k+Z));if(u.shiftKey)if(qa==1)qa=ga;else ga=qa;v.setScale(qa,ga);P.setTranslate(C+Y,k+Z);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(v,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(v,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition",J);break;
case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(u.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea=="square"||
u.shiftKey){L=D=Math.max(L,D);C=h<x?h:h-L;k=m<y?m:m-D}else{C=Math.min(h,x);k=Math.min(m,y)}if(u.altKey){L*=2;D*=2;C=h-L/2;k=m-D/2}if(n.gridSnapping){L=wa(L);D=wa(D);C=wa(C);k=wa(k)}ma(G,{width:L,height:D,x:C,y:k},1E3);break;case "circle":L=$(G).attr(["cx","cy"]);D=L.cx;C=L.cy;L=Math.sqrt((x-D)*(x-D)+(y-C)*(y-C));if(n.gridSnapping)L=wa(L);G.setAttributeNS(null,"r",L);break;case "ellipse":L=$(G).attr(["cx","cy"]);D=Math.abs(h+(x-h)/2);C=Math.abs(m+(y-m)/2);L=null;window.opera||d.suspendRedraw(1E3);
if(n.gridSnapping){x=wa(x);D=wa(D);y=wa(y);C=wa(C)}k=Math.abs(h-D);v=Math.abs(m-C);if(u.shiftKey){v=k;C=y>m?m+k:m-k}if(u.altKey){D=h;C=m;k=Math.abs(x-D);v=u.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",v);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+
k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(u.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L=
svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=Y(F);G=N(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove",
svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=X(F);G=N(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove",
{event:u,mouse_x:E,mouse_y:I,selected:F})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var F=u.target.parentNode;if(F!==K){var I=Ib(u),E=I.tagName;if(E==="text"&&Ea!=="textedit"){u=N(u.pageX,u.pageY,rb);hb.select(I,u.x,u.y)}if((E==="g"||E==="a")&&pa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(u){c.addClones=false;window.removeEventListener("keyup",c.removeClones);
if(u.button!==2){var F=Cb;Cb=null;if(La){var I=N(u.pageX,u.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=ra(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity=
E.getAttribute("stroke-opacity");bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(E=0;E<u;++E){if(J[E]==null)break;J[E].firstChild||Ha.requestSelector(J[E]).resize()}}else{E=
@ -267,14 +267,14 @@ if(v=G>=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPo
curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);v=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);v=true}break;case "text":v=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(u,k,E,I);k=F.element;v=F.keep;break;case "pathedit":v=true;k=null;Ja.mouseUp(u);
break;case "textedit":v=false;k=null;hb.mouseUp(u,E,I);break;case "rotate":v=true;k=null;Ea="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:u,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){v=U.keep||v;k=U.element;La=U.started||La}});if(!v&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=u.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&&
E.id!="svgcanvas"&&E.id!="svgroot"){c.setMode("select");xb([E],true)}}else if(k!=null){c.addedNew=true;u=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=O.opacity){C=$(false).clone().attr({to:O.opacity,dur:u}).appendTo(k);try{C[0].beginElement()}catch(D){}}else u=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",O.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},u*
1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(u.wheelDelta)if(u.wheelDelta>=120)F.factor=2;else{if(u.wheelDelta<=-120)F.factor=0.5}else if(u.detail)if(u.detail>0)F.factor=0.5;else if(u.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=c.textActions=function(){function e(S){var X=I.value===
"";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var Z;Z=k[S];X||I.setSelectionRange(S,S);E=ra("text_cursor");if(!E){E=document.createElementNS(b,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=ra("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));X=H(Z.x,v.y);Z=H(Z.x,v.y+v.height);ma(E,{x1:X.x,y1:X.y,x2:Z.x,
y2:Z.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,Z){if(S===X)e(X);else{Z||I.setSelectionRange(S,X);G=ra("text_selectblock");if(!G){G=document.createElementNS(b,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});ra("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];E.setAttribute("visibility","hidden");X=H(S.x,v.y);Z=H(S.x+(ga.x-S.x),v.y);var qa=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+X.x+
","+X.y+" L"+Z.x+","+Z.y+" "+S.x+","+S.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function m(S,X){var Z=d.createSVGPoint();Z.x=S;Z.y=X;if(k.length==1)return 0;Z=F.getCharNumAtPosition(Z);if(Z<0){Z=k.length-2;if(S<=k[0].x)Z=0}else if(Z>=k.length-2)Z=k.length-2;var ga=k[Z];S>ga.x+ga.width/2&&Z++;return Z}function z(S,X,Z){var ga=I.selectionStart;S=m(S,X);h(Math.min(ga,S),Math.max(ga,S),!Z)}function w(S,X){var Z={x:S,y:X};Z.x/=o;Z.y/=o;if(C){var ga=N(Z.x,Z.y,C.inverse());Z.x=ga.x;Z.y=ga.y}return Z}
function H(S,X){var Z={x:S,y:X};if(C){var ga=N(Z.x,Z.y,C);Z.x=ga.x;Z.y=ga.y}Z.x*=o;Z.y*=o;return Z}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function u(S){if(U&&F){var X=N(S.pageX,S.pageY,rb);X=w(X.x*o,X.y*o);X=m(X.x,X.y);var Z=F.textContent,ga=Z.substr(0,X).replace(/[a-z0-9]+$/i,"").length;Z=Z.substr(X).match(/^[a-z0-9]+/i);h(ga,(Z?Z[0].length:0)+X);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],v,C,D,P,U;return{select:function(S,
X,Z){F=S;hb.toEditMode(X,Z)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,X,Z,ga){S=w(Z,ga);I.focus();e(m(S.x,S.y));D=Z;P=ga},mouseMove:function(S,X){var Z=w(S,X);z(Z.x,Z.y)},mouseUp:function(S,X,Z){var ga=w(X,Z);z(ga.x,ga.y,true);S.target!==F&&X<D+2&&X>D-2&&Z<P+2&&Z>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var Z=w(S,X);e(m(Z.x,Z.y))}else e();setTimeout(function(){U=
1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(u.wheelDelta)if(u.wheelDelta>=120)F.factor=2;else{if(u.wheelDelta<=-120)F.factor=0.5}else if(u.detail)if(u.detail>0)F.factor=0.5;else if(u.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=c.textActions=function(){function e(S){var Y=I.value===
"";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var Z;Z=k[S];Y||I.setSelectionRange(S,S);E=ra("text_cursor");if(!E){E=document.createElementNS(b,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=ra("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(Z.x,v.y);Z=H(Z.x,v.y+v.height);ma(E,{x1:Y.x,y1:Y.y,x2:Z.x,
y2:Z.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,Y,Z){if(S===Y)e(Y);else{Z||I.setSelectionRange(S,Y);G=ra("text_selectblock");if(!G){G=document.createElementNS(b,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});ra("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,v.y);Z=H(S.x+(ga.x-S.x),v.y);var qa=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+Y.x+
","+Y.y+" L"+Z.x+","+Z.y+" "+S.x+","+S.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function m(S,Y){var Z=d.createSVGPoint();Z.x=S;Z.y=Y;if(k.length==1)return 0;Z=F.getCharNumAtPosition(Z);if(Z<0){Z=k.length-2;if(S<=k[0].x)Z=0}else if(Z>=k.length-2)Z=k.length-2;var ga=k[Z];S>ga.x+ga.width/2&&Z++;return Z}function z(S,Y,Z){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!Z)}function w(S,Y){var Z={x:S,y:Y};Z.x/=o;Z.y/=o;if(C){var ga=N(Z.x,Z.y,C.inverse());Z.x=ga.x;Z.y=ga.y}return Z}
function H(S,Y){var Z={x:S,y:Y};if(C){var ga=N(Z.x,Z.y,C);Z.x=ga.x;Z.y=ga.y}Z.x*=o;Z.y*=o;return Z}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function u(S){if(U&&F){var Y=N(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var Z=F.textContent,ga=Z.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;Z=Z.substr(Y).match(/^[a-z0-9]+/i);h(ga,(Z?Z[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],v,C,D,P,U;return{select:function(S,
Y,Z){F=S;hb.toEditMode(Y,Z)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,Y,Z,ga){S=w(Z,ga);I.focus();e(m(S.x,S.y));D=Z;P=ga},mouseMove:function(S,Y){var Z=w(S,Y);z(Z.x,Z.y)},mouseUp:function(S,Y,Z){var ga=w(Y,Z);z(ga.x,ga.y,true);S.target!==F&&Y<D+2&&Y>D-2&&Z<P+2&&Z>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var Z=w(S,Y);e(m(Z.x,Z.y))}else e();setTimeout(function(){U=
true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,
X=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=X?Y(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var Z={x:v.x+v.width/2,width:0};for(X=0;X<S;X++){var ga=F.getStartPositionOfChar(X);Z=F.getEndPositionOfChar(X);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*o;ga.x-=qa;Z.x-=qa;ga.x/=o;Z.x/=o}k[X]={x:ga.x,y:v.y,width:Z.x-ga.x,height:v.height}}k.push({x:Z.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=c.pathActions=function(){var e=
Y=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=Y?X(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var Z={x:v.x+v.width/2,width:0};for(Y=0;Y<S;Y++){var ga=F.getStartPositionOfChar(Y);Z=F.getEndPositionOfChar(Y);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*o;ga.x-=qa;Z.x-=qa;ga.x/=o;Z.x/=o}k[Y]={x:ga.x,y:v.y,width:Z.x-ga.x,height:v.height}}k.push({x:Z.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=c.pathActions=function(){var e=
false,h,m,z;svgedit.path.Path.prototype.endChanges=function(A){if(svgedit.browser.isWebkit()){var u=this.elem;u.setAttribute("d",Ja.convertPath(u))}A=new Na(this.elem,{d:this.last_d},A);ya(A);M("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var u=0;u<A.length;u++){var F=A[u],I=this.segs[F];I.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();u=this.selected_pts.length;for(A=Array(u);u--;){I=
this.segs[this.selected_pts[u]];I.select(true);A[u]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,u,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;u=mouse_y/o;F=ra("path_stretch_line");m=[I,u];if(n.gridSnapping){I=wa(I);u=wa(u);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(b,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});
F=ra("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var v=E.getItem(G),C=v.x;v=v.y;if(I>=C-L&&I<=C+L&&u>=v-L&&u<=v+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=ra(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;u=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,u):w.createSVGPathSegCurvetoCubicAbs(I,u,A.x1/o,A.y1/o,I,u);I=w.createSVGPathSegClosePath();
@ -297,9 +297,9 @@ G=function(v,C){for(;C--;)I.removeItem(v)};if(E<=1)return true;for(;E--;){var L=
c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var u=A.points,F=u.numberOfItems;if(F>=4){var I=u.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=u.getItem(G),k=u.getItem(G+1),v=u.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E,L,I))&&I.length==
2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,v.x,v.y].join(","));I=v;E=k}for(A.push("L");G<F;++G){k=u.getItem(G);A.push([k.x,k.y].join(","))}A=A.join(" ");A=Q({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,u){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var I={x:0,y:0};
I[A]=u-F.item[A];F.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var u=A.pathSegList,F=u.numberOfItems,I,E=0;E<F;++E){var G=u.getItem(E);if(G.pathSegType===2)I=G;if(G.pathSegType===1){G=u.getItem(E-1);if(G.x!=I.x||G.y!=I.y){u=A.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(A,u,E);Ja.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ja.convertPath(A))},convertPath:function(A,u){for(var F=A.pathSegList,I=F.numberOfItems,E=0,
G=0,L="",k=null,v=0;v<I;++v){var C=F.getItem(v),D=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,X=C.x2||0,Z=C.y2||0,ga=C.pathSegType,qa=Pa[ga]["to"+(u?"Lower":"Upper")+"Case"](),Oa=function(Ba,ha,Ta){ha=ha?" "+ha.join(" "):"";Ta=Ta?" "+svgedit.units.shortFloat(Ta):"";$.each(Ba,function(Ra,ua){Ba[Ra]=svgedit.units.shortFloat(ua)});L+=qa+Ba.join(" ")+ha+Ta};switch(ga){case 1:L+="z";break;case 12:D-=E;case 13:if(u){E+=D;qa="l"}else{D+=E;E=D;qa="L"}Oa([[D,G]]);break;case 14:P-=G;case 15:if(u){G+=P;qa="l"}else{P+=
G;G=P;qa="L"}Oa([[E,P]]);break;case 2:case 4:case 18:D-=E;P-=G;case 5:case 3:if(k&&F.getItem(v-1).pathSegType===1&&!u){E=k[0];G=k[1]}case 19:if(u){E+=D;G+=P}else{D+=E;P+=G;E=D;G=P}if(ga===3)k=[E,G];Oa([[D,P]]);break;case 6:D-=E;U-=E;X-=E;P-=G;S-=G;Z-=G;case 7:if(u){E+=D;G+=P}else{D+=E;U+=E;X+=E;P+=G;S+=G;Z+=G;E=D;G=P}Oa([[U,S],[X,Z],[D,P]]);break;case 8:D-=E;U-=E;P-=G;S-=G;case 9:if(u){E+=D;G+=P}else{D+=E;U+=E;P+=G;S+=G;E=D;G=P}Oa([[U,S],[D,P]]);break;case 10:D-=E;P-=G;case 11:if(u){E+=D;G+=P}else{D+=
E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;X-=E;P-=G;Z-=G;case 17:if(u){E+=D;G+=P}else{D+=E;X+=E;P+=G;Z+=G;E=D;G=P}Oa([[X,Z],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(b,"*"),A=H.length,u=0;u<A;u++){for(var F=H[u],I=0;I<w;I++){var E=
G=0,L="",k=null,v=0;v<I;++v){var C=F.getItem(v),D=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,Y=C.x2||0,Z=C.y2||0,ga=C.pathSegType,qa=Pa[ga]["to"+(u?"Lower":"Upper")+"Case"](),Oa=function(Ba,ha,Ta){ha=ha?" "+ha.join(" "):"";Ta=Ta?" "+svgedit.units.shortFloat(Ta):"";$.each(Ba,function(Ra,ua){Ba[Ra]=svgedit.units.shortFloat(ua)});L+=qa+Ba.join(" ")+ha+Ta};switch(ga){case 1:L+="z";break;case 12:D-=E;case 13:if(u){E+=D;qa="l"}else{D+=E;E=D;qa="L"}Oa([[D,G]]);break;case 14:P-=G;case 15:if(u){G+=P;qa="l"}else{P+=
G;G=P;qa="L"}Oa([[E,P]]);break;case 2:case 4:case 18:D-=E;P-=G;case 5:case 3:if(k&&F.getItem(v-1).pathSegType===1&&!u){E=k[0];G=k[1]}case 19:if(u){E+=D;G+=P}else{D+=E;P+=G;E=D;G=P}if(ga===3)k=[E,G];Oa([[D,P]]);break;case 6:D-=E;U-=E;Y-=E;P-=G;S-=G;Z-=G;case 7:if(u){E+=D;G+=P}else{D+=E;U+=E;Y+=E;P+=G;S+=G;Z+=G;E=D;G=P}Oa([[U,S],[Y,Z],[D,P]]);break;case 8:D-=E;U-=E;P-=G;S-=G;case 9:if(u){E+=D;G+=P}else{D+=E;U+=E;P+=G;S+=G;E=D;G=P}Oa([[U,S],[D,P]]);break;case 10:D-=E;P-=G;case 11:if(u){E+=D;G+=P}else{D+=
E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;Y-=E;P-=G;Z-=G;case 17:if(u){E+=D;G+=P}else{D+=E;Y+=E;P+=G;Z+=G;E=D;G=P}Oa([[Y,Z],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(b,"*"),A=H.length,u=0;u<A;u++){for(var F=H[u],I=0;I<w;I++){var E=
ka(F.getAttribute(z[I]));E&&h.push(E.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(u=e.length;u--;){z=e[u];w=z.id;if(h.indexOf(w)<0){Ab[w]=z;z.parentNode.removeChild(z);m++}}return m};this.svgCanvasToString=function(){for(;Kb()>0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e=
[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w<z;w++)if(m[w].nodeName=="id"||m[w].nodeName=="style")z--;if(z<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var h=this.svgToString(l,0);e.length&&$(e).each(function(){Bb(this)});return h};this.svgToString=function(e,h){var m=[],z=svgedit.utilities.toXml,w=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+w+"$");if(e){na(e);var A=e.attributes,u,F,I=e.childNodes;for(F=0;F<h;F++)m.push(" ");m.push("<");m.push(e.nodeName);
if(e.id==="svgcontent"){F=Eb();if(w!=="px"){F.w=svgedit.units.convertUnit(F.w,w)+w;F.h=svgedit.units.convertUnit(F.h,w)+w}m.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var E={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(v,C){var D=C.namespaceURI;if(D&&!E[D]&&za[D]!=="xmlns"&&za[D]!=="xml"){E[D]=true;m.push(" xmlns:"+za[D]+'="'+D+'"')}})});F=A.length;for(w=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){u=A.item(F);var G=z(u.nodeValue);if(u.nodeName.indexOf("xmlns:")!==
@ -350,7 +350,7 @@ function(e){Za.fill=e;gb("fill",e)};this.getFontSize=function(){return Za.fill};
true;else if(!m)return;var w=new Aa("Change Image URL");W(h,e);w.addSubCommand(new Na(h,{"#href":z}));m?$(new Image).load(function(){var H=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Ha.requestSelector(h).resize();w.addSubCommand(new Na(h,H));ya(w);M("changed",[h])}).attr("src",e):ya(w)}};this.setLinkURL=function(e){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var m=da(h);if(m!==e){var z=new Aa("Change Link URL");W(h,e);
z.addSubCommand(new Na(h,{"#href":m}));ya(z)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:J.every(function(h){return h&&J[0]?h.nodeName==J[0].nodeName:null})};this.setRectRadius=function(e){c.elementsAreSame(J)&&J[0].tagName=="rect"&&J.forEach(function(h){var m=h.getAttribute("rx");if(m!=e){h.setAttribute("rx",e);h.setAttribute("ry",e);ya(new Na(h,{rx:m,ry:m},"Radius"));M("changed",[h])}})};this.makeHyperlink=function(e){c.groupSelectedElements("a",e)};this.removeHyperlink=
function(){c.ungroupSelectedElement()};this.setSegType=function(e){Ja.setSegType(e)};this.convertToPath=function(e,h){if(e==null)$.each(J,function(U,S){S&&c.convertToPath(S)});else{if(!h)var m=new Aa("Convert element to Path");var z=h?{}:{fill:O.fill,"fill-opacity":O.fill_opacity,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,opacity:O.opacity,visibility:"hidden"};
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,u=e.parentNode;e.nextSibling?u.insertBefore(w,e):u.appendChild(w);var F="",I=function(U){$.each(U,function(S,X){var Z=X[1];F+=X[0];for(var ga=0;ga<Z.length;ga+=2)F+=Z[ga]+","+Z[ga+1]+" "})},E=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,u=e.parentNode;e.nextSibling?u.insertBefore(w,e):u.appendChild(w);var F="",I=function(U){$.each(U,function(S,Y){var Z=Y[1];F+=Y[0];for(var ga=0;ga<Z.length;ga+=2)F+=Z[ga]+","+Z[ga+1]+" "})},E=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
"ry","cx","cy"]),L=G.cx,k=G.cy,v=G.rx;G=G.ry;if(e.tagName=="circle")v=G=$(e).attr("r");I([["M",[L-v,k]],["C",[L-v,k-G/E,L-v/E,k-G,L,k-G]],["C",[L+v/E,k-G,L+v,k-G/E,L+v,k]],["C",[L+v,k+G/E,L+v/E,k+G,L,k+G]],["C",[L-v/E,k+G,L-v,k+G/E,L-v,k]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":G=$(e).attr(["x1","y1","x2","y2"]);F="M"+G.x1+","+G.y1+"L"+G.x2+","+G.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":G=$(e).attr(["rx","ry"]);v=G.rx;G=
G.ry;var C=e.getBBox();L=C.x;k=C.y;var D=C.width;C=C.height;E=4-E;!v&&!G?I([["M",[L,k]],["L",[L+D,k]],["L",[L+D,k+C]],["L",[L,k+C]],["L",[L,k]],["Z",[]]]):I([["M",[L,k+G]],["C",[L,k+G/E,L+v/E,k,L+v,k]],["L",[L+D-v,k]],["C",[L+D-v/E,k,L+D,k+G/E,L+D,k+G]],["L",[L+D,k+C-G]],["C",[L+D,k+C-G/E,L+D-v/E,k+C,L+D-v,k+C]],["L",[L+v,k+C]],["C",[L+v/E,k+C,L,k+C-G/E,L,k+C-G]],["L",[L,k+G]],["Z",[]]]);break;default:w.parentNode.removeChild(w)}F&&w.setAttribute("d",F);if(h){Ja.resetOrientation(w);m=false;try{m=
w.getBBox()}catch(P){}w.parentNode.removeChild(w);return m}else{if(H){H=V(w);oa(H)&&Ja.resetOrientation(w)}m.addSubCommand(new Ka(e,e.nextSibling,u));m.addSubCommand(new Ca(w));Qa();e.parentNode.removeChild(e);w.setAttribute("id",A);w.removeAttribute("visibility");vb([w],true);ya(m)}}};var yb=this.changeSelectedAttributeNoUndo=function(e,h,m){var z=d.suspendRedraw(1E3);Ea=="pathedit"&&Ja.moveNode(e,h);m=m||J;for(var w=m.length,H=["g","polyline","path"];w--;){var A=m[w];if(A!=null){Ea==="textedit"&&
@ -361,7 +361,7 @@ var u=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new K
100);ya(z);M("changed",m)}};this.groupSelectedElements=function(e){e||(e="g");var h="";switch(e){case "a":h="Make hyperlink";var m="";if(arguments.length>1)m=arguments[1];break;default:e="g";h="Group Elements"}h=new Aa(h);var z=Q({element:e,attr:{id:ja()}});e==="a"&&W(z,m);h.addSubCommand(new Ca(z));for(m=J.length;m--;){var w=J[m];if(w!=null){if(w.parentNode.tagName==="a"&&w.parentNode.childNodes.length===1)w=w.parentNode;var H=w.nextSibling,A=w.parentNode;z.appendChild(w);h.addSubCommand(new Ia(w,
H,A))}}h.isEmpty()||ya(h);xb([z],true)};var Mb=this.pushGroupProperties=function(e,h){var m=e.childNodes,z=m.length,w=e.getAttribute("transform"),H=V(e),A=fa(H).matrix,u=new Aa("Push group properties"),F=0,I=pa(e),E=$(e).attr(["filter","opacity"]),G,L;for(F=0;F<z;F++){var k=m[F];if(k.nodeType===1){if(E.opacity!==null&&E.opacity!==1){k.getAttribute("opacity");var v=Math.round((k.getAttribute("opacity")||1)*E.opacity*100)/100;gb("opacity",v,[k])}if(E.filter){var C=v=this.getBlur(k);L||(L=this.getBlur(e));
if(v)v=L-0+(v-0);else if(v===0)v=L;if(C)G=R(k.getAttribute("filter"));else if(G){G=la(G);lb().appendChild(G)}else G=R(E.filter);G.id=k.id+"_"+(G.firstChild.tagName==="feGaussianBlur"?"blur":"filter");gb("filter","url(#"+G.id+")",[k]);if(v){gb("stdDeviation",v,[G.firstChild]);c.setBlurOffsets(G,v)}}v=V(k);if(~k.tagName.indexOf("Gradient"))v=null;if(v)if(k.tagName!=="defs")if(H.numberOfItems){if(I&&H.numberOfItems==1){var D=H.getItem(0).matrix,P=d.createSVGMatrix();if(C=pa(k))P=v.getItem(0).matrix;
var U=svgedit.utilities.getBBox(k),S=fa(v).matrix,X=N(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,X.x,X.y);D=ia(D,P,S.matrix.inverse());C&&v.removeItem(0);if(U)v.numberOfItems?v.insertItemBefore(S,0):v.appendItem(S);if(D.e||D.f){C=d.createSVGTransform();C.setTranslate(D.e,D.f);v.numberOfItems?v.insertItemBefore(C,0):v.appendItem(C)}}else{C=k.getAttribute("transform");D={};D.transform=C?C:"";C=d.createSVGTransform();D=fa(v).matrix;P=D.inverse();D=ia(P,A,D);C.setMatrix(D);
var U=svgedit.utilities.getBBox(k),S=fa(v).matrix,Y=N(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,Y.x,Y.y);D=ia(D,P,S.matrix.inverse());C&&v.removeItem(0);if(U)v.numberOfItems?v.insertItemBefore(S,0):v.appendItem(S);if(D.e||D.f){C=d.createSVGTransform();C.setTranslate(D.e,D.f);v.numberOfItems?v.insertItemBefore(C,0):v.appendItem(C)}}else{C=k.getAttribute("transform");D={};D.transform=C?C:"";C=d.createSVGTransform();D=fa(v).matrix;P=D.inverse();D=ia(P,A,D);C.setMatrix(D);
v.appendItem(C)}(k=Ua(k))&&u.addSubCommand(k)}}}if(w){D={};D.transform=w;e.setAttribute("transform","");e.removeAttribute("transform");u.addSubCommand(new Na(e,D))}if(h&&!u.isEmpty())return u};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Db(e);else if(e.tagName==="use"){var h=ra(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Db(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new Aa("Ungroup Elements");var m=
Mb(e,true);m&&h.addSubCommand(m);m=e.parentNode;for(var z=e.nextSibling,w=Array(e.childNodes.length),H=0;e.firstChild;){var A=e.firstChild,u=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ka(A,A.nextSibling,F));F.removeChild(A)}else{w[H++]=A=m.insertBefore(A,z);h.addSubCommand(new Ia(A,u,F))}}Qa();z=e.nextSibling;e=m.removeChild(e);h.addSubCommand(new Ka(e,z,m));h.isEmpty()||ya(h);vb(w)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
m=e.nextSibling;e=e.parentNode.appendChild(e);if(m!=e.nextSibling){ya(new Ia(e,m,h,"top"));M("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,m=e.nextSibling,z=e.parentNode.firstChild;if(z.tagName=="title")z=z.nextSibling;if(z.tagName=="defs")z=z.nextSibling;e=e.parentNode.insertBefore(e,z);if(m!=e.nextSibling){ya(new Ia(e,m,h,"bottom"));M("changed",[e])}}};this.moveUpDownSelected=function(e){var h=J[0];if(h){mb=[];var m,z,w=$(tb(getStrokedBBox([h]))).toArray();
@ -380,7 +380,7 @@ QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo his
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};var s={},c={};b.curConfig=curConfig;b.tool_scale=1;b.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
b.setCustomHandlers=function(d){b.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){b.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);c=d})};b.randomizeIds=function(){g.randomizeIds(arguments)};b.init=function(){function d(k,v){var C=k.id,D=C.split("_"),P=D[0];D=D[1];v&&g.setStrokeAttr("stroke-"+P,D);qb();yb("#cur_"+P,C,20);a(k).addClass("current").siblings().removeClass("current")}function l(k,
v){var C=document.getElementById("ruler_x_cursor"),D=document.getElementById("ruler_y_cursor"),P=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Sb){Sb.stopPropagation();C.style.left=Sb.pageX-66+P.scrollLeft+"px";D.style.top=Sb.pageY-48+P.scrollTop+"px"});v||(v=g.getZoom());k||(k=a("#svgcanvas"));for(var U=g.getContentElem(),S=svgedit.units.getTypeMap()[curConfig.baseUnit],
X=0;X<2;X++){var Z=X===0,ga=Z?"x":"y",qa=Z?"width":"height",Oa=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[qa]()*2;Ba.parentNode.style[qa]=ha+"px";var Ta=0,Ra,ua=Ba.getContext("2d");ua.fillStyle="rgb(200,0,0)";ua.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Ra=Array(Ma);Ra[0]=ua;for(var xa=1;xa<Ma;xa++){Ba[qa]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Y=0;Y<2;Y++){var Z=Y===0,ga=Z?"x":"y",qa=Z?"width":"height",Oa=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[qa]()*2;Ba.parentNode.style[qa]=ha+"px";var Ta=0,Ra,ua=Ba.getContext("2d");ua.fillStyle="rgb(200,0,0)";ua.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Ra=Array(Ma);Ra[0]=ua;for(var xa=1;xa<Ma;xa++){Ba[qa]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Ra[xa]=ab.getContext("2d")}ab[qa]=ga%3E4;ga=3E4}Ba[qa]=ga;qa=S*v;var Xa=50/qa;Ba=1;for(xa=0;xa<I.length;xa++){Ba=Ma=I[xa];if(Xa<=Ma)break}Xa=Ba*qa;ua.font="normal 9px 'Lucida Grande', sans-serif";ua.fillStyle="#777";for(var cb=Oa/qa%Ba*qa,Hb=cb-Xa;cb<ha;cb+=Xa){Hb+=Xa;xa=Math.round(cb)+0.5;if(Z){ua.moveTo(xa,15);ua.lineTo(xa,0)}else{ua.moveTo(15,xa);ua.lineTo(0,xa)}Ma=(Hb-Oa)/qa;if(Ba>=1)xa=Math.round(Ma);else{xa=(Ba+"").split(".")[1].length;xa=Ma.toFixed(xa)-0}if(xa!==0&&xa!==1E3&&xa%1E3===0)xa=
xa/1E3+"K";if(Z){ua.fillText(xa,cb+2,8);ua.fillStyle="#777"}else{Ma=(xa+"").split("");for(xa=0;xa<Ma.length;xa++){ua.fillText(Ma[xa],1,cb+9+xa*9);ua.fillStyle="#777"}}Ma=Xa/10;for(xa=1;xa<10;xa++){var zb=Math.round(cb+Ma*xa)+0.5;if(Ra&&zb>ga){Ta++;ua.stroke();if(Ta>=Ra.length){xa=10;cb=ha;continue}ua=Ra[Ta];cb-=3E4;zb=Math.round(cb+Ma*xa)+0.5}var Gb=xa%2?12:10;if(Z){ua.moveTo(zb,15);ua.lineTo(zb,Gb)}else{ua.moveTo(15,zb);ua.lineTo(Gb,zb)}}}ua.strokeStyle="#666";ua.stroke()}}(function(){var k=window.opener;
if(k)try{var v=k.document.createEvent("Event");v.initEvent("svgEditorReady",true,true);k.document.documentElement.dispatchEvent(v)}catch(C){}})();(function(){a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);a("body").toggleClass("touch",svgedit.browser.isTouch());var k=a.deparam.querystring(true);if(!a.isEmptyObject(k)){if(k.dimensions)k.dimensions=k.dimensions.split(",");if(k.extensions)k.extensions=k.extensions.split(",");if(k.bkgd_color)k.bkgd_color=
@ -392,113 +392,113 @@ spapelib:"shapelib.png",node_delete:"node_delete.png",align_left:"align-left.png
var k=a("#tools_left");if(k.length!=0){k.offset();k.outerHeight()}a(".tools_flyout").each(function(){var v=a("#"+this.id+"_show"),C=v.attr("data-curopt");if(!v.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");v.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},1)}});a("#rulers").on("dblclick",function(k){a("#base_unit_container").css({top:k.pageY-
10,left:k.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});b.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=
0,o=q?"meta+":"ctrl+",K=g.pathActions,T=g.undoMgr,O=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",Q=a("#workarea"),V=a("#cmenu_canvas"),N=null,ia=1,oa="toolbars",fa="";q||a(".shortcut").each(function(){var k=a(this).text();a(this).text(k.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var k=a("#dialog_box"),v=a("#dialog_buttons"),C=function(D,P,U,S){a("#dialog_content").html("<p>"+P.replace(/\n/g,
"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");v.empty();var X=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(v);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(v).on("click, touchstart",function(){k.hide();U(false)});if(D=="prompt"){var Z=a('<input type="text">').prependTo(v);Z.val(S||"");Z.bind("keydown","return",function(){X.trigger("click touchstart")})}D=="process"&&X.hide();k.show();X.on("click touchstart",function(){k.hide();var ga=
D=="prompt"?Z.val():true;U&&U(ga)}).focus();D=="prompt"&&Z.focus()};a.alert=function(D,P){C("alert",D,P)};a.confirm=function(D,P){C("confirm",D,P)};a.process_cancel=function(D,P){C("process",D,P)};a.prompt=function(D,P,U){C("prompt",D,U,P)}})();var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},Y=null,sa=
false,ka=false,da="",W=function(k,v){var C=g.getResolution();a("#svgcanvas").position();var D=g.setBBoxZoom(v,Q.width()-15,Q.height()-15);if(D){var P=D.zoom;D=D.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var X=C.zoom,Z=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(X+S*ga);F();if(ga<1)requestAnimationFrame(Z);else{a("#zoom").val(P*100);a("option","#zoom_select").removeAttr("selected");a("option[value="+P*100+"]","#zoom_select").attr("selected","selected")}};
"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");v.empty();var Y=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(v);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(v).on("click, touchstart",function(){k.hide();U(false)});if(D=="prompt"){var Z=a('<input type="text">').prependTo(v);Z.val(S||"");Z.bind("keydown","return",function(){Y.trigger("click touchstart")})}D=="process"&&Y.hide();k.show();Y.on("click touchstart",function(){k.hide();var ga=
D=="prompt"?Z.val():true;U&&U(ga)}).focus();D=="prompt"&&Z.focus()};a.alert=function(D,P){C("alert",D,P)};a.confirm=function(D,P){C("confirm",D,P)};a.process_cancel=function(D,P){C("process",D,P)};a.prompt=function(D,P,U){C("prompt",D,U,P)}})();var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},X=null,sa=
false,ka=false,da="",W=function(k,v){var C=g.getResolution();a("#svgcanvas").position();var D=g.setBBoxZoom(v,Q.width()-15,Q.height()-15);if(D){var P=D.zoom;D=D.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var Y=C.zoom,Z=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(Y+S*ga);F();if(ga<1)requestAnimationFrame(Z);else{a("#zoom").val(P*100);a("option","#zoom_select").removeAttr("selected");a("option[value="+P*100+"]","#zoom_select").attr("selected","selected")}};
Z(Date.now());g.getMode()=="zoom"&&D.width&&ba();lb()}}};a("#cur_context_panel").delegate("a","click",function(){var k=a(this);k.attr("data-root")?g.leaveContext():g.setContext(k.text());return false});var aa=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},pa={},ra=function(k){a.each(k,function(v,C){var D=a(v).children(),P=v+"_show",U=a(P),S=false;D.addClass("tool_button").unbind("click mousedown mouseup").each(function(ga){var qa=C[ga];pa[qa.sel]=qa.fn;if(qa.isDefault)S=ga;ga=function(Oa){var Ba=
qa;if(Oa.type==="keydown"){var ha=a(Ba.parent+"_show").hasClass("tool_button_current"),Ta=a(Ba.parent+"_show").attr("data-curopt");a.each(k[qa.parent],function(ua,Ma){if(Ma.sel==Ta)Ba=!Oa.shiftKey||!ha?Ma:k[qa.parent][ua+1]||k[qa.parent][0]})}if(a(this).hasClass("disabled"))return false;$a(P)&&Ba.fn();var Ra=Ba.icon?a.getSvgIcon(Ba.icon,true):a(Ba.sel).children().eq(0).clone();Ra[0].setAttribute("width",U.width());Ra[0].setAttribute("height",U.height());U.children(":not(.flyout_arrow_horiz)").remove();
U.append(Ra).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);qa.key&&a(document).bind("keydown",qa.key[0]+" shift+"+qa.key[0],ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var X,Z=a(P).position();a(v).css({left:Z.left+34,top:Z.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var qa=a(v),Oa=Z.left+34,Ba=qa.width()*-1,ha=qa.data("shown_popop")?200:0;X=setTimeout(function(){U.data("isLibrary")?
qa.css("left",Oa).show():qa.css("left",Ba).show().animate({left:Oa},50);qa.data("shown_popop",true)},ha);ga.preventDefault()}).mouseup(function(){clearTimeout(X);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in pa&&pa[ga]()})});za()},ma=function(k,v){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(v)},na=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show"),v=k.offset();
U.append(Ra).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);qa.key&&a(document).bind("keydown",qa.key[0]+" shift+"+qa.key[0],ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var Y,Z=a(P).position();a(v).css({left:Z.left+34,top:Z.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var qa=a(v),Oa=Z.left+34,Ba=qa.width()*-1,ha=qa.data("shown_popop")?200:0;Y=setTimeout(function(){U.data("isLibrary")?
qa.css("left",Oa).show():qa.css("left",Ba).show().animate({left:Oa},50);qa.data("shown_popop",true)},ha);ga.preventDefault()}).mouseup(function(){clearTimeout(Y);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in pa&&pa[ga]()})});za()},ma=function(k,v){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(v)},na=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show"),v=k.offset();
k=k.outerWidth();a(this).css({left:(v.left+k)*ia,top:v.top})})},za=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show");if(!k.data("isLibrary")){var v=[];a(this).children().each(function(){v.push(this.title)});k[0].title=v.join(" / ")}})},Fa,Ia=function(k,v,C){var D=null;if(k.indexOf("url(#")===0){k=(k=g.getRefElem(k))?k.cloneNode(true):a("#"+C+"_color defs *")[0];D={alpha:v};D[k.tagName]=k}else D=k.indexOf("#")===0?{alpha:v,solidColor:k.substr(1)}:{alpha:v,solidColor:"none"};
return new a.jGraduate.Paint(D)},Ca=g.getResolution();if(curConfig.baseUnit!=="px"){Ca.w=svgedit.units.convertUnit(Ca.w)+curConfig.baseUnit;Ca.h=svgedit.units.convertUnit(Ca.h)+curConfig.baseUnit}var Ka=function(k){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ca.w+2,height:Ca.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:k||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||
Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=b.setImageURL=function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},Aa=function(){var k=Y;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var v=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item",
"#object_menu").addClass("disabled");if(sa){sa=sa.filter(Boolean);(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected")}if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,X=g.getRotationAngle(k);a("#angle").val(Math.round(X));X=g.getBlur(k);a("#blur").val(X);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var Z,ga;
Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=b.setImageURL=function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},Aa=function(){var k=X;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var v=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item",
"#object_menu").addClass("disabled");if(sa){sa=sa.filter(Boolean);(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected")}if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,Y=g.getRotationAngle(k);a("#angle").val(Math.round(Y));Y=g.getBlur(k);a("#blur").val(Y);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var Z,ga;
if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){Z=C.x;ga=C.y}if(D){Z=svgedit.units.convertUnit(Z);ga=svgedit.units.convertUnit(ga)}a("#"+S+"_x").val(Math.round(Z));a("#"+S+"_y").val(Math.round(ga));if(S==="polyline"){a("#path_x").val(Math.round(Z));a("#path_y").val(Math.round(ga))}["image","text","path","g","use"].indexOf(S)==-1&&a(".action_path_convert_selected").removeClass("disabled");S==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();
a("#stroke_panel").hide();v=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);yb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(v){P=a("#seg_type");if(D){v.x=svgedit.units.convertUnit(v.x);v.y=svgedit.units.convertUnit(v.y)}a("#path_node_x").val(Math.round(v.x));a("#path_node_y").val(Math.round(v.y));v.type?P.val(v.type).removeAttr("disabled"):P.val(4).attr("disabled",
"disabled")}return}D=null;if(qa==="a"){D=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show();D=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!D);D&&a("#link_url").val(D);D={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var qa=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();
if(qa=="path"||qa=="polyline")a("#path_panel").show();if(D[qa]){D=D[qa];a("#"+qa+"_panel").show();qa=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(D,function(Oa,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!=="px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Ta=document.getElementById(qa+"_"+Ba);Ta.value=Math.round(ha)||0;Ta.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Ta)});if(qa=="text"){D=k.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=
3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active",g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);a("#preview_font").text(D.split(",")[0].replace(/'/g,"")).css("font-family",D);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(qa=="image")Na(g.getHref(k));else if(qa==="g"||qa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");
g.getTitle()}}U[(qa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(qa==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}if(sa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}k||U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");
T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(v);V.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,v){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";Y=v.length==1||v[1]==null?v[0]:null;v=v.filter(Boolean);sa=v.length>=2?v:
false;if(Y!=null)if(!C){if(Y!=null)switch(Y.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=Y.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var X=P[U].getAttribute("stroke-width");if(U===0)D=X;else if(D!==X)D=null}a("#stroke_width").val(D===null?"":D);b.paintBox.fill.update(true);b.paintBox.stroke.update(true);break;default:b.paintBox.fill.update(true);b.paintBox.stroke.update(true);a("#stroke_width").val(Y.getAttribute("stroke-width")||1);D=Y.getAttribute("stroke-dasharray")||
"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+D+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);D=Y.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+D).length!=0&&d(a("#linejoin_"+D)[0]);D=Y.getAttribute("stroke-linecap")||"butt";a("#linecap_"+D).length!=0&&d(a("#linecap_"+D)[0])}if(Y!=null){D=(Y.getAttribute("opacity")||1)*100;a("#group_opacity").val(D);a.fn.dragInput.updateCursor(a("#group_opacity")[0])}}D=
v;a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");yb("#tool_select","select_node");sa=false;if(D.length)Y=D[0]}else{if(D[0]){C=g.selectorManager.requestSelector(D[0]);C.reset(D[0]);C.selectorRect.setAttribute("display","inline")}yb("#tool_select","select")}g.runExtensions("selectedChanged",{elems:v,selectedElement:Y,
multiselected:sa})});g.bind("transition",function(k,v){var C=g.getMode(),D=v[0];if(D){sa=v.length>=2&&v[1]!=null?v:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(D);a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",{elems:v})}});g.bind("changed",function(k,v){var C=g.getMode();C==="select"&&ba();for(var D=0;D<v.length;++D){var P=v[D];if(P&&P.tagName==="svg")F();else if(P&&Y&&Y.parentNode==null)Y=P}b.show_save_warning=
true;Aa();if(Y&&C==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:v})});g.bind("saved",function(k,v){b.show_save_warning=false;v='<?xml version="1.0"?>\n'+v;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var D=k.open("data:image/svg+xml;base64,"+O.encode64(v)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==
-1)if(v.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");P!=="part"&&D.alert(U)}}});g.bind("exported",function(k,v){var C=v.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=g.contentW;D.height=g.contentH;canvg(D,v.svg,{renderCallback:function(){var P=D.toDataURL("image/png");N.location.href=
P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+C.join("\n \u2022 ");a.pref("export_notice_done","all");N.alert(P)}}})});g.bind("zoomed",W);g.bind("contextset",function(k,v){var C="";if(v){var D="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(v).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;
C+=this!==v?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=D}else da=null;a("#cur_context_panel").toggle(!!v).html(C)});g.bind("extension_added",function(k,v){function C(){if(Fa){clearTimeout(Fa);Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},50))}var D=false,P=false,U=true,S=function(){if(v.callback&&!D&&U){D=true;v.callback()}},X=[];v.context_tools&&a.each(v.context_tools,function(Ba,ha){var Ta=ha.container_id?' id="'+ha.container_id+'"':"",Ra=a("#"+ha.panel);Ra.length||(Ra=a("<div>",
{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ua='<div class="tool_button">'+ha.id+"</div>",Ma=a(ua).appendTo(Ra);ha.events&&a.each(ha.events,function(Xa,cb){a(Ma).bind(Xa,cb)});break;case "select":ua="<label"+Ta+'><select id="'+ha.id+'">';a.each(ha.options,function(Xa,cb){ua+='<option value="'+Xa+'"'+(Xa==ha.defval?" selected":"")+">"+cb+"</option>"});ua+="</select></label>";var xa=a(ua).appendTo(Ra).find("select");a.each(ha.events,function(Xa,cb){a(xa).bind(Xa,
cb)});break;case "button-select":ua='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Ta=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");ha.colnum&&Ta.addClass("optcols"+ha.colnum);a(ua).appendTo(Ra).children();X.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ua="<label"+Ta+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+
ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ua).appendTo(Ra).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Xa,cb){ab.bind(Xa,cb)})}});if(v.buttons){var Z={},ga={},qa=v.svgicons,Oa={};a.each(v.buttons,function(Ba,ha){for(var Ta,Ra=ha.id,ua=Ba;a("#"+Ra).length;)Ra=ha.id+"_"+ ++ua;if(qa){Z[Ra]=ha.icon;ua=ha.svgicon?ha.svgicon:ha.id;if(ha.type=="app_menu")ga["#"+Ra+" > div"]=ua;else ga["#"+
Ra]=ua}else Ta=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||
ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Ra).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):a(xa).after(ab);if(ha.type=="mode_flyout"){ua=a(ab);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){var Xa=ua[0].id.replace("tool_","tools_"),cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua);Ma.data("isLibrary",
true);cb.data("isLibrary",true)}ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+ha.list).append(ab.children().clone());ua=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ua}}else if(ha.includeWith){xa=ha.includeWith;ua=a(xa.button);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){Xa=
ua[0].id.replace("tool_","tools_");cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua)}var Hb=u.getButtonData(xa.button);if(xa.isDefault)ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,key:ha.key,isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Xa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Hb)Ma.children().eq(Xa).before(ab);else{Ma.append(ab);Ra.reverse()}}qa||
ab.append(Ta);ha.list||a.each(ha.events,function(zb,Gb){if(zb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(zb,Gb):ab.bind(zb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",ha.title+" ["+ha.key+"]")}}else ab.bind(zb,Gb);else ab.bind(zb,Gb)});ra(Oa)});a.each(X,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(qa)U=false;a.svgIcons(qa,{w:27,h:27,id_match:false,no_img:!B,fallback:Z,placement:ga,callback:function(){s.iconsize&&
s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff",
"#aad4ff"],function(k,v){ya+='<div class="palette_item" style="background-color: '+v+';" data-rgb="'+v+'"></div>'});a("#palette").append(ya);var Ha=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Ha.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var v=k.value/100;if(v<0.0010)k.value=0.1;else{k=g.getZoom();W(window,{width:0,height:0,x:(Q[0].scrollLeft+Q.width()/2)/k,y:(Q[0].scrollTop+Q.height()/
2)/k,zoom:v},true)}},qb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);qb()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});
changeAttribute=function(k){var v=k.getAttribute("data-attr"),C=k.getAttribute("data-multiplier")||1;C=parseFloat(C);C=k.value*C;if(!svgedit.units.isValidUnit(v,C,Y)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=Y.getAttribute(v);return false}g.changeSelectedAttributeNoUndo(v,C)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),
v=k?"stroke":"fill",C=a(this).attr("data-rgb"),D=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});b.paintBox[v].setPaint(D);if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display",
"table-cell");a(this).addClass("expanded");z()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");z()});var $a=function(k,v){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;var C=C||"normal";v||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=
null,v=null,C=Q[0],D=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(D!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-v;k=U.clientX;v=U.clientY;if(U.type==="mouseup"||U.type==="touchend")D=false;return false}}).on("mousedown touchmove",function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){D=true;k=U.clientX;v=U.clientY;return false}});a(window).mouseup(function(){D=false;a("body").removeClass("dragging")});a(document).bind("keydown",
"space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&Q.removeClass("out")})})();var ib=a(".menu"),Wa=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background=
"#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){Wa(k)});a("svg, body").on("mousedown touchstart",function(k){if(k.target.nodeName.toLowerCase()!=="input")if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Wa(k):a("#menu_bar").removeClass("active")});
var Sa=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,v,C,D){if(k.altKey){k.preventDefault();k=g.getZoom()*100;v=Sa.length;for(E=0;E<v;E++){C=Math.min(v,E+1);if(D>0)zoom=Sa[E]<=k?Sa[C]:zoom;if(D<0)zoom=Sa[E]<k?Sa[E]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");
a(this).parent().addClass("open")});b.addDropDown=function(k,v,C){if(a(k).length!=0){var D=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+"-list");C||a("#option_lists").append(P);var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",v);a(window).mouseup(function(){if(!U){D.removeClass("down");P.hide()}U=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");P.hide()}else{D.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-
110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,v,C,D){var P=a(k);v=a(v);var U=false,S=D.dropUp;S&&a(k).addClass("dropup");v.find("li").bind("mouseup",function(){if(D.seticon){yb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");v.hide();v.css({top:0,left:0})}U=false});v.height();a(k).bind("mousedown",function(){var X=
a(k).offset();if(S){X.top-=v.height();X.left+=8}else X.top+=a(k).height();a(v).offset(X);if(P.hasClass("down")){P.removeClass("down");v.hide();v.css({top:0,left:0})}else{P.addClass("down");v.show();U=true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});D.multiclick&&v.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,v=this.options[this.selectedIndex].text;a("#preview_font").html(v).css("font-family",k);
a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,"page")})});(function(){var k,v=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;oa="toolbars";Q.mousedown(v)}).blur(function(){oa="canvas";Q.unbind("mousedown",v);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&
g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Va=function(){$a("#tool_rect")&&g.setMode("rect")},Ea=function(){$a("#tool_ellipse")&&g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ta=function(){if(Y!=
null||sa)g.deleteSelectedElements()},mb=function(){if(Y!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(Y!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.copySelectedElements()}},Ab=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),v=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",v,k)},ob=function(){if(Y!=null){window.event.type===
"keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},
Bb=function(){if(Y!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);g.clearSelection()}},la=function(){Y!=null&&K.reorient()},ca=function(){if(Y!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,v){if(Y!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;v*=C}a("input").blur();
g.moveSelectedElements(k,v)}},M=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),v=!k.hasClass("push_button_pressed");v?k.addClass("push_button_pressed").removeClass("tool_button"):
k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(v)},Pa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,v){if(!(Y==null||sa)){k||(v*=-1);var C=a("#angle").val()*1+v;g.setRotationAngle(C);Aa()}},Ua=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(v){if(v){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();Aa();aa();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());
Aa();return false},Qa=function(){g.setItalic(!g.getItalic());Aa();return false},vb=function(){if(!c.pngsave){var k=uiStrings.notification.loadingImage;N=window.open("data:text/html;charset=utf-8,<title>"+k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},xb=function(){g.open()},Ib=function(){},pb=function(k){var v=k.prev();v.css("background","#09f");setTimeout(function(){v.css("background",
"")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else Y&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},
Ob=function(){var k=document.querySelector("#tool_stroke rect"),v=document.querySelector("#tool_fill rect"),C=v.getAttribute("fill"),D=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));if(isNaN(k))k=100;v=parseFloat(v.getAttribute("fill-opacity"));if(isNaN(v))v=100;D=Ia(D,k,"stroke");C=Ia(C,v,"fill");b.paintBox.fill.setPaint(D,true);b.paintBox.stroke.setPaint(C,true)},Db=function(k){var v=g.getResolution();k=k?v.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?
a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");lb()}},Jb=function(){var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},Rb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},
Eb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},lb=function(){if(!H){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(Q.hasClass("wireframe")?
k:"")}},Qb=function(k,v){if(!ka){ka=true;a("#save_output_btns").toggle(!!v);a("#tool_source_back").toggle(!v);var C=fa=g.getSvgString();a("#svg_source_textarea").val(C);a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();aa()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;
g.clearSelection();m();Db();aa()});ba()}},yb=b.setIcon=function(k,v){var C=typeof v==="string"?a.getSvgIcon(v,true):v.clone();C?a(k).find("img").replaceWith(C):console.log("NOTE: Icon image missing: "+v)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,v=document.getElementsByTagName("script")[0],C;for(C in v.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in v.style)return"Webkit";if("KhtmlOpacity"in v.style)return"Khtml";return""}();var Mb=function(k,v){gb.toLowerCase();
var C=["top","left","bottom","right"];k.each(function(){for(var D=a(this),P=D.outerWidth()*(v-1),U=D.outerHeight()*(v-1),S=0;S<4;S++){var X=C[S],Z=D.data("orig_margin-"+X);if(Z==null){Z=parseInt(D.css("margin-"+X));D.data("orig_margin-"+X,Z)}Z=Z*v;if(X==="right")Z+=P;else if(X==="bottom")Z+=U;D.css("margin-"+X,Z)}})},e=b.setIconSize=function(k,v){if(!(k==s.size&&!v)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),
D=1;D=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=ia=D;na();var P=C.parents(":hidden");P.css("visibility","hidden").show();Mb(C,D);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,X){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(X,function(Z,ga){if(typeof ga==="number")var qa=ga*D+"px";else if(ga[k]||ga.all)qa=
ga[k]||ga.all;U+=Z+":"+qa+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+P+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/D+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();
if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var z=a.noop;a(window).resize(function(){F()});(function(){Q.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=Q[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=Q[0].scrollTop})})();
a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var k=g.getHref(Y);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(v){v&&Na(v)})});var w=function(k){var v=k[0].id=="stroke_color"?"stroke":"fill",C=k[0].id=="canvas_color";if(C)v="canvas";var D=b.paintBox[v].paint;k=v=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",
containment:"window"}).css(C).jGraduate({paint:D,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){D=new a.jGraduate.Paint(P);b.paintBox[v].setPaint(D);g.setPaint(v,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,v){var C=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(v=="stroke")D=curConfig.initStroke;if(v=="fill")D=curConfig.initFill;if(v=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D=
{color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+D.color+'" opacity="'+D.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));v==="canvas"?C.setAttribute("width",60.5):
C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=v;this.setPaint=function(P,U){this.paint=P;var S="none",X=P.type,Z=P.alpha/100;switch(X){case "solidColor":S=P[X]=="none"||P[X]=="one"?"none":"#"+P[X];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[X]);S="url(#"+(this.grad.id="gradbox_"+
this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",Z);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,Z,true)}if(this.type=="canvas")(X=document.getElementById("canvas_background"))?X.setAttribute("fill",S):Ka(S)};this.update=function(P){if(Y){var U=this.type;switch(Y.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,X=Y.getElementsByTagName("*"),Z=0,ga=X.length;Z<ga;Z++){var qa=X[Z].getAttribute(U);if(Z===0)S=
qa;else if(S!==qa){S=null;break}}if(S===null){X=null;return}X=S;S=1;break;default:S=parseFloat(Y.getAttribute(U+"-opacity"));if(isNaN(S))S=1;X=U==="fill"?"black":"none";X=Y.getAttribute(U)||X}if(P){g.setColor(U,X,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(X,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=new a.jGraduate.Paint({copy:this.paint});g.setPaint(v,P)}}};b.paintBox.fill=new q("#fill_color","fill");b.paintBox.stroke=new q("#stroke_color",
"stroke");b.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=b.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var H=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(q).remove();
setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))w(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",
function(){if(a("#tool_stroke").hasClass("active"))w(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){w(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");w(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");w(a("#fill_color"))});
a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a(window).bind("load resize",function(){Q.css("line-height",
Q.height()+"px")});var A=function(){var k=a("#canvas_width"),v=a("#canvas_height"),C=k.val(),D=v.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);v.parent().addClass("error");return false}v.parent().removeClass("error");if(!g.setResolution(C,D)){a.alert(uiStrings.notification.noContentToFitTo);
C=g.getResolution();k.val(C.w);v.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],v=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";v.value="fit";A();var C=g.getResolution();k.value=C.w;v.value=C.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var P=D[0]-k.value,U=D[1]-v.value,S=Date.now(),X=function(Z){Z=(Z-S)/1E3;Z=Math.pow(Z-1,3)+1;k.value=(D[0]-P+Z*P).toFixed(0);v.value=(D[1]-U+Z*U).toFixed(0);
A();if(Z>=1){Z=g.getResolution();a("#canvas_width").val(Z.w.toFixed());a("#canvas_height").val(Z.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Z.w+"<span>\u00d7</span></br>"+Z.h+"</div>")}else requestAnimationFrame(X)};X(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;v.value=100}}});a("#zoom").change(function(){wa(this)});a("input,select").attr("autocomplete","off");var u=function(){var k=[{sel:"#tool_select",
fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Va,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Ua,evt:"mouseup",
key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():g.save({images:s.img_save,round_digits:6})},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:xb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ta,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:M,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Pa,evt:"click"},{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},
{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Bb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},
{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:Ab,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:Qa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},
{key:"ctrl+left",fn:function(){nb(0,1)}},{key:"ctrl+right",fn:function(){nb(1,1)}},{key:"ctrl+shift+left",fn:function(){nb(0,5)}},{key:"ctrl+shift+right",fn:function(){nb(1,5)}},{key:"shift+O",fn:db},{key:"shift+P",fn:Ya},{key:[o+"+",true],fn:function(){Db(2)}},{key:[o+"-",true],fn:function(){Db(0.5)}},{key:["up",true],fn:function(){ja(0,-1)}},{key:["down",true],fn:function(){ja(0,1)}},{key:["left",true],fn:function(){ja(-1,0)}},{key:["right",true],fn:function(){ja(1,0)}},{key:"shift+up",fn:function(){ja(0,
-10)}},{key:"shift+down",fn:function(){ja(0,10)}},{key:"shift+left",fn:function(){ja(-10,0)}},{key:"shift+right",fn:function(){ja(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var C=a(".tool_button_current");if(C.length&&C[0].id!=="tool_eyedropper"){C.removeClass("tool_button_current").addClass("tool_button");a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},
{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],v={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(D,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var X=P.fn,
Z=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)Z=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(qa,Oa){a(document).bind("keydown",Oa,function(Ba){X();Z&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";v[S]=P.sel;U.parents("#main_menu").length||U.attr("title",ga)}}});ra(C);a(window).bind("keydown","tab",function(D){if(oa===
"canvas"){D.preventDefault();Ya()}}).bind("keydown","shift+tab",function(D){if(oa==="canvas"){D.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(v,function(C,D){var P=a(D).parents("#main_menu").length;a(D).each(function(){var U=P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(X,Z){var ga=Z.split("+"),qa="";if(ga.length>1){qa=ga[0]+"+";Z=ga[1]}S+=(X?"/":"")+qa+(uiStrings["key_"+Z]||Z)});if(P)this.lastChild.textContent=U+" ["+
S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var D;a.each(k,function(P,U){if(U.sel===C)D=U});return D}}}();u.setAll();b.ready(function(){var k=curConfig.initTool,v=a("#tools_left, #svg_editor .tools_flyout"),C=v.find("#tool_"+k);k=v.find("#"+k);(C.length?C:k.length?k:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});a("#canvas_height").dragInput({min:10,max:null,
step:10,callback:A,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:A,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});
a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1,max:null,step:1,callback:changeAttribute,
cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_width").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});
a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var v=k.value;if(v==0&&Y&&["line","polyline"].indexOf(Y.nodeName)>=
0)v=k.value=1;g.setStrokeWidth(v)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,v){var C=k.value-0,D=C+v,P=D>=C;if(v===0)return C;return C>=24?P?Math.round(C*1.1):Math.round(C/1.1):
C<=1?P?C*2:C/2:D}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);g.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ta();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();break;case "paste_in_place":g.pasteElements("in_place");
break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":ob();break;case "move_up":wb("Up");break;case "move_down":wb("Down");break;case "move_back":eb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();V.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=
function(){if(T.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;b.openPrep(function(v){if(v){g.clear();if(k.files.length==1){v=new FileReader;v.onloadend=function(C){p(C.target.result);F()};v.readAsText(k.files[0])}}})});
a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(v){g.importSvgString(v.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=b.updateCanvas=function(k,v){var C=Q.width(),D=Q.height(),P=C,U=D,S=g.getZoom(),X=a("#svgcanvas"),Z={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);D=
Math.max(U,g.contentH*S*ga);C==P&&D==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=X.height()/2;var qa=X.width()/2;X.width(C).height(D);var Oa=D/2,Ba=C/2,ha=g.updateCanvas(C,D),Ta=Ba/qa;C=C/2-P/2;D=D/2-U/2;if(v){v.x+=ha.x;v.y+=ha.y}else v={x:Ba+(Z.x-qa)*Ta,y:Oa+(Z.y-ga)*Ta};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=D}else{Q[0].scrollLeft=v.x-P/2;Q[0].scrollTop=v.y-U/2}if(curConfig.showRulers){l(X,S);Q.scroll()}},
I=[],E=0.1;E<1E5;E*=10){I.push(1*E);I.push(2*E);I.push(5*E)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var v=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(k.length){for(var C=0;C<
k.length;C++)k[C]=v(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var D in k)C.push(v(D)+":"+v(k[D]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var v=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+v+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+v+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,v){a.pref("lang",k);a("#lang_select").val(k);
if(v){g.runExtensions("langChanged",k);za();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,D){a(D).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(d){n?d():f.push(d)};b.runCallbacks=function(){a.each(f,function(){this()});
n=true};b.loadFromString=function(d){b.ready(function(){p(d)})};b.loadFromURL=function(d,l){l||(l={});var q=l.cache,B=l.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,T){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+T+"",B)}})})};b.loadFromDataURI=function(d){b.ready(function(){var l=d.substring(26);p(svgedit.utilities.decode64(l))})};b.addExtension=function(){var d=arguments;
a(function(){g&&g.addExtension.apply(this,d)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(v);V.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,v){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";X=v.length==1||v[1]==null?v[0]:null;v=v.filter(Boolean);sa=v.length>=2?v:
false;if(g.elementsAreSame(sa))X=sa[0];if(X!=null){if(!C){a("#multiselected_panel").hide();if(X!=null)switch(X.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=X.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var Y=P[U].getAttribute("stroke-width");if(U===0)D=Y;else if(D!==Y)D=null}a("#stroke_width").val(D===null?"":D);b.paintBox.fill.update(true);b.paintBox.stroke.update(true);break;default:b.paintBox.fill.update(true);b.paintBox.stroke.update(true);
a("#stroke_width").val(X.getAttribute("stroke-width")||1);D=X.getAttribute("stroke-dasharray")||"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+D+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);D=X.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+D).length!=0&&d(a("#linejoin_"+D)[0]);D=X.getAttribute("stroke-linecap")||"butt";a("#linecap_"+D).length!=0&&d(a("#linecap_"+D)[0])}if(X!=
null){D=(X.getAttribute("opacity")||1)*100;a("#group_opacity").val(D);a.fn.dragInput.updateCursor(a("#group_opacity")[0])}}sa.length&&a("#tools_top").addClass("multiselected")}else if(sa.length){a(".context_panel").hide();a("#tools_top").removeClass("multiselected");a("#multiselected_panel").show()}else{a(".context_panel").hide();a("#canvas_panel").show();a("#tools_top").removeClass("multiselected")}D=v;a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");
a("#tool_select").addClass("tool_button_current").removeClass("tool_button");yb("#tool_select","select_node");sa=false;if(D.length)X=D[0]}else{if(D[0]){C=g.selectorManager.requestSelector(D[0]);C.reset(D[0]);C.selectorRect.setAttribute("display","inline")}yb("#tool_select","select")}g.runExtensions("selectedChanged",{elems:v,selectedElement:X,multiselected:sa})});g.bind("transition",function(k,v){var C=g.getMode(),D=v[0];if(D){sa=v.length>=2&&v[1]!=null?v:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(D);
a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",{elems:v})}});g.bind("changed",function(k,v){var C=g.getMode();C==="select"&&ba();for(var D=0;D<v.length;++D){var P=v[D];if(P&&P.tagName==="svg")F();else if(P&&X&&X.parentNode==null)X=P}b.show_save_warning=true;Aa();if(X&&C==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:v})});g.bind("saved",function(k,v){b.show_save_warning=
false;v='<?xml version="1.0"?>\n'+v;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var D=k.open("data:image/svg+xml;base64,"+O.encode64(v)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(v.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done",
"all");P!=="part"&&D.alert(U)}}});g.bind("exported",function(k,v){var C=v.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=g.contentW;D.height=g.contentH;canvg(D,v.svg,{renderCallback:function(){var P=D.toDataURL("image/png");N.location.href=P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+
C.join("\n \u2022 ");a.pref("export_notice_done","all");N.alert(P)}}})});g.bind("zoomed",W);g.bind("contextset",function(k,v){var C="";if(v){var D="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(v).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;C+=this!==v?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=D}else da=null;a("#cur_context_panel").toggle(!!v).html(C)});g.bind("extension_added",function(k,v){function C(){if(Fa){clearTimeout(Fa);
Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},50))}var D=false,P=false,U=true,S=function(){if(v.callback&&!D&&U){D=true;v.callback()}},Y=[];v.context_tools&&a.each(v.context_tools,function(Ba,ha){var Ta=ha.container_id?' id="'+ha.container_id+'"':"",Ra=a("#"+ha.panel);Ra.length||(Ra=a("<div>",{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ua='<div class="tool_button">'+ha.id+"</div>",Ma=a(ua).appendTo(Ra);ha.events&&a.each(ha.events,function(Xa,cb){a(Ma).bind(Xa,
cb)});break;case "select":ua="<label"+Ta+'><select id="'+ha.id+'">';a.each(ha.options,function(Xa,cb){ua+='<option value="'+Xa+'"'+(Xa==ha.defval?" selected":"")+">"+cb+"</option>"});ua+="</select></label>";var xa=a(ua).appendTo(Ra).find("select");a.each(ha.events,function(Xa,cb){a(xa).bind(Xa,cb)});break;case "button-select":ua='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Ta=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");
ha.colnum&&Ta.addClass("optcols"+ha.colnum);a(ua).appendTo(Ra).children();Y.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ua="<label"+Ta+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ua).appendTo(Ra).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Xa,
cb){ab.bind(Xa,cb)})}});if(v.buttons){var Z={},ga={},qa=v.svgicons,Oa={};a.each(v.buttons,function(Ba,ha){for(var Ta,Ra=ha.id,ua=Ba;a("#"+Ra).length;)Ra=ha.id+"_"+ ++ua;if(qa){Z[Ra]=ha.icon;ua=ha.svgicon?ha.svgicon:ha.id;if(ha.type=="app_menu")ga["#"+Ra+" > div"]=ua;else ga["#"+Ra]=ua}else Ta=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+
ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Ra).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):
a(xa).after(ab);if(ha.type=="mode_flyout"){ua=a(ab);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){var Xa=ua[0].id.replace("tool_","tools_"),cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua);Ma.data("isLibrary",true);cb.data("isLibrary",true)}ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");
a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+ha.list).append(ab.children().clone());ua=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ua}}else if(ha.includeWith){xa=ha.includeWith;ua=a(xa.button);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){Xa=ua[0].id.replace("tool_","tools_");cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua)}var Hb=u.getButtonData(xa.button);if(xa.isDefault)ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+
Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,key:ha.key,isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Xa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Hb)Ma.children().eq(Xa).before(ab);else{Ma.append(ab);Ra.reverse()}}qa||ab.append(Ta);ha.list||a.each(ha.events,function(zb,Gb){if(zb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(zb,Gb):ab.bind(zb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",
ha.title+" ["+ha.key+"]")}}else ab.bind(zb,Gb);else ab.bind(zb,Gb)});ra(Oa)});a.each(Y,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(qa)U=false;a.svgIcons(qa,{w:27,h:27,id_match:false,no_img:!B,fallback:Z,placement:ga,callback:function(){s.iconsize&&s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00",
"#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(k,v){ya+='<div class="palette_item" style="background-color: '+v+';" data-rgb="'+v+'"></div>'});a("#palette").append(ya);var Ha=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k=
"rotate("+k+"deg)";Ha.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var v=k.value/100;if(v<0.0010)k.value=0.1;else{k=g.getZoom();W(window,{width:0,height:0,x:(Q[0].scrollLeft+Q.width()/2)/k,y:(Q[0].scrollTop+Q.height()/2)/k,zoom:v},true)}},qb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);
qb()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k){var v=k.getAttribute("data-attr"),C=k.getAttribute("data-multiplier")||1;C=parseFloat(C);C=k.value*C;if(!svgedit.units.isValidUnit(v,C,X)){a.alert(uiStrings.notification.invalidAttrValGiven);
k.value=X.getAttribute(v);return false}g.changeSelectedAttributeNoUndo(v,C)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),v=k?"stroke":"fill",C=a(this).attr("data-rgb"),D=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});b.paintBox[v].setPaint(D);
if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");z()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");z()});var $a=function(k,v){if(a(k).hasClass("disabled"))return false;
if(a(k).parent().hasClass("tools_flyout"))return true;var C=C||"normal";v||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=null,v=null,C=Q[0],D=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(D!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-v;k=U.clientX;v=U.clientY;
if(U.type==="mouseup"||U.type==="touchend")D=false;return false}}).on("mousedown touchmove",function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){D=true;k=U.clientX;v=U.clientY;return false}});a(window).mouseup(function(){D=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()===
"zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&Q.removeClass("out")})})();var ib=a(".menu"),Wa=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",
function(k){Wa(k)});a("svg, body").on("mousedown touchstart",function(k){if(k.target.nodeName.toLowerCase()!=="input")if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Wa(k):a("#menu_bar").removeClass("active")});var Sa=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,v,C,D){if(k.altKey){k.preventDefault();k=g.getZoom()*100;v=Sa.length;for(E=0;E<v;E++){C=
Math.min(v,E+1);if(D>0)zoom=Sa[E]<=k?Sa[C]:zoom;if(D<0)zoom=Sa[E]<k?Sa[E]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(k,v,C){if(a(k).length!=0){var D=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+"-list");C||a("#option_lists").append(P);
var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",v);a(window).mouseup(function(){if(!U){D.removeClass("down");P.hide()}U=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");P.hide()}else{D.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,v,C,D){var P=a(k);v=a(v);var U=false,S=D.dropUp;S&&a(k).addClass("dropup");v.find("li").bind("mouseup",
function(){if(D.seticon){yb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");v.hide();v.css({top:0,left:0})}U=false});v.height();a(k).bind("mousedown",function(){var Y=a(k).offset();if(S){Y.top-=v.height();Y.left+=8}else Y.top+=a(k).height();a(v).offset(Y);if(P.hasClass("down")){P.removeClass("down");v.hide();v.css({top:0,left:0})}else{P.addClass("down");v.show();U=
true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});D.multiclick&&v.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,v=this.options[this.selectedIndex].text;a("#preview_font").html(v).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,"page")})});
(function(){var k,v=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;oa="toolbars";Q.mousedown(v)}).blur(function(){oa="canvas";Q.unbind("mousedown",v);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Va=function(){$a("#tool_rect")&&g.setMode("rect")},Ea=function(){$a("#tool_ellipse")&&
g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ta=function(){if(X!=null||sa)g.deleteSelectedElements()},mb=function(){if(X!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(X!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));
g.copySelectedElements()}},Ab=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),v=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",v,k)},ob=function(){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(X!=null){window.event.type==="keydown"&&
pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},Bb=function(){if(X!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);g.clearSelection()}},la=function(){X!=
null&&K.reorient()},ca=function(){if(X!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,v){if(X!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;v*=C}a("input").blur();g.moveSelectedElements(k,v)}},M=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",
false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),v=!k.hasClass("push_button_pressed");v?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(v)},Pa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,v){if(!(X==null||sa)){k||(v*=-1);
var C=a("#angle").val()*1+v;g.setRotationAngle(C);Aa()}},Ua=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(v){if(v){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();Aa();aa();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());Aa();return false},Qa=function(){g.setItalic(!g.getItalic());Aa();return false},vb=function(){if(!c.pngsave){var k=uiStrings.notification.loadingImage;N=window.open("data:text/html;charset=utf-8,<title>"+
k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},xb=function(){g.open()},Ib=function(){},pb=function(k){var v=k.prev();v.css("background","#09f");setTimeout(function(){v.css("background","")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));
T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else X&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},Ob=function(){var k=document.querySelector("#tool_stroke rect"),v=document.querySelector("#tool_fill rect"),C=v.getAttribute("fill"),D=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));
if(isNaN(k))k=100;v=parseFloat(v.getAttribute("fill-opacity"));if(isNaN(v))v=100;D=Ia(D,k,"stroke");C=Ia(C,v,"fill");b.paintBox.fill.setPaint(D,true);b.paintBox.stroke.setPaint(C,true)},Db=function(k){var v=g.getResolution();k=k?v.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=
a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");lb()}},Jb=function(){var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},Rb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},Eb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",
false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},lb=function(){if(!H){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(Q.hasClass("wireframe")?k:"")}},Qb=function(k,v){if(!ka){ka=true;a("#save_output_btns").toggle(!!v);a("#tool_source_back").toggle(!v);var C=fa=g.getSvgString();a("#svg_source_textarea").val(C);
a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();aa()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();m();Db();aa()});ba()}},yb=b.setIcon=function(k,v){var C=typeof v==="string"?a.getSvgIcon(v,true):v.clone();C?a(k).find("img").replaceWith(C):
console.log("NOTE: Icon image missing: "+v)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,v=document.getElementsByTagName("script")[0],C;for(C in v.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in v.style)return"Webkit";if("KhtmlOpacity"in v.style)return"Khtml";return""}();var Mb=function(k,v){gb.toLowerCase();var C=["top","left","bottom","right"];k.each(function(){for(var D=a(this),P=D.outerWidth()*(v-1),U=D.outerHeight()*(v-1),S=0;S<4;S++){var Y=C[S],Z=D.data("orig_margin-"+
Y);if(Z==null){Z=parseInt(D.css("margin-"+Y));D.data("orig_margin-"+Y,Z)}Z=Z*v;if(Y==="right")Z+=P;else if(Y==="bottom")Z+=U;D.css("margin-"+Y,Z)}})},e=b.setIconSize=function(k,v){if(!(k==s.size&&!v)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),D=1;D=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=ia=D;na();var P=C.parents(":hidden");
P.css("visibility","hidden").show();Mb(C,D);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,Y){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(Y,function(Z,ga){if(typeof ga==="number")var qa=ga*D+"px";else if(ga[k]||ga.all)qa=ga[k]||ga.all;U+=Z+":"+qa+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
P+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/D+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();
var z=a.noop;a(window).resize(function(){F()});(function(){Q.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=Q[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=Q[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var k=g.getHref(X);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(v){v&&Na(v)})});var w=function(k){var v=k[0].id=="stroke_color"?"stroke":
"fill",C=k[0].id=="canvas_color";if(C)v="canvas";var D=b.paintBox[v].paint;k=v=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(C).jGraduate({paint:D,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){D=new a.jGraduate.Paint(P);b.paintBox[v].setPaint(D);
g.setPaint(v,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,v){var C=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(v=="stroke")D=curConfig.initStroke;if(v=="fill")D=curConfig.initFill;if(v=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D={color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
D.color+'" opacity="'+D.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));v==="canvas"?C.setAttribute("width",60.5):C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=v;this.setPaint=function(P,U){this.paint=P;var S="none",Y=P.type,Z=P.alpha/100;switch(Y){case "solidColor":S=
P[Y]=="none"||P[Y]=="one"?"none":"#"+P[Y];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[Y]);S="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",Z);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,Z,true)}if(this.type=="canvas")(Y=document.getElementById("canvas_background"))?Y.setAttribute("fill",S):Ka(S)};this.update=function(P){if(X){var U=this.type;
switch(X.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,Y=X.getElementsByTagName("*"),Z=0,ga=Y.length;Z<ga;Z++){var qa=Y[Z].getAttribute(U);if(Z===0)S=qa;else if(S!==qa){S=null;break}}if(S===null){Y=null;return}Y=S;S=1;break;default:S=parseFloat(X.getAttribute(U+"-opacity"));if(isNaN(S))S=1;Y=U==="fill"?"black":"none";Y=X.getAttribute(U)||Y}if(P){g.setColor(U,Y,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(Y,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=
new a.jGraduate.Paint({copy:this.paint});g.setPaint(v,P)}}};b.paintBox.fill=new q("#fill_color","fill");b.paintBox.stroke=new q("#stroke_color","stroke");b.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=b.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var H=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(q).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))w(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))w(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){w(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");w(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");w(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){Q.css("line-height",Q.height()+"px")});var A=function(){var k=a("#canvas_width"),v=a("#canvas_height"),C=k.val(),D=v.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);v.parent().addClass("error");return false}v.parent().removeClass("error");
if(!g.setResolution(C,D)){a.alert(uiStrings.notification.noContentToFitTo);C=g.getResolution();k.val(C.w);v.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],v=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";v.value="fit";A();var C=g.getResolution();k.value=C.w;v.value=C.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var P=D[0]-k.value,U=D[1]-v.value,S=Date.now(),Y=function(Z){Z=(Z-S)/1E3;Z=Math.pow(Z-
1,3)+1;k.value=(D[0]-P+Z*P).toFixed(0);v.value=(D[1]-U+Z*U).toFixed(0);A();if(Z>=1){Z=g.getResolution();a("#canvas_width").val(Z.w.toFixed());a("#canvas_height").val(Z.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Z.w+"<span>\u00d7</span></br>"+Z.h+"</div>")}else requestAnimationFrame(Y)};Y(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;v.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var u=function(){var k=[{sel:"#tool_select",fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Va,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},
{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Ua,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():g.save({images:s.img_save,round_digits:6})},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:xb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",
fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ta,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:M,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Pa,evt:"click"},
{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Bb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+
"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:Ab,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+
"B",true]},{sel:"#tool_italic",fn:Qa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},{key:"ctrl+left",fn:function(){nb(0,1)}},{key:"ctrl+right",fn:function(){nb(1,1)}},{key:"ctrl+shift+left",fn:function(){nb(0,5)}},{key:"ctrl+shift+right",fn:function(){nb(1,5)}},{key:"shift+O",fn:db},{key:"shift+P",fn:Ya},{key:[o+"+",true],fn:function(){Db(2)}},{key:[o+"-",true],fn:function(){Db(0.5)}},{key:["up",true],fn:function(){ja(0,-1)}},{key:["down",true],fn:function(){ja(0,1)}},
{key:["left",true],fn:function(){ja(-1,0)}},{key:["right",true],fn:function(){ja(1,0)}},{key:"shift+up",fn:function(){ja(0,-10)}},{key:"shift+down",fn:function(){ja(0,10)}},{key:"shift+left",fn:function(){ja(-10,0)}},{key:"shift+right",fn:function(){ja(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,
0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var C=a(".tool_button_current");if(C.length&&C[0].id!=="tool_eyedropper"){C.removeClass("tool_button_current").addClass("tool_button");
a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],v={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(D,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));
S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var Y=P.fn,Z=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)Z=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(qa,Oa){a(document).bind("keydown",Oa,function(Ba){Y();Z&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";v[S]=P.sel;U.parents("#main_menu").length||
U.attr("title",ga)}}});ra(C);a(window).bind("keydown","tab",function(D){if(oa==="canvas"){D.preventDefault();Ya()}}).bind("keydown","shift+tab",function(D){if(oa==="canvas"){D.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(v,function(C,D){var P=a(D).parents("#main_menu").length;a(D).each(function(){var U=P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(Y,Z){var ga=Z.split("+"),qa="";if(ga.length>1){qa=ga[0]+"+";Z=ga[1]}S+=
(Y?"/":"")+qa+(uiStrings["key_"+Z]||Z)});if(P)this.lastChild.textContent=U+" ["+S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var D;a.each(k,function(P,U){if(U.sel===C)D=U});return D}}}();u.setAll();b.ready(function(){var k=curConfig.initTool,v=a("#tools_left, #svg_editor .tools_flyout"),C=v.find("#tool_"+k);k=v.find("#"+k);(C.length?C:k.length?k:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});
a("#canvas_height").dragInput({min:10,max:null,step:10,callback:A,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:A,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null,
step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1,
max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var v=k.value;if(v==0&&
X&&["line","polyline"].indexOf(X.nodeName)>=0)v=k.value=1;g.setStrokeWidth(v)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,v){var C=k.value-0,D=C+v,P=D>=C;if(v===0)return C;return C>=
24?P?Math.round(C*1.1):Math.round(C/1.1):C<=1?P?C*2:C/2:D}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);g.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ta();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();
break;case "paste_in_place":g.pasteElements("in_place");break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":ob();break;case "move_up":wb("Up");break;case "move_down":wb("Down");break;case "move_back":eb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();
V.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(T.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;b.openPrep(function(v){if(v){g.clear();if(k.files.length==1){v=new FileReader;
v.onloadend=function(C){p(C.target.result);F()};v.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(v){g.importSvgString(v.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=b.updateCanvas=function(k,v){var C=Q.width(),D=Q.height(),P=C,U=D,S=g.getZoom(),Y=a("#svgcanvas"),Z={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+
U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);D=Math.max(U,g.contentH*S*ga);C==P&&D==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=Y.height()/2;var qa=Y.width()/2;Y.width(C).height(D);var Oa=D/2,Ba=C/2,ha=g.updateCanvas(C,D),Ta=Ba/qa;C=C/2-P/2;D=D/2-U/2;if(v){v.x+=ha.x;v.y+=ha.y}else v={x:Ba+(Z.x-qa)*Ta,y:Oa+(Z.y-ga)*Ta};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=D}else{Q[0].scrollLeft=v.x-P/2;
Q[0].scrollTop=v.y-U/2}if(curConfig.showRulers){l(Y,S);Q.scroll()}},I=[],E=0.1;E<1E5;E*=10){I.push(1*E);I.push(2*E);I.push(5*E)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var v=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(k.length){for(var C=0;C<k.length;C++)k[C]=v(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var D in k)C.push(v(D)+":"+v(k[D]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var v=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+v+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+v+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,
v){a.pref("lang",k);a("#lang_select").val(k);if(v){g.runExtensions("langChanged",k);za();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,D){a(D).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(d){n?d():f.push(d)};
b.runCallbacks=function(){a.each(f,function(){this()});n=true};b.loadFromString=function(d){b.ready(function(){p(d)})};b.loadFromURL=function(d,l){l||(l={});var q=l.cache,B=l.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,T){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+T+"",B)}})})};b.loadFromDataURI=function(d){b.ready(function(){var l=d.substring(26);p(svgedit.utilities.decode64(l))})};
b.addExtension=function(){var d=arguments;a(function(){g&&g.addExtension.apply(this,d)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var p=this.dragCfg.dragAdjust,g=$(this).parent(),b=$(this),n=this.dragCfg.height,s=this.dragCfg.min,c=this.dragCfg.max,f=this.dragCfg.step,d=c-s>0?(c-s)/f:200,l=d/n*f,q=0,B=this.getAttribute("data-attr"),o=svgEditor.canvas,K=o.getSelectedElems(),T=svgedit.browser.isTouch(),O=true,J=d&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(g):false;b.attr("readonly","readonly");J&&!isNaN(this.dragCfg.start)&&J.css("top",this.dragCfg.start*
-1/l+n);this.adjustValue=function(Q,V){var N;N=isNaN(this.value)?this.dragCfg.reset:$.isFunction(this.dragCfg.stepfunc)?this.dragCfg.stepfunc(this,Q):Number((Number(this.value)+Number(Q)).toFixed(5));if(c!==null)N=Math.min(N,c);if(s!==null)N=Math.max(N,s);J&&this.updateCursor(N);this.value=N;g.attr("data-value",N);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,V)};g.toggleClass("draginput",g.is("label"));this.move=function(Q,V,N){if(T)Q=Q.originalEvent.touches[0];if(q===0)q=V;V=(Q.pageY-
q)*-1;q=Q.pageY;N=V*l*p;this.adjustValue(N.toFixed(f<1?1:0))};this.stop=function(){$("body").removeClass("dragging");g.removeClass("active");O=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");q=0;if(K[0]){var Q=o.undoMgr.finishUndoableChange();Q.isEmpty()||o.undoMgr.addCommandToHistory(Q)}this.adjustValue(0,O)};this.updateCursor=function(){var Q=parseFloat(this.value)*-1/l+n;J.css("top",Q)};this.start=function(Q){if(T)Q=Q.originalEvent.touches[0];
@ -581,44 +581,44 @@ this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui
return g=this._trimAlignValue(g)}g=this.options.values.slice();for(b=0;b<g.length;b+=1)g[b]=this._trimAlignValue(g[b]);return g},_trimAlignValue:function(p){if(p<=this._valueMin())return this._valueMin();if(p>=this._valueMax())return this._valueMax();var g=this.options.step>0?this.options.step:1,b=(p-this._valueMin())%g;p=p-b;Math.abs(b)*2>=g&&(p+=b>0?g:-g);return parseFloat(p.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var p=
this.options.range,g=this.options,b=this,n=this._animateOff?false:g.animate,s,c={},f,d,l,q;this.options.values&&this.options.values.length?this.handles.each(function(B){s=(b.values(B)-b._valueMin())/(b._valueMax()-b._valueMin())*100;c[b.orientation==="horizontal"?"left":"bottom"]=s+"%";a(this).stop(1,1)[n?"animate":"css"](c,g.animate);b.options.range===true&&(b.orientation==="horizontal"?(B===0&&b.range.stop(1,1)[n?"animate":"css"]({left:s+"%"},g.animate),B===1&&b.range[n?"animate":"css"]({width:s-
f+"%"},{queue:false,duration:g.animate})):(B===0&&b.range.stop(1,1)[n?"animate":"css"]({bottom:s+"%"},g.animate),B===1&&b.range[n?"animate":"css"]({height:s-f+"%"},{queue:false,duration:g.animate})));f=s}):(d=this.value(),l=this._valueMin(),q=this._valueMax(),s=q!==l?(d-l)/(q-l)*100:0,c[b.orientation==="horizontal"?"left":"bottom"]=s+"%",this.handle.stop(1,1)[n?"animate":"css"](c,g.animate),p==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[n?"animate":"css"]({width:s+"%"},g.animate),
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,f){if(f===undefined)f=0;return Math.round(c*Math.pow(10,f))/Math.pow(10,f)};var p=function(c,f){var d=this,l=c.find("img:first"),q=0,B=100,o=100,K=0,T=100,O=100,J=0,Q=0,V,N,ia=[],oa=function(W){for(var aa=0;aa<ia.length;aa++)ia[aa].call(d,d,W)},fa=function(W){var aa=c.offset();V={l:aa.left|0,t:aa.top|0};clearTimeout(N);N=setTimeout(function(){sa.call(d,W)},0);a(document).bind("mousemove",ba).bind("mouseup",Y);W.preventDefault()},ba=function(W){clearTimeout(N);
N=setTimeout(function(){sa.call(d,W)},0);W.stopPropagation();W.preventDefault();return false},Y=function(W){a(document).unbind("mouseup",Y).unbind("mousemove",ba);W.stopPropagation();W.preventDefault();return false},sa=function(W){var aa=W.pageX-V.l;W=W.pageY-V.t;var pa=c.w,ra=c.h;if(aa<0)aa=0;else if(aa>pa)aa=pa;if(W<0)W=0;else if(W>ra)W=ra;ka.call(d,"xy",{x:aa/pa*o+q,y:W/ra*O+K})},ka=function(W,aa,pa){if(aa===undefined){if(W===undefined||W==null)W="xy";switch(W.toLowerCase()){case "x":return J;
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,f){if(f===undefined)f=0;return Math.round(c*Math.pow(10,f))/Math.pow(10,f)};var p=function(c,f){var d=this,l=c.find("img:first"),q=0,B=100,o=100,K=0,T=100,O=100,J=0,Q=0,V,N,ia=[],oa=function(W){for(var aa=0;aa<ia.length;aa++)ia[aa].call(d,d,W)},fa=function(W){var aa=c.offset();V={l:aa.left|0,t:aa.top|0};clearTimeout(N);N=setTimeout(function(){sa.call(d,W)},0);a(document).bind("mousemove",ba).bind("mouseup",X);W.preventDefault()},ba=function(W){clearTimeout(N);
N=setTimeout(function(){sa.call(d,W)},0);W.stopPropagation();W.preventDefault();return false},X=function(W){a(document).unbind("mouseup",X).unbind("mousemove",ba);W.stopPropagation();W.preventDefault();return false},sa=function(W){var aa=W.pageX-V.l;W=W.pageY-V.t;var pa=c.w,ra=c.h;if(aa<0)aa=0;else if(aa>pa)aa=pa;if(W<0)W=0;else if(W>ra)W=ra;ka.call(d,"xy",{x:aa/pa*o+q,y:W/ra*O+K})},ka=function(W,aa,pa){if(aa===undefined){if(W===undefined||W==null)W="xy";switch(W.toLowerCase()){case "x":return J;
case "y":return Q;default:return{x:J,y:Q}}}if(!(pa!=null&&pa==d)){var ra=false,ma,na;if(W==null)W="xy";switch(W.toLowerCase()){case "x":ma=aa&&(aa.x&&aa.x|0||aa|0)||0;break;case "y":na=aa&&(aa.y&&aa.y|0||aa|0)||0;break;default:ma=aa&&aa.x&&aa.x|0||0;na=aa&&aa.y&&aa.y|0||0}if(ma!=null){if(ma<q)ma=q;else if(ma>B)ma=B;if(J!=ma){J=ma;ra=true}}if(na!=null){if(na<K)na=K;else if(na>T)na=T;if(Q!=na){Q=na;ra=true}}ra&&oa.call(d,pa||d)}},da=function(W){a.isFunction(W)&&ia.push(W)};a.extend(true,d,{val:ka,range:function(W,
aa){if(aa===undefined){if(W===undefined||W==null)W="all";switch(W.toLowerCase()){case "minx":return q;case "maxx":return B;case "rangex":return{minX:q,maxX:B,rangeX:o};case "miny":return K;case "maxy":return T;case "rangey":return{minY:K,maxY:T,rangeY:O};default:return{minX:q,maxX:B,rangeX:o,minY:K,maxY:T,rangeY:O}}}var pa,ra,ma,na;if(W==null)W="all";switch(W.toLowerCase()){case "minx":pa=aa&&(aa.minX&&aa.minX|0||aa|0)||0;break;case "maxx":ra=aa&&(aa.maxX&&aa.maxX|0||aa|0)||0;break;case "rangex":pa=
aa&&aa.minX&&aa.minX|0||0;ra=aa&&aa.maxX&&aa.maxX|0||0;break;case "miny":ma=aa&&(aa.minY&&aa.minY|0||aa|0)||0;break;case "maxy":na=aa&&(aa.maxY&&aa.maxY|0||aa|0)||0;break;case "rangey":ma=aa&&aa.minY&&aa.minY|0||0;na=aa&&aa.maxY&&aa.maxY|0||0;break;default:pa=aa&&aa.minX&&aa.minX|0||0;ra=aa&&aa.maxX&&aa.maxX|0||0;ma=aa&&aa.minY&&aa.minY|0||0;na=aa&&aa.maxY&&aa.maxY|0||0}if(pa!=null&&q!=pa){q=pa;o=B-q}if(ra!=null&&B!=ra){B=ra;o=B-q}if(ma!=null&&K!=ma){K=ma;O=T-K}if(na!=null&&T!=na){T=na;O=T-K}},bind:da,
unbind:function(W){if(a.isFunction(W))for(var aa;(aa=a.inArray(W,ia))!=-1;)ia.splice(aa,1)},destroy:function(){a(document).unbind("mouseup",Y).unbind("mousemove",ba);c.unbind("mousedown",fa);ia=l=c=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();c.w=f.map&&f.map.width||c.width();c.h=f.map&&f.map.height||c.height();c.bind("mousedown",fa);da.call(d,function(){var W=0,aa=0,pa=c.w,ra=c.h,ma=l.w,na=l.h;setTimeout(function(){if(o>0)W=J==
B?pa:J/o*pa|0;if(O>0)aa=Q==T?ra:Q/O*ra|0;if(ma>=pa)W=(pa>>1)-(ma>>1);else W-=ma>>1;if(na>=ra)aa=(ra>>1)-(na>>1);else aa-=na>>1;l.css({left:W+"px",top:aa+"px"})},0)})},g=function(c,f,d,l){var q=this;c=c.find("td.Text input");var B=c.eq(3),o=c.eq(4),K=c.eq(5),T=c.length>7?c.eq(6):null,O=c.eq(0),J=c.eq(1),Q=c.eq(2),V=c.eq(c.length>7?7:6),N=c.length>7?c.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(Y.call(q,
(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(Y.call(q,(B.val()<<0)-1,0,255));f.val("r",B.val(),ka.target);return false}break;case o.get(0):switch(ka.keyCode){case 38:o.val(Y.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ka.target);return false;case 40:o.val(Y.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ka.target);return false}break;case K.get(0):switch(ka.keyCode){case 38:K.val(Y.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ka.target);return false;case 40:K.val(Y.call(q,
(K.val()<<0)-1,0,255));f.val("b",K.val(),ka.target);return false}break;case T&&T.get(0):switch(ka.keyCode){case 38:T.val(Y.call(q,parseFloat(T.val())+1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false;case 40:T.val(Y.call(q,parseFloat(T.val())-1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false}break;case O.get(0):switch(ka.keyCode){case 38:O.val(Y.call(q,(O.val()<<0)+1,0,360));f.val("h",O.val(),ka.target);return false;case 40:O.val(Y.call(q,(O.val()<<
0)-1,0,360));f.val("h",O.val(),ka.target);return false}break;case J.get(0):switch(ka.keyCode){case 38:J.val(Y.call(q,(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(Y.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(Y.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(Y.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},oa=function(ka){if(!(ka.target.value==
""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(Y.call(q,B.val(),0,255));f.val("r",B.val(),ka.target);break;case o.get(0):o.val(Y.call(q,o.val(),0,255));f.val("g",o.val(),ka.target);break;case K.get(0):K.val(Y.call(q,K.val(),0,255));f.val("b",K.val(),ka.target);break;case T&&T.get(0):T.val(Y.call(q,T.val(),0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);break;case O.get(0):O.val(Y.call(q,O.val(),0,360));f.val("h",
O.val(),ka.target);break;case J.get(0):J.val(Y.call(q,J.val(),0,100));f.val("s",J.val(),ka.target);break;case Q.get(0):Q.val(Y.call(q,Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case V.get(0):V.val(V.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(V.val());f.val("hex",V.val()!=""?V.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));V.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;
unbind:function(W){if(a.isFunction(W))for(var aa;(aa=a.inArray(W,ia))!=-1;)ia.splice(aa,1)},destroy:function(){a(document).unbind("mouseup",X).unbind("mousemove",ba);c.unbind("mousedown",fa);ia=l=c=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();c.w=f.map&&f.map.width||c.width();c.h=f.map&&f.map.height||c.height();c.bind("mousedown",fa);da.call(d,function(){var W=0,aa=0,pa=c.w,ra=c.h,ma=l.w,na=l.h;setTimeout(function(){if(o>0)W=J==
B?pa:J/o*pa|0;if(O>0)aa=Q==T?ra:Q/O*ra|0;if(ma>=pa)W=(pa>>1)-(ma>>1);else W-=ma>>1;if(na>=ra)aa=(ra>>1)-(na>>1);else aa-=na>>1;l.css({left:W+"px",top:aa+"px"})},0)})},g=function(c,f,d,l){var q=this;c=c.find("td.Text input");var B=c.eq(3),o=c.eq(4),K=c.eq(5),T=c.length>7?c.eq(6):null,O=c.eq(0),J=c.eq(1),Q=c.eq(2),V=c.eq(c.length>7?7:6),N=c.length>7?c.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(X.call(q,
(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(X.call(q,(B.val()<<0)-1,0,255));f.val("r",B.val(),ka.target);return false}break;case o.get(0):switch(ka.keyCode){case 38:o.val(X.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ka.target);return false;case 40:o.val(X.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ka.target);return false}break;case K.get(0):switch(ka.keyCode){case 38:K.val(X.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ka.target);return false;case 40:K.val(X.call(q,
(K.val()<<0)-1,0,255));f.val("b",K.val(),ka.target);return false}break;case T&&T.get(0):switch(ka.keyCode){case 38:T.val(X.call(q,parseFloat(T.val())+1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false;case 40:T.val(X.call(q,parseFloat(T.val())-1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false}break;case O.get(0):switch(ka.keyCode){case 38:O.val(X.call(q,(O.val()<<0)+1,0,360));f.val("h",O.val(),ka.target);return false;case 40:O.val(X.call(q,(O.val()<<
0)-1,0,360));f.val("h",O.val(),ka.target);return false}break;case J.get(0):switch(ka.keyCode){case 38:J.val(X.call(q,(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(X.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(X.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(X.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},oa=function(ka){if(!(ka.target.value==
""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(X.call(q,B.val(),0,255));f.val("r",B.val(),ka.target);break;case o.get(0):o.val(X.call(q,o.val(),0,255));f.val("g",o.val(),ka.target);break;case K.get(0):K.val(X.call(q,K.val(),0,255));f.val("b",K.val(),ka.target);break;case T&&T.get(0):T.val(X.call(q,T.val(),0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);break;case O.get(0):O.val(X.call(q,O.val(),0,360));f.val("h",
O.val(),ka.target);break;case J.get(0):J.val(X.call(q,J.val(),0,100));f.val("s",J.val(),ka.target);break;case Q.get(0):Q.val(X.call(q,Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case V.get(0):V.val(V.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(V.val());f.val("hex",V.val()!=""?V.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));V.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;
case N&&N.get(0):N.val(N.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",N.val()!=null?parseInt(N.val(),16):null,ka.target)}}},fa=function(ka){if(f.val()!=null)switch(ka.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case T&&T.get(0):T.val(Math.precision(f.val("a")*100/255,l));break;case O.get(0):O.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case Q.get(0):Q.val(f.val("v"));break;case V.get(0):case d&&
d.get(0):V.val(f.val("hex"));d&&d.val(f.val("hex"));break;case N&&N.get(0):N.val(f.val("ahex").substring(6))}},ba=function(ka){switch(ka.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(ka.ctrlKey)return false}return true},Y=function(ka,da,W){if(ka==""||isNaN(ka))return da;if(ka>W)return W;if(ka<da)return da;return ka},sa=function(ka,da){var W=ka.val("all");if(da!=B.get(0))B.val(W!=null?W.r:"");if(da!=o.get(0))o.val(W!=null?W.g:"");if(da!=
d.get(0):V.val(f.val("hex"));d&&d.val(f.val("hex"));break;case N&&N.get(0):N.val(f.val("ahex").substring(6))}},ba=function(ka){switch(ka.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(ka.ctrlKey)return false}return true},X=function(ka,da,W){if(ka==""||isNaN(ka))return da;if(ka>W)return W;if(ka<da)return da;return ka},sa=function(ka,da){var W=ka.val("all");if(da!=B.get(0))B.val(W!=null?W.r:"");if(da!=o.get(0))o.val(W!=null?W.g:"");if(da!=
K.get(0))K.val(W!=null?W.b:"");if(T&&da!=T.get(0))T.val(W!=null?Math.precision(W.a*100/255,l):"");if(da!=O.get(0))O.val(W!=null?W.h:"");if(da!=J.get(0))J.val(W!=null?W.s:"");if(da!=Q.get(0))Q.val(W!=null?W.v:"");if(da!=V.get(0)&&(d&&da!=d.get(0)||!d))V.val(W!=null?W.hex:"");if(d&&da!=d.get(0)&&da!=V.get(0))d.val(W!=null?W.hex:"");if(N&&da!=N.get(0))N.val(W!=null?W.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(T).add(O).add(J).add(Q).add(V).add(d).add(N).unbind("keyup",
oa).unbind("blur",fa);B.add(o).add(K).add(T).add(O).add(J).add(Q).unbind("keydown",ia);f.unbind(sa);N=V=Q=J=O=T=K=o=B=null}});B.add(o).add(K).add(T).add(O).add(J).add(Q).add(V).add(d).add(N).bind("keyup",oa).bind("blur",fa);B.add(o).add(K).add(T).add(O).add(J).add(Q).bind("keydown",ia);f.bind(sa)};a.jPicker={List:[],Color:function(c){var f=this,d,l,q,B,o,K,T,O=[],J=function(V){for(var N=0;N<O.length;N++)O[N].call(f,f,V)},Q=function(V,N,ia){if(N===undefined){if(V===undefined||V==null||V=="")V="all";
if(d==null)return null;switch(V.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:l,b:q,a:B});case "hex":return Q("ahex").substring(0,6);case "all":return{r:d,g:l,b:q,a:B,h:o,s:K,v:T,hex:Q.call(f,"hex"),ahex:Q.call(f,"ahex")};default:N={};for(var oa=0;oa<V.length;oa++)switch(V.charAt(oa)){case "r":if(V.length==1)N=d;else N.r=d;break;case "g":if(V.length==1)N=l;else N.g=l;break;case "b":if(V.length==1)N=q;else N.b=q;break;case "a":if(V.length==1)N=B;else N.a=B;break;case "h":if(V.length==1)N=o;
else N.h=o;break;case "s":if(V.length==1)N=K;else N.s=K;break;case "v":if(V.length==1)N=T;else N.v=T}return N=={}?Q.call(f,"all"):N}}if(!(ia!=null&&ia==f)){var fa=false;if(V==null)V="";if(N==null){if(d!=null){d=null;fa=true}if(l!=null){l=null;fa=true}if(q!=null){q=null;fa=true}if(B!=null){B=null;fa=true}if(o!=null){o=null;fa=true}if(K!=null){K=null;fa=true}if(T!=null){T=null;fa=true}fa&&J.call(f,ia||f)}else switch(V.toLowerCase()){case "ahex":case "hex":N=s.hexToRgba(N&&(N.ahex||N.hex)||N||"00000000");
Q.call(f,"rgba",{r:N.r,g:N.g,b:N.b,a:V=="ahex"?N.a:B!=null?B:255},ia);break;default:if(N&&(N.ahex!=null||N.hex!=null)){Q.call(f,"ahex",N.ahex||N.hex||"00000000",ia);break}var ba={},Y=false,sa=false;if(N.r!==undefined&&!V.indexOf("r")==-1)V+="r";if(N.g!==undefined&&!V.indexOf("g")==-1)V+="g";if(N.b!==undefined&&!V.indexOf("b")==-1)V+="b";if(N.a!==undefined&&!V.indexOf("a")==-1)V+="a";if(N.h!==undefined&&!V.indexOf("h")==-1)V+="h";if(N.s!==undefined&&!V.indexOf("s")==-1)V+="s";if(N.v!==undefined&&!V.indexOf("v")==
-1)V+="v";for(oa=0;oa<V.length;oa++)switch(V.charAt(oa)){case "r":if(sa)continue;Y=true;ba.r=N&&N.r&&N.r|0||N&&N|0||0;if(ba.r<0)ba.r=0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;fa=true}break;case "g":if(sa)continue;Y=true;ba.g=N&&N.g&&N.g|0||N&&N|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(l!=ba.g){l=ba.g;fa=true}break;case "b":if(sa)continue;Y=true;ba.b=N&&N.b&&N.b|0||N&&N|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;fa=true}break;case "a":ba.a=N&&N.a!=null?N.a|0:
N!=null?N|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;fa=true}break;case "h":if(Y)continue;sa=true;ba.h=N&&N.h&&N.h|0||N&&N|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;fa=true}break;case "s":if(Y)continue;sa=true;ba.s=N&&N.s!=null?N.s|0:N!=null?N|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;fa=true}break;case "v":if(Y)continue;sa=true;ba.v=N&&N.v!=null?N.v|0:N!=null?N|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(T!=ba.v){T=
ba.v;fa=true}}if(fa){if(Y){d=d||0;l=l||0;q=q||0;N=s.rgbToHsv({r:d,g:l,b:q});o=N.h;K=N.s;T=N.v}else if(sa){o=o||0;K=K!=null?K:100;T=T!=null?T:100;N=s.hsvToRgb({h:o,s:K,v:T});d=N.r;l=N.g;q=N.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(V){a.isFunction(V)&&O.push(V)},unbind:function(V){if(a.isFunction(V))for(var N;(N=a.inArray(V,O))!=-1;)O.splice(N,1)},destroy:function(){O=null}});if(c)if(c.ahex!=null)Q("ahex",c);else if(c.hex!=null)Q((c.a!=null?"a":"")+"hex",c.a!=null?
Q.call(f,"rgba",{r:N.r,g:N.g,b:N.b,a:V=="ahex"?N.a:B!=null?B:255},ia);break;default:if(N&&(N.ahex!=null||N.hex!=null)){Q.call(f,"ahex",N.ahex||N.hex||"00000000",ia);break}var ba={},X=false,sa=false;if(N.r!==undefined&&!V.indexOf("r")==-1)V+="r";if(N.g!==undefined&&!V.indexOf("g")==-1)V+="g";if(N.b!==undefined&&!V.indexOf("b")==-1)V+="b";if(N.a!==undefined&&!V.indexOf("a")==-1)V+="a";if(N.h!==undefined&&!V.indexOf("h")==-1)V+="h";if(N.s!==undefined&&!V.indexOf("s")==-1)V+="s";if(N.v!==undefined&&!V.indexOf("v")==
-1)V+="v";for(oa=0;oa<V.length;oa++)switch(V.charAt(oa)){case "r":if(sa)continue;X=true;ba.r=N&&N.r&&N.r|0||N&&N|0||0;if(ba.r<0)ba.r=0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;fa=true}break;case "g":if(sa)continue;X=true;ba.g=N&&N.g&&N.g|0||N&&N|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(l!=ba.g){l=ba.g;fa=true}break;case "b":if(sa)continue;X=true;ba.b=N&&N.b&&N.b|0||N&&N|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;fa=true}break;case "a":ba.a=N&&N.a!=null?N.a|0:
N!=null?N|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;fa=true}break;case "h":if(X)continue;sa=true;ba.h=N&&N.h&&N.h|0||N&&N|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;fa=true}break;case "s":if(X)continue;sa=true;ba.s=N&&N.s!=null?N.s|0:N!=null?N|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;fa=true}break;case "v":if(X)continue;sa=true;ba.v=N&&N.v!=null?N.v|0:N!=null?N|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(T!=ba.v){T=
ba.v;fa=true}}if(fa){if(X){d=d||0;l=l||0;q=q||0;N=s.rgbToHsv({r:d,g:l,b:q});o=N.h;K=N.s;T=N.v}else if(sa){o=o||0;K=K!=null?K:100;T=T!=null?T:100;N=s.hsvToRgb({h:o,s:K,v:T});d=N.r;l=N.g;q=N.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(V){a.isFunction(V)&&O.push(V)},unbind:function(V){if(a.isFunction(V))for(var N;(N=a.inArray(V,O))!=-1;)O.splice(N,1)},destroy:function(){O=null}});if(c)if(c.ahex!=null)Q("ahex",c);else if(c.hex!=null)Q((c.a!=null?"a":"")+"hex",c.a!=null?
{ahex:c.hex+s.intToHex(c.a)}:c);else if(c.r!=null&&c.g!=null&&c.b!=null)Q("rgb"+(c.a!=null?"a":""),c);else if(c.h!=null&&c.s!=null&&c.v!=null)Q("hsv"+(c.a!=null?"a":""),c)},ColorMethods:{hexToRgba:function(c){c=this.validateHex(c);if(c=="")return{r:null,g:null,b:null,a:null};var f="00",d="00",l="00",q="255";if(c.length==6)c+="ff";if(c.length>6){f=c.substring(0,2);d=c.substring(2,4);l=c.substring(4,6);q=c.substring(6,c.length)}else{if(c.length>4){f=c.substring(4,c.length);c=c.substring(0,4)}if(c.length>
2){d=c.substring(2,c.length);c=c.substring(0,2)}if(c.length>0)l=c.substring(0,c.length)}return{r:this.hexToInt(f),g:this.hexToInt(d),b:this.hexToInt(l),a:this.hexToInt(q)}},validateHex:function(c){if(typeof c=="object")return"";c=c.toLowerCase().replace(/[^a-f0-9]/g,"");if(c.length>8)c=c.substring(0,8);return c},rgbaToHex:function(c){return this.intToHex(c.r)+this.intToHex(c.g)+this.intToHex(c.b)+this.intToHex(c.a)},intToHex:function(c){c=(c|0).toString(16);if(c.length==1)c="0"+c;return c.toLowerCase()},
hexToInt:function(c){return parseInt(c,16)},rgbToHsv:function(c){var f=c.r/255,d=c.g/255;c=c.b/255;var l={h:0,s:0,v:0},q=0,B=0;if(f>=d&&f>=c){B=f;q=d>c?c:d}else if(d>=c&&d>=f){B=d;q=f>c?c:f}else{B=c;q=d>f?f:d}l.v=B;l.s=B?(B-q)/B:0;if(l.s){q=B-q;l.h=f==B?(d-c)/q:d==B?2+(c-f)/q:4+(f-d)/q;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(c){var f={r:0,g:0,b:0,a:100},d=c.h,l=c.s;c=c.v;if(l==0)f.r=c==0?f.g=f.b=0:f.g=f.b=c*255/100|0;else{if(d==360)d=
0;d/=60;l/=100;c/=100;var q=d|0,B=d-q;d=c*(1-l);var o=c*(1-l*B);l=c*(1-l*(1-B));switch(q){case 0:f.r=c;f.g=l;f.b=d;break;case 1:f.r=o;f.g=c;f.b=d;break;case 2:f.r=d;f.g=c;f.b=l;break;case 3:f.r=d;f.g=o;f.b=c;break;case 4:f.r=l;f.g=d;f.b=c;break;case 5:f.r=c;f.g=d;f.b=o}f.r=f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var b=a.jPicker.Color,n=a.jPicker.List,s=a.jPicker.ColorMethods;a.fn.jPicker=function(c){var f=arguments;return this.each(function(){var d=this,l=a.extend(true,{},a.fn.jPicker.defaults,
c);if(a(d).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,input:a(d)}});if(a(d).val()==""){l.color.active=new b({hex:null});l.color.current=new b({hex:null})}else if(s.validateHex(a(d).val())){l.color.active=new b({hex:a(d).val(),a:l.color.active.val("a")});l.color.current=new b({hex:a(d).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(d).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,O=null,J=null,Q=null,V=null,N=null,ia=null,oa=null,fa=null,ba=null,Y=null,sa=null,ka=null,da=null,W=null,aa=null,pa=null,ra=null,ma=null,na=null,za=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(M){var R=ja.active,ea=R.val("hex"),Ga,Pa;l.color.mode=M;switch(M){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
O,260);va.call(d,O,100);Wa.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,V,260);va.call(d,V,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);Y.val("y",360-R.val("h"),Y);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
O,-520);Da.call(d,Q,-260);Da.call(d,V,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);Y.val("y",100-R.val("s"),Y);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,O,260);Wa.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);Y.val("y",100-R.val("v"),Y);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);Y.val("y",255-R.val("r"),Y);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);Y.val("y",255-R.val("g"),Y);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);Y.val("y",255-R.val("b"),Y);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,O,-520);Da.call(d,Q,260);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);Y.val("y",255-R.val("a"),Y);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,O,Ga-260);Da.call(d,Q,Pa-780);Da.call(d,V,Pa-520);Da.call(d,N,Pa);Da.call(d,ia,Pa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&Aa.call(d,R)},Aa=function(M,R){if(R==null||R!=Y&&R!=ba)wa.call(d,M,R);setTimeout(function(){qb.call(d,M);$a.call(d,M);ib.call(d,M)},0)},ya=function(M,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=M.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
{h:Ga.x,v:100-Ga.y},R);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},R);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},R);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},R);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},R)}}},Ha=function(M,R){var ea=ja.active;if(!(R!=Y&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-M.val("y")},R);break;case "s":ea.val("s",{s:100-M.val("y")},R);break;case "v":ea.val("v",{v:100-M.val("y")},R);break;case "r":ea.val("r",{r:255-M.val("y")},R);break;case "g":ea.val("g",
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,O=null,J=null,Q=null,V=null,N=null,ia=null,oa=null,fa=null,ba=null,X=null,sa=null,ka=null,da=null,W=null,aa=null,pa=null,ra=null,ma=null,na=null,za=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(M){var R=ja.active,ea=R.val("hex"),Ga,Pa;l.color.mode=M;switch(M){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
O,260);va.call(d,O,100);Wa.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,V,260);va.call(d,V,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);X.val("y",360-R.val("h"),X);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
O,-520);Da.call(d,Q,-260);Da.call(d,V,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);X.val("y",100-R.val("s"),X);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,O,260);Wa.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);X.val("y",100-R.val("v"),X);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});X.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);X.val("y",255-R.val("r"),X);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});X.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);X.val("y",255-R.val("g"),X);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});X.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);X.val("y",255-R.val("b"),X);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,O,-520);Da.call(d,Q,260);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);X.val("y",255-R.val("a"),X);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,O,Ga-260);Da.call(d,Q,Pa-780);Da.call(d,V,Pa-520);Da.call(d,N,Pa);Da.call(d,ia,Pa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&Aa.call(d,R)},Aa=function(M,R){if(R==null||R!=X&&R!=ba)wa.call(d,M,R);setTimeout(function(){qb.call(d,M);$a.call(d,M);ib.call(d,M)},0)},ya=function(M,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=M.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
{h:Ga.x,v:100-Ga.y},R);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},R);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},R);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},R);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},R)}}},Ha=function(M,R){var ea=ja.active;if(!(R!=X&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-M.val("y")},R);break;case "s":ea.val("s",{s:100-M.val("y")},R);break;case "v":ea.val("v",{v:100-M.val("y")},R);break;case "r":ea.val("r",{r:255-M.val("y")},R);break;case "g":ea.val("g",
{g:255-M.val("y")},R);break;case "b":ea.val("b",{b:255-M.val("y")},R);break;case "a":ea.val("a",255-M.val("y"),R)}},wa=function(M,R){if(R!=ba)switch(l.color.mode){case "h":var ea=M.val("sv");ba.val("xy",{x:ea!=null?ea.s:100,y:100-(ea!=null?ea.v:100)},R);break;case "s":case "a":ea=M.val("hv");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.v:100)},R);break;case "v":ea=M.val("hs");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.s:100)},R);break;case "r":ea=M.val("bg");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&
ea.g||0)},R);break;case "g":ea=M.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},R);break;case "b":ea=M.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},R)}if(R!=Y)switch(l.color.mode){case "h":Y.val("y",360-(M.val("h")||0),R);break;case "s":ea=M.val("s");Y.val("y",100-(ea!=null?ea:100),R);break;case "v":ea=M.val("v");Y.val("y",100-(ea!=null?ea:100),R);break;case "r":Y.val("y",255-(M.val("r")||0),R);break;case "g":Y.val("y",255-(M.val("g")||0),R);break;case "b":Y.val("y",255-(M.val("b")||
0),R);break;case "a":ea=M.val("a");Y.val("y",255-(ea!=null?ea:255),R)}},qb=function(M){try{var R=M.val("all");pa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,pa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(M){switch(l.color.mode){case "h":Wa.call(d,o,(new b({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=M.val("s");va.call(d,O,100-(R!=null?R:100));break;case "v":R=M.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,O,Math.precision((M.val("r")||
ea.g||0)},R);break;case "g":ea=M.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},R);break;case "b":ea=M.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},R)}if(R!=X)switch(l.color.mode){case "h":X.val("y",360-(M.val("h")||0),R);break;case "s":ea=M.val("s");X.val("y",100-(ea!=null?ea:100),R);break;case "v":ea=M.val("v");X.val("y",100-(ea!=null?ea:100),R);break;case "r":X.val("y",255-(M.val("r")||0),R);break;case "g":X.val("y",255-(M.val("g")||0),R);break;case "b":X.val("y",255-(M.val("b")||
0),R);break;case "a":ea=M.val("a");X.val("y",255-(ea!=null?ea:255),R)}},qb=function(M){try{var R=M.val("all");pa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,pa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(M){switch(l.color.mode){case "h":Wa.call(d,o,(new b({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=M.val("s");va.call(d,O,100-(R!=null?R:100));break;case "v":R=M.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,O,Math.precision((M.val("r")||
0)/255*100,4));break;case "g":va.call(d,O,Math.precision((M.val("g")||0)/255*100,4));break;case "b":va.call(d,O,Math.precision((M.val("b")||0)/255*100))}M=M.val("a");va.call(d,J,Math.precision((255-(M||0))*100/255,4))},ib=function(M){switch(l.color.mode){case "h":var R=M.val("a");va.call(d,oa,Math.precision((255-(R||0))*100/255,4));break;case "s":R=M.val("hva");var ea=new b({h:R&&R.h||0,s:100,v:R!=null?R.v:100});Wa.call(d,K,ea.val("hex"));va.call(d,V,100-(R!=null?R.v:100));va.call(d,oa,Math.precision((255-
(R&&R.a||0))*100/255,4));break;case "v":R=M.val("hsa");ea=new b({h:R&&R.h||0,s:R!=null?R.s:100,v:100});Wa.call(d,K,ea.val("hex"));va.call(d,oa,Math.precision((255-(R&&R.a||0))*100/255,4));break;case "r":case "g":case "b":ea=R=0;M=M.val("rgba");if(l.color.mode=="r"){R=M&&M.b||0;ea=M&&M.g||0}else if(l.color.mode=="g"){R=M&&M.b||0;ea=M&&M.r||0}else if(l.color.mode=="b"){R=M&&M.r||0;ea=M&&M.g||0}var Ga=ea>R?R:ea;va.call(d,V,R>ea?Math.precision((R-ea)/(255-ea)*100,4):0);va.call(d,N,ea>R?Math.precision((ea-
R)/(255-R)*100,4):0);va.call(d,ia,Math.precision(Ga/255*100,4));va.call(d,oa,Math.precision((255-(M&&M.a||0))*100/255,4));break;case "a":R=M.val("a");Wa.call(d,K,M.val("hex")||"000000");va.call(d,oa,R!=null?0:100);va.call(d,fa,R!=null?100:0)}},Wa=function(M,R){M.css({backgroundColor:R&&R.length==6&&"#"+R||"transparent"})},Sa=function(M,R){if(q&&(R.indexOf("AlphaBar.png")!=-1||R.indexOf("Bars.png")!=-1||R.indexOf("Maps.png")!=-1)){M.attr("pngSrc",R);M.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
@ -639,14 +639,14 @@ la.clientPath+la.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9
"")+'" title="'+ca.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ca.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(ea!=null?ea.hex:"")+'"/></label>'+(M.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(ea!=null?ea.ahex.substring(6):"")+'" title="'+ca.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";if(M.expandable){B.html(Ga);a(document.body).children("div.jPicker.Container").length==
0?a(document.body).prepend(B):a(document.body).children("div.jPicker.Container:last").after(B);B.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})});B.css({left:M.position.x=="left"?R.offset().left-530-(M.position.y=="center"?25:0)+"px":M.position.x=="center"?R.offset().left-260+"px":M.position.x=="right"?R.offset().left-10+(M.position.y=="center"?25:0)+"px":M.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":R.offset().left+parseInt(M.position.x)+
"px",position:"absolute",top:M.position.y=="top"?R.offset().top-312+"px":M.position.y=="center"?R.offset().top-156+"px":M.position.y=="bottom"?R.offset().top+25+"px":R.offset().top+parseInt(M.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Pa=o.find("span"),Ya=K.find("span");T=Pa.filter(".Map1:first");O=Pa.filter(".Map2:first");J=Pa.filter(".Map3:first");Q=Ya.filter(".Map1:first");V=Ya.filter(".Map2:first");N=Ya.filter(".Map3:first");
ia=Ya.filter(".Map4:first");oa=Ya.filter(".Map5:first");fa=Ya.filter(".Map6:first");ba=new p(o,{map:{width:la.colorMap.width,height:la.colorMap.height},arrow:{image:la.clientPath+la.colorMap.arrow.file,width:la.colorMap.arrow.width,height:la.colorMap.arrow.height}});ba.bind(ya);Y=new p(K,{map:{width:la.colorBar.width,height:la.colorBar.height},arrow:{image:la.clientPath+la.colorBar.arrow.file,width:la.colorBar.arrow.width,height:la.colorBar.arrow.height}});Y.bind(Ha);sa=new g(Ga,ja.active,M.expandable&&
ia=Ya.filter(".Map4:first");oa=Ya.filter(".Map5:first");fa=Ya.filter(".Map6:first");ba=new p(o,{map:{width:la.colorMap.width,height:la.colorMap.height},arrow:{image:la.clientPath+la.colorMap.arrow.file,width:la.colorMap.arrow.width,height:la.colorMap.arrow.height}});ba.bind(ya);X=new p(K,{map:{width:la.colorBar.width,height:la.colorBar.height},arrow:{image:la.clientPath+la.colorBar.arrow.file,width:la.colorBar.arrow.width,height:la.colorBar.arrow.height}});X.bind(Ha);sa=new g(Ga,ja.active,M.expandable&&
M.bindToInput?M.input:null,M.alphaPrecision);Pa=ea!=null?ea.hex:null;var db=Ga.find(".Preview");Ya=Ga.find(".Button");pa=db.find(".Active:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});ra=db.find(".Current:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"}).bind("click",Ea);va.call(d,ra,Math.precision(ja.current.val("a")*100)/255,4);ma=Ya.find(".Ok:first").bind("click touchstart",sb);na=Ya.find(".Cancel:first").bind("click touchstart",kb);za=Ya.find(".Grid:first");setTimeout(function(){Sa.call(d,
T,la.clientPath+"Maps.png");Sa.call(d,O,la.clientPath+"Maps.png");Sa.call(d,J,la.clientPath+"map-opacity.png");Sa.call(d,Q,la.clientPath+"Bars.png");Sa.call(d,V,la.clientPath+"Bars.png");Sa.call(d,N,la.clientPath+"Bars.png");Sa.call(d,ia,la.clientPath+"Bars.png");Sa.call(d,oa,la.clientPath+"bar-opacity.png");Sa.call(d,fa,la.clientPath+"AlphaBar.png");Sa.call(d,db.find("div:last"),la.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Va);if(ja.quickList&&ja.quickList.length>
0){Ya="";for(i=0;i<ja.quickList.length;i++){if((typeof ja.quickList[i]).toString().toLowerCase()=="string")ja.quickList[i]=new b({hex:ja.quickList[i]});var nb=ja.quickList[i].val("a"),Ua=ja.quickList[i].val("ahex");if(!M.alphaSupport&&Ua)Ua=Ua.substring(0,6)+"ff";var rb=ja.quickList[i].val("hex");Ya+='<span class="QuickColor"'+(Ua&&' title="#'+Ua+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+la.clientPath+"NoColor.png)")+(M.alphaSupport&&nb&&nb<255?";opacity:"+
Math.precision(nb/255,4)+";filter:Alpha(opacity="+Math.precision(nb/2.55,4)+")":"")+'">&nbsp;</span>'}Sa.call(d,za,la.clientPath+"bar-opacity.png");za.html(Ya);za.find(".QuickColor").click(Ab)}Na.call(d,l.color.mode);ja.active.bind(Aa);a.isFunction(eb)&&ja.active.bind(eb);ja.current.bind(bb);if(M.expandable){d.icon=R.parents(".Icon:first");Fa=d.icon.find(".Color:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});Ia=d.icon.find(".Alpha:first");Sa.call(d,Ia,la.clientPath+"bar-opacity.png");va.call(d,
Ia,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ca=d.icon.find(".Image:first").css({backgroundImage:"url('"+la.clientPath+la.picker.file+"')"}).bind("click",Za);if(M.bindToInput&&M.updateInputColor)M.input.css({backgroundColor:Pa&&"#"+Pa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Ga.find(".Move:first").bind("mousedown",ta);ja.active.bind(Cb)}else ub.call(d)},la=l.images,ca=l.localization,ja={active:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&
l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);ra.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",Ab);fa=oa=ia=N=V=Q=J=O=T=K=o=null;ba.destroy();ba=null;Y.destroy();Y=null;sa.destroy();
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);ra.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",Ab);fa=oa=ia=N=V=Q=J=O=T=K=o=null;ba.destroy();ba=null;X.destroy();X=null;sa.destroy();
eb=tb=ob=za=na=ma=ra=pa=sa=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){Bb.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new b({ahex:"#ffcc00ff"}),quickList:[new b({h:360,s:33,v:100}),new b({h:360,s:66,v:100}),new b({h:360,s:100,v:100}),
new b({h:360,s:100,v:75}),new b({h:360,s:100,v:50}),new b({h:180,s:0,v:100}),new b({h:30,s:33,v:100}),new b({h:30,s:66,v:100}),new b({h:30,s:100,v:100}),new b({h:30,s:100,v:75}),new b({h:30,s:100,v:50}),new b({h:180,s:0,v:90}),new b({h:60,s:33,v:100}),new b({h:60,s:66,v:100}),new b({h:60,s:100,v:100}),new b({h:60,s:100,v:75}),new b({h:60,s:100,v:50}),new b({h:180,s:0,v:80}),new b({h:90,s:33,v:100}),new b({h:90,s:66,v:100}),new b({h:90,s:100,v:100}),new b({h:90,s:100,v:75}),new b({h:90,s:100,v:50}),
new b({h:180,s:0,v:70}),new b({h:120,s:33,v:100}),new b({h:120,s:66,v:100}),new b({h:120,s:100,v:100}),new b({h:120,s:100,v:75}),new b({h:120,s:100,v:50}),new b({h:180,s:0,v:60}),new b({h:150,s:33,v:100}),new b({h:150,s:66,v:100}),new b({h:150,s:100,v:100}),new b({h:150,s:100,v:75}),new b({h:150,s:100,v:50}),new b({h:180,s:0,v:50}),new b({h:180,s:33,v:100}),new b({h:180,s:66,v:100}),new b({h:180,s:100,v:100}),new b({h:180,s:100,v:75}),new b({h:180,s:100,v:50}),new b({h:180,s:0,v:40}),new b({h:210,
@ -677,7 +677,7 @@ times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(O);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(V){V=$(V.target).closest("div.tool_button");if(V.length){var N=V.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(N).attr("data-curopt","#"+V[0].id).mouseup();s.setMode(T);n=V[0].id.substr((T+"_").length);b=K.data[n];$(".tools_flyout").fadeOut()}});O=$('<div id="shape_cats">');var Q="";$.each(B,function(V,
N){Q+="<div data-cat="+V+">"+N+"</div>"});O.html(Q).children().bind("mouseup",function(){var V=$(this);V.siblings().removeClass("current");V.addClass("current");p(V.attr("data-cat"));return false});O.children().eq(0).addClass("current");$("#tools_shapelib").prepend(O);J.mouseup(function(){s.setMode(b?T:"select")});$("#tool_shapelib").remove();O=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(O/2),"margin-left":3})},mouseDown:function(O){if(s.getMode()===T){var J=f=O.start_x;
O=d=O.start_y;var Q=s.getStyle();c=s.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:b,id:s.getNextId(),opacity:Q.opacity/2,style:"pointer-events:none"}});c.setAttribute("d",b);if(/[a-z]/.test(b)){b=K.data[n]=s.pathActions.convertPath(c);c.setAttribute("d",b);s.pathActions.fixEnd(c)}c.setAttribute("transform","translate("+J+","+O+") scale(0.005) translate("+-J+","+-O+")");s.recalculateDimensions(c);s.getTransformList(c);q=c.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(O){if(s.getMode()===
T){var J=s.getZoom(),Q=O.event,V=O.mouse_x/J,N=O.mouse_y/J;O=s.getTransformList(c);var ia=c.getBBox();J=ia.x;var oa=ia.y,fa=ia.width,ba=ia.height,Y=V-f,sa=N-d,ka={x:Math.min(f,V),y:Math.min(d,N),width:Math.abs(V-f),height:Math.abs(N-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+Y)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(V<f)ia=q.width;if(N<d)da=q.height;V=l.createSVGTransform();N=l.createSVGTransform();ka=l.createSVGTransform();V.setTranslate(-(J+ia),-(oa+da));if(Q.shiftKey){replaced=
T){var J=s.getZoom(),Q=O.event,V=O.mouse_x/J,N=O.mouse_y/J;O=s.getTransformList(c);var ia=c.getBBox();J=ia.x;var oa=ia.y,fa=ia.width,ba=ia.height,X=V-f,sa=N-d,ka={x:Math.min(f,V),y:Math.min(d,N),width:Math.abs(V-f),height:Math.abs(N-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+X)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(V<f)ia=q.width;if(N<d)da=q.height;V=l.createSVGTransform();N=l.createSVGTransform();ka=l.createSVGTransform();V.setTranslate(-(J+ia),-(oa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(ba));fa=Q*(fa<0?-1:1);ba=Q*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){Q=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;fa*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=Q}}totalScale.sx*=fa;totalScale.sy*=ba;N.setScale(fa,ba);ka.setTranslate(J+ia,oa+da);O.appendItem(ka);O.appendItem(N);O.appendItem(V);s.recalculateDimensions(c);q=c.getBBox()}},mouseUp:function(O){if(s.getMode()===T){if(O.mouse_x==f&&O.mouse_y==d)return{keep:false,
element:c,started:false};s.setMode("select");return{keep:true,element:c,started:false}}}}});(function(){for(var a=0,p=["ms","moz","webkit","o"],g=0;g<p.length&&!window.requestAnimationFrame;++g){window.requestAnimationFrame=window[p[g]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[p[g]+"CancelAnimationFrame"]||window[p[g]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var n=(new Date).getTime(),s=Math.max(0,16-(n-a)),c=window.setTimeout(function(){b(n+s)},s);a=n+s;return c};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
function(b){clearTimeout(b)}})();(function(a){function p(o){var K=o.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){c.call(this,o);o=a(this);o.bind(q,g);o.bind(l,b)}else{clearTimeout(B);s.call(this)}}function g(o){if(B!=null){var K=o.originalEvent;o=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var T=a(this).data("taphold.point");o=o-T.x;K=K-T.y;if(Math.sqrt(o*o+K*K)>d){clearTimeout(B);s.call(this)}}}function b(){clearTimeout(B);s.call(this)}

View File

@ -259,6 +259,22 @@ $(function(){
<span class="icon_label">Height</span>
</label>
</div>
<div id="circle_panel" class="context_panel">
<h4>Circle</h4>
<label id="tool_circle_cx">
<span>Center X</span>
<input id="circle_cx" class="attr_changer" title="Change circle's cx coordinate" size="3" data-attr="cx"/>
</label>
<label id="tool_circle_cy">
<span>Center Y</span>
<input id="circle_cy" class="attr_changer" title="Change circle's cy coordinate" size="3" data-attr="cy"/>
</label>
<label id="tool_circle_r">
<span>Radius</span>
<input id="circle_r" class="attr_changer" title="Change circle's radius" size="3" data-attr="r"/>
</label>
</div>
<div id="ellipse_panel" class="context_panel clearfix">
<h4>Ellipse</h4>

View File

@ -540,11 +540,7 @@
// called when we've selected a different element
var selectedChanged = function(window,elems) {
//check if anything is a polyline
//polyline = elems.filter(function(el){ return el && el.nodeName == "polyline" })
//if (polyline.length) {svgCanvas.convertToPath();}
var mode = svgCanvas.getMode();
if(mode === "select") setSelectMode();
var is_node = (mode == "pathedit");
@ -552,13 +548,28 @@
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
elems = elems.filter(Boolean)
multiselected = (elems.length >= 2) ? elems : false;
if (svgCanvas.elementsAreSame(multiselected)) selectedElement = multiselected[0]
if (selectedElement != null) {
if (!is_node) {
$('#multiselected_panel').hide()
updateToolbar();
}
}
if (multiselected.length) {//multiselected elements are the same
$('#tools_top').addClass('multiselected')
}
}
else if (multiselected.length) {
$('.context_panel').hide()
$('#tools_top').removeClass('multiselected')
$('#multiselected_panel').show()
}
else {
$('.context_panel').hide()
$('#canvas_panel').show()
$('#tools_top').removeClass('multiselected')
}
togglePathEditMode(is_node, elems);
svgCanvas.runExtensions("selectedChanged", {
elems: elems,
@ -1399,7 +1410,7 @@
elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null
if (elem) $("#tools_top").addClass("multiselected")
}
if (!elem && !multiselected) {
$("#tools_top").removeClass("multiselected")
$("#stroke_panel").hide();

View File

@ -7623,7 +7623,7 @@ this.setLinkURL = function(val) {
};
// Function selectedAreSame
// Function elementAreSame
// Checks if all the selected Elements are the same type
//
// Parameters:

View File

@ -1,8 +1,8 @@
function touchHandler(a){var p=a.changedTouches,g=p[0],b="";switch(a.type){case "touchstart":b="mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(b,true,true,window,1,g.screenX,g.screenY,g.clientX,g.clientY,false,false,false,false,0,null);if(p.length<2){g.target.dispatchEvent(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var b=g.handler,n=g.data.toLowerCase().split(" ");g.handler=function(s){if(!(this!==s.target&&(/textarea|select/i.test(s.target.nodeName)||s.target.type==="text"))){var c=s.type!=="keypress"&&a.hotkeys.specialKeys[s.which],f=String.fromCharCode(s.which).toLowerCase(),d="",l={};if(s.altKey&&c!=="alt")d+="alt+";if(s.ctrlKey&&c!=="ctrl")d+="ctrl+";if(s.metaKey&&!s.ctrlKey&&c!=="meta")d+="meta+";if(s.shiftKey&&c!=="shift")d+="shift+";if(c)l[d+c]=
true;else{l[d+f]=true;l[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[f]]=true}c=0;for(f=n.length;c<f;c++)if(l[n[c]])return b.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
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:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,aa,pa,ra){var ma;if(pa!==f){W=aa.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);aa=W[3]||"";if(ra===2&&g(pa))pa=pa.replace(da?Y:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=ra===2?pa:ra===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+
aa}else da=W(aa!==f?aa:p[oa][fa]);return da}function s(da,W,aa){if(W===f||typeof W==="boolean"){aa=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?Y:ba,""):W;return o(W,aa)}function c(da,W,aa,pa){if(!g(aa)&&typeof aa!=="object"){pa=aa;aa=W;W=f}return this.each(function(){var ra=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&ra.attr(ma)||"";ra.attr(ma,q[da](na,aa,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},O,J,Q,V=a.event.special,N="querystring",
ia="fragment",oa="location",fa="href",ba=/^.*\?|#.*$/g,Y=/^.*\#/,sa,ka={};q[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var aa={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ra,ma){var na=ma.split("="),
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:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var W=d.call(arguments,1);return function(){return da.apply(this,W.concat(d.call(arguments)))}}function n(da,W,aa,pa,ra){var ma;if(pa!==f){W=aa.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);aa=W[3]||"";if(ra===2&&g(pa))pa=pa.replace(da?X:ba,"");else{ma=o(W[2]);pa=g(pa)?o[da?ia:N](pa):pa;pa=ra===2?pa:ra===1?a.extend({},pa,ma):a.extend({},ma,pa);pa=q(pa);if(da)pa=pa.replace(sa,l)}da=W[1]+(da?"#":pa||!W[1]?"?":"")+pa+
aa}else da=W(aa!==f?aa:p[oa][fa]);return da}function s(da,W,aa){if(W===f||typeof W==="boolean"){aa=W;W=q[da?ia:N]()}else W=g(W)?W.replace(da?X:ba,""):W;return o(W,aa)}function c(da,W,aa,pa){if(!g(aa)&&typeof aa!=="object"){pa=aa;aa=W;W=f}return this.each(function(){var ra=a(this),ma=W||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&ra.attr(ma)||"";ra.attr(ma,q[da](na,aa,pa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},O,J,Q,V=a.event.special,N="querystring",
ia="fragment",oa="location",fa="href",ba=/^.*\?|#.*$/g,X=/^.*\#/,sa,ka={};q[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,W){var aa={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ra,ma){var na=ma.split("="),
za=l(na[0]),Fa=aa,Ia=0,Ca=za.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(W)na=na&&!isNaN(na)?+na:na==="undefined"?f:pa[na]!==f?pa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){za=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[za]=Ia<Ka?Fa[za]||(Ca[Ia+1]&&isNaN(Ca[Ia+1])?{}:[]):na}else if(a.isArray(aa[za]))aa[za].push(na);else aa[za]=aa[za]!==f?[aa[za],na]:na}else if(za)aa[za]=
W?f:""});return aa};o[N]=b(s,0);o[ia]=K=b(s,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(ka,da)})({a:fa,base:fa,iframe:"src",img:"src",input:"src",form:"action",link:fa,script:"src"});Q=a.elemUrlAttr;a.fn[N]=b(c,N);a.fn[ia]=b(c,ia);T.pushState=O=function(da,W){if(g(da)&&/^#/.test(da)&&W===f)W=2;var aa=da!==f;aa=B(p[oa][fa],aa?da:{},aa?W:2);p[oa][fa]=aa+(/#/.test(aa)?"":"#")};T.getState=J=function(da,W){return da===f||typeof da==="boolean"?K(da):K(W)[da]};T.removeState=function(da){var W=
{};if(da!==f){W=J();a.each(a.isArray(da)?da:arguments,function(aa,pa){delete W[pa]})}O(W,2)};V.hashchange=a.extend(V.hashchange,{add:function(da){function W(pa){var ra=pa[ia]=B();pa.getState=function(ma,na){return ma===f||typeof ma==="boolean"?o(ra,ma):o(ra,na)[ma]};aa.apply(this,arguments)}var aa;if(a.isFunction(da)){aa=da;return W}else{aa=da.handler;da.handler=W}}})})(jQuery,this);
@ -13,19 +13,19 @@ function c(da,W){if(!J){if(n.no_img)da=false;if(da){var aa=a(document.createElem
src:na})}else na=g(a(Fa),ma);ka(na,za)}n.placement&&a.each(n.placement,function(Ka,Na){p[Na]&&a(Ka).each(function(Aa){var ya=p[Na].clone();if(Aa>0&&!da)ya=g(ya,Aa,true);sa(a(this),ya,Na)})});if(!W){da&&aa.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)}
function d(da){if(window.btoa)return window.btoa(da);var W=Array(Math.floor((da.length+2)/3)*4),aa,pa,ra,ma,na,za,Fa=0,Ia=0;do{aa=da.charCodeAt(Fa++);pa=da.charCodeAt(Fa++);ra=da.charCodeAt(Fa++);ma=aa>>2;aa=(aa&3)<<4|pa>>4;na=(pa&15)<<2|ra>>6;za=ra&63;if(isNaN(pa))na=za=64;else if(isNaN(ra))za=64;W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(aa);W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na);
W[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(za)}while(Fa<da.length);return W.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,T,O,J=false,Q=false,V=0,N=navigator.userAgent,ia=!!window.opera;N.indexOf("Safari/")>-1&&N.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+b+'" type=image/svg+xml>').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s);
s(0,true)}catch(ba){f()}}else{var Y=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){T=Y.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=Y.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,aa,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",aa);(aa=da.attr("class"))&&W.attr("class",
s(0,true)}catch(ba){f()}}else{var X=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){T=X.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=X.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,W,aa,pa){ia&&W.css("visibility","hidden");if(n.replace){pa&&W.attr("id",aa);(aa=da.attr("class"))&&W.attr("class",
"svg_icon "+aa);da.replaceWith(W)}else da.append(W);ia&&setTimeout(function(){W.removeAttr("style")},1)},ka=function(da,W){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,W,true);p[W]=da};g=function(da,W){var aa=da.find("defs");if(!aa.length)return da;aa=ia?aa.find("*").filter(function(){return!!this.id}):aa.find("[id]");var pa=da[0].getElementsByTagName("*"),ra=pa.length;aa.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+W+ma;na="url(#"+na+")";var za="url(#"+ma+")";
for(ma=0;ma<ra;ma++){var Fa=pa[ma];Fa.getAttribute("fill")===na&&Fa.setAttribute("fill",za);Fa.getAttribute("stroke")===na&&Fa.setAttribute("stroke",za);Fa.getAttribute("filter")===na&&Fa.setAttribute("filter",za)}});return da}};a.getSvgIcon=function(b,n){var s=p[b];if(n&&s)s=g(s,0,true).clone(true);return s};a.resizeSvgIcons=function(b){var n=!a(".svg_icon:first").length;a.each(b,function(s,c){var f=a.isArray(c),d=f?c[0]:c,l=f?c[1]:c;if(n)s=s.replace(/\.svg_icon/g,"svg");a(s).each(function(){this.setAttribute("width",
d);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=d+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(b,n,s){b=document.createElementNS(p.svg,b);if(g)for(var c in n)b.setAttribute(c,n[c]);else for(c in n){var f=n[c],d=b[c];if(d&&d.constructor==="SVGLength")d.baseVal.value=f;else b.setAttribute(c,f)}s&&s.appendChild(b);return b}var p={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(b){b=b||{};this.alpha=isNaN(b.alpha)?100:b.alpha;if(b.copy){this.type=
b.copy.type;this.alpha=b.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=b.copy.solidColor;break;case "linearGradient":this.linearGradient=b.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=b.copy.radialGradient.cloneNode(true)}}else if(b.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=b.linearGradient.cloneNode(true)}else if(b.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=b.radialGradient.cloneNode(true)}else if(b.solidColor){this.type="solidColor";this.solidColor=b.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 g=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(b){var n=
arguments;return this.each(function(){function s(la,ca,ja,M,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},Y);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else Y.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga=
arguments;return this.each(function(){function s(la,ca,ja,M,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},X);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else X.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Pa){c(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")||
1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Ua){db=Ua.val("hex")?"#"+Ua.val("hex"):"none";Ya=Ua.val("a")!==null?Ua.val("a")/256:1;Pa.setAttribute("fill",db);Pa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color",
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(Y).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var M=0;$(Y).find("stop").each(function(){var R=this.getAttribute("offset"),
ea=$(this);if(R<M){ea.prev().before(ea);wa=$(Y).find("stop")}M=R})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var T=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},O=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(X).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?X.removeAttribute("gradientTransform"):X.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var M=0;$(X).find("stop").each(function(){var R=this.getAttribute("offset"),
ea=$(this);if(R<M){ea.prev().before(ea);wa=$(X).find("stop")}M=R})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var T=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},O=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
q.hide()};$.extend(true,q,{paint:new $.jGraduate.Paint({copy:B.paint}),okCallback:$.isFunction(n[1])&&n[1]||null,cancelCallback:$.isFunction(n[2])&&n[2]||null});q.position();var J=null,Q=$(window);if(q.paint.type=="none")q.paint=$.jGraduate.Paint({solidColor:"ffffff"});q.addClass("jGraduate_Picker");q.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var V=$(K+"> .jGraduate_colPick"),N=$(K+"> .jGraduate_gradPick");N.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
o+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_y1" size="3" title="Enter starting y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">End Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
@ -34,25 +34,25 @@ o+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'
o+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+o+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+o+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+
o+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+o+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+o+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+B.images.clientPath+
'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba&nbsp;</label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+o+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+o+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
o+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+o+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ia=256,oa=ia-0,fa=ia-0,ba,Y,sa,ka={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],W=a("svg",{id:o+"_jgraduate_svg",width:ia,height:ia,xmlns:p.svg},da);ba=ba||q.paint.type;var aa=Y=q.paint[ba],pa=q.paint.alpha,ra=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!ra){Y.id=o+"_lg_jgraduate_grad";
aa=Y=W.appendChild(Y)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!ra){Y.id=o+"_rg_jgraduate_grad";aa=Y=W.appendChild(Y)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(ra){aa=Y=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){J.substr(na,2);var za=(255-parseInt(J.substr(na,2),16)).toString(16);
o+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+o+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ia=256,oa=ia-0,fa=ia-0,ba,X,sa,ka={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],W=a("svg",{id:o+"_jgraduate_svg",width:ia,height:ia,xmlns:p.svg},da);ba=ba||q.paint.type;var aa=X=q.paint[ba],pa=q.paint.alpha,ra=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!ra){X.id=o+"_lg_jgraduate_grad";
aa=X=W.appendChild(X)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},W);if(ba==="linearGradient")break;case "radialGradient":if(!ra){X.id=o+"_rg_jgraduate_grad";aa=X=W.appendChild(X)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},W)}if(ra){aa=X=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":ma="";for(var na=0;na<6;na+=2){J.substr(na,2);var za=(255-parseInt(J.substr(na,2),16)).toString(16);
if(za.length<2)za=0+za;ma+=za}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(aa.getAttribute("x1")||0);ma=parseFloat(aa.getAttribute("y1")||0);na=parseFloat(aa.getAttribute("x2")||1);za=parseFloat(aa.getAttribute("y2")||0);var Fa=parseFloat(aa.getAttribute("cx")||0.5),Ia=parseFloat(aa.getAttribute("cy")||0.5),Ca=parseFloat(aa.getAttribute("fx")||Fa),Ka=parseFloat(aa.getAttribute("fy")||
Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:oa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":pa/100},W);var Na=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:J*ia}).data("coord","start").appendTo(da),Aa=Na.clone().text(2).css({top:za*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa*
ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=Y.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")Y.setAttribute(ca,this.value);var R=M?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:Aa,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=X.getAttribute(ca),M=isNaN(ca[1]);ja||(ja=M?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")X.setAttribute(ca,this.value);var R=M?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:Aa,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Da)});qb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb=
N.find(".jGraduate_spreadMethod").change(function(){Y.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/oa;ja=ja/fa;var M=Za.data("coord"),R=Y;switch(M){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca);
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=Y.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na<ta;na++)s(0,0,0,0,wa[na]);sb.val(Y.getAttribute("spreadMethod")||
"pad");var mb,jb=false;sa.setAttribute("fill-opacity",pa/100);$("#"+o+" div.grad_coord").mousedown(function(la){la.preventDefault();Za=$(this);Za.offset();mb=Za.parent().offset();Q.mousemove(bb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=Y.cloneNode(true);q.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){O()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ka.fx.val("");ka.fy.val("")}$("#"+
o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=Y;if(jb){var ca=Ab||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{Ab=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=Y.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var eb;pa=N=0;if(ba==="radialGradient"){W=Y.gradientTransform.baseVal;if(W.numberOfItems===2){ta=W.getItem(0);W=W.getItem(1);if(ta.type===2&&W.type===3){ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==1)N=Math.round((1-ta.d)*100)}}else if(W.numberOfItems===3){da=W.getItem(0);ta=W.getItem(1);W=W.getItem(2);if(da.type===4&&ta.type===2&&W.type===3){pa=Math.round(da.angle);ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)N=Math.round((1-ta.d)*100)}}}N={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(Y.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:N},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:pa}};$.each(N,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(M){var R=
ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&Y.setAttribute("r",M/100);R=Math.pow(M/100,0.4)/2*145;break;case "opacity":q.paint.alpha=M;sa.setAttribute("fill-opacity",M/100);R=M*1.45;break;case "ellip":fb=La=1;if(M===0){R=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else fb=-(M/100)-1;R=145*((M+100)/
2)/100;ea&&d();break;case "angle":Va=M;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;Y.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
N.find(".jGraduate_spreadMethod").change(function(){X.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/oa;ja=ja/fa;var M=Za.data("coord"),R=X;switch(M){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca);
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=X.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){X.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=X.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na<ta;na++)s(0,0,0,0,wa[na]);sb.val(X.getAttribute("spreadMethod")||
"pad");var mb,jb=false;sa.setAttribute("fill-opacity",pa/100);$("#"+o+" div.grad_coord").mousedown(function(la){la.preventDefault();Za=$(this);Za.offset();mb=Za.parent().offset();Q.mousemove(bb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=X.cloneNode(true);q.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){O()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ka.fx.val("");ka.fy.val("")}$("#"+
o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=X;if(jb){var ca=Ab||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{Ab=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=X.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){X.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=X.getElementsByTagNameNS(p.svg,"stop")}var eb;pa=N=0;if(ba==="radialGradient"){W=X.gradientTransform.baseVal;if(W.numberOfItems===2){ta=W.getItem(0);W=W.getItem(1);if(ta.type===2&&W.type===3){ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==1)N=Math.round((1-ta.d)*100)}}else if(W.numberOfItems===3){da=W.getItem(0);ta=W.getItem(1);W=W.getItem(2);if(da.type===4&&ta.type===2&&W.type===3){pa=Math.round(da.angle);ta=W.matrix;if(ta.a!==1)N=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)N=Math.round((1-ta.d)*100)}}}N={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(X.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:N},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:pa}};$.each(N,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(M){var R=
ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&X.setAttribute("r",M/100);R=Math.pow(M/100,0.4)/2*145;break;case "opacity":q.paint.alpha=M;sa.setAttribute("fill-opacity",M/100);R=M*1.45;break;case "ellip":fb=La=1;if(M===0){R=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else fb=-(M/100)-1;R=145*((M+100)/
2)/100;ea&&d();break;case "angle":Va=M;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;X.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(N=(q.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+N;ra||(J=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});V.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){O()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current");
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(Y!==ca){var ja=
$(Y).find("stop");$(ca).empty().append(ja);Y=ca;ca=sb.val();Y.setAttribute("spreadMethod",ca)}jb=la==="rg"&&Y.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb=
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(X!==ca){var ja=
$(X).find("stop");$(ca).empty().append(ja);X=ca;ca=sb.val();X.setAttribute("spreadMethod",ca)}jb=la==="rg"&&X.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb=
$(K+" .jGraduate_tab_radgrad");break;default:Bb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,b){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),c=$("#"+g.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var B=d.pageX,o=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;o=d.originalEvent.touches[0].pageY}d=a.width()-c.width();l=a.height()-c.height();if(B>d-15)B=d-15;
if(o>l-30)o=l-30;if(svgedit.browser.isTouch())o-=c.height()/2;p.unbind("click");c.css({top:o,left:B}).fadeIn(g.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
@ -64,7 +64,7 @@ function(){return false})});return $(this)},disableContextMenuItems:function(g){
0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(oa,0);return true}catch(ba){}return false}(),T=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var fa=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(oa,
0);return true}catch(ba){}return false}(),O=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);fa.setAttribute("x",5);oa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(oa);return fa===0}(),J=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(oa);return fa.height>4&&fa.height<5}(),Q=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 10,0");var ba=
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(fa);Y.appendChild(ba);oa.appendChild(Y);fa=Y.getBBox();document.documentElement.removeChild(oa);return fa.width==15}(),V=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var X=document.createElementNS("http://www.w3.org/2000/svg","g");X.appendChild(fa);X.appendChild(ba);oa.appendChild(X);fa=X.getBBox();document.documentElement.removeChild(oa);return fa.width==15}(),V=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
return oa}(),N=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("style","vector-effect:non-scaling-stroke");return oa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();oa.appendItem(fa);return oa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return s};
svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return V};svgedit.browser.supportsNonScalingStroke=function(){return N};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
@ -200,7 +200,7 @@ true);a.appendChild(d);var l=f.createElementNS(b,"svg");(c.clearSvgContentElemen
function(e){q=e};c.current_drawing_=new svgedit.draw.Drawing(l,q);var B=c.getCurrentDrawing=function(){return c.current_drawing_},o=1,K=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=T.shape,J=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(b,e.element);if(m)(K||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,
"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},V=c.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ia=c.matrixMultiply=svgedit.math.matrixMultiply,oa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=c.transformListToTransform=svgedit.math.transformListToTransform,
ba=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
ba=svgedit.math.snapToAngle,X=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
getSVGContent:function(){return l}});var ka=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,W=c.setHref=svgedit.utilities.setHref,aa=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var pa=c.getRotationAngle=svgedit.utilities.getRotationAngle,ra=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,za=svgedit.sanitize.getNSMap(),Fa=c.sanitizeSvg=
svgedit.sanitize.sanitizeSvg,Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,Aa=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)c.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();c.pathActions.clear();M("changed",z);z=h.type();
m=e==m.AFTER_APPLY;if(z==Ia.type()){m=m?h.newParent:h.oldParent;m==l&&c.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&c.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&c.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&
@ -228,17 +228,17 @@ case 11:case 10:m+=u.r1+","+u.r2+" "+u.angle+" "+ +u.largeArcFlag+" "+ +u.sweepF
2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new Aa("Transform");var A={},u=null;z=[];switch(e.tagName){case "line":z=["x1","y1",
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":u={};u.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I<F;++I){var E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}break;case "path":u={};u.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
$(e).attr(z);$.each(A,function(ha,Ta){A[ha]=sa(ha,Ta)})}else if(H)A={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(u==null){u=$.extend(true,{},A);$.each(u,function(ha,Ta){u[ha]=sa(ha,Ta)})}u.transform=Va?Va:"";if(e.tagName=="g"&&!H||e.tagName=="a"){w=svgedit.utilities.getBBox(e);var G={x:w.x+w.width/2,y:w.y+w.height/2},L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);z=d.createSVGMatrix();if(w=pa(e)){I=w*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var v=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=V(U);if(S){z=fa(S).matrix;H=pa(U);var X=Va,Z=[];Va=U.getAttribute("transform");if(H||oa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);Z.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var qa=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();qa.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(qa);Z.push(Ba);Z.push(Oa);Z.push(qa)}m.addSubCommand(Ua(U));Va=X}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){X=U.getAttribute("clip-path");if(k.indexOf(X)===-1){nb(X,H,z);k.push(X)}}X=Va;Va=U.getAttribute("transform");
if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(b,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=X}}}k=[];Va=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform");
if(S=V(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=X;X=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(X)&&U.setAttribute("stroke-width",X*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+v.e,y:G.y+v.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(w,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){X=Va;Va=U.getAttribute("transform");S=V(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Ua(U));Va=X}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=pa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((v=e.getAttribute("fill"))&&v.indexOf("url(")===0){v=R(v);X="pattern";if(v.tagName!==X)X="gradient";if(v.getAttribute(X+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=V(v);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";v.setAttribute(X+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;v=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,v,X);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var v=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=V(U);if(S){z=fa(S).matrix;H=pa(U);var Y=Va,Z=[];Va=U.getAttribute("transform");if(H||oa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);Z.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var qa=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();qa.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(qa);Z.push(Ba);Z.push(Oa);Z.push(qa)}m.addSubCommand(Ua(U));Va=Y}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){Y=U.getAttribute("clip-path");if(k.indexOf(Y)===-1){nb(Y,H,z);k.push(Y)}}Y=Va;Va=U.getAttribute("transform");
if(S=V(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(b,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);V(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=Y}}}k=[];Va=Y}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");
if(S=V(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=Y;Y=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(Y)&&U.setAttribute("stroke-width",Y*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+v.e,y:G.y+v.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(w,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,v,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");S=V(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Ua(U));Va=Y}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=pa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=N(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((v=e.getAttribute("fill"))&&v.indexOf("url(")===0){v=R(v);Y="pattern";if(v.tagName!==Y)Y="gradient";if(v.getAttribute(Y+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=V(v);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";v.setAttribute(Y+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;v=h.getItem(0).matrix;Y=fa(h,1).matrix;w=Y.inverse();z=ia(w,v,Y);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
A.points=Array(F);for(I=0;I<F;++I){E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}}case "path":A.d=e.getAttribute("d");I=1;h.clear()}}else{I=4;if(H){G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)db(e,A,z);if(I==2){if(H){oa(h)||(L={x:G.x+z.e,y:G.y+z.f});G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==
3&&H){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(H,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,v,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,u));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||M("selected",
3&&H){z=fa(h).matrix;v=d.createSVGTransform();v.setRotate(H,G.x,G.y);v=v.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,v,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,u));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||M("selected",
J)},vb=this.addToSelection=function(e,h){if(e.length!=0){for(var m=0;m<J.length;){if(J[m]==null)break;++m}for(var z=e.length;z--;){var w=e[z];if(w&&svgedit.utilities.getBBox(w)){if(w.tagName==="a"&&w.childNodes.length===1)w=w.firstChild;if(J.indexOf(w)==-1){J[m]=w;m++;w=Ha.requestSelector(w);J.length>1&&w.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3-
(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m<len;++m){var z=J[m];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ea="select";xb($(K||e).children())}};var Ib=this.getMouseTarget=function(e){if(e==
null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z=
@ -252,13 +252,13 @@ curStyles:true,attr:{cx:E,cy:I,r:0,id:ja(),opacity:O.opacity/2}});break;case "el
true;break;case "textedit":h*=o;m*=o;hb.mouseDown(u,G,h,m);La=true;break;case "rotate":La=true;c.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}C=ob("mouseDown",{event:u,start_x:h,start_y:m,selectedElements:J},true);$.each(C,function(P,U){if(U&&U.started)La=true});if(Ea)document.getElementById("workarea").className=Ea=="resize"?u.target.style.cursor:Ea}}).mousemove(function(u){if(!(u.originalEvent.touches&&u.originalEvent.touches.length>1))if(La)if(!(u.button===
1||c.spaceKey)){var F=J[0],I=N(u.pageX,u.pageY,rb),E=I.x*(isBotchedZoom?1:o);I=I.y*(isBotchedZoom?1:o);var G=ra(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}u.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v)}if(u.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||v!=0){C=J.length;for(k=0;k<C;++k){F=J[k];if(F==null)break;var D=d.createSVGTransform();G=V(F);D.setTranslate(L,v);G.numberOfItems?G.replaceItem(D,0):G.appendItem(D);Ha.requestSelector(F).resize()}if(u.altKey)if(!c.addClones){c.addClones=
c.cloneSelectedElements(0,0,D);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(Oa){Oa.parentNode&&Oa.parentNode.removeChild(Oa);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",J)}}break;case "multiselect":L*=o;k*=o;ma(ta,{x:Math.min(z,L),y:Math.min(w,k),width:Math.abs(L-z),height:Math.abs(k-w)},100);G=[];L=[];D=tb();C=J.length;for(k=0;k<C;++k){v=D.indexOf(J[k]);if(v==-1)G.push(J[k]);else D[v]=null}C=D.length;for(k=0;k<C;++k)D[k]&&L.push(D[k]);
G.length>0&&c.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var X=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=X*Math.cos(v);v=X*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var Z=X=0,ga=U?(U+v)/U:1,qa=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/
U:1;Z=U}if(kb.indexOf("w")>=0){qa=P?(P-L)/P:1;X=P}L=d.createSVGTransform();v=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);X=wa(X);k=wa(k);Z=wa(Z)}L.setTranslate(-(C+X),-(k+Z));if(u.shiftKey)if(qa==1)qa=ga;else ga=qa;v.setScale(qa,ga);P.setTranslate(C+X,k+Z);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(v,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(v,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition",J);break;
G.length>0&&c.removeFromSelection(G);L.length>0&&vb(L);break;case "resize":G=V(F);L=(D=oa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;v=y-m;if(n.gridSnapping){L=wa(L);v=wa(v);U=wa(U);P=wa(P)}var S=pa(F);if(S){var Y=Math.sqrt(L*L+v*v);v=Math.atan2(v,L)-S*Math.PI/180;L=Y*Math.cos(v);v=Y*Math.sin(v)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)v=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var Z=Y=0,ga=U?(U+v)/U:1,qa=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-v)/
U:1;Z=U}if(kb.indexOf("w")>=0){qa=P?(P-L)/P:1;Y=P}L=d.createSVGTransform();v=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);Z=wa(Z)}L.setTranslate(-(C+Y),-(k+Z));if(u.shiftKey)if(qa==1)qa=ga;else ga=qa;v.setScale(qa,ga);P.setTranslate(C+Y,k+Z);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(v,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(v,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();M("transition",J);break;
case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(u.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea=="square"||
u.shiftKey){L=D=Math.max(L,D);C=h<x?h:h-L;k=m<y?m:m-D}else{C=Math.min(h,x);k=Math.min(m,y)}if(u.altKey){L*=2;D*=2;C=h-L/2;k=m-D/2}if(n.gridSnapping){L=wa(L);D=wa(D);C=wa(C);k=wa(k)}ma(G,{width:L,height:D,x:C,y:k},1E3);break;case "circle":L=$(G).attr(["cx","cy"]);D=L.cx;C=L.cy;L=Math.sqrt((x-D)*(x-D)+(y-C)*(y-C));if(n.gridSnapping)L=wa(L);G.setAttributeNS(null,"r",L);break;case "ellipse":L=$(G).attr(["cx","cy"]);D=Math.abs(h+(x-h)/2);C=Math.abs(m+(y-m)/2);L=null;window.opera||d.suspendRedraw(1E3);
if(n.gridSnapping){x=wa(x);D=wa(D);y=wa(y);C=wa(C)}k=Math.abs(h-D);v=Math.abs(m-C);if(u.shiftKey){v=k;C=y>m?m+k:m-k}if(u.altKey){D=h;C=m;k=Math.abs(x-D);v=u.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",v);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+
k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(u.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L=
svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=Y(F);G=N(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove",
svgedit.utilities.getBBox(F);D=L.x+L.width/2;C=L.y+L.height/2;G=X(F);G=N(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);M("transition",J)}ob("mouseMove",
{event:u,mouse_x:E,mouse_y:I,selected:F})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var F=u.target.parentNode;if(F!==K){var I=Ib(u),E=I.tagName;if(E==="text"&&Ea!=="textedit"){u=N(u.pageX,u.pageY,rb);hb.select(I,u.x,u.y)}if((E==="g"||E==="a")&&pa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(u){c.addClones=false;window.removeEventListener("keyup",c.removeClones);
if(u.button!==2){var F=Cb;Cb=null;if(La){var I=N(u.pageX,u.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=ra(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity=
E.getAttribute("stroke-opacity");bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(E=0;E<u;++E){if(J[E]==null)break;J[E].firstChild||Ha.requestSelector(J[E]).resize()}}else{E=
@ -267,14 +267,14 @@ if(v=G>=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPo
curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[k]);v=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[k]);v=true}break;case "text":v=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(u,k,E,I);k=F.element;v=F.keep;break;case "pathedit":v=true;k=null;Ja.mouseUp(u);
break;case "textedit":v=false;k=null;hb.mouseUp(u,E,I);break;case "rotate":v=true;k=null;Ea="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();M("changed",J)}E=ob("mouseUp",{event:u,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){v=U.keep||v;k=U.element;La=U.started||La}});if(!v&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=u.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&&
E.id!="svgcanvas"&&E.id!="svgroot"){c.setMode("select");xb([E],true)}}else if(k!=null){c.addedNew=true;u=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=O.opacity){C=$(false).clone().attr({to:O.opacity,dur:u}).appendTo(k);try{C[0].beginElement()}catch(D){}}else u=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",O.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));M("changed",[k])},u*
1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(u.wheelDelta)if(u.wheelDelta>=120)F.factor=2;else{if(u.wheelDelta<=-120)F.factor=0.5}else if(u.detail)if(u.detail>0)F.factor=0.5;else if(u.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=c.textActions=function(){function e(S){var X=I.value===
"";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var Z;Z=k[S];X||I.setSelectionRange(S,S);E=ra("text_cursor");if(!E){E=document.createElementNS(b,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=ra("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));X=H(Z.x,v.y);Z=H(Z.x,v.y+v.height);ma(E,{x1:X.x,y1:X.y,x2:Z.x,
y2:Z.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,Z){if(S===X)e(X);else{Z||I.setSelectionRange(S,X);G=ra("text_selectblock");if(!G){G=document.createElementNS(b,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});ra("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];E.setAttribute("visibility","hidden");X=H(S.x,v.y);Z=H(S.x+(ga.x-S.x),v.y);var qa=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+X.x+
","+X.y+" L"+Z.x+","+Z.y+" "+S.x+","+S.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function m(S,X){var Z=d.createSVGPoint();Z.x=S;Z.y=X;if(k.length==1)return 0;Z=F.getCharNumAtPosition(Z);if(Z<0){Z=k.length-2;if(S<=k[0].x)Z=0}else if(Z>=k.length-2)Z=k.length-2;var ga=k[Z];S>ga.x+ga.width/2&&Z++;return Z}function z(S,X,Z){var ga=I.selectionStart;S=m(S,X);h(Math.min(ga,S),Math.max(ga,S),!Z)}function w(S,X){var Z={x:S,y:X};Z.x/=o;Z.y/=o;if(C){var ga=N(Z.x,Z.y,C.inverse());Z.x=ga.x;Z.y=ga.y}return Z}
function H(S,X){var Z={x:S,y:X};if(C){var ga=N(Z.x,Z.y,C);Z.x=ga.x;Z.y=ga.y}Z.x*=o;Z.y*=o;return Z}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function u(S){if(U&&F){var X=N(S.pageX,S.pageY,rb);X=w(X.x*o,X.y*o);X=m(X.x,X.y);var Z=F.textContent,ga=Z.substr(0,X).replace(/[a-z0-9]+$/i,"").length;Z=Z.substr(X).match(/^[a-z0-9]+/i);h(ga,(Z?Z[0].length:0)+X);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],v,C,D,P,U;return{select:function(S,
X,Z){F=S;hb.toEditMode(X,Z)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,X,Z,ga){S=w(Z,ga);I.focus();e(m(S.x,S.y));D=Z;P=ga},mouseMove:function(S,X){var Z=w(S,X);z(Z.x,Z.y)},mouseUp:function(S,X,Z){var ga=w(X,Z);z(ga.x,ga.y,true);S.target!==F&&X<D+2&&X>D-2&&Z<P+2&&Z>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var Z=w(S,X);e(m(Z.x,Z.y))}else e();setTimeout(function(){U=
1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=l.getScreenCTM().inverse();var F=N(u.pageX,u.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(u.wheelDelta)if(u.wheelDelta>=120)F.factor=2;else{if(u.wheelDelta<=-120)F.factor=0.5}else if(u.detail)if(u.detail>0)F.factor=0.5;else if(u.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=c.textActions=function(){function e(S){var Y=I.value===
"";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!==I.selectionStart)return;S=I.selectionEnd}var Z;Z=k[S];Y||I.setSelectionRange(S,S);E=ra("text_cursor");if(!E){E=document.createElementNS(b,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=ra("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(Z.x,v.y);Z=H(Z.x,v.y+v.height);ma(E,{x1:Y.x,y1:Y.y,x2:Z.x,
y2:Z.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,Y,Z){if(S===Y)e(Y);else{Z||I.setSelectionRange(S,Y);G=ra("text_selectblock");if(!G){G=document.createElementNS(b,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});ra("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,v.y);Z=H(S.x+(ga.x-S.x),v.y);var qa=H(S.x,v.y+v.height);S=H(S.x+(ga.x-S.x),v.y+v.height);ma(G,{d:"M"+Y.x+
","+Y.y+" L"+Z.x+","+Z.y+" "+S.x+","+S.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function m(S,Y){var Z=d.createSVGPoint();Z.x=S;Z.y=Y;if(k.length==1)return 0;Z=F.getCharNumAtPosition(Z);if(Z<0){Z=k.length-2;if(S<=k[0].x)Z=0}else if(Z>=k.length-2)Z=k.length-2;var ga=k[Z];S>ga.x+ga.width/2&&Z++;return Z}function z(S,Y,Z){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!Z)}function w(S,Y){var Z={x:S,y:Y};Z.x/=o;Z.y/=o;if(C){var ga=N(Z.x,Z.y,C.inverse());Z.x=ga.x;Z.y=ga.y}return Z}
function H(S,Y){var Z={x:S,y:Y};if(C){var ga=N(Z.x,Z.y,C);Z.x=ga.x;Z.y=ga.y}Z.x*=o;Z.y*=o;return Z}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function u(S){if(U&&F){var Y=N(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var Z=F.textContent,ga=Z.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;Z=Z.substr(Y).match(/^[a-z0-9]+/i);h(ga,(Z?Z[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],v,C,D,P,U;return{select:function(S,
Y,Z){F=S;hb.toEditMode(Y,Z)},start:function(S){F=S;hb.toEditMode()},mouseDown:function(S,Y,Z,ga){S=w(Z,ga);I.focus();e(m(S.x,S.y));D=Z;P=ga},mouseMove:function(S,Y){var Z=w(S,Y);z(Z.x,Z.y)},mouseUp:function(S,Y,Z){var ga=w(Y,Z);z(ga.x,ga.y,true);S.target!==F&&Y<D+2&&Y>D-2&&Z<P+2&&Z>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var Z=w(S,Y);e(m(Z.x,Z.y))}else e();setTimeout(function(){U=
true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");M("selected",[F]);vb([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,
X=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=X?Y(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var Z={x:v.x+v.width/2,width:0};for(X=0;X<S;X++){var ga=F.getStartPositionOfChar(X);Z=F.getEndPositionOfChar(X);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*o;ga.x-=qa;Z.x-=qa;ga.x/=o;Z.x/=o}k[X]={x:ga.x,y:v.y,width:Z.x-ga.x,height:v.height}}k.push({x:Z.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=c.pathActions=function(){var e=
Y=F.getAttribute("transform");v=svgedit.utilities.getBBox(F);C=Y?X(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",u).dblclick(u);if(!S)var Z={x:v.x+v.width/2,width:0};for(Y=0;Y<S;Y++){var ga=F.getStartPositionOfChar(Y);Z=F.getEndPositionOfChar(Y);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*o;ga.x-=qa;Z.x-=qa;ga.x/=o;Z.x/=o}k[Y]={x:ga.x,y:v.y,width:Z.x-ga.x,height:v.height}}k.push({x:Z.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=c.pathActions=function(){var e=
false,h,m,z;svgedit.path.Path.prototype.endChanges=function(A){if(svgedit.browser.isWebkit()){var u=this.elem;u.setAttribute("d",Ja.convertPath(u))}A=new Na(this.elem,{d:this.last_d},A);ya(A);M("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var u=0;u<A.length;u++){var F=A[u],I=this.segs[F];I.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();u=this.selected_pts.length;for(A=Array(u);u--;){I=
this.segs[this.selected_pts[u]];I.select(true);A[u]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,u,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;u=mouse_y/o;F=ra("path_stretch_line");m=[I,u];if(n.gridSnapping){I=wa(I);u=wa(u);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(b,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});
F=ra("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var v=E.getItem(G),C=v.x;v=v.y;if(I>=C-L&&I<=C+L&&u>=v-L&&u<=v+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=ra(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;u=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,u):w.createSVGPathSegCurvetoCubicAbs(I,u,A.x1/o,A.y1/o,I,u);I=w.createSVGPathSegClosePath();
@ -297,9 +297,9 @@ G=function(v,C){for(;C--;)I.removeItem(v)};if(E<=1)return true;for(;E--;){var L=
c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var u=A.points,F=u.numberOfItems;if(F>=4){var I=u.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=u.getItem(G),k=u.getItem(G+1),v=u.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E,L,I))&&I.length==
2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,v.x,v.y].join(","));I=v;E=k}for(A.push("L");G<F;++G){k=u.getItem(G);A.push([k.x,k.y].join(","))}A=A.join(" ");A=Q({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,u){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var I={x:0,y:0};
I[A]=u-F.item[A];F.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var u=A.pathSegList,F=u.numberOfItems,I,E=0;E<F;++E){var G=u.getItem(E);if(G.pathSegType===2)I=G;if(G.pathSegType===1){G=u.getItem(E-1);if(G.x!=I.x||G.y!=I.y){u=A.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(A,u,E);Ja.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ja.convertPath(A))},convertPath:function(A,u){for(var F=A.pathSegList,I=F.numberOfItems,E=0,
G=0,L="",k=null,v=0;v<I;++v){var C=F.getItem(v),D=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,X=C.x2||0,Z=C.y2||0,ga=C.pathSegType,qa=Pa[ga]["to"+(u?"Lower":"Upper")+"Case"](),Oa=function(Ba,ha,Ta){ha=ha?" "+ha.join(" "):"";Ta=Ta?" "+svgedit.units.shortFloat(Ta):"";$.each(Ba,function(Ra,ua){Ba[Ra]=svgedit.units.shortFloat(ua)});L+=qa+Ba.join(" ")+ha+Ta};switch(ga){case 1:L+="z";break;case 12:D-=E;case 13:if(u){E+=D;qa="l"}else{D+=E;E=D;qa="L"}Oa([[D,G]]);break;case 14:P-=G;case 15:if(u){G+=P;qa="l"}else{P+=
G;G=P;qa="L"}Oa([[E,P]]);break;case 2:case 4:case 18:D-=E;P-=G;case 5:case 3:if(k&&F.getItem(v-1).pathSegType===1&&!u){E=k[0];G=k[1]}case 19:if(u){E+=D;G+=P}else{D+=E;P+=G;E=D;G=P}if(ga===3)k=[E,G];Oa([[D,P]]);break;case 6:D-=E;U-=E;X-=E;P-=G;S-=G;Z-=G;case 7:if(u){E+=D;G+=P}else{D+=E;U+=E;X+=E;P+=G;S+=G;Z+=G;E=D;G=P}Oa([[U,S],[X,Z],[D,P]]);break;case 8:D-=E;U-=E;P-=G;S-=G;case 9:if(u){E+=D;G+=P}else{D+=E;U+=E;P+=G;S+=G;E=D;G=P}Oa([[U,S],[D,P]]);break;case 10:D-=E;P-=G;case 11:if(u){E+=D;G+=P}else{D+=
E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;X-=E;P-=G;Z-=G;case 17:if(u){E+=D;G+=P}else{D+=E;X+=E;P+=G;Z+=G;E=D;G=P}Oa([[X,Z],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(b,"*"),A=H.length,u=0;u<A;u++){for(var F=H[u],I=0;I<w;I++){var E=
G=0,L="",k=null,v=0;v<I;++v){var C=F.getItem(v),D=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,Y=C.x2||0,Z=C.y2||0,ga=C.pathSegType,qa=Pa[ga]["to"+(u?"Lower":"Upper")+"Case"](),Oa=function(Ba,ha,Ta){ha=ha?" "+ha.join(" "):"";Ta=Ta?" "+svgedit.units.shortFloat(Ta):"";$.each(Ba,function(Ra,ua){Ba[Ra]=svgedit.units.shortFloat(ua)});L+=qa+Ba.join(" ")+ha+Ta};switch(ga){case 1:L+="z";break;case 12:D-=E;case 13:if(u){E+=D;qa="l"}else{D+=E;E=D;qa="L"}Oa([[D,G]]);break;case 14:P-=G;case 15:if(u){G+=P;qa="l"}else{P+=
G;G=P;qa="L"}Oa([[E,P]]);break;case 2:case 4:case 18:D-=E;P-=G;case 5:case 3:if(k&&F.getItem(v-1).pathSegType===1&&!u){E=k[0];G=k[1]}case 19:if(u){E+=D;G+=P}else{D+=E;P+=G;E=D;G=P}if(ga===3)k=[E,G];Oa([[D,P]]);break;case 6:D-=E;U-=E;Y-=E;P-=G;S-=G;Z-=G;case 7:if(u){E+=D;G+=P}else{D+=E;U+=E;Y+=E;P+=G;S+=G;Z+=G;E=D;G=P}Oa([[U,S],[Y,Z],[D,P]]);break;case 8:D-=E;U-=E;P-=G;S-=G;case 9:if(u){E+=D;G+=P}else{D+=E;U+=E;P+=G;S+=G;E=D;G=P}Oa([[U,S],[D,P]]);break;case 10:D-=E;P-=G;case 11:if(u){E+=D;G+=P}else{D+=
E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;Y-=E;P-=G;Z-=G;case 17:if(u){E+=D;G+=P}else{D+=E;Y+=E;P+=G;Z+=G;E=D;G=P}Oa([[Y,Z],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(b,"*"),A=H.length,u=0;u<A;u++){for(var F=H[u],I=0;I<w;I++){var E=
ka(F.getAttribute(z[I]));E&&h.push(E.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(u=e.length;u--;){z=e[u];w=z.id;if(h.indexOf(w)<0){Ab[w]=z;z.parentNode.removeChild(z);m++}}return m};this.svgCanvasToString=function(){for(;Kb()>0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e=
[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w<z;w++)if(m[w].nodeName=="id"||m[w].nodeName=="style")z--;if(z<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var h=this.svgToString(l,0);e.length&&$(e).each(function(){Bb(this)});return h};this.svgToString=function(e,h){var m=[],z=svgedit.utilities.toXml,w=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+w+"$");if(e){na(e);var A=e.attributes,u,F,I=e.childNodes;for(F=0;F<h;F++)m.push(" ");m.push("<");m.push(e.nodeName);
if(e.id==="svgcontent"){F=Eb();if(w!=="px"){F.w=svgedit.units.convertUnit(F.w,w)+w;F.h=svgedit.units.convertUnit(F.h,w)+w}m.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var E={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(v,C){var D=C.namespaceURI;if(D&&!E[D]&&za[D]!=="xmlns"&&za[D]!=="xml"){E[D]=true;m.push(" xmlns:"+za[D]+'="'+D+'"')}})});F=A.length;for(w=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){u=A.item(F);var G=z(u.nodeValue);if(u.nodeName.indexOf("xmlns:")!==
@ -350,7 +350,7 @@ function(e){Za.fill=e;gb("fill",e)};this.getFontSize=function(){return Za.fill};
true;else if(!m)return;var w=new Aa("Change Image URL");W(h,e);w.addSubCommand(new Na(h,{"#href":z}));m?$(new Image).load(function(){var H=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Ha.requestSelector(h).resize();w.addSubCommand(new Na(h,H));ya(w);M("changed",[h])}).attr("src",e):ya(w)}};this.setLinkURL=function(e){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var m=da(h);if(m!==e){var z=new Aa("Change Link URL");W(h,e);
z.addSubCommand(new Na(h,{"#href":m}));ya(z)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:J.every(function(h){return h&&J[0]?h.nodeName==J[0].nodeName:null})};this.setRectRadius=function(e){c.elementsAreSame(J)&&J[0].tagName=="rect"&&J.forEach(function(h){var m=h.getAttribute("rx");if(m!=e){h.setAttribute("rx",e);h.setAttribute("ry",e);ya(new Na(h,{rx:m,ry:m},"Radius"));M("changed",[h])}})};this.makeHyperlink=function(e){c.groupSelectedElements("a",e)};this.removeHyperlink=
function(){c.ungroupSelectedElement()};this.setSegType=function(e){Ja.setSegType(e)};this.convertToPath=function(e,h){if(e==null)$.each(J,function(U,S){S&&c.convertToPath(S)});else{if(!h)var m=new Aa("Convert element to Path");var z=h?{}:{fill:O.fill,"fill-opacity":O.fill_opacity,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,opacity:O.opacity,visibility:"hidden"};
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,u=e.parentNode;e.nextSibling?u.insertBefore(w,e):u.appendChild(w);var F="",I=function(U){$.each(U,function(S,X){var Z=X[1];F+=X[0];for(var ga=0;ga<Z.length;ga+=2)F+=Z[ga]+","+Z[ga+1]+" "})},E=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,u=e.parentNode;e.nextSibling?u.insertBefore(w,e):u.appendChild(w);var F="",I=function(U){$.each(U,function(S,Y){var Z=Y[1];F+=Y[0];for(var ga=0;ga<Z.length;ga+=2)F+=Z[ga]+","+Z[ga+1]+" "})},E=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
"ry","cx","cy"]),L=G.cx,k=G.cy,v=G.rx;G=G.ry;if(e.tagName=="circle")v=G=$(e).attr("r");I([["M",[L-v,k]],["C",[L-v,k-G/E,L-v/E,k-G,L,k-G]],["C",[L+v/E,k-G,L+v,k-G/E,L+v,k]],["C",[L+v,k+G/E,L+v/E,k+G,L,k+G]],["C",[L-v/E,k+G,L-v,k+G/E,L-v,k]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":G=$(e).attr(["x1","y1","x2","y2"]);F="M"+G.x1+","+G.y1+"L"+G.x2+","+G.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":G=$(e).attr(["rx","ry"]);v=G.rx;G=
G.ry;var C=e.getBBox();L=C.x;k=C.y;var D=C.width;C=C.height;E=4-E;!v&&!G?I([["M",[L,k]],["L",[L+D,k]],["L",[L+D,k+C]],["L",[L,k+C]],["L",[L,k]],["Z",[]]]):I([["M",[L,k+G]],["C",[L,k+G/E,L+v/E,k,L+v,k]],["L",[L+D-v,k]],["C",[L+D-v/E,k,L+D,k+G/E,L+D,k+G]],["L",[L+D,k+C-G]],["C",[L+D,k+C-G/E,L+D-v/E,k+C,L+D-v,k+C]],["L",[L+v,k+C]],["C",[L+v/E,k+C,L,k+C-G/E,L,k+C-G]],["L",[L,k+G]],["Z",[]]]);break;default:w.parentNode.removeChild(w)}F&&w.setAttribute("d",F);if(h){Ja.resetOrientation(w);m=false;try{m=
w.getBBox()}catch(P){}w.parentNode.removeChild(w);return m}else{if(H){H=V(w);oa(H)&&Ja.resetOrientation(w)}m.addSubCommand(new Ka(e,e.nextSibling,u));m.addSubCommand(new Ca(w));Qa();e.parentNode.removeChild(e);w.setAttribute("id",A);w.removeAttribute("visibility");vb([w],true);ya(m)}}};var yb=this.changeSelectedAttributeNoUndo=function(e,h,m){var z=d.suspendRedraw(1E3);Ea=="pathedit"&&Ja.moveNode(e,h);m=m||J;for(var w=m.length,H=["g","polyline","path"];w--;){var A=m[w];if(A!=null){Ea==="textedit"&&
@ -361,7 +361,7 @@ var u=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new K
100);ya(z);M("changed",m)}};this.groupSelectedElements=function(e){e||(e="g");var h="";switch(e){case "a":h="Make hyperlink";var m="";if(arguments.length>1)m=arguments[1];break;default:e="g";h="Group Elements"}h=new Aa(h);var z=Q({element:e,attr:{id:ja()}});e==="a"&&W(z,m);h.addSubCommand(new Ca(z));for(m=J.length;m--;){var w=J[m];if(w!=null){if(w.parentNode.tagName==="a"&&w.parentNode.childNodes.length===1)w=w.parentNode;var H=w.nextSibling,A=w.parentNode;z.appendChild(w);h.addSubCommand(new Ia(w,
H,A))}}h.isEmpty()||ya(h);xb([z],true)};var Mb=this.pushGroupProperties=function(e,h){var m=e.childNodes,z=m.length,w=e.getAttribute("transform"),H=V(e),A=fa(H).matrix,u=new Aa("Push group properties"),F=0,I=pa(e),E=$(e).attr(["filter","opacity"]),G,L;for(F=0;F<z;F++){var k=m[F];if(k.nodeType===1){if(E.opacity!==null&&E.opacity!==1){k.getAttribute("opacity");var v=Math.round((k.getAttribute("opacity")||1)*E.opacity*100)/100;gb("opacity",v,[k])}if(E.filter){var C=v=this.getBlur(k);L||(L=this.getBlur(e));
if(v)v=L-0+(v-0);else if(v===0)v=L;if(C)G=R(k.getAttribute("filter"));else if(G){G=la(G);lb().appendChild(G)}else G=R(E.filter);G.id=k.id+"_"+(G.firstChild.tagName==="feGaussianBlur"?"blur":"filter");gb("filter","url(#"+G.id+")",[k]);if(v){gb("stdDeviation",v,[G.firstChild]);c.setBlurOffsets(G,v)}}v=V(k);if(~k.tagName.indexOf("Gradient"))v=null;if(v)if(k.tagName!=="defs")if(H.numberOfItems){if(I&&H.numberOfItems==1){var D=H.getItem(0).matrix,P=d.createSVGMatrix();if(C=pa(k))P=v.getItem(0).matrix;
var U=svgedit.utilities.getBBox(k),S=fa(v).matrix,X=N(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,X.x,X.y);D=ia(D,P,S.matrix.inverse());C&&v.removeItem(0);if(U)v.numberOfItems?v.insertItemBefore(S,0):v.appendItem(S);if(D.e||D.f){C=d.createSVGTransform();C.setTranslate(D.e,D.f);v.numberOfItems?v.insertItemBefore(C,0):v.appendItem(C)}}else{C=k.getAttribute("transform");D={};D.transform=C?C:"";C=d.createSVGTransform();D=fa(v).matrix;P=D.inverse();D=ia(P,A,D);C.setMatrix(D);
var U=svgedit.utilities.getBBox(k),S=fa(v).matrix,Y=N(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,Y.x,Y.y);D=ia(D,P,S.matrix.inverse());C&&v.removeItem(0);if(U)v.numberOfItems?v.insertItemBefore(S,0):v.appendItem(S);if(D.e||D.f){C=d.createSVGTransform();C.setTranslate(D.e,D.f);v.numberOfItems?v.insertItemBefore(C,0):v.appendItem(C)}}else{C=k.getAttribute("transform");D={};D.transform=C?C:"";C=d.createSVGTransform();D=fa(v).matrix;P=D.inverse();D=ia(P,A,D);C.setMatrix(D);
v.appendItem(C)}(k=Ua(k))&&u.addSubCommand(k)}}}if(w){D={};D.transform=w;e.setAttribute("transform","");e.removeAttribute("transform");u.addSubCommand(new Na(e,D))}if(h&&!u.isEmpty())return u};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Db(e);else if(e.tagName==="use"){var h=ra(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Db(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new Aa("Ungroup Elements");var m=
Mb(e,true);m&&h.addSubCommand(m);m=e.parentNode;for(var z=e.nextSibling,w=Array(e.childNodes.length),H=0;e.firstChild;){var A=e.firstChild,u=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ka(A,A.nextSibling,F));F.removeChild(A)}else{w[H++]=A=m.insertBefore(A,z);h.addSubCommand(new Ia(A,u,F))}}Qa();z=e.nextSibling;e=m.removeChild(e);h.addSubCommand(new Ka(e,z,m));h.isEmpty()||ya(h);vb(w)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
m=e.nextSibling;e=e.parentNode.appendChild(e);if(m!=e.nextSibling){ya(new Ia(e,m,h,"top"));M("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,m=e.nextSibling,z=e.parentNode.firstChild;if(z.tagName=="title")z=z.nextSibling;if(z.tagName=="defs")z=z.nextSibling;e=e.parentNode.insertBefore(e,z);if(m!=e.nextSibling){ya(new Ia(e,m,h,"bottom"));M("changed",[e])}}};this.moveUpDownSelected=function(e){var h=J[0];if(h){mb=[];var m,z,w=$(tb(getStrokedBBox([h]))).toArray();
@ -380,7 +380,7 @@ QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo his
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};var s={},c={};b.curConfig=curConfig;b.tool_scale=1;b.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
b.setCustomHandlers=function(d){b.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){b.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);c=d})};b.randomizeIds=function(){g.randomizeIds(arguments)};b.init=function(){function d(k,v){var C=k.id,D=C.split("_"),P=D[0];D=D[1];v&&g.setStrokeAttr("stroke-"+P,D);qb();yb("#cur_"+P,C,20);a(k).addClass("current").siblings().removeClass("current")}function l(k,
v){var C=document.getElementById("ruler_x_cursor"),D=document.getElementById("ruler_y_cursor"),P=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Sb){Sb.stopPropagation();C.style.left=Sb.pageX-66+P.scrollLeft+"px";D.style.top=Sb.pageY-48+P.scrollTop+"px"});v||(v=g.getZoom());k||(k=a("#svgcanvas"));for(var U=g.getContentElem(),S=svgedit.units.getTypeMap()[curConfig.baseUnit],
X=0;X<2;X++){var Z=X===0,ga=Z?"x":"y",qa=Z?"width":"height",Oa=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[qa]()*2;Ba.parentNode.style[qa]=ha+"px";var Ta=0,Ra,ua=Ba.getContext("2d");ua.fillStyle="rgb(200,0,0)";ua.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Ra=Array(Ma);Ra[0]=ua;for(var xa=1;xa<Ma;xa++){Ba[qa]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Y=0;Y<2;Y++){var Z=Y===0,ga=Z?"x":"y",qa=Z?"width":"height",Oa=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[qa]()*2;Ba.parentNode.style[qa]=ha+"px";var Ta=0,Ra,ua=Ba.getContext("2d");ua.fillStyle="rgb(200,0,0)";ua.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Ra=Array(Ma);Ra[0]=ua;for(var xa=1;xa<Ma;xa++){Ba[qa]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Ra[xa]=ab.getContext("2d")}ab[qa]=ga%3E4;ga=3E4}Ba[qa]=ga;qa=S*v;var Xa=50/qa;Ba=1;for(xa=0;xa<I.length;xa++){Ba=Ma=I[xa];if(Xa<=Ma)break}Xa=Ba*qa;ua.font="normal 9px 'Lucida Grande', sans-serif";ua.fillStyle="#777";for(var cb=Oa/qa%Ba*qa,Hb=cb-Xa;cb<ha;cb+=Xa){Hb+=Xa;xa=Math.round(cb)+0.5;if(Z){ua.moveTo(xa,15);ua.lineTo(xa,0)}else{ua.moveTo(15,xa);ua.lineTo(0,xa)}Ma=(Hb-Oa)/qa;if(Ba>=1)xa=Math.round(Ma);else{xa=(Ba+"").split(".")[1].length;xa=Ma.toFixed(xa)-0}if(xa!==0&&xa!==1E3&&xa%1E3===0)xa=
xa/1E3+"K";if(Z){ua.fillText(xa,cb+2,8);ua.fillStyle="#777"}else{Ma=(xa+"").split("");for(xa=0;xa<Ma.length;xa++){ua.fillText(Ma[xa],1,cb+9+xa*9);ua.fillStyle="#777"}}Ma=Xa/10;for(xa=1;xa<10;xa++){var zb=Math.round(cb+Ma*xa)+0.5;if(Ra&&zb>ga){Ta++;ua.stroke();if(Ta>=Ra.length){xa=10;cb=ha;continue}ua=Ra[Ta];cb-=3E4;zb=Math.round(cb+Ma*xa)+0.5}var Gb=xa%2?12:10;if(Z){ua.moveTo(zb,15);ua.lineTo(zb,Gb)}else{ua.moveTo(15,zb);ua.lineTo(Gb,zb)}}}ua.strokeStyle="#666";ua.stroke()}}(function(){var k=window.opener;
if(k)try{var v=k.document.createEvent("Event");v.initEvent("svgEditorReady",true,true);k.document.documentElement.dispatchEvent(v)}catch(C){}})();(function(){a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);a("body").toggleClass("touch",svgedit.browser.isTouch());var k=a.deparam.querystring(true);if(!a.isEmptyObject(k)){if(k.dimensions)k.dimensions=k.dimensions.split(",");if(k.extensions)k.extensions=k.extensions.split(",");if(k.bkgd_color)k.bkgd_color=
@ -392,113 +392,113 @@ spapelib:"shapelib.png",node_delete:"node_delete.png",align_left:"align-left.png
var k=a("#tools_left");if(k.length!=0){k.offset();k.outerHeight()}a(".tools_flyout").each(function(){var v=a("#"+this.id+"_show"),C=v.attr("data-curopt");if(!v.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");v.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},1)}});a("#rulers").on("dblclick",function(k){a("#base_unit_container").css({top:k.pageY-
10,left:k.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});b.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=
0,o=q?"meta+":"ctrl+",K=g.pathActions,T=g.undoMgr,O=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",Q=a("#workarea"),V=a("#cmenu_canvas"),N=null,ia=1,oa="toolbars",fa="";q||a(".shortcut").each(function(){var k=a(this).text();a(this).text(k.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var k=a("#dialog_box"),v=a("#dialog_buttons"),C=function(D,P,U,S){a("#dialog_content").html("<p>"+P.replace(/\n/g,
"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");v.empty();var X=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(v);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(v).on("click, touchstart",function(){k.hide();U(false)});if(D=="prompt"){var Z=a('<input type="text">').prependTo(v);Z.val(S||"");Z.bind("keydown","return",function(){X.trigger("click touchstart")})}D=="process"&&X.hide();k.show();X.on("click touchstart",function(){k.hide();var ga=
D=="prompt"?Z.val():true;U&&U(ga)}).focus();D=="prompt"&&Z.focus()};a.alert=function(D,P){C("alert",D,P)};a.confirm=function(D,P){C("confirm",D,P)};a.process_cancel=function(D,P){C("process",D,P)};a.prompt=function(D,P,U){C("prompt",D,U,P)}})();var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},Y=null,sa=
false,ka=false,da="",W=function(k,v){var C=g.getResolution();a("#svgcanvas").position();var D=g.setBBoxZoom(v,Q.width()-15,Q.height()-15);if(D){var P=D.zoom;D=D.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var X=C.zoom,Z=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(X+S*ga);F();if(ga<1)requestAnimationFrame(Z);else{a("#zoom").val(P*100);a("option","#zoom_select").removeAttr("selected");a("option[value="+P*100+"]","#zoom_select").attr("selected","selected")}};
"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");v.empty();var Y=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(v);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(v).on("click, touchstart",function(){k.hide();U(false)});if(D=="prompt"){var Z=a('<input type="text">').prependTo(v);Z.val(S||"");Z.bind("keydown","return",function(){Y.trigger("click touchstart")})}D=="process"&&Y.hide();k.show();Y.on("click touchstart",function(){k.hide();var ga=
D=="prompt"?Z.val():true;U&&U(ga)}).focus();D=="prompt"&&Z.focus()};a.alert=function(D,P){C("alert",D,P)};a.confirm=function(D,P){C("confirm",D,P)};a.process_cancel=function(D,P){C("process",D,P)};a.prompt=function(D,P,U){C("prompt",D,U,P)}})();var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},X=null,sa=
false,ka=false,da="",W=function(k,v){var C=g.getResolution();a("#svgcanvas").position();var D=g.setBBoxZoom(v,Q.width()-15,Q.height()-15);if(D){var P=D.zoom;D=D.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var Y=C.zoom,Z=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(Y+S*ga);F();if(ga<1)requestAnimationFrame(Z);else{a("#zoom").val(P*100);a("option","#zoom_select").removeAttr("selected");a("option[value="+P*100+"]","#zoom_select").attr("selected","selected")}};
Z(Date.now());g.getMode()=="zoom"&&D.width&&ba();lb()}}};a("#cur_context_panel").delegate("a","click",function(){var k=a(this);k.attr("data-root")?g.leaveContext():g.setContext(k.text());return false});var aa=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},pa={},ra=function(k){a.each(k,function(v,C){var D=a(v).children(),P=v+"_show",U=a(P),S=false;D.addClass("tool_button").unbind("click mousedown mouseup").each(function(ga){var qa=C[ga];pa[qa.sel]=qa.fn;if(qa.isDefault)S=ga;ga=function(Oa){var Ba=
qa;if(Oa.type==="keydown"){var ha=a(Ba.parent+"_show").hasClass("tool_button_current"),Ta=a(Ba.parent+"_show").attr("data-curopt");a.each(k[qa.parent],function(ua,Ma){if(Ma.sel==Ta)Ba=!Oa.shiftKey||!ha?Ma:k[qa.parent][ua+1]||k[qa.parent][0]})}if(a(this).hasClass("disabled"))return false;$a(P)&&Ba.fn();var Ra=Ba.icon?a.getSvgIcon(Ba.icon,true):a(Ba.sel).children().eq(0).clone();Ra[0].setAttribute("width",U.width());Ra[0].setAttribute("height",U.height());U.children(":not(.flyout_arrow_horiz)").remove();
U.append(Ra).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);qa.key&&a(document).bind("keydown",qa.key[0]+" shift+"+qa.key[0],ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var X,Z=a(P).position();a(v).css({left:Z.left+34,top:Z.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var qa=a(v),Oa=Z.left+34,Ba=qa.width()*-1,ha=qa.data("shown_popop")?200:0;X=setTimeout(function(){U.data("isLibrary")?
qa.css("left",Oa).show():qa.css("left",Ba).show().animate({left:Oa},50);qa.data("shown_popop",true)},ha);ga.preventDefault()}).mouseup(function(){clearTimeout(X);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in pa&&pa[ga]()})});za()},ma=function(k,v){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(v)},na=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show"),v=k.offset();
U.append(Ra).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);qa.key&&a(document).bind("keydown",qa.key[0]+" shift+"+qa.key[0],ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var Y,Z=a(P).position();a(v).css({left:Z.left+34,top:Z.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var qa=a(v),Oa=Z.left+34,Ba=qa.width()*-1,ha=qa.data("shown_popop")?200:0;Y=setTimeout(function(){U.data("isLibrary")?
qa.css("left",Oa).show():qa.css("left",Ba).show().animate({left:Oa},50);qa.data("shown_popop",true)},ha);ga.preventDefault()}).mouseup(function(){clearTimeout(Y);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in pa&&pa[ga]()})});za()},ma=function(k,v){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(v)},na=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show"),v=k.offset();
k=k.outerWidth();a(this).css({left:(v.left+k)*ia,top:v.top})})},za=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show");if(!k.data("isLibrary")){var v=[];a(this).children().each(function(){v.push(this.title)});k[0].title=v.join(" / ")}})},Fa,Ia=function(k,v,C){var D=null;if(k.indexOf("url(#")===0){k=(k=g.getRefElem(k))?k.cloneNode(true):a("#"+C+"_color defs *")[0];D={alpha:v};D[k.tagName]=k}else D=k.indexOf("#")===0?{alpha:v,solidColor:k.substr(1)}:{alpha:v,solidColor:"none"};
return new a.jGraduate.Paint(D)},Ca=g.getResolution();if(curConfig.baseUnit!=="px"){Ca.w=svgedit.units.convertUnit(Ca.w)+curConfig.baseUnit;Ca.h=svgedit.units.convertUnit(Ca.h)+curConfig.baseUnit}var Ka=function(k){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ca.w+2,height:Ca.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:k||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||
Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=b.setImageURL=function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},Aa=function(){var k=Y;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var v=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item",
"#object_menu").addClass("disabled");if(sa){sa=sa.filter(Boolean);(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected")}if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,X=g.getRotationAngle(k);a("#angle").val(Math.round(X));X=g.getBlur(k);a("#blur").val(X);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var Z,ga;
Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=b.setImageURL=function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},Aa=function(){var k=X;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var v=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item",
"#object_menu").addClass("disabled");if(sa){sa=sa.filter(Boolean);(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected")}if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,Y=g.getRotationAngle(k);a("#angle").val(Math.round(Y));Y=g.getBlur(k);a("#blur").val(Y);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var Z,ga;
if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){Z=C.x;ga=C.y}if(D){Z=svgedit.units.convertUnit(Z);ga=svgedit.units.convertUnit(ga)}a("#"+S+"_x").val(Math.round(Z));a("#"+S+"_y").val(Math.round(ga));if(S==="polyline"){a("#path_x").val(Math.round(Z));a("#path_y").val(Math.round(ga))}["image","text","path","g","use"].indexOf(S)==-1&&a(".action_path_convert_selected").removeClass("disabled");S==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();
a("#stroke_panel").hide();v=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);yb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(v){P=a("#seg_type");if(D){v.x=svgedit.units.convertUnit(v.x);v.y=svgedit.units.convertUnit(v.y)}a("#path_node_x").val(Math.round(v.x));a("#path_node_y").val(Math.round(v.y));v.type?P.val(v.type).removeAttr("disabled"):P.val(4).attr("disabled",
"disabled")}return}D=null;if(qa==="a"){D=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show();D=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!D);D&&a("#link_url").val(D);D={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var qa=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();
if(qa=="path"||qa=="polyline")a("#path_panel").show();if(D[qa]){D=D[qa];a("#"+qa+"_panel").show();qa=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(D,function(Oa,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!=="px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Ta=document.getElementById(qa+"_"+Ba);Ta.value=Math.round(ha)||0;Ta.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Ta)});if(qa=="text"){D=k.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=
3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active",g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);a("#preview_font").text(D.split(",")[0].replace(/'/g,"")).css("font-family",D);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(qa=="image")Na(g.getHref(k));else if(qa==="g"||qa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");
g.getTitle()}}U[(qa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(qa==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}if(sa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}k||U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");
T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(v);V.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,v){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";Y=v.length==1||v[1]==null?v[0]:null;v=v.filter(Boolean);sa=v.length>=2?v:
false;if(Y!=null)if(!C){if(Y!=null)switch(Y.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=Y.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var X=P[U].getAttribute("stroke-width");if(U===0)D=X;else if(D!==X)D=null}a("#stroke_width").val(D===null?"":D);b.paintBox.fill.update(true);b.paintBox.stroke.update(true);break;default:b.paintBox.fill.update(true);b.paintBox.stroke.update(true);a("#stroke_width").val(Y.getAttribute("stroke-width")||1);D=Y.getAttribute("stroke-dasharray")||
"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+D+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);D=Y.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+D).length!=0&&d(a("#linejoin_"+D)[0]);D=Y.getAttribute("stroke-linecap")||"butt";a("#linecap_"+D).length!=0&&d(a("#linecap_"+D)[0])}if(Y!=null){D=(Y.getAttribute("opacity")||1)*100;a("#group_opacity").val(D);a.fn.dragInput.updateCursor(a("#group_opacity")[0])}}D=
v;a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");yb("#tool_select","select_node");sa=false;if(D.length)Y=D[0]}else{if(D[0]){C=g.selectorManager.requestSelector(D[0]);C.reset(D[0]);C.selectorRect.setAttribute("display","inline")}yb("#tool_select","select")}g.runExtensions("selectedChanged",{elems:v,selectedElement:Y,
multiselected:sa})});g.bind("transition",function(k,v){var C=g.getMode(),D=v[0];if(D){sa=v.length>=2&&v[1]!=null?v:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(D);a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",{elems:v})}});g.bind("changed",function(k,v){var C=g.getMode();C==="select"&&ba();for(var D=0;D<v.length;++D){var P=v[D];if(P&&P.tagName==="svg")F();else if(P&&Y&&Y.parentNode==null)Y=P}b.show_save_warning=
true;Aa();if(Y&&C==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:v})});g.bind("saved",function(k,v){b.show_save_warning=false;v='<?xml version="1.0"?>\n'+v;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var D=k.open("data:image/svg+xml;base64,"+O.encode64(v)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==
-1)if(v.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");P!=="part"&&D.alert(U)}}});g.bind("exported",function(k,v){var C=v.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=g.contentW;D.height=g.contentH;canvg(D,v.svg,{renderCallback:function(){var P=D.toDataURL("image/png");N.location.href=
P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+C.join("\n \u2022 ");a.pref("export_notice_done","all");N.alert(P)}}})});g.bind("zoomed",W);g.bind("contextset",function(k,v){var C="";if(v){var D="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(v).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;
C+=this!==v?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=D}else da=null;a("#cur_context_panel").toggle(!!v).html(C)});g.bind("extension_added",function(k,v){function C(){if(Fa){clearTimeout(Fa);Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},50))}var D=false,P=false,U=true,S=function(){if(v.callback&&!D&&U){D=true;v.callback()}},X=[];v.context_tools&&a.each(v.context_tools,function(Ba,ha){var Ta=ha.container_id?' id="'+ha.container_id+'"':"",Ra=a("#"+ha.panel);Ra.length||(Ra=a("<div>",
{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ua='<div class="tool_button">'+ha.id+"</div>",Ma=a(ua).appendTo(Ra);ha.events&&a.each(ha.events,function(Xa,cb){a(Ma).bind(Xa,cb)});break;case "select":ua="<label"+Ta+'><select id="'+ha.id+'">';a.each(ha.options,function(Xa,cb){ua+='<option value="'+Xa+'"'+(Xa==ha.defval?" selected":"")+">"+cb+"</option>"});ua+="</select></label>";var xa=a(ua).appendTo(Ra).find("select");a.each(ha.events,function(Xa,cb){a(xa).bind(Xa,
cb)});break;case "button-select":ua='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Ta=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");ha.colnum&&Ta.addClass("optcols"+ha.colnum);a(ua).appendTo(Ra).children();X.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ua="<label"+Ta+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+
ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ua).appendTo(Ra).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Xa,cb){ab.bind(Xa,cb)})}});if(v.buttons){var Z={},ga={},qa=v.svgicons,Oa={};a.each(v.buttons,function(Ba,ha){for(var Ta,Ra=ha.id,ua=Ba;a("#"+Ra).length;)Ra=ha.id+"_"+ ++ua;if(qa){Z[Ra]=ha.icon;ua=ha.svgicon?ha.svgicon:ha.id;if(ha.type=="app_menu")ga["#"+Ra+" > div"]=ua;else ga["#"+
Ra]=ua}else Ta=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||
ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Ra).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):a(xa).after(ab);if(ha.type=="mode_flyout"){ua=a(ab);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){var Xa=ua[0].id.replace("tool_","tools_"),cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua);Ma.data("isLibrary",
true);cb.data("isLibrary",true)}ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+ha.list).append(ab.children().clone());ua=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ua}}else if(ha.includeWith){xa=ha.includeWith;ua=a(xa.button);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){Xa=
ua[0].id.replace("tool_","tools_");cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua)}var Hb=u.getButtonData(xa.button);if(xa.isDefault)ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,key:ha.key,isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Xa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Hb)Ma.children().eq(Xa).before(ab);else{Ma.append(ab);Ra.reverse()}}qa||
ab.append(Ta);ha.list||a.each(ha.events,function(zb,Gb){if(zb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(zb,Gb):ab.bind(zb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",ha.title+" ["+ha.key+"]")}}else ab.bind(zb,Gb);else ab.bind(zb,Gb)});ra(Oa)});a.each(X,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(qa)U=false;a.svgIcons(qa,{w:27,h:27,id_match:false,no_img:!B,fallback:Z,placement:ga,callback:function(){s.iconsize&&
s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff",
"#aad4ff"],function(k,v){ya+='<div class="palette_item" style="background-color: '+v+';" data-rgb="'+v+'"></div>'});a("#palette").append(ya);var Ha=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Ha.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var v=k.value/100;if(v<0.0010)k.value=0.1;else{k=g.getZoom();W(window,{width:0,height:0,x:(Q[0].scrollLeft+Q.width()/2)/k,y:(Q[0].scrollTop+Q.height()/
2)/k,zoom:v},true)}},qb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);qb()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});
changeAttribute=function(k){var v=k.getAttribute("data-attr"),C=k.getAttribute("data-multiplier")||1;C=parseFloat(C);C=k.value*C;if(!svgedit.units.isValidUnit(v,C,Y)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=Y.getAttribute(v);return false}g.changeSelectedAttributeNoUndo(v,C)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),
v=k?"stroke":"fill",C=a(this).attr("data-rgb"),D=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});b.paintBox[v].setPaint(D);if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display",
"table-cell");a(this).addClass("expanded");z()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");z()});var $a=function(k,v){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;var C=C||"normal";v||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=
null,v=null,C=Q[0],D=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(D!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-v;k=U.clientX;v=U.clientY;if(U.type==="mouseup"||U.type==="touchend")D=false;return false}}).on("mousedown touchmove",function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){D=true;k=U.clientX;v=U.clientY;return false}});a(window).mouseup(function(){D=false;a("body").removeClass("dragging")});a(document).bind("keydown",
"space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&Q.removeClass("out")})})();var ib=a(".menu"),Wa=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background=
"#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){Wa(k)});a("svg, body").on("mousedown touchstart",function(k){if(k.target.nodeName.toLowerCase()!=="input")if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Wa(k):a("#menu_bar").removeClass("active")});
var Sa=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,v,C,D){if(k.altKey){k.preventDefault();k=g.getZoom()*100;v=Sa.length;for(E=0;E<v;E++){C=Math.min(v,E+1);if(D>0)zoom=Sa[E]<=k?Sa[C]:zoom;if(D<0)zoom=Sa[E]<k?Sa[E]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");
a(this).parent().addClass("open")});b.addDropDown=function(k,v,C){if(a(k).length!=0){var D=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+"-list");C||a("#option_lists").append(P);var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",v);a(window).mouseup(function(){if(!U){D.removeClass("down");P.hide()}U=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");P.hide()}else{D.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-
110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,v,C,D){var P=a(k);v=a(v);var U=false,S=D.dropUp;S&&a(k).addClass("dropup");v.find("li").bind("mouseup",function(){if(D.seticon){yb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");v.hide();v.css({top:0,left:0})}U=false});v.height();a(k).bind("mousedown",function(){var X=
a(k).offset();if(S){X.top-=v.height();X.left+=8}else X.top+=a(k).height();a(v).offset(X);if(P.hasClass("down")){P.removeClass("down");v.hide();v.css({top:0,left:0})}else{P.addClass("down");v.show();U=true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});D.multiclick&&v.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,v=this.options[this.selectedIndex].text;a("#preview_font").html(v).css("font-family",k);
a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,"page")})});(function(){var k,v=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;oa="toolbars";Q.mousedown(v)}).blur(function(){oa="canvas";Q.unbind("mousedown",v);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&
g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Va=function(){$a("#tool_rect")&&g.setMode("rect")},Ea=function(){$a("#tool_ellipse")&&g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ta=function(){if(Y!=
null||sa)g.deleteSelectedElements()},mb=function(){if(Y!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(Y!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.copySelectedElements()}},Ab=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),v=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",v,k)},ob=function(){if(Y!=null){window.event.type===
"keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(Y!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},
Bb=function(){if(Y!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);g.clearSelection()}},la=function(){Y!=null&&K.reorient()},ca=function(){if(Y!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,v){if(Y!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;v*=C}a("input").blur();
g.moveSelectedElements(k,v)}},M=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),v=!k.hasClass("push_button_pressed");v?k.addClass("push_button_pressed").removeClass("tool_button"):
k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(v)},Pa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,v){if(!(Y==null||sa)){k||(v*=-1);var C=a("#angle").val()*1+v;g.setRotationAngle(C);Aa()}},Ua=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(v){if(v){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();Aa();aa();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());
Aa();return false},Qa=function(){g.setItalic(!g.getItalic());Aa();return false},vb=function(){if(!c.pngsave){var k=uiStrings.notification.loadingImage;N=window.open("data:text/html;charset=utf-8,<title>"+k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},xb=function(){g.open()},Ib=function(){},pb=function(k){var v=k.prev();v.css("background","#09f");setTimeout(function(){v.css("background",
"")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else Y&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},
Ob=function(){var k=document.querySelector("#tool_stroke rect"),v=document.querySelector("#tool_fill rect"),C=v.getAttribute("fill"),D=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));if(isNaN(k))k=100;v=parseFloat(v.getAttribute("fill-opacity"));if(isNaN(v))v=100;D=Ia(D,k,"stroke");C=Ia(C,v,"fill");b.paintBox.fill.setPaint(D,true);b.paintBox.stroke.setPaint(C,true)},Db=function(k){var v=g.getResolution();k=k?v.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?
a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");lb()}},Jb=function(){var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},Rb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},
Eb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},lb=function(){if(!H){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(Q.hasClass("wireframe")?
k:"")}},Qb=function(k,v){if(!ka){ka=true;a("#save_output_btns").toggle(!!v);a("#tool_source_back").toggle(!v);var C=fa=g.getSvgString();a("#svg_source_textarea").val(C);a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();aa()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;
g.clearSelection();m();Db();aa()});ba()}},yb=b.setIcon=function(k,v){var C=typeof v==="string"?a.getSvgIcon(v,true):v.clone();C?a(k).find("img").replaceWith(C):console.log("NOTE: Icon image missing: "+v)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,v=document.getElementsByTagName("script")[0],C;for(C in v.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in v.style)return"Webkit";if("KhtmlOpacity"in v.style)return"Khtml";return""}();var Mb=function(k,v){gb.toLowerCase();
var C=["top","left","bottom","right"];k.each(function(){for(var D=a(this),P=D.outerWidth()*(v-1),U=D.outerHeight()*(v-1),S=0;S<4;S++){var X=C[S],Z=D.data("orig_margin-"+X);if(Z==null){Z=parseInt(D.css("margin-"+X));D.data("orig_margin-"+X,Z)}Z=Z*v;if(X==="right")Z+=P;else if(X==="bottom")Z+=U;D.css("margin-"+X,Z)}})},e=b.setIconSize=function(k,v){if(!(k==s.size&&!v)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),
D=1;D=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=ia=D;na();var P=C.parents(":hidden");P.css("visibility","hidden").show();Mb(C,D);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,X){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(X,function(Z,ga){if(typeof ga==="number")var qa=ga*D+"px";else if(ga[k]||ga.all)qa=
ga[k]||ga.all;U+=Z+":"+qa+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+P+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/D+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();
if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var z=a.noop;a(window).resize(function(){F()});(function(){Q.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=Q[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=Q[0].scrollTop})})();
a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var k=g.getHref(Y);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(v){v&&Na(v)})});var w=function(k){var v=k[0].id=="stroke_color"?"stroke":"fill",C=k[0].id=="canvas_color";if(C)v="canvas";var D=b.paintBox[v].paint;k=v=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",
containment:"window"}).css(C).jGraduate({paint:D,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){D=new a.jGraduate.Paint(P);b.paintBox[v].setPaint(D);g.setPaint(v,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,v){var C=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(v=="stroke")D=curConfig.initStroke;if(v=="fill")D=curConfig.initFill;if(v=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D=
{color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+D.color+'" opacity="'+D.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));v==="canvas"?C.setAttribute("width",60.5):
C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=v;this.setPaint=function(P,U){this.paint=P;var S="none",X=P.type,Z=P.alpha/100;switch(X){case "solidColor":S=P[X]=="none"||P[X]=="one"?"none":"#"+P[X];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[X]);S="url(#"+(this.grad.id="gradbox_"+
this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",Z);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,Z,true)}if(this.type=="canvas")(X=document.getElementById("canvas_background"))?X.setAttribute("fill",S):Ka(S)};this.update=function(P){if(Y){var U=this.type;switch(Y.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,X=Y.getElementsByTagName("*"),Z=0,ga=X.length;Z<ga;Z++){var qa=X[Z].getAttribute(U);if(Z===0)S=
qa;else if(S!==qa){S=null;break}}if(S===null){X=null;return}X=S;S=1;break;default:S=parseFloat(Y.getAttribute(U+"-opacity"));if(isNaN(S))S=1;X=U==="fill"?"black":"none";X=Y.getAttribute(U)||X}if(P){g.setColor(U,X,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(X,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=new a.jGraduate.Paint({copy:this.paint});g.setPaint(v,P)}}};b.paintBox.fill=new q("#fill_color","fill");b.paintBox.stroke=new q("#stroke_color",
"stroke");b.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=b.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var H=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(q).remove();
setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))w(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",
function(){if(a("#tool_stroke").hasClass("active"))w(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){w(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");w(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");w(a("#fill_color"))});
a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a(window).bind("load resize",function(){Q.css("line-height",
Q.height()+"px")});var A=function(){var k=a("#canvas_width"),v=a("#canvas_height"),C=k.val(),D=v.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);v.parent().addClass("error");return false}v.parent().removeClass("error");if(!g.setResolution(C,D)){a.alert(uiStrings.notification.noContentToFitTo);
C=g.getResolution();k.val(C.w);v.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],v=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";v.value="fit";A();var C=g.getResolution();k.value=C.w;v.value=C.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var P=D[0]-k.value,U=D[1]-v.value,S=Date.now(),X=function(Z){Z=(Z-S)/1E3;Z=Math.pow(Z-1,3)+1;k.value=(D[0]-P+Z*P).toFixed(0);v.value=(D[1]-U+Z*U).toFixed(0);
A();if(Z>=1){Z=g.getResolution();a("#canvas_width").val(Z.w.toFixed());a("#canvas_height").val(Z.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Z.w+"<span>\u00d7</span></br>"+Z.h+"</div>")}else requestAnimationFrame(X)};X(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;v.value=100}}});a("#zoom").change(function(){wa(this)});a("input,select").attr("autocomplete","off");var u=function(){var k=[{sel:"#tool_select",
fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Va,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Ua,evt:"mouseup",
key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():g.save({images:s.img_save,round_digits:6})},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:xb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ta,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:M,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Pa,evt:"click"},{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},
{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Bb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},
{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:Ab,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:Qa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},
{key:"ctrl+left",fn:function(){nb(0,1)}},{key:"ctrl+right",fn:function(){nb(1,1)}},{key:"ctrl+shift+left",fn:function(){nb(0,5)}},{key:"ctrl+shift+right",fn:function(){nb(1,5)}},{key:"shift+O",fn:db},{key:"shift+P",fn:Ya},{key:[o+"+",true],fn:function(){Db(2)}},{key:[o+"-",true],fn:function(){Db(0.5)}},{key:["up",true],fn:function(){ja(0,-1)}},{key:["down",true],fn:function(){ja(0,1)}},{key:["left",true],fn:function(){ja(-1,0)}},{key:["right",true],fn:function(){ja(1,0)}},{key:"shift+up",fn:function(){ja(0,
-10)}},{key:"shift+down",fn:function(){ja(0,10)}},{key:"shift+left",fn:function(){ja(-10,0)}},{key:"shift+right",fn:function(){ja(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var C=a(".tool_button_current");if(C.length&&C[0].id!=="tool_eyedropper"){C.removeClass("tool_button_current").addClass("tool_button");a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},
{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],v={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(D,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var X=P.fn,
Z=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)Z=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(qa,Oa){a(document).bind("keydown",Oa,function(Ba){X();Z&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";v[S]=P.sel;U.parents("#main_menu").length||U.attr("title",ga)}}});ra(C);a(window).bind("keydown","tab",function(D){if(oa===
"canvas"){D.preventDefault();Ya()}}).bind("keydown","shift+tab",function(D){if(oa==="canvas"){D.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(v,function(C,D){var P=a(D).parents("#main_menu").length;a(D).each(function(){var U=P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(X,Z){var ga=Z.split("+"),qa="";if(ga.length>1){qa=ga[0]+"+";Z=ga[1]}S+=(X?"/":"")+qa+(uiStrings["key_"+Z]||Z)});if(P)this.lastChild.textContent=U+" ["+
S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var D;a.each(k,function(P,U){if(U.sel===C)D=U});return D}}}();u.setAll();b.ready(function(){var k=curConfig.initTool,v=a("#tools_left, #svg_editor .tools_flyout"),C=v.find("#tool_"+k);k=v.find("#"+k);(C.length?C:k.length?k:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});a("#canvas_height").dragInput({min:10,max:null,
step:10,callback:A,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:A,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});
a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1,max:null,step:1,callback:changeAttribute,
cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_width").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});
a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var v=k.value;if(v==0&&Y&&["line","polyline"].indexOf(Y.nodeName)>=
0)v=k.value=1;g.setStrokeWidth(v)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,v){var C=k.value-0,D=C+v,P=D>=C;if(v===0)return C;return C>=24?P?Math.round(C*1.1):Math.round(C/1.1):
C<=1?P?C*2:C/2:D}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);g.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ta();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();break;case "paste_in_place":g.pasteElements("in_place");
break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":ob();break;case "move_up":wb("Up");break;case "move_down":wb("Down");break;case "move_back":eb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();V.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=
function(){if(T.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;b.openPrep(function(v){if(v){g.clear();if(k.files.length==1){v=new FileReader;v.onloadend=function(C){p(C.target.result);F()};v.readAsText(k.files[0])}}})});
a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(v){g.importSvgString(v.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=b.updateCanvas=function(k,v){var C=Q.width(),D=Q.height(),P=C,U=D,S=g.getZoom(),X=a("#svgcanvas"),Z={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);D=
Math.max(U,g.contentH*S*ga);C==P&&D==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=X.height()/2;var qa=X.width()/2;X.width(C).height(D);var Oa=D/2,Ba=C/2,ha=g.updateCanvas(C,D),Ta=Ba/qa;C=C/2-P/2;D=D/2-U/2;if(v){v.x+=ha.x;v.y+=ha.y}else v={x:Ba+(Z.x-qa)*Ta,y:Oa+(Z.y-ga)*Ta};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=D}else{Q[0].scrollLeft=v.x-P/2;Q[0].scrollTop=v.y-U/2}if(curConfig.showRulers){l(X,S);Q.scroll()}},
I=[],E=0.1;E<1E5;E*=10){I.push(1*E);I.push(2*E);I.push(5*E)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var v=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(k.length){for(var C=0;C<
k.length;C++)k[C]=v(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var D in k)C.push(v(D)+":"+v(k[D]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var v=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+v+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+v+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,v){a.pref("lang",k);a("#lang_select").val(k);
if(v){g.runExtensions("langChanged",k);za();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,D){a(D).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(d){n?d():f.push(d)};b.runCallbacks=function(){a.each(f,function(){this()});
n=true};b.loadFromString=function(d){b.ready(function(){p(d)})};b.loadFromURL=function(d,l){l||(l={});var q=l.cache,B=l.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,T){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+T+"",B)}})})};b.loadFromDataURI=function(d){b.ready(function(){var l=d.substring(26);p(svgedit.utilities.decode64(l))})};b.addExtension=function(){var d=arguments;
a(function(){g&&g.addExtension.apply(this,d)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(v);V.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,v){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";X=v.length==1||v[1]==null?v[0]:null;v=v.filter(Boolean);sa=v.length>=2?v:
false;if(g.elementsAreSame(sa))X=sa[0];if(X!=null){if(!C){a("#multiselected_panel").hide();if(X!=null)switch(X.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=X.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var Y=P[U].getAttribute("stroke-width");if(U===0)D=Y;else if(D!==Y)D=null}a("#stroke_width").val(D===null?"":D);b.paintBox.fill.update(true);b.paintBox.stroke.update(true);break;default:b.paintBox.fill.update(true);b.paintBox.stroke.update(true);
a("#stroke_width").val(X.getAttribute("stroke-width")||1);D=X.getAttribute("stroke-dasharray")||"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+D+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);D=X.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+D).length!=0&&d(a("#linejoin_"+D)[0]);D=X.getAttribute("stroke-linecap")||"butt";a("#linecap_"+D).length!=0&&d(a("#linecap_"+D)[0])}if(X!=
null){D=(X.getAttribute("opacity")||1)*100;a("#group_opacity").val(D);a.fn.dragInput.updateCursor(a("#group_opacity")[0])}}sa.length&&a("#tools_top").addClass("multiselected")}else if(sa.length){a(".context_panel").hide();a("#tools_top").removeClass("multiselected");a("#multiselected_panel").show()}else{a(".context_panel").hide();a("#canvas_panel").show();a("#tools_top").removeClass("multiselected")}D=v;a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");
a("#tool_select").addClass("tool_button_current").removeClass("tool_button");yb("#tool_select","select_node");sa=false;if(D.length)X=D[0]}else{if(D[0]){C=g.selectorManager.requestSelector(D[0]);C.reset(D[0]);C.selectorRect.setAttribute("display","inline")}yb("#tool_select","select")}g.runExtensions("selectedChanged",{elems:v,selectedElement:X,multiselected:sa})});g.bind("transition",function(k,v){var C=g.getMode(),D=v[0];if(D){sa=v.length>=2&&v[1]!=null?v:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(D);
a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",{elems:v})}});g.bind("changed",function(k,v){var C=g.getMode();C==="select"&&ba();for(var D=0;D<v.length;++D){var P=v[D];if(P&&P.tagName==="svg")F();else if(P&&X&&X.parentNode==null)X=P}b.show_save_warning=true;Aa();if(X&&C==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:v})});g.bind("saved",function(k,v){b.show_save_warning=
false;v='<?xml version="1.0"?>\n'+v;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var D=k.open("data:image/svg+xml;base64,"+O.encode64(v)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(v.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done",
"all");P!=="part"&&D.alert(U)}}});g.bind("exported",function(k,v){var C=v.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=g.contentW;D.height=g.contentH;canvg(D,v.svg,{renderCallback:function(){var P=D.toDataURL("image/png");N.location.href=P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+
C.join("\n \u2022 ");a.pref("export_notice_done","all");N.alert(P)}}})});g.bind("zoomed",W);g.bind("contextset",function(k,v){var C="";if(v){var D="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(v).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;C+=this!==v?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=D}else da=null;a("#cur_context_panel").toggle(!!v).html(C)});g.bind("extension_added",function(k,v){function C(){if(Fa){clearTimeout(Fa);
Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},50))}var D=false,P=false,U=true,S=function(){if(v.callback&&!D&&U){D=true;v.callback()}},Y=[];v.context_tools&&a.each(v.context_tools,function(Ba,ha){var Ta=ha.container_id?' id="'+ha.container_id+'"':"",Ra=a("#"+ha.panel);Ra.length||(Ra=a("<div>",{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ua='<div class="tool_button">'+ha.id+"</div>",Ma=a(ua).appendTo(Ra);ha.events&&a.each(ha.events,function(Xa,cb){a(Ma).bind(Xa,
cb)});break;case "select":ua="<label"+Ta+'><select id="'+ha.id+'">';a.each(ha.options,function(Xa,cb){ua+='<option value="'+Xa+'"'+(Xa==ha.defval?" selected":"")+">"+cb+"</option>"});ua+="</select></label>";var xa=a(ua).appendTo(Ra).find("select");a.each(ha.events,function(Xa,cb){a(xa).bind(Xa,cb)});break;case "button-select":ua='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Ta=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");
ha.colnum&&Ta.addClass("optcols"+ha.colnum);a(ua).appendTo(Ra).children();Y.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ua="<label"+Ta+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ua).appendTo(Ra).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Xa,
cb){ab.bind(Xa,cb)})}});if(v.buttons){var Z={},ga={},qa=v.svgicons,Oa={};a.each(v.buttons,function(Ba,ha){for(var Ta,Ra=ha.id,ua=Ba;a("#"+Ra).length;)Ra=ha.id+"_"+ ++ua;if(qa){Z[Ra]=ha.icon;ua=ha.svgicon?ha.svgicon:ha.id;if(ha.type=="app_menu")ga["#"+Ra+" > div"]=ua;else ga["#"+Ra]=ua}else Ta=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+
ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Ra).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):
a(xa).after(ab);if(ha.type=="mode_flyout"){ua=a(ab);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){var Xa=ua[0].id.replace("tool_","tools_"),cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua);Ma.data("isLibrary",true);cb.data("isLibrary",true)}ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");
a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+ha.list).append(ab.children().clone());ua=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ua}}else if(ha.includeWith){xa=ha.includeWith;ua=a(xa.button);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){Xa=ua[0].id.replace("tool_","tools_");cb=ua.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Xa,ua)}var Hb=u.getButtonData(xa.button);if(xa.isDefault)ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+
Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,key:ha.key,isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Xa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Hb)Ma.children().eq(Xa).before(ab);else{Ma.append(ab);Ra.reverse()}}qa||ab.append(Ta);ha.list||a.each(ha.events,function(zb,Gb){if(zb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(zb,Gb):ab.bind(zb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",
ha.title+" ["+ha.key+"]")}}else ab.bind(zb,Gb);else ab.bind(zb,Gb)});ra(Oa)});a.each(Y,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(qa)U=false;a.svgIcons(qa,{w:27,h:27,id_match:false,no_img:!B,fallback:Z,placement:ga,callback:function(){s.iconsize&&s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00",
"#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(k,v){ya+='<div class="palette_item" style="background-color: '+v+';" data-rgb="'+v+'"></div>'});a("#palette").append(ya);var Ha=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k=
"rotate("+k+"deg)";Ha.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,"-ms-transform":k,transform:k})};var wa=function(k){var v=k.value/100;if(v<0.0010)k.value=0.1;else{k=g.getZoom();W(window,{width:0,height:0,x:(Q[0].scrollLeft+Q.width()/2)/k,y:(Q[0].scrollTop+Q.height()/2)/k,zoom:v},true)}},qb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);
qb()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k){var v=k.getAttribute("data-attr"),C=k.getAttribute("data-multiplier")||1;C=parseFloat(C);C=k.value*C;if(!svgedit.units.isValidUnit(v,C,X)){a.alert(uiStrings.notification.invalidAttrValGiven);
k.value=X.getAttribute(v);return false}g.changeSelectedAttributeNoUndo(v,C)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),v=k?"stroke":"fill",C=a(this).attr("data-rgb"),D=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});b.paintBox[v].setPaint(D);
if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");z()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");z()});var $a=function(k,v){if(a(k).hasClass("disabled"))return false;
if(a(k).parent().hasClass("tools_flyout"))return true;var C=C||"normal";v||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=null,v=null,C=Q[0],D=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(D!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-v;k=U.clientX;v=U.clientY;
if(U.type==="mouseup"||U.type==="touchend")D=false;return false}}).on("mousedown touchmove",function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){D=true;k=U.clientX;v=U.clientY;return false}});a(window).mouseup(function(){D=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()===
"zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&Q.removeClass("out")})})();var ib=a(".menu"),Wa=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",
function(k){Wa(k)});a("svg, body").on("mousedown touchstart",function(k){if(k.target.nodeName.toLowerCase()!=="input")if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Wa(k):a("#menu_bar").removeClass("active")});var Sa=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,v,C,D){if(k.altKey){k.preventDefault();k=g.getZoom()*100;v=Sa.length;for(E=0;E<v;E++){C=
Math.min(v,E+1);if(D>0)zoom=Sa[E]<=k?Sa[C]:zoom;if(D<0)zoom=Sa[E]<k?Sa[E]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(k,v,C){if(a(k).length!=0){var D=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+"-list");C||a("#option_lists").append(P);
var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",v);a(window).mouseup(function(){if(!U){D.removeClass("down");P.hide()}U=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");P.hide()}else{D.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,v,C,D){var P=a(k);v=a(v);var U=false,S=D.dropUp;S&&a(k).addClass("dropup");v.find("li").bind("mouseup",
function(){if(D.seticon){yb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");v.hide();v.css({top:0,left:0})}U=false});v.height();a(k).bind("mousedown",function(){var Y=a(k).offset();if(S){Y.top-=v.height();Y.left+=8}else Y.top+=a(k).height();a(v).offset(Y);if(P.hasClass("down")){P.removeClass("down");v.hide();v.css({top:0,left:0})}else{P.addClass("down");v.show();U=
true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});D.multiclick&&v.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,v=this.options[this.selectedIndex].text;a("#preview_font").html(v).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,"page")})});
(function(){var k,v=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;oa="toolbars";Q.mousedown(v)}).blur(function(){oa="canvas";Q.unbind("mousedown",v);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Va=function(){$a("#tool_rect")&&g.setMode("rect")},Ea=function(){$a("#tool_ellipse")&&
g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ta=function(){if(X!=null||sa)g.deleteSelectedElements()},mb=function(){if(X!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(X!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));
g.copySelectedElements()}},Ab=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),v=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",v,k)},ob=function(){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(X!=null){window.event.type==="keydown"&&
pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(X!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},Bb=function(){if(X!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);g.clearSelection()}},la=function(){X!=
null&&K.reorient()},ca=function(){if(X!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,v){if(X!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;v*=C}a("input").blur();g.moveSelectedElements(k,v)}},M=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",
false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),v=!k.hasClass("push_button_pressed");v?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(v)},Pa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,v){if(!(X==null||sa)){k||(v*=-1);
var C=a("#angle").val()*1+v;g.setRotationAngle(C);Aa()}},Ua=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(v){if(v){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();Aa();aa();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());Aa();return false},Qa=function(){g.setItalic(!g.getItalic());Aa();return false},vb=function(){if(!c.pngsave){var k=uiStrings.notification.loadingImage;N=window.open("data:text/html;charset=utf-8,<title>"+
k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},xb=function(){g.open()},Ib=function(){},pb=function(k){var v=k.prev();v.css("background","#09f");setTimeout(function(){v.css("background","")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));
T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else X&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},Ob=function(){var k=document.querySelector("#tool_stroke rect"),v=document.querySelector("#tool_fill rect"),C=v.getAttribute("fill"),D=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));
if(isNaN(k))k=100;v=parseFloat(v.getAttribute("fill-opacity"));if(isNaN(v))v=100;D=Ia(D,k,"stroke");C=Ia(C,v,"fill");b.paintBox.fill.setPaint(D,true);b.paintBox.stroke.setPaint(C,true)},Db=function(k){var v=g.getResolution();k=k?v.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=
a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");lb()}},Jb=function(){var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},Rb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},Eb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",
false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},lb=function(){if(!H){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(Q.hasClass("wireframe")?k:"")}},Qb=function(k,v){if(!ka){ka=true;a("#save_output_btns").toggle(!!v);a("#tool_source_back").toggle(!v);var C=fa=g.getSvgString();a("#svg_source_textarea").val(C);
a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();aa()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();m();Db();aa()});ba()}},yb=b.setIcon=function(k,v){var C=typeof v==="string"?a.getSvgIcon(v,true):v.clone();C?a(k).find("img").replaceWith(C):
console.log("NOTE: Icon image missing: "+v)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,v=document.getElementsByTagName("script")[0],C;for(C in v.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in v.style)return"Webkit";if("KhtmlOpacity"in v.style)return"Khtml";return""}();var Mb=function(k,v){gb.toLowerCase();var C=["top","left","bottom","right"];k.each(function(){for(var D=a(this),P=D.outerWidth()*(v-1),U=D.outerHeight()*(v-1),S=0;S<4;S++){var Y=C[S],Z=D.data("orig_margin-"+
Y);if(Z==null){Z=parseInt(D.css("margin-"+Y));D.data("orig_margin-"+Y,Z)}Z=Z*v;if(Y==="right")Z+=P;else if(Y==="bottom")Z+=U;D.css("margin-"+Y,Z)}})},e=b.setIconSize=function(k,v){if(!(k==s.size&&!v)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),D=1;D=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];b.tool_scale=ia=D;na();var P=C.parents(":hidden");
P.css("visibility","hidden").show();Mb(C,D);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,Y){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(Y,function(Z,ga){if(typeof ga==="number")var qa=ga*D+"px";else if(ga[k]||ga.all)qa=ga[k]||ga.all;U+=Z+":"+qa+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
P+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/D+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();
var z=a.noop;a(window).resize(function(){F()});(function(){Q.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=Q[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=Q[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var k=g.getHref(X);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(v){v&&Na(v)})});var w=function(k){var v=k[0].id=="stroke_color"?"stroke":
"fill",C=k[0].id=="canvas_color";if(C)v="canvas";var D=b.paintBox[v].paint;k=v=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(C).jGraduate({paint:D,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){D=new a.jGraduate.Paint(P);b.paintBox[v].setPaint(D);
g.setPaint(v,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,v){var C=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(v=="stroke")D=curConfig.initStroke;if(v=="fill")D=curConfig.initFill;if(v=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D={color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
D.color+'" opacity="'+D.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));v==="canvas"?C.setAttribute("width",60.5):C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=v;this.setPaint=function(P,U){this.paint=P;var S="none",Y=P.type,Z=P.alpha/100;switch(Y){case "solidColor":S=
P[Y]=="none"||P[Y]=="one"?"none":"#"+P[Y];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[Y]);S="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",Z);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,Z,true)}if(this.type=="canvas")(Y=document.getElementById("canvas_background"))?Y.setAttribute("fill",S):Ka(S)};this.update=function(P){if(X){var U=this.type;
switch(X.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,Y=X.getElementsByTagName("*"),Z=0,ga=Y.length;Z<ga;Z++){var qa=Y[Z].getAttribute(U);if(Z===0)S=qa;else if(S!==qa){S=null;break}}if(S===null){Y=null;return}Y=S;S=1;break;default:S=parseFloat(X.getAttribute(U+"-opacity"));if(isNaN(S))S=1;Y=U==="fill"?"black":"none";Y=X.getAttribute(U)||Y}if(P){g.setColor(U,Y,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(Y,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=
new a.jGraduate.Paint({copy:this.paint});g.setPaint(v,P)}}};b.paintBox.fill=new q("#fill_color","fill");b.paintBox.stroke=new q("#stroke_color","stroke");b.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=b.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var H=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(q).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))w(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))w(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){w(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");w(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");w(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){Q.css("line-height",Q.height()+"px")});var A=function(){var k=a("#canvas_width"),v=a("#canvas_height"),C=k.val(),D=v.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);v.parent().addClass("error");return false}v.parent().removeClass("error");
if(!g.setResolution(C,D)){a.alert(uiStrings.notification.noContentToFitTo);C=g.getResolution();k.val(C.w);v.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],v=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";v.value="fit";A();var C=g.getResolution();k.value=C.w;v.value=C.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var P=D[0]-k.value,U=D[1]-v.value,S=Date.now(),Y=function(Z){Z=(Z-S)/1E3;Z=Math.pow(Z-
1,3)+1;k.value=(D[0]-P+Z*P).toFixed(0);v.value=(D[1]-U+Z*U).toFixed(0);A();if(Z>=1){Z=g.getResolution();a("#canvas_width").val(Z.w.toFixed());a("#canvas_height").val(Z.h.toFixed());a("#resolution_label").html("<div class='pull'>"+Z.w+"<span>\u00d7</span></br>"+Z.h+"</div>")}else requestAnimationFrame(Y)};Y(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;v.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var u=function(){var k=[{sel:"#tool_select",fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Va,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},
{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Ua,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():g.save({images:s.img_save,round_digits:6})},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:xb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",
fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ta,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:M,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Pa,evt:"click"},
{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Bb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+
"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:Ab,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+
"B",true]},{sel:"#tool_italic",fn:Qa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},{key:"ctrl+left",fn:function(){nb(0,1)}},{key:"ctrl+right",fn:function(){nb(1,1)}},{key:"ctrl+shift+left",fn:function(){nb(0,5)}},{key:"ctrl+shift+right",fn:function(){nb(1,5)}},{key:"shift+O",fn:db},{key:"shift+P",fn:Ya},{key:[o+"+",true],fn:function(){Db(2)}},{key:[o+"-",true],fn:function(){Db(0.5)}},{key:["up",true],fn:function(){ja(0,-1)}},{key:["down",true],fn:function(){ja(0,1)}},
{key:["left",true],fn:function(){ja(-1,0)}},{key:["right",true],fn:function(){ja(1,0)}},{key:"shift+up",fn:function(){ja(0,-10)}},{key:"shift+down",fn:function(){ja(0,10)}},{key:"shift+left",fn:function(){ja(-10,0)}},{key:"shift+right",fn:function(){ja(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,
0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var C=a(".tool_button_current");if(C.length&&C[0].id!=="tool_eyedropper"){C.removeClass("tool_button_current").addClass("tool_button");
a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],v={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(D,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));
S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var Y=P.fn,Z=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)Z=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(qa,Oa){a(document).bind("keydown",Oa,function(Ba){Y();Z&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";v[S]=P.sel;U.parents("#main_menu").length||
U.attr("title",ga)}}});ra(C);a(window).bind("keydown","tab",function(D){if(oa==="canvas"){D.preventDefault();Ya()}}).bind("keydown","shift+tab",function(D){if(oa==="canvas"){D.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(v,function(C,D){var P=a(D).parents("#main_menu").length;a(D).each(function(){var U=P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(Y,Z){var ga=Z.split("+"),qa="";if(ga.length>1){qa=ga[0]+"+";Z=ga[1]}S+=
(Y?"/":"")+qa+(uiStrings["key_"+Z]||Z)});if(P)this.lastChild.textContent=U+" ["+S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var D;a.each(k,function(P,U){if(U.sel===C)D=U});return D}}}();u.setAll();b.ready(function(){var k=curConfig.initTool,v=a("#tools_left, #svg_editor .tools_flyout"),C=v.find("#tool_"+k);k=v.find("#"+k);(C.length?C:k.length?k:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});
a("#canvas_height").dragInput({min:10,max:null,step:10,callback:A,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:A,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null,
step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1,
max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var v=k.value;if(v==0&&
X&&["line","polyline"].indexOf(X.nodeName)>=0)v=k.value=1;g.setStrokeWidth(v)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,v){var C=k.value-0,D=C+v,P=D>=C;if(v===0)return C;return C>=
24?P?Math.round(C*1.1):Math.round(C/1.1):C<=1?P?C*2:C/2:D}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);g.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ta();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();
break;case "paste_in_place":g.pasteElements("in_place");break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":ob();break;case "move_up":wb("Up");break;case "move_down":wb("Down");break;case "move_back":eb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();
V.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(T.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;b.openPrep(function(v){if(v){g.clear();if(k.files.length==1){v=new FileReader;
v.onloadend=function(C){p(C.target.result);F()};v.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(v){g.importSvgString(v.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=b.updateCanvas=function(k,v){var C=Q.width(),D=Q.height(),P=C,U=D,S=g.getZoom(),Y=a("#svgcanvas"),Z={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+
U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);D=Math.max(U,g.contentH*S*ga);C==P&&D==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=Y.height()/2;var qa=Y.width()/2;Y.width(C).height(D);var Oa=D/2,Ba=C/2,ha=g.updateCanvas(C,D),Ta=Ba/qa;C=C/2-P/2;D=D/2-U/2;if(v){v.x+=ha.x;v.y+=ha.y}else v={x:Ba+(Z.x-qa)*Ta,y:Oa+(Z.y-ga)*Ta};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=D}else{Q[0].scrollLeft=v.x-P/2;
Q[0].scrollTop=v.y-U/2}if(curConfig.showRulers){l(Y,S);Q.scroll()}},I=[],E=0.1;E<1E5;E*=10){I.push(1*E);I.push(2*E);I.push(5*E)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var v=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(k.length){for(var C=0;C<k.length;C++)k[C]=v(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var D in k)C.push(v(D)+":"+v(k[D]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var v=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+v+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+v+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(k,
v){a.pref("lang",k);a("#lang_select").val(k);if(v){g.runExtensions("langChanged",k);za();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,D){a(D).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(d){n?d():f.push(d)};
b.runCallbacks=function(){a.each(f,function(){this()});n=true};b.loadFromString=function(d){b.ready(function(){p(d)})};b.loadFromURL=function(d,l){l||(l={});var q=l.cache,B=l.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,T){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+T+"",B)}})})};b.loadFromDataURI=function(d){b.ready(function(){var l=d.substring(26);p(svgedit.utilities.decode64(l))})};
b.addExtension=function(){var d=arguments;a(function(){g&&g.addExtension.apply(this,d)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var p=this.dragCfg.dragAdjust,g=$(this).parent(),b=$(this),n=this.dragCfg.height,s=this.dragCfg.min,c=this.dragCfg.max,f=this.dragCfg.step,d=c-s>0?(c-s)/f:200,l=d/n*f,q=0,B=this.getAttribute("data-attr"),o=svgEditor.canvas,K=o.getSelectedElems(),T=svgedit.browser.isTouch(),O=true,J=d&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(g):false;b.attr("readonly","readonly");J&&!isNaN(this.dragCfg.start)&&J.css("top",this.dragCfg.start*
-1/l+n);this.adjustValue=function(Q,V){var N;N=isNaN(this.value)?this.dragCfg.reset:$.isFunction(this.dragCfg.stepfunc)?this.dragCfg.stepfunc(this,Q):Number((Number(this.value)+Number(Q)).toFixed(5));if(c!==null)N=Math.min(N,c);if(s!==null)N=Math.max(N,s);J&&this.updateCursor(N);this.value=N;g.attr("data-value",N);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,V)};g.toggleClass("draginput",g.is("label"));this.move=function(Q,V,N){if(T)Q=Q.originalEvent.touches[0];if(q===0)q=V;V=(Q.pageY-
q)*-1;q=Q.pageY;N=V*l*p;this.adjustValue(N.toFixed(f<1?1:0))};this.stop=function(){$("body").removeClass("dragging");g.removeClass("active");O=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");q=0;if(K[0]){var Q=o.undoMgr.finishUndoableChange();Q.isEmpty()||o.undoMgr.addCommandToHistory(Q)}this.adjustValue(0,O)};this.updateCursor=function(){var Q=parseFloat(this.value)*-1/l+n;J.css("top",Q)};this.start=function(Q){if(T)Q=Q.originalEvent.touches[0];
@ -581,44 +581,44 @@ this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui
return g=this._trimAlignValue(g)}g=this.options.values.slice();for(b=0;b<g.length;b+=1)g[b]=this._trimAlignValue(g[b]);return g},_trimAlignValue:function(p){if(p<=this._valueMin())return this._valueMin();if(p>=this._valueMax())return this._valueMax();var g=this.options.step>0?this.options.step:1,b=(p-this._valueMin())%g;p=p-b;Math.abs(b)*2>=g&&(p+=b>0?g:-g);return parseFloat(p.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var p=
this.options.range,g=this.options,b=this,n=this._animateOff?false:g.animate,s,c={},f,d,l,q;this.options.values&&this.options.values.length?this.handles.each(function(B){s=(b.values(B)-b._valueMin())/(b._valueMax()-b._valueMin())*100;c[b.orientation==="horizontal"?"left":"bottom"]=s+"%";a(this).stop(1,1)[n?"animate":"css"](c,g.animate);b.options.range===true&&(b.orientation==="horizontal"?(B===0&&b.range.stop(1,1)[n?"animate":"css"]({left:s+"%"},g.animate),B===1&&b.range[n?"animate":"css"]({width:s-
f+"%"},{queue:false,duration:g.animate})):(B===0&&b.range.stop(1,1)[n?"animate":"css"]({bottom:s+"%"},g.animate),B===1&&b.range[n?"animate":"css"]({height:s-f+"%"},{queue:false,duration:g.animate})));f=s}):(d=this.value(),l=this._valueMin(),q=this._valueMax(),s=q!==l?(d-l)/(q-l)*100:0,c[b.orientation==="horizontal"?"left":"bottom"]=s+"%",this.handle.stop(1,1)[n?"animate":"css"](c,g.animate),p==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[n?"animate":"css"]({width:s+"%"},g.animate),
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,f){if(f===undefined)f=0;return Math.round(c*Math.pow(10,f))/Math.pow(10,f)};var p=function(c,f){var d=this,l=c.find("img:first"),q=0,B=100,o=100,K=0,T=100,O=100,J=0,Q=0,V,N,ia=[],oa=function(W){for(var aa=0;aa<ia.length;aa++)ia[aa].call(d,d,W)},fa=function(W){var aa=c.offset();V={l:aa.left|0,t:aa.top|0};clearTimeout(N);N=setTimeout(function(){sa.call(d,W)},0);a(document).bind("mousemove",ba).bind("mouseup",Y);W.preventDefault()},ba=function(W){clearTimeout(N);
N=setTimeout(function(){sa.call(d,W)},0);W.stopPropagation();W.preventDefault();return false},Y=function(W){a(document).unbind("mouseup",Y).unbind("mousemove",ba);W.stopPropagation();W.preventDefault();return false},sa=function(W){var aa=W.pageX-V.l;W=W.pageY-V.t;var pa=c.w,ra=c.h;if(aa<0)aa=0;else if(aa>pa)aa=pa;if(W<0)W=0;else if(W>ra)W=ra;ka.call(d,"xy",{x:aa/pa*o+q,y:W/ra*O+K})},ka=function(W,aa,pa){if(aa===undefined){if(W===undefined||W==null)W="xy";switch(W.toLowerCase()){case "x":return J;
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,f){if(f===undefined)f=0;return Math.round(c*Math.pow(10,f))/Math.pow(10,f)};var p=function(c,f){var d=this,l=c.find("img:first"),q=0,B=100,o=100,K=0,T=100,O=100,J=0,Q=0,V,N,ia=[],oa=function(W){for(var aa=0;aa<ia.length;aa++)ia[aa].call(d,d,W)},fa=function(W){var aa=c.offset();V={l:aa.left|0,t:aa.top|0};clearTimeout(N);N=setTimeout(function(){sa.call(d,W)},0);a(document).bind("mousemove",ba).bind("mouseup",X);W.preventDefault()},ba=function(W){clearTimeout(N);
N=setTimeout(function(){sa.call(d,W)},0);W.stopPropagation();W.preventDefault();return false},X=function(W){a(document).unbind("mouseup",X).unbind("mousemove",ba);W.stopPropagation();W.preventDefault();return false},sa=function(W){var aa=W.pageX-V.l;W=W.pageY-V.t;var pa=c.w,ra=c.h;if(aa<0)aa=0;else if(aa>pa)aa=pa;if(W<0)W=0;else if(W>ra)W=ra;ka.call(d,"xy",{x:aa/pa*o+q,y:W/ra*O+K})},ka=function(W,aa,pa){if(aa===undefined){if(W===undefined||W==null)W="xy";switch(W.toLowerCase()){case "x":return J;
case "y":return Q;default:return{x:J,y:Q}}}if(!(pa!=null&&pa==d)){var ra=false,ma,na;if(W==null)W="xy";switch(W.toLowerCase()){case "x":ma=aa&&(aa.x&&aa.x|0||aa|0)||0;break;case "y":na=aa&&(aa.y&&aa.y|0||aa|0)||0;break;default:ma=aa&&aa.x&&aa.x|0||0;na=aa&&aa.y&&aa.y|0||0}if(ma!=null){if(ma<q)ma=q;else if(ma>B)ma=B;if(J!=ma){J=ma;ra=true}}if(na!=null){if(na<K)na=K;else if(na>T)na=T;if(Q!=na){Q=na;ra=true}}ra&&oa.call(d,pa||d)}},da=function(W){a.isFunction(W)&&ia.push(W)};a.extend(true,d,{val:ka,range:function(W,
aa){if(aa===undefined){if(W===undefined||W==null)W="all";switch(W.toLowerCase()){case "minx":return q;case "maxx":return B;case "rangex":return{minX:q,maxX:B,rangeX:o};case "miny":return K;case "maxy":return T;case "rangey":return{minY:K,maxY:T,rangeY:O};default:return{minX:q,maxX:B,rangeX:o,minY:K,maxY:T,rangeY:O}}}var pa,ra,ma,na;if(W==null)W="all";switch(W.toLowerCase()){case "minx":pa=aa&&(aa.minX&&aa.minX|0||aa|0)||0;break;case "maxx":ra=aa&&(aa.maxX&&aa.maxX|0||aa|0)||0;break;case "rangex":pa=
aa&&aa.minX&&aa.minX|0||0;ra=aa&&aa.maxX&&aa.maxX|0||0;break;case "miny":ma=aa&&(aa.minY&&aa.minY|0||aa|0)||0;break;case "maxy":na=aa&&(aa.maxY&&aa.maxY|0||aa|0)||0;break;case "rangey":ma=aa&&aa.minY&&aa.minY|0||0;na=aa&&aa.maxY&&aa.maxY|0||0;break;default:pa=aa&&aa.minX&&aa.minX|0||0;ra=aa&&aa.maxX&&aa.maxX|0||0;ma=aa&&aa.minY&&aa.minY|0||0;na=aa&&aa.maxY&&aa.maxY|0||0}if(pa!=null&&q!=pa){q=pa;o=B-q}if(ra!=null&&B!=ra){B=ra;o=B-q}if(ma!=null&&K!=ma){K=ma;O=T-K}if(na!=null&&T!=na){T=na;O=T-K}},bind:da,
unbind:function(W){if(a.isFunction(W))for(var aa;(aa=a.inArray(W,ia))!=-1;)ia.splice(aa,1)},destroy:function(){a(document).unbind("mouseup",Y).unbind("mousemove",ba);c.unbind("mousedown",fa);ia=l=c=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();c.w=f.map&&f.map.width||c.width();c.h=f.map&&f.map.height||c.height();c.bind("mousedown",fa);da.call(d,function(){var W=0,aa=0,pa=c.w,ra=c.h,ma=l.w,na=l.h;setTimeout(function(){if(o>0)W=J==
B?pa:J/o*pa|0;if(O>0)aa=Q==T?ra:Q/O*ra|0;if(ma>=pa)W=(pa>>1)-(ma>>1);else W-=ma>>1;if(na>=ra)aa=(ra>>1)-(na>>1);else aa-=na>>1;l.css({left:W+"px",top:aa+"px"})},0)})},g=function(c,f,d,l){var q=this;c=c.find("td.Text input");var B=c.eq(3),o=c.eq(4),K=c.eq(5),T=c.length>7?c.eq(6):null,O=c.eq(0),J=c.eq(1),Q=c.eq(2),V=c.eq(c.length>7?7:6),N=c.length>7?c.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(Y.call(q,
(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(Y.call(q,(B.val()<<0)-1,0,255));f.val("r",B.val(),ka.target);return false}break;case o.get(0):switch(ka.keyCode){case 38:o.val(Y.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ka.target);return false;case 40:o.val(Y.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ka.target);return false}break;case K.get(0):switch(ka.keyCode){case 38:K.val(Y.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ka.target);return false;case 40:K.val(Y.call(q,
(K.val()<<0)-1,0,255));f.val("b",K.val(),ka.target);return false}break;case T&&T.get(0):switch(ka.keyCode){case 38:T.val(Y.call(q,parseFloat(T.val())+1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false;case 40:T.val(Y.call(q,parseFloat(T.val())-1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false}break;case O.get(0):switch(ka.keyCode){case 38:O.val(Y.call(q,(O.val()<<0)+1,0,360));f.val("h",O.val(),ka.target);return false;case 40:O.val(Y.call(q,(O.val()<<
0)-1,0,360));f.val("h",O.val(),ka.target);return false}break;case J.get(0):switch(ka.keyCode){case 38:J.val(Y.call(q,(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(Y.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(Y.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(Y.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},oa=function(ka){if(!(ka.target.value==
""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(Y.call(q,B.val(),0,255));f.val("r",B.val(),ka.target);break;case o.get(0):o.val(Y.call(q,o.val(),0,255));f.val("g",o.val(),ka.target);break;case K.get(0):K.val(Y.call(q,K.val(),0,255));f.val("b",K.val(),ka.target);break;case T&&T.get(0):T.val(Y.call(q,T.val(),0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);break;case O.get(0):O.val(Y.call(q,O.val(),0,360));f.val("h",
O.val(),ka.target);break;case J.get(0):J.val(Y.call(q,J.val(),0,100));f.val("s",J.val(),ka.target);break;case Q.get(0):Q.val(Y.call(q,Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case V.get(0):V.val(V.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(V.val());f.val("hex",V.val()!=""?V.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));V.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;
unbind:function(W){if(a.isFunction(W))for(var aa;(aa=a.inArray(W,ia))!=-1;)ia.splice(aa,1)},destroy:function(){a(document).unbind("mouseup",X).unbind("mousemove",ba);c.unbind("mousedown",fa);ia=l=c=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();c.w=f.map&&f.map.width||c.width();c.h=f.map&&f.map.height||c.height();c.bind("mousedown",fa);da.call(d,function(){var W=0,aa=0,pa=c.w,ra=c.h,ma=l.w,na=l.h;setTimeout(function(){if(o>0)W=J==
B?pa:J/o*pa|0;if(O>0)aa=Q==T?ra:Q/O*ra|0;if(ma>=pa)W=(pa>>1)-(ma>>1);else W-=ma>>1;if(na>=ra)aa=(ra>>1)-(na>>1);else aa-=na>>1;l.css({left:W+"px",top:aa+"px"})},0)})},g=function(c,f,d,l){var q=this;c=c.find("td.Text input");var B=c.eq(3),o=c.eq(4),K=c.eq(5),T=c.length>7?c.eq(6):null,O=c.eq(0),J=c.eq(1),Q=c.eq(2),V=c.eq(c.length>7?7:6),N=c.length>7?c.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(X.call(q,
(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(X.call(q,(B.val()<<0)-1,0,255));f.val("r",B.val(),ka.target);return false}break;case o.get(0):switch(ka.keyCode){case 38:o.val(X.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ka.target);return false;case 40:o.val(X.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ka.target);return false}break;case K.get(0):switch(ka.keyCode){case 38:K.val(X.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ka.target);return false;case 40:K.val(X.call(q,
(K.val()<<0)-1,0,255));f.val("b",K.val(),ka.target);return false}break;case T&&T.get(0):switch(ka.keyCode){case 38:T.val(X.call(q,parseFloat(T.val())+1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false;case 40:T.val(X.call(q,parseFloat(T.val())-1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false}break;case O.get(0):switch(ka.keyCode){case 38:O.val(X.call(q,(O.val()<<0)+1,0,360));f.val("h",O.val(),ka.target);return false;case 40:O.val(X.call(q,(O.val()<<
0)-1,0,360));f.val("h",O.val(),ka.target);return false}break;case J.get(0):switch(ka.keyCode){case 38:J.val(X.call(q,(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(X.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(X.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(X.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},oa=function(ka){if(!(ka.target.value==
""&&ka.target!=V.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(X.call(q,B.val(),0,255));f.val("r",B.val(),ka.target);break;case o.get(0):o.val(X.call(q,o.val(),0,255));f.val("g",o.val(),ka.target);break;case K.get(0):K.val(X.call(q,K.val(),0,255));f.val("b",K.val(),ka.target);break;case T&&T.get(0):T.val(X.call(q,T.val(),0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);break;case O.get(0):O.val(X.call(q,O.val(),0,360));f.val("h",
O.val(),ka.target);break;case J.get(0):J.val(X.call(q,J.val(),0,100));f.val("s",J.val(),ka.target);break;case Q.get(0):Q.val(X.call(q,Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case V.get(0):V.val(V.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(V.val());f.val("hex",V.val()!=""?V.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));V.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;
case N&&N.get(0):N.val(N.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",N.val()!=null?parseInt(N.val(),16):null,ka.target)}}},fa=function(ka){if(f.val()!=null)switch(ka.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case T&&T.get(0):T.val(Math.precision(f.val("a")*100/255,l));break;case O.get(0):O.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case Q.get(0):Q.val(f.val("v"));break;case V.get(0):case d&&
d.get(0):V.val(f.val("hex"));d&&d.val(f.val("hex"));break;case N&&N.get(0):N.val(f.val("ahex").substring(6))}},ba=function(ka){switch(ka.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(ka.ctrlKey)return false}return true},Y=function(ka,da,W){if(ka==""||isNaN(ka))return da;if(ka>W)return W;if(ka<da)return da;return ka},sa=function(ka,da){var W=ka.val("all");if(da!=B.get(0))B.val(W!=null?W.r:"");if(da!=o.get(0))o.val(W!=null?W.g:"");if(da!=
d.get(0):V.val(f.val("hex"));d&&d.val(f.val("hex"));break;case N&&N.get(0):N.val(f.val("ahex").substring(6))}},ba=function(ka){switch(ka.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(ka.ctrlKey)return false}return true},X=function(ka,da,W){if(ka==""||isNaN(ka))return da;if(ka>W)return W;if(ka<da)return da;return ka},sa=function(ka,da){var W=ka.val("all");if(da!=B.get(0))B.val(W!=null?W.r:"");if(da!=o.get(0))o.val(W!=null?W.g:"");if(da!=
K.get(0))K.val(W!=null?W.b:"");if(T&&da!=T.get(0))T.val(W!=null?Math.precision(W.a*100/255,l):"");if(da!=O.get(0))O.val(W!=null?W.h:"");if(da!=J.get(0))J.val(W!=null?W.s:"");if(da!=Q.get(0))Q.val(W!=null?W.v:"");if(da!=V.get(0)&&(d&&da!=d.get(0)||!d))V.val(W!=null?W.hex:"");if(d&&da!=d.get(0)&&da!=V.get(0))d.val(W!=null?W.hex:"");if(N&&da!=N.get(0))N.val(W!=null?W.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(T).add(O).add(J).add(Q).add(V).add(d).add(N).unbind("keyup",
oa).unbind("blur",fa);B.add(o).add(K).add(T).add(O).add(J).add(Q).unbind("keydown",ia);f.unbind(sa);N=V=Q=J=O=T=K=o=B=null}});B.add(o).add(K).add(T).add(O).add(J).add(Q).add(V).add(d).add(N).bind("keyup",oa).bind("blur",fa);B.add(o).add(K).add(T).add(O).add(J).add(Q).bind("keydown",ia);f.bind(sa)};a.jPicker={List:[],Color:function(c){var f=this,d,l,q,B,o,K,T,O=[],J=function(V){for(var N=0;N<O.length;N++)O[N].call(f,f,V)},Q=function(V,N,ia){if(N===undefined){if(V===undefined||V==null||V=="")V="all";
if(d==null)return null;switch(V.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:l,b:q,a:B});case "hex":return Q("ahex").substring(0,6);case "all":return{r:d,g:l,b:q,a:B,h:o,s:K,v:T,hex:Q.call(f,"hex"),ahex:Q.call(f,"ahex")};default:N={};for(var oa=0;oa<V.length;oa++)switch(V.charAt(oa)){case "r":if(V.length==1)N=d;else N.r=d;break;case "g":if(V.length==1)N=l;else N.g=l;break;case "b":if(V.length==1)N=q;else N.b=q;break;case "a":if(V.length==1)N=B;else N.a=B;break;case "h":if(V.length==1)N=o;
else N.h=o;break;case "s":if(V.length==1)N=K;else N.s=K;break;case "v":if(V.length==1)N=T;else N.v=T}return N=={}?Q.call(f,"all"):N}}if(!(ia!=null&&ia==f)){var fa=false;if(V==null)V="";if(N==null){if(d!=null){d=null;fa=true}if(l!=null){l=null;fa=true}if(q!=null){q=null;fa=true}if(B!=null){B=null;fa=true}if(o!=null){o=null;fa=true}if(K!=null){K=null;fa=true}if(T!=null){T=null;fa=true}fa&&J.call(f,ia||f)}else switch(V.toLowerCase()){case "ahex":case "hex":N=s.hexToRgba(N&&(N.ahex||N.hex)||N||"00000000");
Q.call(f,"rgba",{r:N.r,g:N.g,b:N.b,a:V=="ahex"?N.a:B!=null?B:255},ia);break;default:if(N&&(N.ahex!=null||N.hex!=null)){Q.call(f,"ahex",N.ahex||N.hex||"00000000",ia);break}var ba={},Y=false,sa=false;if(N.r!==undefined&&!V.indexOf("r")==-1)V+="r";if(N.g!==undefined&&!V.indexOf("g")==-1)V+="g";if(N.b!==undefined&&!V.indexOf("b")==-1)V+="b";if(N.a!==undefined&&!V.indexOf("a")==-1)V+="a";if(N.h!==undefined&&!V.indexOf("h")==-1)V+="h";if(N.s!==undefined&&!V.indexOf("s")==-1)V+="s";if(N.v!==undefined&&!V.indexOf("v")==
-1)V+="v";for(oa=0;oa<V.length;oa++)switch(V.charAt(oa)){case "r":if(sa)continue;Y=true;ba.r=N&&N.r&&N.r|0||N&&N|0||0;if(ba.r<0)ba.r=0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;fa=true}break;case "g":if(sa)continue;Y=true;ba.g=N&&N.g&&N.g|0||N&&N|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(l!=ba.g){l=ba.g;fa=true}break;case "b":if(sa)continue;Y=true;ba.b=N&&N.b&&N.b|0||N&&N|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;fa=true}break;case "a":ba.a=N&&N.a!=null?N.a|0:
N!=null?N|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;fa=true}break;case "h":if(Y)continue;sa=true;ba.h=N&&N.h&&N.h|0||N&&N|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;fa=true}break;case "s":if(Y)continue;sa=true;ba.s=N&&N.s!=null?N.s|0:N!=null?N|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;fa=true}break;case "v":if(Y)continue;sa=true;ba.v=N&&N.v!=null?N.v|0:N!=null?N|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(T!=ba.v){T=
ba.v;fa=true}}if(fa){if(Y){d=d||0;l=l||0;q=q||0;N=s.rgbToHsv({r:d,g:l,b:q});o=N.h;K=N.s;T=N.v}else if(sa){o=o||0;K=K!=null?K:100;T=T!=null?T:100;N=s.hsvToRgb({h:o,s:K,v:T});d=N.r;l=N.g;q=N.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(V){a.isFunction(V)&&O.push(V)},unbind:function(V){if(a.isFunction(V))for(var N;(N=a.inArray(V,O))!=-1;)O.splice(N,1)},destroy:function(){O=null}});if(c)if(c.ahex!=null)Q("ahex",c);else if(c.hex!=null)Q((c.a!=null?"a":"")+"hex",c.a!=null?
Q.call(f,"rgba",{r:N.r,g:N.g,b:N.b,a:V=="ahex"?N.a:B!=null?B:255},ia);break;default:if(N&&(N.ahex!=null||N.hex!=null)){Q.call(f,"ahex",N.ahex||N.hex||"00000000",ia);break}var ba={},X=false,sa=false;if(N.r!==undefined&&!V.indexOf("r")==-1)V+="r";if(N.g!==undefined&&!V.indexOf("g")==-1)V+="g";if(N.b!==undefined&&!V.indexOf("b")==-1)V+="b";if(N.a!==undefined&&!V.indexOf("a")==-1)V+="a";if(N.h!==undefined&&!V.indexOf("h")==-1)V+="h";if(N.s!==undefined&&!V.indexOf("s")==-1)V+="s";if(N.v!==undefined&&!V.indexOf("v")==
-1)V+="v";for(oa=0;oa<V.length;oa++)switch(V.charAt(oa)){case "r":if(sa)continue;X=true;ba.r=N&&N.r&&N.r|0||N&&N|0||0;if(ba.r<0)ba.r=0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;fa=true}break;case "g":if(sa)continue;X=true;ba.g=N&&N.g&&N.g|0||N&&N|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(l!=ba.g){l=ba.g;fa=true}break;case "b":if(sa)continue;X=true;ba.b=N&&N.b&&N.b|0||N&&N|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;fa=true}break;case "a":ba.a=N&&N.a!=null?N.a|0:
N!=null?N|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;fa=true}break;case "h":if(X)continue;sa=true;ba.h=N&&N.h&&N.h|0||N&&N|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;fa=true}break;case "s":if(X)continue;sa=true;ba.s=N&&N.s!=null?N.s|0:N!=null?N|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;fa=true}break;case "v":if(X)continue;sa=true;ba.v=N&&N.v!=null?N.v|0:N!=null?N|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(T!=ba.v){T=
ba.v;fa=true}}if(fa){if(X){d=d||0;l=l||0;q=q||0;N=s.rgbToHsv({r:d,g:l,b:q});o=N.h;K=N.s;T=N.v}else if(sa){o=o||0;K=K!=null?K:100;T=T!=null?T:100;N=s.hsvToRgb({h:o,s:K,v:T});d=N.r;l=N.g;q=N.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(V){a.isFunction(V)&&O.push(V)},unbind:function(V){if(a.isFunction(V))for(var N;(N=a.inArray(V,O))!=-1;)O.splice(N,1)},destroy:function(){O=null}});if(c)if(c.ahex!=null)Q("ahex",c);else if(c.hex!=null)Q((c.a!=null?"a":"")+"hex",c.a!=null?
{ahex:c.hex+s.intToHex(c.a)}:c);else if(c.r!=null&&c.g!=null&&c.b!=null)Q("rgb"+(c.a!=null?"a":""),c);else if(c.h!=null&&c.s!=null&&c.v!=null)Q("hsv"+(c.a!=null?"a":""),c)},ColorMethods:{hexToRgba:function(c){c=this.validateHex(c);if(c=="")return{r:null,g:null,b:null,a:null};var f="00",d="00",l="00",q="255";if(c.length==6)c+="ff";if(c.length>6){f=c.substring(0,2);d=c.substring(2,4);l=c.substring(4,6);q=c.substring(6,c.length)}else{if(c.length>4){f=c.substring(4,c.length);c=c.substring(0,4)}if(c.length>
2){d=c.substring(2,c.length);c=c.substring(0,2)}if(c.length>0)l=c.substring(0,c.length)}return{r:this.hexToInt(f),g:this.hexToInt(d),b:this.hexToInt(l),a:this.hexToInt(q)}},validateHex:function(c){if(typeof c=="object")return"";c=c.toLowerCase().replace(/[^a-f0-9]/g,"");if(c.length>8)c=c.substring(0,8);return c},rgbaToHex:function(c){return this.intToHex(c.r)+this.intToHex(c.g)+this.intToHex(c.b)+this.intToHex(c.a)},intToHex:function(c){c=(c|0).toString(16);if(c.length==1)c="0"+c;return c.toLowerCase()},
hexToInt:function(c){return parseInt(c,16)},rgbToHsv:function(c){var f=c.r/255,d=c.g/255;c=c.b/255;var l={h:0,s:0,v:0},q=0,B=0;if(f>=d&&f>=c){B=f;q=d>c?c:d}else if(d>=c&&d>=f){B=d;q=f>c?c:f}else{B=c;q=d>f?f:d}l.v=B;l.s=B?(B-q)/B:0;if(l.s){q=B-q;l.h=f==B?(d-c)/q:d==B?2+(c-f)/q:4+(f-d)/q;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(c){var f={r:0,g:0,b:0,a:100},d=c.h,l=c.s;c=c.v;if(l==0)f.r=c==0?f.g=f.b=0:f.g=f.b=c*255/100|0;else{if(d==360)d=
0;d/=60;l/=100;c/=100;var q=d|0,B=d-q;d=c*(1-l);var o=c*(1-l*B);l=c*(1-l*(1-B));switch(q){case 0:f.r=c;f.g=l;f.b=d;break;case 1:f.r=o;f.g=c;f.b=d;break;case 2:f.r=d;f.g=c;f.b=l;break;case 3:f.r=d;f.g=o;f.b=c;break;case 4:f.r=l;f.g=d;f.b=c;break;case 5:f.r=c;f.g=d;f.b=o}f.r=f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var b=a.jPicker.Color,n=a.jPicker.List,s=a.jPicker.ColorMethods;a.fn.jPicker=function(c){var f=arguments;return this.each(function(){var d=this,l=a.extend(true,{},a.fn.jPicker.defaults,
c);if(a(d).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,input:a(d)}});if(a(d).val()==""){l.color.active=new b({hex:null});l.color.current=new b({hex:null})}else if(s.validateHex(a(d).val())){l.color.active=new b({hex:a(d).val(),a:l.color.active.val("a")});l.color.current=new b({hex:a(d).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(d).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,O=null,J=null,Q=null,V=null,N=null,ia=null,oa=null,fa=null,ba=null,Y=null,sa=null,ka=null,da=null,W=null,aa=null,pa=null,ra=null,ma=null,na=null,za=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(M){var R=ja.active,ea=R.val("hex"),Ga,Pa;l.color.mode=M;switch(M){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
O,260);va.call(d,O,100);Wa.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,V,260);va.call(d,V,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);Y.val("y",360-R.val("h"),Y);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
O,-520);Da.call(d,Q,-260);Da.call(d,V,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);Y.val("y",100-R.val("s"),Y);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,O,260);Wa.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);Y.val("y",100-R.val("v"),Y);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);Y.val("y",255-R.val("r"),Y);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);Y.val("y",255-R.val("g"),Y);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);Y.val("y",255-R.val("b"),Y);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,O,-520);Da.call(d,Q,260);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);Y.val("y",255-R.val("a"),Y);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,O,Ga-260);Da.call(d,Q,Pa-780);Da.call(d,V,Pa-520);Da.call(d,N,Pa);Da.call(d,ia,Pa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&Aa.call(d,R)},Aa=function(M,R){if(R==null||R!=Y&&R!=ba)wa.call(d,M,R);setTimeout(function(){qb.call(d,M);$a.call(d,M);ib.call(d,M)},0)},ya=function(M,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=M.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
{h:Ga.x,v:100-Ga.y},R);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},R);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},R);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},R);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},R)}}},Ha=function(M,R){var ea=ja.active;if(!(R!=Y&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-M.val("y")},R);break;case "s":ea.val("s",{s:100-M.val("y")},R);break;case "v":ea.val("v",{v:100-M.val("y")},R);break;case "r":ea.val("r",{r:255-M.val("y")},R);break;case "g":ea.val("g",
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,O=null,J=null,Q=null,V=null,N=null,ia=null,oa=null,fa=null,ba=null,X=null,sa=null,ka=null,da=null,W=null,aa=null,pa=null,ra=null,ma=null,na=null,za=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(M){var R=ja.active,ea=R.val("hex"),Ga,Pa;l.color.mode=M;switch(M){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
O,260);va.call(d,O,100);Wa.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,V,260);va.call(d,V,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);X.val("y",360-R.val("h"),X);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
O,-520);Da.call(d,Q,-260);Da.call(d,V,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);X.val("y",100-R.val("s"),X);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,O,260);Wa.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);X.val("y",100-R.val("v"),X);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});X.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);X.val("y",255-R.val("r"),X);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});X.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);X.val("y",255-R.val("g"),X);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});X.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);X.val("y",255-R.val("b"),X);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,O,-520);Da.call(d,Q,260);Da.call(d,V,260);va.call(d,V,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});X.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);X.val("y",255-R.val("a"),X);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,N,260);va.call(d,N,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,O,Ga-260);Da.call(d,Q,Pa-780);Da.call(d,V,Pa-520);Da.call(d,N,Pa);Da.call(d,ia,Pa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&Aa.call(d,R)},Aa=function(M,R){if(R==null||R!=X&&R!=ba)wa.call(d,M,R);setTimeout(function(){qb.call(d,M);$a.call(d,M);ib.call(d,M)},0)},ya=function(M,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=M.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
{h:Ga.x,v:100-Ga.y},R);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},R);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},R);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},R);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},R)}}},Ha=function(M,R){var ea=ja.active;if(!(R!=X&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-M.val("y")},R);break;case "s":ea.val("s",{s:100-M.val("y")},R);break;case "v":ea.val("v",{v:100-M.val("y")},R);break;case "r":ea.val("r",{r:255-M.val("y")},R);break;case "g":ea.val("g",
{g:255-M.val("y")},R);break;case "b":ea.val("b",{b:255-M.val("y")},R);break;case "a":ea.val("a",255-M.val("y"),R)}},wa=function(M,R){if(R!=ba)switch(l.color.mode){case "h":var ea=M.val("sv");ba.val("xy",{x:ea!=null?ea.s:100,y:100-(ea!=null?ea.v:100)},R);break;case "s":case "a":ea=M.val("hv");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.v:100)},R);break;case "v":ea=M.val("hs");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.s:100)},R);break;case "r":ea=M.val("bg");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&
ea.g||0)},R);break;case "g":ea=M.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},R);break;case "b":ea=M.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},R)}if(R!=Y)switch(l.color.mode){case "h":Y.val("y",360-(M.val("h")||0),R);break;case "s":ea=M.val("s");Y.val("y",100-(ea!=null?ea:100),R);break;case "v":ea=M.val("v");Y.val("y",100-(ea!=null?ea:100),R);break;case "r":Y.val("y",255-(M.val("r")||0),R);break;case "g":Y.val("y",255-(M.val("g")||0),R);break;case "b":Y.val("y",255-(M.val("b")||
0),R);break;case "a":ea=M.val("a");Y.val("y",255-(ea!=null?ea:255),R)}},qb=function(M){try{var R=M.val("all");pa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,pa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(M){switch(l.color.mode){case "h":Wa.call(d,o,(new b({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=M.val("s");va.call(d,O,100-(R!=null?R:100));break;case "v":R=M.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,O,Math.precision((M.val("r")||
ea.g||0)},R);break;case "g":ea=M.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},R);break;case "b":ea=M.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},R)}if(R!=X)switch(l.color.mode){case "h":X.val("y",360-(M.val("h")||0),R);break;case "s":ea=M.val("s");X.val("y",100-(ea!=null?ea:100),R);break;case "v":ea=M.val("v");X.val("y",100-(ea!=null?ea:100),R);break;case "r":X.val("y",255-(M.val("r")||0),R);break;case "g":X.val("y",255-(M.val("g")||0),R);break;case "b":X.val("y",255-(M.val("b")||
0),R);break;case "a":ea=M.val("a");X.val("y",255-(ea!=null?ea:255),R)}},qb=function(M){try{var R=M.val("all");pa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,pa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(M){switch(l.color.mode){case "h":Wa.call(d,o,(new b({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=M.val("s");va.call(d,O,100-(R!=null?R:100));break;case "v":R=M.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,O,Math.precision((M.val("r")||
0)/255*100,4));break;case "g":va.call(d,O,Math.precision((M.val("g")||0)/255*100,4));break;case "b":va.call(d,O,Math.precision((M.val("b")||0)/255*100))}M=M.val("a");va.call(d,J,Math.precision((255-(M||0))*100/255,4))},ib=function(M){switch(l.color.mode){case "h":var R=M.val("a");va.call(d,oa,Math.precision((255-(R||0))*100/255,4));break;case "s":R=M.val("hva");var ea=new b({h:R&&R.h||0,s:100,v:R!=null?R.v:100});Wa.call(d,K,ea.val("hex"));va.call(d,V,100-(R!=null?R.v:100));va.call(d,oa,Math.precision((255-
(R&&R.a||0))*100/255,4));break;case "v":R=M.val("hsa");ea=new b({h:R&&R.h||0,s:R!=null?R.s:100,v:100});Wa.call(d,K,ea.val("hex"));va.call(d,oa,Math.precision((255-(R&&R.a||0))*100/255,4));break;case "r":case "g":case "b":ea=R=0;M=M.val("rgba");if(l.color.mode=="r"){R=M&&M.b||0;ea=M&&M.g||0}else if(l.color.mode=="g"){R=M&&M.b||0;ea=M&&M.r||0}else if(l.color.mode=="b"){R=M&&M.r||0;ea=M&&M.g||0}var Ga=ea>R?R:ea;va.call(d,V,R>ea?Math.precision((R-ea)/(255-ea)*100,4):0);va.call(d,N,ea>R?Math.precision((ea-
R)/(255-R)*100,4):0);va.call(d,ia,Math.precision(Ga/255*100,4));va.call(d,oa,Math.precision((255-(M&&M.a||0))*100/255,4));break;case "a":R=M.val("a");Wa.call(d,K,M.val("hex")||"000000");va.call(d,oa,R!=null?0:100);va.call(d,fa,R!=null?100:0)}},Wa=function(M,R){M.css({backgroundColor:R&&R.length==6&&"#"+R||"transparent"})},Sa=function(M,R){if(q&&(R.indexOf("AlphaBar.png")!=-1||R.indexOf("Bars.png")!=-1||R.indexOf("Maps.png")!=-1)){M.attr("pngSrc",R);M.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
@ -639,14 +639,14 @@ la.clientPath+la.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9
"")+'" title="'+ca.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ca.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(ea!=null?ea.hex:"")+'"/></label>'+(M.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(ea!=null?ea.ahex.substring(6):"")+'" title="'+ca.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";if(M.expandable){B.html(Ga);a(document.body).children("div.jPicker.Container").length==
0?a(document.body).prepend(B):a(document.body).children("div.jPicker.Container:last").after(B);B.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})});B.css({left:M.position.x=="left"?R.offset().left-530-(M.position.y=="center"?25:0)+"px":M.position.x=="center"?R.offset().left-260+"px":M.position.x=="right"?R.offset().left-10+(M.position.y=="center"?25:0)+"px":M.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":R.offset().left+parseInt(M.position.x)+
"px",position:"absolute",top:M.position.y=="top"?R.offset().top-312+"px":M.position.y=="center"?R.offset().top-156+"px":M.position.y=="bottom"?R.offset().top+25+"px":R.offset().top+parseInt(M.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Pa=o.find("span"),Ya=K.find("span");T=Pa.filter(".Map1:first");O=Pa.filter(".Map2:first");J=Pa.filter(".Map3:first");Q=Ya.filter(".Map1:first");V=Ya.filter(".Map2:first");N=Ya.filter(".Map3:first");
ia=Ya.filter(".Map4:first");oa=Ya.filter(".Map5:first");fa=Ya.filter(".Map6:first");ba=new p(o,{map:{width:la.colorMap.width,height:la.colorMap.height},arrow:{image:la.clientPath+la.colorMap.arrow.file,width:la.colorMap.arrow.width,height:la.colorMap.arrow.height}});ba.bind(ya);Y=new p(K,{map:{width:la.colorBar.width,height:la.colorBar.height},arrow:{image:la.clientPath+la.colorBar.arrow.file,width:la.colorBar.arrow.width,height:la.colorBar.arrow.height}});Y.bind(Ha);sa=new g(Ga,ja.active,M.expandable&&
ia=Ya.filter(".Map4:first");oa=Ya.filter(".Map5:first");fa=Ya.filter(".Map6:first");ba=new p(o,{map:{width:la.colorMap.width,height:la.colorMap.height},arrow:{image:la.clientPath+la.colorMap.arrow.file,width:la.colorMap.arrow.width,height:la.colorMap.arrow.height}});ba.bind(ya);X=new p(K,{map:{width:la.colorBar.width,height:la.colorBar.height},arrow:{image:la.clientPath+la.colorBar.arrow.file,width:la.colorBar.arrow.width,height:la.colorBar.arrow.height}});X.bind(Ha);sa=new g(Ga,ja.active,M.expandable&&
M.bindToInput?M.input:null,M.alphaPrecision);Pa=ea!=null?ea.hex:null;var db=Ga.find(".Preview");Ya=Ga.find(".Button");pa=db.find(".Active:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});ra=db.find(".Current:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"}).bind("click",Ea);va.call(d,ra,Math.precision(ja.current.val("a")*100)/255,4);ma=Ya.find(".Ok:first").bind("click touchstart",sb);na=Ya.find(".Cancel:first").bind("click touchstart",kb);za=Ya.find(".Grid:first");setTimeout(function(){Sa.call(d,
T,la.clientPath+"Maps.png");Sa.call(d,O,la.clientPath+"Maps.png");Sa.call(d,J,la.clientPath+"map-opacity.png");Sa.call(d,Q,la.clientPath+"Bars.png");Sa.call(d,V,la.clientPath+"Bars.png");Sa.call(d,N,la.clientPath+"Bars.png");Sa.call(d,ia,la.clientPath+"Bars.png");Sa.call(d,oa,la.clientPath+"bar-opacity.png");Sa.call(d,fa,la.clientPath+"AlphaBar.png");Sa.call(d,db.find("div:last"),la.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Va);if(ja.quickList&&ja.quickList.length>
0){Ya="";for(i=0;i<ja.quickList.length;i++){if((typeof ja.quickList[i]).toString().toLowerCase()=="string")ja.quickList[i]=new b({hex:ja.quickList[i]});var nb=ja.quickList[i].val("a"),Ua=ja.quickList[i].val("ahex");if(!M.alphaSupport&&Ua)Ua=Ua.substring(0,6)+"ff";var rb=ja.quickList[i].val("hex");Ya+='<span class="QuickColor"'+(Ua&&' title="#'+Ua+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+la.clientPath+"NoColor.png)")+(M.alphaSupport&&nb&&nb<255?";opacity:"+
Math.precision(nb/255,4)+";filter:Alpha(opacity="+Math.precision(nb/2.55,4)+")":"")+'">&nbsp;</span>'}Sa.call(d,za,la.clientPath+"bar-opacity.png");za.html(Ya);za.find(".QuickColor").click(Ab)}Na.call(d,l.color.mode);ja.active.bind(Aa);a.isFunction(eb)&&ja.active.bind(eb);ja.current.bind(bb);if(M.expandable){d.icon=R.parents(".Icon:first");Fa=d.icon.find(".Color:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});Ia=d.icon.find(".Alpha:first");Sa.call(d,Ia,la.clientPath+"bar-opacity.png");va.call(d,
Ia,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ca=d.icon.find(".Image:first").css({backgroundImage:"url('"+la.clientPath+la.picker.file+"')"}).bind("click",Za);if(M.bindToInput&&M.updateInputColor)M.input.css({backgroundColor:Pa&&"#"+Pa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Ga.find(".Move:first").bind("mousedown",ta);ja.active.bind(Cb)}else ub.call(d)},la=l.images,ca=l.localization,ja={active:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&
l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);ra.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",Ab);fa=oa=ia=N=V=Q=J=O=T=K=o=null;ba.destroy();ba=null;Y.destroy();Y=null;sa.destroy();
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);ra.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",Ab);fa=oa=ia=N=V=Q=J=O=T=K=o=null;ba.destroy();ba=null;X.destroy();X=null;sa.destroy();
eb=tb=ob=za=na=ma=ra=pa=sa=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){Bb.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new b({ahex:"#ffcc00ff"}),quickList:[new b({h:360,s:33,v:100}),new b({h:360,s:66,v:100}),new b({h:360,s:100,v:100}),
new b({h:360,s:100,v:75}),new b({h:360,s:100,v:50}),new b({h:180,s:0,v:100}),new b({h:30,s:33,v:100}),new b({h:30,s:66,v:100}),new b({h:30,s:100,v:100}),new b({h:30,s:100,v:75}),new b({h:30,s:100,v:50}),new b({h:180,s:0,v:90}),new b({h:60,s:33,v:100}),new b({h:60,s:66,v:100}),new b({h:60,s:100,v:100}),new b({h:60,s:100,v:75}),new b({h:60,s:100,v:50}),new b({h:180,s:0,v:80}),new b({h:90,s:33,v:100}),new b({h:90,s:66,v:100}),new b({h:90,s:100,v:100}),new b({h:90,s:100,v:75}),new b({h:90,s:100,v:50}),
new b({h:180,s:0,v:70}),new b({h:120,s:33,v:100}),new b({h:120,s:66,v:100}),new b({h:120,s:100,v:100}),new b({h:120,s:100,v:75}),new b({h:120,s:100,v:50}),new b({h:180,s:0,v:60}),new b({h:150,s:33,v:100}),new b({h:150,s:66,v:100}),new b({h:150,s:100,v:100}),new b({h:150,s:100,v:75}),new b({h:150,s:100,v:50}),new b({h:180,s:0,v:50}),new b({h:180,s:33,v:100}),new b({h:180,s:66,v:100}),new b({h:180,s:100,v:100}),new b({h:180,s:100,v:75}),new b({h:180,s:100,v:50}),new b({h:180,s:0,v:40}),new b({h:210,
@ -677,7 +677,7 @@ times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(O);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(V){V=$(V.target).closest("div.tool_button");if(V.length){var N=V.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(N).attr("data-curopt","#"+V[0].id).mouseup();s.setMode(T);n=V[0].id.substr((T+"_").length);b=K.data[n];$(".tools_flyout").fadeOut()}});O=$('<div id="shape_cats">');var Q="";$.each(B,function(V,
N){Q+="<div data-cat="+V+">"+N+"</div>"});O.html(Q).children().bind("mouseup",function(){var V=$(this);V.siblings().removeClass("current");V.addClass("current");p(V.attr("data-cat"));return false});O.children().eq(0).addClass("current");$("#tools_shapelib").prepend(O);J.mouseup(function(){s.setMode(b?T:"select")});$("#tool_shapelib").remove();O=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(O/2),"margin-left":3})},mouseDown:function(O){if(s.getMode()===T){var J=f=O.start_x;
O=d=O.start_y;var Q=s.getStyle();c=s.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:b,id:s.getNextId(),opacity:Q.opacity/2,style:"pointer-events:none"}});c.setAttribute("d",b);if(/[a-z]/.test(b)){b=K.data[n]=s.pathActions.convertPath(c);c.setAttribute("d",b);s.pathActions.fixEnd(c)}c.setAttribute("transform","translate("+J+","+O+") scale(0.005) translate("+-J+","+-O+")");s.recalculateDimensions(c);s.getTransformList(c);q=c.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(O){if(s.getMode()===
T){var J=s.getZoom(),Q=O.event,V=O.mouse_x/J,N=O.mouse_y/J;O=s.getTransformList(c);var ia=c.getBBox();J=ia.x;var oa=ia.y,fa=ia.width,ba=ia.height,Y=V-f,sa=N-d,ka={x:Math.min(f,V),y:Math.min(d,N),width:Math.abs(V-f),height:Math.abs(N-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+Y)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(V<f)ia=q.width;if(N<d)da=q.height;V=l.createSVGTransform();N=l.createSVGTransform();ka=l.createSVGTransform();V.setTranslate(-(J+ia),-(oa+da));if(Q.shiftKey){replaced=
T){var J=s.getZoom(),Q=O.event,V=O.mouse_x/J,N=O.mouse_y/J;O=s.getTransformList(c);var ia=c.getBBox();J=ia.x;var oa=ia.y,fa=ia.width,ba=ia.height,X=V-f,sa=N-d,ka={x:Math.min(f,V),y:Math.min(d,N),width:Math.abs(V-f),height:Math.abs(N-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+X)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(V<f)ia=q.width;if(N<d)da=q.height;V=l.createSVGTransform();N=l.createSVGTransform();ka=l.createSVGTransform();V.setTranslate(-(J+ia),-(oa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(ba));fa=Q*(fa<0?-1:1);ba=Q*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){Q=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;fa*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=Q}}totalScale.sx*=fa;totalScale.sy*=ba;N.setScale(fa,ba);ka.setTranslate(J+ia,oa+da);O.appendItem(ka);O.appendItem(N);O.appendItem(V);s.recalculateDimensions(c);q=c.getBBox()}},mouseUp:function(O){if(s.getMode()===T){if(O.mouse_x==f&&O.mouse_y==d)return{keep:false,
element:c,started:false};s.setMode("select");return{keep:true,element:c,started:false}}}}});(function(){for(var a=0,p=["ms","moz","webkit","o"],g=0;g<p.length&&!window.requestAnimationFrame;++g){window.requestAnimationFrame=window[p[g]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[p[g]+"CancelAnimationFrame"]||window[p[g]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var n=(new Date).getTime(),s=Math.max(0,16-(n-a)),c=window.setTimeout(function(){b(n+s)},s);a=n+s;return c};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
function(b){clearTimeout(b)}})();(function(a){function p(o){var K=o.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){c.call(this,o);o=a(this);o.bind(q,g);o.bind(l,b)}else{clearTimeout(B);s.call(this)}}function g(o){if(B!=null){var K=o.originalEvent;o=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var T=a(this).data("taphold.point");o=o-T.x;K=K-T.y;if(Math.sqrt(o*o+K*K)>d){clearTimeout(B);s.call(this)}}}function b(){clearTimeout(B);s.call(this)}