websch/method-draw/svgedit.compiled.js

684 lines
344 KiB
JavaScript
Raw Normal View History

(function(a){function n(f){if(typeof f.data==="string"){var c=f.handler,m=f.data.toLowerCase().split(" ");f.handler=function(o){if(!(this!==o.target&&(/textarea|select/i.test(o.target.nodeName)||o.target.type==="text"))){var b=o.type!=="keypress"&&a.hotkeys.specialKeys[o.which],d=String.fromCharCode(o.which).toLowerCase(),e="",l={};if(o.altKey&&b!=="alt")e+="alt+";if(o.ctrlKey&&b!=="ctrl")e+="ctrl+";if(o.metaKey&&!o.ctrlKey&&b!=="meta")e+="meta+";if(o.shiftKey&&b!=="shift")e+="shift+";if(b)l[e+b]=
true;else{l[e+d]=true;l[e+a.hotkeys.shiftNums[d]]=true;if(e==="shift+")l[a.hotkeys.shiftNums[d]]=true}b=0;for(d=m.length;b<d;b++)if(l[m[b]])return c.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",
2012-07-19 14:54:50 +00:00
106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:n}})})(jQuery);(function(a,n){function f(ca){return typeof ca==="string"}function c(ca){var T=e.call(arguments,1);return function(){return ca.apply(this,T.concat(e.call(arguments)))}}function m(ca,T,V,sa,ta){var aa;if(sa!==d){T=V.match(ca?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);V=T[3]||"";if(ta===2&&f(sa))sa=sa.replace(ca?ga:ea,"");else{aa=q(T[2]);sa=f(sa)?q[ca?ha:Q](sa):sa;sa=ta===2?sa:ta===1?a.extend({},sa,aa):a.extend({},aa,sa);sa=u(sa);if(ca)sa=sa.replace(ra,l)}ca=T[1]+(ca?"#":sa||!T[1]?"?":"")+sa+V}else ca=
T(V!==d?V:n[ua][ia]);return ca}function o(ca,T,V){if(T===d||typeof T==="boolean"){V=T;T=u[ca?ha:Q]()}else T=f(T)?T.replace(ca?ga:ea,""):T;return q(T,V)}function b(ca,T,V,sa){if(!f(V)&&typeof V!=="object"){sa=V;V=T;T=d}return this.each(function(){var ta=a(this),aa=T||fa()[(this.nodeName||"").toLowerCase()]||"",ma=aa&&ta.attr(aa)||"";ta.attr(aa,u[ca](ma,V,sa))})}var d,e=Array.prototype.slice,l=decodeURIComponent,u=a.param,w,q,M,U=a.bbq=a.bbq||{},P,K,fa,W=a.event.special,Q="querystring",ha="fragment",
ua="location",ia="href",ea=/^.*\?|#.*$/g,ga=/^.*\#/,ra,qa={};u[Q]=c(m,0,function(ca){return ca.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});u[ha]=w=c(m,1,function(ca){return ca.replace(/^[^#]*#?(.*)$/,"$1")});w.noEscape=function(ca){ca=ca||"";ca=a.map(ca.split(""),encodeURIComponent);ra=RegExp(ca.join("|"),"g")};w.noEscape(",/");a.deparam=q=function(ca,T){var V={},sa={"true":true,"false":false,"null":null};a.each(ca.replace(/\+/g," ").split("&"),function(ta,aa){var ma=aa.split("="),Ga=l(ma[0]),Ma=
V,Ra=0,Qa=Ga.split("]["),Va=Qa.length-1;if(/\[/.test(Qa[0])&&/\]$/.test(Qa[Va])){Qa[Va]=Qa[Va].replace(/\]$/,"");Qa=Qa.shift().split("[").concat(Qa);Va=Qa.length-1}else Va=0;if(ma.length===2){ma=l(ma[1]);if(T)ma=ma&&!isNaN(ma)?+ma:ma==="undefined"?d:sa[ma]!==d?sa[ma]:ma;if(Va)for(;Ra<=Va;Ra++){Ga=Qa[Ra]===""?Ma.length:Qa[Ra];Ma=Ma[Ga]=Ra<Va?Ma[Ga]||(Qa[Ra+1]&&isNaN(Qa[Ra+1])?{}:[]):ma}else if(a.isArray(V[Ga]))V[Ga].push(ma);else V[Ga]=V[Ga]!==d?[V[Ga],ma]:ma}else if(Ga)V[Ga]=T?d:""});return V};q[Q]=
c(o,0);q[ha]=M=c(o,1);a.elemUrlAttr||(a.elemUrlAttr=function(ca){return a.extend(qa,ca)})({a:ia,base:ia,iframe:"src",img:"src",input:"src",form:"action",link:ia,script:"src"});fa=a.elemUrlAttr;a.fn[Q]=c(b,Q);a.fn[ha]=c(b,ha);U.pushState=P=function(ca,T){if(f(ca)&&/^#/.test(ca)&&T===d)T=2;var V=ca!==d;V=w(n[ua][ia],V?ca:{},V?T:2);n[ua][ia]=V+(/#/.test(V)?"":"#")};U.getState=K=function(ca,T){return ca===d||typeof ca==="boolean"?M(ca):M(T)[ca]};U.removeState=function(ca){var T={};if(ca!==d){T=K();a.each(a.isArray(ca)?
ca:arguments,function(V,sa){delete T[sa]})}P(T,2)};W.hashchange=a.extend(W.hashchange,{add:function(ca){function T(sa){var ta=sa[ha]=w();sa.getState=function(aa,ma){return aa===d||typeof aa==="boolean"?q(ta,aa):q(ta,ma)[aa]};V.apply(this,arguments)}var V;if(a.isFunction(ca)){V=ca;return T}else{V=ca.handler;ca.handler=T}}})})(jQuery,this);
(function(a,n,f){function c(w){w=w||n[b][d];return w.replace(/^[^#]*#?(.*)$/,"$1")}var m,o=a.event.special,b="location",d="href",e=document.documentMode,l=a.browser.msie&&(e===f||e<8),u="onhashchange"in n&&!l;a.hashchangeDelay=100;o.hashchange=a.extend(o.hashchange,{setup:function(){if(u)return false;a(m.start)},teardown:function(){if(u)return false;a(m.stop)}});m=function(){function w(){P=K=function(fa){return fa};if(l){U=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
K=function(){return c(U.document[b][d])};P=function(fa,W){if(fa!==W){var Q=U.document;Q.open().close();Q[b].hash="#"+fa}};P(c())}}var q={},M,U,P,K;q.start=function(){if(!M){var fa=c();P||w();(function W(){var Q=c(),ha=K(fa);if(Q!==fa){P(fa=Q,ha);a(n).trigger("hashchange")}else if(ha!==fa)n[b][d]=n[b][d].replace(/#.*/,"")+"#"+ha;M=setTimeout(W,a.hashchangeDelay)})()}};q.stop=function(){if(!U){M&&clearTimeout(M);M=0}};return q}()})(jQuery,this);(function(a){var n={},f;a.svgIcons=function(c,m){function o(ca,T){if(ca!=="ajax"){if(fa)return;var V=(U=ia[0].contentDocument)&&U.getElementById("svg_eof");if(!V&&!(T&&V)){W++;if(W<50)setTimeout(o,20);else{d();fa=true}return}fa=true}M=a(U.firstChild).children();if(m.no_img)setTimeout(function(){K||b()},500);else{V=ua+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";P=a(new Image).attr({src:V,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
function b(ca,T){if(!K){if(m.no_img)ca=false;if(ca){var V=a(document.createElement("div"));V.hide().appendTo("body")}if(T){var sa=m.fallback_path?m.fallback_path:"";a.each(T,function(Va,Xa){a("#"+Va);var Na=a(new Image).attr({"class":"svg_icon",src:sa+Xa,width:w,height:q,alt:"icon"});qa(Na,Va)})}else for(var ta=M.length,aa=0;aa<ta;aa++){var ma=M[aa],Ga=ma.id;if(Ga==="svg_eof")break;a("#"+Ga);ma=ma.getElementsByTagNameNS(l,"svg")[0];var Ma=document.createElementNS(l,"svg");Ma.setAttributeNS(l,"viewBox",
[0,0,w,q].join(" "));var Ra=ma.getAttribute("width"),Qa=ma.getAttribute("height");ma.removeAttribute("width");ma.removeAttribute("height");ma.getAttribute("viewBox")||ma.setAttribute("viewBox",[0,0,Ra,Qa].join(" "));Ma.setAttribute("xmlns",l);Ma.setAttribute("width",w);Ma.setAttribute("height",q);Ma.setAttribute("xmlns:xlink",u);Ma.setAttribute("class","svg_icon");ha||(ma=ma.cloneNode(true));Ma.appendChild(ma);if(ca){ha||Ma.cloneNode(true);V.empty().append(Ma);ma=ua+e(V.html());ma=a(new Image).attr({"class":"svg_icon",
src:ma})}else ma=f(a(Ma),aa);qa(ma,Ga)}m.placement&&a.each(m.placement,function(Va,Xa){n[Xa]&&a(Va).each(function(Na){var Ha=n[Xa].clone();if(Na>0&&!ca)Ha=f(Ha,Na,true);ra(a(this),Ha,Xa)})});if(!T){ca&&V.remove();ia&&ia.remove();P&&P.remove()}m.resize&&a.resizeSvgIcons(m.resize);K=true;m.callback&&m.callback(n)}}function d(){if(c.indexOf(".svgz")!=-1){var ca=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(ca,m)}else m.fallback&&b(false,m.fallback)}
function e(ca){if(window.btoa)return window.btoa(ca);var T=Array(Math.floor((ca.length+2)/3)*4),V,sa,ta,aa,ma,Ga,Ma=0,Ra=0;do{V=ca.charCodeAt(Ma++);sa=ca.charCodeAt(Ma++);ta=ca.charCodeAt(Ma++);aa=V>>2;V=(V&3)<<4|sa>>4;ma=(sa&15)<<2|ta>>6;Ga=ta&63;if(isNaN(sa))ma=Ga=64;else if(isNaN(ta))Ga=64;T[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(aa);T[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(V);T[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);
T[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Ga)}while(Ma<ca.length);return T.join("")}var l="http://www.w3.org/2000/svg",u="http://www.w3.org/1999/xlink",w=m.w?m.w:24,q=m.h?m.h:24,M,U,P,K=false,fa=false,W=0,Q=navigator.userAgent,ha=!!window.opera;Q.indexOf("Safari/")>-1&&Q.indexOf("Chrome/");var ua="data:image/svg+xml;charset=utf-8;base64,";if(m.svgz){var ia=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{U=ia[0].contentDocument;ia.load(o);
o(0,true)}catch(ea){d()}}else{var ga=new DOMParser;a.ajax({url:c,dataType:"string",success:function(ca){if(ca){U=ga.parseFromString(ca,"text/xml");a(function(){o("ajax")})}else a(d)},error:function(ca){if(window.opera)a(function(){d()});else if(ca.responseText){U=ga.parseFromString(ca.responseText,"text/xml");U.childNodes.length||a(d);a(function(){o("ajax")})}else a(d)}})}var ra=function(ca,T,V,sa){ha&&T.css("visibility","hidden");if(m.replace){sa&&T.attr("id",V);(V=ca.attr("class"))&&T.attr("class",
"svg_icon "+V);ca.replaceWith(T)}else ca.append(T);ha&&setTimeout(function(){T.removeAttr("style")},1)},qa=function(ca,T){if(m.id_match===undefined||m.id_match!==false)ra(holder,ca,T,true);n[T]=ca};f=function(ca,T){var V=ca.find("defs");if(!V.length)return ca;V=ha?V.find("*").filter(function(){return!!this.id}):V.find("[id]");var sa=ca[0].getElementsByTagName("*"),ta=sa.length;V.each(function(aa){var ma=this.id;a(U).find("#"+ma);this.id=aa="x"+ma+T+aa;ma="url(#"+ma+")";var Ga="url(#"+aa+")";for(aa=
0;aa<ta;aa++){var Ma=sa[aa];Ma.getAttribute("fill")===ma&&Ma.setAttribute("fill",Ga);Ma.getAttribute("stroke")===ma&&Ma.setAttribute("stroke",Ga);Ma.getAttribute("filter")===ma&&Ma.setAttribute("filter",Ga)}});return ca}};a.getSvgIcon=function(c,m){var o=n[c];if(m&&o)o=f(o,0,true).clone(true);return o};a.resizeSvgIcons=function(c){var m=!a(".svg_icon:first").length;a.each(c,function(o,b){var d=a.isArray(b),e=d?b[0]:b,l=d?b[1]:b;if(m)o=o.replace(/\.svg_icon/g,"svg");a(o).each(function(){this.setAttribute("width",
e);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=e+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(c,m,o){c=document.createElementNS(n.svg,c);if(f)for(var b in m)c.setAttribute(b,m[b]);else for(b in m){var d=m[b],e=c[b];if(e&&e.constructor==="SVGLength")e.baseVal.value=d;else c.setAttribute(b,d)}o&&o.appendChild(c);return c}var n={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(c){c=c||{};this.alpha=isNaN(c.alpha)?100:c.alpha;if(c.copy){this.type=
c.copy.type;this.alpha=c.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=c.copy.solidColor;break;case "linearGradient":this.linearGradient=c.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=c.copy.radialGradient.cloneNode(true)}}else if(c.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=c.linearGradient.cloneNode(true)}else if(c.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=c.radialGradient.cloneNode(true)}else if(c.solidColor){this.type="solidColor";this.solidColor=c.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var f=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(c){var m=
2012-07-19 14:54:50 +00:00
arguments;return this.each(function(){function o(na,ba,va,O,H){var Z=H||a("stop",{"stop-color":ba,"stop-opacity":va,offset:na},ga);if(H){ba=H.getAttribute("stop-color");va=H.getAttribute("stop-opacity");na=H.getAttribute("offset")}else ga.appendChild(Z);if(va===null)va=1;H=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+na*ha)+", 26)"},Ja);var Oa=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ba,"fill-opacity":va,transform:"translate("+(10+na*ha)+", 26)",stroke:"#000","stroke-width":1.5},Ja);$(Oa).mousedown(function(Za){b(this);$a=tb;fa.mousemove(l).mouseup(d);Da=Jb.offset();Za.preventDefault();return false}).data("stop",Z).data("bg",H).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Za=this,fb=+Z.getAttribute("stop-opacity")||
1,wb=Z.getAttribute("stop-color")||1,xb=(parseFloat(fb)*255).toString(16);xb.length<2;)xb="0"+xb;ba=wb.substr(1)+xb;$("#"+q+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:w.images.clientPath},color:{active:ba,alphaSupport:true}},function(Db){wb=Db.val("hex")?"#"+Db.val("hex"):"none";fb=Db.val("a")!==null?Db.val("a")/256:1;Za.setAttribute("fill",wb);Za.setAttribute("fill-opacity",fb);Z.setAttribute("stop-color",
wb);Z.setAttribute("stop-opacity",fb);$("div.jGraduate_LightBox").hide();$("#"+q+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+q+"_jGraduate_stopPicker").hide()})});$(ga).find("stop").each(function(){var Za=$(this);if(+this.getAttribute("offset")>na){if(!ba){var fb=this.getAttribute("stop-color"),wb=this.getAttribute("stop-opacity");Z.setAttribute("stop-color",fb);Oa.setAttribute("fill",fb);Z.setAttribute("stop-opacity",wb===null?1:wb);Oa.setAttribute("fill-opacity",
wb===null?1:wb)}Za.before(Z);return false}});O&&b(Oa);return Z}function b(na){tb&&tb.setAttribute("stroke","#000");na.setAttribute("stroke","blue");tb=na;tb.parentNode.appendChild(tb)}function d(){fa.unbind("mousemove",l);if(Ka.getAttribute("display")!=="none"){Ka.setAttribute("display","none");var na=$(tb),ba=na.data("stop");na=na.data("bg");$([tb,ba,na]).remove()}$a=null}function e(){var na=Sa?"rotate("+Sa+","+gb+","+Ia+") ":"";yb===1&&bb===1?ga.removeAttribute("gradientTransform"):ga.setAttribute("gradientTransform",
na+"translate("+-gb*(yb-1)+","+-Ia*(bb-1)+") scale("+yb+","+bb+")")}function l(na){var ba=na.pageX-Da.left;na=na.pageY-Da.top;ba=ba<10?10:ba>ha+10?ha+10:ba;var va="translate("+ba+", 26)";if(na<-60||na>130){Ka.setAttribute("display","block");Ka.setAttribute("transform",va)}else Ka.setAttribute("display","none");$a.setAttribute("transform",va);$.data($a,"bg").setAttribute("transform",va);$.data($a,"stop").setAttribute("offset",(ba-10)/ha);var O=0;$(ga).find("stop").each(function(){var H=this.getAttribute("offset"),
Z=$(this);if(H<O){Z.prev().before(Z);zb=$(ga).find("stop")}O=H})}var u=$(this),w=$.extend(true,{},jQuery.fn.jGraduateDefaults,c),q=u.attr("id"),M="#"+u.attr("id")+" ";if(M){var U=function(){switch(u.paint.type){case "radialGradient":u.paint.linearGradient=null;break;case "linearGradient":u.paint.radialGradient=null;break;case "solidColor":u.paint.radialGradient=u.paint.linearGradient=null}$.isFunction(u.okCallback)&&u.okCallback(u.paint);u.hide()},P=function(){$.isFunction(u.cancelCallback)&&u.cancelCallback();
u.hide()};$.extend(true,u,{paint:new $.jGraduate.Paint({copy:w.paint}),okCallback:$.isFunction(m[1])&&m[1]||null,cancelCallback:$.isFunction(m[2])&&m[2]||null});u.position();var K=null,fa=$(window);if(u.paint.type=="none")u.paint=$.jGraduate.Paint({solidColor:"ffffff"});u.addClass("jGraduate_Picker");u.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="'+
q+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var W=$(M+"> .jGraduate_colPick"),Q=$(M+"> .jGraduate_gradPick");Q.html('<div id="'+q+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+w.window.pickerTitle+'</h2><div id="'+q+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+q+'_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="'+
q+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+q+'_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="'+q+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
q+'_jGraduate_y2" size="3" title="Enter ending y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_rg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Center Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+q+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+q+'_jGraduate_cy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Focal Point</label><div class="jGraduate_Form_Section"><label>Match center: <input type="checkbox" checked="checked" id="'+
q+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+q+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+q+'_jGraduate_fy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_StopSection jGraduate_SpreadMethod"><label class="jGraduate_Form_Heading">Spread method</label><div class="jGraduate_Form_Section"><select class="jGraduate_spreadMethod"><option value=pad selected>Pad</option><option value=reflect>Reflect</option><option value=repeat>Repeat</option></select></div></div><div class="jGraduate_Form"><div class="jGraduate_Slider jGraduate_RadiusField jGraduate_rg_field"><label class="prelabel">Radius:</label><div id="'+
q+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+q+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+w.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+q+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+q+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+
q+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+w.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+q+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+q+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+q+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+w.images.clientPath+
'rangearrows2.gif"></div><label><input type="text" id="'+q+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba&nbsp;</label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+q+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+q+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+w.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+q+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
q+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+q+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ha=256,ua=ha-0,ia=ha-0,ea,ga,ra,qa={};$(".jGraduate_SliderBar").width(145);var ca=$("#"+q+"_jGraduate_GradContainer")[0],T=a("svg",{id:q+"_jgraduate_svg",width:ha,height:ha,xmlns:n.svg},ca);ea=ea||u.paint.type;var V=ga=u.paint[ea],sa=u.paint.alpha,ta=ea==="solidColor";switch(ea){case "solidColor":case "linearGradient":if(!ta){ga.id=q+"_lg_jgraduate_grad";
V=ga=T.appendChild(ga)}a("radialGradient",{id:q+"_rg_jgraduate_grad"},T);if(ea==="linearGradient")break;case "radialGradient":if(!ta){ga.id=q+"_rg_jgraduate_grad";V=ga=T.appendChild(ga)}a("linearGradient",{id:q+"_lg_jgraduate_grad"},T)}if(ta){V=ga=$("#"+q+"_lg_jgraduate_grad")[0];K=u.paint[ea];o(0,"#"+K,1);var aa=typeof w.newstop;if(aa==="string")switch(w.newstop){case "same":o(1,"#"+K,1);break;case "inverse":aa="";for(var ma=0;ma<6;ma+=2){K.substr(ma,2);var Ga=(255-parseInt(K.substr(ma,2),16)).toString(16);
if(Ga.length<2)Ga=0+Ga;aa+=Ga}o(1,"#"+aa,1);break;case "white":o(1,"#ffffff",1);break;case "black":o(1,"#000000",1)}else if(aa==="object")o(1,w.newstop.color||"#"+K,"opac"in w.newstop?w.newstop.opac:1)}K=parseFloat(V.getAttribute("x1")||0);aa=parseFloat(V.getAttribute("y1")||0);ma=parseFloat(V.getAttribute("x2")||1);Ga=parseFloat(V.getAttribute("y2")||0);var Ma=parseFloat(V.getAttribute("cx")||0.5),Ra=parseFloat(V.getAttribute("cy")||0.5),Qa=parseFloat(V.getAttribute("fx")||Ma),Va=parseFloat(V.getAttribute("fy")||
Ra);ra=a("rect",{id:q+"_jgraduate_rect",x:0,y:0,width:ua,height:ia,fill:"url(#"+q+"_jgraduate_grad)","fill-opacity":sa/100},T);var Xa=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:aa*ha,left:K*ha}).data("coord","start").appendTo(ca),Na=Xa.clone().text(2).css({top:Ga*ha,left:ma*ha}).attr("title","End stop").data("coord","end").appendTo(ca),Ha=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ra*ha,left:Ma*
ha}).data("coord","center").appendTo(ca),Pa=Ha.clone().text("F").css({top:Va*ha,left:Qa*ha,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ca);Pa[0].id=q+"_jGraduate_focusCoord";$(M+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(na,ba){var va=ga.getAttribute(ba),O=isNaN(ba[1]);va||(va=O?"0.5":ba==="x2"?"1.0":"0.0");qa[ba]=$("#"+q+"_jGraduate_"+ba).val(va).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ba[0]==="f"&&!jb))if(O&&ea==="radialGradient"||!O&&ea==="linearGradient")ga.setAttribute(ba,this.value);var H=O?ba[0]==="c"?Ha:Pa:ba[1]==="1"?Xa:Na,Z=ba.indexOf("x")>=0?"left":"top";H.css(Z,this.value*ha)}).change()});var zb,Ja,Jb=$("#"+q+"_jGraduate_StopSlider"),tb,ab,$a,Ka=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},ab),Da,yb=1,bb=1,Sa=0,gb=Ma,Ia=Ra;ab=a("svg",{width:"100%",height:45},Jb[0]);ca=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ab);a("image",{width:16,height:16},ca).setAttributeNS(n.xlink,"xlink:href",w.images.clientPath+"map-opacity.png");$(ab).click(function(na){Da=Jb.offset();if(na.target.tagName!=="path"){var ba=na.pageX-Da.left-8;ba=ba<10?10:ba>ha+10?ha+10:ba;o(ba/ha,0,0,true);na.stopPropagation()}});$(ab).mouseover(function(){ab.appendChild(Ka)});Ja=a("g",{},ab);a("line",{x1:10,y1:15,x2:ha+10,y2:15,"stroke-width":2,stroke:"#000"},ab);var rb=Q.find(".jGraduate_spreadMethod").change(function(){ga.setAttribute("spreadMethod",
$(this).val())}),sb=null,mb=function(na){var ba=na.pageX-Wa.left,va=na.pageY-Wa.top;ba=ba<0?0:ba>ha?ha:ba;va=va<0?0:va>ha?ha:va;sb.css("left",ba).css("top",va);ba/=ua;va/=ia;var O=sb.data("coord"),H=ga;switch(O){case "start":qa.x1.val(ba);qa.y1.val(va);H.setAttribute("x1",ba);H.setAttribute("y1",va);break;case "end":qa.x2.val(ba);qa.y2.val(va);H.setAttribute("x2",ba);H.setAttribute("y2",va);break;case "center":qa.cx.val(ba);qa.cy.val(va);H.setAttribute("cx",ba);H.setAttribute("cy",va);gb=ba;Ia=va;
e();break;case "focus":qa.fx.val(ba);qa.fy.val(va);H.setAttribute("fx",ba);H.setAttribute("fy",va);e()}na.preventDefault()},hb=function(){sb=null;fa.unbind("mousemove",mb).unbind("mouseup",hb)};zb=ga.getElementsByTagNameNS(n.svg,"stop");if(La<2){for(;La<2;){ga.appendChild(document.createElementNS(n.svg,"stop"));++La}zb=ga.getElementsByTagNameNS(n.svg,"stop")}var La=zb.length;for(ma=0;ma<La;ma++)o(0,0,0,0,zb[ma]);rb.val(ga.getAttribute("spreadMethod")||"pad");var Wa,jb=false;ra.setAttribute("fill-opacity",
sa/100);$("#"+q+" div.grad_coord").mousedown(function(na){na.preventDefault();sb=$(this);sb.offset();Wa=sb.parent().offset();fa.mousemove(mb).mouseup(hb)});$("#"+q+"_jGraduate_Ok").bind("click",function(){u.paint.type=ea;u.paint[ea]=ga.cloneNode(true);u.paint.solidColor=null;U()});$("#"+q+"_jGraduate_Cancel").bind("click",function(){P()});if(ea==="radialGradient")if(jb)Pa.show();else{Pa.hide();qa.fx.val("");qa.fy.val("")}$("#"+q+"_jGraduate_match_ctr")[0].checked=!jb;var Eb,Fb;$("#"+q+"_jGraduate_match_ctr").change(function(){jb=
!this.checked;Pa.toggle(jb);qa.fx.val("");qa.fy.val("");var na=ga;if(jb){var ba=Eb||0.5,va=Fb||0.5;na.setAttribute("fx",ba);na.setAttribute("fy",va);qa.fx.val(ba);qa.fy.val(va)}else{Eb=na.getAttribute("fx");Fb=na.getAttribute("fy");na.removeAttribute("fx");na.removeAttribute("fy")}});zb=ga.getElementsByTagNameNS(n.svg,"stop");La=zb.length;if(La<2){for(;La<2;){ga.appendChild(document.createElementNS(n.svg,"stop"));++La}zb=ga.getElementsByTagNameNS(n.svg,"stop")}var nb;sa=Q=0;if(ea==="radialGradient"){T=
ga.gradientTransform.baseVal;if(T.numberOfItems===2){La=T.getItem(0);T=T.getItem(1);if(La.type===2&&T.type===3){La=T.matrix;if(La.a!==1)Q=Math.round(-(1-La.a)*100);else if(La.d!==1)Q=Math.round((1-La.d)*100)}}else if(T.numberOfItems===3){ca=T.getItem(0);La=T.getItem(1);T=T.getItem(2);if(ca.type===4&&La.type===2&&T.type===3){sa=Math.round(ca.angle);La=T.matrix;if(La.a!==1)Q=Math.round(-(1-La.a)*100);else if(La.d!==1)Q=Math.round((1-La.d)*100)}}}Q={radius:{handle:"#"+q+"_jGraduate_RadiusArrows",input:"#"+
q+"_jGraduate_RadiusInput",val:(ga.getAttribute("r")||0.5)*100},opacity:{handle:"#"+q+"_jGraduate_OpacArrows",input:"#"+q+"_jGraduate_OpacInput",val:u.paint.alpha||100},ellip:{handle:"#"+q+"_jGraduate_EllipArrows",input:"#"+q+"_jGraduate_EllipInput",val:Q},angle:{handle:"#"+q+"_jGraduate_AngleArrows",input:"#"+q+"_jGraduate_AngleInput",val:sa}};$.each(Q,function(na,ba){var va=$(ba.handle);va.mousedown(function(O){var H=va.parent();nb={type:na,elem:va,input:$(ba.input),parent:H,offset:H.offset()};
fa.mousemove(Gb).mouseup(Ob);O.preventDefault()});$(ba.input).val(ba.val).change(function(){var O=+this.value,H=0,Z=ea==="radialGradient";switch(na){case "radius":Z&&ga.setAttribute("r",O/100);H=Math.pow(O/100,0.4)/2*145;break;case "opacity":u.paint.alpha=O;ra.setAttribute("fill-opacity",O/100);H=O*1.45;break;case "ellip":yb=bb=1;if(O===0){H=72.5;break}if(O>99.5)O=99.5;if(O>0)bb=1-O/100;else yb=-(O/100)-1;H=145*((O+100)/2)/100;Z&&e();break;case "angle":Sa=O;H=Sa/180;H+=0.5;H*=145;Z&&e()}if(H>145)H=
145;else if(H<0)H=0;va.css({"margin-left":H-5})}).change()});var Gb=function(na){var ba=na.pageX-nb.offset.left-parseInt(nb.parent.css("border-left-width"));if(ba>145)ba=145;if(ba<=0)ba=0;var va=ba-5;ba/=145;switch(nb.type){case "radius":ba=Math.pow(ba*2,2.5);if(ba>0.98&&ba<1.02)ba=1;if(ba<=0.01)ba=0.01;ga.setAttribute("r",ba);break;case "opacity":u.paint.alpha=parseInt(ba*100);ra.setAttribute("fill-opacity",ba);break;case "ellip":bb=yb=1;if(ba<0.5){ba/=0.5;yb=ba<=0?0.01:ba}else if(ba>0.5){ba/=0.5;
ba=2-ba;bb=ba<=0?0.01:ba}e();ba-=1;if(bb===ba+1)ba=Math.abs(ba);break;case "angle":ba-=0.5;Sa=ba*=180;e();ba/=100}nb.elem.css({"margin-left":va});ba=Math.round(ba*100);nb.input.val(ba);na.preventDefault()},Ob=function(){fa.unbind("mousemove",Gb).unbind("mouseup",Ob);nb=null};for(Q=(u.paint.alpha*255/100).toString(16);Q.length<2;)Q="0"+Q;Q=Q.split(".")[0];K=u.paint.solidColor=="none"?"":u.paint.solidColor+Q;ta||(K=zb[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,
effects:{type:"show",speed:0}});W.jPicker({window:{title:w.window.pickerTitle},images:{clientPath:w.images.clientPath},color:{active:K,alphaSupport:true}},function(na){u.paint.type="solidColor";u.paint.alpha=na.val("ahex")?Math.round(na.val("a")/255*100):100;u.paint.solidColor=na.val("hex")?na.val("hex"):"none";u.paint.radialGradient=null;U()},null,function(){P()});var Kb=$(M+" .jGraduate_tabs li");Kb.click(function(){Kb.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current");
$(M+" > div").hide();var na=$(this).attr("data-type");$(M+" .jGraduate_gradPick").show();if(na==="rg"||na==="lg"){$(".jGraduate_"+na+"_field").show();$(".jGraduate_"+(na==="lg"?"rg":"lg")+"_field").hide();$("#"+q+"_jgraduate_rect")[0].setAttribute("fill","url(#"+q+"_"+na+"_jgraduate_grad)");ea=na==="lg"?"linearGradient":"radialGradient";$("#"+q+"_jGraduate_OpacInput").val(u.paint.alpha).change();var ba=$("#"+q+"_"+na+"_jgraduate_grad")[0];if(ga!==ba){var va=$(ga).find("stop");$(ba).empty().append(va);
ga=ba;ba=rb.val();ga.setAttribute("spreadMethod",ba)}jb=na==="rg"&&ga.getAttribute("fx")!=null&&!(Ma==Qa&&Ra==Va);$("#"+q+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+q+"_jGraduate_match_ctr")[0].checked=false}else{$(M+" .jGraduate_gradPick").hide();$(M+" .jGraduate_colPick").show()}});$(M+" > div").hide();Kb.removeClass("jGraduate_tab_current");var Ub;switch(u.paint.type){case "linearGradient":Ub=$(M+" .jGraduate_tab_lingrad");break;case "radialGradient":Ub=$(M+" .jGraduate_tab_radgrad");break;
default:Ub=$(M+" .jGraduate_tab_color")}u.show();setTimeout(function(){Ub.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();$.fn.SpinButton=function(a){function n(f,c){for(var m=f[c],o=document.body;(f=f.offsetParent)&&f!=o;)if(!$.browser.msie||f.currentStyle.position!="relative")m+=f[c];return m}return this.each(function(){this.repeating=false;this.spinCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&a.step?Number(a.step):1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,upClass:a&&a.upClass?a.upClass:"up",downClass:a&&a.downClass?
a.downClass:"down",reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.spinCfg.smallStep=a&&a.smallStep?a.smallStep:this.spinCfg.step/2;this.adjustValue=function(f){f=isNaN(this.value)?this.spinCfg.reset:$.isFunction(this.spinCfg.stepfunc)?this.spinCfg.stepfunc(this,f):Number((Number(this.value)+Number(f)).toFixed(5));if(this.spinCfg.min!==
null)f=Math.max(f,this.spinCfg.min);if(this.spinCfg.max!==null)f=Math.min(f,this.spinCfg.max);this.value=f;$.isFunction(this.spinCfg.callback)&&this.spinCfg.callback(this)};$(this).addClass(a&&a.spinClass?a.spinClass:"spin-button").mousemove(function(f){var c=f.pageX||f.x,m=f.pageY||f.y;f=f.target||f.srcElement;var o=svgEditor.tool_scale||1,b=$(f).height()/2;c=c>n(f,"offsetLeft")+f.offsetWidth*o-this.spinCfg._btn_width?m<n(f,"offsetTop")+b*o?1:-1:0;if(c!==this.spinCfg._direction){switch(c){case 1:$(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);
break;case -1:$(this).removeClass(this.spinCfg.upClass).addClass(this.spinCfg.downClass);break;default:$(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass)}this.spinCfg._direction=c}}).mouseout(function(){$(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);this.spinCfg._direction=null;window.clearInterval(this.spinCfg._repeat);window.clearTimeout(this.spinCfg._delay)}).mousedown(function(f){if(f.button===0&&this.spinCfg._direction!=0){var c=this,
m=f.shiftKey?c.spinCfg.smallStep:c.spinCfg.step,o=function(){c.adjustValue(c.spinCfg._direction*m)};o();c.spinCfg._delay=window.setTimeout(function(){o();c.spinCfg._repeat=window.setInterval(o,c.spinCfg.interval)},c.spinCfg.delay)}}).mouseup(function(){window.clearInterval(this.spinCfg._repeat);window.clearTimeout(this.spinCfg._delay)}).dblclick(function(){$.browser.msie&&this.adjustValue(this.spinCfg._direction*this.spinCfg.step)}).keydown(function(f){switch(f.keyCode){case 38:this.adjustValue(this.spinCfg.step);
break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page)}}).keypress(function(f){if(this.repeating)switch(f.keyCode){case 38:this.adjustValue(this.spinCfg.step);break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page)}else this.repeating=true}).keyup(function(f){this.repeating=false;switch(f.keyCode){case 38:case 40:case 33:case 34:case 13:this.adjustValue(0)}}).bind("mousewheel",
function(f){if(f.wheelDelta>=120)this.adjustValue(this.spinCfg.step);else f.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step);f.preventDefault()}).change(function(){this.adjustValue(0)});this.addEventListener&&this.addEventListener("DOMMouseScroll",function(f){if(f.detail>0)this.adjustValue(-this.spinCfg.step);else f.detail<0&&this.adjustValue(this.spinCfg.step);f.preventDefault()},false)})};function touchHandler(a){var n=a.changedTouches,f=n[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var m=document.createEvent("MouseEvent");m.initMouseEvent(c,true,true,window,1,f.screenX,f.screenY,f.clientX,f.clientY,false,false,false,false,0,null);if(n.length<2){f.target.dispatchEvent(m);a.preventDefault()}};jQuery&&function(){var a=$(window),n=$(document);$.extend($.fn,{contextMenu:function(f,c){if(f.menu==undefined)return false;if(f.inSpeed==undefined)f.inSpeed=150;if(f.outSpeed==undefined)f.outSpeed=75;if(f.inSpeed==0)f.inSpeed=-1;if(f.outSpeed==0)f.outSpeed=-1;$(this).each(function(){var m=$(this),o=$(m).offset(),b=$("#"+f.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).mouseup(function(e){var l=$(this);l.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||f.allowLeft||
2012-07-19 14:54:50 +00:00
d.ctrlKey&&svgedit.browser.isMac()){e.stopPropagation();if(m.hasClass("disabled")||d.altKey)return false;var u=e.pageX,w=e.pageY;e=a.width()-b.width();var q=a.height()-b.height();if(u>e-15)u=e-15;if(w>q-30)w=q-30;n.unbind("click");b.css({top:w,left:u}).fadeIn(f.inSpeed);b.find("A").mouseover(function(){b.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){b.find("LI.hover").removeClass("hover")});n.keypress(function(M){switch(M.keyCode){case 38:if(b.find("LI.hover").length){b.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");
b.find("LI.hover").length||b.find("LI:last").addClass("hover")}else b.find("LI:last").addClass("hover");break;case 40:if(b.find("LI.hover").length==0)b.find("LI:first").addClass("hover");else{b.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");b.find("LI.hover").length||b.find("LI:first").addClass("hover")}break;case 13:b.find("LI.hover A").trigger("click");break;case 27:n.trigger("click")}});b.find("A").unbind("mouseup");b.find("LI:not(.disabled) A").mouseup(function(){n.unbind("click").unbind("keypress");
$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),$(l),{x:u-o.left,y:w-o.top,docX:u,docY:w});return false});setTimeout(function(){n.click(function(){n.unbind("click").unbind("keypress");b.fadeOut(f.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+f.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+f.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+f.menu).each(function(){$(this).bind("mousedown.disableTextSelect",
function(){return false})});$(m).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(f){if(f==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(f!=undefined)for(var c=f.split(","),m=0;m<c.length;m++)$(this).find('A[href="'+c[m]+'"]').parent().addClass("disabled")});return $(this)},enableContextMenuItems:function(f){if(f==undefined){$(this).find("LI.disabled").removeClass("disabled");return $(this)}$(this).each(function(){if(f!=
undefined)for(var c=f.split(","),m=0;m<c.length;m++)$(this).find('A[href="'+c[m]+'"]').parent().removeClass("disabled")});return $(this)},disableContextMenu:function(){$(this).each(function(){$(this).addClass("disabled")});return $(this)},enableContextMenu:function(){$(this).each(function(){$(this).removeClass("disabled")});return $(this)},destroyContextMenu:function(){$(this).each(function(){$(this).unbind("mousedown").unbind("mouseup")});return $(this)}})}(jQuery);var svgedit=svgedit||{};
(function(){if(!svgedit.browser)svgedit.browser={};var a=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;svgedit.browser.supportsSvg=function(){return a};if(svgedit.browser.supportsSvg()){var n=navigator.userAgent,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),c=!!window.opera,m=n.indexOf("AppleWebKit")>=0,o=n.indexOf("Gecko/")>=0,b=n.indexOf("MSIE")>=0,d=n.indexOf("Chrome/")>=0,e=n.indexOf("Windows")>=0,l=n.indexOf("Macintosh")>=
2012-07-19 14:54:50 +00:00
0,u="ontouchstart"in window,w=!!f.querySelector,q=!!document.evaluate,M=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","path");ua.setAttribute("d","M0,0 10,10");var ia=ua.pathSegList;ua=ua.createSVGPathSegLinetoAbs(5,5);try{ia.replaceItem(ua,0);return true}catch(ea){}return false}(),U=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","path");ua.setAttribute("d","M0,0 10,10");var ia=ua.pathSegList;ua=ua.createSVGPathSegLinetoAbs(5,5);try{ia.insertItemBefore(ua,
0);return true}catch(ea){}return false}(),P=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","svg"),ia=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(ua);ia.setAttribute("x",5);ua.appendChild(ia);var ea=document.createElementNS("http://www.w3.org/2000/svg","text");ea.textContent="a";ia.appendChild(ea);ia=ea.getStartPositionOfChar(0).x;document.documentElement.removeChild(ua);return ia===0}(),K=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(ua);var ia=document.createElementNS("http://www.w3.org/2000/svg","path");ia.setAttribute("d","M0,0 C0,0 10,10 10,0");ua.appendChild(ia);ia=ia.getBBox();document.documentElement.removeChild(ua);return ia.height>4&&ia.height<5}(),fa=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(ua);var ia=document.createElementNS("http://www.w3.org/2000/svg","path");ia.setAttribute("d","M0,0 10,0");var ea=
document.createElementNS("http://www.w3.org/2000/svg","path");ea.setAttribute("d","M5,0 15,0");var ga=document.createElementNS("http://www.w3.org/2000/svg","g");ga.appendChild(ia);ga.appendChild(ea);ua.appendChild(ga);ia=ga.getBBox();document.documentElement.removeChild(ua);return ia.width==15}(),W=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","rect");ua.setAttribute("x",0.1);(ua=ua.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 ua}(),Q=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","rect");ua.setAttribute("style","vector-effect:non-scaling-stroke");return ua.style.vectorEffect==="non-scaling-stroke"}(),ha=function(){var ua=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,ia=f.createSVGTransform();ua.appendItem(ia);return ua.getItem(0)==ia}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return m};svgedit.browser.isGecko=function(){return o};
svgedit.browser.isIE=function(){return b};svgedit.browser.isChrome=function(){return d};svgedit.browser.isWindows=function(){return e};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return u};svgedit.browser.supportsSelectors=function(){return w};svgedit.browser.supportsXpath=function(){return q};svgedit.browser.supportsPathReplaceItem=function(){return M};svgedit.browser.supportsPathInsertItemBefore=function(){return U};svgedit.browser.supportsPathBBox=function(){return K};
svgedit.browser.supportsHVLineContainerBBox=function(){return fa};svgedit.browser.supportsGoodTextCharPos=function(){return P};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return W};svgedit.browser.supportsNonScalingStroke=function(){return Q};svgedit.browser.supportsNativeTransformLists=function(){return ha}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),n={};svgedit.transformlist.SVGTransformList=function(f){this._elem=f||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();for(var m=0;m<this.numberOfItems;++m){var o=this._list.getItem(m);c=c;o=o;var b=o.matrix,d="";switch(o.type){case 1:d="matrix("+[b.a,b.b,b.c,b.d,b.e,b.f].join(",")+")";break;case 2:d="translate("+b.e+","+b.f+")";break;case 3:d=
b.a==b.d?"scale("+b.a+")":"scale("+b.a+","+b.d+")";break;case 4:var e=0;d=0;if(o.angle!=0){e=1-b.a;d=(e*b.f+b.b*b.e)/(e*e+b.b*b.b);e=(b.e-b.b*d)/e}d="rotate("+o.angle+" "+e+","+d+")"}c=c+(d+" ")}this._elem.setAttribute("transform",c)};this._list=this;this._init=function(){var c=this._elem.getAttribute("transform");if(c)for(var m=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,o=true;o;){o=c.match(m);c=c.replace(m,"");if(o&&o[1]){var b=o[1].split(/\s*\(/),d=b[0];b=b[1].match(/\s*(.*?)\s*\)/);
2012-07-19 14:54:50 +00:00
b[1]=b[1].replace(/(\d)-/g,"$1 -");var e=b[1].split(/[, ]+/),l="abcdef".split(""),u=a.createSVGMatrix();$.each(e,function(M,U){e[M]=parseFloat(U);if(d=="matrix")u[l[M]]=e[M]});b=a.createSVGTransform();var w="set"+d.charAt(0).toUpperCase()+d.slice(1),q=d=="matrix"?[u]:e;if(d=="scale"&&q.length==1)q.push(q[0]);else if(d=="translate"&&q.length==1)q.push(0);else if(d=="rotate"&&q.length==1){q.push(0);q.push(0)}b[w].apply(b,q);this._list.appendItem(b)}}};this._removeFromOtherLists=function(c){if(c){var m=
false,o;for(o in n){for(var b=n[o],d=0,e=b._xforms.length;d<e;++d)if(b._xforms[d]==c){m=true;b.removeItem(d);break}if(m)break}}};this.numberOfItems=0;this.clear=function(){this.numberOfItems=0;this._xforms=[]};this.initialize=function(c){this.numberOfItems=1;this._removeFromOtherLists(c);this._xforms=[c]};this.getItem=function(c){if(c<this.numberOfItems&&c>=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,m){var o=null;if(m>=0)if(m<this.numberOfItems){this._removeFromOtherLists(c);
o=Array(this.numberOfItems+1);for(var b=0;b<m;++b)o[b]=this._xforms[b];o[b]=c;for(var d=b+1;b<this.numberOfItems;++d,++b)o[d]=this._xforms[b];this.numberOfItems++;this._xforms=o;o=c;this._list._update()}else o=this._list.appendItem(c);return o};this.replaceItem=function(c,m){var o=null;if(m<this.numberOfItems&&m>=0){this._removeFromOtherLists(c);o=this._xforms[m]=c;this._list._update()}return o};this.removeItem=function(c){if(c<this.numberOfItems&&c>=0){for(var m=this._xforms[c],o=Array(this.numberOfItems-
1),b=0;b<c;++b)o[b]=this._xforms[b];for(c=b;c<this.numberOfItems-1;++c,++b)o[c]=this._xforms[b+1];this.numberOfItems--;this._xforms=o;this._list._update();return m}else throw{code:1};};this.appendItem=function(c){this._removeFromOtherLists(c);this._xforms.push(c);this.numberOfItems++;this._list._update();return c}};svgedit.transformlist.resetListMap=function(){n={}};svgedit.transformlist.removeElementFromListMap=function(f){f.id&&n[f.id]&&delete n[f.id]};svgedit.transformlist.getTransformList=function(f){if(svgedit.browser.supportsNativeTransformLists())if(f.transform)return f.transform.baseVal;
else if(f.gradientTransform)return f.gradientTransform.baseVal;else{if(f.patternTransform)return f.patternTransform.baseVal}else{var c=f.id;c||(c="temp");var m=n[c];if(!m||c=="temp"){n[c]=new svgedit.transformlist.SVGTransformList(f);n[c]._init();m=n[c]}return m}return null}})();svgedit=svgedit||{};
(function(){if(!svgedit.math)svgedit.math={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg");svgedit.math.transformPoint=function(n,f,c){return{x:c.a*n+c.c*f+c.e,y:c.b*n+c.d*f+c.f}};svgedit.math.isIdentity=function(n){return n.a===1&&n.b===0&&n.c===0&&n.d===1&&n.e===0&&n.f===0};svgedit.math.matrixMultiply=function(){for(var n=arguments,f=n.length,c=n[f-1];f-- >1;)c=n[f-1].multiply(c);if(Math.abs(c.a)<1.0E-14)c.a=0;if(Math.abs(c.b)<1.0E-14)c.b=0;if(Math.abs(c.c)<1.0E-14)c.c=0;if(Math.abs(c.d)<
1.0E-14)c.d=0;if(Math.abs(c.e)<1.0E-14)c.e=0;if(Math.abs(c.f)<1.0E-14)c.f=0;return c};svgedit.math.hasMatrixTransform=function(n){if(!n)return false;for(var f=n.numberOfItems;f--;){var c=n.getItem(f);if(c.type==1&&!svgedit.math.isIdentity(c.matrix))return true}return false};svgedit.math.transformBox=function(n,f,c,m,o){var b={x:n,y:f},d={x:n+c,y:f};c={x:n+c,y:f+m};n={x:n,y:f+m};f=svgedit.math.transformPoint;b=f(b.x,b.y,o);var e=m=b.x,l=b.y,u=b.y;d=f(d.x,d.y,o);m=Math.min(m,d.x);e=Math.max(e,d.x);
l=Math.min(l,d.y);u=Math.max(u,d.y);n=f(n.x,n.y,o);m=Math.min(m,n.x);e=Math.max(e,n.x);l=Math.min(l,n.y);u=Math.max(u,n.y);c=f(c.x,c.y,o);m=Math.min(m,c.x);e=Math.max(e,c.x);l=Math.min(l,c.y);u=Math.max(u,c.y);return{tl:b,tr:d,bl:n,br:c,aabox:{x:m,y:l,width:e-m,height:u-l}}};svgedit.math.transformListToTransform=function(n,f,c){if(n==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());f=f==undefined?0:f;c=c==undefined?n.numberOfItems-1:c;f=parseInt(f);c=parseInt(c);if(f>c){var m=c;c=f;
f=m}m=a.createSVGMatrix();for(f=f;f<=c;++f){var o=f>=0&&f<n.numberOfItems?n.getItem(f).matrix:a.createSVGMatrix();m=svgedit.math.matrixMultiply(m,o)}return a.createSVGTransformFromMatrix(m)};svgedit.math.getMatrix=function(n){n=svgedit.transformlist.getTransformList(n);return svgedit.math.transformListToTransform(n).matrix};svgedit.math.snapToAngle=function(n,f,c,m){var o=Math.PI/4;c=c-n;var b=m-f;m=Math.sqrt(c*c+b*b);o=Math.round(Math.atan2(b,c)/o)*o;return{x:n+m*Math.cos(o),y:f+m*Math.sin(o),a:o}};
svgedit.math.rectsIntersect=function(n,f){return f.x<n.x+n.width&&f.x+f.width>n.x&&f.y<n.y+n.height&&f.y+f.height>n.y}})();svgedit=svgedit||{};
(function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],n=["y","y1","cy","ry","height"],f=$.merge(["r","radius"],a);$.merge(f,n);var c,m={px:1};svgedit.units.init=function(b){c=b;b=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(b);var d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("width","1em");d.setAttribute("height","1ex");d.setAttribute("x","1in");b.appendChild(d);d=d.getBBox();document.body.removeChild(b);
b=d.x;m.em=d.width;m.ex=d.height;m["in"]=b;m.cm=b/2.54;m.mm=b/25.4;m.pt=b/72;m.pc=b/6;m["%"]=0};svgedit.units.getTypeMap=function(){return m};svgedit.units.shortFloat=function(b){var d=c.getRoundDigits();if(isNaN(b)){if($.isArray(b))return svgedit.units.shortFloat(b[0])+","+svgedit.units.shortFloat(b[1])}else return+(+b).toFixed(d);return parseFloat(b).toFixed(d)-0};svgedit.units.convertUnit=function(b,d){d=d||c.getBaseUnit();return svgedit.unit.shortFloat(b/m[d])};svgedit.units.setUnitAttr=function(b,
2012-07-19 14:54:50 +00:00
d,e){isNaN(e)||b.getAttribute(d);b.setAttribute(d,e)};var o={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(b){var d=b.tagName,e=c.getBaseUnit();if(d=o[d])for(var l=d.length,u=0;u<l;u++){var w=d[u],q=b.getAttribute(w);if(q)isNaN(q)||b.setAttribute(w,q/m[e]+e)}};svgedit.units.convertToNum=
function(b,d){if(!isNaN(d))return d-0;if(d.substr(-1)==="%"){var e=d.substr(0,d.length-1)/100,l=c.getWidth(),u=c.getHeight();return a.indexOf(b)>=0?e*l:n.indexOf(b)>=0?e*u:e*Math.sqrt(l*l+u*u)/Math.sqrt(2)}else{l=d.substr(-2);e=d.substr(0,d.length-2);return e*m[l]}};svgedit.units.isValidUnit=function(b,d,e){var l=false;if(f.indexOf(b)>=0)if(isNaN(d)){d=d.toLowerCase();$.each(m,function(q){if(!l)if(RegExp("^-?[\\d\\.]+"+q+"$").test(d))l=true})}else l=true;else if(b=="id"){b=false;try{var u=c.getElement(d);
b=u==null||u===e}catch(w){}return b}else l=true;return l}})();svgedit=svgedit||{};
2012-07-19 14:54:50 +00:00
(function(){function a(b){if(svgedit.browser.supportsHVLineContainerBBox())try{return b.getBBox()}catch(d){}var e=$.data(b,"ref"),l=null;if(e){var u=$(e).children().clone().attr("visibility","hidden");$(o).append(u);l=u.filter("line, path")}else l=$(b).find("line, path");var w=false;if(l.length){l.each(function(){var q=this.getBBox();if(!q.width||!q.height)w=true});if(w){b=e?u:$(b).children();ret=getStrokedBBox(b)}else ret=b.getBBox()}else ret=b.getBBox();e&&u.remove();return ret}if(!svgedit.utilities)svgedit.utilities=
{};var n="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),f=null,c=null,m=null,o=null;svgedit.utilities.init=function(b){f=b;c=b.getDOMDocument();m=b.getDOMContainer();o=b.getSVGRoot()};svgedit.utilities.toXml=function(b){return $("<p/>").text(b).html()};svgedit.utilities.fromXml=function(b){return $("<p/>").html(b).text()};svgedit.utilities.encode64=function(b){b=svgedit.utilities.convertToXMLReferences(b);if(window.btoa)return window.btoa(b);
2012-07-19 14:54:50 +00:00
var d=Array(Math.floor((b.length+2)/3)*4),e,l,u,w,q,M,U=0,P=0;do{e=b.charCodeAt(U++);l=b.charCodeAt(U++);u=b.charCodeAt(U++);w=e>>2;e=(e&3)<<4|l>>4;q=(l&15)<<2|u>>6;M=u&63;if(isNaN(l))q=M=64;else if(isNaN(u))M=64;d[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(w);d[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e);d[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(q);d[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(M)}while(U<
b.length);return d.join("")};svgedit.utilities.decode64=function(b){if(window.atob)return window.atob(b);var d="",e,l,u="",w,q="",M=0;b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(M++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(M++));w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(M++));q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(M++));
e=e<<2|l>>4;l=(l&15)<<4|w>>2;u=(w&3)<<6|q;d+=String.fromCharCode(e);if(w!=64)d+=String.fromCharCode(l);if(q!=64)d+=String.fromCharCode(u)}while(M<b.length);return unescape(d)};svgedit.utilities.convertToXMLReferences=function(b){for(var d="",e=0;e<b.length;e++){var l=b.charCodeAt(e);if(l<128)d+=b[e];else if(l>127)d+="&#"+l+";"}return d};svgedit.utilities.text2xml=function(b){if(b.indexOf("<svg:svg")>=0)b=b.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var d;try{var e=window.DOMParser?
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");e.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{d=e.loadXML?e.loadXML(b)?e:false:e.parseFromString(b,"text/xml")}catch(u){throw Error("Error parsing XML string");}return d};svgedit.utilities.bboxToObj=function(b){return{x:b.x,y:b.y,width:b.width,height:b.height}};svgedit.utilities.walkTree=function(b,d){if(b&&b.nodeType==1){d(b);for(var e=b.childNodes.length;e--;)svgedit.utilities.walkTree(b.childNodes.item(e),d)}};
svgedit.utilities.walkTreePost=function(b,d){if(b&&b.nodeType==1){for(var e=b.childNodes.length;e--;)svgedit.utilities.walkTree(b.childNodes.item(e),d);d(b)}};svgedit.utilities.getUrlFromAttr=function(b){if(b)if(b.indexOf('url("')===0)return b.substring(5,b.indexOf('"',6));else if(b.indexOf("url('")===0)return b.substring(5,b.indexOf("'",6));else if(b.indexOf("url(")===0)return b.substring(4,b.indexOf(")"));return null};svgedit.utilities.getHref=function(b){return b.getAttributeNS("http://www.w3.org/1999/xlink",
"href")};svgedit.utilities.setHref=function(b,d){b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d)};svgedit.utilities.findDefs=function(b){b=f.getSVGContent().documentElement;var d=b.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return d=d.length>0?d[0]:b.insertBefore(b.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),b.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(b){var d=b.pathSegList,e=d.numberOfItems;b=[[],[]];var l=d.getItem(0),
2012-07-19 14:54:50 +00:00
u=[l.x,l.y];for(l=0;l<e;l++){var w=d.getItem(l);if(typeof w.x!="undefined"){b[0].push(u[0]);b[1].push(u[1]);if(w.x1){for(var q=[w.x1,w.y1],M=[w.x2,w.y2],U=[w.x,w.y],P=0;P<2;P++){w=function(ha){return Math.pow(1-ha,3)*u[P]+3*Math.pow(1-ha,2)*ha*q[P]+3*(1-ha)*Math.pow(ha,2)*M[P]+Math.pow(ha,3)*U[P]};var K=6*u[P]-12*q[P]+6*M[P],fa=-3*u[P]+9*q[P]-9*M[P]+3*U[P],W=3*q[P]-3*u[P];if(fa==0){if(K!=0){K=-W/K;0<K&&K<1&&b[P].push(w(K))}}else{W=Math.pow(K,2)-4*W*fa;if(!(W<0)){var Q=(-K+Math.sqrt(W))/(2*fa);0<Q&&
Q<1&&b[P].push(w(Q));K=(-K-Math.sqrt(W))/(2*fa);0<K&&K<1&&b[P].push(w(K))}}}u=U}else{b[0].push(w.x);b[1].push(w.y)}}}d=Math.min.apply(null,b[0]);e=Math.max.apply(null,b[0])-d;l=Math.min.apply(null,b[1]);b=Math.max.apply(null,b[1])-l;return{x:d,y:l,width:e,height:b}};svgedit.utilities.getBBox=function(b){var d=b||f.geSelectedElements()[0];if(b.nodeType!=1)return null;b=null;var e=d.nodeName;switch(e){case "text":if(d.textContent===""){d.textContent="a";b=d.getBBox();d.textContent=""}else try{b=d.getBBox()}catch(l){}break;
case "path":if(svgedit.browser.supportsPathBBox())try{b=d.getBBox()}catch(u){}else b=svgedit.utilities.getPathBBox(d);break;case "g":case "a":b=a(d);break;default:if(e==="use")b=a(d,true);if(e==="use"){b||(b=d.getBBox());if(!svgedit.browser.isWebkit()){e={};e.width=b.width;e.height=b.height;e.x=b.x+parseFloat(d.getAttribute("x")||0);e.y=b.y+parseFloat(d.getAttribute("y")||0);b=e}}else if(~n.indexOf(e))try{b=d.getBBox()}catch(w){d=$(d).closest("foreignObject");if(d.length)try{b=d[0].getBBox()}catch(q){b=
null}else b=null}}if(b)b=svgedit.utilities.bboxToObj(b);return b};svgedit.utilities.getRotationAngle=function(b,d){var e=b||f.getSelectedElements()[0];e=svgedit.transformlist.getTransformList(e);if(!e)return 0;for(var l=e.numberOfItems,u=0;u<l;++u){var w=e.getItem(u);if(w.type==4)return d?w.angle*Math.PI/180:w.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(b){return o.querySelector("#"+b)}:svgedit.browser.supportsXpath()?function(b){return c.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
b+'"]',m,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(b){return $(o).find("[id="+b+"]")[0]};svgedit.utilities.assignAttributes=function(b,d,e,l){e||(e=0);svgedit.browser.isOpera()||o.suspendRedraw(e);for(var u in d)if(e=u.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":u.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)b.setAttributeNS(e,u,d[u]);else l?svgedit.units.setUnitAttr(b,u,d[u]):b.setAttribute(u,d[u]);svgedit.browser.isOpera()||o.unsuspendRedraw(null)};
svgedit.utilities.cleanupElement=function(b){var d=o.suspendRedraw(60),e={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none","stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0},l;for(l in e){var u=e[l];b.getAttribute(l)==u&&b.removeAttribute(l)}o.unsuspendRedraw(d)}})();svgedit=svgedit||{};
(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a={};a["http://www.w3.org/1999/xlink"]="xlink";a["http://www.w3.org/XML/1998/namespace"]="xml";a["http://www.w3.org/2000/xmlns/"]="xmlns";a["http://svg-edit.googlecode.com"]="se";a["http://www.w3.org/1999/xhtml"]="xhtml";a["http://www.w3.org/1998/Math/MathML"]="mathml";var n={};$.each(a,function(m,o){n[o]=m});var f={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray",
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class",
"clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters",
"filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage",
"transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
"stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class",
"clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class",
"clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points",
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray",
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],
symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity",
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight",
"id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width",
"style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth",
"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},c={};$.each(f,function(m,o){var b={};$.each(o,function(d,e){if(e.indexOf(":")>=
0){var l=e.split(":");b[l[1]]=n[l[0]]}else b[e]=e=="xmlns"?"http://www.w3.org/2000/xmlns/":null});c[m]=b});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(m){if(m.nodeType==3){m.nodeValue=m.nodeValue.replace(/^\s+|\s+$/g,"");m.nodeValue.length||m.parentNode.removeChild(m)}if(m.nodeType==1){var o=m.parentNode;if(m.ownerDocument&&o){var b=f[m.nodeName],d=c[m.nodeName];if(b!=undefined){for(var e=[],l=m.attributes.length;l--;){var u=m.attributes.item(l),w=u.nodeName,
2012-07-19 14:54:50 +00:00
q=u.localName,M=u.namespaceURI;if(!(d.hasOwnProperty(q)&&M==d[q]&&M!="http://www.w3.org/2000/xmlns/")&&!(M=="http://www.w3.org/2000/xmlns/"&&a[u.nodeValue])){w.indexOf("se:")==0&&e.push([w,u.nodeValue]);m.removeAttributeNS(M,q)}if(svgedit.browser.isGecko())switch(w){case "transform":case "gradientTransform":case "patternTransform":q=u.nodeValue.replace(/(\d)-/g,"$1 -");m.setAttribute(w,q)}if(w=="style"){u=u.nodeValue.split(";");for(w=u.length;w--;){q=u[w].split(":");b.indexOf(q[0])>=0&&m.setAttribute(q[0],
q[1])}m.removeAttribute("style")}}$.each(e,function(U,P){m.setAttributeNS("http://svg-edit.googlecode.com",P[0],P[1])});if((l=svgedit.utilities.getHref(m))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(m.nodeName)>=0)if(l[0]!="#"){svgedit.utilities.setHref(m,"");m.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(m.nodeName=="use"&&!svgedit.utilities.getHref(m))o.removeChild(m);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start",
"mask","stroke"],function(U,P){var K=m.getAttribute(P);if(K)if((K=svgedit.utilities.getUrlFromAttr(K))&&K[0]!=="#"){m.setAttribute(P,"");m.removeAttribute(P)}});for(l=m.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(m.childNodes.item(l))}}else{for(b=[];m.hasChildNodes();)b.push(o.insertBefore(m.firstChild,m));o.removeChild(m);for(l=b.length;l--;)svgedit.sanitize.sanitizeSvg(b[l])}}}}})();svgedit=svgedit||{};
(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,n,f,c){this.elem=a;this.text=c?"Move "+a.tagName+" to "+c:"Move "+a.tagName;this.oldNextSibling=n;this.oldParent=f;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};svgedit.history.MoveElementCommand.prototype.type=
svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,n){this.elem=a;this.text=n||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type=function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type=
svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,n,f,c){this.elem=a;this.text=c||"Delete "+a.tagName;this.nextSibling=n;this.parent=f;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};
svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};
svgedit.history.ChangeElementCommand=function(a,n,f){this.elem=a;this.text=f?"Change "+a.tagName+" "+f:"Change "+a.tagName;this.newValues={};this.oldValues=n;for(var c in n)this.newValues[c]=c=="#text"?a.textContent:c=="#href"?svgedit.utilities.getHref(a):a.getAttribute(c)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=
function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var n=false,f;for(f in this.newValues){if(this.newValues[f])if(f=="#text")this.elem.textContent=this.newValues[f];else f=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[f]):this.elem.setAttribute(f,this.newValues[f]);else if(f=="#text")this.elem.textContent="";else{this.elem.setAttribute(f,"");this.elem.removeAttribute(f)}if(f==
"transform")n=true}if(!n)if(n=svgedit.utilities.getRotationAngle(this.elem)){f=elem.getBBox();n=["rotate(",n," ",f.x+f.width/2,",",f.y+f.height/2,")"].join("");n!=elem.getAttribute("transform")&&elem.setAttribute("transform",n)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var n=false,f;for(f in this.oldValues){if(this.oldValues[f])if(f==
"#text")this.elem.textContent=this.oldValues[f];else f=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[f]):this.elem.setAttribute(f,this.oldValues[f]);else if(f=="#text")this.elem.textContent="";else this.elem.removeAttribute(f);if(f=="transform")n=true}if(!n)if(n=svgedit.utilities.getRotationAngle(this.elem)){f=elem.getBBox();n=["rotate(",n," ",f.x+f.width/2,",",f.y+f.height/2,")"].join("");n!=elem.getAttribute("transform")&&elem.setAttribute("transform",n)}svgedit.transformlist.removeElementFromListMap(this.elem);
a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command";this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply=
function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);for(var n=this.stack.length,f=0;f<n;++f)this.stack[f].apply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.BatchCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);for(var n=this.stack.length-1;n>=0;n--)this.stack[n].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,
this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],n=this.stack.length;n--;)for(var f=this.stack[n].elements(),c=f.length;c--;)a.indexOf(f[c])==-1&&a.push(f[c]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=
-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():
""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""};svgedit.history.UndoManager.prototype.undo=function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};
svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,n){for(var f=++this.undoChangeStackPointer,c=n.length,m=Array(c),o=Array(c);c--;){var b=n[c];if(b!=null){o[c]=b;m[c]=b.getAttribute(a)}}this.undoableChangeStack[f]=
{attrName:a,oldValues:m,elements:o}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,n=this.undoableChangeStack[a],f=n.elements.length,c=n.attrName,m=new svgedit.history.BatchCommand("Change "+c);f--;){var o=n.elements[f];if(o!=null){var b={};b[c]=n.oldValues[f];b[c]!=o.getAttribute(c)&&m.addSubCommand(new svgedit.history.ChangeElementCommand(o,b,c))}}this.undoableChangeStack[a]=null;return m}})();svgedit=svgedit||{};
(function(){if(!svgedit.select)svgedit.select={};var a,n,f;svgedit.select.Selector=function(c,m){this.id=c;this.selectedElement=m;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));this.gripCoords={nw:null,n:null,ne:null,e:null,
se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(c){this.locked=true;this.selectedElement=c;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(c){var m=[];c=Math.round(c/45);if(c<0)c+=8;for(var o in f.selectorGrips)m.push(o);for(;c>0;){m.push(m.shift());c--}c=0;for(o in f.selectorGrips){f.selectorGrips[o].setAttribute("style","cursor:"+m[c]+"-resize");c++}};
svgedit.select.Selector.prototype.showGrips=function(c){f.selectorGripsGroup.setAttribute("display",c?"inline":"none");var m=this.selectedElement;this.hasGrips=c;if(m&&c){this.selectorGroup.appendChild(f.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(m))}};svgedit.select.Selector.prototype.resize=function(){var c=this.selectorRect,m=f,o=m.selectorGrips,b=this.selectedElement,d=b.getAttribute("stroke-width"),e=a.currentZoom(),l=1/e;if(b.getAttribute("stroke")!=="none"&&
2012-07-19 14:54:50 +00:00
!isNaN(d))l+=d/2;var u=b.tagName;if(u==="text")l+=2/e;d=svgedit.transformlist.getTransformList(b);d=svgedit.math.transformListToTransform(d).matrix;d.e*=e;d.f*=e;var w=svgedit.utilities.getBBox(b);if(u==="g"&&!$.data(b,"gsvg"))if(u=a.getStrokedBBox(b.childNodes))w=u;u=w.x;var q=w.y,M=w.width;w=w.height;l*=e;e=svgedit.math.transformBox(u*e,q*e,M*e,w*e,d);d=e.aabox;u=d.x-l;q=d.y-l;M=d.width+l*2;var U=d.height+l*2;d=u+M/2;w=q+U/2;if(b=svgedit.utilities.getRotationAngle(b)){u=a.svgRoot().createSVGTransform();
u.setRotate(-b,d,w);u=u.matrix;e.tl=svgedit.math.transformPoint(e.tl.x,e.tl.y,u);e.tr=svgedit.math.transformPoint(e.tr.x,e.tr.y,u);e.bl=svgedit.math.transformPoint(e.bl.x,e.bl.y,u);e.br=svgedit.math.transformPoint(e.br.x,e.br.y,u);u=e.tl;M=u.x;U=u.y;var P=u.x,K=u.y;u=Math.min;q=Math.max;M=u(M,u(e.tr.x,u(e.bl.x,e.br.x)))-l;U=u(U,u(e.tr.y,u(e.bl.y,e.br.y)))-l;P=q(P,q(e.tr.x,q(e.bl.x,e.br.x)))+l;K=q(K,q(e.tr.y,q(e.bl.y,e.br.y)))+l;u=M;q=U;M=P-M;U=K-U}l=a.svgRoot().suspendRedraw(100);c.setAttribute("d",
"M"+u+","+q+" L"+(u+M)+","+q+" "+(u+M)+","+(q+U)+" "+u+","+(q+U)+"z");this.selectorGroup.setAttribute("transform",b?"rotate("+[b,d,w].join(",")+")":"");u-=3.5;q-=3.5;this.gripCoords={nw:[u,q],ne:[u+M,q],sw:[u,q+U],se:[u+M,q+U],n:[u+M/2,q],w:[u,q+U/2],e:[u+M,q+U/2],s:[u+M/2,q+U]};for(var fa in this.gripCoords){c=this.gripCoords[fa];o[fa].setAttribute("x",c[0]);o[fa].setAttribute("y",c[1])}this.rotateCoords={nw:[u,q],ne:[u+M+8,q],sw:[u,q+U+8],se:[u+M+8,q+U+8]};for(fa in this.rotateCoords){c=this.rotateCoords[fa];
m.rotateGrips[fa].setAttribute("cx",c[0]);m.rotateGrips[fa].setAttribute("cy",c[1])}a.svgRoot().unsuspendRedraw(l)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.selectorGripsGroup=null;this.rotateGrips={nw:null,ne:null,se:null,sw:null};this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&
this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var c in this.rotateGrips){var m=a.createSVGElement({element:"circle",
2012-07-15 02:38:51 +00:00
attr:{id:"selectorGrip_rotate_"+c,fill:"#000",r:8,stroke:"#000","fill-opacity":0,"stroke-opacity":0,"stroke-width":0,style:"cursor:url("+n.imgPath+"rotate.png) 12 12, auto;"}});$.data(m,"dir",c);$.data(m,"type","rotate");this.rotateGrips[c]=this.selectorGripsGroup.appendChild(m)}for(c in this.selectorGrips){m=a.createSVGElement({element:"rect",attr:{id:"selectorGrip_resize_"+c,width:7,height:7,fill:"#4F80FF",stroke:"transparent","stroke-width":2,style:"cursor:"+c+"-resize","pointer-events":"all"}});
$.data(m,"dir",c);$.data(m,"type","resize");this.selectorGrips[c]=this.selectorGripsGroup.appendChild(m)}if(!$("#canvasBackground").length){c=n.dimensions;c=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:c[0],height:c[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});m=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});c.appendChild(m);
a.svgRoot().insertBefore(c,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(c){if(c==null)return null;var m=this.selectors.length;if(typeof this.selectorMap[c.id]=="object"){this.selectorMap[c.id].locked=true;return this.selectorMap[c.id]}for(var o=0;o<m;++o)if(this.selectors[o]&&!this.selectors[o].locked){this.selectors[o].locked=true;this.selectors[o].reset(c);this.selectorMap[c.id]=this.selectors[o];return this.selectors[o]}this.selectors[m]=new svgedit.select.Selector(m,
c);this.selectorParentGroup.appendChild(this.selectors[m].selectorGroup);this.selectorMap[c.id]=this.selectors[m];return this.selectors[m]};svgedit.select.SelectorManager.prototype.releaseSelector=function(c){if(c!=null)for(var m=this.selectors.length,o=this.selectorMap[c.id],b=0;b<m;++b)if(this.selectors[b]&&this.selectors[b]==o){o.locked==false&&console.log("WARNING! selector was released but was already unlocked");delete this.selectorMap[c.id];o.locked=false;o.selectedElement=null;o.showGrips(false);
try{o.selectorGroup.setAttribute("display","none")}catch(d){}break}};svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){if(!this.rubberBandBox)this.rubberBandBox=this.selectorParentGroup.appendChild(a.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"transparent",stroke:"#666","stroke-width":1,"stroke-dasharray":"3,2",display:"none",style:"pointer-events:none"}}));return this.rubberBandBox};svgedit.select.init=function(c,m){n=c;a=m;f=new svgedit.select.SelectorManager};
svgedit.select.getSelectorManager=function(){return f}})();svgedit=svgedit||{};
(function(){if(!svgedit.draw)svgedit.draw={};var a="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),n={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},f=n.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(c,m){this.name_=c;this.group_=m};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(c,m){f=c==false?n.NEVER_RANDOMIZE:
n.ALWAYS_RANDOMIZE;if(f==n.ALWAYS_RANDOMIZE&&!m.getNonce())m.setNonce(Math.floor(Math.random()*100001));else f==n.NEVER_RANDOMIZE&&m.getNonce()&&m.clearNonce()};svgedit.draw.Drawing=function(c,m){if(!c||!c.tagName||!c.namespaceURI||c.tagName!="svg"||c.namespaceURI!="http://www.w3.org/2000/svg")throw"Error: svgedit.draw.Drawing instance initialized without a <svg> element";this.svgElem_=c;this.obj_num=0;this.idPrefix=m||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
"";var o=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(o&&f!=n.NEVER_RANDOMIZE)this.nonce_=o;else f==n.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(c){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+c):$(this.svgElem_).find("[id="+c+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};
svgedit.draw.Drawing.prototype.setNonce=function(c){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",c);this.nonce_=c};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var c=
this.obj_num,m=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();m=true}else this.obj_num++;for(var o=this.getId();this.getElem_(o);){if(m){this.obj_num=c;m=false}this.obj_num++;o=this.getId()}if(m)this.obj_num=c;return o};svgedit.draw.Drawing.prototype.releaseId=function(c){var m=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof c!="string"||c.indexOf(m)!=0)return false;c=parseInt(c.substr(m.length));if(typeof c!="number"||c<=0||this.releasedNums.indexOf(c)!=-1)return false;
this.releasedNums.push(c);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(c){for(var m=0;m<this.getNumLayers();m++)if(this.all_layers[m][0]==c)return true;return false};svgedit.draw.Drawing.prototype.getLayerName=function(c){if(c>=0&&c<this.getNumLayers())return this.all_layers[c][0];return""};svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer};svgedit.draw.Drawing.prototype.getCurrentLayerName=
function(){for(var c=0;c<this.getNumLayers();++c)if(this.all_layers[c][1]==this.current_layer)return this.getLayerName(c);return""};svgedit.draw.Drawing.prototype.setCurrentLayer=function(c){for(var m=0;m<this.getNumLayers();++m)if(c==this.getLayerName(m)){if(this.current_layer!=this.all_layers[m][1]){this.current_layer.setAttribute("style","pointer-events:none");this.current_layer=this.all_layers[m][1];this.current_layer.setAttribute("style","pointer-events:all")}return true}return false};svgedit.draw.Drawing.prototype.deleteCurrentLayer=
function(){if(this.current_layer&&this.getNumLayers()>1){var c=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return c}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var c=this.svgElem_.childNodes.length,m=[],o=[],b=null,d=false,e=0;e<c;++e){var l=this.svgElem_.childNodes.item(e);if(l&&l.nodeType==1)if(l.tagName=="g"){d=true;var u=$("title",l).text();if(!u&&svgedit.browser.isOpera()&&l.querySelectorAll)u=$(l.querySelectorAll("title")).text();
if(u){o.push(u);this.all_layers.push([u,l]);b=l;svgedit.utilities.walkTree(l,function(w){w.setAttribute("style","pointer-events:inherit")});b.setAttribute("style","pointer-events:none")}else m.push(l)}else if(~a.indexOf(l.nodeName)){svgedit.utilities.getBBox(l);m.push(l)}}c=this.svgElem_.ownerDocument;if(m.length>0||!d){for(e=1;o.indexOf("Layer "+e)>=0;)e++;o="Layer "+e;b=c.createElementNS("http://www.w3.org/2000/svg","g");d=c.createElementNS("http://www.w3.org/2000/svg","title");d.textContent=o;
b.appendChild(d);for(d=0;d<m.length;++d)b.appendChild(m[d]);this.svgElem_.appendChild(b);this.all_layers.push([o,b])}svgedit.utilities.walkTree(b,function(w){w.setAttribute("style","pointer-events:inherit")});this.current_layer=b;this.current_layer.setAttribute("style","pointer-events:all")};svgedit.draw.Drawing.prototype.createLayer=function(c){var m=this.svgElem_.ownerDocument,o=m.createElementNS("http://www.w3.org/2000/svg","g");m=m.createElementNS("http://www.w3.org/2000/svg","title");m.textContent=
c;o.appendChild(m);this.svgElem_.appendChild(o);this.identifyLayers();return o};svgedit.draw.Drawing.prototype.getLayerVisibility=function(c){for(var m=null,o=0;o<this.getNumLayers();++o)if(this.getLayerName(o)==c){m=this.all_layers[o][1];break}if(!m)return false;return m.getAttribute("display")!="none"};svgedit.draw.Drawing.prototype.setLayerVisibility=function(c,m){if(typeof m!="boolean")return null;for(var o=null,b=0;b<this.getNumLayers();++b)if(this.getLayerName(b)==c){o=this.all_layers[b][1];
break}if(!o)return null;o.getAttribute("display");o.setAttribute("display",m?"inline":"none");return o};svgedit.draw.Drawing.prototype.getLayerOpacity=function(c){for(var m=0;m<this.getNumLayers();++m)if(this.getLayerName(m)==c){(c=this.all_layers[m][1].getAttribute("opacity"))||(c="1.0");return parseFloat(c)}return null};svgedit.draw.Drawing.prototype.setLayerOpacity=function(c,m){if(!(typeof m!="number"||m<0||m>1))for(var o=0;o<this.getNumLayers();++o)if(this.getLayerName(o)==c){this.all_layers[o][1].setAttribute("opacity",
m);break}}})();svgedit=svgedit||{};
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},n={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},f=[],c=true,m={};svgedit.path.setLinkControlPoints=function(d){c=d};var o=svgedit.path.path=null;svgedit.path.init=
2012-07-19 14:54:50 +00:00
function(d){o=d;f=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,l){f.push(l+"Abs");f.push(l+"Rel")})};svgedit.path.insertItemBefore=function(d,e,l){d=d.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())d.insertItemBefore(e,l);else{for(var u=d.numberOfItems,w=[],q=0;q<u;q++){var M=d.getItem(q);w.push(M)}d.clear();for(q=0;q<u;q++){q==l&&d.appendItem(e);d.appendItem(w[q])}}};
svgedit.path.ptObjToArr=function(d,e){for(var l=n[d],u=l.length,w=Array(u),q=0;q<u;q++)w[q]=e[l[q]];return w};svgedit.path.getGripPt=function(d,e){var l={x:e?e.x:d.item.x,y:e?e.y:d.item.y},u=d.path;if(u.matrix)l=svgedit.math.transformPoint(l.x,l.y,u.matrix);l.x*=o.getCurrentZoom();l.y*=o.getCurrentZoom();return l};svgedit.path.getPointFromGrip=function(d,e){var l={x:d.x,y:d.y};if(e.matrix){d=svgedit.math.transformPoint(l.x,l.y,e.imatrix);l.x=d.x;l.y=d.y}l.x/=o.getCurrentZoom();l.y/=o.getCurrentZoom();
return l};svgedit.path.addPointGrip=function(d,e,l){var u=svgedit.path.getGripContainer(),w=svgedit.utilities.getElem("pathpointgrip_"+d);if(!w){w=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(w,{id:"pathpointgrip_"+d,display:"none",width:5,height:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});w=u.appendChild(w);$("#pathpointgrip_"+d).dblclick(function(){svgedit.path.path&&
svgedit.path.path.setSegType()})}e&&l&&svgedit.utilities.assignAttributes(w,{x:e-2.5,y:l-2.5,display:"inline"});return w};svgedit.path.getGripContainer=function(){var d=svgedit.utilities.getElem("pathpointgrip_container");if(!d){d=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));d.id="pathpointgrip_container"}return d};svgedit.path.addCtrlGrip=function(d){var e=svgedit.utilities.getElem("ctrlpointgrip_"+d);if(e)return e;e=document.createElementNS("http://www.w3.org/2000/svg",
"circle");svgedit.utilities.assignAttributes(e,{id:"ctrlpointgrip_"+d,display:"none",r:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(e);return e};svgedit.path.getCtrlLine=function(d){var e=svgedit.utilities.getElem("ctrlLine_"+d);if(e)return e;e=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(e,{id:"ctrlLine_"+d,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});
2012-07-19 14:54:50 +00:00
svgedit.path.getGripContainer().appendChild(e);return e};svgedit.path.getPointGrip=function(d,e){var l=svgedit.path.addPointGrip(d.index);if(e){var u=svgedit.path.getGripPt(d);svgedit.utilities.assignAttributes(l,{x:u.x-2.5,y:u.y-2.5,display:"inline"})}return l};svgedit.path.getControlPoints=function(d){var e=d.item,l=d.index;if(!("x1"in e)||!("x2"in e))return null;var u={};svgedit.path.getGripContainer();for(var w=[svgedit.path.path.segs[l-1].item,e],q=1;q<3;q++){var M=l+"c"+q,U=u["c"+q+"_line"]=
svgedit.path.getCtrlLine(M),P=svgedit.path.getGripPt(d,{x:e["x"+q],y:e["y"+q]}),K=svgedit.path.getGripPt(d,{x:w[q-1].x,y:w[q-1].y});svgedit.utilities.assignAttributes(U,{x1:P.x,y1:P.y,x2:K.x,y2:K.y,display:"inline"});u["c"+q+"_line"]=U;pointGrip=u["c"+q]=svgedit.path.addCtrlGrip(M);svgedit.utilities.assignAttributes(pointGrip,{cx:P.x,cy:P.y,display:"inline"});u["c"+q]=pointGrip}return u};svgedit.path.replacePathSeg=function(d,e,l,u){u=u||svgedit.path.path.elem;d=u["createSVGPathSeg"+f[d]].apply(u,
l);if(svgedit.browser.supportsPathReplaceItem())u.pathSegList.replaceItem(d,e);else{l=u.pathSegList;u=l.numberOfItems;for(var w=[],q=0;q<u;q++){var M=l.getItem(q);w.push(M)}l.clear();for(q=0;q<u;q++)q==e?l.appendItem(d):l.appendItem(w[q])}};svgedit.path.getSegSelector=function(d,e){var l=d.index,u=svgedit.utilities.getElem("segline_"+l);if(!u){var w=svgedit.path.getGripContainer();u=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(u,{id:"segline_"+l,
display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});w.appendChild(u)}if(e){l=d.prev;if(!l){u.setAttribute("display","none");return u}l=svgedit.path.getGripPt(l);svgedit.path.replacePathSeg(2,0,[l.x,l.y],u);w=svgedit.path.ptObjToArr(d.type,d.item,true);for(var q=0;q<w.length;q+=2){l=svgedit.path.getGripPt(d,{x:w[q],y:w[q+1]});w[q]=l.x;w[q+1]=l.y}svgedit.path.replacePathSeg(d.type,1,w,u)}return u};svgedit.path.smoothControlPoints=this.smoothControlPoints=
function(d,e,l){var u=d.x-l.x,w=d.y-l.y,q=e.x-l.x,M=e.y-l.y;if((u!=0||w!=0)&&(q!=0||M!=0)){d=Math.atan2(w,u);e=Math.atan2(M,q);u=Math.sqrt(u*u+w*w);q=Math.sqrt(q*q+M*M);w=o.getSVGRoot().createSVGPoint();M=o.getSVGRoot().createSVGPoint();if(d<0)d+=2*Math.PI;if(e<0)e+=2*Math.PI;var U=Math.abs(d-e),P=Math.abs(Math.PI-U)/2;if(d-e>0){d=U<Math.PI?d+P:d-P;e=U<Math.PI?e-P:e+P}else{d=U<Math.PI?d-P:d+P;e=U<Math.PI?e+P:e-P}w.x=u*Math.cos(d)+l.x;w.y=u*Math.sin(d)+l.y;M.x=q*Math.cos(e)+l.x;M.y=q*Math.sin(e)+l.y;
return[w,M]}};svgedit.path.Segment=function(d,e){this.selected=false;this.index=d;this.item=e;this.type=e.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=function(d){for(var e in this.ctrlpts)this.ctrlpts[e].setAttribute("display",d?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(d){if(this.ptgrip){this.ptgrip.setAttribute("display",
d?"inline":"none");this.segsel.setAttribute("display",d?"inline":"none");this.showCtrlPts(d)}};svgedit.path.Segment.prototype.select=function(d){if(this.ptgrip){this.ptgrip.setAttribute("stroke",d?"#0FF":"#00F");this.segsel.setAttribute("display",d?"inline":"none");this.ctrlpts&&this.selectCtrls(d);this.selected=d}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,
true)};svgedit.path.Segment.prototype.update=function(d){if(this.ptgrip){var e=svgedit.path.getGripPt(this);svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:e.x-2.5,y:e.y-2.5}:{cx:e.x,cy:e.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(d){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(d,e){var l=this.item;l=this.ctrlpts?
[l.x+=d,l.y+=e,l.x1,l.y1,l.x2+=d,l.y2+=e]:[l.x+=d,l.y+=e];svgedit.path.replacePathSeg(this.type,this.index,l);if(this.next&&this.next.ctrlpts){l=this.next.item;l=[l.x,l.y,l.x1+=d,l.y1+=e,l.x2,l.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,l)}if(this.mate){l=this.mate.item;l=[l.x+=d,l.y+=e];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,l)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(d){var e,l,u;if(d==2){l=1;e=
this.next;if(!e)return;u=this.item}else{l=2;e=this.prev;if(!e)return;u=e.item}var w=e.item;w["x"+l]=u.x+(u.x-this.item["x"+d]);w["y"+l]=u.y+(u.y-this.item["y"+d]);svgedit.path.replacePathSeg(e.type,e.index,[w.x,w.y,w.x1,w.y1,w.x2,w.y2]);e.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(d,e,l){var u=this.item;u["x"+d]+=e;u["y"+d]+=l;svgedit.path.replacePathSeg(this.type,this.index,[u.x,u.y,u.x1,u.y1,u.x2,u.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(d,e){svgedit.path.replacePathSeg(d,
this.index,e);this.type=d;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(d===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(d){if(!d||d.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=d;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var d=
2012-07-19 14:54:50 +00:00
this.elem.pathSegList,e=d.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l<e;l++){var u=d.getItem(l);u=new svgedit.path.Segment(l,u);u.path=this;this.segs.push(u)}d=this.segs;u=null;for(l=0;l<e;l++){var w=d[l],q=l+1>=e?null:d[l+1],M=l-1<0?null:d[l-1];if(w.type===2){if(M&&M.type!==1){q=d[u];q.next=d[u+1];q.next.prev=q;q.addGrip()}u=l}else if(q&&q.type===1){w.next=d[u+1];w.next.prev=w;w.mate=d[u];w.addGrip();if(this.first_seg==null)this.first_seg=w}else if(q){if(w.type!==
1){w.addGrip();if(q&&q.type!==2){w.next=q;w.next.prev=w}}}else if(w.type!==1){q=d[u];q.next=d[u+1];q.next.prev=q;q.addGrip();w.addGrip();if(!this.first_seg)this.first_seg=d[u]}}return this};svgedit.path.Path.prototype.eachSeg=function(d){for(var e=this.segs.length,l=0;l<e;l++)if(d.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(d){var e=this.segs[d];if(e.prev){var l=e.prev,u;switch(e.item.pathSegType){case 4:var w=(e.item.x+l.item.x)/2,q=(e.item.y+l.item.y)/2;u=this.elem.createSVGPathSegLinetoAbs(w,
q);break;case 6:u=(l.item.x+e.item.x1)/2;var M=(e.item.x1+e.item.x2)/2,U=(e.item.x2+e.item.x)/2,P=(u+M)/2;M=(M+U)/2;w=(P+M)/2;var K=(l.item.y+e.item.y1)/2,fa=(e.item.y1+e.item.y2)/2;l=(e.item.y2+e.item.y)/2;var W=(K+fa)/2;fa=(fa+l)/2;q=(W+fa)/2;u=this.elem.createSVGPathSegCurvetoCubicAbs(w,q,u,K,P,W);svgedit.path.replacePathSeg(e.type,d,[e.item.x,e.item.y,M,fa,U,l])}svgedit.path.insertItemBefore(this.elem,u,d)}};svgedit.path.Path.prototype.deleteSeg=function(d){var e=this.segs[d],l=this.elem.pathSegList;
e.show(false);var u=e.next;if(e.mate){var w=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,u.index,w);svgedit.path.replacePathSeg(4,e.index,w);l.removeItem(e.mate.index)}else{if(!e.prev){w=[u.item.x,u.item.y];svgedit.path.replacePathSeg(2,e.next.index,w)}l.removeItem(d)}};svgedit.path.Path.prototype.subpathIsClosed=function(d){var e=false;svgedit.path.path.eachSeg(function(l){if(l<=d)return true;if(this.type===2)return false;else if(this.type===1){e=true;return false}});return e};svgedit.path.Path.prototype.removePtFromSelection=
function(d){var e=this.selected_pts.indexOf(d);if(e!=-1){this.segs[d].select(false);this.selected_pts.splice(e,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(d){this.eachSeg(function(){this.show(d)});d&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(d,
2012-07-19 14:54:50 +00:00
e){for(var l=this.selected_pts.length;l--;)this.segs[this.selected_pts[l]].move(d,e)};svgedit.path.Path.prototype.moveCtrl=function(d,e){var l=this.segs[this.selected_pts[0]];l.moveCtrl(this.dragctrl,d,e);c&&l.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(d){this.storeD();for(var e=this.selected_pts.length,l;e--;){var u=this.segs[this.selected_pts[e]],w=u.prev;if(w){if(!d){l="Toggle Path Segment Type";d=u.type==6?4:6}d-=0;var q=u.item.x,M=u.item.y,U=w.item.x;w=w.item.y;
var P;switch(d){case 6:if(u.olditem){U=u.olditem;P=[q,M,U.x1,U.y1,U.x2,U.y2]}else{P=q-U;var K=M-w;P=[q,M,U+P/3,w+K/3,q-P/3,M-K/3]}break;case 4:P=[q,M];u.olditem=u.item}u.setType(d,P)}}svgedit.path.path.endChanges(l)};svgedit.path.Path.prototype.selectPt=function(d,e){this.clearSelection();d==null&&this.eachSeg(function(l){if(this.prev)d=l});this.addPtsToSelection(d);if(e){this.dragctrl=e;c&&this.segs[d].setLinked(e)}};svgedit.path.Path.prototype.update=function(){var d=this.elem;if(svgedit.utilities.getRotationAngle(d)){this.matrix=
svgedit.math.getMatrix(d);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=null;this.eachSeg(function(e){this.item=d.pathSegList.getItem(e);this.update()});return this};svgedit.path.getPath_=function(d){var e=m[d.id];e||(e=m[d.id]=new svgedit.path.Path(d));return e};svgedit.path.removePath_=function(d){d in m&&delete m[d]};var b=function(d,e){dx=d-oldcx;dy=e-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;
2012-07-19 14:54:50 +00:00
dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var d=svgedit.path.path.elem,e=svgedit.utilities.getRotationAngle(d,true);if(e){var l=svgedit.utilities.getBBox(d),u=svgedit.path.path.oldbbox,w=u.x+u.width/2,q=u.y+u.height/2;u=l.x+l.width/2;l=l.y+l.height/2;u=u-w;var M=l-q;l=Math.sqrt(u*u+M*M);M=Math.atan2(M,u)+e;u=l*Math.cos(M)+w;l=l*Math.sin(M)+q;w=d.pathSegList;for(q=w.numberOfItems;q;){q-=
1;M=w.getItem(q);var U=M.pathSegType;if(U!=1){var P=b(M.x,M.y);P=[P.x,P.y];if(M.x1!=null&&M.x2!=null){c_vals1=b(M.x1,M.y1);c_vals2=b(M.x2,M.y2);P.splice(P.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(U,q,P)}}svgedit.utilities.getBBox(d);w=svgroot.createSVGTransform();d=svgedit.transformlist.getTransformList(d);w.setRotate(e*180/Math.PI,u,l);d.replaceItem(w,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(n,f){var c=this.length;if(!c)return a.apply(this,arguments);for(var m=0;m<c;m++){var o=this[m];if(o.namespaceURI==="http://www.w3.org/2000/svg")if(f!==undefined)o.setAttribute(n,f);else if($.isArray(n)){c=n.length;for(m={};c--;){var b=n[c],d=o.getAttribute(b);if(d||d==="0")d=isNaN(d)?d:d-0;m[b]=d}return m}else if(typeof n==="object")for(b in n)o.setAttribute(b,n[b]);else{if((d=o.getAttribute(n))||d==="0")d=isNaN(d)?d:d-0;return d}else return a.apply(this,
arguments)}return this}})();
2012-07-19 14:54:50 +00:00
$.SvgCanvas=function(a,n){function f(g,h){for(var k=svgedit.utilities.getBBox(g),v=0;v<2;v++){var s=v===0?"fill":"stroke",G=g.getAttribute(s);if(G&&G.indexOf("url(")===0){G=Z(G);if(G.tagName==="linearGradient"){var z=G.getAttribute("x1")||0,A=G.getAttribute("y1")||0,C=G.getAttribute("x2")||1,F=G.getAttribute("y2")||0;z=k.width*z+k.x;A=k.height*A+k.y;C=k.width*C+k.x;F=k.height*F+k.y;z=Q(z,A,h);F=Q(C,F,h);C={};C.x1=(z.x-k.x)/k.width;C.y1=(z.y-k.y)/k.height;C.x2=(F.x-k.x)/k.width;C.y2=(F.y-k.y)/k.height;
G=G.cloneNode(true);$(G).attr(C);G.id=O();Bb().appendChild(G);g.setAttribute(s,"url(#"+G.id+")")}}}}var c="http://www.w3.org/2000/svg",m={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};n&&$.extend(m,n);var o=m.dimensions,b=this,d=a.ownerDocument,e=d.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+c+'" xlinkns="http://www.w3.org/1999/xlink" width="'+o[0]+'" height="'+o[1]+'" x="'+o[0]+'" y="'+o[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,
true);a.appendChild(e);var l=d.createElementNS(c,"svg");(b.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:o[0],height:o[1],x:o[0],y:o[1],overflow:m.show_outside_canvas?"visible":"hidden",xmlns:c,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(e);var g=d.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(g)})();var u="svg_";b.setIdPrefix=
2012-07-19 14:54:50 +00:00
function(g){u=g};b.current_drawing_=new svgedit.draw.Drawing(l,u);var w=b.getCurrentDrawing=function(){return b.current_drawing_},q=1,M=null,U={shape:{fill:(m.initFill.color=="none"?"":"#")+m.initFill.color,fill_paint:null,fill_opacity:m.initFill.opacity,stroke:"#"+m.initStroke.color,stroke_paint:null,stroke_opacity:m.initStroke.opacity,stroke_width:m.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:m.initOpacity}};U.text=$.extend(true,{},U.shape);$.extend(U.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Junction"});var P=U.shape,K=Array(1),fa=this.addSvgElementFromJson=function(g){var h=svgedit.utilities.getElem(g.attr.id),k=w().getCurrentLayer();if(h&&g.element!=h.tagName){k.removeChild(h);h=null}if(!h){h=d.createElementNS(c,g.element);if(k)(M||k).appendChild(h)}g.curStyles&&svgedit.utilities.assignAttributes(h,{fill:P.fill,stroke:P.stroke,"stroke-width":P.stroke_width,"stroke-dasharray":P.stroke_dasharray,"stroke-linejoin":P.stroke_linejoin,
"stroke-linecap":P.stroke_linecap,"stroke-opacity":P.stroke_opacity,"fill-opacity":P.fill_opacity,opacity:P.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,g.attr,100);svgedit.utilities.cleanupElement(h);return h},W=b.getTransformList=svgedit.transformlist.getTransformList,Q=svgedit.math.transformPoint,ha=b.matrixMultiply=svgedit.math.matrixMultiply,ua=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,ia=b.transformListToTransform=svgedit.math.transformListToTransform,
ea=svgedit.math.snapToAngle,ga=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return m.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/q},getWidth:function(){return l.getAttribute("width")/q},getRoundDigits:function(){return bb.round_digits}});var ra=b.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return d},getDOMContainer:function(){return a},getSVGRoot:function(){return e},getSelectedElements:function(){return K},
getSVGContent:function(){return l}});var qa=b.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,ca=b.getHref=svgedit.utilities.getHref,T=b.setHref=svgedit.utilities.setHref,V=svgedit.utilities.getPathBBox;b.getBBox=svgedit.utilities.getBBox;var sa=b.getRotationAngle=svgedit.utilities.getRotationAngle,ta=b.getElem=svgedit.utilities.getElem,aa=b.assignAttributes=svgedit.utilities.assignAttributes,ma=this.cleanupElement=svgedit.utilities.cleanupElement,Ga=svgedit.sanitize.getNSMap(),Ma=b.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
Ra=svgedit.history.MoveElementCommand,Qa=svgedit.history.InsertElementCommand,Va=svgedit.history.RemoveElementCommand,Xa=svgedit.history.ChangeElementCommand,Na=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(g,h){var k=svgedit.history.HistoryEventTypes;if(g==k.BEFORE_UNAPPLY||g==k.BEFORE_APPLY)b.clearSelection();else if(g==k.AFTER_APPLY||g==k.AFTER_UNAPPLY){var v=h.elements();b.pathActions.clear();H("changed",v);v=h.type();k=g==k.AFTER_APPLY;if(v==
Ra.type()){k=k?h.newParent:h.oldParent;k==l&&b.identifyLayers()}else if(v==Qa.type()||v==Va.type()){h.parent==l&&b.identifyLayers();if(v==Qa.type())k&&$a(h.elem);else k||$a(h.elem);h.elem.tagName==="use"&&gc(h.elem)}else if(v==Xa.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();k=k?h.newValues:h.oldValues;k.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,k.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){v=h.elem;if(!v.getAttribute("x")&&!v.getAttribute("y")){k=
v.parentNode;var s=v.nextSibling;k.removeChild(v);k.insertBefore(v,s)}}}}}});var Ha=function(g){b.undoMgr.addCommandToHistory(g)};svgedit.select.init(m,{createSVGElement:function(g){return b.addSvgElementFromJson(g)},svgRoot:function(){return e},svgContent:function(){return l},currentZoom:function(){return q},getStrokedBBox:function(g){return b.getStrokedBBox([g])}});var Pa=this.selectorManager=svgedit.select.getSelectorManager(),zb=this.hoverManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return q},
getSVGRoot:function(){return e}});svgedit.utilities.snapToGrid=function(g){var h=m.snappingStep,k=m.baseUnit;if(k!=="px")h*=svgedit.units.getTypeMap()[k];return g=Math.round(g/h)*h};var Ja=svgedit.utilities.snapToGrid,Jb={exportNoBlur:"Blurred elements will appear as un-blurred",exportNoforeignObject:"foreignObject elements will not appear",exportNoDashArray:"Strokes will appear filled",exportNoText:"Text may not appear as expected"},tb=["clip-path","fill","filter","marker-end","marker-mid","marker-start",
"mask","stroke"],ab=$.data,$a=function(g){var h=$(g).attr(tb),k;for(k in h){var v=h[k];if(v&&v.indexOf("url(")===0){v=qa(v).substr(1);if(!ta(v)){Bb().appendChild(Fb[v]);delete Fb[v]}}}g=g.getElementsByTagName("*");if(g.length){h=0;for(k=g.length;h<k;h++)$a(g[h])}},Ka={},Da=m.imgPath+"logo.png",yb=[],bb={round_digits:5},Sa=false,gb=null,Ia="select",rb="none",sb={},mb=U.text,hb=P,La=null,Wa=null,jb=[],Eb={},Fb={};b.clipBoard=[];var nb=this.runExtensions=function(g,h,k){var v=false;if(k)v=[];$.each(Eb,
function(s,G){if(g in G)if(k)v.push(G[g](h));else v=G[g](h)});return v};this.addExtension=function(g,h){if(g in Eb)console.log('Cannot add extension "'+g+'", an extension by that name already exists"');else{var k=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:e,svgcontent:l,nonce:w().getNonce(),selectorManager:Pa,hoverManager:zb})):h;Eb[g]=k;H("extension_added",k)}};var Gb=this.round=function(g){return parseInt(g*q)/q},Ob=this.getIntersectionList=function(g){if(Wa==null)return null;var h=
M||w().getCurrentLayer();jb.length||(jb=Ub(h));var k=null;try{k=h.getIntersectionList(g,null)}catch(v){}if(k==null||typeof k.item!="function"){k=[];if(g)g=g;else{g=Wa.getBBox();h={};for(var s in g)h[s]=g[s]/q;g=h}for(s=jb.length;s--;)g.width&&g.width&&svgedit.math.rectsIntersect(g,jb[s].bbox)&&k.push(jb[s].elem)}return k};getStrokedBBox=this.getStrokedBBox=function(g){g||(g=Kb());if(!g.length)return false;var h=function(F){try{var E=svgedit.utilities.getBBox(F),D=svgedit.utilities.getRotationAngle(F);
if(D&&D%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(F))){D=false;if(["ellipse","path","line","polyline","polygon"].indexOf(F.tagName)>=0)E=D=b.convertToPath(F,true);else if(F.tagName=="rect"){var L=F.getAttribute("rx"),I=F.getAttribute("ry");if(L||I)E=D=b.convertToPath(F,true)}if(!D){var N=F.cloneNode(true),X=document.createElementNS(c,"g"),R=F.parentNode;R.appendChild(X);X.appendChild(N);E=svgedit.utilities.bboxToObj(X.getBBox());R.removeChild(X)}}return E}catch(pa){console.log(F,
pa);return null}},k;$.each(g,function(){if(!k)if(this.parentNode)k=h(this)});if(k==null)return null;var v=k.x+k.width,s=k.y+k.height,G=k.x,z=k.y,A=function(F){var E=F.getAttribute("stroke-width"),D=0;if(F.getAttribute("stroke")!="none"&&!isNaN(E))D+=E/2;return D},C=[];$.each(g,function(F,E){var D=h(E);if(D){var L=A(E);G=Math.min(G,D.x-L);z=Math.min(z,D.y-L);C.push(D)}});k.x=G;k.y=z;$.each(g,function(F,E){var D=C[F];if(D&&E.nodeType==1){var L=A(E);v=Math.max(v,D.x+D.width+L);s=Math.max(s,D.y+D.height+
L)}});k.width=v-G;k.height=s-z;return k};var Kb=this.getVisibleElements=function(g){g||(g=$(l).children());var h=[];$(g).children().each(function(k,v){try{v.getBBox()&&h.push(v)}catch(s){}});return h.reverse()},Ub=this.getVisibleElementsAndBBoxes=function(g){g||(g=$(l).children());var h=[];$(g).children().each(function(k,v){try{v.getBBox()&&h.push({elem:v,bbox:getStrokedBBox([v])})}catch(s){}});return h.reverse()},na=this.groupSvgElem=function(g){var h=document.createElementNS(c,"g");g.parentNode.replaceChild(h,
g);$(h).append(g).data("gsvg",g)[0].id=O()},ba=function(g){var h=document.createElementNS(g.namespaceURI,g.nodeName);h.removeAttribute("id");$.each(g.attributes,function(v,s){s.localName!="-moz-math-font-style"&&h.setAttributeNS(s.namespaceURI,s.nodeName,s.nodeValue)});if(svgedit.browser.isWebkit()&&g.nodeName=="path"){var k=Ua.convertPath(g);h.setAttribute("d",k)}$.each(g.childNodes,function(v,s){switch(s.nodeType){case 1:h.appendChild(ba(s));break;case 3:h.textContent=s.nodeValue}});if($(g).data("gsvg"))$(h).data("gsvg",
h.firstChild);else if($(g).data("symbol")){g=$(g).data("symbol");$(h).data("ref",g).data("symbol",g)}else h.tagName=="image"&&Lb(h);h.id=O();return h},va,O,H;(function(g){var h={};va=g.getId=function(){return w().getId()};O=g.getNextId=function(){return w().getNextId()};H=g.call=function(k,v){if(h[k])return h[k](this,v)};g.bind=function(k,v){var s=h[k];h[k]=v;return s}})(b);this.prepareSvg=function(g){this.sanitizeSvg(g.documentElement);g=g.getElementsByTagNameNS(c,"path");for(var h=0,k=g.length;h<
k;++h){var v=g[h];v.setAttribute("d",Ua.convertPath(v));Ua.fixEnd(v)}};var Z=this.getRefElem=function(g){return ta(qa(g).substr(1))},Oa=function(g){if(!svgedit.browser.isGecko())return g;var h=g.cloneNode(true);g.parentNode.insertBefore(h,g);g.parentNode.removeChild(g);Pa.releaseSelector(g);K[0]=h;Pa.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(g,h){g=parseFloat(g);var k=K[0],v=k.getAttribute("transform"),s=svgedit.utilities.getBBox(k),G=s.x+s.width/2,z=s.y+s.height/
2;s=W(k);s.numberOfItems>0&&s.getItem(0).type==4&&s.removeItem(0);if(g!=0){G=Q(G,z,ia(s).matrix);z=e.createSVGTransform();z.setRotate(g,G.x,G.y);s.numberOfItems?s.insertItemBefore(z,0):s.appendItem(z)}else s.numberOfItems==0&&k.removeAttribute("transform");if(!h){s=k.getAttribute("transform");k.setAttribute("transform",v);ub("transform",s,K);H("changed",K)}ta("pathpointgrip_container");k=Pa.requestSelector(K[0]);k.resize();k.updateGripCursors(g)};var Za=this.recalculateAllSelectedDimensions=function(){for(var g=
new Na(rb=="none"?"position":"size"),h=K.length;h--;){var k=pb(K[h]);k&&g.addSubCommand(k)}if(!g.isEmpty()){Ha(g);H("changed",K)}},fb=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],wb=function(g){console.log([g.a,g.b,g.c,g.d,g.e,g.f])},xb=this.remapElement=function(g,h,k){var v=m.gridSnapping&&g.parentNode.parentNode.localName==="svg",s=function(){if(v)for(var D in h)h[D]=Ja(h[D]);aa(g,h,1E3,true)};box=svgedit.utilities.getBBox(g);for(var G=0;G<2;G++){var z=G===0?
"fill":"stroke",A=g.getAttribute(z);if(A&&A.indexOf("url(")===0)if(k.a<0||k.d<0){A=Z(A).cloneNode(true);if(k.a<0){var C=A.getAttribute("x1"),F=A.getAttribute("x2");A.setAttribute("x1",-(C-1));A.setAttribute("x2",-(F-1))}if(k.d<0){C=A.getAttribute("y1");F=A.getAttribute("y2");A.setAttribute("y1",-(C-1));A.setAttribute("y2",-(F-1))}A.id=O();Bb().appendChild(A);g.setAttribute(z,"url(#"+A.id+")")}}G=g.tagName;if(G==="g"||G==="text"||G==="use")if(k.a==1&&k.b==0&&k.c==0&&k.d==1&&(k.e!=0||k.f!=0)){z=ia(g).matrix;
z=ha(z.inverse(),k,z);h.x=parseFloat(h.x)+z.e;h.y=parseFloat(h.y)+z.f}else{z=W(g);A=e.createSVGTransform();A.setMatrix(ha(ia(z).matrix,k));z.clear();z.appendItem(A)}switch(G){case "foreignObject":case "rect":case "image":if(G==="image"&&(k.a<0||k.d<0)){z=W(g);A=e.createSVGTransform();A.setMatrix(ha(ia(z).matrix,k));z.clear();z.appendItem(A)}else{z=Q(h.x,h.y,k);h.width=k.a*h.width;h.height=k.d*h.height;h.x=z.x+Math.min(0,h.width);h.y=z.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}s();
break;case "ellipse":G=Q(h.cx,h.cy,k);h.cx=G.x;h.cy=G.y;h.rx=k.a*h.rx;h.ry=k.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);s();break;case "circle":G=Q(h.cx,h.cy,k);h.cx=G.x;h.cy=G.y;G=svgedit.math.transformBox(box.x,box.y,box.width,box.height,k);h.r=Math.min((G.tr.x-G.tl.x)/2,(G.bl.y-G.tl.y)/2);if(h.r)h.r=Math.abs(h.r);s();break;case "line":z=Q(h.x1,h.y1,k);C=Q(h.x2,h.y2,k);h.x1=z.x;h.y1=z.y;h.x2=C.x;h.y2=C.y;case "text":k=g.querySelectorAll("tspan");for(G=k.length;G--;){z=ra("x",g.getAttribute("x"));
A=ra("x",k[G].getAttribute("x"));C=ra("y",g.getAttribute("y"));F=ra("y",k[G].getAttribute("y"));var E={};if(!isNaN(z)&&!isNaN(A)&&z!=0&&A!=0&&h.x)E.x=h.x-(z-A);if(!isNaN(C)&&!isNaN(F)&&C!=0&&F!=0&&h.y)E.y=h.y-(C-F);if(E.x||E.y)aa(k[G],E,1E3,true)}s();break;case "use":s();break;case "g":(s=$(g).data("gsvg"))&&aa(s,h,1E3,true);break;case "polyline":case "polygon":s=h.points.length;for(G=0;G<s;++G){F=h.points[G];F=Q(F.x,F.y,k);h.points[G].x=F.x;h.points[G].y=F.y}s=h.points.length;k="";for(G=0;G<s;++G){F=
h.points[G];k+=F.x+","+F.y+" "}g.setAttribute("points",k);break;case "path":z=g.pathSegList;s=z.numberOfItems;h.d=Array(s);for(G=0;G<s;++G){A=z.getItem(G);h.d[G]={type:A.pathSegType,x:A.x,y:A.y,x1:A.x1,y1:A.y1,x2:A.x2,y2:A.y2,r1:A.r1,r2:A.r2,angle:A.angle,largeArcFlag:A.largeArcFlag,sweepFlag:A.sweepFlag}}s=h.d.length;G=h.d[0];E=Q(G.x,G.y,k);h.d[0].x=E.x;h.d[0].y=E.y;for(G=1;G<s;++G){A=h.d[G];z=A.type;if(z%2==0){F=Q(A.x!=undefined?A.x:E.x,A.y!=undefined?A.y:E.y,k);z=Q(A.x1,A.y1,k);C=Q(A.x2,A.y2,k);
A.x=F.x;A.y=F.y;A.x1=z.x;A.y1=z.y;A.x2=C.x;A.y2=C.y}else{A.x=k.a*A.x;A.y=k.d*A.y;A.x1=k.a*A.x1;A.y1=k.d*A.y1;A.x2=k.a*A.x2;A.y2=k.d*A.y2}A.r1=k.a*A.r1;A.r2=k.d*A.r2}k="";s=h.d.length;for(G=0;G<s;++G){A=h.d[G];z=A.type;k+=fb[z];switch(z){case 13:case 12:k+=A.x+" ";break;case 15:case 14:k+=A.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:k+=A.x+","+A.y+" ";break;case 7:case 6:k+=A.x1+","+A.y1+" "+A.x2+","+A.y2+" "+A.x+","+A.y+" ";break;case 9:case 8:k+=A.x1+","+A.y1+" "+A.x+","+A.y+" ";break;
case 11:case 10:k+=A.r1+","+A.r2+" "+A.angle+" "+ +A.largeArcFlag+" "+ +A.sweepFlag+" "+A.x+","+A.y+" ";break;case 17:case 16:k+=A.x2+","+A.y2+" "+A.x+","+A.y+" "}}g.setAttribute("d",k)}},Db=function(g,h,k){g=Z(g).firstChild;var v=W(g),s=e.createSVGTransform();s.setTranslate(h,k);v.appendItem(s);pb(g)},pb=this.recalculateDimensions=function(g){if(g==null)return null;var h=W(g);if(h&&h.numberOfItems>0){for(var k=h.numberOfItems;k--;){var v=h.getItem(k);if(v.type===0)h.removeItem(k);else if(v.type===
1)svgedit.math.isIdentity(v.matrix)&&h.removeItem(k);else v.type===4&&v.angle===0&&h.removeItem(k)}if(h.numberOfItems===1&&sa(g))return null}if(!h||h.numberOfItems==0){g.removeAttribute("transform");return null}if(h){k=h.numberOfItems;for(var s=[];k--;){v=h.getItem(k);if(v.type===1)s.push([v.matrix,k]);else if(s.length)s=[]}if(s.length===2){k=e.createSVGTransformFromMatrix(ha(s[1][0],s[0][0]));h.removeItem(s[0][1]);h.removeItem(s[1][1]);h.insertItemBefore(k,s[1][1])}k=h.numberOfItems;if(k>=2&&h.getItem(k-
2).type===1&&h.getItem(k-1).type===2){s=e.createSVGTransform();v=ha(h.getItem(k-2).matrix,h.getItem(k-1).matrix);s.setMatrix(v);h.removeItem(k-2);h.removeItem(k-2);h.appendItem(s)}}switch(g.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var G=$(g).data("gsvg");k=new Na("Transform");var z={},A=null;v=[];switch(g.tagName){case "line":v=["x1","y1",
"x2","y2"];break;case "circle":v=["cx","cy","r"];break;case "ellipse":v=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":v=["width","height","x","y"];break;case "use":case "text":case "tspan":v=["x","y"];break;case "polygon":case "polyline":A={};A.points=g.getAttribute("points");s=g.points;var C=s.numberOfItems;z.points=Array(C);for(var F=0;F<C;++F){var E=s.getItem(F);z.points[F]={x:E.x,y:E.y}}break;case "path":A={};A.d=g.getAttribute("d");z.d=g.getAttribute("d")}if(v.length){z=
$(g).attr(v);$.each(z,function(Mb,Rb){z[Mb]=ra(Mb,Rb)})}else if(G)z={x:$(G).attr("x")||0,y:$(G).attr("y")||0};if(A==null){A=$.extend(true,{},z);$.each(A,function(Mb,Rb){A[Mb]=ra(Mb,Rb)})}A.transform=gb?gb:"";if(g.tagName=="g"&&!G||g.tagName=="a"){s=svgedit.utilities.getBBox(g);var D={x:s.x+s.width/2,y:s.y+s.height/2},L=Q(s.x+s.width/2,s.y+s.height/2,ia(h).matrix);v=e.createSVGMatrix();if(s=sa(g)){F=s*Math.PI/180;C=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){v=
h.getItem(F);if(v.type==4){v=v.matrix;D.y=(C*v.e+v.f)/2;D.x=(v.e-C*v.f)/2;h.removeItem(F);break}}}F=v=G=0;var I=h.numberOfItems;if(I)var N=h.getItem(0).matrix;if(I>=3&&h.getItem(I-2).type==3&&h.getItem(I-3).type==2&&h.getItem(I-1).type==2){F=3;var X=h.getItem(I-3).matrix,R=h.getItem(I-2).matrix,pa=h.getItem(I-1).matrix;C=g.childNodes;for(E=C.length;E--;){var xa=C.item(E);v=G=0;if(xa.nodeType==1){var da=W(xa);if(da){v=ia(da).matrix;G=sa(xa);var ka=gb,oa=[];gb=xa.getAttribute("transform");if(G||ua(da)){var za=
e.createSVGTransform();za.setMatrix(ha(X,R,pa,v));da.clear();da.appendItem(za);oa.push(za)}else{G=ha(v.inverse(),pa,v);za=e.createSVGMatrix();za.e=-G.e;za.f=-G.f;v=ha(za.inverse(),v.inverse(),X,R,pa,v,G.inverse());var kb=e.createSVGTransform(),ob=e.createSVGTransform(),Vb=e.createSVGTransform();kb.setTranslate(G.e,G.f);ob.setScale(v.a,v.d);Vb.setTranslate(za.e,za.f);da.appendItem(Vb);da.appendItem(ob);da.appendItem(kb);oa.push(Vb);oa.push(ob);oa.push(kb)}k.addSubCommand(pb(xa));gb=ka}}}h.removeItem(I-
1);h.removeItem(I-2);h.removeItem(I-3)}else if(I>=3&&h.getItem(I-1).type==1){F=3;v=ia(h).matrix;za=e.createSVGTransform();za.setMatrix(v);h.clear();h.appendItem(za)}else if((I==1||I>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;G=ia(h).matrix;h.removeItem(0);v=ia(h).matrix.inverse();v=ha(v,G);G=v.e;v=v.f;if(G!=0||v!=0){C=g.childNodes;E=C.length;for(I=[];E--;){xa=C.item(E);if(xa.nodeType==1){if(xa.getAttribute("clip-path")){ka=xa.getAttribute("clip-path");if(I.indexOf(ka)===-1){Db(ka,G,v);I.push(ka)}}ka=
gb;gb=xa.getAttribute("transform");if(da=W(xa)){X=e.createSVGTransform();X.setTranslate(G,v);da.numberOfItems?da.insertItemBefore(X,0):da.appendItem(X);k.addSubCommand(pb(xa));da=g.getElementsByTagNameNS(c,"use");xa="#"+xa.id;for(X=da.length;X--;){R=da.item(X);if(xa==ca(R)){pa=e.createSVGTransform();pa.setTranslate(-G,-v);W(R).insertItemBefore(pa,0);k.addSubCommand(pb(R))}}gb=ka}}}I=[];gb=ka}}else if(I==1&&h.getItem(0).type==1&&!s){F=1;v=h.getItem(0).matrix;C=g.childNodes;for(E=C.length;E--;){xa=
C.item(E);if(xa.nodeType==1){ka=gb;gb=xa.getAttribute("transform");if(da=W(xa)){G=ha(v,ia(da).matrix);I=e.createSVGTransform();I.setMatrix(G);da.clear();da.appendItem(I,0);k.addSubCommand(pb(xa));gb=ka;ka=xa.getAttribute("stroke-width");xa.getAttribute("stroke")!=="none"&&!isNaN(ka)&&xa.setAttribute("stroke-width",ka*((Math.abs(G.a)+Math.abs(G.d))/2))}}}h.clear()}else{if(s){D=e.createSVGTransform();D.setRotate(s,L.x,L.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&
g.removeAttribute("transform");return null}if(F==2){if(s){L={x:D.x+N.e,y:D.y+N.f};D=e.createSVGTransform();D.setRotate(s,L.x,L.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else if(F==3){v=ia(h).matrix;N=e.createSVGTransform();N.setRotate(s,D.x,D.y);N=N.matrix;D=e.createSVGTransform();D.setRotate(s,L.x,L.y);L=D.matrix.inverse();ka=v.inverse();L=ha(ka,L,N,v);G=L.e;v=L.f;if(G!=0||v!=0){C=g.childNodes;for(E=C.length;E--;){xa=C.item(E);if(xa.nodeType==1){ka=gb;gb=xa.getAttribute("transform");
da=W(xa);X=e.createSVGTransform();X.setTranslate(G,v);da.numberOfItems?da.insertItemBefore(X,0):da.appendItem(X);k.addSubCommand(pb(xa));gb=ka}}}if(s)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else{s=svgedit.utilities.getBBox(g);if(!s&&g.tagName!="path")return null;v=e.createSVGMatrix();if(G=sa(g)){D={x:s.x+s.width/2,y:s.y+s.height/2};L=Q(s.x+s.width/2,s.y+s.height/2,ia(h).matrix);F=G*Math.PI/180;C=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){v=
h.getItem(F);if(v.type==4){v=v.matrix;D.y=(C*v.e+v.f)/2;D.x=(v.e-C*v.f)/2;h.removeItem(F);break}}}F=0;I=h.numberOfItems;if(!svgedit.browser.isWebkit())if((N=g.getAttribute("fill"))&&N.indexOf("url(")===0){N=Z(N);ka="pattern";if(N.tagName!==ka)ka="gradient";if(N.getAttribute(ka+"Units")==="userSpaceOnUse"){v=ia(h).matrix;s=W(N);s=ia(s).matrix;v=ha(v,s);s="matrix("+[v.a,v.b,v.c,v.d,v.e,v.f].join(",")+")";N.setAttribute(ka+"Transform",s)}}if(I>=3&&h.getItem(I-2).type==3&&h.getItem(I-3).type==2&&h.getItem(I-
1).type==2){F=3;v=ia(h,I-3,I-1).matrix;h.removeItem(I-1);h.removeItem(I-2);h.removeItem(I-3)}else if(I==4&&h.getItem(I-1).type==1){F=3;v=ia(h).matrix;za=e.createSVGTransform();za.setMatrix(v);h.clear();h.appendItem(za);v=e.createSVGMatrix()}else if((I==1||I>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;N=h.getItem(0).matrix;ka=ia(h,1).matrix;s=ka.inverse();v=ha(s,N,ka);h.removeItem(0)}else if(I==1&&h.getItem(0).type==1&&!G){v=ia(h).matrix;switch(g.tagName){case "line":z=$(g).attr(["x1","y1",
"x2","y2"]);case "polyline":case "polygon":z.points=g.getAttribute("points");if(z.points){s=g.points;C=s.numberOfItems;z.points=Array(C);for(F=0;F<C;++F){E=s.getItem(F);z.points[F]={x:E.x,y:E.y}}}case "path":z.d=g.getAttribute("d");F=1;h.clear()}}else{F=4;if(G){D=e.createSVGTransform();D.setRotate(G,L.x,L.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");return null}if(F==1||F==2||F==3)xb(g,z,v);if(F==2){if(G){ua(h)||(L={x:D.x+v.e,y:D.y+
v.f});D=e.createSVGTransform();D.setRotate(G,L.x,L.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else if(F==3&&G){v=ia(h).matrix;N=e.createSVGTransform();N.setRotate(G,D.x,D.y);N=N.matrix;D=e.createSVGTransform();D.setRotate(G,L.x,L.y);L=D.matrix.inverse();ka=v.inverse();L=ha(ka,L,N,v);xb(g,z,L);if(G)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}h.numberOfItems==0&&g.removeAttribute("transform");k.addSubCommand(new Xa(g,A));return k},Pb=null,cb=this.clearSelection=function(g){if(K[0]!=
null)for(var h=K.length,k=0;k<h;++k){var v=K[k];if(v==null)break;Pa.releaseSelector(v);K[k]=null}g||H("selected",K)},Nb=this.addToSelection=function(g,h){if(g.length!=0){for(var k=0;k<K.length;){if(K[k]==null)break;++k}for(var v=g.length;v--;){var s=g[v];if(s&&svgedit.utilities.getBBox(s)){if(s.tagName==="a"&&s.childNodes.length===1)s=s.firstChild;if(K.indexOf(s)==-1){K[k]=s;k++;s=Pa.requestSelector(s);K.length>1&&s.showGrips(false)}}}H("selected",K);h||K.length==1?Pa.requestSelector(K[0]).showGrips(true):
Pa.requestSelector(K[0]).showGrips(false);for(K.sort(function(G,z){if(G&&z&&G.compareDocumentPosition)return 3-(z.compareDocumentPosition(G)&6);else if(G==null)return 1});K[0]==null;)K.shift(0)}},Sb=this.selectOnly=function(g,h){cb(true);Nb(g,h)};this.removeFromSelection=function(g){if(K[0]!=null)if(g.length!=0){var h=Array(K.length);j=0;len=K.length;for(var k=0;k<len;++k){var v=K[k];if(v)if(g.indexOf(v)==-1){h[j]=v;j++}else Pa.releaseSelector(v)}K=h}};this.selectAllInCurrentLayer=function(){var g=
w().getCurrentLayer();if(g){Ia="select";Sb($(M||g).children())}};var ac=this.getMouseTarget=function(g){if(g==null)return null;g=g.target;if(g.correspondingUseElement)g=g.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(g.namespaceURI)>=0&&g.id!="svgcanvas")for(;g.nodeName!="foreignObject";){g=g.parentNode;if(!g)return e}var h=w().getCurrentLayer();if([e,a,l,h].indexOf(g)>=0)return e;if($(g).closest("#selectorParentGroup").length)return Pa.selectorParentGroup;
for(;g.parentNode!==(M||h);)g=g.parentNode;return g};(function(){var g=null,h=null,k=null,v=null,s=null,G={},z={minx:null,miny:null,maxx:null,maxy:null},A=mosueOver=function(C){if(!(b.spaceKey||C.button===1)){var F=C.button===2;C.altKey&&svgCanvas.cloneSelectedElements(0,0);Pb=l.getScreenCTM().inverse();var E=Q(C.pageX,C.pageY,Pb),D=E.x*q;E=E.y*q;C.preventDefault();if(F)Ia="select";D=D/q;E=E/q;var L=ac(C);if(L.tagName==="a"&&L.childNodes.length===1)L=L.firstChild;var I=v=h=D,N=s=k=E;if(m.gridSnapping){D=
Ja(D);E=Ja(E);h=Ja(h);k=Ja(k)}if(L==Pa.selectorParentGroup&&K[0]!=null){L=C.target;var X=ab(L,"type");if(X=="rotate"){Ia="rotate";current_rotate_mode=ab(L,"dir")}else if(X=="resize"){Ia="resize";rb=ab(L,"dir")}L=K[0]}gb=L.getAttribute("transform");X=W(L);switch(Ia){case "select":Sa=true;rb="none";if(F)Sa=false;if(L!=e){if(K.indexOf(L)==-1){C.shiftKey||cb(true);Nb([L]);La=L;Ua.clear()}if(!F)for(F=0;F<K.length;++F)if(K[F]!=null){var R=W(K[F]);R.numberOfItems?R.insertItemBefore(e.createSVGTransform(),
0):R.appendItem(e.createSVGTransform())}}else if(!F){cb();Ia="multiselect";if(Wa==null)Wa=Pa.getRubberBandBox();v*=q;s*=q;aa(Wa,{x:v,y:s,width:0,height:0,display:"inline"},100)}break;case "zoom":Sa=true;if(Wa==null)Wa=Pa.getRubberBandBox();aa(Wa,{x:I*q,y:I*q,width:0,height:0,display:"inline"},100);break;case "resize":Sa=true;h=D;k=E;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var pa={};$.each(G,function(xa,da){pa[xa]=da/q});G=pa;F=sa(L)?1:0;if(ua(X)){X.insertItemBefore(e.createSVGTransform(),
F);X.insertItemBefore(e.createSVGTransform(),F);X.insertItemBefore(e.createSVGTransform(),F)}else{X.appendItem(e.createSVGTransform());X.appendItem(e.createSVGTransform());X.appendItem(e.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(D=svgedit.browser.isChrome())R=function(xa){var da=xa.getAttributeNS(null,"stroke");xa.removeAttributeNS(null,"stroke");setTimeout(function(){xa.setAttributeNS(null,"stroke",da)},1)};L.style.vectorEffect="non-scaling-stroke";D&&R(L);E=L.getElementsByTagName("*");
I=E.length;for(F=0;F<I;F++){E[F].style.vectorEffect="non-scaling-stroke";D&&R(E[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":Sa=true;g=I+","+N+" ";R=P.stroke_width==0?1:P.stroke_width;fa({element:"polyline",curStyles:true,attr:{points:g,id:O(),fill:"none",opacity:P.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});z.minx=I;z.maxx=I;z.miny=N;z.maxy=N;break;case "image":Sa=true;R=fa({element:"image",attr:{x:D,y:E,width:0,height:0,id:O(),opacity:P.opacity/2,style:"pointer-events:inherit"}});
T(R,Da);Lb(R);break;case "square":case "rect":Sa=true;h=D;k=E;fa({element:"rect",curStyles:true,attr:{x:D,y:E,width:0,height:0,id:O(),opacity:P.opacity/2}});break;case "line":Sa=true;R=P.stroke_width==0?1:P.stroke_width;fa({element:"line",curStyles:true,attr:{x1:D,y1:E,x2:D,y2:E,id:O(),stroke:P.stroke,"stroke-width":R,"stroke-dasharray":P.stroke_dasharray,"stroke-linejoin":P.stroke_linejoin,"stroke-linecap":P.stroke_linecap,"stroke-opacity":P.stroke_opacity,fill:"none",opacity:P.opacity/2,style:"pointer-events:none"}});
break;case "circle":Sa=true;fa({element:"circle",curStyles:true,attr:{cx:D,cy:E,r:0,id:O(),opacity:P.opacity/2}});break;case "ellipse":Sa=true;fa({element:"ellipse",curStyles:true,attr:{cx:D,cy:E,rx:0,ry:0,id:O(),opacity:P.opacity/2}});break;case "text":Sa=true;fa({element:"text",curStyles:true,attr:{x:D,y:E,id:O(),fill:mb.fill,"stroke-width":mb.stroke_width,"font-size":mb.font_size,"font-family":mb.font_family,"text-anchor":"left","xml:space":"preserve",opacity:P.opacity}});break;case "path":case "pathedit":h*=
q;k*=q;Ua.mouseDown(C,L,h,k);Sa=true;break;case "textedit":h*=q;k*=q;qb.mouseDown(C,L,h,k);Sa=true;break;case "rotate":Sa=true;b.undoMgr.beginUndoableChange("transform",K);document.getElementById("workarea").className="rotate"}R=nb("mouseDown",{event:C,start_x:h,start_y:k,selectedElements:K},true);$.each(R,function(xa,da){if(da&&da.started)Sa=true});if(Ia)document.getElementById("workarea").className=Ia=="resize"?C.target.style.cursor:Ia}};$(a).mousedown(A).mousemove(function(C){if(Sa)if(!(C.button===
1||b.spaceKey)){var F=K[0],E=Q(C.pageX,C.pageY,Pb),D=E.x*q;E=E.y*q;var L=ta(va()),I=x=D/q,N=y=E/q;if(m.gridSnapping){x=Ja(x);y=Ja(y)}C.preventDefault();switch(Ia){case "select":if(K[0]!==null){I=x-h;var X=y-k;if(m.gridSnapping){I=Ja(I);X=Ja(X)}if(C.shiftKey){var R=ea(h,k,x,y);x=R.x;y=R.y}if(I!=0||X!=0){R=K.length;for(N=0;N<R;++N){F=K[N];if(F==null)break;var pa=e.createSVGTransform();L=W(F);pa.setTranslate(I,X);L.numberOfItems?L.replaceItem(pa,0):L.appendItem(pa);Pa.requestSelector(F).resize()}H("transition",
K)}}break;case "multiselect":I*=q;N*=q;aa(Wa,{x:Math.min(v,I),y:Math.min(s,N),width:Math.abs(I-v),height:Math.abs(N-s)},100);L=[];I=[];pa=Ob();R=K.length;for(N=0;N<R;++N){X=pa.indexOf(K[N]);if(X==-1)L.push(K[N]);else pa[X]=null}R=pa.length;for(N=0;N<R;++N)pa[N]&&I.push(pa[N]);L.length>0&&b.removeFromSelection(L);I.length>0&&Nb(I);break;case "resize":L=W(F);I=(R=ua(L))?G:svgedit.utilities.getBBox(F);N=I.x;pa=I.y;var xa=I.width,da=I.height;I=x-h;X=y-k;if(m.gridSnapping){I=Ja(I);X=Ja(X);da=Ja(da);xa=
Ja(xa)}var ka=sa(F);if(ka){var oa=Math.sqrt(I*I+X*X);X=Math.atan2(X,I)-ka*Math.PI/180;I=oa*Math.cos(X);X=oa*Math.sin(X)}if(rb.indexOf("n")==-1&&rb.indexOf("s")==-1)X=0;if(rb.indexOf("e")==-1&&rb.indexOf("w")==-1)I=0;var za=oa=0,kb=da?(da+X)/da:1,ob=xa?(xa+I)/xa:1;if(rb.indexOf("n")>=0){kb=da?(da-X)/da:1;za=da}if(rb.indexOf("w")>=0){ob=xa?(xa-I)/xa:1;oa=xa}I=e.createSVGTransform();X=e.createSVGTransform();xa=e.createSVGTransform();if(m.gridSnapping){N=Ja(N);oa=Ja(oa);pa=Ja(pa);za=Ja(za)}I.setTranslate(-(N+
oa),-(pa+za));if(C.shiftKey)if(ob==1)ob=kb;else kb=ob;X.setScale(ob,kb);xa.setTranslate(N+oa,pa+za);if(R){R=ka?1:0;L.replaceItem(I,2+R);L.replaceItem(X,1+R);L.replaceItem(xa,0+R)}else{R=L.numberOfItems;L.replaceItem(xa,R-3);L.replaceItem(X,R-2);L.replaceItem(I,R-1)}Pa.requestSelector(F).resize();H("transition",K);break;case "zoom":I*=q;N*=q;aa(Wa,{x:Math.min(v*q,I),y:Math.min(s*q,N),width:Math.abs(I-v*q),height:Math.abs(N-s*q)},100);break;case "text":aa(L,{x:x,y:y},1E3);break;case "line":I=null;window.opera||
e.suspendRedraw(1E3);if(m.gridSnapping){x=Ja(x);y=Ja(y)}N=x;R=y;if(C.shiftKey){R=ea(h,k,N,R);N=R.x;R=R.y}L.setAttributeNS(null,"x2",N);L.setAttributeNS(null,"y2",R);window.opera||e.unsuspendRedraw(I);break;case "foreignObject":case "square":case "rect":case "image":I=Math.abs(x-h);R=Math.abs(y-k);if(Ia=="square"||C.shiftKey){I=R=Math.max(I,R);N=h<x?h:h-I;pa=k<y?k:k-R}else{N=Math.min(h,x);pa=Math.min(k,y)}if(C.altKey){I*=2;R*=2;N=h-I/2;pa=k-R/2}if(m.gridSnapping){I=Ja(I);R=Ja(R);N=Ja(N);pa=Ja(pa)}aa(L,
{width:I,height:R,x:N,y:pa},1E3);break;case "circle":I=$(L).attr(["cx","cy"]);R=I.cx;N=I.cy;I=Math.sqrt((x-R)*(x-R)+(y-N)*(y-N));if(m.gridSnapping)I=Ja(I);L.setAttributeNS(null,"r",I);break;case "ellipse":$(L).attr(["cx","cy"]);R=Math.abs(h+(x-h)/2);N=Math.abs(k+(y-k)/2);I=null;window.opera||e.suspendRedraw(1E3);if(m.gridSnapping){x=Ja(x);R=Ja(R);y=Ja(y);N=Ja(N)}pa=Math.abs(h-R);X=Math.abs(k-N);if(C.shiftKey){X=pa;N=y>k?k+pa:k-pa}if(C.altKey){R=h;N=k;pa=Math.abs(x-R);X=C.shiftKey?pa:Math.abs(y-N)}L.setAttributeNS(null,
"rx",pa);L.setAttributeNS(null,"ry",X);L.setAttributeNS(null,"cx",R);L.setAttributeNS(null,"cy",N);window.opera||e.unsuspendRedraw(I);break;case "fhellipse":case "fhrect":z.minx=Math.min(I,z.minx);z.maxx=Math.max(I,z.maxx);z.miny=Math.min(N,z.miny);z.maxy=Math.max(N,z.maxy);case "fhpath":g+=+I+","+N+" ";L.setAttributeNS(null,"points",g);break;case "path":case "pathedit":x*=q;y*=q;if(m.gridSnapping){x=Ja(x);y=Ja(y);h=Ja(h);k=Ja(k)}if(C.shiftKey){if(R=svgedit.path.path){L=R.dragging?R.dragging[0]:h;
R=R.dragging?R.dragging[1]:k}else{L=h;R=k}R=ea(L,R,x,y);x=R.x;y=R.y}if(Wa&&Wa.getAttribute("display")!=="none"){I*=q;N*=q;aa(Wa,{x:Math.min(v*q,I),y:Math.min(s*q,N),width:Math.abs(I-v*q),height:Math.abs(N-s*q)},100)}Ua.mouseMove(C,x,y);break;case "textedit":x*=q;y*=q;qb.mouseMove(D,E);break;case "rotate":I=svgedit.utilities.getBBox(F);R=I.x+I.width/2;N=I.y+I.height/2;L=ga(F);L=Q(R,N,L);R=L.x;N=L.y;L=I.x;pa=I.y;if(current_rotate_mode=="nw")L=I.x+I.width;if(current_rotate_mode=="se")pa=I.y+I.height;
if(current_rotate_mode=="sw"){L=I.x+I.width;pa=I.y+I.height}compensation_angle=(Math.atan2(N-pa,R-L)*(180/Math.PI)-90)%360;ka=(Math.atan2(N-y,R-x)*(180/Math.PI)-90)%360;ka+=compensation_angle;if(m.gridSnapping)ka=Ja(ka);if(C.shiftKey)ka=Math.round(ka/45)*45;b.setRotationAngle(ka<-180?360+ka:ka,true);H("transition",K)}nb("mouseMove",{event:C,mouse_x:D,mouse_y:E,selected:F})}}).click(function(C){C.preventDefault();return false}).dblclick(function(C){var F=C.target.parentNode;if(F!==M){var E=ac(C),D=
E.tagName;if(D==="text"&&Ia!=="textedit"){C=Q(C.pageX,C.pageY,Pb);qb.select(E,C.x,C.y)}if((D==="g"||D==="a")&&sa(E)){bc(E);E=K[0];cb(true)}M&&cc();F.tagName!=="g"&&F.tagName!=="a"||F===w().getCurrentLayer()||E===Pa.selectorParentGroup||oc(E)}}).mouseup(function(C){if(C.button!==2){var F=La;La=null;if(Sa){var E=Q(C.pageX,C.pageY,Pb),D=E.x*q;E=E.y*q;var L=D/q,I=E/q,N=ta(va()),X=false;Sa=false;switch(Ia){case "resize":case "multiselect":if(Wa!=null){Wa.setAttribute("display","none");jb=[]}Ia="select";
case "select":if(K[0]!=null){if(K[1]==null){D=K[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:hb.fill=D.getAttribute("fill");hb.fill_opacity=D.getAttribute("fill-opacity");hb.stroke=D.getAttribute("stroke");hb.stroke_opacity=D.getAttribute("stroke-opacity");hb.stroke_width=D.getAttribute("stroke-width");hb.stroke_dasharray=D.getAttribute("stroke-dasharray");hb.stroke_linejoin=D.getAttribute("stroke-linejoin");hb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName==
"text"){mb.font_size=D.getAttribute("font-size");mb.font_family=D.getAttribute("font-family")}Pa.requestSelector(D).showGrips(true)}Za();if(L!=v||I!=s){C=K.length;for(D=0;D<C;++D){if(K[D]==null)break;K[D].firstChild||Pa.requestSelector(K[D]).resize()}}else{D=C.target;if(K[0].nodeName==="path"&&K[1]==null)Ua.select(K[0]);else C.shiftKey&&F!=D&&b.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(C=K[0]){C.removeAttribute("style");svgedit.utilities.walkTree(C,function(xa){xa.removeAttribute("style")})}}return;
case "zoom":Wa!=null&&Wa.setAttribute("display","none");H("zoomed",{x:Math.min(v,L),y:Math.min(s,I),width:Math.abs(L-v),height:Math.abs(I-s),factor:C.altKey?0.5:2});return;case "fhpath":F=N.getAttribute("points");L=F.indexOf(",");if(X=L>=0?F.indexOf(",",L+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)N=Ua.smoothPolylineIntoPath(N);break;case "line":F=$(N).attr(["x1","x2","y1","y2"]);X=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(N).attr(["width","height"]);
X=F.width!=0||F.height!=0||Ia==="image";break;case "circle":X=N.getAttribute("r")!=0;break;case "ellipse":F=$(N).attr(["rx","ry"]);X=F.rx!=null||F.ry!=null;break;case "fhellipse":if(z.maxx-z.minx>0&&z.maxy-z.miny>0){N=fa({element:"ellipse",curStyles:true,attr:{cx:(z.minx+z.maxx)/2,cy:(z.miny+z.maxy)/2,rx:(z.maxx-z.minx)/2,ry:(z.maxy-z.miny)/2,id:va()}});H("changed",[N]);X=true}break;case "fhrect":if(z.maxx-z.minx>0&&z.maxy-z.miny>0){N=fa({element:"rect",curStyles:true,attr:{x:z.minx,y:z.miny,width:z.maxx-
z.minx,height:z.maxy-z.miny,id:va()}});H("changed",[N]);X=true}break;case "text":X=true;Sb([N]);qb.start(N);break;case "path":N=null;Sa=true;F=Ua.mouseUp(C,N,D,E);N=F.element;X=F.keep;break;case "pathedit":X=true;N=null;Ua.mouseUp(C);break;case "textedit":X=false;N=null;qb.mouseUp(C,D,E);break;case "rotate":X=true;N=null;Ia="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||Ha(F);Za();H("changed",K)}D=nb("mouseUp",{event:C,mouse_x:D,mouse_y:E},true);$.each(D,function(xa,da){if(da){X=da.keep||
X;N=da.element;Sa=da.started||Sa}});if(!X&&N!=null){w().releaseId(va());N.parentNode.removeChild(N);N=null;for(D=C.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Ia!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&D.id!="svgcanvas"&&D.id!="svgroot"){b.setMode("select");Sb([D],true)}}else if(N!=null){b.addedNew=true;C=0.2;var R;if(false.beginElement&&N.getAttribute("opacity")!=P.opacity){R=$(false).clone().attr({to:P.opacity,dur:C}).appendTo(N);try{R[0].beginElement()}catch(pa){}}else C=
0;setTimeout(function(){R&&R.remove();N.setAttribute("opacity",P.opacity);N.setAttribute("style","pointer-events:inherit");ma(N);if(Ia==="path")Ua.toEditMode(N);else m.selectNew&&Sb([N],true);Ha(new Qa(N));H("changed",[N])},C*1E3)}gb=null}}});$(a).bind("mousewheel DOMMouseScroll",function(C){if(C.shiftKey){C.preventDefault();Pb=l.getScreenCTM().inverse();var F=Q(C.pageX,C.pageY,Pb);F={x:F.x,y:F.y,width:0,height:0};if(C.wheelDelta)if(C.wheelDelta>=120)F.factor=2;else{if(C.wheelDelta<=-120)F.factor=
0.5}else if(C.detail)if(C.detail>0)F.factor=0.5;else if(C.detail<0)F.factor=2;F.factor&&H("zoomed",F)}})})();var Lb=function(g){$(g).click(function(h){h.preventDefault()})},qb=b.textActions=function(){function g(da){var ka=F.value==="";$(F).focus();if(!arguments.length)if(ka)da=0;else{if(F.selectionEnd!==F.selectionStart)return;da=F.selectionEnd}var oa;oa=I[da];ka||F.setSelectionRange(da,da);E=ta("text_cursor");if(!E){E=document.createElementNS(c,"line");aa(E,{id:"text_cursor",stroke:"#333","stroke-width":1});
E=ta("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var za=E.getAttribute("display")==="none";E.setAttribute("display",za?"inline":"none")},600));ka=G(oa.x,N.y);oa=G(oa.x,N.y+N.height);aa(E,{x1:ka.x,y1:ka.y,x2:oa.x,y2:oa.y,visibility:"visible",display:"inline"});D&&D.setAttribute("d","")}function h(da,ka,oa){if(da===ka)g(ka);else{oa||F.setSelectionRange(da,ka);D=ta("text_selectblock");if(!D){D=document.createElementNS(c,"path");aa(D,{id:"text_selectblock",fill:"green",opacity:0.5,
style:"pointer-events:none"});ta("selectorParentGroup").appendChild(D)}da=I[da];var za=I[ka];E.setAttribute("visibility","hidden");ka=G(da.x,N.y);oa=G(da.x+(za.x-da.x),N.y);var kb=G(da.x,N.y+N.height);da=G(da.x+(za.x-da.x),N.y+N.height);aa(D,{d:"M"+ka.x+","+ka.y+" L"+oa.x+","+oa.y+" "+da.x+","+da.y+" "+kb.x+","+kb.y+"z",display:"inline"})}}function k(da,ka){var oa=e.createSVGPoint();oa.x=da;oa.y=ka;if(I.length==1)return 0;oa=C.getCharNumAtPosition(oa);if(oa<0){oa=I.length-2;if(da<=I[0].x)oa=0}else if(oa>=
I.length-2)oa=I.length-2;var za=I[oa];da>za.x+za.width/2&&oa++;return oa}function v(da,ka,oa){var za=F.selectionStart;da=k(da,ka);h(Math.min(za,da),Math.max(za,da),!oa)}function s(da,ka){var oa={x:da,y:ka};oa.x/=q;oa.y/=q;if(X){var za=Q(oa.x,oa.y,X.inverse());oa.x=za.x;oa.y=za.y}return oa}function G(da,ka){var oa={x:da,y:ka};if(X){var za=Q(oa.x,oa.y,X);oa.x=za.x;oa.y=za.y}oa.x*=q;oa.y*=q;return oa}function z(da){h(0,C.textContent.length);$(this).unbind(da)}function A(da){if(xa&&C){var ka=Q(da.pageX,
da.pageY,Pb);ka=s(ka.x*q,ka.y*q);ka=k(ka.x,ka.y);var oa=C.textContent,za=oa.substr(0,ka).replace(/[a-z0-9]+$/i,"").length;oa=oa.substr(ka).match(/^[a-z0-9]+/i);h(za,(oa?oa[0].length:0)+ka);$(da.target).click(z);setTimeout(function(){$(da.target).unbind("click",z)},300)}}var C,F,E,D,L,I=[],N,X,R,pa,xa;return{select:function(da,ka,oa){C=da;qb.toEditMode(ka,oa)},start:function(da){C=da;qb.toEditMode()},mouseDown:function(da,ka,oa,za){da=s(oa,za);F.focus();g(k(da.x,da.y));R=oa;pa=za},mouseMove:function(da,
ka){var oa=s(da,ka);v(oa.x,oa.y)},mouseUp:function(da,ka,oa){var za=s(ka,oa);v(za.x,za.y,true);da.target!==C&&ka<R+2&&ka>R-2&&oa<pa+2&&oa>pa-2&&qb.toSelectMode(true)},setCursor:g,toEditMode:function(da,ka){xa=false;Ia="textedit";Pa.requestSelector(C).showGrips(false);Pa.requestSelector(C);qb.init();$(C).css("cursor","text");if(arguments.length){var oa=s(da,ka);g(k(oa.x,oa.y))}else g();setTimeout(function(){xa=true},300)},toSelectMode:function(da){Ia="select";clearInterval(L);L=null;D&&$(D).attr("display",
"none");E&&$(E).attr("visibility","hidden");$(C).css("cursor","move");if(da){cb();$(C).css("cursor","move");H("selected",[C]);Nb([C],true)}C&&!C.textContent.length&&b.deleteSelectedElements();$(F).blur();C=false},setInputElem:function(da){F=da},clear:function(){Ia=="textedit"&&qb.toSelectMode()},init:function(){if(C){if(!C.parentNode){C=K[0];Pa.requestSelector(C).showGrips(false)}var da=C.textContent.length,ka=C.getAttribute("transform");N=svgedit.utilities.getBBox(C);X=ka?ga(C):null;I=Array(da);
F.focus();$(C).unbind("dblclick",A).dblclick(A);if(!da)var oa={x:N.x+N.width/2,width:0};for(ka=0;ka<da;ka++){var za=C.getStartPositionOfChar(ka);oa=C.getEndPositionOfChar(ka);if(!svgedit.browser.supportsGoodTextCharPos()){var kb=b.contentW*q;za.x-=kb;oa.x-=kb;za.x/=q;oa.x/=q}I[ka]={x:za.x,y:N.y,width:oa.x-za.x,height:N.height}}I.push({x:oa.x,width:0});h(F.selectionStart,F.selectionEnd,true)}}}}(),Ua=b.pathActions=function(){var g=false,h,k,v;svgedit.path.Path.prototype.endChanges=function(z){if(svgedit.browser.isWebkit()){var A=
this.elem;A.setAttribute("d",Ua.convertPath(A))}z=new Xa(this.elem,{d:this.last_d},z);Ha(z);H("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(z){$.isArray(z)||(z=[z]);for(var A=0;A<z.length;A++){var C=z[A],F=this.segs[C];F.ptgrip&&this.selected_pts.indexOf(C)==-1&&C>=0&&this.selected_pts.push(C)}this.selected_pts.sort();A=this.selected_pts.length;for(z=Array(A);A--;){F=this.segs[this.selected_pts[A]];F.select(true);z[A]=F.ptgrip}Ua.canDeleteNodes=true;Ua.closed_subpath=
this.subpathIsClosed(this.selected_pts[0]);H("selected",z)};var s=h=null,G=false;return{mouseDown:function(z,A,C,F){if(Ia==="path"){mouse_x=C;mouse_y=F;F=mouse_x/q;A=mouse_y/q;C=ta("path_stretch_line");k=[F,A];if(m.gridSnapping){F=Ja(F);A=Ja(A);mouse_x=Ja(mouse_x);mouse_y=Ja(mouse_y)}if(!C){C=document.createElementNS(c,"path");aa(C,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});C=ta("selectorParentGroup").appendChild(C)}C.setAttribute("display","inline");var E=null;if(s){E=
s.pathSegList;for(var D=E.numberOfItems,L=6/q,I=false;D;){D--;var N=E.getItem(D),X=N.x;N=N.y;if(F>=X-L&&F<=X+L&&A>=N-L&&A<=N+L){I=true;break}}L=va();svgedit.path.removePath_(L);L=ta(L);X=E.numberOfItems;if(I){if(D<=1&&X>=2){F=E.getItem(0).x;A=E.getItem(0).y;z=C.pathSegList.getItem(1);z=z.pathSegType===4?s.createSVGPathSegLinetoAbs(F,A):s.createSVGPathSegCurvetoCubicAbs(F,A,z.x1/q,z.y1/q,F,A);F=s.createSVGPathSegClosePath();E.appendItem(z);E.appendItem(F)}else if(X<3)return E=false;$(C).remove();element=
L;s=null;Sa=false;if(g){svgedit.path.path.matrix&&xb(L,{},svgedit.path.path.matrix.inverse());C=L.getAttribute("d");z=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",z+C);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ua.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,ac(z))){console.log("Clicked outside canvas");return false}E=s.pathSegList.numberOfItems;D=s.pathSegList.getItem(E-
1);L=D.x;D=D.y;if(z.shiftKey){z=ea(L,D,F,A);F=z.x;A=z.y}z=C.pathSegList.getItem(1);z=z.pathSegType===4?s.createSVGPathSegLinetoAbs(Gb(F),Gb(A)):s.createSVGPathSegCurvetoCubicAbs(Gb(F),Gb(A),z.x1/q,z.y1/q,z.x2/q,z.y2/q);s.pathSegList.appendItem(z);F*=q;A*=q;C.setAttribute("d",["M",F,A,F,A].join(" "));C=E;if(g)C+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(C,F,A)}}else{d_attr="M"+F+","+A+" ";s=fa({element:"path",curStyles:true,attr:{d:d_attr,id:O(),opacity:P.opacity/2}});C.setAttribute("d",
["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));C=g?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(C,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=z.target.id;if(L.substr(0,14)=="pathpointgrip_"){A=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[C,F];E=svgedit.path.path.segs[A];if(z.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(A):svgedit.path.path.addPtsToSelection(A);else{if(svgedit.path.path.selected_pts.length<=
1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(A)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[C,F];z=L.split("_")[1].split("c");A=z[0]-0;svgedit.path.path.selectPt(A,z[1]-0)}if(!svgedit.path.path.dragging){if(Wa==null)Wa=Pa.getRubberBandBox();aa(Wa,{x:C*q,y:F*q,width:0,height:0,display:"inline"},100)}}},mouseMove:function(z,A,C){G=true;if(Ia==="path"){if(s){var F=s.pathSegList;z=F.numberOfItems-1;if(k){var E=svgedit.path.addCtrlGrip("1c1"),
D=svgedit.path.addCtrlGrip("0c2");D.getAttribute("cx");D.getAttribute("cy");E.setAttribute("cx",A);E.setAttribute("cy",C);E.setAttribute("display","inline");E=k[0];var L=k[1];F.getItem(z);var I=E+(E-A/q),N=L+(L-C/q);D.setAttribute("cx",I*q);D.setAttribute("cy",N*q);D.setAttribute("display","inline");D=svgedit.path.getCtrlLine(1);var X=svgedit.path.getCtrlLine(2);aa(D,{x1:A,y1:C,x2:E*q,y2:L*q,display:"inline"});aa(X,{x1:I*q,y1:N*q,x2:E*q,y2:L*q,display:"inline"});if(z===0)v=[A,C];else{F=F.getItem(z-
1);A=F.x;C=F.y;if(F.pathSegType===6){A+=A-F.x2;C+=C-F.y2}else if(v){A=v[0]/q;C=v[1]/q}svgedit.path.replacePathSeg(6,z,[E,L,A,C,I,N],s)}}else if(E=ta("path_stretch_line")){z=F.getItem(z);if(z.pathSegType===6)svgedit.path.replacePathSeg(6,1,[A,C,(z.x+(z.x-z.x2))*q,(z.y+(z.y-z.y2))*q,A,C],E);else v?svgedit.path.replacePathSeg(6,1,[A,C,v[0],v[1],A,C],E):svgedit.path.replacePathSeg(4,1,[A,C],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},
svgedit.path.path);L=svgedit.path.getPointFromGrip({x:A,y:C},svgedit.path.path);z=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[A,C];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(z,E):svgedit.path.path.movePts(z,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var R=Wa.getBBox(),pa=svgedit.path.getGripPt(this);R=svgedit.math.rectsIntersect(R,{x:pa.x,y:pa.y,width:0,height:0});this.select(R);R&&svgedit.path.path.selected_pts.push(this.index)}})}},
mouseUp:function(z,A){if(Ia==="path"){k=null;if(!s){A=ta(va());Sa=false;v=null}return{keep:true,element:A}}if(svgedit.path.path.dragging){var C=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!z.shiftKey&&!G&&svgedit.path.path.selectPt(C)}else if(Wa&&Wa.getAttribute("display")!="none"){Wa.setAttribute("display","none");Wa.getAttribute("width")<=2&&Wa.getAttribute("height")<=
2&&Ua.toSelectMode(z.target)}else Ua.toSelectMode(z.target);G=false},toEditMode:function(z){svgedit.path.path=svgedit.path.getPath_(z);Ia="pathedit";cb();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);g=false},toSelectMode:function(z){var A=z==svgedit.path.path.elem;Ia="select";svgedit.path.path.show(false);h=false;cb();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(A){H("selected",[z]);Nb([z],true)}},addSubPath:function(z){if(z){Ia=
"path";g=true}else{Ua.clear(true);Ua.toEditMode(svgedit.path.path.elem)}},select:function(z){if(h===z){Ua.toEditMode(z);Ia="pathedit"}else h=z},reorient:function(){var z=K[0];if(z)if(sa(z)!=0){var A=new Na("Reorient path"),C={d:z.getAttribute("d"),transform:z.getAttribute("transform")};A.addSubCommand(new Xa(z,C));cb();this.resetOrientation(z);Ha(A);svgedit.path.getPath_(z).show(false).matrix=null;this.clear();Nb([z],true);H("changed",K)}},clear:function(){h=null;if(s){var z=ta(va());$(ta("path_stretch_line")).remove();
$(z).remove();$(ta("pathpointgrip_container")).find("*").attr("display","none");s=v=null;Sa=false}else Ia=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(z){if(z==null||z.nodeName!="path")return false;var A=W(z),C=ia(A).matrix;A.clear();z.removeAttribute("transform");A=z.pathSegList;for(var F=A.numberOfItems,E=0;E<F;++E){var D=A.getItem(E),L=D.pathSegType;if(L!=1){var I=[];$.each(["",1,2],function(N,X){var R=D["x"+X],pa=D["y"+X];
if(R!==undefined&&pa!==undefined){R=Q(R,pa,C);I.splice(I.length,0,R.x,R.y)}});svgedit.path.replacePathSeg(L,E,I,z)}}f(z,C)},zoomChange:function(){Ia=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var z=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:z.item.x,y:z.item.y,type:z.type}},linkControlPoints:function(z){svgedit.path.setLinkControlPoints(z)},clonePathNode:function(){svgedit.path.path.storeD();for(var z=svgedit.path.path.selected_pts,
A=z.length,C=[];A--;){var F=z[A];svgedit.path.path.addSeg(F);C.push(F+A);C.push(F+A+1)}svgedit.path.path.init().addPtsToSelection(C);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var z=svgedit.path.path.selected_pts;if(z.length===1){var A=svgedit.path.path.elem,C=A.pathSegList,F=z[0],E=null,D=null;svgedit.path.path.eachSeg(function(X){if(this.type===2&&X<=F)D=this.item;if(X<=F)return true;if(this.type===2){E=X;return false}else if(this.type===1)return E=false});if(E==
null)E=svgedit.path.path.segs.length-1;if(E!==false){var L=A.createSVGPathSegLinetoAbs(D.x,D.y),I=A.createSVGPathSegClosePath();if(E==svgedit.path.path.segs.length-1){C.appendItem(L);C.appendItem(I)}else{svgedit.path.insertItemBefore(A,I,E);svgedit.path.insertItemBefore(A,L,E)}svgedit.path.path.init().selectPt(E+1)}else if(svgedit.path.path.segs[F].mate){C.removeItem(F);C.removeItem(F);svgedit.path.path.init().selectPt(F-1)}else{for(z=0;z<C.numberOfItems;z++){var N=C.getItem(z);if(N.pathSegType===
2)L=z;else if(z===F)C.removeItem(L);else if(N.pathSegType===1&&F<z){I=z-1;C.removeItem(z);break}}for(z=F-L-1;z--;)svgedit.path.insertItemBefore(A,C.getItem(L),I);A=C.getItem(L);svgedit.path.replacePathSeg(2,L,[A.x,A.y]);z=F;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ua.canDeleteNodes){svgedit.path.path.storeD();for(var z=svgedit.path.path.selected_pts,A=z.length;A--;)svgedit.path.path.deleteSeg(z[A]);var C=function(){var F=svgedit.path.path.elem.pathSegList,E=F.numberOfItems,
D=function(N,X){for(;X--;)F.removeItem(N)};if(E<=1)return true;for(;E--;){var L=F.getItem(E);if(L.pathSegType===1){L=F.getItem(E-1);var I=F.getItem(E-2);if(L.pathSegType===2){D(E-1,2);C();break}else if(I.pathSegType===2){D(E-2,3);C();break}}else if(L.pathSegType===2)if(E>0){L=F.getItem(E-1).pathSegType;if(L===2){D(E-1,1);C();break}else if(L===1&&F.numberOfItems-1===E){D(E,1);C();break}}}return false};C();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ua.toSelectMode(svgedit.path.path.elem);
b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){z=$(svgedit.path.path.elem);z.attr("d",z.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(z){var A=z.points,C=A.numberOfItems;if(C>=4){var F=A.getItem(0),E=null;z=[];z.push(["M",F.x,",",F.y," C"].join(""));for(var D=1;D<=C-4;D+=3){var L=A.getItem(D),I=A.getItem(D+1),N=A.getItem(D+2);if(E)if((F=svgedit.path.smoothControlPoints(E,L,F))&&F.length==
2){L=z[z.length-1].split(",");L[2]=F[0].x;L[3]=F[0].y;z[z.length-1]=L.join(",");L=F[1]}z.push([L.x,L.y,I.x,I.y,N.x,N.y].join(","));F=N;E=I}for(z.push("L");D<C;++D){I=A.getItem(D);z.push([I.x,I.y].join(","))}z=z.join(" ");z=fa({element:"path",curStyles:true,attr:{id:va(),d:z,fill:"none"}})}return z},setSegType:function(z){svgedit.path.path.setSegType(z)},moveNode:function(z,A){var C=svgedit.path.path.selected_pts;if(C.length){svgedit.path.path.storeD();C=svgedit.path.path.segs[C[0]];var F={x:0,y:0};
F[z]=A-C.item[z];C.move(F.x,F.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(z){for(var A=z.pathSegList,C=A.numberOfItems,F,E=0;E<C;++E){var D=A.getItem(E);if(D.pathSegType===2)F=D;if(D.pathSegType===1){D=A.getItem(E-1);if(D.x!=F.x||D.y!=F.y){A=z.createSVGPathSegLinetoAbs(F.x,F.y);svgedit.path.insertItemBefore(z,A,E);Ua.fixEnd(z);break}}}svgedit.browser.isWebkit()&&z.setAttribute("d",Ua.convertPath(z))},convertPath:function(z,A){for(var C=z.pathSegList,F=C.numberOfItems,E=0,
D=0,L="",I=null,N=0;N<F;++N){var X=C.getItem(N),R=X.x||0,pa=X.y||0,xa=X.x1||0,da=X.y1||0,ka=X.x2||0,oa=X.y2||0,za=X.pathSegType,kb=fb[za]["to"+(A?"Lower":"Upper")+"Case"](),ob=function(Vb,Mb,Rb){Mb=Mb?" "+Mb.join(" "):"";Rb=Rb?" "+svgedit.units.shortFloat(Rb):"";$.each(Vb,function(Xb,dc){Vb[Xb]=svgedit.units.shortFloat(dc)});L+=kb+Vb.join(" ")+Mb+Rb};switch(za){case 1:L+="z";break;case 12:R-=E;case 13:if(A){E+=R;kb="l"}else{R+=E;E=R;kb="L"}ob([[R,D]]);break;case 14:pa-=D;case 15:if(A){D+=pa;kb="l"}else{pa+=
D;D=pa;kb="L"}ob([[E,pa]]);break;case 2:case 4:case 18:R-=E;pa-=D;case 5:case 3:if(I&&C.getItem(N-1).pathSegType===1&&!A){E=I[0];D=I[1]}case 19:if(A){E+=R;D+=pa}else{R+=E;pa+=D;E=R;D=pa}if(za===3)I=[E,D];ob([[R,pa]]);break;case 6:R-=E;xa-=E;ka-=E;pa-=D;da-=D;oa-=D;case 7:if(A){E+=R;D+=pa}else{R+=E;xa+=E;ka+=E;pa+=D;da+=D;oa+=D;E=R;D=pa}ob([[xa,da],[ka,oa],[R,pa]]);break;case 8:R-=E;xa-=E;pa-=D;da-=D;case 9:if(A){E+=R;D+=pa}else{R+=E;xa+=E;pa+=D;da+=D;E=R;D=pa}ob([[xa,da],[R,pa]]);break;case 10:R-=
E;pa-=D;case 11:if(A){E+=R;D+=pa}else{R+=E;pa+=D;E=R;D=pa}ob([[X.r1,X.r2]],[X.angle,X.largeArcFlag?1:0,X.sweepFlag?1:0],[R,pa]);break;case 16:R-=E;ka-=E;pa-=D;oa-=D;case 17:if(A){E+=R;D+=pa}else{R+=E;ka+=E;pa+=D;oa+=D;E=R;D=pa}ob([[ka,oa],[R,pa]])}}return L}}}(),kc=this.removeUnusedDefElems=function(){var g=l.getElementsByTagNameNS(c,"defs");if(!g||!g.length)return 0;for(var h=[],k=0,v=["fill","stroke","filter","marker-start","marker-mid","marker-end"],s=v.length,G=l.getElementsByTagNameNS(c,"*"),
z=G.length,A=0;A<z;A++){for(var C=G[A],F=0;F<s;F++){var E=qa(C.getAttribute(v[F]));E&&h.push(E.substr(1))}(C=ca(C))&&C.indexOf("#")===0&&h.push(C.substr(1))}g=$(g).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(A=g.length;A--;){v=g[A];s=v.id;if(h.indexOf(s)<0){Fb[s]=v;v.parentNode.removeChild(v);k++}}return k};this.svgCanvasToString=function(){for(;kc()>0;);Ua.clear(true);$.each(l.childNodes,function(k,v){k&&v.nodeType===8&&v.data.indexOf("Created with")>=0&&
l.insertBefore(v,l.firstChild)});if(M){cc();Sb([M])}var g=[];$(l).find("g:data(gsvg)").each(function(){for(var k=this.attributes,v=k.length,s=0;s<v;s++)if(k[s].nodeName=="id"||k[s].nodeName=="style")v--;if(v<=0){k=this.firstChild;g.push(k);$(this).replaceWith(k)}});var h=this.svgToString(l,0);g.length&&$(g).each(function(){na(this)});return h};this.svgToString=function(g,h){var k=[],v=svgedit.utilities.toXml,s=m.baseUnit,G=RegExp("^-?[\\d\\.]+"+s+"$");if(g){ma(g);var z=g.attributes,A,C,F=g.childNodes;
for(C=0;C<h;C++)k.push(" ");k.push("<");k.push(g.nodeName);if(g.id==="svgcontent"){C=Yb();if(s!=="px"){C.w=svgedit.units.convertUnit(C.w,s)+s;C.h=svgedit.units.convertUnit(C.h,s)+s}k.push(' width="'+C.w+'" height="'+C.h+'" xmlns="'+c+'"');var E={};$(g).find("*").andSelf().each(function(){$.each(this.attributes,function(N,X){var R=X.namespaceURI;if(R&&!E[R]&&Ga[R]!=="xmlns"&&Ga[R]!=="xml"){E[R]=true;k.push(" xmlns:"+Ga[R]+'="'+R+'"')}})});C=z.length;for(s=["width","height","xmlns","x","y","viewBox",
"id","overflow"];C--;){A=z.item(C);var D=v(A.nodeValue);if(A.nodeName.indexOf("xmlns:")!==0)if(D!=""&&s.indexOf(A.localName)==-1)if(!A.namespaceURI||Ga[A.namespaceURI]){k.push(" ");k.push(A.nodeName);k.push('="');k.push(D);k.push('"')}}}else{if(g.nodeName==="defs"&&!g.firstChild)return;var L=["-moz-math-font-style","_moz-math-font-style"];for(C=z.length-1;C>=0;C--){A=z.item(C);D=v(A.nodeValue);if(!(L.indexOf(A.localName)>=0))if(D!="")if(D.indexOf("pointer-events")!==0)if(!(A.localName==="class"&&
D.indexOf("se_")===0)){k.push(" ");if(A.localName==="d")D=Ua.convertPath(g,true);if(isNaN(D)){if(G.test(D))D=svgedit.units.shortFloat(D)+s}else D=svgedit.units.shortFloat(D);if(bb.apply&&g.nodeName==="image"&&A.localName==="href"&&bb.images&&bb.images==="embed"){var I=Ka[D];if(I)D=I}if(!A.namespaceURI||A.namespaceURI==c||Ga[A.namespaceURI]){k.push(A.nodeName);k.push('="');k.push(D);k.push('"')}}}}if(g.hasChildNodes()){k.push(">");h++;z=false;for(C=0;C<F.length;C++){s=F.item(C);switch(s.nodeType){case 1:k.push("\n");
k.push(this.svgToString(F.item(C),h));break;case 3:s=s.nodeValue.replace(/^\s+|\s+$/g,"");if(s!=""){z=true;k.push(v(s)+"")}break;case 4:k.push("\n");k.push(Array(h+1).join(" "));k.push("<![CDATA[");k.push(s.nodeValue);k.push("]]\>");break;case 8:k.push("\n");k.push(Array(h+1).join(" "));k.push("<!--");k.push(s.data);k.push("--\>")}}h--;if(!z){k.push("\n");for(C=0;C<h;C++)k.push(" ")}k.push("</");k.push(g.nodeName);k.push(">")}else k.push("/>")}return k.join("")};this.embedImage=function(g,h){$(new Image).load(function(){var k=
document.createElement("canvas");k.width=this.width;k.height=this.height;k.getContext("2d").drawImage(this,0,0);try{var v=";svgedit_url="+encodeURIComponent(g);v=k.toDataURL().replace(";base64",v+";base64");Ka[g]=v}catch(s){Ka[g]=false}Da=g;h&&h(Ka[g])}).attr("src",g)};this.setGoodImage=function(g){Da=g};this.open=function(){};this.save=function(g){cb();g&&$.extend(bb,g);bb.apply=true;g=this.svgCanvasToString();H("saved",g)};this.rasterExport=function(){cb();var g=[],h={feGaussianBlur:Jb.exportNoBlur,
foreignObject:Jb.exportNoforeignObject,"[stroke-dasharray]":Jb.exportNoDashArray},k=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=Jb.exportNoText;$.each(h,function(v,s){k.find(v).length&&g.push(s)});h=this.svgCanvasToString();H("exported",{svg:h,issues:g})};this.getSvgString=function(){bb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,w()):svgedit.draw.randomizeIds(true,w())};var hc=this.uniquifyElems=
function(g){var h={},k=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(g,function(A){if(A.nodeType==1){if(A.id){A.id in h||(h[A.id]={elem:null,attrs:[],hrefs:[]});h[A.id].elem=A}$.each(tb,function(F,E){var D=A.getAttributeNode(E);if(D){var L=svgedit.utilities.getUrlFromAttr(D.value);if(L=L?L.substr(1):null){L in h||(h[L]={elem:null,attrs:[],hrefs:[]});h[L].attrs.push(D)}}});var C=svgedit.utilities.getHref(A);if(C&&k.indexOf(A.nodeName)>=
0)if(C=C.substr(1)){C in h||(h[C]={elem:null,attrs:[],hrefs:[]});h[C].hrefs.push(A)}}});for(var v in h)if(v){var s=h[v].elem;if(s){g=O();s.id=g;s=h[v].attrs;for(var G=s.length;G--;){var z=s[G];z.ownerElement.setAttribute(z.name,"url(#"+g+")")}s=h[v].hrefs;for(G=s.length;G--;)svgedit.utilities.setHref(s[G],"#"+g)}}},gc=this.setUseData=function(g){var h=$(g);if(g.tagName!=="use")h=h.find("use");h.each(function(){var k=ca(this).substr(1);if(k=ta(k)){$(this).data("ref",k);if(k.tagName=="symbol"||k.tagName==
"svg")$(this).data("symbol",k).data("ref",k)}})},ec=this.convertGradients=function(g){var h=$(g).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(g).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var k=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(k.length)if(k=svgedit.utilities.getBBox(k[0]))if(this.tagName==="linearGradient"){var v=$(this).attr(["x1",
"y1","x2","y2"]),s=this.gradientTransform.baseVal;if(s&&s.numberOfItems>0){var G=ia(s).matrix;s=Q(v.x1,v.y1,G);G=Q(v.x2,v.y2,G);v.x1=s.x;v.y1=s.y;v.x2=G.x;v.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(v.x1-k.x)/k.width,y1:(v.y1-k.y)/k.height,x2:(v.x2-k.x)/k.width,y2:(v.y2-k.y)/k.height});this.removeAttribute("gradientUnits")}}})},ic=this.convertToGroup=function(g){g||(g=K[0]);var h=$(g),k=new Na,v;if(h.data("gsvg")){k=$(g.firstChild).attr(["x","y"]);$(g.firstChild.firstChild).unwrap();
$(g).removeData("gsvg");v=W(g);var s=e.createSVGTransform();s.setTranslate(k.x,k.y);v.appendItem(s);pb(g);H("selected",[g])}else if(h.data("symbol")){g=h.data("symbol");v=h.attr("transform");s=h.attr(["x","y"]);var G=g.getAttribute("viewBox");if(G){G=G.split(" ");s.x-=+G[0];s.y-=+G[1]}v+=" translate("+(s.x||0)+","+(s.y||0)+")";s=h.prev();k.addSubCommand(new Va(h[0],h[0].nextSibling,h[0].parentNode));h.remove();G=$(l).find("use:data(symbol)").length;h=d.createElementNS(c,"g");for(var z=g.childNodes,
A=0;A<z.length;A++)h.appendChild(z[A].cloneNode(true));if(svgedit.browser.isGecko()){z=$(Bb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(z)}v&&h.setAttribute("transform",v);v=g.parentNode;hc(h);svgedit.browser.isGecko()&&$(Bb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=O();s.after(h);if(v){if(!G){s=g.nextSibling;v.removeChild(g);k.addSubCommand(new Va(g,s,v))}k.addSubCommand(new Qa(h))}gc(h);svgedit.browser.isGecko()?ec(Bb()):ec(h);svgedit.utilities.walkTreePost(h,
function(C){try{pb(C)}catch(F){console.log(F)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=O()});Sb([h]);(g=bc(h,true))&&k.addSubCommand(g);Ha(k)}else console.log("Unexpected element to ungroup:",g)};this.setSvgString=function(g){try{var h=svgedit.utilities.text2xml(g);this.prepareSvg(h);var k=new Na("Change Source"),v=l.nextSibling,s=e.removeChild(l);k.addSubCommand(new Va(s,v,e));l=d.adoptNode?d.adoptNode(h.documentElement):
d.importNode(h.documentElement,true);e.appendChild(l);var G=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,u);var z=w().getNonce();z?H("setnonce",z):H("unsetnonce");G.find("image").each(function(){var I=this;Lb(I);var N=ca(this);if(N.indexOf("data:")===0){var X=N.match(/svgedit_url=(.*?);/);if(X){var R=decodeURIComponent(X[1]);$(new Image).load(function(){I.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",R)}).attr("src",R)}}b.embedImage(N)});G.find("svg").each(function(){if(!$(this).closest("defs").length){hc(this);
var I=this.parentNode;if(I.childNodes.length===1&&I.nodeName==="g"){$(I).data("gsvg",this);I.id=I.id||O()}else na(this)}});svgedit.browser.isGecko()&&G.find("linearGradient, radialGradient, pattern").appendTo(Bb());gc(G);ec(G[0]);svgedit.utilities.walkTreePost(l,function(I){try{pb(I)}catch(N){console.log(N)}});var A={id:"svgcontent",overflow:m.show_outside_canvas?"visible":"hidden"},C=false;if(G.attr("viewBox")){var F=G.attr("viewBox").split(" ");A.width=F[2];A.height=F[3]}else $.each(["width","height"],
function(I,N){var X=G.attr(N);X||(X="100%");if((X+"").substr(-1)==="%")C=true;else A[N]=ra(N,X)});Tb();G.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=O()});if(C){var E=getStrokedBBox();A.width=E.width+E.x;A.height=E.height+E.y}if(A.width<=0)A.width=100;if(A.height<=0)A.height=100;G.attr(A);this.contentW=A.width;this.contentH=A.height;k.addSubCommand(new Qa(l));var D=G.attr(["width","height"]);k.addSubCommand(new Xa(e,
D));q=1;svgedit.transformlist.resetListMap();cb();svgedit.path.clearData();e.appendChild(Pa.selectorParentGroup);Ha(k);H("changed",[l])}catch(L){console.log(L);return false}return true};this.importSvgString=function(g){try{var h=svgedit.utilities.encode64(g.length+g).substr(0,32),k=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)k=true;var v=new Na("Import SVG");if(k)var s=sb[h].symbol,G=sb[h].xform;else{var z=svgedit.utilities.text2xml(g);this.prepareSvg(z);var A;A=d.adoptNode?d.adoptNode(z.documentElement):
d.importNode(z.documentElement,true);hc(A);var C=ra("width",A.getAttribute("width")),F=ra("height",A.getAttribute("height")),E=A.getAttribute("viewBox"),D=E?E.split(" "):[0,0,C,F];for(g=0;g<4;++g)D[g]=+D[g];l.getAttribute("width");var L=+l.getAttribute("height");G=F>C?"scale("+L/3/D[3]+")":"scale("+L/3/D[2]+")";G="translate(0) "+G+" translate(0)";s=d.createElementNS(c,"symbol");var I=Bb();for(svgedit.browser.isGecko()&&$(A).find("linearGradient, radialGradient, pattern").appendTo(I);A.firstChild;)s.appendChild(A.firstChild);
var N=A.attributes;for(A=0;A<N.length;A++){var X=N[A];s.setAttribute(X.nodeName,X.nodeValue)}s.id=O();sb[h]={symbol:s,xform:G};Bb().appendChild(s);v.addSubCommand(new Qa(s))}var R=d.createElementNS(c,"use");R.id=O();T(R,"#"+s.id);(M||w().getCurrentLayer()).appendChild(R);v.addSubCommand(new Qa(R));cb();R.setAttribute("transform",G);pb(R);$(R).data("symbol",s).data("ref",s);Nb([R]);Ha(v);H("changed",[l])}catch(pa){console.log(pa);return false}return true};var Tb=b.identifyLayers=function(){cc();w().identifyLayers()};
this.createLayer=function(g){var h=new Na("Create Layer");g=w().createLayer(g);h.addSubCommand(new Qa(g));Ha(h);cb();H("changed",[g])};this.cloneLayer=function(g){var h=new Na("Duplicate Layer"),k=d.createElementNS(c,"g"),v=d.createElementNS(c,"title");v.textContent=g;k.appendChild(v);v=w().getCurrentLayer();$(v).after(k);v=v.childNodes;for(var s=0;s<v.length;s++){var G=v[s];G.localName!="title"&&k.appendChild(ba(G))}cb();Tb();h.addSubCommand(new Qa(k));Ha(h);b.setCurrentLayer(g);H("changed",[k])};
this.deleteCurrentLayer=function(){var g=w().getCurrentLayer(),h=g.nextSibling,k=g.parentNode;if(g=w().deleteCurrentLayer()){var v=new Na("Delete Layer");v.addSubCommand(new Va(g,h,k));Ha(v);cb();H("changed",[k]);return true}return false};this.setCurrentLayer=function(g){(g=w().setCurrentLayer(svgedit.utilities.toXml(g)))&&cb();return g};this.renameCurrentLayer=function(g){var h=w();if(h.current_layer){var k=h.current_layer;if(!b.setCurrentLayer(g)){for(var v=new Na("Rename Layer"),s=0;s<h.getNumLayers();++s)if(h.all_layers[s][1]==
k)break;var G=h.getLayerName(s);h.all_layers[s][0]=svgedit.utilities.toXml(g);var z=k.childNodes.length;for(s=0;s<z;++s){var A=k.childNodes.item(s);if(A&&A.tagName=="title"){for(;A.firstChild;)A.removeChild(A.firstChild);A.textContent=g;v.addSubCommand(new Xa(A,{"#text":G}));Ha(v);H("changed",[k]);return true}}}h.current_layer=k}return false};this.setCurrentLayerPosition=function(g){var h=w();if(h.current_layer&&g>=0&&g<h.getNumLayers()){for(var k=0;k<h.getNumLayers();++k)if(h.all_layers[k][1]==h.current_layer)break;
if(k==h.getNumLayers())return false;if(k!=g){var v=null,s=h.current_layer.nextSibling;if(g>k){if(g<h.getNumLayers()-1)v=h.all_layers[g+1][1]}else v=h.all_layers[g][1];l.insertBefore(h.current_layer,v);Ha(new Ra(h.current_layer,s,l));Tb();b.setCurrentLayer(h.getLayerName(g));return true}}return false};this.setLayerVisibility=function(g,h){var k=w(),v=k.getLayerVisibility(g),s=k.setLayerVisibility(g,h);if(s)Ha(new Xa(s,{display:v?"inline":"none"},"Layer Visibility"));else return false;if(s==k.getCurrentLayer()){cb();
Ua.clear()}return true};this.moveSelectedToLayer=function(g){for(var h=null,k=w(),v=0;v<k.getNumLayers();++v)if(k.getLayerName(v)==g){h=k.all_layers[v][1];break}if(!h)return false;g=new Na("Move Elements to Layer");k=K;for(v=k.length;v--;){var s=k[v];if(s){var G=s.nextSibling,z=s.parentNode;h.appendChild(s);g.addSubCommand(new Ra(s,G,z))}}Ha(g);return true};this.mergeLayer=function(g){var h=new Na("Merge Layer"),k=w(),v=$(k.current_layer).prev()[0];if(v){for(h.addSubCommand(new Va(k.current_layer,
k.current_layer.nextSibling,l));k.current_layer.firstChild;){var s=k.current_layer.firstChild;if(s.localName=="title"){h.addSubCommand(new Va(s,s.nextSibling,k.current_layer));k.current_layer.removeChild(s)}else{var G=s.nextSibling;v.appendChild(s);h.addSubCommand(new Ra(s,G,k.current_layer))}}l.removeChild(k.current_layer);if(!g){cb();Tb();H("changed",[l]);Ha(h)}k.current_layer=v;return h}};this.mergeAllLayers=function(){var g=new Na("Merge all Layers"),h=w();for(h.current_layer=h.all_layers[h.getNumLayers()-
1][1];$(l).children("g").length>1;)g.addSubCommand(b.mergeLayer(true));cb();Tb();H("changed",[l]);Ha(g)};var cc=this.leaveContext=function(){var g=yb.length;if(g){for(var h=0;h<g;h++){var k=yb[h],v=ab(k,"orig_opac");v!==1?k.setAttribute("opacity",v):k.removeAttribute("opacity");k.setAttribute("style","pointer-events: inherit")}yb=[];cb(true);H("contextset",null)}M=null},oc=this.setContext=function(g){cc();if(typeof g==="string")g=ta(g);M=g;$(g).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=
this.getAttribute("opacity")||1;ab(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style","pointer-events: none");yb.push(this)});cb();H("contextset",M)};this.clear=function(){Ua.clear();cb();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Pa.initGroup();Wa=Pa.getRubberBandBox();H("cleared")};this.linkControlPoints=Ua.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=
function(){return e};this.getSelectedElems=function(){return K};var Yb=this.getResolution=function(){var g=l.getAttribute("width")/q,h=l.getAttribute("height")/q;return{w:g,h:h,zoom:q}};this.getZoom=function(){return q};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(g){$.extend(Jb,g.notification)};this.setConfig=function(g){$.extend(m,g)};this.getTitle=function(g){if(g=g||K[0]){g=$(g).data("gsvg")||$(g).data("symbol")||g;g=g.childNodes;for(var h=0;h<g.length;h++)if(g[h].nodeName==
"title")return g[h].textContent;return""}};this.setGroupTitle=function(g){var h=K[0];h=$(h).data("gsvg")||h;var k=$(h).children("title"),v=new Na("Set Label");if(g.length)if(k.length){k=k[0];v.addSubCommand(new Xa(k,{"#text":k.textContent}));k.textContent=g}else{k=d.createElementNS(c,"title");k.textContent=g;$(h).prepend(k);v.addSubCommand(new Qa(k))}else{v.addSubCommand(new Va(k[0],k.nextSibling,h));k.remove()}Ha(v)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(g){for(var h=
l.childNodes,k=false,v="",s=new Na("Change Image Title"),G=0;G<h.length;G++)if(h[G].nodeName=="title"){k=h[G];v=k.textContent;break}if(!k){k=d.createElementNS(c,"title");l.insertBefore(k,l.firstChild)}if(g.length)k.textContent=g;else k.parentNode.removeChild(k);s.addSubCommand(new Xa(k,{"#text":v}));Ha(s)};this.getEditorNS=function(g){g&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(g,h){var k=Yb(),v=k.w;k=k.h;var s;
if(g=="fit"){var G=getStrokedBBox();if(G){s=new Na("Fit Canvas to Content");var z=Kb();Nb(z);var A=[],C=[];$.each(z,function(){A.push(G.x*-1);C.push(G.y*-1)});z=b.moveSelectedElements(A,C,true);s.addSubCommand(z);cb();g=Math.round(G.width);h=Math.round(G.height)}else return false}if(g!=v||h!=k){z=e.suspendRedraw(1E3);s||(s=new Na("Change Image Dimensions"));g=ra("width",g);h=ra("height",h);l.setAttribute("width",g);l.setAttribute("height",h);this.contentW=g;this.contentH=h;s.addSubCommand(new Xa(l,
{width:v,height:k}));l.setAttribute("viewBox",[0,0,g/q,h/q].join(" "));s.addSubCommand(new Xa(l,{viewBox:["0 0",v,k].join(" ")}));Ha(s);e.unsuspendRedraw(z);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",g+2);background.setAttribute("height",h+2)}H("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,s=function(G){if(!G)return false;
var z=Math.min(Math.round(h/G.width*100*v)/100,Math.round(k/G.height*100*v)/100);b.setZoom(z);return{zoom:z,bbox:G}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:q*g.factor);return{zoom:q,bbox:g}}return s(g)}switch(g){case "selection":if(!K[0])return;g=$.map(K,function(G){if(G)return G});g=getStrokedBBox(g);break;case "canvas":g=Yb();v=0.95;g={width:g.w,height:g.h,x:0,y:0};break;case "content":g=getStrokedBBox();break;case "layer":g=getStrokedBBox(Kb(w().getCurrentLayer()));
break;default:return}return s(g)};this.setZoom=function(g){var h=Yb();l.setAttribute("viewBox","0 0 "+h.w/g+" "+h.h/g);q=g;$.each(K,function(k,v){v&&Pa.requestSelector(v).resize()});Ua.zoomChange();nb("zoomChanged",g)};this.getMode=function(){return Ia};this.setMode=function(g){Ua.clear(true);qb.clear();$("#workarea").attr("class",g);hb=K[0]&&K[0].nodeName=="text"?mb:P;Ia=g};this.getColor=function(g){return hb[g]};this.setColor=function(g,h,k){P[g]=h;hb[g+"_paint"]={type:"solidColor"};for(var v=[],
s=K.length;s--;){var G=K[s];if(G)if(G.tagName=="g")svgedit.utilities.walkTree(G,function(z){z.nodeName!="g"&&v.push(z)});else if(g=="fill")G.tagName!="polyline"&&G.tagName!="line"&&v.push(G);else v.push(G)}if(v.length>0)if(k)vb(g,h,v);else{ub(g,h,v);H("changed",v)}};var Bb=function(){var g=l.getElementsByTagNameNS(c,"defs");if(g.length>0)g=g[0];else{g=d.createElementNS(c,"defs");l.firstChild?l.insertBefore(g,l.firstChild.nextSibling):l.appendChild(g)}return g},mc=this.setGradient=function(g){if(!(!hb[g+
"_paint"]||hb[g+"_paint"].type=="solidColor")){var h=b[g+"Grad"],k=lc(h),v=Bb();if(k)h=k;else{h=v.appendChild(d.importNode(h,true));h.id=O()}b.setColor(g,"url(#"+h.id+")");if(g=="canvas")(g=document.getElementById("canvas_background"))&&g.setAttribute("fill","url(#"+h.id+")")}},lc=function(g){var h=Bb();h=$(h).find("linearGradient, radialGradient");for(var k=h.length,v=["r","cx","cy","fx","fy"];k--;){var s=h[k];if(g.tagName=="linearGradient"){if(g.getAttribute("x1")!=s.getAttribute("x1")||g.getAttribute("y1")!=
s.getAttribute("y1")||g.getAttribute("x2")!=s.getAttribute("x2")||g.getAttribute("y2")!=s.getAttribute("y2"))continue}else{var G=$(g).attr(v),z=$(s).attr(v),A=false;$.each(v,function(I,N){if(G[N]!=z[N])A=true});if(A)continue}var C=g.getElementsByTagNameNS(c,"stop"),F=s.getElementsByTagNameNS(c,"stop");if(C.length==F.length){for(var E=C.length;E--;){var D=C[E],L=F[E];if(D.getAttribute("offset")!=L.getAttribute("offset")||D.getAttribute("stop-opacity")!=L.getAttribute("stop-opacity")||D.getAttribute("stop-color")!=
L.getAttribute("stop-color"))break}if(E==-1)return s}}return null};this.setPaint=function(g,h){var k=new $.jGraduate.Paint(h);this.setPaintOpacity(g,k.alpha/100,true);hb[g+"_paint"]=k;switch(k.type){case "solidColor":if(k.solidColor!="none"&&k.solidColor!="#none")this.setColor(g,"#"+k.solidColor);else{this.setColor(g,"none");document.querySelector(g=="fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","none")}break;case "linearGradient":case "radialGradient":b[g+"Grad"]=k[k.type];
mc(g)}};this.getStrokeWidth=function(){return hb.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Ia)>=0)b.setStrokeWidth(1);else{hb.stroke_width=g;for(var h=[],k=K.length;k--;){var v=K[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(s){s.nodeName!="g"&&h.push(s)}):h.push(v)}if(h.length>0){ub("stroke-width",g,h);H("changed",K)}}};this.setStrokeAttr=function(g,h){P[g.replace("-","_")]=h;for(var k=[],v=K.length;v--;){var s=K[v];if(s)s.tagName=="g"?svgedit.utilities.walkTree(s,
function(G){G.nodeName!="g"&&k.push(G)}):k.push(s)}if(k.length>0){ub(g,h,k);H("changed",K)}};this.getStyle=function(){return P};this.getOpacity=function(){return P.opacity};this.setOpacity=function(g){P.opacity=g;ub("opacity",g)};this.getFillOpacity=function(){return P.fill_opacity};this.getStrokeOpacity=function(){return P.stroke_opacity};this.setPaintOpacity=function(g,h,k){P[g+"_opacity"]=h;k?vb(g+"-opacity",h):ub(g+"-opacity",h)};this.getBlur=function(g){var h=0;if(g)if(g.getAttribute("filter"))if(g=
ta(g.id+"_blur"))h=g.firstChild.getAttribute("stdDeviation");return h};(function(){function g(){var s=b.undoMgr.finishUndoableChange();h.addSubCommand(s);Ha(h);k=h=null}var h=null,k=null,v=false;b.setBlurNoUndo=function(s){if(k)if(s===0){vb("filter","");v=true}else{var G=K[0];v&&vb("filter","url(#"+G.id+"_blur)");if(svgedit.browser.isWebkit()){G.removeAttribute("filter");G.setAttribute("filter","url(#"+G.id+"_blur)")}vb("stdDeviation",s,[k.firstChild]);b.setBlurOffsets(k,s)}else b.setBlur(s)};b.setBlurOffsets=
function(s,G){if(G>3)aa(s,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){s.removeAttribute("x");s.removeAttribute("y");s.removeAttribute("width");s.removeAttribute("height")}};b.setBlur=function(s,G){if(h)g();else{var z=K[0],A=z.id;k=ta(A+"_blur");s-=0;var C=new Na;if(k){if(s===0)k=null}else{var F=fa({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:s}});k=fa({element:"filter",attr:{id:A+"_blur"}});k.appendChild(F);Bb().appendChild(k);C.addSubCommand(new Qa(k))}F=
{filter:z.getAttribute("filter")};if(s===0){z.removeAttribute("filter");C.addSubCommand(new Xa(z,F))}else{ub("filter","url(#"+A+"_blur)");C.addSubCommand(new Xa(z,F));b.setBlurOffsets(k,s);h=C;b.undoMgr.beginUndoableChange("stdDeviation",[k?k.firstChild:null]);if(G){b.setBlurNoUndo(s);g()}}}}})();this.getBold=function(){var g=K[0];if(g!=null&&g.tagName=="text"&&K[1]==null)return g.getAttribute("font-weight")=="bold";return false};this.setBold=function(g){var h=K[0];if(h!=null&&h.tagName=="text"&&
K[1]==null)ub("font-weight",g?"bold":"normal");K[0].textContent||qb.setCursor()};this.getItalic=function(){var g=K[0];if(g!=null&&g.tagName=="text"&&K[1]==null)return g.getAttribute("font-style")=="italic";return false};this.setItalic=function(g){var h=K[0];if(h!=null&&h.tagName=="text"&&K[1]==null)ub("font-style",g?"italic":"normal");K[0].textContent||qb.setCursor()};this.getFontFamily=function(){return mb.font_family};this.setFontFamily=function(g){mb.font_family=g;ub("font-family",g);K[0]&&!K[0].textContent&&
qb.setCursor()};this.setFontColor=function(g){mb.fill=g;ub("fill",g)};this.getFontSize=function(){return mb.fill};this.getFontSize=function(){return mb.font_size};this.setFontSize=function(g){mb.font_size=g;ub("font-size",g);K[0].textContent||qb.setCursor()};this.getText=function(){var g=K[0];if(g==null)return"";return g.textContent};this.setTextContent=function(g){ub("#text",g);qb.init(g);qb.setCursor()};this.setImageURL=function(g){var h=K[0];if(h){var k=$(h).attr(["width","height"]);k=!k.width||
!k.height;var v=ca(h);if(v!==g)k=true;else if(!k)return;var s=new Na("Change Image URL");T(h,g);s.addSubCommand(new Xa(h,{"#href":v}));k?$(new Image).load(function(){var G=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Pa.requestSelector(h).resize();s.addSubCommand(new Xa(h,G));Ha(s);H("changed",[h])}).attr("src",g):Ha(s)}};this.setLinkURL=function(g){var h=K[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var k=ca(h);if(k!==g){var v=
new Na("Change Link URL");T(h,g);v.addSubCommand(new Xa(h,{"#href":k}));Ha(v)}}};this.setRectRadius=function(g){var h=K[0];if(h!=null&&h.tagName=="rect"){var k=h.getAttribute("rx");if(k!=g){h.setAttribute("rx",g);h.setAttribute("ry",g);Ha(new Xa(h,{rx:k,ry:k},"Radius"));H("changed",[h])}}};this.makeHyperlink=function(g){b.groupSelectedElements("a",g)};this.removeHyperlink=function(){b.ungroupSelectedElement()};this.setSegType=function(g){Ua.setSegType(g)};this.convertToPath=function(g,h){if(g==null)$.each(K,
function(xa,da){da&&b.convertToPath(da)});else{if(!h)var k=new Na("Convert element to Path");var v=h?{}:{fill:P.fill,"fill-opacity":P.fill_opacity,stroke:P.stroke,"stroke-width":P.stroke_width,"stroke-dasharray":P.stroke_dasharray,"stroke-linejoin":P.stroke_linejoin,"stroke-linecap":P.stroke_linecap,"stroke-opacity":P.stroke_opacity,opacity:P.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(g.getAttribute(this))v[this]=g.getAttribute(this)});
var s=fa({element:"path",attr:v}),G=g.getAttribute("transform");G&&s.setAttribute("transform",G);var z=g.id,A=g.parentNode;g.nextSibling?A.insertBefore(s,g):A.appendChild(s);var C="",F=function(xa){$.each(xa,function(da,ka){var oa=ka[1];C+=ka[0];for(var za=0;za<oa.length;za+=2)C+=oa[za]+","+oa[za+1]+" "})},E=1.81;switch(g.tagName){case "ellipse":case "circle":var D=$(g).attr(["rx","ry","cx","cy"]),L=D.cx,I=D.cy,N=D.rx;D=D.ry;if(g.tagName=="circle")N=D=$(g).attr("r");F([["M",[L-N,I]],["C",[L-N,I-D/
E,L-N/E,I-D,L,I-D]],["C",[L+N/E,I-D,L+N,I-D/E,L+N,I]],["C",[L+N,I+D/E,L+N/E,I+D,L,I+D]],["C",[L-N/E,I+D,L-N,I+D/E,L-N,I]],["Z",[]]]);break;case "path":C=g.getAttribute("d");break;case "line":D=$(g).attr(["x1","y1","x2","y2"]);C="M"+D.x1+","+D.y1+"L"+D.x2+","+D.y2;break;case "polyline":case "polygon":C="M"+g.getAttribute("points");break;case "rect":D=$(g).attr(["rx","ry"]);N=D.rx;D=D.ry;var X=g.getBBox();L=X.x;I=X.y;var R=X.width;X=X.height;E=4-E;!N&&!D?F([["M",[L,I]],["L",[L+R,I]],["L",[L+R,I+X]],
["L",[L,I+X]],["L",[L,I]],["Z",[]]]):F([["M",[L,I+D]],["C",[L,I+D/E,L+N/E,I,L+N,I]],["L",[L+R-N,I]],["C",[L+R-N/E,I,L+R,I+D/E,L+R,I+D]],["L",[L+R,I+X-D]],["C",[L+R,I+X-D/E,L+R-N/E,I+X,L+R-N,I+X]],["L",[L+N,I+X]],["C",[L+N/E,I+X,L,I+X-D/E,L,I+X-D]],["L",[L,I+D]],["Z",[]]]);break;default:s.parentNode.removeChild(s)}C&&s.setAttribute("d",C);if(h){Ua.resetOrientation(s);k=false;try{k=s.getBBox()}catch(pa){}s.parentNode.removeChild(s);return k}else{if(G){G=W(s);ua(G)&&Ua.resetOrientation(s)}k.addSubCommand(new Va(g,
g.nextSibling,A));k.addSubCommand(new Qa(s));cb();g.parentNode.removeChild(g);s.setAttribute("id",z);s.removeAttribute("visibility");Nb([s],true);Ha(k)}}};var vb=function(g,h,k){var v=e.suspendRedraw(1E3);Ia=="pathedit"&&Ua.moveNode(g,h);k=k||K;for(var s=k.length,G=["g","polyline","path"];s--;){var z=k[s];if(z!=null){Ia==="textedit"&&g!=="#text"&&z.textContent.length&&qb.toSelectMode(z);if((g==="x"||g==="y")&&G.indexOf(z.tagName)>=0){var A=getStrokedBBox([z]);b.moveSelectedElements((g==="x"?h-A.x:
0)*q,(g==="y"?h-A.y:0)*q,true)}else{A=g==="#text"?z.textContent:z.getAttribute(g);if(A==null)A="";if(A!==String(h)){if(g=="#text"){svgedit.utilities.getBBox(z);z.textContent=h;if(/rotate/.test(z.getAttribute("transform")))z=Oa(z)}else g=="#href"?T(z,h):z.setAttribute(g,h);if(svgedit.browser.isGecko()&&z.nodeName==="text"&&/rotate/.test(z.getAttribute("transform")))if((h+"").indexOf("url")===0||["font-size","font-family","x","y"].indexOf(g)>=0&&z.textContent)z=Oa(z);K.indexOf(z)>=0&&setTimeout(function(){z.parentNode&&
Pa.requestSelector(z).resize()},0);A=sa(z);if(A!=0&&g!="transform")for(var C=W(z),F=C.numberOfItems;F--;)if(C.getItem(F).type==4){C.removeItem(F);var E=svgedit.utilities.getBBox(z),D=Q(E.x+E.width/2,E.y+E.height/2,ia(C).matrix);E=D.x;D=D.y;var L=e.createSVGTransform();L.setRotate(A,E,D);C.insertItemBefore(L,F);break}}}}}e.unsuspendRedraw(v)},ub=this.changeSelectedAttribute=function(g,h,k){k=k||K;b.undoMgr.beginUndoableChange(g,k);vb(g,h,k);g=b.undoMgr.finishUndoableChange();g.isEmpty()||Ha(g)};this.deleteSelectedElements=
function(){for(var g=new Na("Delete Elements"),h=K.length,k=[],v=0;v<h;++v){var s=K[v];if(s==null)break;var G=s.parentNode,z=s;Pa.releaseSelector(z);svgedit.path.removePath_(z.id);if(G.tagName==="a"&&G.childNodes.length===1){z=G;G=G.parentNode}var A=z.nextSibling;z=G.removeChild(z);k.push(s);K[v]=null;g.addSubCommand(new Va(z,A,G))}g.isEmpty()||Ha(g);H("changed",k);cb()};this.cutSelectedElements=function(){for(var g=new Na("Cut Elements"),h=K.length,k=[],v=0;v<h;++v){var s=K[v];if(s==null)break;var G=
s.parentNode,z=s;Pa.releaseSelector(z);svgedit.path.removePath_(z.id);var A=z.nextSibling;z=G.removeChild(z);k.push(s);K[v]=null;g.addSubCommand(new Va(z,A,G))}g.isEmpty()||Ha(g);H("changed",k);cb();b.clipBoard=k};this.copySelectedElements=function(){b.clipBoard=$.merge([],K)};this.pasteElements=function(){var g=b.clipBoard,h=g.length;if(h){for(var k=[],v=new Na("Paste elements");h--;){var s=g[h];if(s){var G=ba(s);if(!ta(s.id))G.id=s.id;k.push(G);(M||w().getCurrentLayer()).appendChild(G);v.addSubCommand(new Qa(G))}}svgCanvas.clearSelection();
setTimeout(function(){Sb(k)},100);Ha(v);H("changed",k)}};this.groupSelectedElements=function(g){g||(g="g");var h="";switch(g){case "a":h="Make hyperlink";var k="";if(arguments.length>1)k=arguments[1];break;default:g="g";h="Group Elements"}h=new Na(h);var v=fa({element:g,attr:{id:O()}});g==="a"&&T(v,k);h.addSubCommand(new Qa(v));for(k=K.length;k--;){var s=K[k];if(s!=null){if(s.parentNode.tagName==="a"&&s.parentNode.childNodes.length===1)s=s.parentNode;var G=s.nextSibling,z=s.parentNode;v.appendChild(s);
h.addSubCommand(new Ra(s,G,z))}}h.isEmpty()||Ha(h);Sb([v],true)};var bc=this.pushGroupProperties=function(g,h){var k=g.childNodes,v=k.length,s=g.getAttribute("transform"),G=W(g),z=ia(G).matrix,A=new Na("Push group properties"),C=0,F=sa(g),E=$(g).attr(["filter","opacity"]),D,L;for(C=0;C<v;C++){var I=k[C];if(I.nodeType===1){if(E.opacity!==null&&E.opacity!==1){I.getAttribute("opacity");var N=Math.round((I.getAttribute("opacity")||1)*E.opacity*100)/100;ub("opacity",N,[I])}if(E.filter){var X=N=this.getBlur(I);
L||(L=this.getBlur(g));if(N)N=L-0+(N-0);else if(N===0)N=L;if(X)D=Z(I.getAttribute("filter"));else if(D){D=ba(D);Bb().appendChild(D)}else D=Z(E.filter);D.id=I.id+"_"+(D.firstChild.tagName==="feGaussianBlur"?"blur":"filter");ub("filter","url(#"+D.id+")",[I]);if(N){ub("stdDeviation",N,[D.firstChild]);b.setBlurOffsets(D,N)}}N=W(I);if(~I.tagName.indexOf("Gradient"))N=null;if(N)if(I.tagName!=="defs")if(G.numberOfItems){if(F&&G.numberOfItems==1){var R=G.getItem(0).matrix,pa=e.createSVGMatrix();if(X=sa(I))pa=
N.getItem(0).matrix;var xa=svgedit.utilities.getBBox(I),da=ia(N).matrix,ka=Q(xa.x+xa.width/2,xa.y+xa.height/2,da);xa=F+X;da=e.createSVGTransform();da.setRotate(xa,ka.x,ka.y);R=ha(R,pa,da.matrix.inverse());X&&N.removeItem(0);if(xa)N.numberOfItems?N.insertItemBefore(da,0):N.appendItem(da);if(R.e||R.f){X=e.createSVGTransform();X.setTranslate(R.e,R.f);N.numberOfItems?N.insertItemBefore(X,0):N.appendItem(X)}}else{X=I.getAttribute("transform");R={};R.transform=X?X:"";X=e.createSVGTransform();R=ia(N).matrix;
pa=R.inverse();R=ha(pa,z,R);X.setMatrix(R);N.appendItem(X)}(I=pb(I))&&A.addSubCommand(I)}}}if(s){R={};R.transform=s;g.setAttribute("transform","");g.removeAttribute("transform");A.addSubCommand(new Xa(g,R))}if(h&&!A.isEmpty())return A};this.ungroupSelectedElement=function(){var g=K[0];if($(g).data("gsvg")||$(g).data("symbol"))ic(g);else if(g.tagName==="use"){var h=ta(ca(g).substr(1));$(g).data("symbol",h).data("ref",h);ic(g)}else{h=$(g).parents("a");if(h.length)g=h[0];if(g.tagName==="g"||g.tagName===
"a"){h=new Na("Ungroup Elements");var k=bc(g,true);k&&h.addSubCommand(k);k=g.parentNode;for(var v=g.nextSibling,s=Array(g.childNodes.length),G=0;g.firstChild;){var z=g.firstChild,A=z.nextSibling,C=z.parentNode;if(z.tagName==="title"){h.addSubCommand(new Va(z,z.nextSibling,C));C.removeChild(z)}else{s[G++]=z=k.insertBefore(z,v);h.addSubCommand(new Ra(z,A,C))}}cb();v=g.nextSibling;g=k.removeChild(g);h.addSubCommand(new Va(g,v,k));h.isEmpty()||Ha(h);Nb(s)}}};this.moveToTopSelectedElement=function(){var g=
K[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling;g=g.parentNode.appendChild(g);if(k!=g.nextSibling){Ha(new Ra(g,k,h,"top"));H("changed",[g])}}};this.moveToBottomSelectedElement=function(){var g=K[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling,v=g.parentNode.firstChild;if(v.tagName=="title")v=v.nextSibling;if(v.tagName=="defs")v=v.nextSibling;g=g.parentNode.insertBefore(g,v);if(k!=g.nextSibling){Ha(new Ra(g,k,h,"bottom"));H("changed",[g])}}};this.moveUpDownSelected=function(g){var h=
K[0];if(h){jb=[];var k,v,s=$(Ob(getStrokedBBox([h]))).toArray();g=="Down"&&s.reverse();$.each(s,function(){if(v){k=this;return false}else if(this==h)v=true});if(k){s=h.parentNode;var G=h.nextSibling;$(k)[g=="Down"?"before":"after"](h);if(G!=h.nextSibling){Ha(new Ra(h,G,s,"Move "+g));H("changed",[h])}}}};this.moveSelectedElements=function(g,h,k){if(g.constructor!=Array){g/=q;h/=q}k=k||true;for(var v=new Na("position"),s=K.length;s--;){var G=K[s];if(G!=null){var z=e.createSVGTransform(),A=W(G);g.constructor==
Array?z.setTranslate(g[s],h[s]):z.setTranslate(g,h);A.numberOfItems?A.insertItemBefore(z,0):A.appendItem(z);(z=pb(G))&&v.addSubCommand(z);Pa.requestSelector(G).resize()}}if(!v.isEmpty()){k&&Ha(v);H("changed",K);return v}};this.cloneSelectedElements=function(g,h){for(var k=new Na("Clone Elements"),v=K.length,s=0;s<v;++s){var G=K[s];if(G==null)break}v=K.slice(0,s);this.clearSelection(true);for(s=v.length;s--;){G=v[s]=ba(v[s]);(M||w().getCurrentLayer()).appendChild(G);k.addSubCommand(new Qa(G))}if(!k.isEmpty()){Nb(v.reverse());
this.moveSelectedElements(g,h,false);Ha(k)}};this.alignSelectedElements=function(g,h){var k=[],v=Number.MAX_VALUE,s=Number.MIN_VALUE,G=Number.MAX_VALUE,z=Number.MIN_VALUE,A=Number.MIN_VALUE,C=Number.MIN_VALUE,F=K.length;if(F){for(var E=0;E<F;++E){if(K[E]==null)break;k[E]=getStrokedBBox([K[E]]);switch(h){case "smallest":if((g=="l"||g=="c"||g=="r")&&(A==Number.MIN_VALUE||A>k[E].width)||(g=="t"||g=="m"||g=="b")&&(C==Number.MIN_VALUE||C>k[E].height)){v=k[E].x;G=k[E].y;s=k[E].x+k[E].width;z=k[E].y+k[E].height;
A=k[E].width;C=k[E].height}break;case "largest":if((g=="l"||g=="c"||g=="r")&&(A==Number.MIN_VALUE||A<k[E].width)||(g=="t"||g=="m"||g=="b")&&(C==Number.MIN_VALUE||C<k[E].height)){v=k[E].x;G=k[E].y;s=k[E].x+k[E].width;z=k[E].y+k[E].height;A=k[E].width;C=k[E].height}break;default:if(k[E].x<v)v=k[E].x;if(k[E].y<G)G=k[E].y;if(k[E].x+k[E].width>s)s=k[E].x+k[E].width;if(k[E].y+k[E].height>z)z=k[E].y+k[E].height}}if(h=="page"){G=v=0;s=b.contentW;z=b.contentH}A=Array(F);C=Array(F);for(E=0;E<F;++E){if(K[E]==
null)break;var D=k[E];A[E]=0;C[E]=0;switch(g){case "l":A[E]=v-D.x;break;case "c":A[E]=(v+s)/2-(D.x+D.width/2);break;case "r":A[E]=s-(D.x+D.width);break;case "t":C[E]=G-D.y;break;case "m":C[E]=(G+z)/2-(D.y+D.height/2);break;case "b":C[E]=z-(D.y+D.height)}}this.moveSelectedElements(A,C)}};this.contentW=Yb().w;this.contentH=Yb().h;this.updateCanvas=function(g,h){e.setAttribute("width",g);e.setAttribute("height",h);var k=$("#canvasBackground")[0],v=l.getAttribute("x"),s=l.getAttribute("y"),G=g/2-this.contentW*
q/2,z=h/2-this.contentH*q/2;aa(l,{width:this.contentW*q,height:this.contentH*q,x:G,y:z,viewBox:"0 0 "+this.contentW+" "+this.contentH});aa(k,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:G,y:z});(k=ta("background_image"))&&aa(k,{width:"100%",height:"100%"});Pa.selectorParentGroup.setAttribute("transform","translate("+G+","+z+")");return{x:G,y:z,old_x:v,old_y:s,d_x:G-v,d_y:z-s}};this.setBackground=function(g,h){var k=ta("canvasBackground"),v=$(k).find("rect")[0],s=ta("background_image");
v.setAttribute("fill",g);if(h){if(!s){s=d.createElementNS(c,"image");aa(s,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}T(s,h);k.appendChild(s)}else s&&s.parentNode.removeChild(s)};this.cycleElement=function(g){var h=K[0],k=false,v=Kb(M||w().getCurrentLayer());if(v.length){if(h==null){g=g?v.length-1:0;k=v[g]}else for(var s=v.length;s--;)if(v[s]==h){g=g?s-1:s+1;if(g>=v.length)g=0;else if(g<0)g=v.length-1;k=v[g];break}Sb([k],true);H("selected",
K)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:Ha,setGradient:mc,addSvgElementFromJson:fa,assignAttributes:aa,BatchCommand:Na,call:H,ChangeElementCommand:Xa,copyElem:ba,ffClone:Oa,findDefs:Bb,findDuplicateGradient:lc,getElem:ta,getId:va,getIntersectionList:Ob,getMouseTarget:ac,getNextId:O,getPathBBox:V,getUrlFromAttr:qa,hasMatrixTransform:ua,identifyLayers:Tb,InsertElementCommand:Qa,isIdentity:svgedit.math.isIdentity,logMatrix:wb,matrixMultiply:ha,MoveElementCommand:Ra,
preventClickDefault:Lb,recalculateAllSelectedDimensions:Za,recalculateDimensions:pb,remapElement:xb,RemoveElementCommand:Va,removeUnusedDefElems:kc,round:Gb,runExtensions:nb,sanitizeSvg:Ma,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:ia,transformPoint:Q,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function n(w,q){var M=f.setSvgString(w)!==false;q=q||a.noop;M?q(true):a.alert(e.notification.errorLoadingSVG,function(){q(false)})}var f,c={},m=false,o={lang:"en",iconsize:"m",bkgd_color:"FFF",bkgd_url:"",img_save:"embed"},
b={},d={canvas_expansion:1,dimensions:[640,480],initFill:{color:"fff",opacity:1},initStroke:{width:1.5,color:"000",opacity:1},initOpacity:1,imgPath:"images/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",extensions:[],initTool:"select",wireframe:false,colorPickerCSS:false,gridSnapping:false,gridColor:"#000",baseUnit:"px",snappingStep:10,showRulers:true,show_outside_canvas:false,no_save_warning:true,initFont:"Sans-serif"},e=c.uiStrings={common:{ok:"OK",cancel:"Cancel",key_up:"Up",key_down:"Down",
key_backspace:"Backspace",key_del:"Del"},layers:{layer:"Layer"},notification:{invalidAttrValGiven:"Invalid value given",noContentToFitTo:"No content to fit to",dupeLayerName:"There is already a layer named that!",enterUniqueLayerName:"Please enter a unique layer name",enterNewLayerName:"Please enter the new layer name",layerHasThatName:"Layer already has that name",QmoveElemsToLayer:'Move selected elements to layer "%s"?',QwantToClear:"Do you want to clear the drawing?\nThis will also erase your undo history!",
QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo history!",QerrorsRevertToSource:"There were parsing errors in your SVG source.\nRevert back to original SVG source?",QignoreSourceChanges:"Ignore changes made to SVG source?",featNotSupported:"Feature not supported",enterNewImgURL:"Enter the new image URL",defsFailOnSave:"NOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.",loadingImage:"Loading image, please wait...",
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" ...'}};b={};var l={};c.curConfig=d;c.tool_scale=1;a.pref=function(w,q){if(q)b[w]=q;w="svg-edit-"+w;var M=location.hostname,U=M&&M.indexOf(".")>=0,P=q!=undefined,
K=false;try{if(window.localStorage)K=localStorage}catch(fa){}try{if(window.globalStorage&&U)K=globalStorage[M]}catch(W){}if(K)if(P)K.setItem(w,q);else{if(K.getItem(w))return K.getItem(w)+""}else if(window.widget)if(P)widget.setPreferenceForKey(q,w);else return widget.preferenceForKey(w);else if(P){M=new Date;M.setTime(M.getTime()+31536E6);q=encodeURIComponent(q);document.cookie=w+"="+q+"; expires="+M.toUTCString()}else return(M=document.cookie.match(RegExp(w+"=([^;]+)")))?decodeURIComponent(M[1]):
""};c.setConfig=function(w){a.each(w,function(q,M){q in o&&a.pref(q,M)});a.extend(true,d,w);if(w.extensions)d.extensions=w.extensions};c.setCustomHandlers=function(w){c.ready(function(){if(w.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();f.open=w.open}if(w.save){c.show_save_warning=false;f.bind("saved",w.save)}w.pngsave&&f.bind("exported",w.pngsave);l=w})};c.randomizeIds=function(){f.randomizeIds(arguments)};c.init=function(){function w(p,B){var J=p.id,S=J.split("_"),Y=
S[0];S=S[1];B&&f.setStrokeAttr("stroke-"+Y,S);mb();da("#cur_"+Y,J,20);a(p).addClass("current").siblings().removeClass("current")}function q(p,B){a.pref("bkgd_color",p);a.pref("bkgd_url",B);f.setBackground(p,B)}function M(){var p=f.getHref(aa);p=p.indexOf("data:")===0?"":p;a.prompt(e.notification.enterNewImgURL,p,function(B){B&&Da(B)})}function U(){if(f.deleteCurrentLayer()){bb();Hb();a("#layerlist tr.layer").removeClass("layersel");a("#layerlist tr.layer:first").addClass("layersel")}}function P(){var p=
f.getCurrentDrawing().getCurrentLayerName()+" copy";a.prompt(e.notification.enterUniqueLayerName,p,function(B){if(B)if(f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.dupeLayerName);else{f.cloneLayer(B);bb();Hb()}})}function K(p){var B=a("#layerlist tr.layersel").index(),J=f.getCurrentDrawing().getNumLayers();if(B>0||B<J-1){B+=p;f.setCurrentLayerPosition(J-B-1);Hb()}}function fa(p,B){var J=document.getElementById("ruler_x_cursor"),S=document.getElementById("ruler_y_cursor"),Y=document.getElementById("workarea");
document.getElementById("title_show");svgedit.browser.isTouch()||a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(pc){pc.stopPropagation();J.style.left=pc.pageX-66+Y.scrollLeft+"px";S.style.top=pc.pageY-48+Y.scrollTop+"px"});B||(B=f.getZoom());p||(p=a("#svgcanvas"));for(var la=f.getContentElem(),wa=svgedit.units.getTypeMap()[d.baseUnit],ya=0;ya<2;ya++){var Ca=ya===0,Ba=Ca?"x":"y",Aa=Ca?"width":"height",Ab=la.getAttribute(Ba)-0;Ba=a("#ruler_"+Ba+" canvas:first");$hcanv=Ba.clone();
Ba.replaceWith($hcanv);var Ta=$hcanv[0];var ja=Ba=p[Aa]()*2;Ta.parentNode.style[Aa]=ja+"px";var Cb=0,db,Ea=Ta.getContext("2d");Ea.fillStyle="rgb(200,0,0)";Ea.fillRect(0,0,Ta.width,Ta.height);$hcanv.siblings().remove();if(Ba>=3E4){var Ya=parseInt(Ba/3E4)+1;db=Array(Ya);db[0]=Ea;for(var Fa=1;Fa<Ya;Fa++){Ta[Aa]=3E4;var ib=Ta.cloneNode(true);Ta.parentNode.appendChild(ib);db[Fa]=ib.getContext("2d")}ib[Aa]=Ba%3E4;Ba=3E4}Ta[Aa]=Ba;Aa=wa*B;var eb=50/Aa;Ta=1;for(Fa=0;Fa<jc.length;Fa++){Ta=Ya=jc[Fa];if(eb<=
Ya)break}eb=Ta*Aa;Ea.font="normal 9px 'Lucida Grande', sans-serif";Ea.fillStyle="#777";for(var lb=Ab/Aa%Ta*Aa,$b=lb-eb;lb<ja;lb+=eb){$b+=eb;Fa=Math.round(lb)+0.5;if(Ca){Ea.moveTo(Fa,15);Ea.lineTo(Fa,0)}else{Ea.moveTo(15,Fa);Ea.lineTo(0,Fa)}Ya=($b-Ab)/Aa;if(Ta>=1)Fa=Math.round(Ya);else{Fa=(Ta+"").split(".")[1].length;Fa=Ya.toFixed(Fa)-0}if(Fa!==0&&Fa!==1E3&&Fa%1E3===0)Fa=Fa/1E3+"K";if(Ca){Ea.fillText(Fa,lb+2,8);Ea.fillStyle="#777"}else{Ya=(Fa+"").split("");for(Fa=0;Fa<Ya.length;Fa++){Ea.fillText(Ya[Fa],
1,lb+9+Fa*9);Ea.fillStyle="#777"}}Ya=eb/10;for(Fa=1;Fa<10;Fa++){var Qb=Math.round(lb+Ya*Fa)+0.5;if(db&&Qb>Ba){Cb++;Ea.stroke();if(Cb>=db.length){Fa=10;lb=ja;continue}Ea=db[Cb];lb-=3E4;Qb=Math.round(lb+Ya*Fa)+0.5}var Zb=Fa%2?12:10;if(Ca){Ea.moveTo(Qb,15);Ea.lineTo(Qb,Zb)}else{Ea.moveTo(15,Qb);Ea.lineTo(Zb,Qb)}}}Ea.strokeStyle="#666";Ea.stroke()}}(function(){var p=window.opener;if(p)try{var B=p.document.createEvent("Event");B.initEvent("svgEditorReady",true,true);p.document.documentElement.dispatchEvent(B)}catch(J){}})();
(function(){var p=a.deparam.querystring(true);if(!a.isEmptyObject(p)){if(p.dimensions)p.dimensions=p.dimensions.split(",");if(p.extensions)p.extensions=p.extensions.split(",");if(p.bkgd_color)p.bkgd_color="#"+p.bkgd_color;svgEditor.setConfig(p);var B=p.source,J=a.param.querystring();if(!B)if(J.indexOf("source=data:")>=0)B=J.match(/source=(data:[^&]*)/)[1];if(B)if(B.indexOf("data:")===0){B=B.replace(/ /g,"+");c.loadFromDataURI(B)}else c.loadFromString(B);else if(J.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(J.substr(9));
else p.url&&svgEditor.loadFromURL(p.url)}})();var W=function(){a.each(d.extensions,function(){var p=this;a.getScript(d.extPath+p,function(B){if(!B){B=document.createElement("script");B.src=d.extPath+p;document.querySelector("head").appendChild(B)}})})};document.location.protocol==="file:"?setTimeout(W,100):W();a.svgIcons(d.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:!svgedit.browser.isWebkit(),fallback_path:d.imgPath,fallback:{new_image:"clear.png",save:"save.png",open:"open.png",
source:"source.png",docprops:"document-properties.png",wireframe:"wireframe.png",undo:"undo.png",redo:"redo.png",select:"select.png",select_node:"select_node.png",pencil:"fhpath.png",pen:"line.png",square:"square.png",rect:"rect.png",fh_rect:"freehand-square.png",circle:"circle.png",ellipse:"ellipse.png",fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png",clone:"clone.png",node_clone:"node_clone.png","delete":"delete.png",node_delete:"node_delete.png",
move_top:"move_top.png",move_bottom:"move_bottom.png",to_path:"to_path.png",link_controls:"link_controls.png",reorient:"reorient.png",align_left:"align-left.png",align_center:"align-center",align_right:"align-right",align_top:"align-top",align_middle:"align-middle",align_bottom:"align-bottom",go_up:"go-up.png",go_down:"go-down.png",ok:"save.png",cancel:"cancel.png",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#tool_docprops > div":"docprops","#tool_select":"select","#tool_fhpath":"pencil",
"#tool_line":"pen","#tool_rect,#tools_rect_show":"rect","#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_node_clone":"node_clone","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center",
"#tool_alignright, #tool_posright":"align_right","#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#linecap_butt,#cur_linecap":"linecap_butt","#linecap_round":"linecap_round","#linecap_square":"linecap_square","#linejoin_miter,#cur_linejoin":"linejoin_miter","#linejoin_round":"linejoin_round","#linejoin_bevel":"linejoin_bevel","#url_notice":"warning","#layer_up":"go_up","#layer_down":"go_down",
"#layer_moreopts":"context_menu","#layerlist td.layervis":"eye","#tool_source_save,#tool_docprops_save,#tool_prefs_save":"ok","#tool_source_cancel,#tool_docprops_cancel,#tool_prefs_cancel":"cancel","#rwidthLabel, #iwidthLabel":"width","#rheightLabel, #iheightLabel":"height","#angleLabel":"angle","#linkLabel,#tool_make_link,#tool_make_link_multi":"globe_link","#zoomLabel":"zoom","#blurLabel":"blur",".flyout_arrow_horiz":"arrow_right","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},
resize:{"#logo .svg_icon":32,".flyout_arrow_horiz .svg_icon":5,".layer_button .svg_icon, #layerlist td.layervis .svg_icon":14,"#main_button .dropdown .svg_icon":9,"#fill_bg .svg_icon, #stroke_bg .svg_icon":24,".palette_item:first .svg_icon":16,".toolbar_button button .svg_icon":16,".stroke_tool div div .svg_icon":20,"#tools_bottom label .svg_icon":18,"#zoom_dropdown .svg_icon":7},callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});
a(".tool_button, .tool_button_current").addClass("loaded");var p=a("#tools_left");if(p.length!=0){p.offset();p.outerHeight()}a(".tools_flyout").each(function(){var B=a("#"+this.id+"_show"),J=B.attr("data-curopt");if(!B.children("svg, img").length){J=a(J).children().clone();if(J.length){J[0].removeAttribute("style");B.append(J)}}});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(p){a("#base_unit_container").css({top:p.pageY-10,left:p.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(){xa()});c.canvas=f=new a.SvgCanvas(document.getElementById("svgcanvas"),d);c.show_save_warning=false;c.paintBox={fill:null,stroke:null,canvas:null};W=navigator.platform.indexOf("Mac")>=0;var Q=
navigator.userAgent.indexOf("AppleWebKit")>=0,ha=W?"meta+":"ctrl+",ua=f.pathActions,ia=f.undoMgr,ea=svgedit.utilities,ga=d.imgPath+"placeholder.svg",ra=a("#workarea"),qa=a("#cmenu_canvas");a("#cmenu_layers");var ca=null,T=1,V="toolbars",sa="";W||a(".shortcut").each(function(){var p=a(this).text();a(this).text(p.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var p=a("#dialog_box"),B=a("#dialog_buttons"),
J=function(S,Y,la,wa){a("#dialog_content").html("<p>"+Y.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",S=="prompt");B.empty();var ya=a('<input type="button" value="'+e.common.ok+'">').appendTo(B);S!="alert"&&a('<input type="button" value="'+e.common.cancel+'">').appendTo(B).click(function(){p.hide();la(false)});if(S=="prompt"){var Ca=a('<input type="text">').prependTo(B);Ca.val(wa||"");Ca.bind("keydown","return",function(){ya.click()})}S=="process"&&ya.hide();p.show();ya.click(function(){p.hide();
var Ba=S=="prompt"?Ca.val():true;la&&la(Ba)}).focus();S=="prompt"&&Ca.focus()};a.alert=function(S,Y){J("alert",S,Y)};a.confirm=function(S,Y){J("confirm",S,Y)};a.process_cancel=function(S,Y){J("process",S,Y)};a.prompt=function(S,Y,la){J("prompt",S,la,Y)}})();var ta=function(){var p=a(".tool_button_current");if(p.length&&p[0].id!=="tool_select"){p.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}f.setMode("select")},
aa=null,ma=false,Ga=false,Ma=false,Ra=false,Qa="",Va=a("title:first").text(),Xa=function(p,B,J){f.getResolution();a("#svgcanvas").position();if(B=f.setBBoxZoom(B,ra.width()-15,ra.height()-15)){p=B.zoom;B=B.bbox;if(p<0.0010)Ia({value:0.1});else{a("#zoom").val(p*100);J?Wb():Wb(false,{x:B.x*p+B.width*p/2,y:B.y*p+B.height*p/2});f.getMode()=="zoom"&&B.width&&ta();E()}}};a("#cur_context_panel").delegate("a","click",function(){var p=a(this);p.attr("data-root")?f.leaveContext():f.setContext(p.text());return false});
var Na=function(){c.paintBox.fill.prep();c.paintBox.stroke.prep()},Ha={},Pa=function(p){a.each(p,function(B,J){var S=a(B).children(),Y=B+"_show",la=a(Y),wa=false;S.addClass("tool_button").unbind("click mousedown mouseup").each(function(Ba){var Aa=J[Ba];Ha[Aa.sel]=Aa.fn;if(Aa.isDefault)wa=Ba;Ba=function(Ab){var Ta=Aa;if(Ab.type==="keydown"){var ja=a(Ta.parent+"_show").hasClass("tool_button_current"),Cb=a(Ta.parent+"_show").attr("data-curopt");a.each(p[Aa.parent],function(Ea,Ya){if(Ya.sel==Cb)Ta=!Ab.shiftKey||
!ja?Ya:p[Aa.parent][Ea+1]||p[Aa.parent][0]})}if(a(this).hasClass("disabled"))return false;La(Y)&&Ta.fn();var db=Ta.icon?a.getSvgIcon(Ta.icon,true):a(Ta.sel).children().eq(0).clone();db[0].setAttribute("width",la.width());db[0].setAttribute("height",la.height());la.children(":not(.flyout_arrow_horiz)").remove();la.append(db).attr("data-curopt",Ta.sel)};a(this).mouseup(Ba);Aa.key&&a(document).bind("keydown",Aa.key[0]+" shift+"+Aa.key[0],Ba)});if(wa)la.attr("data-curopt",J[wa].sel);else la.attr("data-curopt")||
la.attr("data-curopt",J[0].sel);var ya,Ca=a(Y).position();a(B).css({left:Ca.left+34,top:Ca.top+77});la.mousedown(function(Ba){a("#tools_shapelib").is(":visible")&&La(Y,false);if(la.hasClass("disabled"))return false;var Aa=a(B),Ab=Ca.left+34,Ta=Aa.width()*-1,ja=Aa.data("shown_popop")?200:0;ya=setTimeout(function(){la.data("isLibrary")?Aa.css("left",Ab).show():Aa.css("left",Ta).show().animate({left:Ab},150);Aa.data("shown_popop",true)},ja);Ba.preventDefault()}).mouseup(function(){clearTimeout(ya);var Ba=
a(this).attr("data-curopt");if(la.data("isLibrary")&&a(Y.replace("_show","")).is(":visible"))La(Y,true);else La(Y)&&Ba in Ha&&Ha[Ba]()})});Jb()},zb=function(p,B){return a("<div>",{"class":"tools_flyout",id:p}).appendTo("#svg_editor").append(B)},Ja=function(){a(".tools_flyout").each(function(){var p=a("#"+this.id+"_show"),B=p.offset();p=p.outerWidth();a(this).css({left:(B.left+p)*T,top:B.top})})},Jb=function(){a(".tools_flyout").each(function(){var p=a("#"+this.id+"_show");if(!p.data("isLibrary")){var B=
[];a(this).children().each(function(){B.push(this.title)});p[0].title=B.join(" / ")}})},tb,ab=function(p,B,J){var S=null;if(p.indexOf("url(#")===0){p=(p=f.getRefElem(p))?p.cloneNode(true):a("#"+J+"_color defs *")[0];S={alpha:B};S[p.tagName]=p}else S=p.indexOf("#")===0?{alpha:B,solidColor:p.substr(1)}:{alpha:B,solidColor:"none"};return new a.jGraduate.Paint(S)},$a=f.getResolution();if(d.baseUnit!=="px"){$a.w=svgedit.units.convertUnit($a.w)+d.baseUnit;$a.h=svgedit.units.convertUnit($a.h)+d.baseUnit}a(".canvas_width").val($a.w);
a(".canvas_height").val($a.h);a("#docprops_button").on("click",function(){L()});var Ka=function(p){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:$a.w+2,height:$a.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:p||"#fff",style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||Ka();document.getElementById("canvas_background").getAttribute("fill");var Da=c.setImageURL=
function(p){p||(p=ga);f.setImageURL(p);a("#image_url").val(p);if(p.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(p,function(B){B?a("#url_notice").hide():a("#url_notice").show();ga=p});a("#image_url").show();a("#change_image_url").hide()}},yb=function(p){var B=Math.min(Math.max(12+p.value.length*6,50),300);a(p).width(B)},bb=function(){var p=aa;if(p!=null&&!p.parentNode)p=null;var B=f.getCurrentDrawing().getCurrentLayerName(),J=f.getMode(),S=d.baseUnit!==
"px"?d.baseUnit:null,Y=J=="pathedit",la=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");!p&&!ma&&a("#canvas_panel").show();if(p!=null){var wa=p.nodeName,ya=f.getRotationAngle(p);a("#angle").val(Math.round(ya));
ya=f.getBlur(p);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&wa==="image"&&f.getHref(p).indexOf("data:")!==0&&M();if(!Y&&J!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(wa)>=0)a("#xy_panel").hide();else{var Ca,Ba;if(["g","polyline","path"].indexOf(wa)>=0){if(J=f.getStrokedBBox([p])){Ca=J.x;Ba=J.y}}else{Ca=p.getAttribute("x");Ba=p.getAttribute("y")}if(S){Ca=svgedit.units.convertUnit(Ca);
Ba=svgedit.units.convertUnit(Ba)}a("#selected_x").val(Math.round(Ba)||0);a("#selected_y").val(Math.round(Ca)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(wa)==-1&&a(".action_path_convert_selected").removeClass("disabled");wa==="path"&&a(".action_path_selected").removeClass("disabled")}else{B=ua.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!ua.canDeleteNodes);da("#tool_openclose_path",
ua.closed_subpath?"open_path":"close_path");if(B){Y=a("#seg_type");if(S){B.x=svgedit.units.convertUnit(B.x);B.y=svgedit.units.convertUnit(B.y)}a("#path_node_x").val(Math.round(B.x));a("#path_node_y").val(Math.round(B.y));B.type?Y.val(B.type).removeAttr("disabled"):Y.val(4).attr("disabled","disabled")}return}S={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]};var Aa=p.tagName;a(p).data("gsvg")&&
a("#g_panel").show();Aa=="path"&&a("#path_panel").show();if(S[Aa]){S=S[Aa];a("#"+Aa+"_panel").show();a.each(S,function(Ab,Ta){var ja=p.getAttribute(Ta);if(d.baseUnit!=="px"&&p[Ta])ja=svgedit.units.convertUnit(p[Ta].baseVal.value);a("#"+Aa+"_"+Ta).val(Math.round(ja)||0)});if(Aa=="text"){a("#text_panel").css("display","inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");f.getBold()?
a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(p.getAttribute("font-family"));a("#font_size").val(p.getAttribute("font-size"));a("#text").val(p.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(Aa=="image")Da(f.getHref(p));else if(Aa==="g"||Aa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");S=f.getTitle();
wa=a("#g_title")[0];wa.value=S;yb(wa);Aa=="use"?wa.setAttribute("disabled","disabled"):wa.removeAttribute("disabled")}}la[(Aa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");la[(Aa==="g"||!ma?"dis":"en")+"ableContextMenuItems"]("#group")}else if(ma){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");la.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else la.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
ia.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ia.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(p&&!Y||ma){a("#selLayerNames").removeAttr("disabled").val(B);qa.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled","disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",
function(p,B){var J=f.getMode();J==="select"&&ta();J=J=="pathedit";aa=B.length==1||B[1]==null?B[0]:null;ma=B.length>=2&&B[1]!=null;if(aa!=null)if(!J){if(aa!=null)switch(aa.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var S=null,Y=aa.getElementsByTagName("*"),la=0,wa=Y.length;la<wa;la++){var ya=Y[la].getAttribute("stroke-width");if(la===0)S=ya;else if(S!==ya)S=null}a("#stroke_width").val(S===null?"":S);c.paintBox.fill.update(true);c.paintBox.stroke.update(true);
break;default:c.paintBox.fill.update(true);c.paintBox.stroke.update(true);a("#stroke_width").val(aa.getAttribute("stroke-width")||1);a("#stroke_style").val(aa.getAttribute("stroke-dasharray")||"none");S=aa.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+S).length!=0&&w(a("#linejoin_"+S)[0]);S=aa.getAttribute("stroke-linecap")||"butt";a("#linecap_"+S).length!=0&&w(a("#linecap_"+S)[0])}if(aa!=null){S=(aa.getAttribute("opacity")||1)*100;a("#group_opacity").val(S);a("#opac_slider").slider("option",
"value",S);a("#elem_id").val(aa.id)}}a("#path_node_panel").toggle(J);a("#tools_bottom_2,#tools_bottom_3").toggle(!J);if(J){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");da("#tool_select","select_node");ma=false;if(B.length)aa=B[0]}else{if(B[0]){J=f.selectorManager.requestSelector(B[0]);J.reset(B[0]);J.selectorRect.setAttribute("display","inline")}da("#tool_select","select")}bb();f.runExtensions("selectedChanged",
{elems:B,selectedElement:aa,multiselected:ma})});f.bind("transition",function(p,B){var J=f.getMode(),S=B[0];if(S){ma=B.length>=2&&B[1]!=null;if(!ma)switch(J){case "rotate":J=f.getRotationAngle(S);a("#angle").val(Math.round(J));a("#tool_reorient").toggleClass("disabled",J==0)}f.runExtensions("elementTransition",{elems:B})}});f.bind("changed",function(p,B){var J=f.getMode();J==="select"&&ta();for(var S=0;S<B.length;++S){var Y=B[S];if(Y&&Y.tagName==="svg"){Hb();Wb()}else if(Y&&aa&&aa.parentNode==null)aa=
Y}c.show_save_warning=true;bb();if(aa&&J==="select"){c.paintBox.fill.update();c.paintBox.stroke.update()}f.runExtensions("elementChanged",{elems:B})});f.bind("saved",function(p,B){c.show_save_warning=false;B='<?xml version="1.0"?>\n'+B;var J=navigator.userAgent;if(~J.indexOf("Chrome")&&a.browser.version>=533||~J.indexOf("MSIE"))D(0,true);else{var S=p.open("data:image/svg+xml;base64,"+ea.encode64(B)),Y=a.pref("save_notice_done");if(Y!=="all"){var la=e.notification.saveFromBrowser.replace("%s","SVG");
if(J.indexOf("Gecko/")!==-1)if(B.indexOf("<defs")!==-1){la+="\n\n"+e.notification.defsFailOnSave;a.pref("save_notice_done","all");Y="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");Y!=="part"&&S.alert(la)}}});f.bind("exported",function(p,B){var J=B.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var S=a("#export_canvas")[0];S.width=f.contentW;S.height=f.contentH;canvg(S,B.svg,{renderCallback:function(){var Y=S.toDataURL("image/png");
ca.location.href=Y;if(a.pref("export_notice_done")!=="all"){Y=e.notification.saveFromBrowser.replace("%s","PNG");if(J.length)Y+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+J.join("\n \u2022 ");a.pref("export_notice_done","all");ca.alert(Y)}}})});f.bind("zoomed",Xa);f.bind("contextset",function(p,B){var J="";if(B){var S="";J='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(B).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){S+=" > "+this.id;
J+=this!==B?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Qa=S}else Qa=null;a("#cur_context_panel").toggle(!!B).html(J);R()});f.bind("extension_added",function(p,B){function J(){if(tb){clearTimeout(tb);tb=null}Y||(tb=setTimeout(function(){Y=true;za(b.iconsize)},50))}var S=false,Y=false,la=true,wa=function(){if(B.callback&&!S&&la){S=true;B.callback()}},ya=[];B.context_tools&&a.each(B.context_tools,function(Ta,ja){var Cb=ja.container_id?' id="'+ja.container_id+'"':"",db=a("#"+ja.panel);db.length||
(db=a("<div>",{id:ja.panel}).appendTo("#tools_top").hide());switch(ja.type){case "tool_button":var Ea='<div class="tool_button">'+ja.id+"</div>",Ya=a(Ea).appendTo(db);ja.events&&a.each(ja.events,function(eb,lb){a(Ya).bind(eb,lb)});break;case "select":Ea="<label"+Cb+'><select id="'+ja.id+'">';a.each(ja.options,function(eb,lb){Ea+='<option value="'+eb+'"'+(eb==ja.defval?" selected":"")+">"+lb+"</option>"});Ea+="</select></label>";var Fa=a(Ea).appendTo(db).find("select");a.each(ja.events,function(eb,
lb){a(Fa).bind(eb,lb)});break;case "button-select":Ea='<div id="'+ja.id+'" class="dropdown toolset" title="'+ja.title+'"><div id="cur_'+ja.id+'" class="icon_label"></div><button></button></div>';Cb=a('<ul id="'+ja.id+'_opts"></ul>').appendTo("#option_lists");ja.colnum&&Cb.addClass("optcols"+ja.colnum);a(Ea).appendTo(db).children();ya.push({elem:"#"+ja.id,list:"#"+ja.id+"_opts",title:ja.title,callback:ja.events.change,cur:"#cur_"+ja.id});break;case "input":Ea="<label"+Cb+'><span id="'+ja.id+'_label">'+
ja.label+':</span><input id="'+ja.id+'" title="'+ja.title+'" size="'+(ja.size||"4")+'" value="'+(ja.defval||"")+'" type="text"/></label>';var ib=a(Ea).appendTo(db).find("input");ja.spindata&&ib.SpinButton(ja.spindata);ja.events&&a.each(ja.events,function(eb,lb){ib.bind(eb,lb)})}});if(B.buttons){var Ca={},Ba={},Aa=B.svgicons,Ab={};a.each(B.buttons,function(Ta,ja){for(var Cb,db=ja.id,Ea=Ta;a("#"+db).length;)db=ja.id+"_"+ ++Ea;if(Aa){Ca[db]=ja.icon;Ea=ja.svgicon?ja.svgicon:ja.id;if(ja.type=="app_menu")Ba["#"+
db+" > div"]=Ea;else Ba["#"+db]=Ea}else Cb=ja.type=="menu"?"":a('<img src="'+ja.icon+'">');var Ya,Fa;switch(ja.type){case "mode_flyout":case "mode":Ya="tool_button";if(ja.cls)Ya+=" "+ja.cls;Fa="#tools_left";break;case "context":Ya="tool_button";Fa="#"+ja.panel;a(Fa).length||a("<div>",{id:ja.panel}).appendTo("#tools_top");break;case "menu":Ya="menu_item tool_button";Fa="#"+(ja.after||ja.panel);break;case "app_menu":Ya="";Fa=ja.parent||"#main_menu ul";a(Fa).length||a("<div>",{id:ja.panel}).appendTo("#tools_top")}var ib=
a(ja.list||ja.type=="app_menu"?"<li/>":"<div/>").attr("id",db).attr("title",ja.title).addClass(Ya);if(!ja.includeWith&&!ja.list){if("position"in ja)a(Fa).children().eq(ja.position).before(ib);else ja.type!="menu"||!ja.after?ib.appendTo(Fa):a(Fa).after(ib);if(ja.type=="mode_flyout"){Ea=a(ib);Ya=Ea.parent();if(!Ea.parent().hasClass("tools_flyout")){var eb=Ea[0].id.replace("tool_","tools_"),lb=Ea.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Ea.before(lb);Ya=zb(eb,Ea);
Ya.data("isLibrary",true);lb.data("isLibrary",true)}Ba["#"+eb+"_show"]=ja.id;db=Ab["#"+Ya[0].id]=[{sel:"#"+db,fn:ja.events.click,icon:ja.id,isDefault:true},$b]}else if(ja.type=="app_menu"||ja.type=="menu")ib.append(ja.title)}else if(ja.list){ib.addClass("push_button");a("#"+ja.list+"_opts").append(ib);if(ja.isDefault){a("#cur_"+ja.list).append(ib.children().clone());Ea=ja.svgicon?ja.svgicon:ja.id;Ba["#cur_"+ja.list]=Ea}}else if(ja.includeWith){Fa=ja.includeWith;Ea=a(Fa.button);Ya=Ea.parent();if(!Ea.parent().hasClass("tools_flyout")){eb=
Ea[0].id.replace("tool_","tools_");lb=Ea.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Ea.before(lb);Ya=zb(eb,Ea)}var $b=qc.getButtonData(Fa.button);if(Fa.isDefault)Ba["#"+eb+"_show"]=ja.id;db=Ab["#"+Ya[0].id]=[{sel:"#"+db,fn:ja.events.click,icon:ja.id,key:ja.key,isDefault:ja.includeWith?ja.includeWith.isDefault:0},$b];eb="position"in Fa?Fa.position:"last";$b=Ya.children().length;if(!isNaN(eb)&&eb>=0&&eb<$b)Ya.children().eq(eb).before(ib);else{Ya.append(ib);db.reverse()}}Aa||
ib.append(Cb);ja.list||a.each(ja.events,function(Qb,Zb){if(Qb=="click")if(ja.type=="mode"){ja.includeWith?ib.bind(Qb,Zb):ib.bind(Qb,function(){La(ib)&&Zb()});if(ja.key){a(document).bind("keydown",ja.key,Zb);ja.title&&ib.attr("title",ja.title+" ["+ja.key+"]")}}else ib.bind(Qb,Zb);else ib.bind(Qb,Zb)});Pa(Ab)});a.each(ya,function(){Fb(this.elem,this.list,this.callback,{seticon:true})});if(Aa)la=false;a.svgIcons(Aa,{w:27,h:27,id_match:false,no_img:!Q,fallback:Ca,placement:Ba,callback:function(){b.iconsize&&
b.iconsize!="m"&&J();la=true;wa()}})}wa()});f.textActions.setInputElem(a("#text")[0]);var Sa='<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(p,B){Sa+='<div class="palette_item" style="background-color: '+B+';" data-rgb="'+B+'"></div>'});a("#palette").append(Sa);Sa="";a.each(["#FFF","#888","#000"],function(){Sa+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Sa);var gb=a("#bg_blocks div");gb.each(function(){a(this).click(function(){gb.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))q(a.pref("bkgd_color"),a.pref("bkgd_url"));
else a.pref("bkgd_url")&&q(o.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var Ia=function(p){var B=p.value/100;if(B<0.0010)p.value=0.1;else{p=f.getZoom();Xa(window,{width:0,height:0,x:(ra[0].scrollLeft+ra.width()/2)/p,y:(ra[0].scrollTop+ra.height()/2)/p,zoom:B},true)}},rb=function(p,B){if(B==null)B=p.value;a("#group_opacity").val(B);if(!p||!p.handle)a("#opac_slider").slider("option","value",B);f.setOpacity(B/100)},
sb=function(p,B,J){if(B==null)B=p.value;a("#blur").val(B);var S=false;if(!p||!p.handle){a("#blur_slider").slider("option","value",B);S=true}J?f.setBlurNoUndo(B):f.setBlur(B,S)},mb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());mb()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());mb()});a("select").change(function(){a(this).blur()});var hb=false;a("#selLayerNames").change(function(){var p=
this.options[this.selectedIndex].value,B=e.notification.QmoveElemsToLayer.replace("%s",p),J=function(S){if(S){hb=true;f.moveSelectedToLayer(p);f.clearSelection();Hb()}};if(p)hb?J(true):a.confirm(B,J)});a("#font_family").change(function(){f.setFontFamily(this.value)});a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Da(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):
f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var p=this.getAttribute("data-attr"),B=this.value;if(svgedit.units.isValidUnit(p,B,aa))this.blur();else{a.alert(e.notification.invalidAttrValGiven);this.value=aa.getAttribute(p);return false}if(p!=="id")if(isNaN(B))B=f.convertToNum(p,B);else if(d.baseUnit!=="px"){var J=svgedit.units.getTypeMap();if(aa[p]||f.getMode()==="pathedit"||p==="x"||p==="y")B*=J[d.baseUnit]}if(p==="id"){p=
aa;f.clearSelection();p.id=B;f.addToSelection([p],true)}else f.changeSelectedAttribute(p,B);this.blur()});a("#palette").mouseover(function(){var p=a('<input type="hidden">');a(this).append(p);p.focus().remove()});a(".palette_item").mousedown(function(){var p=a("#tool_stroke").hasClass("active"),B=p?"stroke":"fill",J=a(this).attr("data-rgb"),S=null;if(J==="transparent"||J==="initial"||J==="#none"){J="none";S=new a.jGraduate.Paint}else S=new a.jGraduate.Paint({alpha:100,solidColor:J.substr(1)});c.paintBox[B].setPaint(S);
if(p){f.setColor("stroke",J);J!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",J);J!="none"&&f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}}).bind("contextmenu",function(p){p.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Xb()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Xb()});var La=function(p,B){if(a(p).hasClass("disabled"))return false;
if(a(p).parent().hasClass("tools_flyout"))return true;var J=J||"normal";B||a(".tools_flyout").fadeOut(J);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(p).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var p=null,B=null,J=ra[0],S=false,Y=false;a("#svgcanvas").bind("mousemove mouseup",function(la){if(S!==false){J.scrollLeft-=la.clientX-p;J.scrollTop-=la.clientY-B;p=la.clientX;B=la.clientY;if(la.type===
"mouseup")S=false;return false}}).mousedown(function(la){if(la.button===1||Y===true){S=true;p=la.clientX;B=la.clientY;return false}});a(window).mouseup(function(){S=false});a(document).bind("keydown","space",function(la){f.spaceKey=Y=true;la.preventDefault()}).bind("keyup","space",function(la){la.preventDefault();f.spaceKey=Y=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&ra.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&ra.removeClass("out")})})();var Wa=a(".menu"),
jb=function(p){p.target.style.background="#fff";setTimeout(function(){p.target.style.background="#ddd"},50);setTimeout(function(){p.target.style.background="#fff"},150);setTimeout(function(){p.target.style.background="#ddd"},200);setTimeout(function(){p.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").live("click",function(p){jb(p)});a("svg, body").on("mousedown",function(p){top!=self&&!p.isTrigger&&typeof top.exports.setEditorFocus==
"function"&&top.exports.setEditorFocus();if(!a(p.target).hasClass("menu_title"))if(!a(p.target).hasClass("disabled")&&a(p.target).hasClass("menu_item"))jb(p);else{a("#menu_bar").removeClass("active");a("#tools_shapelib").is(":visible")&&!a(p.target).parents("#tools_shapelib_show, #tools_shapelib").length&&a("#tools_shapelib").hide();p.target.nodeName.toLowerCase()!="input"&&a("input").blur()}});var Eb=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(p,B,
J,S){if(p.altKey){p.preventDefault();p=f.getZoom()*100;B=Eb.length;for(Ib=0;Ib<B;Ib++){J=Math.min(B,Ib+1);if(S>0)zoom=Eb[Ib]<=p?Eb[J]:zoom;if(S<0)zoom=Eb[Ib]<p?Eb[Ib]:zoom}zoom&&Ia({value:zoom})}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){Wa.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(p,B,J){if(a(p).length!=0){var S=a(p).find("button"),Y=a(p).find("ul").attr("id",a(p)[0].id+"-list");
J||a("#option_lists").append(Y);var la=false;J&&a(p).addClass("dropup");Y.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!la){S.removeClass("down");Y.hide()}la=false});S.bind("mousedown",function(){if(S.hasClass("down")){S.removeClass("down");Y.hide()}else{S.addClass("down");if(!J){var wa=a(p).offset();Y.css({top:wa.top,left:wa.left-110})}Y.show();la=true}}).hover(function(){la=true}).mouseout(function(){la=false})}};var Fb=function(p,B,J,S){var Y=a(p);B=a(B);var la=false,wa=S.dropUp;
wa&&a(p).addClass("dropup");B.find("li").bind("mouseup",function(){if(S.seticon){da("#cur_"+Y[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}J.apply(this,arguments)});a(window).mouseup(function(){if(!la){Y.removeClass("down");B.hide();B.css({top:0,left:0})}la=false});B.height();a(p).bind("mousedown",function(){var ya=a(p).offset();if(wa){ya.top-=B.height();ya.left+=8}else ya.top+=a(p).height();a(B).offset(ya);if(Y.hasClass("down")){Y.removeClass("down");B.hide();
B.css({top:0,left:0})}else{Y.addClass("down");B.show();la=true;return false}}).hover(function(){la=true}).mouseout(function(){la=false});S.multiclick&&B.mousedown(function(){la=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var p=parseInt(a(this).text().split("%")[0]);rb(false,p)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},
stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(p,B){rb(B)}});c.addDropDown("#blur_dropdown",a.noop);var nb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(p,B){nb=false;sb(B);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){nb=true},slide:function(p,B){sb(B,null,nb)}});c.addDropDown("#zoom_dropdown",function(){var p=a(this),B=p.attr("data-val");B?Xa(window,B):Ia({value:parseInt(p.text())})},true);Fb("#stroke_linecap","#linecap_opts",
function(){w(this,true)},{dropUp:true});Fb("#stroke_linejoin","#linejoin_opts",function(){w(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var p=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(p,"page")})});(function(){var p,B=function(){a(p).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){p=this;V="toolbars";ra.mousedown(B)}).blur(function(){V="canvas";ra.unbind("mousedown",B);f.getMode()==
"textedit"&&a("#text").focus()})})();var Gb=function(){if(La("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},Ob=function(){La("#tool_fhpath")&&f.setMode("fhpath")},Kb=function(){La("#tool_line")&&f.setMode("line")},Ub=function(){La("#tool_rect")&&f.setMode("rect")},na=function(){La("#tool_ellipse")&&f.setMode("ellipse")},ba=function(){La("#tool_image")&&f.setMode("image")},va=function(){La("#tool_zoom")&&
f.setMode("zoom")},O=function(){if(La("#tool_zoom")){s();ta()}},H=function(){La("#tool_text")&&f.setMode("text")},Z=function(){La("#tool_path")&&f.setMode("path")},Oa=function(){if(aa!=null||ma)f.deleteSelectedElements()},Za=function(){if(aa!=null||ma){window.event.type==="keydown"&&vb(a("#edit_menu"));f.cutSelectedElements()}},fb=function(){if(aa!=null||ma){window.event.type==="keydown"&&vb(a("#edit_menu"));f.copySelectedElements()}},wb=function(){window.event.type==="keydown"&&vb(a("#edit_menu"));
var p=f.getZoom(),B=(ra[0].scrollLeft+ra.width()/2)/p-f.contentW;p=(ra[0].scrollTop+ra.height()/2)/p-f.contentH;f.pasteElements("point",B,p)},xb=function(){if(aa!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveToTopSelectedElement()}},Db=function(){if(aa!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveToBottomSelectedElement()}},pb=function(){if(aa!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveUpDownSelected("Up")}},Pb=function(){if(aa!=null){window.event.type===
"keydown"&&vb(a("#object_menu"));f.moveUpDownSelected("Down")}},cb=function(p){if(aa!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveUpDownSelected(p)}},Nb=function(){if(aa!=null){f.convertToPath();elems=f.getSelectedElems();f.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");f.setMode("pathedit");ua.toEditMode(elems[0]);f.clearSelection()}},Sb=function(){aa!=null&&ua.reorient()},ac=function(){if(aa!=null||ma)a.prompt(e.notification.enterNewLinkURL,
"http://",function(p){p&&f.makeHyperlink(p)})},Lb=function(p,B){if(aa!=null||ma){if(d.gridSnapping){var J=f.getZoom()*d.snappingStep;p*=J;B*=J}a("input").blur();f.moveSelectedElements(p,B)}},qb=function(){var p=!a("#tool_node_link").hasClass("push_button_pressed");p?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",false);ua.linkControlPoints(p)},
Ua=function(){ua.getNodePoint()&&ua.clonePathNode()},kc=function(){ua.getNodePoint()&&ua.deletePathNode()},hc=function(){var p=a("#tool_add_subpath"),B=!p.hasClass("push_button_pressed");B?p.addClass("push_button_pressed").removeClass("tool_button"):p.removeClass("push_button_pressed").addClass("tool_button");ua.addSubPath(B)},gc=function(){ua.opencloseSubPath()},ec=function(){f.cycleElement(1)},ic=function(){f.cycleElement(0)},Tb=function(p,B){if(!(aa==null||ma)){p||(B*=-1);var J=a("#angle").val()*
1+B;f.setRotationAngle(J);bb()}},cc=function(){var p=d.dimensions;a.confirm(e.notification.QwantToClear,function(B){if(B){ta();f.clear();f.setResolution(p[0],p[1]);Wb(true);s();Hb();bb();Na();f.runExtensions("onNewDocument")}})},oc=function(){f.setBold(!f.getBold());bb();return false},Yb=function(){f.setItalic(!f.getItalic());bb();return false},Bb=function(){if(!l.pngsave){var p=e.notification.loadingImage;ca=window.open("data:text/html;charset=utf-8,<title>"+p+"</title><h1>"+p+"</h1>")}window.canvg?
f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},mc=function(){f.open()},lc=function(){},vb=function(p){var B=p.prev();B.css("background","#09f");setTimeout(function(){B.css("background","")},200)},ub=function(){if(ia.getUndoStackSize()>0){window.event.type==="keydown"&&vb(a("#edit_menu"));ia.undo();Hb()}},bc=function(){if(ia.getRedoStackSize()>0){window.event.type==="keydown"&&vb(a("#edit_menu"));ia.redo();Hb()}},g=function(){if(ma)f.groupSelectedElements();
else aa&&f.ungroupSelectedElement()},h=function(){window.event.type==="keydown"&&vb(a("#edit_menu"));f.cloneSelectedElements(20,20)},k=function(){var p=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(p,a("#align_relative_to").val())},v=function(){var p=document.querySelector("#tool_stroke rect"),B=document.querySelector("#tool_fill rect"),J=B.getAttribute("fill"),S=p.getAttribute("fill");p=parseFloat(p.getAttribute("stroke-opacity"));if(isNaN(p))p=100;B=parseFloat(B.getAttribute("fill-opacity"));
if(isNaN(B))B=100;S=ab(S,p,"stroke");J=ab(J,B,"fill");c.paintBox.fill.setPaint(S,true);c.paintBox.stroke.setPaint(J,true)},s=function(p){var B=f.getResolution();p=p?B.zoom*p:1;a("#zoom").val(p*100);f.setZoom(p);E();Wb(true)},G=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");ra.toggleClass("wireframe");if(!vc){var p=a("#wireframe_rules");p.length?p.empty():a('<style id="wireframe_rules"></style>').appendTo("head");
E()}},z=function(){var p=!a("#tool_snap").hasClass("push_button_pressed");p?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");d.gridSnapping=p;xa()},A=function(){f.clearSelection();a("#tool_canvas").trigger("click")},C=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},F=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);d.showRulers=
false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=true}a("#rulers").toggle(!!d.showRulers)},E=function(){if(!vc){var p="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(ra.hasClass("wireframe")?p:"")}},D=function(p,B){if(!Ga){Ga=true;a("#save_output_btns").toggle(!!B);a("#tool_source_back").toggle(!B);var J=sa=f.getSvgString();a("#svg_source_textarea").val(J);a("#svg_source_editor").fadeIn();
N();a("#svg_source_textarea").focus()}},L=function(){if(!Ma){Ma=true;a("#image_save_opts input").val([b.img_save]);var p=f.getResolution();if(d.baseUnit!=="px"){p.w=svgedit.units.convertUnit(p.w)+d.baseUnit;p.h=svgedit.units.convertUnit(p.h)+d.baseUnit}a(".canvas_width").val(p.w);a(".canvas_height").val(p.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},I=function(){if(!Ra){Ra=true;var p=a("#bg_blocks div"),B=a.pref("bkgd_color"),J=a.pref("bkgd_url");p.each(function(){var S=
a(this),Y=S.css("background-color")==B;S.toggleClass("cur_background",Y);Y&&a("#canvas_bg_url").removeClass("cur_background")});B||p.eq(0).addClass("cur_background");J&&a("#canvas_bg_url").val(J);a("grid_snapping_step").attr("value",d.snappingStep);d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},N=function(){var p=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",p)},X=function(){if(Ga){var p=
function(){f.clearSelection();ob();s();Hb();R();Na()};f.setSvgString(a("#svg_source_textarea").val())?p():a.confirm(e.notification.QerrorsRevertToSource,function(B){if(!B)return false;p()});ta()}},R=function(p){p=p||f.getDocumentTitle();p=Va+(p?": "+p:"");a("title:first").text(p)},pa=function(){var p=a("#canvas_width"),B=p.val(),J=a("#canvas_height"),S=J.val();if(B!="fit"&&!svgedit.units.isValidUnit("width",B)){a.alert(e.notification.invalidAttrValGiven);p.parent().addClass("error");return false}p.parent().removeClass("error");
if(S!="fit"&&!svgedit.units.isValidUnit("height",S)){a.alert(e.notification.invalidAttrValGiven);J.parent().addClass("error");return false}J.parent().removeClass("error");if(!f.setResolution(B,S)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Wb();Vb()},xa=function(){var p=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";q(p,a("#canvas_bg_url").val());za(a("#iconsize").val());d.gridSnapping=a("#tool_snap").hasClass("push_button_pressed");
d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&fa();d.baseUnit=a("#base_unit").val();f.setConfig(d);Wb();Mb()},da=c.setIcon=function(p,B){var J=typeof B==="string"?a.getSvgIcon(B,true):B.clone();J?a(p).find("img").replaceWith(J):console.log("NOTE: Icon image missing: "+B)},ka;ka=function(){var p=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,B=document.getElementsByTagName("script")[0],J;for(J in B.style)if(p.test(J))return J.match(p)[0];
if("WebkitOpacity"in B.style)return"Webkit";if("KhtmlOpacity"in B.style)return"Khtml";return""}();var oa=function(p,B){ka.toLowerCase();var J=["top","left","bottom","right"];p.each(function(){for(var S=a(this),Y=S.outerWidth()*(B-1),la=S.outerHeight()*(B-1),wa=0;wa<4;wa++){var ya=J[wa],Ca=S.data("orig_margin-"+ya);if(Ca==null){Ca=parseInt(S.css("margin-"+ya));S.data("orig_margin-"+ya,Ca)}Ca=Ca*B;if(ya==="right")Ca+=Y;else if(ya==="bottom")Ca+=la;S.css("margin-"+ya,Ca)}})},za=c.setIconSize=function(p,
B){if(!(p==b.size&&!B)){var J=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"),S=1;S=typeof p=="number"?p:{s:0.75,m:1,l:1.25,xl:1.5}[p];c.tool_scale=T=S;Ja();var Y=J.parents(":hidden");Y.css("visibility","hidden").show();oa(J,S);Y.css("visibility","visible").hide();a.pref("iconsize",p);a("#iconsize").val(p);Y={"#tools_top":{left:50,height:72},
"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};J=a("#tool_size_rules");if(J.length)J.empty();else J=a('<style id="tool_size_rules"></style>').appendTo("head");if(p!="m"){var la="";a.each(Y,function(wa,ya){wa="#svg_editor "+wa.replace(/,/g,", #svg_editor");la+=wa+"{";a.each(ya,function(Ca,Ba){if(typeof Ba==="number")var Aa=Ba*S+"px";else if(Ba[p]||Ba.all)Aa=Ba[p]||Ba.all;la+=Ca+":"+Aa+";"});la+="}"});Y="-"+ka.toLowerCase()+"-";la+="#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{"+
Y+"transform: scale("+S+");} #svg_editor div.toolset .toolset {"+Y+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+Y+"transform: scale("+1/S+");}";J.text(la)}Ja()}},kb=function(){a("#dialog_box").hide();if(!Ga&&!Ma&&!Ra)Qa&&f.leaveContext();else{if(Ga)sa!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(p){p&&ob()}):ob();else if(Ma)Vb();else Ra&&Mb();Xb()}},ob=function(){a("#svg_source_editor").hide();Ga=false;a("#svg_source_textarea").blur()},
Vb=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([b.img_save]);Ma=false},Mb=function(){a("#svg_prefs").hide();Ra=false},Rb={width:a(window).width(),height:a(window).height()},Xb=a.noop,dc;svgedit.browser.isIE()&&function(){Xb=function(){if(ra[0].scrollLeft===0&&ra[0].scrollTop===0){ra[0].scrollLeft=dc.left;ra[0].scrollTop=dc.top}};dc={left:ra[0].scrollLeft,top:ra[0].scrollTop};a(window).resize(Xb);
svgEditor.ready(function(){setTimeout(function(){Xb()},500)});ra.scroll(function(){dc={left:ra[0].scrollLeft,top:ra[0].scrollTop}})}();a(window).resize(function(){Ga&&N();a.each(Rb,function(p,B){var J=a(window)[p]();ra[0]["scroll"+(p==="width"?"Left":"Top")]-=(J-B)/2;Rb[p]=J})});(function(){ra.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ra[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ra[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
a("#change_image_url").click(M);(function(){var p=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],B="";a.each(p,function(J,S){B+="#tool_"+S+(J==p.length-1?",":"")});a(B).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",
function(){a(this).removeClass("tool_button_current")})})();if(W&&!window.opera){W=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(var Ib=W.length;Ib--;){var rc=document.getElementById(W[Ib]);if(rc!=null){var sc=rc.title,wc=sc.indexOf("Ctrl+");rc.title=[sc.substr(0,wc),"Cmd+",sc.substr(wc+5)].join("")}}}var tc=function(p){var B=p[0].id=="stroke_color"?"stroke":"fill",J=p[0].id=="canvas_color";if(J)B="canvas";var S=c.paintBox[B].paint;p=B=="stroke"?"Pick a Stroke Paint and Opacity":
"Pick a Fill Paint and Opacity";J=J?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(J).jGraduate({paint:S,window:{pickerTitle:p},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(Y){S=new a.jGraduate.Paint(Y);c.paintBox[B].setPaint(S);f.setPaint(B,S);a("#color_picker").hide()},function(){a("#color_picker").hide()})};W=function(p,B){var J=document.getElementById("canvas_background"),
S={color:"fff",opacity:1};if(B=="stroke")S=d.initStroke;if(B=="fill")S=d.initFill;if(B=="canvas"&&J)if(J=J.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))S={color:("0"+parseInt(J[1],10).toString(16)).slice(-2)+("0"+parseInt(J[2],10).toString(16)).slice(-2)+("0"+parseInt(J[3],10).toString(16)).slice(-2),opacity:1};J=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+S.color+'" opacity="'+S.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',
"text/xml").documentElement;J=a(p)[0].appendChild(document.importNode(J,true));J.setAttribute("width",24.5);this.rect=J.firstChild;this.defs=J.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:S.color});this.type=B;this.setPaint=function(Y,la){this.paint=Y;var wa="none",ya=Y.type,Ca=Y.alpha/100;switch(ya){case "solidColor":wa=Y[ya]=="none"||Y[ya]=="one"?"none":"#"+Y[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);
this.grad=this.defs.appendChild(Y[ya]);wa="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",wa);this.rect.setAttribute("opacity",Ca);if(la){f.setColor(this.type,wa,true);f.setPaintOpacity(this.type,Ca,true)}if(this.type=="canvas"){(ya=document.getElementById("canvas_background"))?ya.setAttribute("fill",wa):Ka(wa);console.log(ya.getAttribute("fill"))}};this.update=function(Y){if(aa){var la=this.type;switch(aa.tagName){case "use":case "image":case "foreignObject":return;
case "g":case "a":for(var wa=null,ya=aa.getElementsByTagName("*"),Ca=0,Ba=ya.length;Ca<Ba;Ca++){var Aa=ya[Ca].getAttribute(la);if(Ca===0)wa=Aa;else if(wa!==Aa){wa=null;break}}if(wa===null){ya=null;return}ya=wa;wa=1;break;default:wa=parseFloat(aa.getAttribute(la+"-opacity"));if(isNaN(wa))wa=1;ya=la==="fill"?"black":"none";ya=aa.getAttribute(la)||ya}if(Y){f.setColor(la,ya,true);f.setPaintOpacity(la,wa,true)}wa*=100;this.setPaint(ab(ya,wa,la))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var Y=
new a.jGraduate.Paint({copy:this.paint});f.setPaint(B,Y)}}};c.paintBox.fill=new W("#fill_color","fill");c.paintBox.stroke=new W("#stroke_color","stroke");c.paintBox.canvas=new W("#canvas_color","canvas");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);W=c.paintBox.fill.rect.cloneNode(false);W.setAttribute("style","vector-effect:non-scaling-stroke");var vc=W.style.vectorEffect==="non-scaling-stroke";W.removeAttribute("style");W=c.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof W.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(W).remove();setTimeout(function(){f.embedImage("images/placeholder.svg",function(p){if(!p){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);b.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",e.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))tc(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_canvas").click(function(){tc(a("#canvas_color"))});a("#tool_stroke").click(function(){if(a("#tool_stroke").hasClass("active"))tc(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(p){a("#tools_stacking").show();
p.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});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("#layer_new").click(function(){var p=f.getCurrentDrawing().getNumLayers();do var B=e.layers.layer+" "+ ++p;while(f.getCurrentDrawing().hasLayer(B));a.prompt(e.notification.enterUniqueLayerName,B,function(J){if(J)if(f.getCurrentDrawing().hasLayer(J))a.alert(e.notification.dupeLayerName);else{f.createLayer(J);bb();Hb()}})});a("#layer_delete").click(U);a("#layer_up").click(function(){K(-1)});a("#layer_down").click(function(){K(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();
var p=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(B){if(B)if(p==B||f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.layerHasThatName);else{f.renameCurrentLayer(B);Hb()}})});var fc=-1,nc=false,uc=false,xc=function(p){if(uc)if(fc!=-1){nc=true;p=fc-p.pageX;var B=a("#sidepanels"),J=parseInt(B.css("width"));if(J+p>300)p=300-J;else if(J+p<2)p=2-J;if(p!=0){fc-=p;J=a("#layerpanel");ra.css("right",parseInt(ra.css("right"))+p);B.css("width",
parseInt(B.css("width"))+p);J.css("width",parseInt(J.css("width"))+p);B=a("#ruler_x");B.css("right",parseInt(B.css("right"))+p)}}};a("#sidepanel_handle").mousedown(function(p){fc=p.pageX;a(window).mousemove(xc);uc=false;setTimeout(function(){uc=true},20)}).mouseup(function(){nc||yc();fc=-1;nc=false});a(window).mouseup(function(){fc=-1;nc=false;a("#svg_editor").unbind("mousemove",xc)});var yc=function(p){var B=parseInt(a("#sidepanels").css("width"));p=(B>2||p?2:150)-B;B=a("#sidepanels");var J=a("#layerpanel"),
S=a("#ruler_x");ra.css("right",parseInt(ra.css("right"))+p);B.css("width",parseInt(B.css("width"))+p);J.css("width",parseInt(J.css("width"))+p);S.css("right",parseInt(S.css("right"))+p)},zc=function(p){for(var B=Array(f.getCurrentDrawing().getNumLayers()),J=0;J<B.length;++J)B[J]=f.getCurrentDrawing().getLayerName(J);if(p)for(J=0;J<B.length;++J)B[J]!=p&&f.getCurrentDrawing().setLayerOpacity(B[J],0.5);else for(J=0;J<B.length;++J)f.getCurrentDrawing().setLayerOpacity(B[J],1)},Hb=function(){var p=a("#layerlist tbody"),
B=a("#selLayerNames");p.empty();B.empty();for(var J=f.getCurrentDrawing().getCurrentLayerName(),S=f.getCurrentDrawing().getNumLayers(),Y=a.getSvgIcon("eye");S--;){var la=f.getCurrentDrawing().getLayerName(S),wa='<tr class="layer';if(la==J)wa+=" layersel";wa+='">';wa+=f.getCurrentDrawing().getLayerVisibility(la)?'<td class="layervis"/><td class="layername" >'+la+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+la+"</td></tr>";p.append(wa);B.append('<option value="'+la+'">'+la+
"</option>")}if(Y!==undefined){Y.clone();a("td.layervis",p).append(Y.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});zc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});zc()});a("#layerlist td.layervis").click(function(){var ya=
a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Ca=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Ca);Ca?a(this).removeClass("layerinvis"):a(this).addClass("layerinvis")});for(B=5-a("#layerlist tr.layer").size();B-- >0;)p.append('<tr><td style="color:white">_</td><td/></tr>')};Hb();a(window).bind("load resize",function(){ra.css("line-height",ra.height()+"px")});a("#resolution").change(function(){var p=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value==
"content")p.val("fit").attr("disabled","disabled");else{var B=this.value.split("x");a("#canvas_width").val(B[0]);a("#canvas_height").val(B[1]);p.removeAttr("disabled")}else a("#canvas_width").val()=="fit"&&p.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var qc=function(){var p=[{sel:"#tool_select",fn:Gb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Ob,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Kb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ub,evt:"click",
key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:na,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Z,evt:"click",key:["P",true]},{sel:"#tool_text",fn:H,evt:"click",key:["T",true]},{sel:"#tool_image",fn:ba,evt:"mouseup"},{sel:"#tool_zoom",fn:va,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:cc,evt:"mouseup",key:[ha+"N",true]},{sel:"#tool_save",fn:function(){Ga?X():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[ha+"S",true]},{sel:"#tool_export",fn:Bb,evt:"mouseup"},
{sel:"#tool_open",fn:mc,evt:"mouseup"},{sel:"#tool_import",fn:lc,evt:"mouseup"},{sel:"#tool_source",fn:D,evt:"click",key:[ha+"U",true]},{sel:"#tool_wireframe",fn:G,evt:"click"},{sel:"#tool_snap",fn:z,evt:"click"},{sel:"#tool_rulers",fn:F,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:kb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:X,evt:"click"},{sel:"#tool_docprops_save",fn:pa,evt:"click"},{sel:"#tool_docprops",
fn:L,evt:"mouseup"},{sel:"#tool_prefs_save",fn:xa,evt:"click"},{sel:"#tool_prefs_option",fn:function(){I();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Oa,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:Sb,evt:"click"},{sel:"#tool_node_link",fn:qb,evt:"click"},{sel:"#tool_node_clone",fn:Ua,evt:"click"},{sel:"#tool_node_delete",fn:kc,evt:"click"},{sel:"#tool_openclose_path",fn:gc,evt:"click"},{sel:"#tool_add_subpath",fn:hc,evt:"click"},{sel:"#tool_move_top",
fn:xb,evt:"click",key:ha+"shift+up"},{sel:"#tool_move_bottom",fn:Db,evt:"click",key:ha+"shift+down"},{sel:"#tool_move_up",fn:pb,evt:"click",key:[ha+"up",true]},{sel:"#tool_move_down",fn:Pb,evt:"click",key:[ha+"down",true]},{sel:"#tool_topath",fn:Nb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ac,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:h,evt:"click",key:[ha+"D",true]},{sel:"#tool_group",fn:g,evt:"click",key:[ha+"G",true]},{sel:"#tool_ungroup",fn:g,evt:"click",key:ha+"shift+G"},
{sel:"#tool_unlink_use",fn:g,evt:"click"},{sel:"[id^=tool_align]",fn:k,evt:"click"},{sel:"#tool_switch",fn:v,evt:"click",key:["shift+x",true]},{sel:"#tool_undo",fn:ub,evt:"click",key:ha+"z"},{sel:"#tool_redo",fn:bc,evt:"click",key:["y",true]},{sel:"#tool_canvas_color_menu",fn:A,evt:"click"},{sel:"#tool_cut",fn:Za,evt:"click",key:ha+"x"},{sel:"#tool_copy",fn:fb,evt:"click",key:ha+"c"},{sel:"#tool_paste",fn:wb,evt:"click",key:ha+"v"},{sel:"#tool_bold",fn:oc,evt:"mousedown",key:[ha+"B",true]},{sel:"#tool_italic",
fn:Yb,evt:"mousedown",key:[ha+"I",true]},{sel:"#copy_save_done",fn:kb,evt:"click"},{key:"ctrl+left",fn:function(){Tb(0,1)}},{key:"ctrl+right",fn:function(){Tb(1,1)}},{key:"ctrl+shift+left",fn:function(){Tb(0,5)}},{key:"ctrl+shift+right",fn:function(){Tb(1,5)}},{key:"shift+O",fn:ic},{key:"shift+P",fn:ec},{key:[ha+"+",true],fn:function(){s(2)}},{key:[ha+"-",true],fn:function(){s(0.5)}},{key:["up",true],fn:function(){Lb(0,-1)}},{key:["down",true],fn:function(){Lb(0,1)}},{key:["left",true],fn:function(){Lb(-1,
0)}},{key:["right",true],fn:function(){Lb(1,0)}},{key:"shift+up",fn:function(){Lb(0,-10)}},{key:"shift+down",fn:function(){Lb(0,10)}},{key:"shift+left",fn:function(){Lb(-10,0)}},{key:"shift+right",fn:function(){Lb(10,0)}},{key:["alt+up",true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",
true],fn:function(){f.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){f.cloneSelectedElements(10,0)}},{key:ha+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:ha+"shift+z",fn:bc},{key:"esc",fn:C}],B={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var J={};a.each(p,function(S,
Y){if(Y.sel){var la=a(Y.sel);if(la.length==0)return true;if(Y.evt){if(svgedit.browser.isTouch()&&Y.evt==="click")Y.evt="mousedown";la[Y.evt](Y.fn)}if(Y.parent&&a(Y.parent+"_show").length!=0){var wa=a(Y.parent);wa.length||(wa=zb(Y.parent.substr(1)));wa.append(la);a.isArray(J[Y.parent])||(J[Y.parent]=[]);J[Y.parent].push(Y)}}if(Y.key){var ya=Y.fn,Ca=false;if(a.isArray(Y.key)){wa=Y.key[0];if(Y.key.length>1)Ca=Y.key[1]}else wa=Y.key;wa+="";svgedit.browser.isMac&&wa.indexOf("+")!=-1&&wa.split("+")[0]==
"ctrl"&&wa.replace("ctrl","cmd");a.each(wa.split("/"),function(Aa,Ab){a(document).bind("keydown",Ab,function(Ta){ya();Ca&&Ta.preventDefault();return false})});if(Y.sel&&!Y.hidekey&&la.attr("title")){var Ba=la.attr("title").split("[")[0]+" ("+wa+")";B[wa]=Y.sel;la.parents("#main_menu").length||la.attr("title",Ba)}}});Pa(J);a(".attr_changer, #image_url").bind("keydown","return",function(S){a(this).change();S.preventDefault()});a(window).bind("keydown","tab",function(S){if(V==="canvas"){S.preventDefault();
ec()}}).bind("keydown","shift+tab",function(S){if(V==="canvas"){S.preventDefault();ic()}});a("#tool_zoom").dblclick(O)},setTitles:function(){a.each(B,function(J,S){var Y=a(S).parents("#main_menu").length;a(S).each(function(){var la=Y?a(this).text().split(" [")[0]:this.title.split(" [")[0],wa="";a.each(J.split("/"),function(ya,Ca){var Ba=Ca.split("+"),Aa="";if(Ba.length>1){Aa=Ba[0]+"+";Ca=Ba[1]}wa+=(ya?"/":"")+Aa+(e["key_"+Ca]||Ca)});if(Y)this.lastChild.textContent=la+" ["+wa+"]";else this.title=la+
" ["+wa+"]"})})},getButtonData:function(J){var S;a.each(p,function(Y,la){if(la.sel===J)S=la});return S}}}();qc.setAll();c.ready(function(){var p=d.initTool,B=a("#tools_left, #svg_editor .tools_flyout"),J=B.find("#tool_"+p);p=B.find("#"+p);(J.length?J:p.length?p:a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&yc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=true;
d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(p){f.setRectRadius(p.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(p){var B=p.value;if(B==0&&aa&&["line","polyline"].indexOf(aa.nodeName)>=0)B=p.value=1;f.setStrokeWidth(B)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(p){f.setRotationAngle(p.value);a("#tool_reorient").toggleClass("disabled",
p.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(p,B){var J=p.value-0,S=J+B,Y=S>=J;if(B===0)return J;return J>=24?Y?Math.round(J*1.1):Math.round(J/1.1):J<=1?Y?J*2:J/2:S},callback:function(p){f.setFontSize(p.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:rb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:sb});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(p,B){var J=p.value-0;if(J===0)return 100;var S=J+B;if(B===0)return J;
return J>=100?S:S>=J?J*2:J/2},callback:Ia}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(p){switch(p){case "delete":Oa();break;case "cut":Za();break;case "copy":fb();break;case "paste":f.pasteElements();break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":xb();break;case "move_up":cb("Up");break;case "move_down":cb("Down");break;case "move_back":Db();
break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(p)&&svgedit.contextmenu.getCustomHandler(p).call()}f.clipBoard.length&&qa.enableContextMenuItems("#paste,#paste_in_place")});W=function(p){switch(p){case "dupe":P();break;case "delete":U();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();bb();Hb()}break;case "merge_all":f.mergeAllLayers();bb();Hb()}};a("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},
W);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},W);a(".contextMenu li").mousedown(function(p){p.preventDefault()});a("#cmenu_canvas li").disableContextMenu();qa.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(ia.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(p){a("#main_menu").hide();ia.getUndoStackSize()===0?p(true):a.confirm(e.notification.QwantToOpen,
p)};if(window.FileReader){W=a('<input type="file">').change(function(){var p=this;c.openPrep(function(B){if(B){f.clear();if(p.files.length==1){B=new FileReader;B.onloadend=function(J){n(J.target.result);Wb()};B.readAsText(p.files[0])}}})});a("#tool_open").show().prepend(W);W=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var p=new FileReader;p.onloadend=function(B){f.importSvgString(B.target.result,true);Wb()};p.readAsText(this.files[0])}});a("#tool_import").show().prepend(W)}var Wb=
c.updateCanvas=function(p,B){var J=ra.width(),S=ra.height(),Y=J,la=S,wa=f.getZoom(),ya=a("#svgcanvas"),Ca={x:ra[0].scrollLeft+Y/2,y:ra[0].scrollTop+la/2},Ba=d.canvas_expansion;J=Math.max(Y,f.contentW*wa*Ba);S=Math.max(la,f.contentH*wa*Ba);J==Y&&S==la?ra.css("overflow","hidden"):ra.css("overflow","scroll");Ba=ya.height()/2;var Aa=ya.width()/2;ya.width(J).height(S);var Ab=S/2,Ta=J/2,ja=f.updateCanvas(J,S),Cb=Ta/Aa;J=J/2-Y/2;S=S/2-la/2;if(B){B.x+=ja.x;B.y+=ja.y}else B={x:Ta+(Ca.x-Aa)*Cb,y:Ab+(Ca.y-Ba)*
Cb};if(p)if(f.contentW>ra.width()){ra[0].scrollLeft=ja.x-10;ra[0].scrollTop=ja.y-10}else{ra[0].scrollLeft=J;ra[0].scrollTop=S}else{ra[0].scrollLeft=B.x-Y/2;ra[0].scrollTop=B.y-la/2}if(d.showRulers){fa(ya,wa);ra.scroll()}},jc=[];for(Ib=0.1;Ib<1E5;Ib*=10){jc.push(1*Ib);jc.push(2*Ib);jc.push(5*Ib)}Wb(true);try{var Ac=function(p){if(window.JSON&&JSON.stringify)return JSON.stringify(p);var B=arguments.callee;if(typeof p=="boolean"||typeof p=="number")return p+"";else if(typeof p=="string")return'"'+p.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(Y){return"\\u"+("0000"+Y.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(p.length){for(var J=0;J<p.length;J++)p[J]=B(p[J]);return"["+p.join(",")+"]"}else{J=[];for(var S in p)J.push(B(S)+":"+B(p[S]));return"{"+J.join(",")+"}"}};window.addEventListener("message",function(p){var B=parseInt(p.data.substr(0,p.data.indexOf(";")));try{p.source.postMessage("SVGe"+B+";"+Ac(eval(p.data)),"*")}catch(J){p.source.postMessage("SVGe"+B+";error:"+J.message,"*")}},false)}catch(Bc){window.embed_error=
Bc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(p,B){a.pref("lang",p);a("#lang_select").val(p);if(B){var J=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,B);f.setUiStrings(B);qc.setTitles();if(J){f.renameCurrentLayer(e.common.layer+" 1");Hb()}f.runExtensions("langChanged",p);Jb();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(S,Y){a(Y).attr("title",a(S)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var u=[];c.ready=function(w){m?w():u.push(w)};c.runCallbacks=function(){a.each(u,function(){this()});m=true};c.loadFromString=function(w){c.ready(function(){n(w)})};c.disableUI=function(){};c.loadFromURL=function(w,q){q||(q={});var M=q.cache,U=q.callback;c.ready(function(){a.ajax({url:w,dataType:"text",
cache:!!M,success:function(P){n(P,U)},error:function(P,K,fa){P.status!=404&&P.responseText?n(P.responseText,U):a.alert(e.notification.URLloadFail+": \n"+fa+"",U)}})})};c.loadFromDataURI=function(w){c.ready(function(){var q=w.substring(26);n(svgedit.utilities.decode64(q))})};c.addExtension=function(){var w=arguments;a(function(){f&&f.addExtension.apply(this,w)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var n=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var f=n.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+n.id+"'>"+n.label+"<span class='shortcut'>"+f+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(n){if(n&&n.id&&n.label&&n.action&&typeof n.action=="function")if(n.id in a.contextMenuExtensions)console.error('Cannot add extension "'+n.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+n.id+", label:"+n.label+"}");a.contextMenuExtensions[n.id]=n}else console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")};svgedit.contextmenu.hasCustomHandler=
2012-07-19 14:54:50 +00:00
function(n){return a.contextMenuExtensions[n]&&true};svgedit.contextmenu.getCustomHandler=function(n){return a.contextMenuExtensions[n].action}})();var svgEditor=function(a,n){function f(m,o,b){var d=a("#svg_editor").parent(),e;for(e in o){var l=o[e];l||console.log(e);if(b)e="#"+e;if(d.find(e).length){var u=d.find(e)[0];switch(m){case "content":for(var w=0;w<u.childNodes.length;w++){var q=u.childNodes[w];if(q.nodeType===3&&q.textContent.replace(/\s/g,"")){q.textContent=l;break}}break;case "title":u.title=l}}else console.log("Missing: "+e)}}var c;n.readLang=function(m){var o=n.canvas.runExtensions("addlangData",c,true);a.each(o,function(U,P){if(P.data)m=
a.merge(m,P.data)});if(m.tools){var b=m.tools;o=m.properties;var d=m.config,e=m.layers,l=m.common,u=m.ui;f("content",{copyrightLabel:m.misc.powered_by,curve_segments:o.curve_segments,fitToContent:b.fitToContent,fit_to_all:b.fit_to_all,fit_to_canvas:b.fit_to_canvas,fit_to_layer_content:b.fit_to_layer_content,fit_to_sel:b.fit_to_sel,icon_large:d.icon_large,icon_medium:d.icon_medium,icon_small:d.icon_small,icon_xlarge:d.icon_xlarge,image_opt_embed:d.image_opt_embed,image_opt_ref:d.image_opt_ref,includedImages:d.included_images,
largest_object:b.largest_object,layersLabel:e.layers,page:b.page,relativeToLabel:b.relativeTo,selLayerLabel:e.move_elems_to,selectedPredefined:d.select_predefined,selected_objects:b.selected_objects,smallest_object:b.smallest_object,straight_segments:o.straight_segments,svginfo_bg_url:d.editor_img_url+":",svginfo_bg_note:d.editor_bg_note,svginfo_change_background:d.background,svginfo_dim:d.doc_dims,svginfo_editor_prefs:d.editor_prefs,svginfo_height:l.height,svginfo_icons:d.icon_size,svginfo_image_props:d.image_props,
svginfo_lang:d.language,svginfo_title:d.doc_title,svginfo_width:l.width,tool_docprops_cancel:l.cancel,tool_docprops_save:l.ok,tool_source_cancel:l.cancel,tool_source_save:l.ok,tool_prefs_cancel:l.cancel,tool_prefs_save:l.ok,sidepanel_handle:e.layers.split("").join(" "),tool_clear:b.new_doc,tool_docprops:b.docprops,tool_export:b.export_png,tool_import:b.import_doc,tool_imagelib:b.imagelib,tool_open:b.open_doc,tool_save:b.save_doc,svginfo_units_rulers:d.units_and_rulers,svginfo_rulers_onoff:d.show_rulers,
2012-07-19 14:54:50 +00:00
svginfo_unit:d.base_unit,svginfo_grid_settings:d.grid,svginfo_snap_onoff:d.snapping_onoff,svginfo_snap_step:d.snapping_stepsize},true);var w={},q;for(q in m.shape_cats)w['#shape_cats [data-cat="'+q+'"]']=m.shape_cats[q];setTimeout(function(){f("content",w)},2E3);var M={};a.each(["cut","copy","paste","paste_in_place","delete","group","ungroup","move_front","move_up","move_down","move_back"],function(){M['#cmenu_canvas a[href="#'+this+'"]']=b[this]});a.each(["dupe","merge_down","merge_all"],function(){M['#cmenu_layers a[href="#'+
this+'"]']=e[this]});M['#cmenu_layers a[href="#delete"]']=e.del;f("content",M);f("title",{align_relative_to:b.align_relative_to,circle_cx:o.circle_cx,circle_cy:o.circle_cy,circle_r:o.circle_r,cornerRadiusLabel:o.corner_radius,ellipse_cx:o.ellipse_cx,ellipse_cy:o.ellipse_cy,ellipse_rx:o.ellipse_rx,ellipse_ry:o.ellipse_ry,fill_color:o.fill_color,font_family:o.font_family,idLabel:o.id,image_height:o.image_height,image_url:o.image_url,image_width:o.image_width,layer_delete:e.del,layer_down:e.move_down,
layer_new:e["new"],layer_rename:e.rename,layer_moreopts:l.more_opts,layer_up:e.move_up,line_x1:o.line_x1,line_x2:o.line_x2,line_y1:o.line_y1,line_y2:o.line_y2,linecap_butt:o.linecap_butt,linecap_round:o.linecap_round,linecap_square:o.linecap_square,linejoin_bevel:o.linejoin_bevel,linejoin_miter:o.linejoin_miter,linejoin_round:o.linejoin_round,main_icon:b.main_menu,mode_connect:b.mode_connect,tools_shapelib_show:b.mode_shapelib,palette:u.palette_info,zoom_panel:u.zoom_level,path_node_x:o.node_x,path_node_y:o.node_y,
rect_height_tool:o.rect_height,rect_width_tool:o.rect_width,seg_type:o.seg_type,selLayerNames:e.move_selected,selected_x:o.pos_x,selected_y:o.pos_y,stroke_color:o.stroke_color,stroke_style:o.stroke_style,stroke_width:o.stroke_width,svginfo_title:d.doc_title,text:o.text_contents,toggle_stroke_tools:u.toggle_stroke_tools,tool_add_subpath:b.add_subpath,tool_alignbottom:b.align_bottom,tool_aligncenter:b.align_center,tool_alignleft:b.align_left,tool_alignmiddle:b.align_middle,tool_alignright:b.align_right,
tool_aligntop:b.align_top,tool_angle:o.angle,tool_blur:o.blur,tool_bold:o.bold,tool_circle:b.mode_circle,tool_clone:b.clone,tool_clone_multi:b.clone,tool_delete:b.del,tool_delete_multi:b.del,tool_ellipse:b.mode_ellipse,tool_eyedropper:b.mode_eyedropper,tool_fhellipse:b.mode_fhellipse,tool_fhpath:b.mode_fhpath,tool_fhrect:b.mode_fhrect,tool_font_size:o.font_size,tool_group:b.group,tool_make_link:b.make_link,tool_link_url:b.set_link_url,tool_image:b.mode_image,tool_italic:o.italic,tool_line:b.mode_line,
tool_move_bottom:b.move_bottom,tool_move_top:b.move_top,tool_node_clone:b.node_clone,tool_node_delete:b.node_delete,tool_node_link:b.node_link,tool_opacity:o.opacity,tool_openclose_path:b.openclose_path,tool_path:b.mode_path,tool_position:b.align_to_page,tool_rect:b.mode_rect,tool_redo:b.redo,tool_reorient:b.reorient_path,tool_select:b.mode_select,tool_source:b.source_save,tool_square:b.mode_square,tool_text:b.mode_text,tool_topath:b.to_path,tool_undo:b.undo,tool_ungroup:b.ungroup,tool_wireframe:b.wireframe_mode,
view_grid:b.toggle_grid,tool_zoom:b.mode_zoom,url_notice:b.no_embed},true);n.setLang(c,m)}};n.putLocale=function(m,o){if(m)c=m;else{c=a.pref("lang");if(!c){if(navigator.userLanguage)c=navigator.userLanguage;else if(navigator.language)c=navigator.language;if(c=="")return}console.log("Lang: "+c);if(a.inArray(c,o)==-1&&c!=="test")c="en";if(c.indexOf("en")==0)return}var b=n.curConfig.langPath+"lang."+c+".js";a.getScript(b,function(d){if(!d){d=document.createElement("script");d.src=b;document.querySelector("head").appendChild(d)}})};
return n}(jQuery,svgEditor);(function(a,n){function f(m){return!a(m).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function c(m,o){var b=m.nodeName.toLowerCase();if("area"===b){b=m.parentNode;var d=b.name;if(!m.href||!d||b.nodeName.toLowerCase()!=="map")return false;b=a("img[usemap=#"+d+"]")[0];return!!b&&f(b)}return(/input|select|textarea|button|object/.test(b)?!m.disabled:"a"==b?m.href||o:o)&&f(m)}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.17",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(m,o){return typeof m=="number"?this.each(function(){var b=
this;setTimeout(function(){a(b).focus();o&&o.call(b)},m)}):this._focus.apply(this,arguments)},scrollParent:function(){var m;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?m=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):m=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,
"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!m.length?a(document):m},zIndex:function(m){if(m!==n)return this.css("zIndex",m);if(this.length){m=a(this[0]);for(var o;m.length&&m[0]!==document;){o=m.css("position");if(o==="absolute"||o==="relative"||o==="fixed"){o=parseInt(m.css("zIndex"),10);if(!isNaN(o)&&o!==0)return o}m=m.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":
2012-07-19 14:54:50 +00:00
"mousedown")+".ui-disableSelection",function(m){m.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(m,o){function b(u,w,q,M){a.each(d,function(){w-=parseFloat(a.curCSS(u,"padding"+this,true))||0;q&&(w-=parseFloat(a.curCSS(u,"border"+this+"Width",true))||0);M&&(w-=parseFloat(a.curCSS(u,"margin"+this,true))||0)});return w}var d=o==="Width"?["Left","Right"]:["Top","Bottom"],e=o.toLowerCase(),l={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,
outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+o]=function(u){if(u===n)return l["inner"+o].call(this);return this.each(function(){a(this).css(e,b(this,u)+"px")})};a.fn["outer"+o]=function(u,w){if(typeof u!="number")return l["outer"+o].call(this,u);return this.each(function(){a(this).css(e,b(this,u,true,w)+"px")})}}),a.extend(a.expr[":"],{data:function(m,o,b){return!!a.data(m,b[3])},focusable:function(m){return c(m,!isNaN(a.attr(m,"tabindex")))},tabbable:function(m){var o=a.attr(m,
"tabindex"),b=isNaN(o);return(b||o>=0)&&c(m,!b)}}),a(function(){var m=document.body,o=m.appendChild(o=document.createElement("div"));a.extend(o.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=o.offsetHeight===100;a.support.selectstart="onselectstart"in o;m.removeChild(o).style.display="none"}),a.extend(a.ui,{plugin:{add:function(m,o,b){m=a.ui[m].prototype;for(var d in b){m.plugins[d]=m.plugins[d]||[];m.plugins[d].push([o,b[d]])}},call:function(m,o,b){if((o=m.plugins[o])&&
m.element[0].parentNode)for(var d=0;d<o.length;d++)m.options[o[d][0]]&&o[d][1].apply(m.element,b)}},contains:function(m,o){return document.compareDocumentPosition?m.compareDocumentPosition(o)&16:m!==o&&m.contains(o)},hasScroll:function(m,o){if(a(m).css("overflow")==="hidden")return false;var b=o&&o==="left"?"scrollLeft":"scrollTop",d=false;if(m[b]>0)return true;m[b]=1;d=m[b]>0;m[b]=0;return d},isOverAxis:function(m,o,b){return m>o&&m<o+b},isOver:function(m,o,b,d,e,l){return a.ui.isOverAxis(m,b,e)&&
a.ui.isOverAxis(o,d,l)}}))})(jQuery);
(function(a,n){if(a.cleanData){var f=a.cleanData;a.cleanData=function(m){for(var o=0,b;(b=m[o])!=null;o++)try{a(b).triggerHandler("remove")}catch(d){}f(m)}}else{var c=a.fn.remove;a.fn.remove=function(m,o){return this.each(function(){o||(!m||a.filter(m,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}});return c.call(a(this),m,o)})}}a.widget=function(m,o,b){var d=m.split(".")[0],e;m=m.split(".")[1];e=d+"-"+m;b||(b=o,o=a.Widget);a.expr[":"][e]=
function(l){return!!a.data(l,m)};a[d]=a[d]||{};a[d][m]=function(l,u){arguments.length&&this._createWidget(l,u)};o=new o;o.options=a.extend(true,{},o.options);a[d][m].prototype=a.extend(true,o,{namespace:d,widgetName:m,widgetEventPrefix:a[d][m].prototype.widgetEventPrefix||m,widgetBaseClass:e},b);a.widget.bridge(m,a[d][m])};a.widget.bridge=function(m,o){a.fn[m]=function(b){var d=typeof b=="string",e=Array.prototype.slice.call(arguments,1),l=this;b=!d&&e.length?a.extend.apply(null,[true,b].concat(e)):
b;if(d&&b.charAt(0)==="_")return l;d?this.each(function(){var u=a.data(this,m),w=u&&a.isFunction(u[b])?u[b].apply(u,e):u;if(w!==u&&w!==n){l=w;return false}}):this.each(function(){var u=a.data(this,m);u?u.option(b||{})._init():a.data(this,m,new o(b,this))});return l}};a.Widget=function(m,o){arguments.length&&this._createWidget(m,o)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(m,o){a.data(o,this.widgetName,this);this.element=a(o);this.options=
a.extend(true,{},this.options,this._getCreateOptions(),m);var b=this;this.element.bind("remove."+this.widgetName,function(){b.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(m,o){var b=m;if(arguments.length===0)return a.extend({},this.options);if(typeof m=="string"){if(o===n)return this.options[m];b={};b[m]=o}this._setOptions(b);return this},_setOptions:function(m){var o=this;a.each(m,function(b,d){o._setOption(b,d)});return this},_setOption:function(m,o){this.options[m]=o;m==="disabled"&&this.widget()[o?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
o);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(m,o,b){var d,e=this.options[m];b=b||{};o=a.Event(o);o.type=(m===this.widgetEventPrefix?m:this.widgetEventPrefix+m).toLowerCase();o.target=this.element[0];if(m=o.originalEvent)for(d in m)d in o||(o[d]=m[d]);this.element.trigger(o,b);return!(a.isFunction(e)&&e.call(this.element[0],o,b)===false||o.isDefaultPrevented())}}})(jQuery);
(function(a){var n=false;a(document).mouseup(function(){n=false});a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var f=this;this.element.bind("mousedown."+this.widgetName,function(c){return f._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===a.data(c.target,f.widgetName+".preventClickEvent")){a.removeData(c.target,f.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
this.widgetName)},_mouseDown:function(f){if(!n){this._mouseStarted&&this._mouseUp(f);this._mouseDownEvent=f;var c=this,m=f.which==1,o=typeof this.options.cancel=="string"&&f.target.nodeName?a(f.target).closest(this.options.cancel).length:false;if(!m||o||!this._mouseCapture(f))return true;(this.mouseDelayMet=!this.options.delay)||(this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay));if(this._mouseDistanceMet(f)&&this._mouseDelayMet(f)){this._mouseStarted=this._mouseStart(f)!==
false;if(!this._mouseStarted){f.preventDefault();return true}}true===a.data(f.target,this.widgetName+".preventClickEvent")&&a.removeData(f.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(b){return c._mouseMove(b)};this._mouseUpDelegate=function(b){return c._mouseUp(b)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);f.preventDefault();return n=true}},_mouseMove:function(f){if(a.browser.msie&&
!(document.documentMode>=9)&&!f.button)return this._mouseUp(f);if(this._mouseStarted){this._mouseDrag(f);return f.preventDefault()}this._mouseDistanceMet(f)&&this._mouseDelayMet(f)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,f)!==false,this._mouseStarted?this._mouseDrag(f):this._mouseUp(f));return!this._mouseStarted},_mouseUp:function(f){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);this._mouseStarted&&
(this._mouseStarted=false,f.target==this._mouseDownEvent.target&&a.data(f.target,this.widgetName+".preventClickEvent",true),this._mouseStop(f));return false},_mouseDistanceMet:function(f){return Math.max(Math.abs(this._mouseDownEvent.pageX-f.pageX),Math.abs(this._mouseDownEvent.pageY-f.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){this.options.helper=="original"&&
!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative");this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(n){var f=this.options;
if(this.helper||f.disabled||a(n.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(n);if(!this.handle)return false;f.iframeFix&&a(f.iframeFix===true?"iframe":f.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(a(this).offset()).appendTo("body")});return true},_mouseStart:function(n){var f=this.options;this.helper=
this._createHelper(n);this._cacheHelperProportions();a.ui.ddmanager&&(a.ui.ddmanager.current=this);this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};a.extend(this.offset,{click:{left:n.pageX-this.offset.left,top:n.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
this.originalPosition=this.position=this._generatePosition(n);this.originalPageX=n.pageX;this.originalPageY=n.pageY;f.cursorAt&&this._adjustOffsetFromHelper(f.cursorAt);f.containment&&this._setContainment();if(this._trigger("start",n)===false){this._clear();return false}this._cacheHelperProportions();a.ui.ddmanager&&!f.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,n);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(n,true);a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,n);return true},
_mouseDrag:function(n,f){this.position=this._generatePosition(n);this.positionAbs=this._convertPositionTo("absolute");if(!f){var c=this._uiHash();if(this._trigger("drag",n,c)===false){this._mouseUp({});return false}this.position=c.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";a.ui.ddmanager&&a.ui.ddmanager.drag(this,n);return false},_mouseStop:function(n){var f=
false;a.ui.ddmanager&&!this.options.dropBehaviour&&(f=a.ui.ddmanager.drop(this,n));this.dropped&&(f=this.dropped,this.dropped=false);if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!f||this.options.revert=="valid"&&f||this.options.revert===true||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,f)){var c=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),
function(){c._trigger("stop",n)!==false&&c._clear()})}else this._trigger("stop",n)!==false&&this._clear();return false},_mouseUp:function(n){this.options.iframeFix===true&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,n);return a.ui.mouse.prototype._mouseUp.call(this,n)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(n){var f=!this.options.handle||
!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){this==n.target&&(f=true)});return f},_createHelper:function(n){var f=this.options;n=a.isFunction(f.helper)?a(f.helper.apply(this.element[0],[n])):f.helper=="clone"?this.element.clone().removeAttr("id"):this.element;n.parents("body").length||n.appendTo(f.appendTo=="parent"?this.element[0].parentNode:f.appendTo);n[0]!=this.element[0]&&!/(fixed|absolute)/.test(n.css("position"))&&
n.css("position","absolute");return n},_adjustOffsetFromHelper:function(n){typeof n=="string"&&(n=n.split(" "));a.isArray(n)&&(n={left:+n[0],top:+n[1]||0});"left"in n&&(this.offset.click.left=n.left+this.margins.left);"right"in n&&(this.offset.click.left=this.helperProportions.width-n.right+this.margins.left);"top"in n&&(this.offset.click.top=n.top+this.margins.top);"bottom"in n&&(this.offset.click.top=this.helperProportions.height-n.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=
this.helper.offsetParent();var n=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(n.left+=this.scrollParent.scrollLeft(),n.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)n={top:0,left:0};return{top:n.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:n.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var n=this.element.position();return{top:n.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:n.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),
10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var n=this.options;n.containment=="parent"&&(n.containment=this.helper[0].parentNode);if(n.containment=="document"||n.containment=="window")this.containment=[n.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,n.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
(n.containment=="document"?0:a(window).scrollLeft())+a(n.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(n.containment=="document"?0:a(window).scrollTop())+(a(n.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(n.containment)&&n.containment.constructor!=Array){n=a(n.containment);var f=n[0];if(f){n.offset();var c=a(f).css("overflow")!=
"hidden";this.containment=[(parseInt(a(f).css("borderLeftWidth"),10)||0)+(parseInt(a(f).css("paddingLeft"),10)||0),(parseInt(a(f).css("borderTopWidth"),10)||0)+(parseInt(a(f).css("paddingTop"),10)||0),(c?Math.max(f.scrollWidth,f.offsetWidth):f.offsetWidth)-(parseInt(a(f).css("borderLeftWidth"),10)||0)-(parseInt(a(f).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(f.scrollHeight,f.offsetHeight):f.offsetHeight)-(parseInt(a(f).css("borderTopWidth"),
10)||0)-(parseInt(a(f).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=n}}else n.containment.constructor==Array&&(this.containment=n.containment)},_convertPositionTo:function(n,f){f||(f=this.position);var c=n=="absolute"?1:-1,m=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,o=/(html|body)/i.test(m[0].tagName);return{top:f.top+
this.offset.relative.top*c+this.offset.parent.top*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:m.scrollTop())*c),left:f.left+this.offset.relative.left*c+this.offset.parent.left*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:m.scrollLeft())*c)}},_generatePosition:function(n){var f=this.options,c=this.cssPosition=="absolute"&&
(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,m=/(html|body)/i.test(c[0].tagName),o=n.pageX,b=n.pageY;if(this.originalPosition){var d;if(this.containment){if(this.relative_container){d=this.relative_container.offset();d=[this.containment[0]+d.left,this.containment[1]+d.top,this.containment[2]+d.left,this.containment[3]+d.top]}else d=this.containment;n.pageX-this.offset.click.left<d[0]&&(o=d[0]+this.offset.click.left);
n.pageY-this.offset.click.top<d[1]&&(b=d[1]+this.offset.click.top);n.pageX-this.offset.click.left>d[2]&&(o=d[2]+this.offset.click.left);n.pageY-this.offset.click.top>d[3]&&(b=d[3]+this.offset.click.top)}if(f.grid){b=f.grid[1]?this.originalPageY+Math.round((b-this.originalPageY)/f.grid[1])*f.grid[1]:this.originalPageY;b=d?b-this.offset.click.top<d[1]||b-this.offset.click.top>d[3]?b-this.offset.click.top<d[1]?b+f.grid[1]:b-f.grid[1]:b:b;o=f.grid[0]?this.originalPageX+Math.round((o-this.originalPageX)/
f.grid[0])*f.grid[0]:this.originalPageX;o=d?o-this.offset.click.left<d[0]||o-this.offset.click.left>d[2]?o-this.offset.click.left<d[0]?o+f.grid[0]:o-f.grid[0]:o:o}}return{top:b-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():m?0:c.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<
526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():m?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(n,f,c){c=c||this._uiHash();a.ui.plugin.call(this,n,[f,c]);n=="drag"&&(this.positionAbs=this._convertPositionTo("absolute"));return a.Widget.prototype._trigger.call(this,n,f,
c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});a.extend(a.ui.draggable,{version:"1.8.17"});a.ui.plugin.add("draggable","connectToSortable",{start:function(n,f){var c=a(this).data("draggable"),m=c.options,o=a.extend({},f,{item:c.element});c.sortables=[];a(m.connectToSortable).each(function(){var b=a.data(this,"sortable");b&&!b.options.disabled&&(c.sortables.push({instance:b,shouldRevert:b.options.revert}),
b.refreshPositions(),b._trigger("activate",n,o))})},stop:function(n,f){var c=a(this).data("draggable"),m=a.extend({},f,{item:c.element});a.each(c.sortables,function(){this.instance.isOver?(this.instance.isOver=0,c.cancelHelperRemoval=true,this.instance.cancelHelperRemoval=false,this.shouldRevert&&(this.instance.options.revert=true),this.instance._mouseStop(n),this.instance.options.helper=this.instance.options._helper,c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):
(this.instance.cancelHelperRemoval=false,this.instance._trigger("deactivate",n,m))})},drag:function(n,f){var c=a(this).data("draggable"),m=this;a.each(c.sortables,function(){this.instance.positionAbs=c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(m).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",
true),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return f.helper[0]},n.target=this.instance.currentItem[0],this.instance._mouseCapture(n,true),this.instance._mouseStart(n,true,true),this.instance.offset.click.top=c.offset.click.top,this.instance.offset.click.left=c.offset.click.left,this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top,
c._trigger("toSortable",n),c.dropped=this.instance.element,c.currentItem=c.element,this.instance.fromOutside=c),this.instance.currentItem&&this.instance._mouseDrag(n)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=true,this.instance.options.revert=false,this.instance._trigger("out",n,this.instance._uiHash(this.instance)),this.instance._mouseStop(n,true),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&
this.instance.placeholder.remove(),c._trigger("fromSortable",n),c.dropped=false)})}});a.ui.plugin.add("draggable","cursor",{start:function(){var n=a("body"),f=a(this).data("draggable").options;n.css("cursor")&&(f._cursor=n.css("cursor"));n.css("cursor",f.cursor)},stop:function(){var n=a(this).data("draggable").options;n._cursor&&a("body").css("cursor",n._cursor)}});a.ui.plugin.add("draggable","opacity",{start:function(n,f){var c=a(f.helper),m=a(this).data("draggable").options;c.css("opacity")&&(m._opacity=
c.css("opacity"));c.css("opacity",m.opacity)},stop:function(n,f){var c=a(this).data("draggable").options;c._opacity&&a(f.helper).css("opacity",c._opacity)}});a.ui.plugin.add("draggable","scroll",{start:function(){var n=a(this).data("draggable");n.scrollParent[0]!=document&&n.scrollParent[0].tagName!="HTML"&&(n.overflowOffset=n.scrollParent.offset())},drag:function(n){var f=a(this).data("draggable"),c=f.options,m=false;if(f.scrollParent[0]!=document&&f.scrollParent[0].tagName!="HTML"){if(!c.axis||
c.axis!="x")f.overflowOffset.top+f.scrollParent[0].offsetHeight-n.pageY<c.scrollSensitivity?f.scrollParent[0].scrollTop=m=f.scrollParent[0].scrollTop+c.scrollSpeed:n.pageY-f.overflowOffset.top<c.scrollSensitivity&&(f.scrollParent[0].scrollTop=m=f.scrollParent[0].scrollTop-c.scrollSpeed);if(!c.axis||c.axis!="y")f.overflowOffset.left+f.scrollParent[0].offsetWidth-n.pageX<c.scrollSensitivity?f.scrollParent[0].scrollLeft=m=f.scrollParent[0].scrollLeft+c.scrollSpeed:n.pageX-f.overflowOffset.left<c.scrollSensitivity&&
(f.scrollParent[0].scrollLeft=m=f.scrollParent[0].scrollLeft-c.scrollSpeed)}else{if(!c.axis||c.axis!="x")n.pageY-a(document).scrollTop()<c.scrollSensitivity?m=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(n.pageY-a(document).scrollTop())<c.scrollSensitivity&&(m=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed));if(!c.axis||c.axis!="y")n.pageX-a(document).scrollLeft()<c.scrollSensitivity?m=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):
a(window).width()-(n.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(m=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))}m!==false&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(f,n)}});a.ui.plugin.add("draggable","snap",{start:function(){var n=a(this).data("draggable"),f=n.options;n.snapElements=[];a(f.snap.constructor!=String?f.snap.items||":data(draggable)":f.snap).each(function(){var c=a(this),m=c.offset();this!=n.element[0]&&n.snapElements.push({item:this,
2012-07-19 14:54:50 +00:00
width:c.outerWidth(),height:c.outerHeight(),top:m.top,left:m.left})})},drag:function(n,f){for(var c=a(this).data("draggable"),m=c.options,o=m.snapTolerance,b=f.offset.left,d=b+c.helperProportions.width,e=f.offset.top,l=e+c.helperProportions.height,u=c.snapElements.length-1;u>=0;u--){var w=c.snapElements[u].left,q=w+c.snapElements[u].width,M=c.snapElements[u].top,U=M+c.snapElements[u].height;if(w-o<b&&b<q+o&&M-o<e&&e<U+o||w-o<b&&b<q+o&&M-o<l&&l<U+o||w-o<d&&d<q+o&&M-o<e&&e<U+o||w-o<d&&d<q+o&&M-o<l&&
l<U+o){if(m.snapMode!="inner"){var P=Math.abs(M-l)<=o,K=Math.abs(U-e)<=o,fa=Math.abs(w-d)<=o,W=Math.abs(q-b)<=o;P&&(f.position.top=c._convertPositionTo("relative",{top:M-c.helperProportions.height,left:0}).top-c.margins.top);K&&(f.position.top=c._convertPositionTo("relative",{top:U,left:0}).top-c.margins.top);fa&&(f.position.left=c._convertPositionTo("relative",{top:0,left:w-c.helperProportions.width}).left-c.margins.left);W&&(f.position.left=c._convertPositionTo("relative",{top:0,left:q}).left-c.margins.left)}var Q=
P||K||fa||W;if(m.snapMode!="outer"){P=Math.abs(M-e)<=o;K=Math.abs(U-l)<=o;fa=Math.abs(w-b)<=o;W=Math.abs(q-d)<=o;P&&(f.position.top=c._convertPositionTo("relative",{top:M,left:0}).top-c.margins.top);K&&(f.position.top=c._convertPositionTo("relative",{top:U-c.helperProportions.height,left:0}).top-c.margins.top);fa&&(f.position.left=c._convertPositionTo("relative",{top:0,left:w}).left-c.margins.left);W&&(f.position.left=c._convertPositionTo("relative",{top:0,left:q-c.helperProportions.width}).left-
c.margins.left)}!c.snapElements[u].snapping&&(P||K||fa||W||Q)&&c.options.snap.snap&&c.options.snap.snap.call(c.element,n,a.extend(c._uiHash(),{snapItem:c.snapElements[u].item}));c.snapElements[u].snapping=P||K||fa||W||Q}else{c.snapElements[u].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,n,a.extend(c._uiHash(),{snapItem:c.snapElements[u].item}));c.snapElements[u].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var n=a(this).data("draggable").options;
n=a.makeArray(a(n.stack)).sort(function(c,m){return(parseInt(a(c).css("zIndex"),10)||0)-(parseInt(a(m).css("zIndex"),10)||0)});if(n.length){var f=parseInt(n[0].style.zIndex)||0;a(n).each(function(c){this.style.zIndex=f+c});this[0].style.zIndex=f+n.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(n,f){var c=a(f.helper),m=a(this).data("draggable").options;c.css("zIndex")&&(m._zIndex=c.css("zIndex"));c.css("zIndex",m.zIndex)},stop:function(n,f){var c=a(this).data("draggable").options;
c._zIndex&&a(f.helper).css("zIndex",c._zIndex)}})})(jQuery);
(function(a){a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var n=this,f=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),m=f.values&&f.values.length||1,o=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(f.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);f.range&&(f.range===true&&(f.values||(f.values=[this._valueMin(),this._valueMin()]),f.values.length&&f.values.length!==2&&(f.values=[f.values[0],f.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(f.range==="min"||f.range==="max"?" ui-slider-range-"+f.range:"")));for(var b=c.length;b<m;b+=1)o.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
this.handles=c.add(a(o.join("")).appendTo(n.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(d){d.preventDefault()}).hover(function(){f.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){f.disabled?a(this).blur():(a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),a(this).addClass("ui-state-focus"))}).blur(function(){a(this).removeClass("ui-state-focus")});this.handles.each(function(d){a(this).data("index.ui-slider-handle",
2012-07-19 14:54:50 +00:00
d)});this.handles.keydown(function(d){var e=true,l=a(this).data("index.ui-slider-handle"),u,w,q;if(!n.options.disabled){switch(d.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:e=false;if(!n._keySliding){n._keySliding=true;a(this).addClass("ui-state-active");u=n._start(d,l);if(u===false)return}}u=n.options.step;n.options.values&&n.options.values.length?
w=q=n.values(l):w=q=n.value();switch(d.keyCode){case a.ui.keyCode.HOME:q=n._valueMin();break;case a.ui.keyCode.END:q=n._valueMax();break;case a.ui.keyCode.PAGE_UP:q=n._trimAlignValue(w+(n._valueMax()-n._valueMin())/5);break;case a.ui.keyCode.PAGE_DOWN:q=n._trimAlignValue(w-(n._valueMax()-n._valueMin())/5);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(w===n._valueMax())return;q=n._trimAlignValue(w+u);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(w===n._valueMin())return;q=n._trimAlignValue(w-
u)}n._slide(d,l,q);return e}}).keyup(function(d){var e=a(this).data("index.ui-slider-handle");n._keySliding&&(n._keySliding=false,n._stop(d,e),n._change(d,e),a(this).removeClass("ui-state-active"))});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();
return this},_mouseCapture:function(n){var f=this.options,c,m,o,b,d;if(f.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:n.pageX,y:n.pageY});m=this._valueMax()-this._valueMin()+1;b=this;this.handles.each(function(e){var l=Math.abs(c-b.values(e));m>l&&(m=l,o=a(this),d=e)});f.range===true&&this.values(1)===f.min&&(d+=1,o=a(this.handles[d]));if(this._start(n,d)===false)return false;
this._mouseSliding=true;b._handleIndex=d;o.addClass("ui-state-active").focus();f=o.offset();this._clickOffset=!a(n.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:n.pageX-f.left-o.width()/2,top:n.pageY-f.top-o.height()/2-(parseInt(o.css("borderTopWidth"),10)||0)-(parseInt(o.css("borderBottomWidth"),10)||0)+(parseInt(o.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(n,d,c);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(n){var f=
this._normValueFromMouse({x:n.pageX,y:n.pageY});this._slide(n,this._handleIndex,f);return false},_mouseStop:function(n){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(n,this._handleIndex);this._change(n,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(n){var f,c;this.orientation==="horizontal"?
(f=this.elementSize.width,c=n.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(f=this.elementSize.height,c=n.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));n=c/f;n>1&&(n=1);n<0&&(n=0);this.orientation==="vertical"&&(n=1-n);f=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+n*f)},_start:function(n,f){var c={handle:this.handles[f],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(f),
c.values=this.values());return this._trigger("start",n,c)},_slide:function(n,f,c){var m,o,b;this.options.values&&this.options.values.length?(m=this.values(f?0:1),this.options.values.length===2&&this.options.range===true&&(f===0&&c>m||f===1&&c<m)&&(c=m),c!==this.values(f)&&(o=this.values(),o[f]=c,b=this._trigger("slide",n,{handle:this.handles[f],value:c,values:o}),this.values(f?0:1),b!==false&&this.values(f,c,true))):c!==this.value()&&(b=this._trigger("slide",n,{handle:this.handles[f],value:c}),b!==
false&&this.value(c))},_stop:function(n,f){var c={handle:this.handles[f],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(f),c.values=this.values());this._trigger("stop",n,c)},_change:function(n,f){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[f],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(f),c.values=this.values());this._trigger("change",n,c)}},value:function(n){if(arguments.length){this.options.value=
this._trimAlignValue(n);this._refreshValue();this._change(null,0)}else return this._value()},values:function(n,f){var c,m,o;if(arguments.length>1){this.options.values[n]=this._trimAlignValue(f);this._refreshValue();this._change(null,n)}else{if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(n):this.value();c=this.options.values;m=arguments[0];for(o=0;o<c.length;o+=1){c[o]=this._trimAlignValue(m[o]);this._change(null,
o)}this._refreshValue()}},_setOption:function(n,f){var c,m=0;a.isArray(this.options.values)&&(m=this.options.values.length);a.Widget.prototype._setOption.apply(this,arguments);switch(n){case "disabled":f?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",true),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",false),this.element.removeClass("ui-disabled"));break;case "orientation":this._detectOrientation();
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(c=0;c<m;c+=1)this._change(null,c);this._animateOff=false}},_value:function(){var n=this.options.value;return n=this._trimAlignValue(n)},_values:function(n){var f,c;if(arguments.length){f=this.options.values[n];
return f=this._trimAlignValue(f)}f=this.options.values.slice();for(c=0;c<f.length;c+=1)f[c]=this._trimAlignValue(f[c]);return f},_trimAlignValue:function(n){if(n<=this._valueMin())return this._valueMin();if(n>=this._valueMax())return this._valueMax();var f=this.options.step>0?this.options.step:1,c=(n-this._valueMin())%f;n=n-c;Math.abs(c)*2>=f&&(n+=c>0?f:-f);return parseFloat(n.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var n=
this.options.range,f=this.options,c=this,m=this._animateOff?false:f.animate,o,b={},d,e,l,u;this.options.values&&this.options.values.length?this.handles.each(function(w){o=(c.values(w)-c._valueMin())/(c._valueMax()-c._valueMin())*100;b[c.orientation==="horizontal"?"left":"bottom"]=o+"%";a(this).stop(1,1)[m?"animate":"css"](b,f.animate);c.options.range===true&&(c.orientation==="horizontal"?(w===0&&c.range.stop(1,1)[m?"animate":"css"]({left:o+"%"},f.animate),w===1&&c.range[m?"animate":"css"]({width:o-
d+"%"},{queue:false,duration:f.animate})):(w===0&&c.range.stop(1,1)[m?"animate":"css"]({bottom:o+"%"},f.animate),w===1&&c.range[m?"animate":"css"]({height:o-d+"%"},{queue:false,duration:f.animate})));d=o}):(e=this.value(),l=this._valueMin(),u=this._valueMax(),o=u!==l?(e-l)/(u-l)*100:0,b[c.orientation==="horizontal"?"left":"bottom"]=o+"%",this.handle.stop(1,1)[m?"animate":"css"](b,f.animate),n==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[m?"animate":"css"]({width:o+"%"},f.animate),
2012-07-19 14:54:50 +00:00
n==="max"&&this.orientation==="horizontal"&&this.range[m?"animate":"css"]({width:100-o+"%"},{queue:false,duration:f.animate}),n==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[m?"animate":"css"]({height:o+"%"},f.animate),n==="max"&&this.orientation==="vertical"&&this.range[m?"animate":"css"]({height:100-o+"%"},{queue:false,duration:f.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(b,d){if(d===undefined)d=0;return Math.round(b*Math.pow(10,d))/Math.pow(10,d)};var n=function(b,d){var e=this,l=b.find("img:first"),u=0,w=100,q=100,M=0,U=100,P=100,K=0,fa=0,W,Q,ha=[],ua=function(T){for(var V=0;V<ha.length;V++)ha[V].call(e,e,T)},ia=function(T){var V=b.offset();W={l:V.left|0,t:V.top|0};clearTimeout(Q);Q=setTimeout(function(){ra.call(e,T)},0);a(document).bind("mousemove",ea).bind("mouseup",ga);T.preventDefault()},ea=function(T){clearTimeout(Q);Q=setTimeout(function(){ra.call(e,
T)},0);T.stopPropagation();T.preventDefault();return false},ga=function(T){a(document).unbind("mouseup",ga).unbind("mousemove",ea);T.stopPropagation();T.preventDefault();return false},ra=function(T){var V=T.pageX-W.l;T=T.pageY-W.t;var sa=b.w,ta=b.h;if(V<0)V=0;else if(V>sa)V=sa;if(T<0)T=0;else if(T>ta)T=ta;qa.call(e,"xy",{x:V/sa*q+u,y:T/ta*P+M})},qa=function(T,V,sa){if(V===undefined){if(T===undefined||T==null)T="xy";switch(T.toLowerCase()){case "x":return K;case "y":return fa;default:return{x:K,y:fa}}}if(!(sa!=
null&&sa==e)){var ta=false,aa,ma;if(T==null)T="xy";switch(T.toLowerCase()){case "x":aa=V&&(V.x&&V.x|0||V|0)||0;break;case "y":ma=V&&(V.y&&V.y|0||V|0)||0;break;default:aa=V&&V.x&&V.x|0||0;ma=V&&V.y&&V.y|0||0}if(aa!=null){if(aa<u)aa=u;else if(aa>w)aa=w;if(K!=aa){K=aa;ta=true}}if(ma!=null){if(ma<M)ma=M;else if(ma>U)ma=U;if(fa!=ma){fa=ma;ta=true}}ta&&ua.call(e,sa||e)}},ca=function(T){a.isFunction(T)&&ha.push(T)};a.extend(true,e,{val:qa,range:function(T,V){if(V===undefined){if(T===undefined||T==null)T=
"all";switch(T.toLowerCase()){case "minx":return u;case "maxx":return w;case "rangex":return{minX:u,maxX:w,rangeX:q};case "miny":return M;case "maxy":return U;case "rangey":return{minY:M,maxY:U,rangeY:P};default:return{minX:u,maxX:w,rangeX:q,minY:M,maxY:U,rangeY:P}}}var sa,ta,aa,ma;if(T==null)T="all";switch(T.toLowerCase()){case "minx":sa=V&&(V.minX&&V.minX|0||V|0)||0;break;case "maxx":ta=V&&(V.maxX&&V.maxX|0||V|0)||0;break;case "rangex":sa=V&&V.minX&&V.minX|0||0;ta=V&&V.maxX&&V.maxX|0||0;break;case "miny":aa=
V&&(V.minY&&V.minY|0||V|0)||0;break;case "maxy":ma=V&&(V.maxY&&V.maxY|0||V|0)||0;break;case "rangey":aa=V&&V.minY&&V.minY|0||0;ma=V&&V.maxY&&V.maxY|0||0;break;default:sa=V&&V.minX&&V.minX|0||0;ta=V&&V.maxX&&V.maxX|0||0;aa=V&&V.minY&&V.minY|0||0;ma=V&&V.maxY&&V.maxY|0||0}if(sa!=null&&u!=sa){u=sa;q=w-u}if(ta!=null&&w!=ta){w=ta;q=w-u}if(aa!=null&&M!=aa){M=aa;P=U-M}if(ma!=null&&U!=ma){U=ma;P=U-M}},bind:ca,unbind:function(T){if(a.isFunction(T))for(var V;(V=a.inArray(T,ha))!=-1;)ha.splice(V,1)},destroy:function(){a(document).unbind("mouseup",
ga).unbind("mousemove",ea);b.unbind("mousedown",ia);ha=l=b=null}});l.src=d.arrow&&d.arrow.image;l.w=d.arrow&&d.arrow.width||l.width();l.h=d.arrow&&d.arrow.height||l.height();b.w=d.map&&d.map.width||b.width();b.h=d.map&&d.map.height||b.height();b.bind("mousedown",ia);ca.call(e,function(){var T=0,V=0,sa=b.w,ta=b.h,aa=l.w,ma=l.h;setTimeout(function(){if(q>0)T=K==w?sa:K/q*sa|0;if(P>0)V=fa==U?ta:fa/P*ta|0;if(aa>=sa)T=(sa>>1)-(aa>>1);else T-=aa>>1;if(ma>=ta)V=(ta>>1)-(ma>>1);else V-=ma>>1;l.css({left:T+
"px",top:V+"px"})},0)})},f=function(b,d,e,l){var u=this;b=b.find("td.Text input");var w=b.eq(3),q=b.eq(4),M=b.eq(5),U=b.length>7?b.eq(6):null,P=b.eq(0),K=b.eq(1),fa=b.eq(2),W=b.eq(b.length>7?7:6),Q=b.length>7?b.eq(8):null,ha=function(qa){if(!(qa.target.value==""&&qa.target!=W.get(0)&&(e!=null&&qa.target!=e.get(0)||e==null))){if(!ea(qa))return qa;switch(qa.target){case w.get(0):switch(qa.keyCode){case 38:w.val(ga.call(u,(w.val()<<0)+1,0,255));d.val("r",w.val(),qa.target);return false;case 40:w.val(ga.call(u,
(w.val()<<0)-1,0,255));d.val("r",w.val(),qa.target);return false}break;case q.get(0):switch(qa.keyCode){case 38:q.val(ga.call(u,(q.val()<<0)+1,0,255));d.val("g",q.val(),qa.target);return false;case 40:q.val(ga.call(u,(q.val()<<0)-1,0,255));d.val("g",q.val(),qa.target);return false}break;case M.get(0):switch(qa.keyCode){case 38:M.val(ga.call(u,(M.val()<<0)+1,0,255));d.val("b",M.val(),qa.target);return false;case 40:M.val(ga.call(u,(M.val()<<0)-1,0,255));d.val("b",M.val(),qa.target);return false}break;
case U&&U.get(0):switch(qa.keyCode){case 38:U.val(ga.call(u,parseFloat(U.val())+1,0,100));d.val("a",Math.precision(U.val()*255/100,l),qa.target);return false;case 40:U.val(ga.call(u,parseFloat(U.val())-1,0,100));d.val("a",Math.precision(U.val()*255/100,l),qa.target);return false}break;case P.get(0):switch(qa.keyCode){case 38:P.val(ga.call(u,(P.val()<<0)+1,0,360));d.val("h",P.val(),qa.target);return false;case 40:P.val(ga.call(u,(P.val()<<0)-1,0,360));d.val("h",P.val(),qa.target);return false}break;
case K.get(0):switch(qa.keyCode){case 38:K.val(ga.call(u,(K.val()<<0)+1,0,100));d.val("s",K.val(),qa.target);return false;case 40:K.val(ga.call(u,(K.val()<<0)-1,0,100));d.val("s",K.val(),qa.target);return false}break;case fa.get(0):switch(qa.keyCode){case 38:fa.val(ga.call(u,(fa.val()<<0)+1,0,100));d.val("v",fa.val(),qa.target);return false;case 40:fa.val(ga.call(u,(fa.val()<<0)-1,0,100));d.val("v",fa.val(),qa.target);return false}}}},ua=function(qa){if(!(qa.target.value==""&&qa.target!=W.get(0)&&
(e!=null&&qa.target!=e.get(0)||e==null))){if(!ea(qa))return qa;switch(qa.target){case w.get(0):w.val(ga.call(u,w.val(),0,255));d.val("r",w.val(),qa.target);break;case q.get(0):q.val(ga.call(u,q.val(),0,255));d.val("g",q.val(),qa.target);break;case M.get(0):M.val(ga.call(u,M.val(),0,255));d.val("b",M.val(),qa.target);break;case U&&U.get(0):U.val(ga.call(u,U.val(),0,100));d.val("a",Math.precision(U.val()*255/100,l),qa.target);break;case P.get(0):P.val(ga.call(u,P.val(),0,360));d.val("h",P.val(),qa.target);
break;case K.get(0):K.val(ga.call(u,K.val(),0,100));d.val("s",K.val(),qa.target);break;case fa.get(0):fa.val(ga.call(u,fa.val(),0,100));d.val("v",fa.val(),qa.target);break;case W.get(0):W.val(W.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));e&&e.val(W.val());d.val("hex",W.val()!=""?W.val():null,qa.target);break;case e&&e.get(0):e.val(e.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));W.val(e.val());d.val("hex",e.val()!=""?e.val():null,qa.target);break;case Q&&Q.get(0):Q.val(Q.val().replace(/[^a-fA-F0-9]/g,
"").toLowerCase().substring(0,2));d.val("a",Q.val()!=null?parseInt(Q.val(),16):null,qa.target)}}},ia=function(qa){if(d.val()!=null)switch(qa.target){case w.get(0):w.val(d.val("r"));break;case q.get(0):q.val(d.val("g"));break;case M.get(0):M.val(d.val("b"));break;case U&&U.get(0):U.val(Math.precision(d.val("a")*100/255,l));break;case P.get(0):P.val(d.val("h"));break;case K.get(0):K.val(d.val("s"));break;case fa.get(0):fa.val(d.val("v"));break;case W.get(0):case e&&e.get(0):W.val(d.val("hex"));e&&e.val(d.val("hex"));
break;case Q&&Q.get(0):Q.val(d.val("ahex").substring(6))}},ea=function(qa){switch(qa.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(qa.ctrlKey)return false}return true},ga=function(qa,ca,T){if(qa==""||isNaN(qa))return ca;if(qa>T)return T;if(qa<ca)return ca;return qa},ra=function(qa,ca){var T=qa.val("all");if(ca!=w.get(0))w.val(T!=null?T.r:"");if(ca!=q.get(0))q.val(T!=null?T.g:"");if(ca!=M.get(0))M.val(T!=null?T.b:"");if(U&&ca!=U.get(0))U.val(T!=
null?Math.precision(T.a*100/255,l):"");if(ca!=P.get(0))P.val(T!=null?T.h:"");if(ca!=K.get(0))K.val(T!=null?T.s:"");if(ca!=fa.get(0))fa.val(T!=null?T.v:"");if(ca!=W.get(0)&&(e&&ca!=e.get(0)||!e))W.val(T!=null?T.hex:"");if(e&&ca!=e.get(0)&&ca!=W.get(0))e.val(T!=null?T.hex:"");if(Q&&ca!=Q.get(0))Q.val(T!=null?T.ahex.substring(6):"")};a.extend(true,u,{destroy:function(){w.add(q).add(M).add(U).add(P).add(K).add(fa).add(W).add(e).add(Q).unbind("keyup",ua).unbind("blur",ia);w.add(q).add(M).add(U).add(P).add(K).add(fa).unbind("keydown",
ha);d.unbind(ra);Q=W=fa=K=P=U=M=q=w=null}});w.add(q).add(M).add(U).add(P).add(K).add(fa).add(W).add(e).add(Q).bind("keyup",ua).bind("blur",ia);w.add(q).add(M).add(U).add(P).add(K).add(fa).bind("keydown",ha);d.bind(ra)};a.jPicker={List:[],Color:function(b){var d=this,e,l,u,w,q,M,U,P=[],K=function(W){for(var Q=0;Q<P.length;Q++)P[Q].call(d,d,W)},fa=function(W,Q,ha){if(Q===undefined){if(W===undefined||W==null||W=="")W="all";if(e==null)return null;switch(W.toLowerCase()){case "ahex":return o.rgbaToHex({r:e,
g:l,b:u,a:w});case "hex":return fa("ahex").substring(0,6);case "all":return{r:e,g:l,b:u,a:w,h:q,s:M,v:U,hex:fa.call(d,"hex"),ahex:fa.call(d,"ahex")};default:Q={};for(var ua=0;ua<W.length;ua++)switch(W.charAt(ua)){case "r":if(W.length==1)Q=e;else Q.r=e;break;case "g":if(W.length==1)Q=l;else Q.g=l;break;case "b":if(W.length==1)Q=u;else Q.b=u;break;case "a":if(W.length==1)Q=w;else Q.a=w;break;case "h":if(W.length==1)Q=q;else Q.h=q;break;case "s":if(W.length==1)Q=M;else Q.s=M;break;case "v":if(W.length==
1)Q=U;else Q.v=U}return Q=={}?fa.call(d,"all"):Q}}if(!(ha!=null&&ha==d)){var ia=false;if(W==null)W="";if(Q==null){if(e!=null){e=null;ia=true}if(l!=null){l=null;ia=true}if(u!=null){u=null;ia=true}if(w!=null){w=null;ia=true}if(q!=null){q=null;ia=true}if(M!=null){M=null;ia=true}if(U!=null){U=null;ia=true}ia&&K.call(d,ha||d)}else switch(W.toLowerCase()){case "ahex":case "hex":Q=o.hexToRgba(Q&&(Q.ahex||Q.hex)||Q||"00000000");fa.call(d,"rgba",{r:Q.r,g:Q.g,b:Q.b,a:W=="ahex"?Q.a:w!=null?w:255},ha);break;
default:if(Q&&(Q.ahex!=null||Q.hex!=null)){fa.call(d,"ahex",Q.ahex||Q.hex||"00000000",ha);break}var ea={},ga=false,ra=false;if(Q.r!==undefined&&!W.indexOf("r")==-1)W+="r";if(Q.g!==undefined&&!W.indexOf("g")==-1)W+="g";if(Q.b!==undefined&&!W.indexOf("b")==-1)W+="b";if(Q.a!==undefined&&!W.indexOf("a")==-1)W+="a";if(Q.h!==undefined&&!W.indexOf("h")==-1)W+="h";if(Q.s!==undefined&&!W.indexOf("s")==-1)W+="s";if(Q.v!==undefined&&!W.indexOf("v")==-1)W+="v";for(ua=0;ua<W.length;ua++)switch(W.charAt(ua)){case "r":if(ra)continue;
ga=true;ea.r=Q&&Q.r&&Q.r|0||Q&&Q|0||0;if(ea.r<0)ea.r=0;else if(ea.r>255)ea.r=255;if(e!=ea.r){e=ea.r;ia=true}break;case "g":if(ra)continue;ga=true;ea.g=Q&&Q.g&&Q.g|0||Q&&Q|0||0;if(ea.g<0)ea.g=0;else if(ea.g>255)ea.g=255;if(l!=ea.g){l=ea.g;ia=true}break;case "b":if(ra)continue;ga=true;ea.b=Q&&Q.b&&Q.b|0||Q&&Q|0||0;if(ea.b<0)ea.b=0;else if(ea.b>255)ea.b=255;if(u!=ea.b){u=ea.b;ia=true}break;case "a":ea.a=Q&&Q.a!=null?Q.a|0:Q!=null?Q|0:255;if(ea.a<0)ea.a=0;else if(ea.a>255)ea.a=255;if(w!=ea.a){w=ea.a;
ia=true}break;case "h":if(ga)continue;ra=true;ea.h=Q&&Q.h&&Q.h|0||Q&&Q|0||0;if(ea.h<0)ea.h=0;else if(ea.h>360)ea.h=360;if(q!=ea.h){q=ea.h;ia=true}break;case "s":if(ga)continue;ra=true;ea.s=Q&&Q.s!=null?Q.s|0:Q!=null?Q|0:100;if(ea.s<0)ea.s=0;else if(ea.s>100)ea.s=100;if(M!=ea.s){M=ea.s;ia=true}break;case "v":if(ga)continue;ra=true;ea.v=Q&&Q.v!=null?Q.v|0:Q!=null?Q|0:100;if(ea.v<0)ea.v=0;else if(ea.v>100)ea.v=100;if(U!=ea.v){U=ea.v;ia=true}}if(ia){if(ga){e=e||0;l=l||0;u=u||0;Q=o.rgbToHsv({r:e,g:l,b:u});
q=Q.h;M=Q.s;U=Q.v}else if(ra){q=q||0;M=M!=null?M:100;U=U!=null?U:100;Q=o.hsvToRgb({h:q,s:M,v:U});e=Q.r;l=Q.g;u=Q.b}w=w!=null?w:255;K.call(d,ha||d)}}}};a.extend(true,d,{val:fa,bind:function(W){a.isFunction(W)&&P.push(W)},unbind:function(W){if(a.isFunction(W))for(var Q;(Q=a.inArray(W,P))!=-1;)P.splice(Q,1)},destroy:function(){P=null}});if(b)if(b.ahex!=null)fa("ahex",b);else if(b.hex!=null)fa((b.a!=null?"a":"")+"hex",b.a!=null?{ahex:b.hex+o.intToHex(b.a)}:b);else if(b.r!=null&&b.g!=null&&b.b!=null)fa("rgb"+
(b.a!=null?"a":""),b);else if(b.h!=null&&b.s!=null&&b.v!=null)fa("hsv"+(b.a!=null?"a":""),b)},ColorMethods:{hexToRgba:function(b){b=this.validateHex(b);if(b=="")return{r:null,g:null,b:null,a:null};var d="00",e="00",l="00",u="255";if(b.length==6)b+="ff";if(b.length>6){d=b.substring(0,2);e=b.substring(2,4);l=b.substring(4,6);u=b.substring(6,b.length)}else{if(b.length>4){d=b.substring(4,b.length);b=b.substring(0,4)}if(b.length>2){e=b.substring(2,b.length);b=b.substring(0,2)}if(b.length>0)l=b.substring(0,
b.length)}return{r:this.hexToInt(d),g:this.hexToInt(e),b:this.hexToInt(l),a:this.hexToInt(u)}},validateHex:function(b){if(typeof b=="object")return"";b=b.toLowerCase().replace(/[^a-f0-9]/g,"");if(b.length>8)b=b.substring(0,8);return b},rgbaToHex:function(b){return this.intToHex(b.r)+this.intToHex(b.g)+this.intToHex(b.b)+this.intToHex(b.a)},intToHex:function(b){b=(b|0).toString(16);if(b.length==1)b="0"+b;return b.toLowerCase()},hexToInt:function(b){return parseInt(b,16)},rgbToHsv:function(b){var d=
b.r/255,e=b.g/255;b=b.b/255;var l={h:0,s:0,v:0},u=0,w=0;if(d>=e&&d>=b){w=d;u=e>b?b:e}else if(e>=b&&e>=d){w=e;u=d>b?b:d}else{w=b;u=e>d?d:e}l.v=w;l.s=w?(w-u)/w:0;if(l.s){u=w-u;l.h=d==w?(e-b)/u:e==w?2+(b-d)/u:4+(d-e)/u;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(b){var d={r:0,g:0,b:0,a:100},e=b.h,l=b.s;b=b.v;if(l==0)d.r=b==0?d.g=d.b=0:d.g=d.b=b*255/100|0;else{if(e==360)e=0;e/=60;l/=100;b/=100;var u=e|0,w=e-u;e=b*(1-l);var q=b*(1-l*w);l=b*
(1-l*(1-w));switch(u){case 0:d.r=b;d.g=l;d.b=e;break;case 1:d.r=q;d.g=b;d.b=e;break;case 2:d.r=e;d.g=b;d.b=l;break;case 3:d.r=e;d.g=q;d.b=b;break;case 4:d.r=l;d.g=e;d.b=b;break;case 5:d.r=b;d.g=e;d.b=q}d.r=d.r*255|0;d.g=d.g*255|0;d.b=d.b*255|0}return d}}};var c=a.jPicker.Color,m=a.jPicker.List,o=a.jPicker.ColorMethods;a.fn.jPicker=function(b){var d=arguments;return this.each(function(){var e=this,l=a.extend(true,{},a.fn.jPicker.defaults,b);if(a(e).get(0).nodeName.toLowerCase()=="input"){a.extend(true,
l,{window:{bindToInput:true,expandable:true,input:a(e)}});if(a(e).val()==""){l.color.active=new c({hex:null});l.color.current=new c({hex:null})}else if(o.validateHex(a(e).val())){l.color.active=new c({hex:a(e).val(),a:l.color.active.val("a")});l.color.current=new c({hex:a(e).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(e).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 u=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,w=null,q=null,M=null,U=null,P=null,K=null,fa=null,W=null,Q=null,ha=null,ua=null,ia=null,ea=null,ga=null,ra=null,qa=null,ca=null,T=null,V=null,sa=null,ta=null,aa=null,ma=null,Ga=null,Ma=null,Ra=null,Qa=null,Va=null,Xa=function(O){var H=va.active,Z=H.val("hex"),Oa,Za;l.color.mode=O;switch(O){case "h":setTimeout(function(){ab.call(e,q,"transparent");Ka.call(e,U,0);Da.call(e,U,100);Ka.call(e,
P,260);Da.call(e,P,100);ab.call(e,M,"transparent");Ka.call(e,fa,0);Da.call(e,fa,100);Ka.call(e,W,260);Da.call(e,W,100);Ka.call(e,Q,260);Da.call(e,Q,100);Ka.call(e,ha,260);Da.call(e,ha,100);Ka.call(e,ia,260);Da.call(e,ia,100)},0);ea.range("all",{minX:0,maxX:100,minY:0,maxY:100});ga.range("rangeY",{minY:0,maxY:360});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("s"),y:100-H.val("v")},ea);ga.val("y",360-H.val("h"),ga);break;case "s":setTimeout(function(){ab.call(e,q,"transparent");Ka.call(e,U,-260);
Ka.call(e,P,-520);Ka.call(e,fa,-260);Ka.call(e,W,-520);Ka.call(e,ia,260);Da.call(e,ia,100)},0);ea.range("all",{minX:0,maxX:360,minY:0,maxY:100});ga.range("rangeY",{minY:0,maxY:100});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("h"),y:100-H.val("v")},ea);ga.val("y",100-H.val("s"),ga);break;case "v":setTimeout(function(){ab.call(e,q,"000000");Ka.call(e,U,-780);Ka.call(e,P,260);ab.call(e,M,Z);Ka.call(e,fa,-520);Ka.call(e,W,260);Da.call(e,W,100);Ka.call(e,ia,260);Da.call(e,ia,100)},0);ea.range("all",
{minX:0,maxX:360,minY:0,maxY:100});ga.range("rangeY",{minY:0,maxY:100});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("h"),y:100-H.val("s")},ea);ga.val("y",100-H.val("v"),ga);break;case "r":Oa=-1040;Za=-780;ea.range("all",{minX:0,maxX:255,minY:0,maxY:255});ga.range("rangeY",{minY:0,maxY:255});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("b"),y:255-H.val("g")},ea);ga.val("y",255-H.val("r"),ga);break;case "g":Oa=-1560;Za=-1820;ea.range("all",{minX:0,maxX:255,minY:0,maxY:255});ga.range("rangeY",
{minY:0,maxY:255});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("b"),y:255-H.val("r")},ea);ga.val("y",255-H.val("g"),ga);break;case "b":Oa=-2080;Za=-2860;ea.range("all",{minX:0,maxX:255,minY:0,maxY:255});ga.range("rangeY",{minY:0,maxY:255});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("r"),y:255-H.val("g")},ea);ga.val("y",255-H.val("b"),ga);break;case "a":setTimeout(function(){ab.call(e,q,"transparent");Ka.call(e,U,-260);Ka.call(e,P,-520);Ka.call(e,fa,260);Ka.call(e,W,260);Da.call(e,W,100);
Ka.call(e,ia,0);Da.call(e,ia,100)},0);ea.range("all",{minX:0,maxX:360,minY:0,maxY:100});ga.range("rangeY",{minY:0,maxY:255});if(H.val("ahex")==null)break;ea.val("xy",{x:H.val("h"),y:100-H.val("v")},ea);ga.val("y",255-H.val("a"),ga);break;default:throw"Invalid Mode";}switch(O){case "s":case "v":case "a":setTimeout(function(){Da.call(e,U,100);Da.call(e,fa,100);Ka.call(e,Q,260);Da.call(e,Q,100);Ka.call(e,ha,260);Da.call(e,ha,100)},0);break;case "r":case "g":case "b":setTimeout(function(){ab.call(e,q,
"transparent");ab.call(e,M,"transparent");Da.call(e,fa,100);Da.call(e,U,100);Ka.call(e,U,Oa);Ka.call(e,P,Oa-260);Ka.call(e,fa,Za-780);Ka.call(e,W,Za-520);Ka.call(e,Q,Za);Ka.call(e,ha,Za-260);Ka.call(e,ia,260);Da.call(e,ia,100)},0)}H.val("ahex")!=null&&Na.call(e,H)},Na=function(O,H){if(H==null||H!=ga&&H!=ea)zb.call(e,O,H);setTimeout(function(){Ja.call(e,O);Jb.call(e,O);tb.call(e,O)},0)},Ha=function(O,H){var Z=va.active;if(!(H!=ea&&Z.val()==null)){var Oa=O.val("all");switch(l.color.mode){case "h":Z.val("sv",
{s:Oa.x,v:100-Oa.y},H);break;case "s":case "a":Z.val("hv",{h:Oa.x,v:100-Oa.y},H);break;case "v":Z.val("hs",{h:Oa.x,s:100-Oa.y},H);break;case "r":Z.val("gb",{g:255-Oa.y,b:Oa.x},H);break;case "g":Z.val("rb",{r:255-Oa.y,b:Oa.x},H);break;case "b":Z.val("rg",{r:Oa.x,g:255-Oa.y},H)}}},Pa=function(O,H){var Z=va.active;if(!(H!=ga&&Z.val()==null))switch(l.color.mode){case "h":Z.val("h",{h:360-O.val("y")},H);break;case "s":Z.val("s",{s:100-O.val("y")},H);break;case "v":Z.val("v",{v:100-O.val("y")},H);break;
case "r":Z.val("r",{r:255-O.val("y")},H);break;case "g":Z.val("g",{g:255-O.val("y")},H);break;case "b":Z.val("b",{b:255-O.val("y")},H);break;case "a":Z.val("a",255-O.val("y"),H)}},zb=function(O,H){if(H!=ea)switch(l.color.mode){case "h":var Z=O.val("sv");ea.val("xy",{x:Z!=null?Z.s:100,y:100-(Z!=null?Z.v:100)},H);break;case "s":case "a":Z=O.val("hv");ea.val("xy",{x:Z&&Z.h||0,y:100-(Z!=null?Z.v:100)},H);break;case "v":Z=O.val("hs");ea.val("xy",{x:Z&&Z.h||0,y:100-(Z!=null?Z.s:100)},H);break;case "r":Z=
O.val("bg");ea.val("xy",{x:Z&&Z.b||0,y:255-(Z&&Z.g||0)},H);break;case "g":Z=O.val("br");ea.val("xy",{x:Z&&Z.b||0,y:255-(Z&&Z.r||0)},H);break;case "b":Z=O.val("rg");ea.val("xy",{x:Z&&Z.r||0,y:255-(Z&&Z.g||0)},H)}if(H!=ga)switch(l.color.mode){case "h":ga.val("y",360-(O.val("h")||0),H);break;case "s":Z=O.val("s");ga.val("y",100-(Z!=null?Z:100),H);break;case "v":Z=O.val("v");ga.val("y",100-(Z!=null?Z:100),H);break;case "r":ga.val("y",255-(O.val("r")||0),H);break;case "g":ga.val("y",255-(O.val("g")||0),
H);break;case "b":ga.val("y",255-(O.val("b")||0),H);break;case "a":Z=O.val("a");ga.val("y",255-(Z!=null?Z:255),H)}},Ja=function(O){try{var H=O.val("all");sa.css({backgroundColor:H&&"#"+H.hex||"transparent"});Da.call(e,sa,H&&Math.precision(H.a*100/255,4)||0)}catch(Z){}},Jb=function(O){switch(l.color.mode){case "h":ab.call(e,q,(new c({h:O.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var H=O.val("s");Da.call(e,P,100-(H!=null?H:100));break;case "v":H=O.val("v");Da.call(e,U,H!=null?H:
100);break;case "r":Da.call(e,P,Math.precision((O.val("r")||0)/255*100,4));break;case "g":Da.call(e,P,Math.precision((O.val("g")||0)/255*100,4));break;case "b":Da.call(e,P,Math.precision((O.val("b")||0)/255*100))}O=O.val("a");Da.call(e,K,Math.precision((255-(O||0))*100/255,4))},tb=function(O){switch(l.color.mode){case "h":var H=O.val("a");Da.call(e,ua,Math.precision((255-(H||0))*100/255,4));break;case "s":H=O.val("hva");var Z=new c({h:H&&H.h||0,s:100,v:H!=null?H.v:100});ab.call(e,M,Z.val("hex"));
Da.call(e,W,100-(H!=null?H.v:100));Da.call(e,ua,Math.precision((255-(H&&H.a||0))*100/255,4));break;case "v":H=O.val("hsa");Z=new c({h:H&&H.h||0,s:H!=null?H.s:100,v:100});ab.call(e,M,Z.val("hex"));Da.call(e,ua,Math.precision((255-(H&&H.a||0))*100/255,4));break;case "r":case "g":case "b":Z=H=0;O=O.val("rgba");if(l.color.mode=="r"){H=O&&O.b||0;Z=O&&O.g||0}else if(l.color.mode=="g"){H=O&&O.b||0;Z=O&&O.r||0}else if(l.color.mode=="b"){H=O&&O.r||0;Z=O&&O.g||0}var Oa=Z>H?H:Z;Da.call(e,W,H>Z?Math.precision((H-
Z)/(255-Z)*100,4):0);Da.call(e,Q,Z>H?Math.precision((Z-H)/(255-H)*100,4):0);Da.call(e,ha,Math.precision(Oa/255*100,4));Da.call(e,ua,Math.precision((255-(O&&O.a||0))*100/255,4));break;case "a":H=O.val("a");ab.call(e,M,O.val("hex")||"000000");Da.call(e,ua,H!=null?0:100);Da.call(e,ia,H!=null?100:0)}},ab=function(O,H){O.css({backgroundColor:H&&H.length==6&&"#"+H||"transparent"})},$a=function(O,H){if(u&&(H.indexOf("AlphaBar.png")!=-1||H.indexOf("Bars.png")!=-1||H.indexOf("Maps.png")!=-1)){O.attr("pngSrc",
H);O.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+H+"', sizingMethod='scale')"})}else O.css({backgroundImage:"url('"+H+"')"})},Ka=function(O,H){O.css({top:H+"px"})},Da=function(O,H){O.css({visibility:H>0?"visible":"hidden"});if(H>0&&H<100)if(u){var Z=O.attr("pngSrc");Z!=null&&(Z.indexOf("AlphaBar.png")!=-1||Z.indexOf("Bars.png")!=-1||Z.indexOf("Maps.png")!=-1)?O.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+Z+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+
H+")"}):O.css({opacity:Math.precision(H/100,4)})}else O.css({opacity:Math.precision(H/100,4)});else if(H==0||H==100)if(u){Z=O.attr("pngSrc");Z!=null&&(Z.indexOf("AlphaBar.png")!=-1||Z.indexOf("Bars.png")!=-1||Z.indexOf("Maps.png")!=-1)?O.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+Z+"', sizingMethod='scale')"}):O.css({opacity:""})}else O.css({opacity:""})},yb=function(){va.active.val("ahex",va.current.val("ahex"))},bb=function(){va.current.val("ahex",va.active.val("ahex"))},
Sa=function(O){a(this).parents("tbody:first").find('input:radio[value!="'+O.target.value+'"]').removeAttr("checked");Xa.call(e,O.target.value)},gb=function(){yb.call(e)},Ia=function(){yb.call(e);l.window.expandable&&Kb.call(e);a.isFunction(Gb)&&Gb.call(e,va.active,ma)},rb=function(){bb.call(e);l.window.expandable&&Kb.call(e);a.isFunction(Fb)&&Fb.call(e,va.active,aa)},sb=function(){Ob.call(e)},mb=function(O){var H=O.val("hex");ta.css({backgroundColor:H&&"#"+H||"transparent"});Da.call(e,ta,Math.precision((O.val("a")||
0)*100/255,4))},hb=function(O){var H=O.val("hex");O=O.val("va");Ma.css({backgroundColor:H&&"#"+H||"transparent"});Da.call(e,Ra,Math.precision((255-(O&&O.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:H&&"#"+H||"transparent",color:O==null||O.v>75?"#000000":"#ffffff"})},La=function(O){qa=parseInt(w.css("left"));ca=parseInt(w.css("top"));T=O.pageX;V=O.pageY;a(document).bind("mousemove",Wa).bind("mouseup",jb);O.preventDefault()},Wa=function(O){w.css({left:qa-
(T-O.pageX)+"px",top:ca-(V-O.pageY)+"px"});l.window.expandable&&!a.support.boxModel&&w.prev().css({left:w.css("left"),top:w.css("top")});O.stopPropagation();O.preventDefault();return false},jb=function(O){a(document).unbind("mousemove",Wa).unbind("mouseup",jb);O.stopPropagation();O.preventDefault();return false},Eb=function(O){O.preventDefault();O.stopPropagation();va.active.val("ahex",a(this).attr("title")||null,O.target);return false},Fb=a.isFunction(d[1])&&d[1]||null,nb=a.isFunction(d[2])&&d[2]||
null,Gb=a.isFunction(d[3])&&d[3]||null,Ob=function(){va.current.val("ahex",va.active.val("ahex"));var O=function(){if(!(!l.window.expandable||a.support.boxModel)){var H=w.find("table:first");w.before("<iframe/>");w.prev().css({width:H.width(),height:w.height(),opacity:0,position:"absolute",left:w.css("left"),top:w.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});w.css({zIndex:20})}switch(l.window.effects.type){case "fade":w.fadeIn(l.window.effects.speed.show,
O);break;case "slide":w.slideDown(l.window.effects.speed.show,O);break;default:w.show(l.window.effects.speed.show,O)}},Kb=function(){var O=function(){l.window.expandable&&w.css({zIndex:10});!l.window.expandable||a.support.boxModel||w.prev().remove()};switch(l.window.effects.type){case "fade":w.fadeOut(l.window.effects.speed.hide,O);break;case "slide":w.slideUp(l.window.effects.speed.hide,O);break;default:w.hide(l.window.effects.speed.hide,O)}},Ub=function(){var O=l.window,H=O.expandable?a(e).next().find(".Container:first"):
null;w=O.expandable?a("<div/>"):a(e);w.addClass("jPicker Container");O.expandable&&w.hide();w.get(0).onselectstart=function(Pb){if(Pb.target.nodeName.toLowerCase()!=="input")return false};var Z=va.active.val("all");if(O.alphaPrecision<0)O.alphaPrecision=0;else if(O.alphaPrecision>2)O.alphaPrecision=2;var Oa='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(O.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(O.title||ba.text.title)+
'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+na.clientPath+na.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="'+na.clientPath+na.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+
ba.text.newColor+'<div class="color_preview"><span class="Active" title="'+ba.tooltips.colors.newColor+'">&nbsp;</span><span class="Current" title="'+ba.tooltips.colors.currentColor+'">&nbsp;</span></div></div>'+ba.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+ba.text.ok+'" title="'+ba.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+ba.text.cancel+'" title="'+ba.tooltips.buttons.cancel+'"/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="'+
ba.tooltips.hue.radio+'"><input type="radio" value="h"'+(l.color.mode=="h"?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(Z!=null?Z.h:"")+'" title="'+ba.tooltips.hue.textbox+'"/>&nbsp;\u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+ba.tooltips.saturation.radio+'"><input type="radio" value="s"'+(l.color.mode=="s"?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(Z!=
null?Z.s:"")+'" title="'+ba.tooltips.saturation.textbox+'"/>&nbsp;%</td></tr><tr class="Value"><td class="Radio"><label title="'+ba.tooltips.value.radio+'"><input type="radio" value="v"'+(l.color.mode=="v"?' checked="checked"':"")+'/>V:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(Z!=null?Z.v:"")+'" title="'+ba.tooltips.value.textbox+'"/>&nbsp;%<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="'+ba.tooltips.red.radio+'"><input type="radio" value="r"'+(l.color.mode==
"r"?' checked="checked"':"")+'/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(Z!=null?Z.r:"")+'" title="'+ba.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+ba.tooltips.green.radio+'"><input type="radio" value="g"'+(l.color.mode=="g"?' checked="checked"':"")+'/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(Z!=null?Z.g:"")+'" title="'+ba.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+
ba.tooltips.blue.radio+'"><input type="radio" value="b"'+(l.color.mode=="b"?' checked="checked"':"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(Z!=null?Z.b:"")+'" title="'+ba.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(O.alphaSupport?'<label title="'+ba.tooltips.alpha.radio+'"><input type="radio" value="a"'+(l.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":"&nbsp;")+'</td><td class="Text">'+(O.alphaSupport?'<input type="text" maxlength="'+
(3+O.alphaPrecision)+'" value="'+(Z!=null?Math.precision(Z.a*100/255,O.alphaPrecision):"")+'" title="'+ba.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ba.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(Z!=null?Z.hex:"")+'"/></label>'+(O.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(Z!=null?Z.ahex.substring(6):"")+'" title="'+ba.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";
if(O.expandable){w.html(Oa);a(document.body).children("div.jPicker.Container").length==0?a(document.body).prepend(w):a(document.body).children("div.jPicker.Container:last").after(w);w.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});w.css({zIndex:20})});w.css({left:O.position.x=="left"?H.offset().left-530-(O.position.y=="center"?25:0)+"px":O.position.x=="center"?H.offset().left-260+"px":O.position.x=="right"?H.offset().left-10+(O.position.y=="center"?25:0)+
"px":O.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":H.offset().left+parseInt(O.position.x)+"px",position:"absolute",top:O.position.y=="top"?H.offset().top-312+"px":O.position.y=="center"?H.offset().top-156+"px":O.position.y=="bottom"?H.offset().top+25+"px":H.offset().top+parseInt(O.position.y)+"px"})}else{w=a(e);w.html(Oa)}Oa=w.find("tbody:first");q=Oa.find("div.Map:first");M=Oa.find("div.Bar:first");var Za=q.find("span"),fb=M.find("span");U=Za.filter(".Map1:first");P=Za.filter(".Map2:first");
K=Za.filter(".Map3:first");fa=fb.filter(".Map1:first");W=fb.filter(".Map2:first");Q=fb.filter(".Map3:first");ha=fb.filter(".Map4:first");ua=fb.filter(".Map5:first");ia=fb.filter(".Map6:first");ea=new n(q,{map:{width:na.colorMap.width,height:na.colorMap.height},arrow:{image:na.clientPath+na.colorMap.arrow.file,width:na.colorMap.arrow.width,height:na.colorMap.arrow.height}});ea.bind(Ha);ga=new n(M,{map:{width:na.colorBar.width,height:na.colorBar.height},arrow:{image:na.clientPath+na.colorBar.arrow.file,
width:na.colorBar.arrow.width,height:na.colorBar.arrow.height}});ga.bind(Pa);ra=new f(Oa,va.active,O.expandable&&O.bindToInput?O.input:null,O.alphaPrecision);Za=Z!=null?Z.hex:null;var wb=Oa.find(".Preview");fb=Oa.find(".Button");sa=wb.find(".Active:first").css({backgroundColor:Za&&"#"+Za||"transparent"});ta=wb.find(".Current:first").css({backgroundColor:Za&&"#"+Za||"transparent"}).bind("click",gb);Da.call(e,ta,Math.precision(va.current.val("a")*100)/255,4);aa=fb.find(".Ok:first").bind("click",rb);
ma=fb.find(".Cancel:first").bind("click",Ia);Ga=fb.find(".Grid:first");setTimeout(function(){$a.call(e,U,na.clientPath+"Maps.png");$a.call(e,P,na.clientPath+"Maps.png");$a.call(e,K,na.clientPath+"map-opacity.png");$a.call(e,fa,na.clientPath+"Bars.png");$a.call(e,W,na.clientPath+"Bars.png");$a.call(e,Q,na.clientPath+"Bars.png");$a.call(e,ha,na.clientPath+"Bars.png");$a.call(e,ua,na.clientPath+"bar-opacity.png");$a.call(e,ia,na.clientPath+"AlphaBar.png");$a.call(e,wb.find("div:last"),na.clientPath+
"preview-opacity.png")},0);Oa.find("td.Radio input").bind("click",Sa);if(va.quickList&&va.quickList.length>0){fb="";for(i=0;i<va.quickList.length;i++){if((typeof va.quickList[i]).toString().toLowerCase()=="string")va.quickList[i]=new c({hex:va.quickList[i]});var xb=va.quickList[i].val("a"),Db=va.quickList[i].val("ahex");if(!O.alphaSupport&&Db)Db=Db.substring(0,6)+"ff";var pb=va.quickList[i].val("hex");fb+='<span class="QuickColor"'+(Db&&' title="#'+Db+'"'||"")+' style="background-color:'+(pb&&"#"+
pb||"")+";"+(pb?"":"background-image:url("+na.clientPath+"NoColor.png)")+(O.alphaSupport&&xb&&xb<255?";opacity:"+Math.precision(xb/255,4)+";filter:Alpha(opacity="+Math.precision(xb/2.55,4)+")":"")+'">&nbsp;</span>'}$a.call(e,Ga,na.clientPath+"bar-opacity.png");Ga.html(fb);Ga.find(".QuickColor").click(Eb)}Xa.call(e,l.color.mode);va.active.bind(Na);a.isFunction(nb)&&va.active.bind(nb);va.current.bind(mb);if(O.expandable){e.icon=H.parents(".Icon:first");Ma=e.icon.find(".Color:first").css({backgroundColor:Za&&
"#"+Za||"transparent"});Ra=e.icon.find(".Alpha:first");$a.call(e,Ra,na.clientPath+"bar-opacity.png");Da.call(e,Ra,Math.precision((255-(Z!=null?Z.a:0))*100/255,4));Qa=e.icon.find(".Image:first").css({backgroundImage:"url('"+na.clientPath+na.picker.file+"')"}).bind("click",sb);if(O.bindToInput&&O.updateInputColor)O.input.css({backgroundColor:Za&&"#"+Za||"transparent",color:Z==null||Z.v>75?"#000000":"#ffffff"});Va=Oa.find(".Move:first").bind("mousedown",La);va.active.bind(hb)}else Ob.call(e)},na=l.images,
ba=l.localization,va={active:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({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 c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({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,e,{commitCallback:Fb,liveCallback:nb,cancelCallback:Gb,color:va,show:Ob,hide:Kb,destroy:function(){w.find("td.Radio input").unbind("click",Sa);ta.unbind("click",gb);ma.unbind("click",Ia);aa.unbind("click",rb);if(l.window.expandable){Qa.unbind("click",sb);Va.unbind("mousedown",La);e.icon=null}w.find(".QuickColor").unbind("click",Eb);ia=ua=ha=Q=W=fa=K=P=U=
M=q=null;ea.destroy();ea=null;ga.destroy();ga=null;ra.destroy();nb=Gb=Fb=Ga=ma=aa=ta=sa=ra=null;w.html("");for(i=0;i<m.length;i++)m[i]==e&&m.splice(i,1)}});m.push(e);setTimeout(function(){Ub.call(e)},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 c({ahex:"#ffcc00ff"}),quickList:[new c({h:360,
s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),new c({h:360,s:100,v:75}),new c({h:360,s:100,v:50}),new c({h:180,s:0,v:100}),new c({h:30,s:33,v:100}),new c({h:30,s:66,v:100}),new c({h:30,s:100,v:100}),new c({h:30,s:100,v:75}),new c({h:30,s:100,v:50}),new c({h:180,s:0,v:90}),new c({h:60,s:33,v:100}),new c({h:60,s:66,v:100}),new c({h:60,s:100,v:100}),new c({h:60,s:100,v:75}),new c({h:60,s:100,v:50}),new c({h:180,s:0,v:80}),new c({h:90,s:33,v:100}),new c({h:90,s:66,v:100}),new c({h:90,
s:100,v:100}),new c({h:90,s:100,v:75}),new c({h:90,s:100,v:50}),new c({h:180,s:0,v:70}),new c({h:120,s:33,v:100}),new c({h:120,s:66,v:100}),new c({h:120,s:100,v:100}),new c({h:120,s:100,v:75}),new c({h:120,s:100,v:50}),new c({h:180,s:0,v:60}),new c({h:150,s:33,v:100}),new c({h:150,s:66,v:100}),new c({h:150,s:100,v:100}),new c({h:150,s:100,v:75}),new c({h:150,s:100,v:50}),new c({h:180,s:0,v:50}),new c({h:180,s:33,v:100}),new c({h:180,s:66,v:100}),new c({h:180,s:100,v:100}),new c({h:180,s:100,v:75}),
new c({h:180,s:100,v:50}),new c({h:180,s:0,v:40}),new c({h:210,s:33,v:100}),new c({h:210,s:66,v:100}),new c({h:210,s:100,v:100}),new c({h:210,s:100,v:75}),new c({h:210,s:100,v:50}),new c({h:180,s:0,v:30}),new c({h:240,s:33,v:100}),new c({h:240,s:66,v:100}),new c({h:240,s:100,v:100}),new c({h:240,s:100,v:75}),new c({h:240,s:100,v:50}),new c({h:180,s:0,v:20}),new c({h:270,s:33,v:100}),new c({h:270,s:66,v:100}),new c({h:270,s:100,v:100}),new c({h:270,s:100,v:75}),new c({h:270,s:100,v:50}),new c({h:180,
s:0,v:10}),new c({h:300,s:33,v:100}),new c({h:300,s:66,v:100}),new c({h:300,s:100,v:100}),new c({h:300,s:100,v:75}),new c({h:300,s:100,v:50}),new c({h:180,s:0,v:0}),new c({h:330,s:33,v:100}),new c({h:330,s:66,v:100}),new c({h:330,s:100,v:100}),new c({h:330,s:100,v:75}),new c({h:330,s:100,v:50}),new c]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",width:20,height:7}},
picker:{file:"picker.gif",width:25,height:24}},localization:{text:{title:"Drag Markers To Pick A Color",newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press &ldquo;OK&rdquo; To Commit",currentColor:"Click To Revert To Original Color"},buttons:{ok:"Commit To This Color Selection",cancel:"Cancel And Revert To Original Color"},hue:{radio:"Set To &ldquo;Hue&rdquo; Color Mode",textbox:"Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)"},saturation:{radio:"Set To &ldquo;Saturation&rdquo; Color Mode",
textbox:"Enter A &ldquo;Saturation&rdquo; Value (0-100%)"},value:{radio:"Set To &ldquo;Value&rdquo; Color Mode",textbox:"Enter A &ldquo;Value&rdquo; Value (0-100%)"},red:{radio:"Set To &ldquo;Red&rdquo; Color Mode",textbox:"Enter A &ldquo;Red&rdquo; Value (0-255)"},green:{radio:"Set To &ldquo;Green&rdquo; Color Mode",textbox:"Enter A &ldquo;Green&rdquo; Value (0-255)"},blue:{radio:"Set To &ldquo;Blue&rdquo; Color Mode",textbox:"Enter A &ldquo;Blue&rdquo; Value (0-255)"},alpha:{radio:"Set To &ldquo;Alpha&rdquo; Color Mode",
textbox:"Enter A &ldquo;Alpha&rdquo; Value (0-100)"},hex:{textbox:"Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)",alpha:"Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)"}}}}})(jQuery,"1.1.6");(function(a){function n(m){var o=m||window.event,b=[].slice.call(arguments,1),d=0,e=0,l=0;m=a.event.fix(o);m.type="mousewheel";if(o.wheelDelta)d=o.wheelDelta/120;if(o.detail)d=-o.detail/3;l=d;if(o.axis!==undefined&&o.axis===o.HORIZONTAL_AXIS){l=0;e=-1*d}if(o.wheelDeltaY!==undefined)l=o.wheelDeltaY/120;if(o.wheelDeltaX!==undefined)e=-1*o.wheelDeltaX/120;b.unshift(m,d,e,l);return(a.event.dispatch||a.event.handle).apply(this,b)}var f=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=f.length;c;)a.event.fixHooks[f[--c]]=
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var m=f.length;m;)this.addEventListener(f[--m],n,false);else this.onmousewheel=n},teardown:function(){if(this.removeEventListener)for(var m=f.length;m;)this.removeEventListener(f[--m],n,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(m){return m?this.bind("mousewheel",m):this.trigger("mousewheel")},unmousewheel:function(m){return this.unbind("mousewheel",m)}})})(jQuery);