websch/method-draw/svgedit.compiled.js

684 lines
346 KiB
JavaScript
Raw Normal View History

2012-07-31 19:01:03 +00:00
function touchHandler(a){var p=a.changedTouches,h=p[0],b="";switch(a.type){case "touchstart":b="mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var o=document.createEvent("MouseEvent");o.initMouseEvent(b,true,true,window,1,h.screenX,h.screenY,h.clientX,h.clientY,false,false,false,false,0,null);if(p.length<2){h.target.dispatchEvent(o);a.preventDefault()}};(function(a){function p(h){if(typeof h.data==="string"){var b=h.handler,o=h.data.toLowerCase().split(" ");h.handler=function(u){if(!(this!==u.target&&(/textarea|select/i.test(u.target.nodeName)||u.target.type==="text"))){var c=u.type!=="keypress"&&a.hotkeys.specialKeys[u.which],f=String.fromCharCode(u.which).toLowerCase(),d="",l={};if(u.altKey&&c!=="alt")d+="alt+";if(u.ctrlKey&&c!=="ctrl")d+="ctrl+";if(u.metaKey&&!u.ctrlKey&&c!=="meta")d+="meta+";if(u.shiftKey&&c!=="shift")d+="shift+";if(c)l[d+c]=
true;else{l[d+f]=true;l[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[f]]=true}c=0;for(f=o.length;c<f;c++)if(l[o[c]])return b.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function h(ca){return typeof ca==="string"}function b(ca){var V=d.call(arguments,1);return function(){return ca.apply(this,V.concat(d.call(arguments)))}}function o(ca,V,W,na,qa){var ma;if(na!==f){V=W.match(ca?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);W=V[3]||"";if(qa===2&&h(na))na=na.replace(ca?Y:Q,"");else{ma=q(V[2]);na=h(na)?q[ca?ga:M](na):na;na=qa===2?na:qa===1?a.extend({},na,ma):a.extend({},ma,na);na=v(na);if(ca)na=na.replace(xa,l)}ca=V[1]+(ca?"#":na||!V[1]?"?":"")+na+W}else ca=
V(W!==f?W:p[oa][ea]);return ca}function u(ca,V,W){if(V===f||typeof V==="boolean"){W=V;V=v[ca?ga:M]()}else V=h(V)?V.replace(ca?Y:Q,""):V;return q(V,W)}function c(ca,V,W,na){if(!h(W)&&typeof W!=="object"){na=W;W=V;V=f}return this.each(function(){var qa=a(this),ma=V||R()[(this.nodeName||"").toLowerCase()]||"",la=ma&&qa.attr(ma)||"";qa.attr(ma,v[ca](la,W,na))})}var f,d=Array.prototype.slice,l=decodeURIComponent,v=a.param,B,q,K,S=a.bbq=a.bbq||{},O,H,R,U=a.event.special,M="querystring",ga="fragment",oa=
"location",ea="href",Q=/^.*\?|#.*$/g,Y=/^.*\#/,xa,ja={};v[M]=b(o,0,function(ca){return ca.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});v[ga]=B=b(o,1,function(ca){return ca.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(ca){ca=ca||"";ca=a.map(ca.split(""),encodeURIComponent);xa=RegExp(ca.join("|"),"g")};B.noEscape(",/");a.deparam=q=function(ca,V){var W={},na={"true":true,"false":false,"null":null};a.each(ca.replace(/\+/g," ").split("&"),function(qa,ma){var la=ma.split("="),za=l(la[0]),Ga=W,Aa=
0,Ha=za.split("]["),Ja=Ha.length-1;if(/\[/.test(Ha[0])&&/\]$/.test(Ha[Ja])){Ha[Ja]=Ha[Ja].replace(/\]$/,"");Ha=Ha.shift().split("[").concat(Ha);Ja=Ha.length-1}else Ja=0;if(la.length===2){la=l(la[1]);if(V)la=la&&!isNaN(la)?+la:la==="undefined"?f:na[la]!==f?na[la]:la;if(Ja)for(;Aa<=Ja;Aa++){za=Ha[Aa]===""?Ga.length:Ha[Aa];Ga=Ga[za]=Aa<Ja?Ga[za]||(Ha[Aa+1]&&isNaN(Ha[Aa+1])?{}:[]):la}else if(a.isArray(W[za]))W[za].push(la);else W[za]=W[za]!==f?[W[za],la]:la}else if(za)W[za]=V?f:""});return W};q[M]=b(u,
0);q[ga]=K=b(u,1);a.elemUrlAttr||(a.elemUrlAttr=function(ca){return a.extend(ja,ca)})({a:ea,base:ea,iframe:"src",img:"src",input:"src",form:"action",link:ea,script:"src"});R=a.elemUrlAttr;a.fn[M]=b(c,M);a.fn[ga]=b(c,ga);S.pushState=O=function(ca,V){if(h(ca)&&/^#/.test(ca)&&V===f)V=2;var W=ca!==f;W=B(p[oa][ea],W?ca:{},W?V:2);p[oa][ea]=W+(/#/.test(W)?"":"#")};S.getState=H=function(ca,V){return ca===f||typeof ca==="boolean"?K(ca):K(V)[ca]};S.removeState=function(ca){var V={};if(ca!==f){V=H();a.each(a.isArray(ca)?
ca:arguments,function(W,na){delete V[na]})}O(V,2)};U.hashchange=a.extend(U.hashchange,{add:function(ca){function V(na){var qa=na[ga]=B();na.getState=function(ma,la){return ma===f||typeof ma==="boolean"?q(qa,ma):q(qa,la)[ma]};W.apply(this,arguments)}var W;if(a.isFunction(ca)){W=ca;return V}else{W=ca.handler;ca.handler=V}}})})(jQuery,this);
(function(a,p,h){function b(B){B=B||p[c][f];return B.replace(/^[^#]*#?(.*)$/,"$1")}var o,u=a.event.special,c="location",f="href",d=document.documentMode,l=a.browser.msie&&(d===h||d<8),v="onhashchange"in p&&!l;a.hashchangeDelay=100;u.hashchange=a.extend(u.hashchange,{setup:function(){if(v)return false;a(o.start)},teardown:function(){if(v)return false;a(o.stop)}});o=function(){function B(){O=H=function(R){return R};if(l){S=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
H=function(){return b(S.document[c][f])};O=function(R,U){if(R!==U){var M=S.document;M.open().close();M[c].hash="#"+R}};O(b())}}var q={},K,S,O,H;q.start=function(){if(!K){var R=b();O||B();(function U(){var M=b(),ga=H(R);if(M!==R){O(R=M,ga);a(p).trigger("hashchange")}else if(ga!==R)p[c][f]=p[c][f].replace(/#.*/,"")+"#"+ga;K=setTimeout(U,a.hashchangeDelay)})()}};q.stop=function(){if(!S){K&&clearTimeout(K);K=0}};return q}()})(jQuery,this);(function(a){var p={},h;a.svgIcons=function(b,o){function u(ca,V){if(ca!=="ajax"){if(R)return;var W=(S=ea[0].contentDocument)&&S.getElementById("svg_eof");if(!W&&!(V&&W)){U++;if(U<50)setTimeout(u,20);else{f();R=true}return}R=true}K=a(S.firstChild).children();if(o.no_img)setTimeout(function(){H||c()},500);else{W=oa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:W,width:0,height:0}).appendTo("body").load(function(){c(true)}).error(function(){c()})}}
function c(ca,V){if(!H){if(o.no_img)ca=false;if(ca){var W=a(document.createElement("div"));W.hide().appendTo("body")}if(V){var na=o.fallback_path?o.fallback_path:"";a.each(V,function(Ja,Ia){a("#"+Ja);var Da=a(new Image).attr({"class":"svg_icon",src:na+Ia,width:B,height:q,alt:"icon"});ja(Da,Ja)})}else for(var qa=K.length,ma=0;ma<qa;ma++){var la=K[ma],za=la.id;if(za==="svg_eof")break;a("#"+za);la=la.getElementsByTagNameNS(l,"svg")[0];var Ga=document.createElementNS(l,"svg");Ga.setAttributeNS(l,"viewBox",
[0,0,B,q].join(" "));var Aa=la.getAttribute("width"),Ha=la.getAttribute("height");la.removeAttribute("width");la.removeAttribute("height");la.getAttribute("viewBox")||la.setAttribute("viewBox",[0,0,Aa,Ha].join(" "));Ga.setAttribute("xmlns",l);Ga.setAttribute("width",B);Ga.setAttribute("height",q);Ga.setAttribute("xmlns:xlink",v);Ga.setAttribute("class","svg_icon");ga||(la=la.cloneNode(true));Ga.appendChild(la);if(ca){ga||Ga.cloneNode(true);W.empty().append(Ga);la=oa+d(W.html());la=a(new Image).attr({"class":"svg_icon",
src:la})}else la=h(a(Ga),ma);ja(la,za)}o.placement&&a.each(o.placement,function(Ja,Ia){p[Ia]&&a(Ja).each(function(Da){var ya=p[Ia].clone();if(Da>0&&!ca)ya=h(ya,Da,true);xa(a(this),ya,Ia)})});if(!V){ca&&W.remove();ea&&ea.remove();O&&O.remove()}o.resize&&a.resizeSvgIcons(o.resize);H=true;o.callback&&o.callback(p)}}function f(){if(b.indexOf(".svgz")!=-1){var ca=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(ca,o)}else o.fallback&&c(false,o.fallback)}
function d(ca){if(window.btoa)return window.btoa(ca);var V=Array(Math.floor((ca.length+2)/3)*4),W,na,qa,ma,la,za,Ga=0,Aa=0;do{W=ca.charCodeAt(Ga++);na=ca.charCodeAt(Ga++);qa=ca.charCodeAt(Ga++);ma=W>>2;W=(W&3)<<4|na>>4;la=(na&15)<<2|qa>>6;za=qa&63;if(isNaN(na))la=za=64;else if(isNaN(qa))za=64;V[Aa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);V[Aa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(W);V[Aa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(la);
V[Aa++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(za)}while(Ga<ca.length);return V.join("")}var l="http://www.w3.org/2000/svg",v="http://www.w3.org/1999/xlink",B=o.w?o.w:24,q=o.h?o.h:24,K,S,O,H=false,R=false,U=0,M=navigator.userAgent,ga=!!window.opera;M.indexOf("Safari/")>-1&&M.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(o.svgz){var ea=a('<object data="'+b+'" type=image/svg+xml>').appendTo("body").hide();try{S=ea[0].contentDocument;ea.load(u);
u(0,true)}catch(Q){f()}}else{var Y=new DOMParser;a.ajax({url:b,dataType:"string",success:function(ca){if(ca){S=Y.parseFromString(ca,"text/xml");a(function(){u("ajax")})}else a(f)},error:function(ca){if(window.opera)a(function(){f()});else if(ca.responseText){S=Y.parseFromString(ca.responseText,"text/xml");S.childNodes.length||a(f);a(function(){u("ajax")})}else a(f)}})}var xa=function(ca,V,W,na){ga&&V.css("visibility","hidden");if(o.replace){na&&V.attr("id",W);(W=ca.attr("class"))&&V.attr("class",
"svg_icon "+W);ca.replaceWith(V)}else ca.append(V);ga&&setTimeout(function(){V.removeAttr("style")},1)},ja=function(ca,V){if(o.id_match===undefined||o.id_match!==false)xa(holder,ca,V,true);p[V]=ca};h=function(ca,V){var W=ca.find("defs");if(!W.length)return ca;W=ga?W.find("*").filter(function(){return!!this.id}):W.find("[id]");var na=ca[0].getElementsByTagName("*"),qa=na.length;W.each(function(ma){var la=this.id;a(S).find("#"+la);this.id=ma="x"+la+V+ma;la="url(#"+la+")";var za="url(#"+ma+")";for(ma=
0;ma<qa;ma++){var Ga=na[ma];Ga.getAttribute("fill")===la&&Ga.setAttribute("fill",za);Ga.getAttribute("stroke")===la&&Ga.setAttribute("stroke",za);Ga.getAttribute("filter")===la&&Ga.setAttribute("filter",za)}});return ca}};a.getSvgIcon=function(b,o){var u=p[b];if(o&&u)u=h(u,0,true).clone(true);return u};a.resizeSvgIcons=function(b){var o=!a(".svg_icon:first").length;a.each(b,function(u,c){var f=a.isArray(c),d=f?c[0]:c,l=f?c[1]:c;if(o)u=u.replace(/\.svg_icon/g,"svg");a(u).each(function(){this.setAttribute("width",
d);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=d+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(b,o,u){b=document.createElementNS(p.svg,b);if(h)for(var c in o)b.setAttribute(c,o[c]);else for(c in o){var f=o[c],d=b[c];if(d&&d.constructor==="SVGLength")d.baseVal.value=f;else b.setAttribute(c,f)}u&&u.appendChild(b);return b}var p={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(b){b=b||{};this.alpha=isNaN(b.alpha)?100:b.alpha;if(b.copy){this.type=
2012-07-27 23:32:02 +00:00
b.copy.type;this.alpha=b.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=b.copy.solidColor;break;case "linearGradient":this.linearGradient=b.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=b.copy.radialGradient.cloneNode(true)}}else if(b.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=b.linearGradient.cloneNode(true)}else if(b.radialGradient){this.type=
2012-07-31 19:01:03 +00:00
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=b.radialGradient.cloneNode(true)}else if(b.solidColor){this.type="solidColor";this.solidColor=b.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var h=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(b){var o=
arguments;return this.each(function(){function u(ia,aa,ka,N,P){var da=P||a("stop",{"stop-color":aa,"stop-opacity":ka,offset:ia},Y);if(P){aa=P.getAttribute("stop-color");ka=P.getAttribute("stop-opacity");ia=P.getAttribute("offset")}else Y.appendChild(da);if(ka===null)ka=1;P=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+ia*ga)+", 26)"},Ua);var Ea=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:aa,"fill-opacity":ka,transform:"translate("+(10+ia*ga)+", 26)",stroke:"#000","stroke-width":1.5},Ua);$(Ea).mousedown(function(Na){c(this);Wa=eb;R.mousemove(l).mouseup(f);va=tb.offset();Na.preventDefault();return false}).data("stop",da).data("bg",P).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Na=this,Ra=+da.getAttribute("stop-opacity")||
1,bb=da.getAttribute("stop-color")||1,ob=(parseFloat(Ra)*255).toString(16);ob.length<2;)ob="0"+ob;aa=bb.substr(1)+ob;$("#"+q+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:aa,alphaSupport:true}},function(Sa){bb=Sa.val("hex")?"#"+Sa.val("hex"):"none";Ra=Sa.val("a")!==null?Sa.val("a")/256:1;Na.setAttribute("fill",bb);Na.setAttribute("fill-opacity",Ra);da.setAttribute("stop-color",
bb);da.setAttribute("stop-opacity",Ra);$("div.jGraduate_LightBox").hide();$("#"+q+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+q+"_jGraduate_stopPicker").hide()})});$(Y).find("stop").each(function(){var Na=$(this);if(+this.getAttribute("offset")>ia){if(!aa){var Ra=this.getAttribute("stop-color"),bb=this.getAttribute("stop-opacity");da.setAttribute("stop-color",Ra);Ea.setAttribute("fill",Ra);da.setAttribute("stop-opacity",bb===null?1:bb);Ea.setAttribute("fill-opacity",
bb===null?1:bb)}Na.before(da);return false}});N&&c(Ea);return da}function c(ia){eb&&eb.setAttribute("stroke","#000");ia.setAttribute("stroke","blue");eb=ia;eb.parentNode.appendChild(eb)}function f(){R.unbind("mousemove",l);if(Ba.getAttribute("display")!=="none"){Ba.setAttribute("display","none");var ia=$(eb),aa=ia.data("stop");ia=ia.data("bg");$([eb,aa,ia]).remove()}Wa=null}function d(){var ia=Ta?"rotate("+Ta+","+Ca+","+gb+") ":"";cb===1&&Ka===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform",
ia+"translate("+-Ca*(cb-1)+","+-gb*(Ka-1)+") scale("+cb+","+Ka+")")}function l(ia){var aa=ia.pageX-va.left;ia=ia.pageY-va.top;aa=aa<10?10:aa>ga+10?ga+10:aa;var ka="translate("+aa+", 26)";if(ia<-60||ia>130){Ba.setAttribute("display","block");Ba.setAttribute("transform",ka)}else Ba.setAttribute("display","none");Wa.setAttribute("transform",ka);$.data(Wa,"bg").setAttribute("transform",ka);$.data(Wa,"stop").setAttribute("offset",(aa-10)/ga);var N=0;$(Y).find("stop").each(function(){var P=this.getAttribute("offset"),
da=$(this);if(P<N){da.prev().before(da);wa=$(Y).find("stop")}N=P})}var v=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),q=v.attr("id"),K="#"+v.attr("id")+" ";if(K){var S=function(){switch(v.paint.type){case "radialGradient":v.paint.linearGradient=null;break;case "linearGradient":v.paint.radialGradient=null;break;case "solidColor":v.paint.radialGradient=v.paint.linearGradient=null}$.isFunction(v.okCallback)&&v.okCallback(v.paint);v.hide()},O=function(){$.isFunction(v.cancelCallback)&&v.cancelCallback();
v.hide()};$.extend(true,v,{paint:new $.jGraduate.Paint({copy:B.paint}),okCallback:$.isFunction(o[1])&&o[1]||null,cancelCallback:$.isFunction(o[2])&&o[2]||null});v.position();var H=null,R=$(window);if(v.paint.type=="none")v.paint=$.jGraduate.Paint({solidColor:"ffffff"});v.addClass("jGraduate_Picker");v.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 U=$(K+"> .jGraduate_colPick"),M=$(K+"> .jGraduate_gradPick");M.html('<div id="'+q+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.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="'+B.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="'+B.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="'+B.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="'+B.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 ga=256,oa=ga-0,ea=ga-0,Q,Y,xa,ja={};$(".jGraduate_SliderBar").width(145);var ca=$("#"+q+"_jGraduate_GradContainer")[0],V=a("svg",{id:q+"_jgraduate_svg",width:ga,height:ga,xmlns:p.svg},ca);Q=Q||v.paint.type;var W=Y=v.paint[Q],na=v.paint.alpha,qa=Q==="solidColor";switch(Q){case "solidColor":case "linearGradient":if(!qa){Y.id=q+"_lg_jgraduate_grad";
W=Y=V.appendChild(Y)}a("radialGradient",{id:q+"_rg_jgraduate_grad"},V);if(Q==="linearGradient")break;case "radialGradient":if(!qa){Y.id=q+"_rg_jgraduate_grad";W=Y=V.appendChild(Y)}a("linearGradient",{id:q+"_lg_jgraduate_grad"},V)}if(qa){W=Y=$("#"+q+"_lg_jgraduate_grad")[0];H=v.paint[Q];u(0,"#"+H,1);var ma=typeof B.newstop;if(ma==="string")switch(B.newstop){case "same":u(1,"#"+H,1);break;case "inverse":ma="";for(var la=0;la<6;la+=2){H.substr(la,2);var za=(255-parseInt(H.substr(la,2),16)).toString(16);
if(za.length<2)za=0+za;ma+=za}u(1,"#"+ma,1);break;case "white":u(1,"#ffffff",1);break;case "black":u(1,"#000000",1)}else if(ma==="object")u(1,B.newstop.color||"#"+H,"opac"in B.newstop?B.newstop.opac:1)}H=parseFloat(W.getAttribute("x1")||0);ma=parseFloat(W.getAttribute("y1")||0);la=parseFloat(W.getAttribute("x2")||1);za=parseFloat(W.getAttribute("y2")||0);var Ga=parseFloat(W.getAttribute("cx")||0.5),Aa=parseFloat(W.getAttribute("cy")||0.5),Ha=parseFloat(W.getAttribute("fx")||Ga),Ja=parseFloat(W.getAttribute("fy")||
Aa);xa=a("rect",{id:q+"_jgraduate_rect",x:0,y:0,width:oa,height:ea,fill:"url(#"+q+"_jgraduate_grad)","fill-opacity":na/100},V);var Ia=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ga,left:H*ga}).data("coord","start").appendTo(ca),Da=Ia.clone().text(2).css({top:za*ga,left:la*ga}).attr("title","End stop").data("coord","end").appendTo(ca),ya=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Aa*ga,left:Ga*
ga}).data("coord","center").appendTo(ca),Fa=ya.clone().text("F").css({top:Ja*ga,left:Ha*ga,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(ca);Fa[0].id=q+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,aa){var ka=Y.getAttribute(aa),N=isNaN(aa[1]);ka||(ka=N?"0.5":aa==="x2"?"1.0":"0.0");ja[aa]=$("#"+q+"_jGraduate_"+aa).val(ka).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(aa[0]==="f"&&!fb))if(N&&Q==="radialGradient"||!N&&Q==="linearGradient")Y.setAttribute(aa,this.value);var P=N?aa[0]==="c"?ya:Fa:aa[1]==="1"?Ia:Da,da=aa.indexOf("x")>=0?"left":"top";P.css(da,this.value*ga)}).change()});var wa,Ua,tb=$("#"+q+"_jGraduate_StopSlider"),eb,Va,Wa,Ba=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Va),va,cb=1,Ka=1,Ta=0,Ca=Ga,gb=Aa;Va=a("svg",{width:"100%",height:45},tb[0]);ca=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},ca).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Va).on("click touchstart",function(ia){va=tb.offset();if(ia.target.tagName!=="path"){var aa=ia.pageX-va.left-8;aa=aa<10?10:aa>ga+10?ga+10:aa;u(aa/ga,0,0,true);ia.stopPropagation()}});$(Va).mouseover(function(){Va.appendChild(Ba)});Ua=a("g",{},Va);a("line",{x1:10,y1:15,x2:ga+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var pb=
M.find(".jGraduate_spreadMethod").change(function(){Y.setAttribute("spreadMethod",$(this).val())}),Xa=null,Ya=function(ia){var aa=ia.pageX-jb.left,ka=ia.pageY-jb.top;aa=aa<0?0:aa>ga?ga:aa;ka=ka<0?0:ka>ga?ga:ka;Xa.css("left",aa).css("top",ka);aa=aa/oa;ka=ka/ea;var N=Xa.data("coord"),P=Y;switch(N){case "start":ja.x1.val(aa);ja.y1.val(ka);P.setAttribute("x1",aa);P.setAttribute("y1",ka);break;case "end":ja.x2.val(aa);ja.y2.val(ka);P.setAttribute("x2",aa);P.setAttribute("y2",ka);break;case "center":ja.cx.val(aa);
ja.cy.val(ka);P.setAttribute("cx",aa);P.setAttribute("cy",ka);Ca=aa;gb=ka;d();break;case "focus":ja.fx.val(aa);ja.fy.val(ka);P.setAttribute("fx",aa);P.setAttribute("fy",ka);d()}ia.preventDefault()},ub=function(){Xa=null;R.unbind("mousemove",Ya).unbind("mouseup",ub)};wa=Y.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(la=0;la<ta;la++)u(0,0,0,0,wa[la]);pb.val(Y.getAttribute("spreadMethod")||
"pad");var jb,fb=false;xa.setAttribute("fill-opacity",na/100);$("#"+q+" div.grad_coord").mousedown(function(ia){ia.preventDefault();Xa=$(this);Xa.offset();jb=Xa.parent().offset();R.mousemove(Ya).mouseup(ub)});$("#"+q+"_jGraduate_Ok").bind("click touchstart",function(){v.paint.type=Q;v.paint[Q]=Y.cloneNode(true);v.paint.solidColor=null;S()});$("#"+q+"_jGraduate_Cancel").bind("click touchstart",function(){O()});if(Q==="radialGradient")if(fb)Fa.show();else{Fa.hide();ja.fx.val("");ja.fy.val("")}$("#"+
q+"_jGraduate_match_ctr")[0].checked=!fb;var sb,kb;$("#"+q+"_jGraduate_match_ctr").change(function(){fb=!this.checked;Fa.toggle(fb);ja.fx.val("");ja.fy.val("");var ia=Y;if(fb){var aa=sb||0.5,ka=kb||0.5;ia.setAttribute("fx",aa);ia.setAttribute("fy",ka);ja.fx.val(aa);ja.fy.val(ka)}else{sb=ia.getAttribute("fx");kb=ia.getAttribute("fy");ia.removeAttribute("fx");ia.removeAttribute("fy")}});wa=Y.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){Y.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=Y.getElementsByTagNameNS(p.svg,"stop")}var db;na=M=0;if(Q==="radialGradient"){V=Y.gradientTransform.baseVal;if(V.numberOfItems===2){ta=V.getItem(0);V=V.getItem(1);if(ta.type===2&&V.type===3){ta=V.matrix;if(ta.a!==1)M=Math.round(-(1-ta.a)*100);else if(ta.d!==1)M=Math.round((1-ta.d)*100)}}else if(V.numberOfItems===3){ca=V.getItem(0);ta=V.getItem(1);V=V.getItem(2);if(ca.type===4&&ta.type===2&&V.type===3){na=Math.round(ca.angle);ta=V.matrix;if(ta.a!==1)M=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)M=Math.round((1-ta.d)*100)}}}M={radius:{handle:"#"+q+"_jGraduate_RadiusArrows",input:"#"+q+"_jGraduate_RadiusInput",val:(Y.getAttribute("r")||0.5)*100},opacity:{handle:"#"+q+"_jGraduate_OpacArrows",input:"#"+q+"_jGraduate_OpacInput",val:v.paint.alpha||100},ellip:{handle:"#"+q+"_jGraduate_EllipArrows",input:"#"+q+"_jGraduate_EllipInput",val:M},angle:{handle:"#"+q+"_jGraduate_AngleArrows",input:"#"+q+"_jGraduate_AngleInput",val:na}};$.each(M,function(ia,aa){var ka=$(aa.handle);ka.mousedown(function(N){var P=
ka.parent();db={type:ia,elem:ka,input:$(aa.input),parent:P,offset:P.offset()};R.mousemove(mb).mouseup(qb);N.preventDefault()});$(aa.input).val(aa.val).change(function(){var N=+this.value,P=0,da=Q==="radialGradient";switch(ia){case "radius":da&&Y.setAttribute("r",N/100);P=Math.pow(N/100,0.4)/2*145;break;case "opacity":v.paint.alpha=N;xa.setAttribute("fill-opacity",N/100);P=N*1.45;break;case "ellip":cb=Ka=1;if(N===0){P=72.5;break}if(N>99.5)N=99.5;if(N>0)Ka=1-N/100;else cb=-(N/100)-1;P=145*((N+100)/
2)/100;da&&d();break;case "angle":Ta=N;P=Ta/180;P+=0.5;P*=145;da&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var mb=function(ia){var aa=ia.pageX-db.offset.left-parseInt(db.parent.css("border-left-width"));if(aa>145)aa=145;if(aa<=0)aa=0;var ka=aa-5;aa/=145;switch(db.type){case "radius":aa=Math.pow(aa*2,2.5);if(aa>0.98&&aa<1.02)aa=1;if(aa<=0.01)aa=0.01;Y.setAttribute("r",aa);break;case "opacity":v.paint.alpha=parseInt(aa*100);xa.setAttribute("fill-opacity",aa);break;
case "ellip":Ka=cb=1;if(aa<0.5){aa/=0.5;cb=aa<=0?0.01:aa}else if(aa>0.5){aa/=0.5;aa=2-aa;Ka=aa<=0?0.01:aa}d();aa-=1;if(Ka===aa+1)aa=Math.abs(aa);break;case "angle":aa-=0.5;Ta=aa*=180;d();aa/=100}db.elem.css({"margin-left":ka});aa=Math.round(aa*100);db.input.val(aa);ia.preventDefault()},qb=function(){R.unbind("mousemove",mb).unbind("mouseup",qb);db=null};for(M=(v.paint.alpha*255/100).toString(16);M.length<2;)M="0"+M;M=M.split(".")[0];H=v.paint.solidColor=="none"?"":v.paint.solidColor+M;qa||(H=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});U.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:H,alphaSupport:true}},function(ia){v.paint.type="solidColor";v.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;v.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";v.paint.radialGradient=null;S()},null,function(){O()});var vb=$(K+" .jGraduate_tabs li");vb.on("click touchstart",function(){vb.removeClass("jGraduate_tab_current");
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var ia=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+q+"_jgraduate_rect")[0].setAttribute("fill","url(#"+q+"_"+ia+"_jgraduate_grad)");Q=ia==="lg"?"linearGradient":"radialGradient";$("#"+q+"_jGraduate_OpacInput").val(v.paint.alpha).change();var aa=$("#"+q+"_"+ia+"_jgraduate_grad")[0];if(Y!==aa){var ka=
$(Y).find("stop");$(aa).empty().append(ka);Y=aa;aa=pb.val();Y.setAttribute("spreadMethod",aa)}fb=ia==="rg"&&Y.getAttribute("fx")!=null&&!(Ga==Ha&&Aa==Ja);$("#"+q+"_jGraduate_focusCoord").toggle(fb);if(fb)$("#"+q+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();vb.removeClass("jGraduate_tab_current");var wb;switch(v.paint.type){case "linearGradient":wb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":wb=
$(K+" .jGraduate_tab_radgrad");break;default:wb=$(K+" .jGraduate_tab_color")}v.show();setTimeout(function(){wb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(h,b){if(h.menu==undefined)return false;if(h.inSpeed==undefined)h.inSpeed=150;if(h.outSpeed==undefined)h.outSpeed=75;if(h.inSpeed==0)h.inSpeed=-1;if(h.outSpeed==0)h.outSpeed=-1;$(this).each(function(){var o=$(this),u=$(o).offset(),c=$("#"+h.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var v=$(this);v.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
h.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,v)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,v){if(typeof l=="undefined")l=d;d.stopPropagation();if(o.hasClass("disabled")||l.altKey)return false;var B=d.pageX,q=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;q=d.originalEvent.touches[0].pageY}d=a.width()-c.width();l=a.height()-c.height();if(B>d-15)B=d-15;
if(q>l-30)q=l-30;if(svgedit.browser.isTouch())q-=c.height()/2;p.unbind("click");c.css({top:q,left:B}).fadeIn(h.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
break;case 40:if(c.find("LI.hover").length==0)c.find("LI:first").addClass("hover");else{c.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:first").addClass("hover")}break;case 13:c.find("LI.hover A").trigger("click");break;case 27:p.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){p.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1),
$(v),{x:B-u.left,y:q-u.top,docX:B,docY:q});return false});setTimeout(function(){p.click(function(){p.unbind("click").unbind("keypress");c.fadeOut(h.outSpeed);return false})},0)};if($.browser.mozilla)$("#"+h.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+h.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+h.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})});$(o).add($("UL.contextMenu")).bind("contextmenu",
function(){return false})});return $(this)},disableContextMenuItems:function(h){if(h==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(h!=undefined)for(var b=h.split(","),o=0;o<b.length;o++)$(this).find('A[href="'+b[o]+'"]').parent().addClass("disabled")});return $(this)},enableContextMenuItems:function(h){if(h==undefined){$(this).find("LI.disabled").removeClass("disabled");return $(this)}$(this).each(function(){if(h!=undefined)for(var b=h.split(","),o=
0;o<b.length;o++)$(this).find('A[href="'+b[o]+'"]').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 p=navigator.userAgent,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),b=!!window.opera,o=p.indexOf("AppleWebKit")>=0,u=p.indexOf("Gecko/")>=0,c=p.indexOf("MSIE")>=0,f=p.indexOf("Chrome/")>=0,d=p.indexOf("Windows")>=0,l=p.indexOf("Macintosh")>=
0,v="ontouchstart"in window,B=!!h.querySelector,q=!!document.evaluate,K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var ea=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{ea.replaceItem(oa,0);return true}catch(Q){}return false}(),S=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var ea=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{ea.insertItemBefore(oa,
0);return true}catch(Q){}return false}(),O=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),ea=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);ea.setAttribute("x",5);oa.appendChild(ea);var Q=document.createElementNS("http://www.w3.org/2000/svg","text");Q.textContent="a";ea.appendChild(Q);ea=Q.getStartPositionOfChar(0);ea=ea.x;document.documentElement.removeChild(oa);return ea===0}(),H=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(oa);var ea=document.createElementNS("http://www.w3.org/2000/svg","path");ea.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(ea);ea=ea.getBBox();document.documentElement.removeChild(oa);return ea.height>4&&ea.height<5}(),R=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var ea=document.createElementNS("http://www.w3.org/2000/svg","path");ea.setAttribute("d","M0,0 10,0");var Q=
document.createElementNS("http://www.w3.org/2000/svg","path");Q.setAttribute("d","M5,0 15,0");var Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(ea);Y.appendChild(Q);oa.appendChild(Y);ea=Y.getBBox();document.documentElement.removeChild(oa);return ea.width==15}(),U=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("x",0.1);(oa=oa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
return oa}(),M=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect");oa.setAttribute("style","vector-effect:non-scaling-stroke");return oa.style.vectorEffect==="non-scaling-stroke"}(),ga=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,ea=h.createSVGTransform();oa.appendItem(ea);return oa.getItem(0)==ea}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return o};svgedit.browser.isGecko=function(){return u};
svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return v};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return q};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return S};svgedit.browser.supportsPathBBox=function(){return H};
svgedit.browser.supportsHVLineContainerBBox=function(){return R};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return U};svgedit.browser.supportsNonScalingStroke=function(){return M};svgedit.browser.supportsNativeTransformLists=function(){return ga}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),p={};svgedit.transformlist.SVGTransformList=function(h){this._elem=h||null;this._xforms=[];this._update=function(){var b="";a.createSVGMatrix();for(var o=0;o<this.numberOfItems;++o){var u=this._list.getItem(o);b=b;u=u;var c=u.matrix,f="";switch(u.type){case 1:f="matrix("+[c.a,c.b,c.c,c.d,c.e,c.f].join(",")+")";break;case 2:f="translate("+c.e+","+c.f+")";break;case 3:f=
c.a==c.d?"scale("+c.a+")":"scale("+c.a+","+c.d+")";break;case 4:var d=0;f=0;if(u.angle!=0){d=1-c.a;f=(d*c.f+c.b*c.e)/(d*d+c.b*c.b);d=(c.e-c.b*f)/d}f="rotate("+u.angle+" "+d+","+f+")"}b=b+(f+" ")}this._elem.setAttribute("transform",b)};this._list=this;this._init=function(){var b=this._elem.getAttribute("transform");if(b)for(var o=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,u=true;u;){u=b.match(o);b=b.replace(o,"");if(u&&u[1]){var c=u[1].split(/\s*\(/),f=c[0];c=c[1].match(/\s*(.*?)\s*\)/);
c[1]=c[1].replace(/(\d)-/g,"$1 -");var d=c[1].split(/[, ]+/),l="abcdef".split(""),v=a.createSVGMatrix();$.each(d,function(K,S){d[K]=parseFloat(S);if(f=="matrix")v[l[K]]=d[K]});c=a.createSVGTransform();var B="set"+f.charAt(0).toUpperCase()+f.slice(1),q=f=="matrix"?[v]:d;if(f=="scale"&&q.length==1)q.push(q[0]);else if(f=="translate"&&q.length==1)q.push(0);else if(f=="rotate"&&q.length==1){q.push(0);q.push(0)}c[B].apply(c,q);this._list.appendItem(c)}}};this._removeFromOtherLists=function(b){if(b){var o=
false,u;for(u in p){for(var c=p[u],f=0,d=c._xforms.length;f<d;++f)if(c._xforms[f]==b){o=true;c.removeItem(f);break}if(o)break}}};this.numberOfItems=0;this.clear=function(){this.numberOfItems=0;this._xforms=[]};this.initialize=function(b){this.numberOfItems=1;this._removeFromOtherLists(b);this._xforms=[b]};this.getItem=function(b){if(b<this.numberOfItems&&b>=0)return this._xforms[b];throw{code:1};};this.insertItemBefore=function(b,o){var u=null;if(o>=0)if(o<this.numberOfItems){this._removeFromOtherLists(b);
u=Array(this.numberOfItems+1);for(var c=0;c<o;++c)u[c]=this._xforms[c];u[c]=b;for(var f=c+1;c<this.numberOfItems;++f,++c)u[f]=this._xforms[c];this.numberOfItems++;this._xforms=u;u=b;this._list._update()}else u=this._list.appendItem(b);return u};this.replaceItem=function(b,o){var u=null;if(o<this.numberOfItems&&o>=0){this._removeFromOtherLists(b);u=this._xforms[o]=b;this._list._update()}return u};this.removeItem=function(b){if(b<this.numberOfItems&&b>=0){for(var o=this._xforms[b],u=Array(this.numberOfItems-
1),c=0;c<b;++c)u[c]=this._xforms[c];for(b=c;b<this.numberOfItems-1;++b,++c)u[b]=this._xforms[c+1];this.numberOfItems--;this._xforms=u;this._list._update();return o}else throw{code:1};};this.appendItem=function(b){this._removeFromOtherLists(b);this._xforms.push(b);this.numberOfItems++;this._list._update();return b}};svgedit.transformlist.resetListMap=function(){p={}};svgedit.transformlist.removeElementFromListMap=function(h){h.id&&p[h.id]&&delete p[h.id]};svgedit.transformlist.getTransformList=function(h){if(svgedit.browser.supportsNativeTransformLists())if(h.transform)return h.transform.baseVal;
else if(h.gradientTransform)return h.gradientTransform.baseVal;else{if(h.patternTransform)return h.patternTransform.baseVal}else{var b=h.id;b||(b="temp");var o=p[b];if(!o||b=="temp"){p[b]=new svgedit.transformlist.SVGTransformList(h);p[b]._init();o=p[b]}return o}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(p,h,b){return{x:b.a*p+b.c*h+b.e,y:b.b*p+b.d*h+b.f}};svgedit.math.isIdentity=function(p){return p.a===1&&p.b===0&&p.c===0&&p.d===1&&p.e===0&&p.f===0};svgedit.math.matrixMultiply=function(){for(var p=arguments,h=p.length,b=p[h-1];h-- >1;)b=p[h-1].multiply(b);if(Math.abs(b.a)<1.0E-14)b.a=0;if(Math.abs(b.b)<1.0E-14)b.b=0;if(Math.abs(b.c)<1.0E-14)b.c=0;if(Math.abs(b.d)<
1.0E-14)b.d=0;if(Math.abs(b.e)<1.0E-14)b.e=0;if(Math.abs(b.f)<1.0E-14)b.f=0;return b};svgedit.math.hasMatrixTransform=function(p){if(!p)return false;for(var h=p.numberOfItems;h--;){var b=p.getItem(h);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(p,h,b,o,u){var c={x:p,y:h},f={x:p+b,y:h};b={x:p+b,y:h+o};p={x:p,y:h+o};h=svgedit.math.transformPoint;c=h(c.x,c.y,u);var d=o=c.x,l=c.y,v=c.y;f=h(f.x,f.y,u);o=Math.min(o,f.x);d=Math.max(d,f.x);
l=Math.min(l,f.y);v=Math.max(v,f.y);p=h(p.x,p.y,u);o=Math.min(o,p.x);d=Math.max(d,p.x);l=Math.min(l,p.y);v=Math.max(v,p.y);b=h(b.x,b.y,u);o=Math.min(o,b.x);d=Math.max(d,b.x);l=Math.min(l,b.y);v=Math.max(v,b.y);return{tl:c,tr:f,bl:p,br:b,aabox:{x:o,y:l,width:d-o,height:v-l}}};svgedit.math.transformListToTransform=function(p,h,b){if(p==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());h=h==undefined?0:h;b=b==undefined?p.numberOfItems-1:b;h=parseInt(h);b=parseInt(b);if(h>b){var o=b;b=h;
h=o}o=a.createSVGMatrix();for(h=h;h<=b;++h){var u=h>=0&&h<p.numberOfItems?p.getItem(h).matrix:a.createSVGMatrix();o=svgedit.math.matrixMultiply(o,u)}return a.createSVGTransformFromMatrix(o)};svgedit.math.getMatrix=function(p){p=svgedit.transformlist.getTransformList(p);return svgedit.math.transformListToTransform(p).matrix};svgedit.math.snapToAngle=function(p,h,b,o){var u=Math.PI/4;b=b-p;var c=o-h;o=Math.sqrt(b*b+c*c);u=Math.round(Math.atan2(c,b)/u)*u;return{x:p+o*Math.cos(u),y:h+o*Math.sin(u),a:u}};
svgedit.math.rectsIntersect=function(p,h){return h.x<p.x+p.width&&h.x+h.width>p.x&&h.y<p.y+p.height&&h.y+h.height>p.y}})();svgedit=svgedit||{};
(function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],p=["y","y1","cy","ry","height"],h=$.merge(["r","radius"],a);$.merge(h,p);var b,o={px:1};svgedit.units.init=function(c){b=c;c=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(c);var f=document.createElementNS("http://www.w3.org/2000/svg","rect");f.setAttribute("width","1em");f.setAttribute("height","1ex");f.setAttribute("x","1in");c.appendChild(f);f=f.getBBox();document.body.removeChild(c);
c=f.x;o.em=f.width;o.ex=f.height;o["in"]=c;o.cm=c/2.54;o.mm=c/25.4;o.pt=c/72;o.pc=c/6;o["%"]=0};svgedit.units.getTypeMap=function(){return o};svgedit.units.shortFloat=function(c){var f=b.getRoundDigits();if(isNaN(c)){if($.isArray(c))return svgedit.units.shortFloat(c[0])+","+svgedit.units.shortFloat(c[1])}else return+(+c).toFixed(f);return parseFloat(c).toFixed(f)-0};svgedit.units.convertUnit=function(c,f){f=f||b.getBaseUnit();return svgedit.unit.shortFloat(c/o[f])};svgedit.units.setUnitAttr=function(c,
f,d){isNaN(d)||c.getAttribute(f);c.setAttribute(f,d)};var u={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(c){var f=c.tagName,d=b.getBaseUnit();if(f=u[f])for(var l=f.length,v=0;v<l;v++){var B=f[v],q=c.getAttribute(B);if(q)isNaN(q)||c.setAttribute(B,q/o[d]+d)}};svgedit.units.convertToNum=
function(c,f){if(!isNaN(f))return f-0;if(f.substr(-1)==="%"){var d=f.substr(0,f.length-1)/100,l=b.getWidth(),v=b.getHeight();return a.indexOf(c)>=0?d*l:p.indexOf(c)>=0?d*v:d*Math.sqrt(l*l+v*v)/Math.sqrt(2)}else{l=f.substr(-2);d=f.substr(0,f.length-2);return d*o[l]}};svgedit.units.isValidUnit=function(c,f,d){var l=false;if(h.indexOf(c)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(o,function(q){if(!l)if(RegExp("^-?[\\d\\.]+"+q+"$").test(f))l=true})}else l=true;else if(c=="id"){c=false;try{var v=b.getElement(f);
c=v==null||v===d}catch(B){}return c}else l=true;return l}})();svgedit=svgedit||{};
(function(){function a(c){if(svgedit.browser.supportsHVLineContainerBBox())try{return c.getBBox()}catch(f){}var d=$.data(c,"ref"),l=null;if(d){var v=$(d).children().clone().attr("visibility","hidden");$(u).append(v);l=v.filter("line, path")}else l=$(c).find("line, path");var B=false;if(l.length){l.each(function(){var q=this.getBBox();if(!q.width||!q.height)B=true});if(B){c=d?v:$(c).children();ret=getStrokedBBox(c)}else ret=c.getBBox()}else ret=c.getBBox();d&&v.remove();return ret}if(!svgedit.utilities)svgedit.utilities=
{};var p="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),h=null,b=null,o=null,u=null;svgedit.utilities.init=function(c){h=c;b=c.getDOMDocument();o=c.getDOMContainer();u=c.getSVGRoot()};svgedit.utilities.toXml=function(c){return $("<p/>").text(c).html()};svgedit.utilities.fromXml=function(c){return $("<p/>").html(c).text()};svgedit.utilities.encode64=function(c){c=svgedit.utilities.convertToXMLReferences(c);if(window.btoa)return window.btoa(c);
var f=Array(Math.floor((c.length+2)/3)*4),d,l,v,B,q,K,S=0,O=0;do{d=c.charCodeAt(S++);l=c.charCodeAt(S++);v=c.charCodeAt(S++);B=d>>2;d=(d&3)<<4|l>>4;q=(l&15)<<2|v>>6;K=v&63;if(isNaN(l))q=K=64;else if(isNaN(v))K=64;f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(q);f[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(K)}while(S<
c.length);return f.join("")};svgedit.utilities.decode64=function(c){if(window.atob)return window.atob(c);var f="",d,l,v="",B,q="",K=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));
d=d<<2|l>>4;l=(l&15)<<4|B>>2;v=(B&3)<<6|q;f+=String.fromCharCode(d);if(B!=64)f+=String.fromCharCode(l);if(q!=64)f+=String.fromCharCode(v)}while(K<c.length);return unescape(f)};svgedit.utilities.convertToXMLReferences=function(c){for(var f="",d=0;d<c.length;d++){var l=c.charCodeAt(d);if(l<128)f+=c[d];else if(l>127)f+="&#"+l+";"}return f};svgedit.utilities.text2xml=function(c){if(c.indexOf("<svg:svg")>=0)c=c.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var f;try{var d=window.DOMParser?
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");d.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{f=d.loadXML?d.loadXML(c)?d:false:d.parseFromString(c,"text/xml")}catch(v){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(c){return{x:c.x,y:c.y,width:c.width,height:c.height}};svgedit.utilities.walkTree=function(c,f){if(c&&c.nodeType==1){f(c);for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),f)}};
2012-07-27 23:32:02 +00:00
svgedit.utilities.walkTreePost=function(c,f){if(c&&c.nodeType==1){for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),f);f(c)}};svgedit.utilities.getUrlFromAttr=function(c){if(c)if(c.indexOf('url("')===0)return c.substring(5,c.indexOf('"',6));else if(c.indexOf("url('")===0)return c.substring(5,c.indexOf("'",6));else if(c.indexOf("url(")===0)return c.substring(4,c.indexOf(")"));return null};svgedit.utilities.getHref=function(c){return c.getAttributeNS("http://www.w3.org/1999/xlink",
2012-07-31 00:49:46 +00:00
"href")};svgedit.utilities.setHref=function(c,f){c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(c){c=h.getSVGContent().documentElement;var f=c.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:c.insertBefore(c.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),c.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(c){var f=c.pathSegList,d=f.numberOfItems;c=[[],[]];var l=f.getItem(0),
2012-07-31 19:01:03 +00:00
v=[l.x,l.y];for(l=0;l<d;l++){var B=f.getItem(l);if(typeof B.x!="undefined"){c[0].push(v[0]);c[1].push(v[1]);if(B.x1){for(var q=[B.x1,B.y1],K=[B.x2,B.y2],S=[B.x,B.y],O=0;O<2;O++){B=function(ga){return Math.pow(1-ga,3)*v[O]+3*Math.pow(1-ga,2)*ga*q[O]+3*(1-ga)*Math.pow(ga,2)*K[O]+Math.pow(ga,3)*S[O]};var H=6*v[O]-12*q[O]+6*K[O],R=-3*v[O]+9*q[O]-9*K[O]+3*S[O],U=3*q[O]-3*v[O];if(R==0){if(H!=0){H=-U/H;0<H&&H<1&&c[O].push(B(H))}}else{U=Math.pow(H,2)-4*U*R;if(!(U<0)){var M=(-H+Math.sqrt(U))/(2*R);0<M&&M<
1&&c[O].push(B(M));H=(-H-Math.sqrt(U))/(2*R);0<H&&H<1&&c[O].push(B(H))}}}v=S}else{c[0].push(B.x);c[1].push(B.y)}}}f=Math.min.apply(null,c[0]);d=Math.max.apply(null,c[0])-f;l=Math.min.apply(null,c[1]);c=Math.max.apply(null,c[1])-l;return{x:f,y:l,width:d,height:c}};svgedit.utilities.getBBox=function(c){var f=c||h.geSelectedElements()[0];if(c.nodeType!=1)return null;c=null;var d=f.nodeName;switch(d){case "text":if(f.textContent===""){f.textContent="a";c=f.getBBox();f.textContent=""}else try{c=f.getBBox()}catch(l){}break;
case "path":if(svgedit.browser.supportsPathBBox())try{c=f.getBBox()}catch(v){}else c=svgedit.utilities.getPathBBox(f);break;case "g":case "a":c=a(f);break;default:if(d==="use")c=a(f,true);if(d==="use"){c||(c=f.getBBox());if(!svgedit.browser.isWebkit()){d={};d.width=c.width;d.height=c.height;d.x=c.x+parseFloat(f.getAttribute("x")||0);d.y=c.y+parseFloat(f.getAttribute("y")||0);c=d}}else if(~p.indexOf(d))try{c=f.getBBox()}catch(B){f=$(f).closest("foreignObject");if(f.length)try{c=f[0].getBBox()}catch(q){c=
null}else c=null}}if(c)c=svgedit.utilities.bboxToObj(c);return c};svgedit.utilities.getRotationAngle=function(c,f){var d=c||h.getSelectedElements()[0];d=svgedit.transformlist.getTransformList(d);if(!d)return 0;for(var l=d.numberOfItems,v=0;v<l;++v){var B=d.getItem(v);if(B.type==4)return f?B.angle*Math.PI/180:B.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(c){return u.querySelector("#"+c)}:svgedit.browser.supportsXpath()?function(c){return b.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
c+'"]',o,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(c){return $(u).find("[id="+c+"]")[0]};svgedit.utilities.assignAttributes=function(c,f,d,l){d||(d=0);svgedit.browser.isOpera()||u.suspendRedraw(d);for(var v in f)if(d=v.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":v.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)c.setAttributeNS(d,v,f[v]);else l?svgedit.units.setUnitAttr(c,v,f[v]):c.setAttribute(v,f[v]);svgedit.browser.isOpera()||u.unsuspendRedraw(null)};
svgedit.utilities.cleanupElement=function(c){var f=u.suspendRedraw(60),d={"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 d){var v=d[l];c.getAttribute(l)==v&&c.removeAttribute(l)}u.unsuspendRedraw(f)}})();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 p={};$.each(a,function(o,u){p[u]=o});var h={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",
2012-07-31 19:01:03 +00:00
"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},b={};$.each(h,function(o,u){var c={};$.each(u,function(f,d){if(d.indexOf(":")>=
0){var l=d.split(":");c[l[1]]=p[l[0]]}else c[d]=d=="xmlns"?"http://www.w3.org/2000/xmlns/":null});b[o]=c});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(o){if(o.nodeType==3){o.nodeValue=o.nodeValue.replace(/^\s+|\s+$/g,"");o.nodeValue.length||o.parentNode.removeChild(o)}if(o.nodeType==1){var u=o.parentNode;if(o.ownerDocument&&u){var c=h[o.nodeName],f=b[o.nodeName];if(c!=undefined){for(var d=[],l=o.attributes.length;l--;){var v=o.attributes.item(l),B=v.nodeName,
q=v.localName,K=v.namespaceURI;if(!(f.hasOwnProperty(q)&&K==f[q]&&K!="http://www.w3.org/2000/xmlns/")&&!(K=="http://www.w3.org/2000/xmlns/"&&a[v.nodeValue])){B.indexOf("se:")==0&&d.push([B,v.nodeValue]);o.removeAttributeNS(K,q)}if(svgedit.browser.isGecko())switch(B){case "transform":case "gradientTransform":case "patternTransform":q=v.nodeValue.replace(/(\d)-/g,"$1 -");o.setAttribute(B,q)}if(B=="style"){v=v.nodeValue.split(";");for(B=v.length;B--;){q=v[B].split(":");c.indexOf(q[0])>=0&&o.setAttribute(q[0],
q[1])}o.removeAttribute("style")}}$.each(d,function(S,O){o.setAttributeNS("http://svg-edit.googlecode.com",O[0],O[1])});if((l=svgedit.utilities.getHref(o))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(o.nodeName)>=0)if(l[0]!="#"){svgedit.utilities.setHref(o,"");o.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(o.nodeName=="use"&&!svgedit.utilities.getHref(o))u.removeChild(o);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start",
"mask","stroke"],function(S,O){var H=o.getAttribute(O);if(H)if((H=svgedit.utilities.getUrlFromAttr(H))&&H[0]!=="#"){o.setAttribute(O,"");o.removeAttribute(O)}});for(l=o.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(o.childNodes.item(l))}}else{for(c=[];o.hasChildNodes();)c.push(u.insertBefore(o.firstChild,o));u.removeChild(o);for(l=c.length;l--;)svgedit.sanitize.sanitizeSvg(c[l])}}}}})();svgedit=svgedit||{};
(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,p,h,b){this.elem=a;this.text=b?"Move "+a.tagName+" to "+b:"Move "+a.tagName;this.oldNextSibling=p;this.oldParent=h;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,
2012-07-31 19:01:03 +00:00
this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,p){this.elem=a;this.text=p||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type=function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type=
svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
2012-07-31 19:01:03 +00:00
this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,p,h,b){this.elem=a;this.text=b||"Delete "+a.tagName;this.nextSibling=p;this.parent=h;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]};
2012-07-31 19:01:03 +00:00
svgedit.history.ChangeElementCommand=function(a,p,h){this.elem=a;this.text=h?"Change "+a.tagName+" "+h:"Change "+a.tagName;this.newValues={};this.oldValues=p;for(var b in p)this.newValues[b]=b=="#text"?a.textContent:b=="#href"?svgedit.utilities.getHref(a):a.getAttribute(b)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=
function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var p=false,h;for(h in this.newValues){if(this.newValues[h])if(h=="#text")this.elem.textContent=this.newValues[h];else h=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[h]):this.elem.setAttribute(h,this.newValues[h]);else if(h=="#text")this.elem.textContent="";else{this.elem.setAttribute(h,"");this.elem.removeAttribute(h)}if(h==
"transform")p=true}if(!p)if(p=svgedit.utilities.getRotationAngle(this.elem)){h=elem.getBBox();p=["rotate(",p," ",h.x+h.width/2,",",h.y+h.height/2,")"].join("");p!=elem.getAttribute("transform")&&elem.setAttribute("transform",p)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var p=false,h;for(h in this.oldValues){if(this.oldValues[h])if(h==
"#text")this.elem.textContent=this.oldValues[h];else h=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[h]):this.elem.setAttribute(h,this.oldValues[h]);else if(h=="#text")this.elem.textContent="";else this.elem.removeAttribute(h);if(h=="transform")p=true}if(!p)if(p=svgedit.utilities.getRotationAngle(this.elem)){h=this.elem.getBBox();p=["rotate(",p," ",h.x+h.width/2,",",h.y+h.height/2,")"].join("");p!=this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",p)}svgedit.transformlist.removeElementFromListMap(this.elem);
a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command";this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply=
2012-07-31 19:01:03 +00:00
function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);for(var p=this.stack.length,h=0;h<p;++h)this.stack[h].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 p=this.stack.length-1;p>=0;p--)this.stack[p].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,
this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],p=this.stack.length;p--;)for(var h=this.stack[p].elements(),b=h.length;b--;)a.indexOf(h[b])==-1&&a.push(h[b]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=
-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():
""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.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_)};
2012-07-31 19:01:03 +00:00
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,p){for(var h=++this.undoChangeStackPointer,b=p.length,o=Array(b),u=Array(b);b--;){var c=p[b];if(c!=null){u[b]=c;o[b]=c.getAttribute(a)}}this.undoableChangeStack[h]=
{attrName:a,oldValues:o,elements:u}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,p=this.undoableChangeStack[a],h=p.elements.length,b=p.attrName,o=new svgedit.history.BatchCommand("Change "+b);h--;){var u=p.elements[h];if(u!=null){var c={};c[b]=p.oldValues[h];c[b]!=u.getAttribute(b)&&o.addSubCommand(new svgedit.history.ChangeElementCommand(u,c,b))}}this.undoableChangeStack[a]=null;return o}})();svgedit=svgedit||{};
(function(){if(!svgedit.select)svgedit.select={};var a,p,h;svgedit.select.Selector=function(b,o){this.id=b;this.selectedElement=o;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));svgedit.browser.isTouch()&&this.selectorRect.setAttribute("stroke-opacity",
0.3);this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(b){this.locked=true;this.selectedElement=b;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(b){var o=[];b=Math.round(b/45);if(b<0)b+=8;for(var u in h.selectorGrips)o.push(u);for(;b>0;){o.push(o.shift());b--}b=0;for(u in h.selectorGrips){h.selectorGrips[u].setAttribute("style",
"cursor:"+o[b]+"-resize");b++}};svgedit.select.Selector.prototype.showGrips=function(b){h.selectorGripsGroup.setAttribute("display",b?"inline":"none");var o=this.selectedElement;this.hasGrips=b;if(o&&b){this.selectorGroup.appendChild(h.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(o))}};svgedit.select.Selector.prototype.resize=function(){var b=this.selectorRect,o=h,u=o.selectorGrips,c=this.selectedElement,f=c.getAttribute("stroke-width"),d=a.currentZoom(),l=1/d;if(c.getAttribute("stroke")!==
"none"&&!isNaN(f))l+=f/2;var v=c.tagName;if(v==="text")l+=2/d;f=svgedit.transformlist.getTransformList(c);f=svgedit.math.transformListToTransform(f).matrix;f.e*=d;f.f*=d;var B=svgedit.utilities.getBBox(c);if(v==="g"&&!$.data(c,"gsvg"))if(v=a.getStrokedBBox(c.childNodes))B=v;v=B.x;var q=B.y,K=B.width;B=B.height;l*=d;d=svgedit.math.transformBox(v*d,q*d,K*d,B*d,f);f=d.aabox;v=f.x-l;q=f.y-l;K=f.width+l*2;var S=f.height+l*2;f=v+K/2;B=q+S/2;if(c=svgedit.utilities.getRotationAngle(c)){v=a.svgRoot().createSVGTransform();
v.setRotate(-c,f,B);v=v.matrix;d.tl=svgedit.math.transformPoint(d.tl.x,d.tl.y,v);d.tr=svgedit.math.transformPoint(d.tr.x,d.tr.y,v);d.bl=svgedit.math.transformPoint(d.bl.x,d.bl.y,v);d.br=svgedit.math.transformPoint(d.br.x,d.br.y,v);v=d.tl;K=v.x;S=v.y;var O=v.x,H=v.y;v=Math.min;q=Math.max;K=v(K,v(d.tr.x,v(d.bl.x,d.br.x)))-l;S=v(S,v(d.tr.y,v(d.bl.y,d.br.y)))-l;O=q(O,q(d.tr.x,q(d.bl.x,d.br.x)))+l;H=q(H,q(d.tr.y,q(d.bl.y,d.br.y)))+l;v=K;q=S;K=O-K;S=H-S}l=a.svgRoot().suspendRedraw(100);b.setAttribute("d",
"M"+v+","+q+" L"+(v+K)+","+q+" "+(v+K)+","+(q+S)+" "+v+","+(q+S)+"z");this.selectorGroup.setAttribute("transform",c?"rotate("+[c,f,B].join(",")+")":"");if(svgedit.browser.isTouch()){v-=15.75;q-=15.75}else{v-=4;q-=4}this.gripCoords={nw:[v,q].map(Math.round),ne:[v+K,q].map(Math.round),sw:[v,q+S].map(Math.round),se:[v+K,q+S].map(Math.round),n:[v+K/2,q].map(Math.round),w:[v,q+S/2].map(Math.round),e:[v+K,q+S/2].map(Math.round),s:[v+K/2,q+S].map(Math.round)};for(var R in this.gripCoords){b=this.gripCoords[R];
u[R].setAttribute("x",b[0]);u[R].setAttribute("y",b[1])}this.rotateCoords={nw:[v,q],ne:[v+K+8,q],sw:[v,q+S+8],se:[v+K+8,q+S+8]};for(R in this.rotateCoords){b=this.rotateCoords[R];o.rotateGrips[R].setAttribute("cx",b[0]);o.rotateGrips[R].setAttribute("cy",b[1])}a.svgRoot().unsuspendRedraw(l)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};
2012-07-24 02:30:12 +00:00
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);
2012-07-31 19:01:03 +00:00
a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var b in this.rotateGrips){var o=a.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate_"+b,fill:"#000",r:8,stroke:"#000","fill-opacity":0,"stroke-opacity":0,"stroke-width":0,style:"cursor:url("+p.imgPath+"rotate.png) 12 12, auto;"}});$.data(o,"dir",b);$.data(o,"type","rotate");this.rotateGrips[b]=this.selectorGripsGroup.appendChild(o)}for(b in this.selectorGrips){o=a.createSVGElement({element:"rect",
attr:{id:"selectorGrip_resize_"+b,width:8,height:8,fill:"#4F80FF",stroke:"rgba(0,0,0,0)","stroke-width":1,style:"cursor:"+b+"-resize","pointer-events":"all"}});if(svgedit.browser.isTouch()){o.setAttribute("width",30.5);o.setAttribute("height",30.5);o.setAttribute("fill-opacity",0.3)}$.data(o,"dir",b);$.data(o,"type","resize");this.selectorGrips[b]=this.selectorGripsGroup.appendChild(o)}if(!$("#canvasBackground").length){b=p.dimensions;b=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",
width:b[0],height:b[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});o=a.createSVGElement({element:"defs",attr:{id:"placeholder_defs"}});var u=a.createSVGElement({element:"pattern",attr:{id:"checkerPattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:20,height:20,viewBox:"0 0 10 10"}}),c=a.createSVGElement({element:"rect",attr:{x:0,y:0,width:10,height:10,fill:"#fff"}}),f=a.createSVGElement({element:"rect",attr:{x:0,y:0,width:5,height:5,fill:"#eee"}}),
d=a.createSVGElement({element:"rect",attr:{x:5,y:5,width:5,height:5,fill:"#eee"}}),l=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"url(#checkerPattern)",style:"pointer-events:none"}});b.appendChild(o);o.appendChild(u);u.appendChild(c);u.appendChild(f);u.appendChild(d);b.appendChild(l);a.svgRoot().insertBefore(b,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(b){if(b==null)return null;var o=this.selectors.length;
if(typeof this.selectorMap[b.id]=="object"){this.selectorMap[b.id].locked=true;return this.selectorMap[b.id]}for(var u=0;u<o;++u)if(this.selectors[u]&&!this.selectors[u].locked){this.selectors[u].locked=true;this.selectors[u].reset(b);this.selectorMap[b.id]=this.selectors[u];return this.selectors[u]}this.selectors[o]=new svgedit.select.Selector(o,b);this.selectorParentGroup.appendChild(this.selectors[o].selectorGroup);this.selectorMap[b.id]=this.selectors[o];return this.selectors[o]};svgedit.select.SelectorManager.prototype.releaseSelector=
function(b){if(b!=null)for(var o=this.selectors.length,u=this.selectorMap[b.id],c=0;c<o;++c)if(this.selectors[c]&&this.selectors[c]==u){u.locked==false&&console.log("WARNING! selector was released but was already unlocked");delete this.selectorMap[b.id];u.locked=false;u.selectedElement=null;u.showGrips(false);try{u.selectorGroup.setAttribute("display","none")}catch(f){}break}};svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){if(!this.rubberBandBox)this.rubberBandBox=this.selectorParentGroup.appendChild(a.createSVGElement({element:"rect",
attr:{id:"selectorRubberBand",fill:"none",stroke:"#666","stroke-width":1,"stroke-dasharray":"3,2",display:"none",style:"pointer-events:none"}}));return this.rubberBandBox};svgedit.select.init=function(b,o){p=b;a=o;h=new svgedit.select.SelectorManager;a.createSVGElement({element:"g",attr:{id:"hover_group"}})};svgedit.select.getSelectorManager=function(){return h}})();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(","),p={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},h=p.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(b,o){this.name_=b;this.group_=o};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(b,o){h=b==false?p.NEVER_RANDOMIZE:
p.ALWAYS_RANDOMIZE;if(h==p.ALWAYS_RANDOMIZE&&!o.getNonce())o.setNonce(Math.floor(Math.random()*100001));else h==p.NEVER_RANDOMIZE&&o.getNonce()&&o.clearNonce()};svgedit.draw.Drawing=function(b,o){if(!b||!b.tagName||!b.namespaceURI||b.tagName!="svg"||b.namespaceURI!="http://www.w3.org/2000/svg")throw"Error: svgedit.draw.Drawing instance initialized without a <svg> element";this.svgElem_=b;this.obj_num=0;this.idPrefix=o||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
"";var u=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(u&&h!=p.NEVER_RANDOMIZE)this.nonce_=u;else h==p.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(b){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+b):$(this.svgElem_).find("[id="+b+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};
2012-07-27 23:32:02 +00:00
svgedit.draw.Drawing.prototype.setNonce=function(b){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",b);this.nonce_=b};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var b=
2012-07-31 19:01:03 +00:00
this.obj_num,o=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();o=true}else this.obj_num++;for(var u=this.getId();this.getElem_(u);){if(o){this.obj_num=b;o=false}this.obj_num++;u=this.getId()}if(o)this.obj_num=b;return u};svgedit.draw.Drawing.prototype.releaseId=function(b){var o=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof b!="string"||b.indexOf(o)!=0)return false;b=parseInt(b.substr(o.length));if(typeof b!="number"||b<=0||this.releasedNums.indexOf(b)!=-1)return false;
this.releasedNums.push(b);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(b){for(var o=0;o<this.getNumLayers();o++)if(this.all_layers[o][0]==b)return true;return false};svgedit.draw.Drawing.prototype.getLayerName=function(b){if(b>=0&&b<this.getNumLayers())return this.all_layers[b][0];return""};svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer};svgedit.draw.Drawing.prototype.getCurrentLayerName=
function(){for(var b=0;b<this.getNumLayers();++b)if(this.all_layers[b][1]==this.current_layer)return this.getLayerName(b);return""};svgedit.draw.Drawing.prototype.setCurrentLayer=function(b){for(var o=0;o<this.getNumLayers();++o)if(b==this.getLayerName(o)){if(this.current_layer!=this.all_layers[o][1]){this.current_layer.setAttribute("style","pointer-events:none");this.current_layer=this.all_layers[o][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 b=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return b}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var b=this.svgElem_.childNodes.length,o=[],u=[],c=null,f=false,d=0;d<b;++d){var l=this.svgElem_.childNodes.item(d);if(l&&l.nodeType==1)if(l.tagName=="g"){f=true;var v=$("title",l).text();if(!v&&svgedit.browser.isOpera()&&l.querySelectorAll)v=$(l.querySelectorAll("title")).text();
if(v){u.push(v);this.all_layers.push([v,l]);c=l;svgedit.utilities.walkTree(l,function(B){B.setAttribute("style","pointer-events:inherit")});c.setAttribute("style","pointer-events:none")}else o.push(l)}else if(~a.indexOf(l.nodeName)){svgedit.utilities.getBBox(l);o.push(l)}}b=this.svgElem_.ownerDocument;if(o.length>0||!f){for(d=1;u.indexOf("Layer "+d)>=0;)d++;u="Layer "+d;c=b.createElementNS("http://www.w3.org/2000/svg","g");f=b.createElementNS("http://www.w3.org/2000/svg","title");f.textContent=u;
c.appendChild(f);for(f=0;f<o.length;++f)c.appendChild(o[f]);this.svgElem_.appendChild(c);this.all_layers.push([u,c])}svgedit.utilities.walkTree(c,function(B){B.setAttribute("style","pointer-events:inherit")});this.current_layer=c;this.current_layer.setAttribute("style","pointer-events:all")};svgedit.draw.Drawing.prototype.createLayer=function(b){var o=this.svgElem_.ownerDocument,u=o.createElementNS("http://www.w3.org/2000/svg","g");o=o.createElementNS("http://www.w3.org/2000/svg","title");o.textContent=
b;u.appendChild(o);this.svgElem_.appendChild(u);this.identifyLayers();return u};svgedit.draw.Drawing.prototype.getLayerVisibility=function(b){for(var o=null,u=0;u<this.getNumLayers();++u)if(this.getLayerName(u)==b){o=this.all_layers[u][1];break}if(!o)return false;return o.getAttribute("display")!="none"};svgedit.draw.Drawing.prototype.setLayerVisibility=function(b,o){if(typeof o!="boolean")return null;for(var u=null,c=0;c<this.getNumLayers();++c)if(this.getLayerName(c)==b){u=this.all_layers[c][1];
break}if(!u)return null;u.getAttribute("display");u.setAttribute("display",o?"inline":"none");return u};svgedit.draw.Drawing.prototype.getLayerOpacity=function(b){for(var o=0;o<this.getNumLayers();++o)if(this.getLayerName(o)==b){(b=this.all_layers[o][1].getAttribute("opacity"))||(b="1.0");return parseFloat(b)}return null};svgedit.draw.Drawing.prototype.setLayerOpacity=function(b,o){if(!(typeof o!="number"||o<0||o>1))for(var u=0;u<this.getNumLayers();++u)if(this.getLayerName(u)==b){this.all_layers[u][1].setAttribute("opacity",
o);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"},p={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"]},h=[],b=true,o={};svgedit.path.setLinkControlPoints=function(f){b=f};var u=svgedit.path.path=null;svgedit.path.init=
function(f){u=f;h=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(d,l){h.push(l+"Abs");h.push(l+"Rel")})};svgedit.path.insertItemBefore=function(f,d,l){f=f.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())f.insertItemBefore(d,l);else{for(var v=f.numberOfItems,B=[],q=0;q<v;q++){var K=f.getItem(q);B.push(K)}f.clear();for(q=0;q<v;q++){q==l&&f.appendItem(d);f.appendItem(B[q])}}};
svgedit.path.ptObjToArr=function(f,d){for(var l=p[f],v=l.length,B=Array(v),q=0;q<v;q++)B[q]=d[l[q]];return B};svgedit.path.getGripPt=function(f,d){var l={x:d?d.x:f.item.x,y:d?d.y:f.item.y},v=f.path;if(v.matrix)l=svgedit.math.transformPoint(l.x,l.y,v.matrix);l.x*=u.getCurrentZoom();l.y*=u.getCurrentZoom();return l};svgedit.path.getPointFromGrip=function(f,d){var l={x:f.x,y:f.y};if(d.matrix){f=svgedit.math.transformPoint(l.x,l.y,d.imatrix);l.x=f.x;l.y=f.y}l.x/=u.getCurrentZoom();l.y/=u.getCurrentZoom();
return l};svgedit.path.addPointGrip=function(f,d,l){var v=svgedit.path.getGripContainer(),B=svgedit.utilities.getElem("pathpointgrip_"+f);if(!B){B=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(B,{id:"pathpointgrip_"+f,display:"none",width:svgedit.browser.isTouch()?30:5,height:svgedit.browser.isTouch()?30:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});
B=v.appendChild(B);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&l)svgedit.utilities.assignAttributes(B,{x:d-(svgedit.browser.isTouch()?15:2.5),y:l-(svgedit.browser.isTouch()?15:2.5),display:"inline"});return B};svgedit.path.getGripContainer=function(){var f=svgedit.utilities.getElem("pathpointgrip_container");if(!f){f=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));f.id=
2012-07-25 09:18:34 +00:00
"pathpointgrip_container"}return f};svgedit.path.addCtrlGrip=function(f){var d=svgedit.utilities.getElem("ctrlpointgrip_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(d,{id:"ctrlpointgrip_"+f,display:"none",r:svgedit.browser.isTouch()?15:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getCtrlLine=function(f){var d=
2012-07-31 19:01:03 +00:00
svgedit.utilities.getElem("ctrlLine_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(d,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getPointGrip=function(f,d){var l=svgedit.path.addPointGrip(f.index);if(d){var v=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(l,{x:v.x-(svgedit.browser.isTouch()?15:2.5),y:v.y-(svgedit.browser.isTouch()?
15:2.5),display:"inline"})}return l};svgedit.path.getControlPoints=function(f){var d=f.item,l=f.index;if(!("x1"in d)||!("x2"in d))return null;var v={};svgedit.path.getGripContainer();for(var B=[svgedit.path.path.segs[l-1].item,d],q=1;q<3;q++){var K=l+"c"+q,S=v["c"+q+"_line"]=svgedit.path.getCtrlLine(K),O=svgedit.path.getGripPt(f,{x:d["x"+q],y:d["y"+q]}),H=svgedit.path.getGripPt(f,{x:B[q-1].x,y:B[q-1].y});svgedit.utilities.assignAttributes(S,{x1:O.x,y1:O.y,x2:H.x,y2:H.y,display:"inline"});v["c"+q+
"_line"]=S;pointGrip=v["c"+q]=svgedit.path.addCtrlGrip(K);svgedit.utilities.assignAttributes(pointGrip,{cx:O.x,cy:O.y,display:"inline"});v["c"+q]=pointGrip}return v};svgedit.path.replacePathSeg=function(f,d,l,v){v=v||svgedit.path.path.elem;f=v["createSVGPathSeg"+h[f]].apply(v,l);if(svgedit.browser.supportsPathReplaceItem())v.pathSegList.replaceItem(f,d);else{l=v.pathSegList;v=l.numberOfItems;for(var B=[],q=0;q<v;q++){var K=l.getItem(q);B.push(K)}l.clear();for(q=0;q<v;q++)q==d?l.appendItem(f):l.appendItem(B[q])}};
svgedit.path.getSegSelector=function(f,d){var l=f.index,v=svgedit.utilities.getElem("segline_"+l);if(!v){var B=svgedit.path.getGripContainer();v=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(v,{id:"segline_"+l,display:"none",fill:"none",stroke:"#0ff","shape-rendering":"crispEdges","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});B.appendChild(v)}if(d){l=f.prev;if(!l){v.setAttribute("display","none");return v}l=svgedit.path.getGripPt(l);
svgedit.path.replacePathSeg(2,0,[l.x,l.y],v);B=svgedit.path.ptObjToArr(f.type,f.item,true);for(var q=0;q<B.length;q+=2){l=svgedit.path.getGripPt(f,{x:B[q],y:B[q+1]});B[q]=l.x;B[q+1]=l.y}svgedit.path.replacePathSeg(f.type,1,B,v)}return v};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,d,l){var v=f.x-l.x,B=f.y-l.y,q=d.x-l.x,K=d.y-l.y;if((v!=0||B!=0)&&(q!=0||K!=0)){f=Math.atan2(B,v);d=Math.atan2(K,q);v=Math.sqrt(v*v+B*B);q=Math.sqrt(q*q+K*K);B=u.getSVGRoot().createSVGPoint();K=
u.getSVGRoot().createSVGPoint();if(f<0)f+=2*Math.PI;if(d<0)d+=2*Math.PI;var S=Math.abs(f-d),O=Math.abs(Math.PI-S)/2;if(f-d>0){f=S<Math.PI?f+O:f-O;d=S<Math.PI?d-O:d+O}else{f=S<Math.PI?f-O:f+O;d=S<Math.PI?d+O:d-O}B.x=v*Math.cos(f)+l.x;B.y=v*Math.sin(f)+l.y;K.x=q*Math.cos(d)+l.x;K.y=q*Math.sin(d)+l.y;return[B,K]}};svgedit.path.Segment=function(f,d){this.selected=false;this.index=f;this.item=d;this.type=d.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=
2012-07-29 03:56:15 +00:00
function(f){for(var d in this.ctrlpts)this.ctrlpts[d].setAttribute("display",f?"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(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",
f?"#0FF":"#00F");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};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(f){if(this.ptgrip){var d=svgedit.path.getGripPt(this),l=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,
this.ptgrip.nodeName=="rect"?{x:d.x-l,y:d.y-l}:{cx:d.x,cy:d.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){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(f,d){var l=this.item;l=this.ctrlpts?[l.x+=f,l.y+=d,l.x1,l.y1,l.x2+=f,l.y2+=d]:[l.x+=f,l.y+=d];svgedit.path.replacePathSeg(this.type,this.index,l);if(this.next&&this.next.ctrlpts){l=this.next.item;
2012-07-31 19:01:03 +00:00
l=[l.x,l.y,l.x1+=f,l.y1+=d,l.x2,l.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,l)}if(this.mate){l=this.mate.item;l=[l.x+=f,l.y+=d];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(f){var d,l,v;if(f==2){l=1;d=this.next;if(!d)return;v=this.item}else{l=2;d=this.prev;if(!d)return;v=d.item}var B=d.item;B["x"+l]=v.x+(v.x-this.item["x"+f]);B["y"+l]=v.y+(v.y-this.item["y"+
f]);svgedit.path.replacePathSeg(d.type,d.index,[B.x,B.y,B.x1,B.y1,B.x2,B.y2]);d.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,d,l){var v=this.item;v["x"+f]+=d;v["y"+f]+=l;svgedit.path.replacePathSeg(this.type,this.index,[v.x,v.y,v.x1,v.y1,v.x2,v.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);
this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l<d;l++){var v=f.getItem(l);v=new svgedit.path.Segment(l,v);
v.path=this;this.segs.push(v)}f=this.segs;v=null;for(l=0;l<d;l++){var B=f[l],q=l+1>=d?null:f[l+1],K=l-1<0?null:f[l-1];if(B.type===2){if(K&&K.type!==1){q=f[v];q.next=f[v+1];q.next.prev=q;q.addGrip()}v=l}else if(q&&q.type===1){B.next=f[v+1];B.next.prev=B;B.mate=f[v];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(q){if(B.type!==1){B.addGrip();if(q&&q.type!==2){B.next=q;B.next.prev=B}}}else if(B.type!==1){q=f[v];q.next=f[v+1];q.next.prev=q;q.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=
f[v]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=this.segs.length,l=0;l<d;l++)if(f.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var l=d.prev,v;switch(d.item.pathSegType){case 4:var B=(d.item.x+l.item.x)/2,q=(d.item.y+l.item.y)/2;v=this.elem.createSVGPathSegLinetoAbs(B,q);break;case 6:v=(l.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,S=(d.item.x2+d.item.x)/2,O=(v+K)/2;K=(K+S)/2;B=(O+K)/2;var H=(l.item.y+
d.item.y1)/2,R=(d.item.y1+d.item.y2)/2;l=(d.item.y2+d.item.y)/2;var U=(H+R)/2;R=(R+l)/2;q=(U+R)/2;v=this.elem.createSVGPathSegCurvetoCubicAbs(B,q,v,H,O,U);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,K,R,S,l])}svgedit.path.insertItemBefore(this.elem,v,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],l=this.elem.pathSegList;d.show(false);var v=d.next;if(d.mate){var B=[v.item.x,v.item.y];svgedit.path.replacePathSeg(2,v.index,B);svgedit.path.replacePathSeg(4,d.index,
B);l.removeItem(d.mate.index)}else{if(!d.prev){B=[v.item.x,v.item.y];svgedit.path.replacePathSeg(2,d.next.index,B)}l.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(l){if(l<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,
2012-07-29 03:56:15 +00:00
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(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var l=this.selected_pts.length;l--;)this.segs[this.selected_pts[l]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=
2012-07-31 19:01:03 +00:00
function(f,d){var l=this.segs[this.selected_pts[0]];l.moveCtrl(this.dragctrl,f,d);b&&l.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,l;d--;){var v=this.segs[this.selected_pts[d]],B=v.prev;if(B){if(!f){l="Toggle Path Segment Type";f=v.type==6?4:6}f-=0;var q=v.item.x,K=v.item.y,S=B.item.x;B=B.item.y;var O;switch(f){case 6:if(v.olditem){S=v.olditem;O=[q,K,S.x1,S.y1,S.x2,S.y2]}else{O=q-S;var H=K-B;O=[q,K,S+O/3,B+H/3,q-O/3,
K-H/3]}break;case 4:O=[q,K];v.olditem=v.item}v.setType(f,O)}}svgedit.path.path.endChanges(l)};svgedit.path.Path.prototype.selectPt=function(f,d){this.clearSelection();f==null&&this.eachSeg(function(l){if(this.prev)f=l});this.addPtsToSelection(f);if(d){this.dragctrl=d;b&&this.segs[f].setLinked(d)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=
null;this.eachSeg(function(d){this.item=f.pathSegList.getItem(d);this.update()});return this};svgedit.path.getPath_=function(f){var d=o[f.id];d||(d=o[f.id]=new svgedit.path.Path(f));return d};svgedit.path.removePath_=function(f){f in o&&delete o[f]};var c=function(f,d){dx=f-oldcx;dy=d-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;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 f=svgedit.path.path.elem,d=svgedit.utilities.getRotationAngle(f,true);if(d){var l=svgedit.utilities.getBBox(f),v=svgedit.path.path.oldbbox,B=v.x+v.width/2,q=v.y+v.height/2;v=l.x+l.width/2;l=l.y+l.height/2;v=v-B;var K=l-q;l=Math.sqrt(v*v+K*K);K=Math.atan2(K,v)+d;v=l*Math.cos(K)+B;l=l*Math.sin(K)+q;B=f.pathSegList;for(q=B.numberOfItems;q;){q-=1;K=B.getItem(q);var S=K.pathSegType;if(S!=1){var O=c(K.x,K.y);O=[O.x,O.y];
if(K.x1!=null&&K.x2!=null){c_vals1=c(K.x1,K.y1);c_vals2=c(K.x2,K.y2);O.splice(O.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(S,q,O)}}svgedit.utilities.getBBox(f);B=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);B.setRotate(d*180/Math.PI,v,l);f.replaceItem(B,0)}};svgedit.path.clearData=function(){o={}}})();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(p,h){var b=this.length;if(!b)return a.apply(this,arguments);for(var o=0;o<b;o++){var u=this[o];if(u.namespaceURI==="http://www.w3.org/2000/svg")if(h!==undefined)u.setAttribute(p,h);else if($.isArray(p)){b=p.length;for(o={};b--;){var c=p[b],f=u.getAttribute(c);if(f||f==="0")f=isNaN(f)?f:f-0;o[c]=f}return o}else if(typeof p==="object")for(c in p)u.setAttribute(c,p[c]);else{if((f=u.getAttribute(p))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,
arguments)}return this}})();
2012-07-31 19:01:03 +00:00
$.SvgCanvas=function(a,p){function h(e,k){for(var m=svgedit.utilities.getBBox(e),C=0;C<2;C++){var z=C===0?"fill":"stroke",G=e.getAttribute(z);if(G&&G.indexOf("url(")===0){G=P(G);if(G.tagName==="linearGradient"){var D=G.getAttribute("x1")||0,w=G.getAttribute("y1")||0,E=G.getAttribute("x2")||1,I=G.getAttribute("y2")||0;D=m.width*D+m.x;w=m.height*w+m.y;E=m.width*E+m.x;I=m.height*I+m.y;D=M(D,w,k);I=M(E,I,k);E={};E.x1=(D.x-m.x)/m.width;E.y1=(D.y-m.y)/m.height;E.x2=(I.x-m.x)/m.width;E.y2=(I.y-m.y)/m.height;
G=G.cloneNode(true);$(G).attr(E);G.id=ka();ib().appendChild(G);e.setAttribute(z,"url(#"+G.id+")")}}}}var b="http://www.w3.org/2000/svg",o={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};p&&$.extend(o,p);var u=o.dimensions,c=this,f=a.ownerDocument,d=f.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+b+'" xlinkns="http://www.w3.org/1999/xlink" width="'+u[0]+'" height="'+u[1]+'" x="'+u[0]+'" y="'+u[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(d);var l=f.createElementNS(b,"svg");(c.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:u[0],height:u[1],x:u[0],y:u[1],overflow:o.show_outside_canvas?"visible":"hidden",xmlns:b,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(d);var e=f.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var v="svg_";c.setIdPrefix=
function(e){v=e};c.current_drawing_=new svgedit.draw.Drawing(l,v);var B=c.getCurrentDrawing=function(){return c.current_drawing_},q=1,K=null,S={shape:{fill:(o.initFill.color=="none"?"":"#")+o.initFill.color,fill_paint:null,fill_opacity:o.initFill.opacity,stroke:"#"+o.initStroke.color,stroke_paint:null,stroke_opacity:o.initStroke.opacity,stroke_width:o.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:o.initOpacity}};S.text=$.extend(true,{},S.shape);$.extend(S.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=S.shape,H=Array(1),R=this.addSvgElementFromJson=function(e){var k=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(k&&e.element!=k.tagName){m.removeChild(k);k=null}if(!k){k=f.createElementNS(b,e.element);if(m)(K||m).appendChild(k)}e.curStyles&&svgedit.utilities.assignAttributes(k,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,
"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(k,e.attr,100);svgedit.utilities.cleanupElement(k);return k},U=c.getTransformList=svgedit.transformlist.getTransformList,M=svgedit.math.transformPoint,ga=c.matrixMultiply=svgedit.math.matrixMultiply,oa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,ea=c.transformListToTransform=svgedit.math.transformListToTransform,
Q=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return o.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/q},getWidth:function(){return l.getAttribute("width")/q},getRoundDigits:function(){return cb.round_digits}});var xa=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return H},
getSVGContent:function(){return l}});var ja=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,ca=c.getHref=svgedit.utilities.getHref,V=c.setHref=svgedit.utilities.setHref,W=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var na=c.getRotationAngle=svgedit.utilities.getRotationAngle,qa=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,la=this.cleanupElement=svgedit.utilities.cleanupElement,za=svgedit.sanitize.getNSMap(),Ga=c.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
Aa=svgedit.history.MoveElementCommand,Ha=svgedit.history.InsertElementCommand,Ja=svgedit.history.RemoveElementCommand,Ia=svgedit.history.ChangeElementCommand,Da=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,k){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)c.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var C=k.elements();c.pathActions.clear();N("changed",C);C=k.type();m=e==m.AFTER_APPLY;if(C==
Aa.type()){m=m?k.newParent:k.oldParent;m==l&&c.identifyLayers()}else if(C==Ha.type()||C==Ja.type()){k.parent==l&&c.identifyLayers();if(C==Ha.type())m&&Va(k.elem);else m||Va(k.elem);k.elem.tagName==="use"&&yb(k.elem)}else if(C==Ia.type()){k.elem.tagName=="title"&&k.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?k.newValues:k.oldValues;m.stdDeviation&&c.setBlurOffsets(k.elem.parentNode,m.stdDeviation);if(k.elem.tagName==="use"&&svgedit.browser.isWebkit()){C=k.elem;if(!C.getAttribute("x")&&!C.getAttribute("y")){m=
C.parentNode;var z=C.nextSibling;m.removeChild(C);m.insertBefore(C,z)}}}}}});var ya=function(e){c.undoMgr.addCommandToHistory(e)};svgedit.select.init(o,{createSVGElement:function(e){return c.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return q},getStrokedBBox:function(e){return c.getStrokedBBox([e])}});var Fa=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return q},getSVGRoot:function(){return d}});
svgedit.utilities.snapToGrid=function(e){var k=o.snappingStep,m=o.baseUnit;if(m!=="px")k*=svgedit.units.getTypeMap()[m];return e=Math.round(e/k)*k};var wa=svgedit.utilities.snapToGrid,Ua={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"],eb=$.data,
Va=function(e){var k=$(e).attr(tb),m;for(m in k){var C=k[m];if(C&&C.indexOf("url(")===0){C=ja(C).substr(1);if(!qa(C)){ib().appendChild(sb[C]);delete sb[C]}}}e=e.getElementsByTagName("*");if(e.length){k=0;for(m=e.length;k<m;k++)Va(e[k])}},Wa={},Ba=o.imgPath+"logo.png",va=[],cb={round_digits:5},Ka=false,Ta=null,Ca="select",gb="none",pb={},Xa=S.text,Ya=O,ub=null,ta=null,jb=[],fb={},sb={};c.clipBoard=[];var kb=this.runExtensions=function(e,k,m){var C=false;if(m)C=[];$.each(fb,function(z,G){if(e in G)if(m)C.push(G[e](k));
else C=G[e](k)});return C};this.addExtension=function(e,k){if(e in fb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var m=$.isFunction(k)?k($.extend(c.getPrivateMethods(),{svgroot:d,svgcontent:l,nonce:B().getNonce(),selectorManager:Fa})):k;fb[e]=m;N("extension_added",m)}};var db=this.round=function(e){return parseInt(e*q)/q},mb=this.getIntersectionList=function(e){if(ta==null)return null;var k=K||B().getCurrentLayer();jb.length||(jb=vb(k));var m=null;
try{m=k.getIntersectionList(e,null)}catch(C){}if(m==null||typeof m.item!="function"){m=[];if(e)e=e;else{e=ta.getBBox();k={};for(var z in e)k[z]=e[z]/q;e=k}for(z=jb.length;z--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,jb[z].bbox)&&m.push(jb[z].elem)}return m};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=qb());if(!e.length)return false;var k=function(I){try{var g=svgedit.utilities.getBBox(I),n=svgedit.utilities.getRotationAngle(I);if(n&&n%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(I))){n=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(I.tagName)>=0)g=n=c.convertToPath(I,true);else if(I.tagName=="rect"){var s=I.getAttribute("rx"),A=I.getAttribute("ry");if(s||A)g=n=c.convertToPath(I,true)}if(!n){var F=I.cloneNode(true),J=document.createElementNS(b,"g"),L=I.parentNode;L.appendChild(J);J.appendChild(F);g=svgedit.utilities.bboxToObj(J.getBBox());L.removeChild(J)}}return g}catch(Z){console.log(I,Z);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=k(this)});
if(m==null)return null;var C=m.x+m.width,z=m.y+m.height,G=m.x,D=m.y,w=function(I){var g=I.getAttribute("stroke-width"),n=0;if(I.getAttribute("stroke")!="none"&&!isNaN(g))n+=g/2;return n},E=[];$.each(e,function(I,g){var n=k(g);if(n){var s=w(g);G=Math.min(G,n.x-s);D=Math.min(D,n.y-s);E.push(n)}});m.x=G;m.y=D;$.each(e,function(I,g){var n=E[I];if(n&&g.nodeType==1){var s=w(g);C=Math.max(C,n.x+n.width+s);z=Math.max(z,n.y+n.height+s)}});m.width=C-G;m.height=z-D;return m};var qb=this.getVisibleElements=function(e){e||
(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var k=[];$(e).children().each(function(m,C){try{C.getBBox()&&k.push(C)}catch(z){}});return k.reverse()},vb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var k=[];$(e).children().each(function(m,C){try{C.getBBox()&&k.push({elem:C,bbox:getStrokedBBox([C])})}catch(z){}});return k.reverse()},wb=this.groupSvgElem=function(e){var k=document.createElementNS(b,"g");e.parentNode.replaceChild(k,e);$(k).append(e).data("gsvg",
e)[0].id=ka()},ia=function(e){var k=document.createElementNS(e.namespaceURI,e.nodeName);k.removeAttribute("id");$.each(e.attributes,function(C,z){z.localName!="-moz-math-font-style"&&k.setAttributeNS(z.namespaceURI,z.nodeName,z.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=La.convertPath(e);k.setAttribute("d",m)}$.each(e.childNodes,function(C,z){switch(z.nodeType){case 1:k.appendChild(ia(z));break;case 3:k.textContent=z.nodeValue}});if($(e).data("gsvg"))$(k).data("gsvg",k.firstChild);
else if($(e).data("symbol")){e=$(e).data("symbol");$(k).data("ref",e).data("symbol",e)}else k.tagName=="image"&&Db(k);k.id=ka();return k},aa,ka,N;(function(e){var k={};aa=e.getId=function(){return B().getId()};ka=e.getNextId=function(){return B().getNextId()};N=e.call=function(m,C){if(k[m])return k[m](this,C)};e.bind=function(m,C){var z=k[m];k[m]=C;return z}})(c);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(b,"path");for(var k=0,m=e.length;k<m;++k){var C=
e[k];C.setAttribute("d",La.convertPath(C));La.fixEnd(C)}};var P=this.getRefElem=function(e){return qa(ja(e).substr(1))},da=function(e){if(!svgedit.browser.isGecko())return e;var k=e.cloneNode(true);e.parentNode.insertBefore(k,e);e.parentNode.removeChild(e);Fa.releaseSelector(e);H[0]=k;Fa.requestSelector(k).showGrips(true);return k};this.setRotationAngle=function(e,k){e=parseFloat(e);var m=H[0],C=m.getAttribute("transform"),z=svgedit.utilities.getBBox(m),G=z.x+z.width/2,D=z.y+z.height/2;z=U(m);z.numberOfItems>
0&&z.getItem(0).type==4&&z.removeItem(0);if(e!=0){G=M(G,D,ea(z).matrix);D=d.createSVGTransform();D.setRotate(e,G.x,G.y);z.numberOfItems?z.insertItemBefore(D,0):z.appendItem(D)}else z.numberOfItems==0&&m.removeAttribute("transform");if(!k){z=m.getAttribute("transform");m.setAttribute("transform",C);hb("transform",z,H);N("changed",H)}qa("pathpointgrip_container");m=Fa.requestSelector(H[0]);m.resize();m.updateGripCursors(e)};var Ea=this.recalculateAllSelectedDimensions=function(){for(var e=new Da(gb==
"none"?"position":"size"),k=H.length;k--;){var m=Sa(H[k]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",H)}},Na=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ra=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},bb=this.remapElement=function(e,k,m){var C=o.gridSnapping&&e.parentNode.parentNode.localName==="svg",z=function(){if(C)for(var n in k)k[n]=wa(k[n]);ma(e,k,1E3,true)};box=svgedit.utilities.getBBox(e);for(var G=0;G<2;G++){var D=G===0?"fill":"stroke",
w=e.getAttribute(D);if(w&&w.indexOf("url(")===0)if(m.a<0||m.d<0){w=P(w).cloneNode(true);if(m.a<0){var E=w.getAttribute("x1"),I=w.getAttribute("x2");w.setAttribute("x1",-(E-1));w.setAttribute("x2",-(I-1))}if(m.d<0){E=w.getAttribute("y1");I=w.getAttribute("y2");w.setAttribute("y1",-(E-1));w.setAttribute("y2",-(I-1))}w.id=ka();ib().appendChild(w);e.setAttribute(D,"url(#"+w.id+")")}}G=e.tagName;if(G==="g"||G==="text"||G==="use")if(m.a==1&&m.b==0&&m.c==0&&m.d==1&&(m.e!=0||m.f!=0)){D=ea(e).matrix;D=ga(D.inverse(),
m,D);k.x=parseFloat(k.x)+D.e;k.y=parseFloat(k.y)+D.f}else{D=U(e);w=d.createSVGTransform();w.setMatrix(ga(ea(D).matrix,m));D.clear();D.appendItem(w)}switch(G){case "foreignObject":case "rect":case "image":if(G==="image"&&(m.a<0||m.d<0)){D=U(e);w=d.createSVGTransform();w.setMatrix(ga(ea(D).matrix,m));D.clear();D.appendItem(w)}else{D=M(k.x,k.y,m);k.width=m.a*k.width;k.height=m.d*k.height;k.x=D.x+Math.min(0,k.width);k.y=D.y+Math.min(0,k.height);k.width=Math.abs(k.width);k.height=Math.abs(k.height)}z();
break;case "ellipse":G=M(k.cx,k.cy,m);k.cx=G.x;k.cy=G.y;k.rx=m.a*k.rx;k.ry=m.d*k.ry;k.rx=Math.abs(k.rx);k.ry=Math.abs(k.ry);z();break;case "circle":G=M(k.cx,k.cy,m);k.cx=G.x;k.cy=G.y;G=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);k.r=Math.min((G.tr.x-G.tl.x)/2,(G.bl.y-G.tl.y)/2);if(k.r)k.r=Math.abs(k.r);z();break;case "line":D=M(k.x1,k.y1,m);E=M(k.x2,k.y2,m);k.x1=D.x;k.y1=D.y;k.x2=E.x;k.y2=E.y;case "text":m=e.querySelectorAll("tspan");for(G=m.length;G--;){D=xa("x",e.getAttribute("x"));
w=xa("x",m[G].getAttribute("x"));E=xa("y",e.getAttribute("y"));I=xa("y",m[G].getAttribute("y"));var g={};if(!isNaN(D)&&!isNaN(w)&&D!=0&&w!=0&&k.x)g.x=k.x-(D-w);if(!isNaN(E)&&!isNaN(I)&&E!=0&&I!=0&&k.y)g.y=k.y-(E-I);if(g.x||g.y)ma(m[G],g,1E3,true)}z();break;case "use":z();break;case "g":(z=$(e).data("gsvg"))&&ma(z,k,1E3,true);break;case "polyline":case "polygon":z=k.points.length;for(G=0;G<z;++G){I=k.points[G];I=M(I.x,I.y,m);k.points[G].x=I.x;k.points[G].y=I.y}z=k.points.length;m="";for(G=0;G<z;++G){I=
k.points[G];m+=I.x+","+I.y+" "}e.setAttribute("points",m);break;case "path":D=e.pathSegList;z=D.numberOfItems;k.d=Array(z);for(G=0;G<z;++G){w=D.getItem(G);k.d[G]={type:w.pathSegType,x:w.x,y:w.y,x1:w.x1,y1:w.y1,x2:w.x2,y2:w.y2,r1:w.r1,r2:w.r2,angle:w.angle,largeArcFlag:w.largeArcFlag,sweepFlag:w.sweepFlag}}z=k.d.length;G=k.d[0];g=M(G.x,G.y,m);k.d[0].x=g.x;k.d[0].y=g.y;for(G=1;G<z;++G){w=k.d[G];D=w.type;if(D%2==0){I=M(w.x!=undefined?w.x:g.x,w.y!=undefined?w.y:g.y,m);D=M(w.x1,w.y1,m);E=M(w.x2,w.y2,m);
w.x=I.x;w.y=I.y;w.x1=D.x;w.y1=D.y;w.x2=E.x;w.y2=E.y}else{w.x=m.a*w.x;w.y=m.d*w.y;w.x1=m.a*w.x1;w.y1=m.d*w.y1;w.x2=m.a*w.x2;w.y2=m.d*w.y2}w.r1=m.a*w.r1;w.r2=m.d*w.r2}m="";z=k.d.length;for(G=0;G<z;++G){w=k.d[G];D=w.type;m+=Na[D];switch(D){case 13:case 12:m+=w.x+" ";break;case 15:case 14:m+=w.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:m+=w.x+","+w.y+" ";break;case 7:case 6:m+=w.x1+","+w.y1+" "+w.x2+","+w.y2+" "+w.x+","+w.y+" ";break;case 9:case 8:m+=w.x1+","+w.y1+" "+w.x+","+w.y+" ";break;
case 11:case 10:m+=w.r1+","+w.r2+" "+w.angle+" "+ +w.largeArcFlag+" "+ +w.sweepFlag+" "+w.x+","+w.y+" ";break;case 17:case 16:m+=w.x2+","+w.y2+" "+w.x+","+w.y+" "}}e.setAttribute("d",m)}},ob=function(e,k,m){e=P(e).firstChild;var C=U(e),z=d.createSVGTransform();z.setTranslate(k,m);C.appendItem(z);Sa(e)},Sa=this.recalculateDimensions=function(e){if(e==null)return null;var k=U(e);if(k&&k.numberOfItems>0){for(var m=k.numberOfItems;m--;){var C=k.getItem(m);if(C.type===0)k.removeItem(m);else if(C.type===
1)svgedit.math.isIdentity(C.matrix)&&k.removeItem(m);else C.type===4&&C.angle===0&&k.removeItem(m)}if(k.numberOfItems===1&&na(e))return null}if(!k||k.numberOfItems==0){e.removeAttribute("transform");return null}if(k){m=k.numberOfItems;for(var z=[];m--;){C=k.getItem(m);if(C.type===1)z.push([C.matrix,m]);else if(z.length)z=[]}if(z.length===2){m=d.createSVGTransformFromMatrix(ga(z[1][0],z[0][0]));k.removeItem(z[0][1]);k.removeItem(z[1][1]);k.insertItemBefore(m,z[1][1])}m=k.numberOfItems;if(m>=2&&k.getItem(m-
2).type===1&&k.getItem(m-1).type===2){z=d.createSVGTransform();C=ga(k.getItem(m-2).matrix,k.getItem(m-1).matrix);z.setMatrix(C);k.removeItem(m-2);k.removeItem(m-2);k.appendItem(z)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(k.numberOfItems===1&&k.getItem(0).type===1||k.numberOfItems===2&&k.getItem(0).type===1&&k.getItem(0).type===4)return null}var G=$(e).data("gsvg");m=new Da("Transform");var D={},w=null;C=[];switch(e.tagName){case "line":C=["x1","y1",
"x2","y2"];break;case "circle":C=["cx","cy","r"];break;case "ellipse":C=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":C=["width","height","x","y"];break;case "use":case "text":case "tspan":C=["x","y"];break;case "polygon":case "polyline":w={};w.points=e.getAttribute("points");z=e.points;var E=z.numberOfItems;D.points=Array(E);for(var I=0;I<E;++I){var g=z.getItem(I);D.points[I]={x:g.x,y:g.y}}break;case "path":w={};w.d=e.getAttribute("d");D.d=e.getAttribute("d")}if(C.length){D=
$(e).attr(C);$.each(D,function(sa,ra){D[sa]=xa(sa,ra)})}else if(G)D={x:$(G).attr("x")||0,y:$(G).attr("y")||0};if(w==null){w=$.extend(true,{},D);$.each(w,function(sa,ra){w[sa]=xa(sa,ra)})}w.transform=Ta?Ta:"";if(e.tagName=="g"&&!G||e.tagName=="a"){z=svgedit.utilities.getBBox(e);var n={x:z.x+z.width/2,y:z.y+z.height/2},s=M(z.x+z.width/2,z.y+z.height/2,ea(k).matrix);C=d.createSVGMatrix();if(z=na(e)){I=z*Math.PI/180;E=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<k.numberOfItems;++I){C=
k.getItem(I);if(C.type==4){C=C.matrix;n.y=(E*C.e+C.f)/2;n.x=(C.e-E*C.f)/2;k.removeItem(I);break}}}I=C=G=0;var A=k.numberOfItems;if(A)var F=k.getItem(0).matrix;if(A>=3&&k.getItem(A-2).type==3&&k.getItem(A-3).type==2&&k.getItem(A-1).type==2){I=3;var J=k.getItem(A-3).matrix,L=k.getItem(A-2).matrix,Z=k.getItem(A-1).matrix;E=e.childNodes;for(g=E.length;g--;){var ba=E.item(g);C=G=0;if(ba.nodeType==1){var T=U(ba);if(T){C=ea(T).matrix;G=na(ba);var X=Ta,ha=[];Ta=ba.getAttribute("transform");if(G||oa(T)){var pa=
d.createSVGTransform();pa.setMatrix(ga(J,L,Z,C));T.clear();T.appendItem(pa);ha.push(pa)}else{G=ga(C.inverse(),Z,C);pa=d.createSVGMatrix();pa.e=-G.e;pa.f=-G.f;C=ga(pa.inverse(),C.inverse(),J,L,Z,C,G.inverse());var fa=d.createSVGTransform(),ua=d.createSVGTransform(),Ma=d.createSVGTransform();fa.setTranslate(G.e,G.f);ua.setScale(C.a,C.d);Ma.setTranslate(pa.e,pa.f);T.appendItem(Ma);T.appendItem(ua);T.appendItem(fa);ha.push(Ma);ha.push(ua);ha.push(fa)}m.addSubCommand(Sa(ba));Ta=X}}}k.removeItem(A-1);k.removeItem(A-
2);k.removeItem(A-3)}else if(A>=3&&k.getItem(A-1).type==1){I=3;C=ea(k).matrix;pa=d.createSVGTransform();pa.setMatrix(C);k.clear();k.appendItem(pa)}else if((A==1||A>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){I=2;G=ea(k).matrix;k.removeItem(0);C=ea(k).matrix.inverse();C=ga(C,G);G=C.e;C=C.f;if(G!=0||C!=0){E=e.childNodes;g=E.length;for(A=[];g--;){ba=E.item(g);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){X=ba.getAttribute("clip-path");if(A.indexOf(X)===-1){ob(X,G,C);A.push(X)}}X=Ta;Ta=ba.getAttribute("transform");
if(T=U(ba)){J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,0):T.appendItem(J);m.addSubCommand(Sa(ba));T=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(J=T.length;J--;){L=T.item(J);if(ba==ca(L)){Z=d.createSVGTransform();Z.setTranslate(-G,-C);U(L).insertItemBefore(Z,0);m.addSubCommand(Sa(L))}}Ta=X}}}A=[];Ta=X}}else if(A==1&&k.getItem(0).type==1&&!z){I=1;C=k.getItem(0).matrix;E=e.childNodes;for(g=E.length;g--;){ba=E.item(g);if(ba.nodeType==1){X=Ta;Ta=ba.getAttribute("transform");
if(T=U(ba)){G=ga(C,ea(T).matrix);A=d.createSVGTransform();A.setMatrix(G);T.clear();T.appendItem(A,0);m.addSubCommand(Sa(ba));Ta=X;X=ba.getAttribute("stroke-width");ba.getAttribute("stroke")!=="none"&&!isNaN(X)&&ba.setAttribute("stroke-width",X*((Math.abs(G.a)+Math.abs(G.d))/2))}}}k.clear()}else{if(z){n=d.createSVGTransform();n.setRotate(z,s.x,s.y);k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(z){s={x:n.x+F.e,y:n.y+
F.f};n=d.createSVGTransform();n.setRotate(z,s.x,s.y);k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}}else if(I==3){C=ea(k).matrix;F=d.createSVGTransform();F.setRotate(z,n.x,n.y);F=F.matrix;n=d.createSVGTransform();n.setRotate(z,s.x,s.y);s=n.matrix.inverse();X=C.inverse();s=ga(X,s,F,C);G=s.e;C=s.f;if(G!=0||C!=0){E=e.childNodes;for(g=E.length;g--;){ba=E.item(g);if(ba.nodeType==1){X=Ta;Ta=ba.getAttribute("transform");T=U(ba);J=d.createSVGTransform();J.setTranslate(G,C);T.numberOfItems?T.insertItemBefore(J,
0):T.appendItem(J);m.addSubCommand(Sa(ba));Ta=X}}}if(z)k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}}else{z=svgedit.utilities.getBBox(e);if(!z&&e.tagName!="path")return null;C=d.createSVGMatrix();if(G=na(e)){n={x:z.x+z.width/2,y:z.y+z.height/2};s=M(z.x+z.width/2,z.y+z.height/2,ea(k).matrix);I=G*Math.PI/180;E=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<k.numberOfItems;++I){C=k.getItem(I);if(C.type==4){C=C.matrix;n.y=(E*C.e+C.f)/2;n.x=(C.e-E*C.f)/2;k.removeItem(I);break}}}I=
0;A=k.numberOfItems;if(!svgedit.browser.isWebkit())if((F=e.getAttribute("fill"))&&F.indexOf("url(")===0){F=P(F);X="pattern";if(F.tagName!==X)X="gradient";if(F.getAttribute(X+"Units")==="userSpaceOnUse"){C=ea(k).matrix;z=U(F);z=ea(z).matrix;C=ga(C,z);z="matrix("+[C.a,C.b,C.c,C.d,C.e,C.f].join(",")+")";F.setAttribute(X+"Transform",z)}}if(A>=3&&k.getItem(A-2).type==3&&k.getItem(A-3).type==2&&k.getItem(A-1).type==2){I=3;C=ea(k,A-3,A-1).matrix;k.removeItem(A-1);k.removeItem(A-2);k.removeItem(A-3)}else if(A==
4&&k.getItem(A-1).type==1){I=3;C=ea(k).matrix;pa=d.createSVGTransform();pa.setMatrix(C);k.clear();k.appendItem(pa);C=d.createSVGMatrix()}else if((A==1||A>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){I=2;F=k.getItem(0).matrix;X=ea(k,1).matrix;z=X.inverse();C=ga(z,F,X);k.removeItem(0)}else if(A==1&&k.getItem(0).type==1&&!G){C=ea(k).matrix;switch(e.tagName){case "line":D=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":D.points=e.getAttribute("points");if(D.points){z=e.points;E=z.numberOfItems;
D.points=Array(E);for(I=0;I<E;++I){g=z.getItem(I);D.points[I]={x:g.x,y:g.y}}}case "path":D.d=e.getAttribute("d");I=1;k.clear()}}else{I=4;if(G){n=d.createSVGTransform();n.setRotate(G,s.x,s.y);k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)bb(e,D,C);if(I==2){if(G){oa(k)||(s={x:n.x+C.e,y:n.y+C.f});n=d.createSVGTransform();n.setRotate(G,s.x,s.y);k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}}else if(I==
3&&G){C=ea(k).matrix;F=d.createSVGTransform();F.setRotate(G,n.x,n.y);F=F.matrix;n=d.createSVGTransform();n.setRotate(G,s.x,s.y);s=n.matrix.inverse();X=C.inverse();s=ga(X,s,F,C);bb(e,D,s);if(G)k.numberOfItems?k.insertItemBefore(n,0):k.appendItem(n)}}k.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Ia(e,w));return m},nb=null,Pa=this.clearSelection=function(e){if(H[0]!=null)for(var k=H.length,m=0;m<k;++m){var C=H[m];if(C==null)break;Fa.releaseSelector(C);H[m]=null}e||N("selected",
H)},rb=this.addToSelection=function(e,k){if(e.length!=0){for(var m=0;m<H.length;){if(H[m]==null)break;++m}for(var C=e.length;C--;){var z=e[C];if(z&&svgedit.utilities.getBBox(z)){if(z.tagName==="a"&&z.childNodes.length===1)z=z.firstChild;if(H.indexOf(z)==-1){H[m]=z;m++;z=Fa.requestSelector(z);H.length>1&&z.showGrips(false)}}}N("selected",H);k||H.length==1?Fa.requestSelector(H[0]).showGrips(true):Fa.requestSelector(H[0]).showGrips(false);for(H.sort(function(G,D){if(G&&D&&G.compareDocumentPosition)return 3-
(D.compareDocumentPosition(G)&6);else if(G==null)return 1});H[0]==null;)H.shift(0)}},$a=this.selectOnly=function(e,k){Pa(true);rb(e,k)};this.removeFromSelection=function(e){if(H[0]!=null)if(e.length!=0){var k=Array(H.length);j=0;len=H.length;for(var m=0;m<len;++m){var C=H[m];if(C)if(e.indexOf(C)==-1){k[j]=C;j++}else Fa.releaseSelector(C)}H=k}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ca="select";$a($(K||e).children())}};var Eb=this.getMouseTarget=function(e){if(e==
null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var k=B().getCurrentLayer();if([d,a,l,k].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Fa.selectorParentGroup;for(;e.parentNode!==(K||k);)e=e.parentNode;return e};(function(){var e=null,k=null,m=null,C=
null,z=null,G={},D={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(w){if(!(w.originalEvent.touches&&w.originalEvent.touches>1)){var E=w.button===2;nb=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var I=M(w.pageX,w.pageY,nb),g=I.x*(isBotchedZoom?1:q);I=I.y*(isBotchedZoom?1:q);w.preventDefault();if(E)Ca="select";g=g/q;I=I/q;var n=Eb(w);if(n.tagName==="a"&&n.childNodes.length===1)n=n.firstChild;var s=C=k=g,A=z=m=I;if(o.gridSnapping){g=wa(g);I=wa(I);k=wa(k);m=wa(m)}if(n==
Fa.selectorParentGroup&&H[0]!=null){n=w.target;var F=eb(n,"type");if(F=="rotate"){Ca="rotate";current_rotate_mode=eb(n,"dir")}else if(F=="resize"){Ca="resize";gb=eb(n,"dir")}n=H[0]}Ta=n.getAttribute("transform");F=U(n);switch(Ca){case "select":Ka=true;gb="none";if(E)Ka=false;if(n!=d){if(H.indexOf(n)==-1){w.shiftKey||Pa(true);rb([n]);ub=n;La.clear()}if(!E)for(E=0;E<H.length;++E)if(H[E]!=null){var J=U(H[E]);J.numberOfItems?J.insertItemBefore(d.createSVGTransform(),0):J.appendItem(d.createSVGTransform())}}else if(!E){Pa();
Ca="multiselect";if(ta==null)ta=Fa.getRubberBandBox();C*=q;z*=q;ma(ta,{x:C,y:z,width:0,height:0,display:"inline"},100)}break;case "zoom":Ka=true;if(ta==null)ta=Fa.getRubberBandBox();ma(ta,{x:s*q,y:s*q,width:0,height:0,display:"inline"},100);break;case "resize":Ka=true;k=g;m=I;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var L={};$.each(G,function(Z,ba){L[Z]=ba/q});G=L;E=na(n)?1:0;if(oa(F)){F.insertItemBefore(d.createSVGTransform(),E);F.insertItemBefore(d.createSVGTransform(),E);F.insertItemBefore(d.createSVGTransform(),
E)}else{F.appendItem(d.createSVGTransform());F.appendItem(d.createSVGTransform());F.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(g=svgedit.browser.isChrome())J=function(Z){var ba=Z.getAttributeNS(null,"stroke");Z.removeAttributeNS(null,"stroke");setTimeout(function(){Z.setAttributeNS(null,"stroke",ba)},1)};n.style.vectorEffect="non-scaling-stroke";g&&J(n);I=n.getElementsByTagName("*");s=I.length;for(E=0;E<s;E++){I[E].style.vectorEffect="non-scaling-stroke";
g&&J(I[E])}}}break;case "fhellipse":case "fhrect":case "fhpath":Ka=true;e=s+","+A+" ";J=O.stroke_width==0?1:O.stroke_width;R({element:"polyline",curStyles:true,attr:{points:e,id:ka(),fill:"none",opacity:O.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});D.minx=s;D.maxx=s;D.miny=A;D.maxy=A;break;case "image":Ka=true;J=R({element:"image",attr:{x:g,y:I,width:0,height:0,id:ka(),opacity:O.opacity/2,style:"pointer-events:inherit"}});V(J,Ba);Db(J);break;case "square":case "rect":Ka=true;
k=g;m=I;R({element:"rect",curStyles:true,attr:{x:g,y:I,width:0,height:0,id:ka(),opacity:O.opacity/2}});break;case "line":Ka=true;J=O.stroke_width==0?1:O.stroke_width;R({element:"line",curStyles:true,attr:{x1:g,y1:I,x2:g,y2:I,id:ka(),stroke:O.stroke,"stroke-width":J,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,fill:"none",opacity:O.opacity/2,style:"pointer-events:none"}});break;case "circle":Ka=true;R({element:"circle",
curStyles:true,attr:{cx:g,cy:I,r:0,id:ka(),opacity:O.opacity/2}});break;case "ellipse":Ka=true;R({element:"ellipse",curStyles:true,attr:{cx:g,cy:I,rx:0,ry:0,id:ka(),opacity:O.opacity/2}});break;case "text":Ka=true;R({element:"text",curStyles:true,attr:{x:g,y:I,id:ka(),fill:Xa.fill,"stroke-width":Xa.stroke_width,"font-size":Xa.font_size,"font-family":Xa.font_family,"text-anchor":"left","xml:space":"preserve",opacity:O.opacity}});break;case "path":case "pathedit":k*=q;m*=q;La.mouseDown(w,n,k,m);Ka=
true;break;case "textedit":k*=q;m*=q;ab.mouseDown(w,n,k,m);Ka=true;break;case "rotate":Ka=true;c.undoMgr.beginUndoableChange("transform",H);document.getElementById("workarea").className="rotate"}J=kb("mouseDown",{event:w,start_x:k,start_y:m,selectedElements:H},true);$.each(J,function(Z,ba){if(ba&&ba.started)Ka=true});if(Ca)document.getElementById("workarea").className=Ca=="resize"?w.target.style.cursor:Ca}}).mousemove(function(w){if(!(w.originalEvent.touches&&w.originalEvent.touches.length>1))if(Ka)if(!(w.button===
1||c.spaceKey)){var E=H[0],I=M(w.pageX,w.pageY,nb),g=I.x*(isBotchedZoom?1:q);I=I.y*(isBotchedZoom?1:q);var n=qa(aa()),s=x=g/q,A=y=I/q;if(o.gridSnapping){x=wa(x);y=wa(y)}w.preventDefault();switch(Ca){case "select":if(H[0]!==null){s=x-k;var F=y-m;if(o.gridSnapping){s=wa(s);F=wa(F)}if(w.shiftKey){var J=Q(k,m,x,y);x=J.x;y=J.y}if(s!=0||F!=0){J=H.length;for(A=0;A<J;++A){E=H[A];if(E==null)break;var L=d.createSVGTransform();n=U(E);L.setTranslate(s,F);n.numberOfItems?n.replaceItem(L,0):n.appendItem(L);Fa.requestSelector(E).resize()}if(w.altKey)if(!c.addClones){c.addClones=
c.cloneSelectedElements(0,0,L);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(ua){ua.parentNode&&ua.parentNode.removeChild(ua);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}N("transition",H)}}break;case "multiselect":s*=q;A*=q;ma(ta,{x:Math.min(C,s),y:Math.min(z,A),width:Math.abs(s-C),height:Math.abs(A-z)},100);n=[];s=[];L=mb();J=H.length;for(A=0;A<J;++A){F=L.indexOf(H[A]);if(F==-1)n.push(H[A]);else L[F]=null}J=L.length;for(A=0;A<J;++A)L[A]&&s.push(L[A]);
n.length>0&&c.removeFromSelection(n);s.length>0&&rb(s);break;case "resize":n=U(E);s=(L=oa(n))?G:svgedit.utilities.getBBox(E);J=s.x;A=s.y;var Z=s.width,ba=s.height;s=x-k;F=y-m;if(o.gridSnapping){s=wa(s);F=wa(F);ba=wa(ba);Z=wa(Z)}var T=na(E);if(T){var X=Math.sqrt(s*s+F*F);F=Math.atan2(F,s)-T*Math.PI/180;s=X*Math.cos(F);F=X*Math.sin(F)}if(gb.indexOf("n")==-1&&gb.indexOf("s")==-1)F=0;if(gb.indexOf("e")==-1&&gb.indexOf("w")==-1)s=0;var ha=X=0,pa=ba?(ba+F)/ba:1,fa=Z?(Z+s)/Z:1;if(gb.indexOf("n")>=0){pa=
ba?(ba-F)/ba:1;ha=ba}if(gb.indexOf("w")>=0){fa=Z?(Z-s)/Z:1;X=Z}s=d.createSVGTransform();F=d.createSVGTransform();Z=d.createSVGTransform();if(o.gridSnapping){J=wa(J);X=wa(X);A=wa(A);ha=wa(ha)}s.setTranslate(-(J+X),-(A+ha));if(w.shiftKey)if(fa==1)fa=pa;else pa=fa;F.setScale(fa,pa);Z.setTranslate(J+X,A+ha);if(L){L=T?1:0;n.replaceItem(s,2+L);n.replaceItem(F,1+L);n.replaceItem(Z,0+L)}else{L=n.numberOfItems;n.replaceItem(Z,L-3);n.replaceItem(F,L-2);n.replaceItem(s,L-1)}Fa.requestSelector(E).resize();N("transition",
H);break;case "zoom":s*=q;A*=q;ma(ta,{x:Math.min(C*q,s),y:Math.min(z*q,A),width:Math.abs(s-C*q),height:Math.abs(A-z*q)},100);break;case "text":ma(n,{x:x,y:y},1E3);break;case "line":s=null;window.opera||d.suspendRedraw(1E3);if(o.gridSnapping){x=wa(x);y=wa(y)}L=x;J=y;if(w.shiftKey){J=Q(k,m,L,J);L=J.x;J=J.y}n.setAttributeNS(null,"x2",L);n.setAttributeNS(null,"y2",J);window.opera||d.unsuspendRedraw(s);break;case "foreignObject":case "square":case "rect":case "image":s=Math.abs(x-k);L=Math.abs(y-m);if(Ca==
"square"||w.shiftKey){s=L=Math.max(s,L);J=k<x?k:k-s;A=m<y?m:m-L}else{J=Math.min(k,x);A=Math.min(m,y)}if(w.altKey){s*=2;L*=2;J=k-s/2;A=m-L/2}if(o.gridSnapping){s=wa(s);L=wa(L);J=wa(J);A=wa(A)}ma(n,{width:s,height:L,x:J,y:A},1E3);break;case "circle":s=$(n).attr(["cx","cy"]);L=s.cx;J=s.cy;s=Math.sqrt((x-L)*(x-L)+(y-J)*(y-J));if(o.gridSnapping)s=wa(s);n.setAttributeNS(null,"r",s);break;case "ellipse":s=$(n).attr(["cx","cy"]);L=Math.abs(k+(x-k)/2);J=Math.abs(m+(y-m)/2);s=null;window.opera||d.suspendRedraw(1E3);
if(o.gridSnapping){x=wa(x);L=wa(L);y=wa(y);J=wa(J)}A=Math.abs(k-L);F=Math.abs(m-J);if(w.shiftKey){F=A;J=y>m?m+A:m-A}if(w.altKey){L=k;J=m;A=Math.abs(x-L);F=w.shiftKey?A:Math.abs(y-J)}n.setAttributeNS(null,"rx",A);n.setAttributeNS(null,"ry",F);n.setAttributeNS(null,"cx",L);n.setAttributeNS(null,"cy",J);window.opera||d.unsuspendRedraw(s);break;case "fhellipse":case "fhrect":D.minx=Math.min(s,D.minx);D.maxx=Math.max(s,D.maxx);D.miny=Math.min(A,D.miny);D.maxy=Math.max(A,D.maxy);case "fhpath":e+=+s+","+
A+" ";n.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=q;y*=q;if(o.gridSnapping){x=wa(x);y=wa(y);k=wa(k);m=wa(m)}if(w.shiftKey){if(L=svgedit.path.path){n=L.dragging?L.dragging[0]:k;L=L.dragging?L.dragging[1]:m}else{n=k;L=m}J=Q(n,L,x,y);x=J.x;y=J.y}if(ta&&ta.getAttribute("display")!=="none"){s*=q;A*=q;ma(ta,{x:Math.min(C*q,s),y:Math.min(z*q,A),width:Math.abs(s-C*q),height:Math.abs(A-z*q)},100)}La.mouseMove(w,x,y);break;case "textedit":x*=q;y*=q;ab.mouseMove(g,I);break;case "rotate":s=
svgedit.utilities.getBBox(E);L=s.x+s.width/2;J=s.y+s.height/2;n=Y(E);n=M(L,J,n);L=n.x;J=n.y;n=s.x;A=s.y;if(current_rotate_mode=="nw")n=s.x+s.width;if(current_rotate_mode=="se")A=s.y+s.height;if(current_rotate_mode=="sw"){n=s.x+s.width;A=s.y+s.height}compensation_angle=(Math.atan2(J-A,L-n)*(180/Math.PI)-90)%360;T=(Math.atan2(J-y,L-x)*(180/Math.PI)-90)%360;T+=compensation_angle;if(o.gridSnapping)T=wa(T);if(w.shiftKey)T=Math.round(T/45)*45;c.setRotationAngle(T<-180?360+T:T,true);N("transition",H)}kb("mouseMove",
{event:w,mouse_x:g,mouse_y:I,selected:E})}}).click(function(w){w.preventDefault();return false}).dblclick(function(w){var E=w.target.parentNode;if(E!==K){var I=Eb(w),g=I.tagName;if(g==="text"&&Ca!=="textedit"){w=M(w.pageX,w.pageY,nb);ab.select(I,w.x,w.y)}if((g==="g"||g==="a")&&na(I)){Fb(I);I=H[0];Pa(true)}K&&Gb();E.tagName!=="g"&&E.tagName!=="a"||E===B().getCurrentLayer()||I===Fa.selectorParentGroup||Jb(I)}}).mouseup(function(w){c.addClones=false;window.removeEventListener("keyup",c.removeClones);
H=H.filter(Boolean);if(w.button!==2){var E=ub;ub=null;if(Ka){var I=M(w.pageX,w.pageY,nb),g=I.x*q;I=I.y*q;var n=g/q,s=I/q,A=qa(aa()),F=false;Ka=false;switch(Ca){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");jb=[]}Ca="select";case "select":if(H[0]!=null){if(H.length==1){g=H[0];switch(g.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Ya.fill=g.getAttribute("fill");Ya.fill_opacity=g.getAttribute("fill-opacity");Ya.stroke=g.getAttribute("stroke");
Ya.stroke_opacity=g.getAttribute("stroke-opacity");Ya.stroke_width=g.getAttribute("stroke-width");Ya.stroke_dasharray=g.getAttribute("stroke-dasharray");Ya.stroke_linejoin=g.getAttribute("stroke-linejoin");Ya.stroke_linecap=g.getAttribute("stroke-linecap")}if(g.tagName=="text"){Xa.font_size=g.getAttribute("font-size");Xa.font_family=g.getAttribute("font-family")}Fa.requestSelector(g).showGrips(true)}Ea();if(n!=C||s!=z){w=H.length;for(g=0;g<w;++g){if(H[g]==null)break;H[g].firstChild||Fa.requestSelector(H[g]).resize()}}else{g=
w.target;if(H[0].nodeName==="path"&&H[1]==null)La.select(H[0]);else w.shiftKey&&E!=g&&c.removeFromSelection([g])}if(svgedit.browser.supportsNonScalingStroke())if(w=H[0]){w.removeAttribute("style");svgedit.utilities.walkTree(w,function(Z){Z.removeAttribute("style")})}}return;case "zoom":ta!=null&&ta.setAttribute("display","none");N("zoomed",{x:Math.min(C,n),y:Math.min(z,s),width:Math.abs(n-C),height:Math.abs(s-z),factor:w.altKey?0.5:2});return;case "fhpath":E=A.getAttribute("points");n=E.indexOf(",");
if(F=n>=0?E.indexOf(",",n+1)>=0:E.indexOf(" ",E.indexOf(" ")+1)>=0)A=La.smoothPolylineIntoPath(A);break;case "line":E=$(A).attr(["x1","x2","y1","y2"]);F=E.x1!=E.x2||E.y1!=E.y2;break;case "foreignObject":case "square":case "rect":case "image":E=$(A).attr(["width","height"]);F=E.width!=0||E.height!=0||Ca==="image";break;case "circle":F=A.getAttribute("r")!=0;break;case "ellipse":E=$(A).attr(["rx","ry"]);F=E.rx!=null||E.ry!=null;break;case "fhellipse":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){A=R({element:"ellipse",
curStyles:true,attr:{cx:(D.minx+D.maxx)/2,cy:(D.miny+D.maxy)/2,rx:(D.maxx-D.minx)/2,ry:(D.maxy-D.miny)/2,id:aa()}});N("changed",[A]);F=true}break;case "fhrect":if(D.maxx-D.minx>0&&D.maxy-D.miny>0){A=R({element:"rect",curStyles:true,attr:{x:D.minx,y:D.miny,width:D.maxx-D.minx,height:D.maxy-D.miny,id:aa()}});N("changed",[A]);F=true}break;case "text":F=true;$a([A]);ab.start(A);break;case "path":A=null;Ka=true;E=La.mouseUp(w,A,g,I);A=E.element;F=E.keep;break;case "pathedit":F=true;A=null;La.mouseUp(w);
break;case "textedit":F=false;A=null;ab.mouseUp(w,g,I);break;case "rotate":F=true;A=null;Ca="select";E=c.undoMgr.finishUndoableChange();E.isEmpty()||ya(E);Ea();N("changed",H)}g=kb("mouseUp",{event:w,mouse_x:g,mouse_y:I},true);$.each(g,function(Z,ba){if(ba){F=ba.keep||F;A=ba.element;Ka=ba.started||Ka}});if(!F&&A!=null){B().releaseId(aa());A.parentNode.removeChild(A);A=null;for(g=w.target;g.parentNode.parentNode.tagName=="g";)g=g.parentNode;if((Ca!="path"||!drawn_path)&&g.parentNode.id!="selectorParentGroup"&&
g.id!="svgcanvas"&&g.id!="svgroot"){c.setMode("select");$a([g],true)}}else if(A!=null){c.addedNew=true;w=0.2;var J;if(false.beginElement&&A.getAttribute("opacity")!=O.opacity){J=$(false).clone().attr({to:O.opacity,dur:w}).appendTo(A);try{J[0].beginElement()}catch(L){}}else w=0;setTimeout(function(){J&&J.remove();A.setAttribute("opacity",O.opacity);A.setAttribute("style","pointer-events:inherit");la(A);if(Ca==="path")La.toEditMode(A);else o.selectNew&&$a([A],true);ya(new Ha(A));N("changed",[A])},w*
1E3)}Ta=null}}});$(a).bind("mousewheel DOMMouseScroll",function(w){if(w.shiftKey){w.preventDefault();nb=l.getScreenCTM().inverse();var E=M(w.pageX,w.pageY,nb);E={x:E.x,y:E.y,width:0,height:0};if(w.wheelDelta)if(w.wheelDelta>=120)E.factor=2;else{if(w.wheelDelta<=-120)E.factor=0.5}else if(w.detail)if(w.detail>0)E.factor=0.5;else if(w.detail<0)E.factor=2;E.factor&&N("zoomed",E)}})})();var Db=function(e){$(e).click(function(k){k.preventDefault()})},ab=c.textActions=function(){function e(T){var X=I.value===
"";$(I).focus();if(!arguments.length)if(X)T=0;else{if(I.selectionEnd!==I.selectionStart)return;T=I.selectionEnd}var ha;ha=A[T];X||I.setSelectionRange(T,T);g=qa("text_cursor");if(!g){g=document.createElementNS(b,"line");ma(g,{id:"text_cursor",stroke:"#333","stroke-width":1});g=qa("selectorParentGroup").appendChild(g)}s||(s=setInterval(function(){var pa=g.getAttribute("display")==="none";g.setAttribute("display",pa?"inline":"none")},600));X=G(ha.x,F.y);ha=G(ha.x,F.y+F.height);ma(g,{x1:X.x,y1:X.y,x2:ha.x,
y2:ha.y,visibility:"visible",display:"inline"});n&&n.setAttribute("d","")}function k(T,X,ha){if(T===X)e(X);else{ha||I.setSelectionRange(T,X);n=qa("text_selectblock");if(!n){n=document.createElementNS(b,"path");ma(n,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(n)}T=A[T];var pa=A[X];g.setAttribute("visibility","hidden");X=G(T.x,F.y);ha=G(T.x+(pa.x-T.x),F.y);var fa=G(T.x,F.y+F.height);T=G(T.x+(pa.x-T.x),F.y+F.height);ma(n,{d:"M"+
X.x+","+X.y+" L"+ha.x+","+ha.y+" "+T.x+","+T.y+" "+fa.x+","+fa.y+"z",display:"inline"})}}function m(T,X){var ha=d.createSVGPoint();ha.x=T;ha.y=X;if(A.length==1)return 0;ha=E.getCharNumAtPosition(ha);if(ha<0){ha=A.length-2;if(T<=A[0].x)ha=0}else if(ha>=A.length-2)ha=A.length-2;var pa=A[ha];T>pa.x+pa.width/2&&ha++;return ha}function C(T,X,ha){var pa=I.selectionStart;T=m(T,X);k(Math.min(pa,T),Math.max(pa,T),!ha)}function z(T,X){var ha={x:T,y:X};ha.x/=q;ha.y/=q;if(J){var pa=M(ha.x,ha.y,J.inverse());ha.x=
pa.x;ha.y=pa.y}return ha}function G(T,X){var ha={x:T,y:X};if(J){var pa=M(ha.x,ha.y,J);ha.x=pa.x;ha.y=pa.y}ha.x*=q;ha.y*=q;return ha}function D(T){k(0,E.textContent.length);$(this).unbind(T)}function w(T){if(ba&&E){var X=M(T.pageX,T.pageY,nb);X=z(X.x*q,X.y*q);X=m(X.x,X.y);var ha=E.textContent,pa=ha.substr(0,X).replace(/[a-z0-9]+$/i,"").length;ha=ha.substr(X).match(/^[a-z0-9]+/i);k(pa,(ha?ha[0].length:0)+X);$(T.target).click(D);setTimeout(function(){$(T.target).unbind("click",D)},300)}}var E,I,g,n,
s,A=[],F,J,L,Z,ba;return{select:function(T,X,ha){E=T;ab.toEditMode(X,ha)},start:function(T){E=T;ab.toEditMode()},mouseDown:function(T,X,ha,pa){T=z(ha,pa);I.focus();e(m(T.x,T.y));L=ha;Z=pa},mouseMove:function(T,X){var ha=z(T,X);C(ha.x,ha.y)},mouseUp:function(T,X,ha){var pa=z(X,ha);C(pa.x,pa.y,true);T.target!==E&&X<L+2&&X>L-2&&ha<Z+2&&ha>Z-2&&ab.toSelectMode(true)},setCursor:e,toEditMode:function(T,X){$a([E],false);ba=false;Ca="textedit";Fa.requestSelector(E).showGrips(false);Fa.requestSelector(E);
ab.init();$(E).css("cursor","text");if(arguments.length){var ha=z(T,X);e(m(ha.x,ha.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(T){Ca="select";clearInterval(s);s=null;n&&$(n).attr("display","none");g&&$(g).attr("visibility","hidden");$(E).css("cursor","move");if(T){Pa();$(E).css("cursor","move");N("selected",[E]);rb([E],true)}E&&!E.textContent.length&&c.deleteSelectedElements();$(I).blur();E=false},setInputElem:function(T){I=T},clear:function(){Ca=="textedit"&&ab.toSelectMode()},
init:function(){if(E){if(!E.parentNode){E=H[0];Fa.requestSelector(E).showGrips(false)}var T=E.textContent.length,X=E.getAttribute("transform");F=svgedit.utilities.getBBox(E);J=X?Y(E):null;A=Array(T);I.focus();$(E).unbind("dblclick",w).dblclick(w);if(!T)var ha={x:F.x+F.width/2,width:0};for(X=0;X<T;X++){var pa=E.getStartPositionOfChar(X);ha=E.getEndPositionOfChar(X);if(!svgedit.browser.supportsGoodTextCharPos()){var fa=c.contentW*q;pa.x-=fa;ha.x-=fa;pa.x/=q;ha.x/=q}A[X]={x:pa.x,y:F.y,width:ha.x-pa.x,
height:F.height}}A.push({x:ha.x,width:0});k(I.selectionStart,I.selectionEnd,true)}}}}(),La=c.pathActions=function(){var e=false,k,m,C;svgedit.path.Path.prototype.endChanges=function(D){if(svgedit.browser.isWebkit()){var w=this.elem;w.setAttribute("d",La.convertPath(w))}D=new Ia(this.elem,{d:this.last_d},D);ya(D);N("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(D){$.isArray(D)||(D=[D]);for(var w=0;w<D.length;w++){var E=D[w],I=this.segs[E];I.ptgrip&&this.selected_pts.indexOf(E)==
-1&&E>=0&&this.selected_pts.push(E)}this.selected_pts.sort();w=this.selected_pts.length;for(D=Array(w);w--;){I=this.segs[this.selected_pts[w]];I.select(true);D[w]=I.ptgrip}La.canDeleteNodes=true;La.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",D)};var z=k=null,G=false;return{mouseDown:function(D,w,E,I){if(Ca==="path"){mouse_x=E;mouse_y=I;I=mouse_x/q;w=mouse_y/q;E=qa("path_stretch_line");m=[I,w];if(o.gridSnapping){I=wa(I);w=wa(w);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!E){E=
document.createElementNS(b,"path");ma(E,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});E=qa("selectorParentGroup").appendChild(E)}E.setAttribute("display","inline");var g=null;if(z){g=z.pathSegList;for(var n=g.numberOfItems,s=6/q,A=false;n;){n--;var F=g.getItem(n),J=F.x;F=F.y;if(I>=J-s&&I<=J+s&&w>=F-s&&w<=F+s){A=true;break}}s=aa();svgedit.path.removePath_(s);s=qa(s);J=g.numberOfItems;if(A){if(n<=1&&J>=2){I=g.getItem(0).x;w=g.getItem(0).y;D=E.pathSegList.getItem(1);D=D.pathSegType===
4?z.createSVGPathSegLinetoAbs(I,w):z.createSVGPathSegCurvetoCubicAbs(I,w,D.x1/q,D.y1/q,I,w);I=z.createSVGPathSegClosePath();g.appendItem(D);g.appendItem(I)}else if(J<3)return g=false;$(E).remove();element=s;z=null;Ka=false;if(e){svgedit.path.path.matrix&&bb(s,{},svgedit.path.path.matrix.inverse());E=s.getAttribute("d");D=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",D+E);$(s).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();La.toEditMode(svgedit.path.path.elem);
svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Eb(D))){console.log("Clicked outside canvas");return false}g=z.pathSegList.numberOfItems;n=z.pathSegList.getItem(g-1);s=n.x;n=n.y;if(D.shiftKey){D=Q(s,n,I,w);I=D.x;w=D.y}D=E.pathSegList.getItem(1);D=D.pathSegType===4?z.createSVGPathSegLinetoAbs(db(I),db(w)):z.createSVGPathSegCurvetoCubicAbs(db(I),db(w),D.x1/q,D.y1/q,D.x2/q,D.y2/q);z.pathSegList.appendItem(D);I*=q;w*=q;E.setAttribute("d",["M",I,w,I,w].join(" "));E=g;if(e)E+=svgedit.path.path.segs.length;
svgedit.path.addPointGrip(E,I,w)}}else{d_attr="M"+I+","+w+" ";z=R({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:O.opacity/2}});E.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));E=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(E,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();s=D.target.id;if(s.substr(0,14)=="pathpointgrip_"){w=svgedit.path.path.cur_pt=parseInt(s.substr(14));svgedit.path.path.dragging=[E,I];g=svgedit.path.path.segs[w];
if(D.shiftKey)g.selected?svgedit.path.path.removePtFromSelection(w):svgedit.path.path.addPtsToSelection(w);else{if(svgedit.path.path.selected_pts.length<=1||!g.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(w)}}else if(s.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[E,I];D=s.split("_")[1].split("c");w=D[0]-0;svgedit.path.path.selectPt(w,D[1]-0)}if(!svgedit.path.path.dragging){if(ta==null)ta=Fa.getRubberBandBox();ma(ta,{x:E*q,y:I*q,width:0,height:0,display:"inline"},
100)}}},mouseMove:function(D,w,E){G=true;if(Ca==="path"){if(z){var I=z.pathSegList;D=I.numberOfItems-1;if(m){var g=svgedit.path.addCtrlGrip("1c1"),n=svgedit.path.addCtrlGrip("0c2");n.getAttribute("cx");n.getAttribute("cy");g.setAttribute("cx",w);g.setAttribute("cy",E);g.setAttribute("display","inline");g=m[0];var s=m[1];I.getItem(D);var A=g+(g-w/q),F=s+(s-E/q);n.setAttribute("cx",A*q);n.setAttribute("cy",F*q);n.setAttribute("display","inline");n=svgedit.path.getCtrlLine(1);var J=svgedit.path.getCtrlLine(2);
ma(n,{x1:w,y1:E,x2:g*q,y2:s*q,display:"inline"});ma(J,{x1:A*q,y1:F*q,x2:g*q,y2:s*q,display:"inline"});if(D===0)C=[w,E];else{I=I.getItem(D-1);w=I.x;E=I.y;if(I.pathSegType===6){w+=w-I.x2;E+=E-I.y2}else if(C){w=C[0]/q;E=C[1]/q}svgedit.path.replacePathSeg(6,D,[g,s,w,E,A,F],z)}}else if(g=qa("path_stretch_line")){D=I.getItem(D);if(D.pathSegType===6)svgedit.path.replacePathSeg(6,1,[w,E,(D.x+(D.x-D.x2))*q,(D.y+(D.y-D.y2))*q,w,E],g);else C?svgedit.path.replacePathSeg(6,1,[w,E,C[0],C[1],w,E],g):svgedit.path.replacePathSeg(4,
1,[w,E],g)}}}else if(svgedit.path.path.dragging){g=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);s=svgedit.path.getPointFromGrip({x:w,y:E},svgedit.path.path);D=s.x-g.x;g=s.y-g.y;svgedit.path.path.dragging=[w,E];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(D,g):svgedit.path.path.movePts(D,g)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var L=ta.getBBox(),Z=svgedit.path.getGripPt(this);
L=svgedit.math.rectsIntersect(L,{x:Z.x,y:Z.y,width:0,height:0});this.select(L);L&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(D,w){if(Ca==="path"){m=null;if(!z){w=qa(aa());Ka=false;C=null}return{keep:true,element:w}}if(svgedit.path.path.dragging){var E=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)");!D.shiftKey&&!G&&svgedit.path.path.selectPt(E)}else if(ta&&
ta.getAttribute("display")!="none"){ta.setAttribute("display","none");ta.getAttribute("width")<=2&&ta.getAttribute("height")<=2&&La.toSelectMode(D.target)}else La.toSelectMode(D.target);G=false},toEditMode:function(D){svgedit.path.path=svgedit.path.getPath_(D);Ca="pathedit";Pa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(D){var w=D==svgedit.path.path.elem;Ca="select";svgedit.path.path.show(false);
k=false;Pa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(w){N("selected",[D]);rb([D],true)}},addSubPath:function(D){if(D){Ca="path";e=true}else{La.clear(true);La.toEditMode(svgedit.path.path.elem)}},select:function(D){if(k===D){La.toEditMode(D);Ca="pathedit"}else k=D},reorient:function(){var D=H[0];if(D)if(na(D)!=0){var w=new Da("Reorient path"),E={d:D.getAttribute("d"),transform:D.getAttribute("transform")};w.addSubCommand(new Ia(D,E));Pa();this.resetOrientation(D);ya(w);svgedit.path.getPath_(D).show(false).matrix=
null;this.clear();rb([D],true);N("changed",H)}},clear:function(){k=null;if(z){var D=qa(aa());$(qa("path_stretch_line")).remove();$(D).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");z=C=null;Ka=false}else Ca=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(D){if(D==null||D.nodeName!="path")return false;var w=U(D),E=ea(w).matrix;w.clear();D.removeAttribute("transform");w=D.pathSegList;for(var I=w.numberOfItems,
g=0;g<I;++g){var n=w.getItem(g),s=n.pathSegType;if(s!=1){var A=[];$.each(["",1,2],function(F,J){var L=n["x"+J],Z=n["y"+J];if(L!==undefined&&Z!==undefined){L=M(L,Z,E);A.splice(A.length,0,L.x,L.y)}});svgedit.path.replacePathSeg(s,g,A,D)}}h(D,E)},zoomChange:function(){Ca=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var D=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:D.item.x,y:D.item.y,type:D.type}},linkControlPoints:function(D){svgedit.path.setLinkControlPoints(D)},
clonePathNode:function(){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,w=D.length,E=[];w--;){var I=D[w];svgedit.path.path.addSeg(I);E.push(I+w);E.push(I+w+1)}svgedit.path.path.init().addPtsToSelection(E);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var D=svgedit.path.path.selected_pts;if(D.length===1){var w=svgedit.path.path.elem,E=w.pathSegList,I=D[0],g=null,n=null;svgedit.path.path.eachSeg(function(J){if(this.type===2&&J<=I)n=this.item;if(J<=
I)return true;if(this.type===2){g=J;return false}else if(this.type===1)return g=false});if(g==null)g=svgedit.path.path.segs.length-1;if(g!==false){var s=w.createSVGPathSegLinetoAbs(n.x,n.y),A=w.createSVGPathSegClosePath();if(g==svgedit.path.path.segs.length-1){E.appendItem(s);E.appendItem(A)}else{svgedit.path.insertItemBefore(w,A,g);svgedit.path.insertItemBefore(w,s,g)}svgedit.path.path.init().selectPt(g+1)}else if(svgedit.path.path.segs[I].mate){E.removeItem(I);E.removeItem(I);svgedit.path.path.init().selectPt(I-
1)}else{for(D=0;D<E.numberOfItems;D++){var F=E.getItem(D);if(F.pathSegType===2)s=D;else if(D===I)E.removeItem(s);else if(F.pathSegType===1&&I<D){A=D-1;E.removeItem(D);break}}for(D=I-s-1;D--;)svgedit.path.insertItemBefore(w,E.getItem(s),A);w=E.getItem(s);svgedit.path.replacePathSeg(2,s,[w.x,w.y]);D=I;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(La.canDeleteNodes){svgedit.path.path.storeD();for(var D=svgedit.path.path.selected_pts,w=D.length;w--;)svgedit.path.path.deleteSeg(D[w]);
var E=function(){var I=svgedit.path.path.elem.pathSegList,g=I.numberOfItems,n=function(F,J){for(;J--;)I.removeItem(F)};if(g<=1)return true;for(;g--;){var s=I.getItem(g);if(s.pathSegType===1){s=I.getItem(g-1);var A=I.getItem(g-2);if(s.pathSegType===2){n(g-1,2);E();break}else if(A.pathSegType===2){n(g-2,3);E();break}}else if(s.pathSegType===2)if(g>0){s=I.getItem(g-1).pathSegType;if(s===2){n(g-1,1);E();break}else if(s===1&&I.numberOfItems-1===g){n(g,1);E();break}}}return false};E();if(svgedit.path.path.elem.pathSegList.numberOfItems<=
1){La.toSelectMode(svgedit.path.path.elem);c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){D=$(svgedit.path.path.elem);D.attr("d",D.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(D){var w=D.points,E=w.numberOfItems;if(E>=4){var I=w.getItem(0),g=null;D=[];D.push(["M",I.x,",",I.y," C"].join(""));for(var n=1;n<=E-4;n+=3){var s=w.getItem(n),A=w.getItem(n+1),F=w.getItem(n+2);if(g)if((I=svgedit.path.smoothControlPoints(g,
s,I))&&I.length==2){s=D[D.length-1].split(",");s[2]=I[0].x;s[3]=I[0].y;D[D.length-1]=s.join(",");s=I[1]}D.push([s.x,s.y,A.x,A.y,F.x,F.y].join(","));I=F;g=A}for(D.push("L");n<E;++n){A=w.getItem(n);D.push([A.x,A.y].join(","))}D=D.join(" ");D=R({element:"path",curStyles:true,attr:{id:aa(),d:D,fill:"none"}})}return D},setSegType:function(D){svgedit.path.path.setSegType(D)},moveNode:function(D,w){var E=svgedit.path.path.selected_pts;if(E.length){svgedit.path.path.storeD();E=svgedit.path.path.segs[E[0]];
var I={x:0,y:0};I[D]=w-E.item[D];E.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(D){for(var w=D.pathSegList,E=w.numberOfItems,I,g=0;g<E;++g){var n=w.getItem(g);if(n.pathSegType===2)I=n;if(n.pathSegType===1){n=w.getItem(g-1);if(n.x!=I.x||n.y!=I.y){w=D.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(D,w,g);La.fixEnd(D);break}}}svgedit.browser.isWebkit()&&D.setAttribute("d",La.convertPath(D))},convertPath:function(D,w){for(var E=D.pathSegList,I=E.numberOfItems,
g=0,n=0,s="",A=null,F=0;F<I;++F){var J=E.getItem(F),L=J.x||0,Z=J.y||0,ba=J.x1||0,T=J.y1||0,X=J.x2||0,ha=J.y2||0,pa=J.pathSegType,fa=Na[pa]["to"+(w?"Lower":"Upper")+"Case"](),ua=function(Ma,sa,ra){sa=sa?" "+sa.join(" "):"";ra=ra?" "+svgedit.units.shortFloat(ra):"";$.each(Ma,function(Za,Qa){Ma[Za]=svgedit.units.shortFloat(Qa)});s+=fa+Ma.join(" ")+sa+ra};switch(pa){case 1:s+="z";break;case 12:L-=g;case 13:if(w){g+=L;fa="l"}else{L+=g;g=L;fa="L"}ua([[L,n]]);break;case 14:Z-=n;case 15:if(w){n+=Z;fa="l"}else{Z+=
n;n=Z;fa="L"}ua([[g,Z]]);break;case 2:case 4:case 18:L-=g;Z-=n;case 5:case 3:if(A&&E.getItem(F-1).pathSegType===1&&!w){g=A[0];n=A[1]}case 19:if(w){g+=L;n+=Z}else{L+=g;Z+=n;g=L;n=Z}if(pa===3)A=[g,n];ua([[L,Z]]);break;case 6:L-=g;ba-=g;X-=g;Z-=n;T-=n;ha-=n;case 7:if(w){g+=L;n+=Z}else{L+=g;ba+=g;X+=g;Z+=n;T+=n;ha+=n;g=L;n=Z}ua([[ba,T],[X,ha],[L,Z]]);break;case 8:L-=g;ba-=g;Z-=n;T-=n;case 9:if(w){g+=L;n+=Z}else{L+=g;ba+=g;Z+=n;T+=n;g=L;n=Z}ua([[ba,T],[L,Z]]);break;case 10:L-=g;Z-=n;case 11:if(w){g+=L;
n+=Z}else{L+=g;Z+=n;g=L;n=Z}ua([[J.r1,J.r2]],[J.angle,J.largeArcFlag?1:0,J.sweepFlag?1:0],[L,Z]);break;case 16:L-=g;X-=g;Z-=n;ha-=n;case 17:if(w){g+=L;n+=Z}else{L+=g;X+=g;Z+=n;ha+=n;g=L;n=Z}ua([[X,ha],[L,Z]])}}return s}}}(),Nb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],m=0,C=["fill","stroke","filter","marker-start","marker-mid","marker-end"],z=C.length,G=l.getElementsByTagNameNS(b,"*"),D=G.length,w=0;w<D;w++){for(var E=G[w],
I=0;I<z;I++){var g=ja(E.getAttribute(C[I]));g&&k.push(g.substr(1))}(E=ca(E))&&E.indexOf("#")===0&&k.push(E.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(w=e.length;w--;){C=e[w];z=C.id;if(k.indexOf(z)<0){sb[z]=C;C.parentNode.removeChild(C);m++}}return m};this.svgCanvasToString=function(){for(;Nb()>0;);La.clear(true);$.each(l.childNodes,function(m,C){m&&C.nodeType===8&&C.data.indexOf("Created with")>=0&&l.insertBefore(C,l.firstChild)});if(K){Gb();
$a([K])}var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,C=m.length,z=0;z<C;z++)if(m[z].nodeName=="id"||m[z].nodeName=="style")C--;if(C<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var k=this.svgToString(l,0);e.length&&$(e).each(function(){wb(this)});return k};this.svgToString=function(e,k){var m=[],C=svgedit.utilities.toXml,z=o.baseUnit,G=RegExp("^-?[\\d\\.]+"+z+"$");if(e){la(e);var D=e.attributes,w,E,I=e.childNodes;for(E=0;E<k;E++)m.push(" ");m.push("<");
m.push(e.nodeName);if(e.id==="svgcontent"){E=zb();if(z!=="px"){E.w=svgedit.units.convertUnit(E.w,z)+z;E.h=svgedit.units.convertUnit(E.h,z)+z}m.push(' width="'+E.w+'" height="'+E.h+'" xmlns="'+b+'"');var g={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(F,J){var L=J.namespaceURI;if(L&&!g[L]&&za[L]!=="xmlns"&&za[L]!=="xml"){g[L]=true;m.push(" xmlns:"+za[L]+'="'+L+'"')}})});E=D.length;for(z=["width","height","xmlns","x","y","viewBox","id","overflow"];E--;){w=D.item(E);var n=
C(w.nodeValue);if(w.nodeName.indexOf("xmlns:")!==0)if(n!=""&&z.indexOf(w.localName)==-1)if(!w.namespaceURI||za[w.namespaceURI]){m.push(" ");m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var s=["-moz-math-font-style","_moz-math-font-style"];for(E=D.length-1;E>=0;E--){w=D.item(E);n=C(w.nodeValue);if(!(s.indexOf(w.localName)>=0))if(n!="")if(n.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&n.indexOf("se_")===0)){m.push(" ");if(w.localName===
"d")n=La.convertPath(e,true);if(isNaN(n)){if(G.test(n))n=svgedit.units.shortFloat(n)+z}else n=svgedit.units.shortFloat(n);if(cb.apply&&e.nodeName==="image"&&w.localName==="href"&&cb.images&&cb.images==="embed"){var A=Wa[n];if(A)n=A}if(!w.namespaceURI||w.namespaceURI==b||za[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(n);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");k++;D=false;for(E=0;E<I.length;E++){z=I.item(E);switch(z.nodeType){case 1:m.push("\n");m.push(this.svgToString(I.item(E),
k));break;case 3:z=z.nodeValue.replace(/^\s+|\s+$/g,"");if(z!=""){D=true;m.push(C(z)+"")}break;case 4:m.push("\n");m.push(Array(k+1).join(" "));m.push("<![CDATA[");m.push(z.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("<!--");m.push(z.data);m.push("--\>")}}k--;if(!D){m.push("\n");for(E=0;E<k;E++)m.push(" ")}m.push("</");m.push(e.nodeName);m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,k){$(new Image).load(function(){var m=document.createElement("canvas");
m.width=this.width;m.height=this.height;m.getContext("2d").drawImage(this,0,0);try{var C=";svgedit_url="+encodeURIComponent(e);C=m.toDataURL().replace(";base64",C+";base64");Wa[e]=C}catch(z){Wa[e]=false}Ba=e;k&&k(Wa[e])}).attr("src",e)};this.setGoodImage=function(e){Ba=e};this.open=function(){};this.save=function(e){Pa();e&&$.extend(cb,e);cb.apply=true;e=this.svgCanvasToString();N("saved",e)};this.rasterExport=function(){Pa();var e=[],k={feGaussianBlur:Ua.exportNoBlur,foreignObject:Ua.exportNoforeignObject,
"[stroke-dasharray]":Ua.exportNoDashArray},m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=Ua.exportNoText;$.each(k,function(C,z){m.find(C).length&&e.push(z)});k=this.svgCanvasToString();N("exported",{svg:k,issues:e})};this.getSvgString=function(){cb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Kb=this.uniquifyElems=function(e){var k={},
m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(w){if(w.nodeType==1){if(w.id){w.id in k||(k[w.id]={elem:null,attrs:[],hrefs:[]});k[w.id].elem=w}$.each(tb,function(I,g){var n=w.getAttributeNode(g);if(n){var s=svgedit.utilities.getUrlFromAttr(n.value);if(s=s?s.substr(1):null){s in k||(k[s]={elem:null,attrs:[],hrefs:[]});k[s].attrs.push(n)}}});var E=svgedit.utilities.getHref(w);if(E&&m.indexOf(w.nodeName)>=0)if(E=E.substr(1)){E in
k||(k[E]={elem:null,attrs:[],hrefs:[]});k[E].hrefs.push(w)}}});for(var C in k)if(C){var z=k[C].elem;if(z){e=ka();z.id=e;z=k[C].attrs;for(var G=z.length;G--;){var D=z[G];D.ownerElement.setAttribute(D.name,"url(#"+e+")")}z=k[C].hrefs;for(G=z.length;G--;)svgedit.utilities.setHref(z[G],"#"+e)}}},yb=this.setUseData=function(e){var k=$(e);if(e.tagName!=="use")k=k.find("use");k.each(function(){var m=ca(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",
m).data("ref",m)}})},Lb=this.convertGradients=function(e){var k=$(e).find("linearGradient, radialGradient");if(!k.length&&svgedit.browser.isWebkit())k=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});k.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var C=$(this).attr(["x1","y1","x2","y2"]),
z=this.gradientTransform.baseVal;if(z&&z.numberOfItems>0){var G=ea(z).matrix;z=M(C.x1,C.y1,G);G=M(C.x2,C.y2,G);C.x1=z.x;C.y1=z.y;C.x2=G.x;C.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(C.x1-m.x)/m.width,y1:(C.y1-m.y)/m.height,x2:(C.x2-m.x)/m.width,y2:(C.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Ob=this.convertToGroup=function(e){e||(e=H[0]);var k=$(e),m=new Da,C;if(k.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");
C=U(e);var z=d.createSVGTransform();z.setTranslate(m.x,m.y);C.appendItem(z);Sa(e);N("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");C=k.attr("transform");z=k.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");z.x-=+G[0];z.y-=+G[1]}C+=" translate("+(z.x||0)+","+(z.y||0)+")";z=k.prev();m.addSubCommand(new Ja(k[0],k[0].nextSibling,k[0].parentNode));k.remove();G=$(l).find("use:data(symbol)").length;k=f.createElementNS(b,"g");for(var D=e.childNodes,w=0;w<D.length;w++)k.appendChild(D[w].cloneNode(true));
if(svgedit.browser.isGecko()){D=$(ib()).children("linearGradient,radialGradient,pattern").clone();$(k).append(D)}C&&k.setAttribute("transform",C);C=e.parentNode;Kb(k);svgedit.browser.isGecko()&&$(ib()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();z.after(k);if(C){if(!G){z=e.nextSibling;C.removeChild(e);m.addSubCommand(new Ja(e,z,C))}m.addSubCommand(new Ha(k))}yb(k);svgedit.browser.isGecko()?Lb(ib()):Lb(k);svgedit.utilities.walkTreePost(k,function(E){try{Sa(E)}catch(I){console.log(I)}});
$(k).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});$a([k]);(e=Fb(k,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);this.prepareSvg(k);var m=new Da("Change Source"),C=l.nextSibling,z=d.removeChild(l);m.addSubCommand(new Ja(z,C,d));l=f.adoptNode?f.adoptNode(k.documentElement):f.importNode(k.documentElement,
true);d.appendChild(l);var G=$(l);c.current_drawing_=new svgedit.draw.Drawing(l,v);var D=B().getNonce();D?N("setnonce",D):N("unsetnonce");G.find("image").each(function(){var A=this;Db(A);var F=ca(this);if(F.indexOf("data:")===0){var J=F.match(/svgedit_url=(.*?);/);if(J){var L=decodeURIComponent(J[1]);$(new Image).load(function(){A.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",L)}).attr("src",L)}}c.embedImage(F)});G.find("svg").each(function(){if(!$(this).closest("defs").length){Kb(this);
var A=this.parentNode;if(A.childNodes.length===1&&A.nodeName==="g"){$(A).data("gsvg",this);A.id=A.id||ka()}else wb(this)}});svgedit.browser.isGecko()&&G.find("linearGradient, radialGradient, pattern").appendTo(ib());yb(G);Lb(G[0]);svgedit.utilities.walkTreePost(l,function(A){try{Sa(A)}catch(F){console.log(F)}});var w={id:"svgcontent",overflow:o.show_outside_canvas?"visible":"hidden"},E=false;if(G.attr("viewBox")){var I=G.attr("viewBox").split(" ");w.width=I[2];w.height=I[3]}else $.each(["width","height"],
function(A,F){var J=G.attr(F);J||(J="100%");if((J+"").substr(-1)==="%")E=true;else w[F]=xa(F,J)});Ab();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=ka()});if(E){var g=getStrokedBBox();w.width=g.width+g.x;w.height=g.height+g.y}if(w.width<=0)w.width=100;if(w.height<=0)w.height=100;G.attr(w);this.contentW=w.width;this.contentH=w.height;m.addSubCommand(new Ha(l));var n=G.attr(["width","height"]);m.addSubCommand(new Ia(d,
n));q=1;svgedit.transformlist.resetListMap();Pa();svgedit.path.clearData();d.appendChild(Fa.selectorParentGroup);ya(m);N("changed",[l])}catch(s){console.log(s);return false}return true};this.importSvgString=function(e){try{var k=svgedit.utilities.encode64(e.length+e).substr(0,32),m=false;if(pb[k])if($(pb[k].symbol).parents("#svgroot").length)m=true;var C=new Da("Import SVG");if(m)var z=pb[k].symbol,G=pb[k].xform;else{var D=svgedit.utilities.text2xml(e);this.prepareSvg(D);var w;w=f.adoptNode?f.adoptNode(D.documentElement):
f.importNode(D.documentElement,true);Kb(w);var E=xa("width",w.getAttribute("width")),I=xa("height",w.getAttribute("height")),g=w.getAttribute("viewBox"),n=g?g.split(" "):[0,0,E,I];for(e=0;e<4;++e)n[e]=+n[e];l.getAttribute("width");var s=+l.getAttribute("height");G=I>E?"scale("+s/3/n[3]+")":"scale("+s/3/n[2]+")";G="translate(0) "+G+" translate(0)";z=f.createElementNS(b,"symbol");var A=ib();for(svgedit.browser.isGecko()&&$(w).find("linearGradient, radialGradient, pattern").appendTo(A);w.firstChild;)z.appendChild(w.firstChild);
var F=w.attributes;for(w=0;w<F.length;w++){var J=F[w];z.setAttribute(J.nodeName,J.nodeValue)}z.id=ka();pb[k]={symbol:z,xform:G};ib().appendChild(z);C.addSubCommand(new Ha(z))}var L=f.createElementNS(b,"use");L.id=ka();V(L,"#"+z.id);(K||B().getCurrentLayer()).appendChild(L);C.addSubCommand(new Ha(L));Pa();L.setAttribute("transform",G);Sa(L);$(L).data("symbol",z).data("ref",z);rb([L]);ya(C);N("changed",[l])}catch(Z){console.log(Z);return false}return true};var Ab=c.identifyLayers=function(){Gb();B().identifyLayers()};
this.createLayer=function(e){var k=new Da("Create Layer");e=B().createLayer(e);k.addSubCommand(new Ha(e));ya(k);Pa();N("changed",[e])};this.cloneLayer=function(e){var k=new Da("Duplicate Layer"),m=f.createElementNS(b,"g"),C=f.createElementNS(b,"title");C.textContent=e;m.appendChild(C);C=B().getCurrentLayer();$(C).after(m);C=C.childNodes;for(var z=0;z<C.length;z++){var G=C[z];G.localName!="title"&&m.appendChild(ia(G))}Pa();Ab();k.addSubCommand(new Ha(m));ya(k);c.setCurrentLayer(e);N("changed",[m])};
this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),k=e.nextSibling,m=e.parentNode;if(e=B().deleteCurrentLayer()){var C=new Da("Delete Layer");C.addSubCommand(new Ja(e,k,m));ya(C);Pa();N("changed",[m]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&Pa();return e};this.renameCurrentLayer=function(e){var k=B();if(k.current_layer){var m=k.current_layer;if(!c.setCurrentLayer(e)){for(var C=new Da("Rename Layer"),z=0;z<k.getNumLayers();++z)if(k.all_layers[z][1]==
m)break;var G=k.getLayerName(z);k.all_layers[z][0]=svgedit.utilities.toXml(e);var D=m.childNodes.length;for(z=0;z<D;++z){var w=m.childNodes.item(z);if(w&&w.tagName=="title"){for(;w.firstChild;)w.removeChild(w.firstChild);w.textContent=e;C.addSubCommand(new Ia(w,{"#text":G}));ya(C);N("changed",[m]);return true}}}k.current_layer=m}return false};this.setCurrentLayerPosition=function(e){var k=B();if(k.current_layer&&e>=0&&e<k.getNumLayers()){for(var m=0;m<k.getNumLayers();++m)if(k.all_layers[m][1]==k.current_layer)break;
if(m==k.getNumLayers())return false;if(m!=e){var C=null,z=k.current_layer.nextSibling;if(e>m){if(e<k.getNumLayers()-1)C=k.all_layers[e+1][1]}else C=k.all_layers[e][1];l.insertBefore(k.current_layer,C);ya(new Aa(k.current_layer,z,l));Ab();c.setCurrentLayer(k.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,k){var m=B(),C=m.getLayerVisibility(e),z=m.setLayerVisibility(e,k);if(z)ya(new Ia(z,{display:C?"inline":"none"},"Layer Visibility"));else return false;if(z==m.getCurrentLayer()){Pa();
La.clear()}return true};this.moveSelectedToLayer=function(e){for(var k=null,m=B(),C=0;C<m.getNumLayers();++C)if(m.getLayerName(C)==e){k=m.all_layers[C][1];break}if(!k)return false;e=new Da("Move Elements to Layer");m=H;for(C=m.length;C--;){var z=m[C];if(z){var G=z.nextSibling,D=z.parentNode;k.appendChild(z);e.addSubCommand(new Aa(z,G,D))}}ya(e);return true};this.mergeLayer=function(e){var k=new Da("Merge Layer"),m=B(),C=$(m.current_layer).prev()[0];if(C){for(k.addSubCommand(new Ja(m.current_layer,
m.current_layer.nextSibling,l));m.current_layer.firstChild;){var z=m.current_layer.firstChild;if(z.localName=="title"){k.addSubCommand(new Ja(z,z.nextSibling,m.current_layer));m.current_layer.removeChild(z)}else{var G=z.nextSibling;C.appendChild(z);k.addSubCommand(new Aa(z,G,m.current_layer))}}l.removeChild(m.current_layer);if(!e){Pa();Ab();N("changed",[l]);ya(k)}m.current_layer=C;return k}};this.mergeAllLayers=function(){var e=new Da("Merge all Layers"),k=B();for(k.current_layer=k.all_layers[k.getNumLayers()-
1][1];$(l).children("g").length>1;)e.addSubCommand(c.mergeLayer(true));Pa();Ab();N("changed",[l]);ya(e)};var Gb=this.leaveContext=function(){var e=va.length;if(e){for(var k=0;k<e;k++){var m=va[k],C=eb(m,"orig_opac");C!==1?m.setAttribute("opacity",C):m.removeAttribute("opacity");m.setAttribute("style","pointer-events: inherit")}va=[];Pa(true);N("contextset",null)}K=null},Jb=this.setContext=function(e){Gb();if(typeof e==="string")e=qa(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var k=
this.getAttribute("opacity")||1;eb(this,"orig_opac",k);this.setAttribute("opacity",k*0.33);this.setAttribute("style","pointer-events: none");va.push(this)});Pa();N("contextset",K)};this.clear=function(){La.clear();Pa();c.clearSvgContentElement();c.current_drawing_=new svgedit.draw.Drawing(l);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();Fa.initGroup();ta=Fa.getRubberBandBox();N("cleared")};this.linkControlPoints=La.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=
function(){return d};this.getSelectedElems=function(){return H};var zb=this.getResolution=function(){var e=l.getAttribute("width")/q,k=l.getAttribute("height")/q;return{w:e,h:k,zoom:q}};this.getZoom=function(){return q};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(Ua,e.notification)};this.setConfig=function(e){$.extend(o,e)};this.getTitle=function(e){if(e=e||H[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var k=0;k<e.length;k++)if(e[k].nodeName==
"title")return e[k].textContent;return""}};this.setGroupTitle=function(e){var k=H[0];k=$(k).data("gsvg")||k;var m=$(k).children("title"),C=new Da("Set Label");if(e.length)if(m.length){m=m[0];C.addSubCommand(new Ia(m,{"#text":m.textContent}));m.textContent=e}else{m=f.createElementNS(b,"title");m.textContent=e;$(k).prepend(m);C.addSubCommand(new Ha(m))}else{C.addSubCommand(new Ja(m[0],m.nextSibling,k));m.remove()}ya(C)};this.getDocumentTitle=function(){return c.getTitle(l)};this.setDocumentTitle=function(e){for(var k=
l.childNodes,m=false,C="",z=new Da("Change Image Title"),G=0;G<k.length;G++)if(k[G].nodeName=="title"){m=k[G];C=m.textContent;break}if(!m){m=f.createElementNS(b,"title");l.insertBefore(m,l.firstChild)}if(e.length)m.textContent=e;else m.parentNode.removeChild(m);z.addSubCommand(new Ia(m,{"#text":C}));ya(z)};this.getEditorNS=function(e){e&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,k){var m=zb(),C=m.w;m=m.h;var z;
if(e=="fit"){var G=getStrokedBBox();if(G){z=new Da("Fit Canvas to Content");var D=qb();rb(D);var w=[],E=[];$.each(D,function(){w.push(G.x*-1);E.push(G.y*-1)});D=c.moveSelectedElements(w,E,true);z.addSubCommand(D);Pa();e=Math.round(G.width);k=Math.round(G.height)}else return false}if(e!=C||k!=m){D=d.suspendRedraw(1E3);z||(z=new Da("Change Image Dimensions"));e=xa("width",e);k=xa("height",k);l.setAttribute("width",e);l.setAttribute("height",k);this.contentW=e;this.contentH=k;z.addSubCommand(new Ia(l,
{width:C,height:m}));l.setAttribute("viewBox",[0,0,e/q,k/q].join(" "));z.addSubCommand(new Ia(l,{viewBox:["0 0",C,m].join(" ")}));ya(z);d.unsuspendRedraw(D);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",k+2)}N("changed",[l])}return[e,k]};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(e,k,m){var C=0.85,z=function(G){if(!G)return false;
var D=Math.min(Math.round(k/G.width*100*C)/100,Math.round(m/G.height*100*C)/100);c.setZoom(D);return{zoom:D,bbox:G}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:q*e.factor);return{zoom:q,bbox:e}}return z(e)}switch(e){case "selection":if(!H[0])return;e=$.map(H,function(G){if(G)return G});e=getStrokedBBox(e);break;case "canvas":e=zb();C=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(qb(B().getCurrentLayer()));
break;default:return}return z(e)};this.setZoom=function(e){var k=zb();l.setAttribute("viewBox","0 0 "+k.w/e+" "+k.h/e);q=e;$.each(H,function(m,C){C&&Fa.requestSelector(C).resize()});La.zoomChange();kb("zoomChanged",e)};this.getMode=function(){return Ca};this.setMode=function(e){La.clear(true);ab.clear();$("#workarea").attr("class",e);Ya=H[0]&&H[0].nodeName=="text"?Xa:O;Ca=e};this.getColor=function(e){return Ya[e]};this.setColor=function(e,k,m){O[e]=k;Ya[e+"_paint"]={type:"solidColor"};for(var C=[],
z=H.length;z--;){var G=H[z];if(G)if(G.tagName=="g")svgedit.utilities.walkTree(G,function(D){D.nodeName!="g"&&C.push(D)});else if(e=="fill")G.tagName!="polyline"&&G.tagName!="line"&&C.push(G);else C.push(G)}if(C.length>0)if(m)Bb(e,k,C);else{hb(e,k,C);N("changed",C)}};var ib=function(){var e=l.getElementsByTagNameNS(b,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(b,"defs");l.firstChild?l.insertBefore(e,l.firstChild.nextSibling):l.appendChild(e)}return e},Ib=this.setGradient=function(e){if(!(!Ya[e+
"_paint"]||Ya[e+"_paint"].type=="solidColor")){var k=c[e+"Grad"],m=Hb(k),C=ib();if(m)k=m;else{k=C.appendChild(f.importNode(k,true));k.id=ka()}c.setColor(e,"url(#"+k.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+k.id+")")}},Hb=function(e){var k=ib();k=$(k).find("linearGradient, radialGradient");for(var m=k.length,C=["r","cx","cy","fx","fy"];m--;){var z=k[m];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=z.getAttribute("x1")||e.getAttribute("y1")!=
z.getAttribute("y1")||e.getAttribute("x2")!=z.getAttribute("x2")||e.getAttribute("y2")!=z.getAttribute("y2"))continue}else{var G=$(e).attr(C),D=$(z).attr(C),w=false;$.each(C,function(A,F){if(G[F]!=D[F])w=true});if(w)continue}var E=e.getElementsByTagNameNS(b,"stop"),I=z.getElementsByTagNameNS(b,"stop");if(E.length==I.length){for(var g=E.length;g--;){var n=E[g],s=I[g];if(n.getAttribute("offset")!=s.getAttribute("offset")||n.getAttribute("stop-opacity")!=s.getAttribute("stop-opacity")||n.getAttribute("stop-color")!=
s.getAttribute("stop-color"))break}if(g==-1)return z}}return null};this.setPaint=function(e,k){var m=new $.jGraduate.Paint(k);this.setPaintOpacity(e,m.alpha/100,true);Ya[e+"_paint"]=m;switch(m.type){case "solidColor":if(m.solidColor!="none"&&m.solidColor!="#none")this.setColor(e,"#"+m.solidColor);else{this.setColor(e,"none");document.querySelector(e=="fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","none")}break;case "linearGradient":case "radialGradient":c[e+"Grad"]=m[m.type];
Ib(e)}};this.getStrokeWidth=function(){return Ya.stroke_width};this.setStrokeWidth=function(e){if(e==0&&["line","path"].indexOf(Ca)>=0)c.setStrokeWidth(1);else{Ya.stroke_width=e;for(var k=[],m=H.length;m--;){var C=H[m];if(C)C.tagName=="g"?svgedit.utilities.walkTree(C,function(z){z.nodeName!="g"&&k.push(z)}):k.push(C)}if(k.length>0){hb("stroke-width",e,k);N("changed",H)}}};this.setStrokeAttr=function(e,k){O[e.replace("-","_")]=k;for(var m=[],C=H.length;C--;){var z=H[C];if(z)z.tagName=="g"?svgedit.utilities.walkTree(z,
function(G){G.nodeName!="g"&&m.push(G)}):m.push(z)}if(m.length>0){hb(e,k,m);N("changed",H)}};this.getStyle=function(){return O};this.getOpacity=function(){return O.opacity};this.setOpacity=function(e){O.opacity=e;hb("opacity",e)};this.getFillOpacity=function(){return O.fill_opacity};this.getStrokeOpacity=function(){return O.stroke_opacity};this.setPaintOpacity=function(e,k,m){O[e+"_opacity"]=k;m?Bb(e+"-opacity",k):hb(e+"-opacity",k)};this.getBlur=function(e){var k=0;if(e)if(e.getAttribute("filter"))if(e=
qa(e.id+"_blur"))k=e.firstChild.getAttribute("stdDeviation");return k};(function(){function e(){var z=c.undoMgr.finishUndoableChange();k.addSubCommand(z);ya(k);m=k=null}var k=null,m=null,C=false;c.setBlurNoUndo=function(z){if(m)if(z===0){Bb("filter","");C=true}else{var G=H[0];C&&Bb("filter","url(#"+G.id+"_blur)");if(svgedit.browser.isWebkit()){G.removeAttribute("filter");G.setAttribute("filter","url(#"+G.id+"_blur)")}Bb("stdDeviation",z,[m.firstChild]);c.setBlurOffsets(m,z)}else c.setBlur(z)};c.setBlurOffsets=
function(z,G){if(G>3)ma(z,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){z.removeAttribute("x");z.removeAttribute("y");z.removeAttribute("width");z.removeAttribute("height")}};c.setBlur=function(z,G){if(k)e();else{var D=H[0],w=D.id;m=qa(w+"_blur");z-=0;var E=new Da;if(m){if(z===0)m=null}else{var I=R({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:z}});m=R({element:"filter",attr:{id:w+"_blur"}});m.appendChild(I);ib().appendChild(m);E.addSubCommand(new Ha(m))}I=
{filter:D.getAttribute("filter")};if(z===0){D.removeAttribute("filter");E.addSubCommand(new Ia(D,I))}else{hb("filter","url(#"+w+"_blur)");E.addSubCommand(new Ia(D,I));c.setBlurOffsets(m,z);k=E;c.undoMgr.beginUndoableChange("stdDeviation",[m?m.firstChild:null]);if(G){c.setBlurNoUndo(z);e()}}}}})();this.getBold=function(){var e=H[0];if(e!=null&&e.tagName=="text"&&H[1]==null)return e.getAttribute("font-weight")=="bold";return false};this.setBold=function(e){var k=H[0];if(k!=null&&k.tagName=="text"&&
H[1]==null)hb("font-weight",e?"bold":"normal");H[0].textContent||ab.setCursor()};this.getItalic=function(){var e=H[0];if(e!=null&&e.tagName=="text"&&H[1]==null)return e.getAttribute("font-style")=="italic";return false};this.setItalic=function(e){var k=H[0];if(k!=null&&k.tagName=="text"&&H[1]==null)hb("font-style",e?"italic":"normal");H[0].textContent||ab.setCursor()};this.getFontFamily=function(){return Xa.font_family};this.setFontFamily=function(e){Xa.font_family=e;hb("font-family",e);H[0]&&!H[0].textContent&&
ab.setCursor()};this.setFontColor=function(e){Xa.fill=e;hb("fill",e)};this.getFontSize=function(){return Xa.fill};this.getFontSize=function(){return Xa.font_size};this.setFontSize=function(e){Xa.font_size=e;hb("font-size",e);H[0].textContent||ab.setCursor()};this.getText=function(){var e=H[0];if(e==null)return"";return e.textContent};this.setTextContent=function(e){hb("#text",e);ab.init(e);ab.setCursor()};this.setImageURL=function(e){var k=H[0];if(k){var m=$(k).attr(["width","height"]);m=!m.width||
!m.height;var C=ca(k);if(C!==e)m=true;else if(!m)return;var z=new Da("Change Image URL");V(k,e);z.addSubCommand(new Ia(k,{"#href":C}));m?$(new Image).load(function(){var G=$(k).attr(["width","height"]);$(k).attr({width:this.width,height:this.height});Fa.requestSelector(k).resize();z.addSubCommand(new Ia(k,G));ya(z);N("changed",[k])}).attr("src",e):ya(z)}};this.setLinkURL=function(e){var k=H[0];if(k){if(k.tagName!=="a"){k=$(k).parents("a");if(k.length)k=k[0];else return}var m=ca(k);if(m!==e){var C=
new Da("Change Link URL");V(k,e);C.addSubCommand(new Ia(k,{"#href":m}));ya(C)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:H.every(function(k){return k&&H[0]?k.nodeName==H[0].nodeName:null})};this.setRectRadius=function(e){c.elementsAreSame(H)&&H[0].tagName=="rect"&&H.forEach(function(k){var m=k.getAttribute("rx");if(m!=e){k.setAttribute("rx",e);k.setAttribute("ry",e);ya(new Ia(k,{rx:m,ry:m},"Radius"));N("changed",[k])}})};this.makeHyperlink=function(e){c.groupSelectedElements("a",
e)};this.removeHyperlink=function(){c.ungroupSelectedElement()};this.setSegType=function(e){La.setSegType(e)};this.convertToPath=function(e,k){if(e==null)$.each(H,function(ba,T){T&&c.convertToPath(T)});else{if(!k)var m=new Da("Convert element to Path");var C=k?{}:{fill:O.fill,"fill-opacity":O.fill_opacity,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,opacity:O.opacity,
visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))C[this]=e.getAttribute(this)});var z=R({element:"path",attr:C}),G=e.getAttribute("transform");G&&z.setAttribute("transform",G);var D=e.id,w=e.parentNode;e.nextSibling?w.insertBefore(z,e):w.appendChild(z);var E="",I=function(ba){$.each(ba,function(T,X){var ha=X[1];E+=X[0];for(var pa=0;pa<ha.length;pa+=2)E+=ha[pa]+","+ha[pa+1]+" "})},g=1.81;switch(e.tagName){case "ellipse":case "circle":var n=
$(e).attr(["rx","ry","cx","cy"]),s=n.cx,A=n.cy,F=n.rx;n=n.ry;if(e.tagName=="circle")F=n=$(e).attr("r");I([["M",[s-F,A]],["C",[s-F,A-n/g,s-F/g,A-n,s,A-n]],["C",[s+F/g,A-n,s+F,A-n/g,s+F,A]],["C",[s+F,A+n/g,s+F/g,A+n,s,A+n]],["C",[s-F/g,A+n,s-F,A+n/g,s-F,A]],["Z",[]]]);break;case "path":E=e.getAttribute("d");break;case "line":n=$(e).attr(["x1","y1","x2","y2"]);E="M"+n.x1+","+n.y1+"L"+n.x2+","+n.y2;break;case "polyline":case "polygon":E="M"+e.getAttribute("points");break;case "rect":n=$(e).attr(["rx",
"ry"]);F=n.rx;n=n.ry;var J=e.getBBox();s=J.x;A=J.y;var L=J.width;J=J.height;g=4-g;if(!F&&!n)I([["M",[s,A]],["L",[s+L,A]],["L",[s+L,A+J]],["L",[s,A+J]],["L",[s,A]],["Z",[]]]);else{n||(n=F);I([["M",[s,A+n]],["C",[s,A+n/g,s+F/g,A,s+F,A]],["L",[s+L-F,A]],["C",[s+L-F/g,A,s+L,A+n/g,s+L,A+n]],["L",[s+L,A+J-n]],["C",[s+L,A+J-n/g,s+L-F/g,A+J,s+L-F,A+J]],["L",[s+F,A+J]],["C",[s+F/g,A+J,s,A+J-n/g,s,A+J-n]],["L",[s,A+n]],["Z",[]]])}break;default:z.parentNode.removeChild(z)}E&&z.setAttribute("d",E);if(k){La.resetOrientation(z);
m=false;try{m=z.getBBox()}catch(Z){}z.parentNode.removeChild(z);return m}else{if(G){G=U(z);oa(G)&&La.resetOrientation(z)}m.addSubCommand(new Ja(e,e.nextSibling,w));m.addSubCommand(new Ha(z));Pa();e.parentNode.removeChild(e);z.setAttribute("id",D);z.removeAttribute("visibility");rb([z],true);ya(m)}}};var Bb=this.changeSelectedAttributeNoUndo=function(e,k,m){var C=d.suspendRedraw(1E3);Ca=="pathedit"&&La.moveNode(e,k);m=m||H;for(var z=m.length,G=["g","polyline","path"];z--;){var D=m[z];if(D!=null){Ca===
"textedit"&&e!=="#text"&&D.textContent.length&&ab.toSelectMode(D);if((e==="x"||e==="y")&&G.indexOf(D.tagName)>=0){var w=getStrokedBBox([D]);c.moveSelectedElements((e==="x"?k-w.x:0)*q,(e==="y"?k-w.y:0)*q,true)}else{w=e==="#text"?D.textContent:D.getAttribute(e);if(w==null)w="";if(w!==String(k)){if(e=="#text"){svgedit.utilities.getBBox(D);D.textContent=k}else e=="#href"?V(D,k):D.setAttribute(e,k);H.indexOf(D)>=0&&setTimeout(function(){D.parentNode&&Fa.requestSelector(D).resize()},0);w=na(D);if(w!=0&&
e!="transform")for(var E=U(D),I=E.numberOfItems;I--;)if(E.getItem(I).type==4){E.removeItem(I);var g=svgedit.utilities.getBBox(D),n=M(g.x+g.width/2,g.y+g.height/2,ea(E).matrix);g=n.x;n=n.y;var s=d.createSVGTransform();s.setRotate(w,g,n);E.insertItemBefore(s,I);break}}}}}d.unsuspendRedraw(C)},hb=this.changeSelectedAttribute=function(e,k,m){m=m||H;c.undoMgr.beginUndoableChange(e,m);Bb(e,k,m);e=c.undoMgr.finishUndoableChange();e.isEmpty()||ya(e)};this.deleteSelectedElements=function(){for(var e=new Da("Delete Elements"),
k=H.length,m=[],C=0;C<k;++C){var z=H[C];if(z==null)break;var G=z.parentNode,D=z;Fa.releaseSelector(D);svgedit.path.removePath_(D.id);if(G.tagName==="a"&&G.childNodes.length===1){D=G;G=G.parentNode}var w=D.nextSibling;D=G.removeChild(D);m.push(z);H[C]=null;e.addSubCommand(new Ja(D,w,G))}e.isEmpty()||ya(e);N("changed",m);Pa()};this.cutSelectedElements=function(){for(var e=new Da("Cut Elements"),k=H.length,m=[],C=0;C<k;++C){var z=H[C];if(z==null)break;var G=z.parentNode,D=z;Fa.releaseSelector(D);svgedit.path.removePath_(D.id);
var w=D.nextSibling;D=G.removeChild(D);m.push(z);H[C]=null;e.addSubCommand(new Ja(D,w,G))}e.isEmpty()||ya(e);N("changed",m);Pa();c.clipBoard=m};this.copySelectedElements=function(){c.clipBoard=$.merge([],H)};this.pasteElements=function(){var e=c.clipBoard,k=e.length;if(k){for(var m=[],C=new Da("Paste elements");k--;){var z=e[k];if(z){var G=ia(z);if(!qa(z.id))G.id=z.id;m.push(G);(K||B().getCurrentLayer()).appendChild(G);C.addSubCommand(new Ha(G))}}svgCanvas.clearSelection();setTimeout(function(){$a(m)},
100);ya(C);N("changed",m)}};this.groupSelectedElements=function(e){e||(e="g");var k="";switch(e){case "a":k="Make hyperlink";var m="";if(arguments.length>1)m=arguments[1];break;default:e="g";k="Group Elements"}k=new Da(k);var C=R({element:e,attr:{id:ka()}});e==="a"&&V(C,m);k.addSubCommand(new Ha(C));for(m=H.length;m--;){var z=H[m];if(z!=null){if(z.parentNode.tagName==="a"&&z.parentNode.childNodes.length===1)z=z.parentNode;var G=z.nextSibling,D=z.parentNode;C.appendChild(z);k.addSubCommand(new Aa(z,
G,D))}}k.isEmpty()||ya(k);$a([C],true)};var Fb=this.pushGroupProperties=function(e,k){var m=e.childNodes,C=m.length,z=e.getAttribute("transform"),G=U(e),D=ea(G).matrix,w=new Da("Push group properties"),E=0,I=na(e),g=$(e).attr(["filter","opacity"]),n,s;for(E=0;E<C;E++){var A=m[E];if(A.nodeType===1){if(g.opacity!==null&&g.opacity!==1){A.getAttribute("opacity");var F=Math.round((A.getAttribute("opacity")||1)*g.opacity*100)/100;hb("opacity",F,[A])}if(g.filter){var J=F=this.getBlur(A);s||(s=this.getBlur(e));
if(F)F=s-0+(F-0);else if(F===0)F=s;if(J)n=P(A.getAttribute("filter"));else if(n){n=ia(n);ib().appendChild(n)}else n=P(g.filter);n.id=A.id+"_"+(n.firstChild.tagName==="feGaussianBlur"?"blur":"filter");hb("filter","url(#"+n.id+")",[A]);if(F){hb("stdDeviation",F,[n.firstChild]);c.setBlurOffsets(n,F)}}F=U(A);if(~A.tagName.indexOf("Gradient"))F=null;if(F)if(A.tagName!=="defs")if(G.numberOfItems){if(I&&G.numberOfItems==1){var L=G.getItem(0).matrix,Z=d.createSVGMatrix();if(J=na(A))Z=F.getItem(0).matrix;
var ba=svgedit.utilities.getBBox(A),T=ea(F).matrix,X=M(ba.x+ba.width/2,ba.y+ba.height/2,T);ba=I+J;T=d.createSVGTransform();T.setRotate(ba,X.x,X.y);L=ga(L,Z,T.matrix.inverse());J&&F.removeItem(0);if(ba)F.numberOfItems?F.insertItemBefore(T,0):F.appendItem(T);if(L.e||L.f){J=d.createSVGTransform();J.setTranslate(L.e,L.f);F.numberOfItems?F.insertItemBefore(J,0):F.appendItem(J)}}else{J=A.getAttribute("transform");L={};L.transform=J?J:"";J=d.createSVGTransform();L=ea(F).matrix;Z=L.inverse();L=ga(Z,D,L);
J.setMatrix(L);F.appendItem(J)}(A=Sa(A))&&w.addSubCommand(A)}}}if(z){L={};L.transform=z;e.setAttribute("transform","");e.removeAttribute("transform");w.addSubCommand(new Ia(e,L))}if(k&&!w.isEmpty())return w};this.ungroupSelectedElement=function(){var e=H[0];if($(e).data("gsvg")||$(e).data("symbol"))Ob(e);else if(e.tagName==="use"){var k=qa(ca(e).substr(1));$(e).data("symbol",k).data("ref",k);Ob(e)}else{k=$(e).parents("a");if(k.length)e=k[0];if(e.tagName==="g"||e.tagName==="a"){k=new Da("Ungroup Elements");
var m=Fb(e,true);m&&k.addSubCommand(m);m=e.parentNode;for(var C=e.nextSibling,z=Array(e.childNodes.length),G=0;e.firstChild;){var D=e.firstChild,w=D.nextSibling,E=D.parentNode;if(D.tagName==="title"){k.addSubCommand(new Ja(D,D.nextSibling,E));E.removeChild(D)}else{z[G++]=D=m.insertBefore(D,C);k.addSubCommand(new Aa(D,w,E))}}Pa();C=e.nextSibling;e=m.removeChild(e);k.addSubCommand(new Ja(e,C,m));k.isEmpty()||ya(k);rb(z)}}};this.moveToTopSelectedElement=function(){var e=H[0];if(e!=null){e=e;var k=e.parentNode,
m=e.nextSibling;e=e.parentNode.appendChild(e);if(m!=e.nextSibling){ya(new Aa(e,m,k,"top"));N("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=H[0];if(e!=null){e=e;var k=e.parentNode,m=e.nextSibling,C=e.parentNode.firstChild;if(C.tagName=="title")C=C.nextSibling;if(C.tagName=="defs")C=C.nextSibling;e=e.parentNode.insertBefore(e,C);if(m!=e.nextSibling){ya(new Aa(e,m,k,"bottom"));N("changed",[e])}}};this.moveUpDownSelected=function(e){var k=H[0];if(k){jb=[];var m,C,z=$(mb(getStrokedBBox([k]))).toArray();
e=="Down"&&z.reverse();$.each(z,function(){if(C){m=this;return false}else if(this==k)C=true});if(m){z=k.parentNode;var G=k.nextSibling;$(m)[e=="Down"?"before":"after"](k);if(G!=k.nextSibling){ya(new Aa(k,G,z,"Move "+e));N("changed",[k])}}}};this.moveSelectedElements=function(e,k,m){if(e.constructor!=Array){e/=q;k/=q}m=m||true;for(var C=new Da("position"),z=H.length;z--;){var G=H[z];if(G!=null){var D=d.createSVGTransform(),w=U(G);e.constructor==Array?D.setTranslate(e[z],k[z]):D.setTranslate(e,k);w.numberOfItems?
w.insertItemBefore(D,0):w.appendItem(D);(D=Sa(G))&&C.addSubCommand(D);Fa.requestSelector(G).resize()}}if(!C.isEmpty()){m&&ya(C);N("changed",H);return C}};this.cloneSelectedElements=function(e,k,m){for(var C=new Da("Clone Elements"),z=H.length,G=0;G<z;++G)if(H[G]==null)break;z=H.slice(0,G);this.clearSelection(true);G=z.length;for(clones=[];G--;){var D=ia(z[G]);if(m){tlist=U(D);tlist.removeItem(m);Sa(D)}(K||B().getCurrentLayer()).appendChild(D);clones.push(D);C.addSubCommand(new Ha(D))}if(!C.isEmpty()){rb(z.reverse());
m||this.moveSelectedElements(e,k,false);ya(C)}return clones};this.alignSelectedElements=function(e,k){var m=[],C=Number.MAX_VALUE,z=Number.MIN_VALUE,G=Number.MAX_VALUE,D=Number.MIN_VALUE,w=Number.MIN_VALUE,E=Number.MIN_VALUE,I=H.length;if(I){for(var g=0;g<I;++g){if(H[g]==null)break;m[g]=getStrokedBBox([H[g]]);switch(k){case "smallest":if((e=="l"||e=="c"||e=="r")&&(w==Number.MIN_VALUE||w>m[g].width)||(e=="t"||e=="m"||e=="b")&&(E==Number.MIN_VALUE||E>m[g].height)){C=m[g].x;G=m[g].y;z=m[g].x+m[g].width;
D=m[g].y+m[g].height;w=m[g].width;E=m[g].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(w==Number.MIN_VALUE||w<m[g].width)||(e=="t"||e=="m"||e=="b")&&(E==Number.MIN_VALUE||E<m[g].height)){C=m[g].x;G=m[g].y;z=m[g].x+m[g].width;D=m[g].y+m[g].height;w=m[g].width;E=m[g].height}break;default:if(m[g].x<C)C=m[g].x;if(m[g].y<G)G=m[g].y;if(m[g].x+m[g].width>z)z=m[g].x+m[g].width;if(m[g].y+m[g].height>D)D=m[g].y+m[g].height}}if(k=="page"){G=C=0;z=c.contentW;D=c.contentH}w=Array(I);E=Array(I);for(g=
0;g<I;++g){if(H[g]==null)break;var n=m[g];w[g]=0;E[g]=0;switch(e){case "l":w[g]=C-n.x;break;case "c":w[g]=(C+z)/2-(n.x+n.width/2);break;case "r":w[g]=z-(n.x+n.width);break;case "t":E[g]=G-n.y;break;case "m":E[g]=(G+D)/2-(n.y+n.height/2);break;case "b":E[g]=D-(n.y+n.height)}}this.moveSelectedElements(w,E)}};this.contentW=zb().w;this.contentH=zb().h;this.updateCanvas=function(e,k){d.setAttribute("width",e);d.setAttribute("height",k);var m=$("#canvasBackground")[0],C=l.getAttribute("x"),z=l.getAttribute("y"),
G=e/2-this.contentW*q/2,D=k/2-this.contentH*q/2;ma(l,{width:this.contentW*q,height:this.contentH*q,x:G,y:D,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(m,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:G,y:D});(m=qa("background_image"))&&ma(m,{width:"100%",height:"100%"});Fa.selectorParentGroup.setAttribute("transform","translate("+G+","+D+")");return{x:G,y:D,old_x:C,old_y:z,d_x:G-C,d_y:D-z}};this.setBackground=function(e,k){var m=qa("canvasBackground"),C=$(m).find("rect")[0],
z=qa("background_image");C.setAttribute("fill",e);if(k){if(!z){z=f.createElementNS(b,"image");ma(z,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}V(z,k);m.appendChild(z)}else z&&z.parentNode.removeChild(z)};this.cycleElement=function(e){var k=H[0],m=false,C=qb(K||B().getCurrentLayer());if(C.length){if(k==null){e=e?C.length-1:0;m=C[e]}else for(var z=C.length;z--;)if(C[z]==k){e=e?z-1:z+1;if(e>=C.length)e=0;else if(e<0)e=C.length-1;m=C[e];
break}$a([m],true);N("selected",H)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:ya,setGradient:Ib,addSvgElementFromJson:R,assignAttributes:ma,BatchCommand:Da,call:N,ChangeElementCommand:Ia,copyElem:ia,ffClone:da,findDefs:ib,findDuplicateGradient:Hb,getElem:qa,getId:aa,getIntersectionList:mb,getMouseTarget:Eb,getNextId:ka,getPathBBox:W,getUrlFromAttr:ja,hasMatrixTransform:oa,identifyLayers:Ab,InsertElementCommand:Ha,isIdentity:svgedit.math.isIdentity,logMatrix:Ra,matrixMultiply:ga,
MoveElementCommand:Aa,preventClickDefault:Db,recalculateAllSelectedDimensions:Ea,recalculateDimensions:Sa,remapElement:bb,RemoveElementCommand:Ja,removeUnusedDefElems:Nb,round:db,runExtensions:kb,sanitizeSvg:Ga,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:ea,transformPoint:M,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 p(d,l){var v=h.setSvgString(d)!==false;l=l||a.noop;v?l(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){l(false)})}var h,b={},o=false;curConfig={canvas_expansion:1,dimensions:[580,400],
2012-07-27 23:32:02 +00:00
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:svgedit.browser.isTouch()?false:true,show_outside_canvas:false,no_save_warning:true,initFont:"Helvetica, Arial, sans-serif"};uiStrings=b.uiStrings={common:{ok:"OK",cancel:"Cancel",key_up:"Up",
2012-07-25 10:27:26 +00:00
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!",
2012-07-19 14:54:50 +00:00
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...",
2012-07-31 00:49:46 +00:00
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};var u={},c={};b.curConfig=curConfig;b.tool_scale=1;b.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
2012-07-31 19:01:03 +00:00
b.setCustomHandlers=function(d){b.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();h.open=d.open}if(d.save){b.show_save_warning=false;h.bind("saved",d.save)}d.pngsave&&h.bind("exported",d.pngsave);c=d})};b.randomizeIds=function(){h.randomizeIds(arguments)};b.init=function(){function d(g,n){var s=g.id,A=s.split("_"),F=A[0];A=A[1];n&&h.setStrokeAttr("stroke-"+F,A);wa();Ib("#cur_"+F,s,20);a(g).addClass("current").siblings().removeClass("current")}(function(){var g=
window.opener;if(g)try{var n=g.document.createEvent("Event");n.initEvent("svgEditorReady",true,true);g.document.documentElement.dispatchEvent(n)}catch(s){}})();(function(){a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);a("body").toggleClass("touch",svgedit.browser.isTouch());var g=a.deparam.querystring(true);if(!a.isEmptyObject(g)){if(g.dimensions)g.dimensions=g.dimensions.split(",");if(g.extensions)g.extensions=g.extensions.split(",");if(g.bkgd_color)g.bkgd_color=
"#"+g.bkgd_color;svgEditor.setConfig(g);var n=g.source,s=a.param.querystring();if(!n)if(s.indexOf("source=data:")>=0)n=s.match(/source=(data:[^&]*)/)[1];if(n)if(n.indexOf("data:")===0){n=n.replace(/ /g,"+");b.loadFromDataURI(n)}else b.loadFromString(n);else if(s.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(s.substr(9));else g.url&&svgEditor.loadFromURL(g.url)}})();var l=function(){a.each(curConfig.extensions,function(){var g=this;a.getScript(curConfig.extPath+g,function(n){if(!n){n=document.createElement("script");
n.src=curConfig.extPath+g;document.querySelector("head").appendChild(n)}})})};document.location.protocol==="file:"?setTimeout(l,100):l();a.svgIcons(curConfig.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:true,fallback_path:curConfig.imgPath,fallback:{logo:"logo.png",select:"select.png",select_node:"select_node.png",pencil:"pencil.png",pen:"line.png",rect:"square.png",ellipse:"ellipse.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png","delete":"delete.png",spapelib:"shapelib.png",
node_delete:"node_delete.png",align_left:"align-left.png",align_center:"align-center.png",align_right:"align-right.png",align_top:"align-top.png",align_middle:"align-middle.png",align_bottom:"align-bottom.png",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#logo":"logo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen","#tool_rect,#tools_rect_show":"rect","#tool_ellipse,#tools_ellipse_show":"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","#zoomLabel":"zoom","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},
resize:{"#logo .svg_icon":15,".flyout_arrow_horiz .svg_icon":5,"#fill_bg .svg_icon, #stroke_bg .svg_icon":svgedit.browser.isTouch()?24:24,".palette_item:first .svg_icon":svgedit.browser.isTouch()?30:16,"#zoomLabel .svg_icon":16,"#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 g=a("#tools_left");if(g.length!=0){g.offset();g.outerHeight()}a(".tools_flyout").each(function(){var n=
a("#"+this.id+"_show"),s=n.attr("data-curopt");if(!n.children("svg, img").length){s=a(s).children().clone();if(s.length){s[0].removeAttribute("style");n.append(s)}}});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(g){a("#base_unit_container").css({top:g.pageY-10,left:g.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",
function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});b.canvas=h=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};l=navigator.platform.indexOf("Mac")>=0;var v=navigator.userAgent.indexOf("AppleWebKit")>=0,B=l?"meta+":"ctrl+",q=h.pathActions,K=h.undoMgr,S=svgedit.utilities,O=curConfig.imgPath+
"placeholder.svg",H=a("#workarea"),R=a("#cmenu_canvas"),U=null,M=1,ga="toolbars",oa="";l||a(".shortcut").each(function(){var g=a(this).text();a(this).text(g.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var g=a("#dialog_box"),n=a("#dialog_buttons"),s=function(A,F,J,L){a("#dialog_content").html("<p>"+F.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",A=="prompt");n.empty();var Z=a('<input type="button" value="'+
uiStrings.common.ok+'">').appendTo(n);A!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(n).on("click, touchstart",function(){g.hide();J(false)});if(A=="prompt"){var ba=a('<input type="text">').prependTo(n);ba.val(L||"");ba.bind("keydown","return",function(){Z.trigger("click touchstart")})}A=="process"&&Z.hide();g.show();Z.on("click touchstart",function(){g.hide();var T=A=="prompt"?ba.val():true;J&&J(T)}).focus();A=="prompt"&&ba.focus()};a.alert=function(A,F){s("alert",
A,F)};a.confirm=function(A,F){s("confirm",A,F)};a.process_cancel=function(A,F){s("process",A,F)};a.prompt=function(A,F,J){s("prompt",A,J,F)}})();var ea=function(){var g=a(".tool_button_current");if(g.length&&g[0].id!=="tool_select"){g.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}h.setMode("select")},Q=null,Y=false,xa=false,ja="",ca=function(g,n){var s=h.getResolution();a("#svgcanvas").position();var A=h.setBBoxZoom(n,
H.width()-15,H.height()-15);if(A){var F=A.zoom;A=A.bbox;if(F<0.0010)Fa({value:0.1});else{typeof animatedZoom!="undefined"&&g.cancelAnimationFrame(animatedZoom);var J=Date.now(),L=F-s.zoom;a("#zoom");var Z=s.zoom,ba=function(T){T=(T-J)/500;T=Math.pow(T-1,3)+1;h.setZoom(Z+L*T);D();if(T<1)g.animatedZoom=requestAnimationFrame(ba);else{a("#zoom").val(parseInt(F*100));a("option","#zoom_select").removeAttr("selected");a("option[value="+parseInt(F*100)+"]","#zoom_select").attr("selected","selected")}};ba(Date.now());
h.getMode()=="zoom"&&A.width&&ea();Jb()}}};a("#cur_context_panel").delegate("a","click",function(){var g=a(this);g.attr("data-root")?h.leaveContext():h.setContext(g.text());return false});var V=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},W={},na=function(g){a.each(g,function(n,s){var A=a(n).children(),F=n+"_show",J=a(F),L=false;A.addClass("tool_button").unbind("click mousedown mouseup").each(function(T){var X=s[T];W[X.sel]=X.fn;if(X.isDefault)L=T;T=function(ha){var pa=X;if(ha.type===
"keydown"){var fa=a(pa.parent+"_show").hasClass("tool_button_current"),ua=a(pa.parent+"_show").attr("data-curopt");a.each(g[X.parent],function(sa,ra){if(ra.sel==ua)pa=!ha.shiftKey||!fa?ra:g[X.parent][sa+1]||g[X.parent][0]})}if(a(this).hasClass("disabled"))return false;Ua(F)&&pa.fn();var Ma=pa.icon?a.getSvgIcon(pa.icon,true):a(pa.sel).children().eq(0).clone();Ma[0].setAttribute("width",J.width());Ma[0].setAttribute("height",J.height());J.children(":not(.flyout_arrow_horiz)").remove();J.append(Ma).attr("data-curopt",
pa.sel)};a(this).mouseup(T);X.key&&a(document).bind("keydown",X.key[0]+" shift+"+X.key[0],T)});if(L)J.attr("data-curopt",s[L].sel);else J.attr("data-curopt")||J.attr("data-curopt",s[0].sel);var Z,ba=a(F).position();a(n).css({left:ba.left+34,top:ba.top+77});J.mousedown(function(T){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&Ua(F,false);if(J.hasClass("disabled"))return false;var X=a(n),ha=ba.left+34,pa=X.width()*-1,fa=X.data("shown_popop")?
200:0;Z=setTimeout(function(){J.data("isLibrary")?X.css("left",ha).show():X.css("left",pa).show().animate({left:ha},50);X.data("shown_popop",true)},fa);T.preventDefault()}).mouseup(function(){clearTimeout(Z);var T=a(this).attr("data-curopt");if(J.data("isLibrary")&&a(F.replace("_show","")).is(":visible"))Ua(F,true);else Ua(F)&&T in W&&W[T]()})});la()},qa=function(g,n){return a("<div>",{"class":"tools_flyout",id:g}).appendTo("#svg_editor").append(n)},ma=function(){a(".tools_flyout").each(function(){var g=
a("#"+this.id+"_show"),n=g.offset();g=g.outerWidth();a(this).css({left:(n.left+g)*M,top:n.top})})},la=function(){a(".tools_flyout").each(function(){var g=a("#"+this.id+"_show");if(!g.data("isLibrary")){var n=[];a(this).children().each(function(){n.push(this.title)});g[0].title=n.join(" / ")}})},za,Ga=function(g,n,s){var A=null;if(g.indexOf("url(#")===0){g=(g=h.getRefElem(g))?g.cloneNode(true):a("#"+s+"_color defs *")[0];A={alpha:n};A[g.tagName]=g}else A=g.indexOf("#")===0?{alpha:n,solidColor:g.substr(1)}:
{alpha:n,solidColor:"none"};return new a.jGraduate.Paint(A)},Aa=h.getResolution();if(curConfig.baseUnit!=="px"){Aa.w=svgedit.units.convertUnit(Aa.w)+curConfig.baseUnit;Aa.h=svgedit.units.convertUnit(Aa.h)+curConfig.baseUnit}var Ha=function(g){h.createLayer("background");cur_shape=h.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Aa.w+2,height:Aa.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:g||"#fff",style:"pointer-events:none"}});h.setCurrentLayer("Layer 1");h.setCurrentLayerPosition("1")};
document.getElementById("canvas_background")||Ha();document.getElementById("canvas_background").getAttribute("fill");var Ja=b.setImageURL=function(g){g||(g=O);h.setImageURL(g);a("#image_url").val(g)},Ia=function(){var g=Q;if(g!=null&&!g.parentNode)g=null;if(Y&&Y[0]!=null&&!Y[0].parentNode)Y=false;var n=h.getCurrentDrawing().getCurrentLayerName(),s=h.getMode(),A=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,F=s=="pathedit";if(F){a(".context_panel").hide();a("#path_node_panel").show();a("#stroke_panel").hide();
n=q.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!q.canDeleteNodes);Ib("#tool_openclose_path",q.closed_subpath?"open_path":"close_path");if(n){F=a("#seg_type");if(A){n.x=svgedit.units.convertUnit(n.x);n.y=svgedit.units.convertUnit(n.y)}a("#path_node_x").val(Math.round(n.x));a("#path_node_y").val(Math.round(n.y));n.type?F.val(n.type).removeAttr("disabled"):F.val(4).attr("disabled","disabled")}a("#tools_top").removeClass("multiselected");
a("#stroke_panel").hide();a("#canvas_panel").hide()}else{var J=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");if(Y){Y=Y.filter(Boolean);(g=h.elementsAreSame(Y)?Y[0]:null)&&a("#tools_top").addClass("multiselected")}if(!g&&!Y){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(g!=null){a("#stroke_panel").show();var L=g.nodeName,Z=h.getRotationAngle(g);
a("#angle").val(Math.round(Z));Z=h.getBlur(g);a("#blur").val(Z);if(!F&&s!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var ba,T;if(["g","polyline","path"].indexOf(L)>=0)if(s=h.getStrokedBBox([g])){ba=s.x;T=s.y}if(A){ba=svgedit.units.convertUnit(ba);T=svgedit.units.convertUnit(T)}a("#"+L+"_x").val(Math.round(ba));a("#"+L+"_y").val(Math.round(T));if(L==="polyline"){a("#path_x").val(Math.round(ba));a("#path_y").val(Math.round(T))}["image","text","path","g","use"].indexOf(L)==
-1&&a(".action_path_convert_selected").removeClass("disabled");L==="path"&&a(".action_path_selected").removeClass("disabled")}A=null;if(X==="a"){A=h.getHref(g);a("#g_panel").show()}if(g.parentNode.tagName==="a")if(!a(g).siblings().length){a("#a_panel").show();A=h.getHref(g.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!A);A&&a("#link_url").val(A);A={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1",
"y1","x2","y2"],text:["x","y"],use:[],path:[]};var X=g.tagName;a(g).data("gsvg")&&a("#g_panel").show();if(X=="path"||X=="polyline")a("#path_panel").show();if(A[X]){A=A[X];a("#"+X+"_panel").show();X=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(A,function(ha,pa){var fa=g.getAttribute(pa);if(curConfig.baseUnit!=="px"&&g[pa])fa=svgedit.units.convertUnit(g[pa].baseVal.value);var ua=document.getElementById(X+"_"+pa);ua.value=Math.round(fa)||0;ua.getAttribute("data-cursor")===
"true"&&a.fn.dragInput.updateCursor(ua)});if(X=="text"){A=g.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",h.getItalic());a("#tool_bold").toggleClass("active",h.getBold());a("#font_family").val(A);a("#font_size").val(g.getAttribute("font-size"));a("#text").val(g.textContent);a("#preview_font").text(A.split(",")[0].replace(/'/g,"")).css("font-family",A);h.addedNew&&setTimeout(function(){a("#text").focus().select()},
100)}else if(X=="image")Ja(h.getHref(g));else if(X==="g"||X==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");h.getTitle()}}J[(X==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");J[(X==="g"||!Y?"dis":"en")+"ableContextMenuItems"]("#group")}if(Y){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");J.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}g||J.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
K.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");K.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");h.addedNew=false;if(g&&!F||Y){a("#selLayerNames").removeAttr("disabled").val(n);R.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});h.bind("selected",function(g,n){var s=h.getMode();s==="select"&&
ea();if(s==="pathedit")return Ia();Q=n.length==1||n[1]==null?n[0]:null;n=n.filter(Boolean);Y=n.length>=2?n:false;if(h.elementsAreSame(Y))Q=Y[0];if(Q!=null){a("#multiselected_panel").hide();if(Q!=null)switch(Q.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":s=null;for(var A=Q.getElementsByTagName("*"),F=0,J=A.length;F<J;F++){var L=A[F].getAttribute("stroke-width");if(F===0)s=L;else if(s!==L)s=null}a("#stroke_width").val(s===null?"":s);break;default:a("#stroke_width").val(Q.getAttribute("stroke-width")||
1);s=Q.getAttribute("stroke-dasharray")||"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+s+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);s=Q.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+s).length!=0&&d(a("#linejoin_"+s)[0]);s=Q.getAttribute("stroke-linecap")||"butt";a("#linecap_"+s).length!=0&&d(a("#linecap_"+s)[0])}if(Q!=null){s=(Q.getAttribute("opacity")||1)*100;a("#group_opacity").val(s);
a.fn.dragInput.updateCursor(a("#group_opacity")[0])}Y.length&&a("#tools_top").addClass("multiselected")}else if(Y.length){a(".context_panel").hide();a("#tools_top").removeClass("multiselected");a("#multiselected_panel").show()}else{a(".context_panel").hide();a("#canvas_panel").show();a("#tools_top").removeClass("multiselected")}h.runExtensions("selectedChanged",{elems:n,selectedElement:Q,multiselected:Y})});h.bind("transition",function(g,n){var s=h.getMode(),A=n[0];if(A){Y=n.length>=2&&n[1]!=null?
n:null;if(!Y)switch(s){case "rotate":s=h.getRotationAngle(A);a("#angle").val(Math.round(s));rotateCursor(s);a("#tool_reorient").toggleClass("disabled",s==0)}h.runExtensions("elementTransition",{elems:n})}});h.bind("changed",function(g,n){var s=h.getMode();s==="select"&&ea();for(var A=0;A<n.length;++A){var F=n[A];if(F&&F.tagName==="svg")D();else if(F&&Q&&Q.parentNode==null)Q=F}b.show_save_warning=true;Ia();if(Q&&s==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}h.runExtensions("elementChanged",
{elems:n})});h.bind("saved",function(g,n){b.show_save_warning=false;n='<?xml version="1.0"?>\n'+n;var s=navigator.userAgent;if(~s.indexOf("Chrome")&&a.browser.version>=533||~s.indexOf("MSIE"))zb(0,true);else{var A=g.open("data:image/svg+xml;base64,"+S.encode64(n)),F=a.pref("save_notice_done");if(F!=="all"){var J=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(s.indexOf("Gecko/")!==-1)if(n.indexOf("<defs")!==-1){J+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done",
"all");F="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");F!=="part"&&A.alert(J)}}});h.bind("exported",function(g,n){var s=n.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var A=a("#export_canvas")[0];A.width=h.contentW;A.height=h.contentH;canvg(A,n.svg,{renderCallback:function(){var F=A.toDataURL("image/png");U.location.href=F;if(a.pref("export_notice_done")!=="all"){F=uiStrings.notification.saveFromBrowser.replace("%s",
"PNG");if(s.length)F+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+s.join("\n \u2022 ");a.pref("export_notice_done","all");U.alert(F)}}})});h.bind("zoomed",ca);h.bind("contextset",function(g,n){var s="";if(n){var A="";s='<a href="#" data-root="y">'+h.getCurrentDrawing().getCurrentLayerName()+"</a>";a(n).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){A+=" > "+this.id;s+=this!==n?' > <a href="#">'+this.id+"</a>":" > "+this.id}});ja=A}else ja=null;a("#cur_context_panel").toggle(!!n).html(s)});
h.bind("extension_added",function(g,n){function s(){if(za){clearTimeout(za);za=null}F||(za=setTimeout(function(){F=true;hb(u.iconsize)},50))}var A=false,F=false,J=true,L=function(){if(n.callback&&!A&&J){A=true;n.callback()}},Z=[];n.context_tools&&a.each(n.context_tools,function(pa,fa){var ua=fa.container_id?' id="'+fa.container_id+'"':"",Ma=a("#"+fa.panel);Ma.length||(Ma=a("<div>",{id:fa.panel}).appendTo("#tools_top").hide());switch(fa.type){case "tool_button":var sa='<div class="tool_button">'+fa.id+
"</div>",ra=a(sa).appendTo(Ma);fa.events&&a.each(fa.events,function(Oa,lb){a(ra).bind(Oa,lb)});break;case "select":sa="<label"+ua+'><select id="'+fa.id+'">';a.each(fa.options,function(Oa,lb){sa+='<option value="'+Oa+'"'+(Oa==fa.defval?" selected":"")+">"+lb+"</option>"});sa+="</select></label>";var Za=a(sa).appendTo(Ma).find("select");a.each(fa.events,function(Oa,lb){a(Za).bind(Oa,lb)});break;case "button-select":sa='<div id="'+fa.id+'" class="dropdown toolset" title="'+fa.title+'"><div id="cur_'+
fa.id+'" class="icon_label"></div><button></button></div>';ua=a('<ul id="'+fa.id+'_opts"></ul>').appendTo("#option_lists");fa.colnum&&ua.addClass("optcols"+fa.colnum);a(sa).appendTo(Ma).children();Z.push({elem:"#"+fa.id,list:"#"+fa.id+"_opts",title:fa.title,callback:fa.events.change,cur:"#cur_"+fa.id});break;case "input":sa="<label"+ua+'><span id="'+fa.id+'_label">'+fa.label+':</span><input id="'+fa.id+'" title="'+fa.title+'" size="'+(fa.size||"4")+'" value="'+(fa.defval||"")+'" type="text"/></label>';
var Qa=a(sa).appendTo(Ma).find("input");fa.spindata&&Qa.SpinButton(fa.spindata);fa.events&&a.each(fa.events,function(Oa,lb){Qa.bind(Oa,lb)})}});if(n.buttons){var ba={},T={},X=n.svgicons,ha={};a.each(n.buttons,function(pa,fa){for(var ua,Ma=fa.id,sa=pa;a("#"+Ma).length;)Ma=fa.id+"_"+ ++sa;if(X){ba[Ma]=fa.icon;sa=fa.svgicon?fa.svgicon:fa.id;if(fa.type=="app_menu")T["#"+Ma+" > div"]=sa;else T["#"+Ma]=sa}else ua=fa.type=="menu"?"":a('<img src="'+fa.icon+'">');var ra,Za;switch(fa.type){case "mode_flyout":case "mode":ra=
"tool_button";if(fa.cls)ra+=" "+fa.cls;Za="#tools_left";break;case "context":ra="tool_button";Za="#"+fa.panel;a(Za).length||a("<div>",{id:fa.panel}).appendTo("#tools_top");break;case "menu":ra="menu_item tool_button";Za="#"+(fa.after||fa.panel);break;case "app_menu":ra="";Za=fa.parent||"#main_menu ul";a(Za).length||a("<div>",{id:fa.panel}).appendTo("#tools_top")}var Qa=a(fa.list||fa.type=="app_menu"?"<li/>":"<div/>").attr("id",Ma).attr("title",fa.title).addClass(ra);if(!fa.includeWith&&!fa.list){if("position"in
fa)a(Za).children().eq(fa.position).before(Qa);else fa.type!="menu"||!fa.after?Qa.appendTo(Za):a(Za).after(Qa);if(fa.type=="mode_flyout"){sa=a(Qa);ra=sa.parent();if(!sa.parent().hasClass("tools_flyout")){var Oa=sa[0].id.replace("tool_","tools_"),lb=sa.clone().attr("id",Oa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));sa.before(lb);ra=qa(Oa,sa);ra.data("isLibrary",true);lb.data("isLibrary",true)}T["#"+Oa+"_show"]=fa.id;Ma=ha["#"+ra[0].id]=[{sel:"#"+Ma,fn:fa.events.click,icon:fa.id,isDefault:true},
xb]}else if(fa.type=="app_menu"||fa.type=="menu")Qa.append(fa.title)}else if(fa.list){Qa.addClass("push_button");a("#"+fa.list+"_opts").append(Qa);if(fa.isDefault){a("#cur_"+fa.list).append(Qa.children().clone());sa=fa.svgicon?fa.svgicon:fa.id;T["#cur_"+fa.list]=sa}}else if(fa.includeWith){Za=fa.includeWith;sa=a(Za.button);ra=sa.parent();if(!sa.parent().hasClass("tools_flyout")){Oa=sa[0].id.replace("tool_","tools_");lb=sa.clone().attr("id",Oa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));
sa.before(lb);ra=qa(Oa,sa)}var xb=G.getButtonData(Za.button);if(Za.isDefault)T["#"+Oa+"_show"]=fa.id;Ma=ha["#"+ra[0].id]=[{sel:"#"+Ma,fn:fa.events.click,icon:fa.id,key:fa.key,isDefault:fa.includeWith?fa.includeWith.isDefault:0},xb];Oa="position"in Za?Za.position:"last";xb=ra.children().length;if(!isNaN(Oa)&&Oa>=0&&Oa<xb)ra.children().eq(Oa).before(Qa);else{ra.append(Qa);Ma.reverse()}}X||Qa.append(ua);fa.list||a.each(fa.events,function(Cb,Mb){if(Cb=="click")if(fa.type=="mode"){fa.includeWith?Qa.bind(Cb,
Mb):Qa.bind(Cb,function(){Ua(Qa)&&Mb()});if(fa.key){a(document).bind("keydown",fa.key,Mb);fa.title&&Qa.attr("title",fa.title+" ["+fa.key+"]")}}else Qa.bind(Cb,Mb);else Qa.bind(Cb,Mb)});na(ha)});a.each(Z,function(){Va(this.elem,this.list,this.callback,{seticon:true})});if(X)J=false;a.svgIcons(X,{w:27,h:27,id_match:false,no_img:!v,fallback:ba,placement:T,callback:function(){u.iconsize&&u.iconsize!="m"&&s();J=true;L()}})}L()});h.textActions.setInputElem(a("#text")[0]);var Da='<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(g,n){Da+='<div class="palette_item" style="background-color: '+n+';" data-rgb="'+n+'"></div>'});a("#palette").append(Da);
var ya=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(g){g="rotate("+g+"deg)";ya.css({"-webkit-transform":g,"-moz-transform":g,"-o-transform":g,"-ms-transform":g,transform:g})};var Fa=function(g){var n=g.value/100;if(n<0.0010)g.value=0.1;else{g=h.getZoom();ca(window,{width:0,height:0,x:(H[0].scrollLeft+H.width()/2)/g,y:(H[0].scrollTop+H.height()/2)/g,zoom:n},true)}},wa=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){h.setStrokeAttr("stroke-dasharray",
a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);wa()});a("#seg_type").change(function(){h.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){h.setFontFamily(this.value)});a("#text").keyup(function(){h.setTextContent(this.value)});changeAttribute=function(g){var n=g.getAttribute("data-attr"),s=g.getAttribute("data-multiplier")||1;s=parseFloat(s);
s=g.value*s;if(!svgedit.units.isValidUnit(n,s,Q)){a.alert(uiStrings.notification.invalidAttrValGiven);g.value=Q.getAttribute(n);return false}h.changeSelectedAttributeNoUndo(n,s)};a("#palette").mouseover(function(){var g=a('<input type="hidden">');a(this).append(g);g.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var g=a("#tool_stroke").hasClass("active"),n=g?"stroke":"fill",s=a(this).attr("data-rgb"),A=null;if(s==="transparent"||s==="initial"||s==="#none"){s=
"none";A=new a.jGraduate.Paint}else A=new a.jGraduate.Paint({alpha:100,solidColor:s.substr(1)});b.paintBox[n].setPaint(A);if(g){h.setColor("stroke",s);s!="none"&&h.getStrokeOpacity()!=1&&h.setPaintOpacity("stroke",1)}else{h.setColor("fill",s);s!="none"&&h.getFillOpacity()!=1&&h.setPaintOpacity("fill",1)}}).bind("contextmenu",function(g){g.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");k()},function(){a(".stroke_tool").css("display",
"none");a(this).removeClass("expanded");k()});var Ua=function(g,n){if(a(g).hasClass("disabled"))return false;if(a(g).parent().hasClass("tools_flyout"))return true;var s=s||"normal";n||a(".tools_flyout").fadeOut(s);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(g).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var g=null,n=null,s=H[0],A=false,F=false;a("#svgcanvas").on("mousemove mouseup touchend",
function(J){if(A!==false){s.scrollLeft-=J.clientX-g;s.scrollTop-=J.clientY-n;g=J.clientX;n=J.clientY;if(J.type==="mouseup"||J.type==="touchend")A=false;return false}}).on("mousedown touchmove",function(J){if(J.button===1||F===true||J.originalEvent.touches&&J.originalEvent.touches.length>=2){A=true;g=J.clientX;n=J.clientY;return false}});a(window).mouseup(function(){A=false});a(document).bind("keydown","space",function(J){J.preventDefault();h.spaceKey=F=true}).bind("keyup","space",function(J){J.preventDefault();
h.spaceKey=F=false}).bind("keydown","alt",function(){h.getMode()==="zoom"&&H.addClass("out")}).bind("keyup","alt",function(){h.getMode()==="zoom"&&H.removeClass("out")})})();var tb=a(".menu"),eb=function(g){g.target.style.background="#fff";setTimeout(function(){g.target.style.background="#ddd"},50);setTimeout(function(){g.target.style.background="#fff"},150);setTimeout(function(){g.target.style.background="#ddd"},200);setTimeout(function(){g.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},
220);return false};a(".menu_item").on("mousedown touchstart",function(g){eb(g)});a("svg, body").on("mousedown touchstart",function(g){if(g.target.nodeName.toLowerCase()!=="input")if(!a(g.target).hasClass("menu_title")&&!a(g.target).parent().hasClass("menu_title"))!a(g.target).hasClass("disabled")&&a(g.target).hasClass("menu_item")?eb(g):a("#menu_bar").removeClass("active")});a("#workarea").on("mousewheel",function(g,n,s,A){if(g.altKey){g.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+
A*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");tb.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){tb.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(g,n,s){if(a(g).length!=0){var A=a(g).find("button"),F=a(g).find("ul").attr("id",a(g)[0].id+"-list");s||a("#option_lists").append(F);var J=false;s&&a(g).addClass("dropup");F.find("li").bind("mouseup",n);a(window).mouseup(function(){if(!J){A.removeClass("down");
F.hide()}J=false});A.bind("mousedown",function(){if(A.hasClass("down")){A.removeClass("down");F.hide()}else{A.addClass("down");if(!s){var L=a(g).offset();F.css({top:L.top,left:L.left-110})}F.show();J=true}}).hover(function(){J=true}).mouseout(function(){J=false})}};var Va=function(g,n,s,A){var F=a(g);n=a(n);var J=false,L=A.dropUp;L&&a(g).addClass("dropup");n.find("li").bind("mouseup",function(){if(A.seticon){Ib("#cur_"+F[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}s.apply(this,
arguments)});a(window).mouseup(function(){if(!J){F.removeClass("down");n.hide();n.css({top:0,left:0})}J=false});n.height();a(g).bind("mousedown",function(){var Z=a(g).offset();if(L){Z.top-=n.height();Z.left+=8}else Z.top+=a(g).height();a(n).offset(Z);if(F.hasClass("down")){F.removeClass("down");n.hide();n.css({top:0,left:0})}else{F.addClass("down");n.show();J=true;return false}}).hover(function(){J=true}).mouseout(function(){J=false});A.multiclick&&n.mousedown(function(){J=true})};a("#font_family_dropdown").change(function(){var g=
this.options[this.selectedIndex].value,n=this.options[this.selectedIndex].text;a("#preview_font").html(n).css("font-family",g);a("#font_family").val(g).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var g=this.id.replace("tool_pos","").charAt(0);h.alignSelectedElements(g,"page")})});(function(){var g,n=function(){a(g).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){g=this;ga="toolbars";H.mousedown(n)}).blur(function(){ga=
"canvas";H.unbind("mousedown",n);h.getMode()=="textedit"&&a("#text").focus()})})();var Wa=function(){Ua("#tool_select")&&h.setMode("select")},Ba=function(){Ua("#tool_fhpath")&&h.setMode("fhpath")},va=function(){Ua("#tool_line")&&h.setMode("line")},cb=function(){Ua("#tool_rect")&&h.setMode("rect")},Ka=function(){Ua("#tool_ellipse")&&h.setMode("ellipse")},Ta=function(){Ua("#tool_image")&&h.setMode("image")},Ca=function(){Ua("#tool_zoom")&&h.setMode("zoom")},gb=function(){if(Ua("#tool_zoom")){yb();ea()}},
pb=function(){Ua("#tool_text")&&h.setMode("text")},Xa=function(){Ua("#tool_path")&&h.setMode("path")},Ya=function(){if(Q!=null||Y)h.deleteSelectedElements()},ub=function(){if(Q!=null||Y){window.event.type==="keydown"&&$a(a("#edit_menu"));h.cutSelectedElements()}},ta=function(){if(Q!=null||Y){window.event.type==="keydown"&&$a(a("#edit_menu"));h.copySelectedElements()}},jb=function(){window.event.type==="keydown"&&$a(a("#edit_menu"));var g=h.getZoom(),n=(H[0].scrollLeft+H.width()/2)/g-h.contentW;g=
(H[0].scrollTop+H.height()/2)/g-h.contentH;h.pasteElements("point",n,g)},fb=function(){if(Q!=null){window.event.type==="keydown"&&$a(a("#object_menu"));h.moveToTopSelectedElement()}},sb=function(){if(Q!=null){window.event.type==="keydown"&&$a(a("#object_menu"));h.moveToBottomSelectedElement()}},kb=function(){if(Q!=null){window.event.type==="keydown"&&$a(a("#object_menu"));h.moveUpDownSelected("Up")}},db=function(){if(Q!=null){window.event.type==="keydown"&&$a(a("#object_menu"));h.moveUpDownSelected("Down")}},
mb=function(g){if(Q!=null){window.event.type==="keydown"&&$a(a("#object_menu"));h.moveUpDownSelected(g)}},qb=function(){if(Q!=null){h.convertToPath();elems=h.getSelectedElems();h.selectorManager.requestSelector(elems[0]).reset(elems[0]);h.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");h.setMode("pathedit");q.toEditMode(elems[0]);h.clearSelection();Ia()}},vb=function(){Q!=null&&q.reorient()},wb=function(){if(Q!=null||Y)a.prompt(uiStrings.notification.enterNewLinkURL,
"http://",function(g){g&&h.makeHyperlink(g)})},ia=function(g,n){if(Q!=null||Y){if(curConfig.gridSnapping){var s=h.getZoom()*curConfig.snappingStep;g*=s;n*=s}a("input").blur();h.moveSelectedElements(g,n)}},aa=function(){var g=!a("#tool_node_link").hasClass("checked");g?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);q.linkControlPoints(g)},ka=function(){q.getNodePoint()&&q.clonePathNode()},N=
function(){q.getNodePoint()&&q.deletePathNode()},P=function(){var g=a("#tool_add_subpath"),n=!g.hasClass("push_button_pressed");n?g.addClass("push_button_pressed").removeClass("tool_button"):g.removeClass("push_button_pressed").addClass("tool_button");q.addSubPath(n)},da=function(){q.opencloseSubPath()},Ea=function(){h.cycleElement(1)},Na=function(){h.cycleElement(0)},Ra=function(g,n){if(!(Q==null||Y)){g||(n*=-1);var s=a("#angle").val()*1+n;h.setRotationAngle(s);Ia()}},bb=function(){var g=curConfig.dimensions;
a.confirm(uiStrings.notification.QwantToClear,function(n){if(n){ea();h.clear();h.setResolution(g[0],g[1]);D(true);yb();Ia();V();h.runExtensions("onNewDocument")}})},ob=function(){h.setBold(!h.getBold());Ia()},Sa=function(){h.setItalic(!h.getItalic());Ia()},nb=function(){if(!c.pngsave){var g=uiStrings.notification.loadingImage;U=window.open("data:text/html;charset=utf-8,<title>"+g+"</title><h1>"+g+"</h1>")}window.canvg?h.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",
function(){h.rasterExport()})})},Pa=function(){h.open()},rb=function(){},$a=function(g){var n=g.prev();n.css("background","#09f");setTimeout(function(){n.css("background","")},200)},Eb=function(){if(K.getUndoStackSize()>0){window.event.type==="keydown"&&$a(a("#edit_menu"));K.undo()}},Db=function(){if(K.getRedoStackSize()>0){window.event.type==="keydown"&&$a(a("#edit_menu"));K.redo()}},ab=function(){if(Y)h.groupSelectedElements();else Q&&h.ungroupSelectedElement()},La=function(){window.event.type===
"keydown"&&$a(a("#edit_menu"));h.cloneSelectedElements(20,20)},Nb=function(){var g=this.id.replace("tool_align","").charAt(0);h.alignSelectedElements(g,a("#align_relative_to").val())},Kb=function(){var g=document.querySelector("#tool_stroke rect"),n=document.querySelector("#tool_fill rect"),s=n.getAttribute("fill"),A=g.getAttribute("fill");g=parseFloat(g.getAttribute("stroke-opacity"));if(isNaN(g))g=100;n=parseFloat(n.getAttribute("fill-opacity"));if(isNaN(n))n=100;A=Ga(A,g,"stroke");s=Ga(s,n,"fill");
b.paintBox.fill.setPaint(A,true);b.paintBox.stroke.setPaint(s,true)},yb=function(g){var n=h.getResolution();g=g?n.zoom*g:1;a("#zoom").val(g*100);h.setZoom(g);Jb();D(true)},Lb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");H.toggleClass("wireframe");if(!C){var g=a("#wireframe_rules");g.length?g.empty():a('<style id="wireframe_rules"></style>').appendTo("head");Jb()}},Ob=function(){var g=
!a("#tool_snap").hasClass("push_button_pressed");g?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=g},Ab=function(){window.self!=window.top&&top.exit_fullscreen()},Gb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",
true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},Jb=function(){if(!C){var g="#workarea.wireframe #svgcontent * { stroke-width: "+1/h.getZoom()+"px; }";a("#wireframe_rules").text(H.hasClass("wireframe")?g:"")}},zb=function(g,n){if(!xa){xa=true;a("#save_output_btns").toggle(!!n);a("#tool_source_back").toggle(!n);var s=oa=h.getSvgString();a("#svg_source_textarea").val(s);a("#svg_source_editor").fadeIn();a("#svg_source_textarea").focus().select()}},ib=function(){if(xa){if(h.setSvgString(a("#svg_source_textarea").val())){h.clearSelection();
e();yb();V()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(g){if(!g)return false;h.clearSelection();e();yb();V()});ea()}},Ib=b.setIcon=function(g,n){var s=typeof n==="string"?a.getSvgIcon(n,true):n.clone();s?a(g).find("img").replaceWith(s):console.log("NOTE: Icon image missing: "+n)},Hb;Hb=function(){var g=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=document.getElementsByTagName("script")[0],s;for(s in n.style)if(g.test(s))return s.match(g)[0];if("WebkitOpacity"in n.style)return"Webkit";
if("KhtmlOpacity"in n.style)return"Khtml";return""}();var Bb=function(g,n){Hb.toLowerCase();var s=["top","left","bottom","right"];g.each(function(){for(var A=a(this),F=A.outerWidth()*(n-1),J=A.outerHeight()*(n-1),L=0;L<4;L++){var Z=s[L],ba=A.data("orig_margin-"+Z);if(ba==null){ba=parseInt(A.css("margin-"+Z));A.data("orig_margin-"+Z,ba)}ba=ba*n;if(Z==="right")ba+=F;else if(Z==="bottom")ba+=J;A.css("margin-"+Z,ba)}})},hb=b.setIconSize=function(g,n){if(!(g==u.size&&!n)){var s=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"),
A=1;A=typeof g=="number"?g:{s:0.75,m:1,l:1.25,xl:1.5}[g];b.tool_scale=M=A;ma();var F=s.parents(":hidden");F.css("visibility","hidden").show();Bb(s,A);F.css("visibility","visible").hide();s=a("#tool_size_rules");if(s.length)s.empty();else s=a('<style id="tool_size_rules"></style>').appendTo("head");if(g!="m"){var J="";a.each(cssResizeRules,function(L,Z){L="#svg_editor "+L.replace(/,/g,", #svg_editor");J+=L+"{";a.each(Z,function(ba,T){if(typeof T==="number")var X=T*A+"px";else if(T[g]||T.all)X=T[g]||
T.all;J+=ba+":"+X+";"});J+="}"});F="-"+Hb.toLowerCase()+"-";J+="#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{"+F+"transform: scale("+A+");} #svg_editor div.toolset .toolset {"+F+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+F+"transform: scale("+1/A+");}";s.text(J)}ma()}},Fb=function(){a("#dialog_box").hide();if(xa){if(xa)oa!==
a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(g){g&&e()}):e();k()}else ja&&h.leaveContext()},e=function(){a("#svg_source_editor").hide();xa=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var k=a.noop;a(window).resize(function(){D()});(function(){H.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=H[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=H[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
a("#change_image_url").click(function(){var g=h.getHref(Q);g=g.indexOf("data:")===0?"":g;a.prompt(uiStrings.notification.enterNewImgURL,g,function(n){n&&Ja(n)})});var m=function(g){var n=g[0].id=="stroke_color"?"stroke":"fill",s=g[0].id=="canvas_color";if(s)n="canvas";var A=b.paintBox[n].paint;g=n=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";s=s?{right:175,top:50}:{left:50,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",
containment:"window"}).removeAttr("style").css(s).jGraduate({paint:A,window:{pickerTitle:g},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(F){A=new a.jGraduate.Paint(F);b.paintBox[n].setPaint(A);h.setPaint(n,A);a("#color_picker").hide()},function(){a("#color_picker").hide()})};l=function(g,n){var s=document.getElementById("canvas_background"),A={color:"fff",opacity:1};if(n=="stroke")A=curConfig.initStroke;if(n=="fill")A=curConfig.initFill;if(n=="canvas"&&s)if(s=s.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))A=
{color:("0"+parseInt(s[1],10).toString(16)).slice(-2)+("0"+parseInt(s[2],10).toString(16)).slice(-2)+("0"+parseInt(s[3],10).toString(16)).slice(-2),opacity:1};s=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+A.color+'" opacity="'+A.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;s=a(g)[0].appendChild(document.importNode(s,true));n==="canvas"?s.setAttribute("width",60.5):
s.setAttribute("width","100%");this.rect=s.firstChild;this.defs=s.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:A.color});this.type=n;this.setPaint=function(F,J){this.paint=F;var L="none",Z=F.type,ba=F.alpha/100;switch(Z){case "solidColor":L=F[Z]=="none"||F[Z]=="one"?"none":"#"+F[Z];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(F[Z]);L="url(#"+(this.grad.id="gradbox_"+
this.type)+")"}this.rect.setAttribute("fill",L);this.rect.setAttribute("opacity",ba);if(J){h.setColor(this.type,L,true);h.setPaintOpacity(this.type,ba,true)}if(this.type=="canvas")if(Z=document.getElementById("canvas_background")){Aa=h.getResolution();Z.setAttribute("x",-1);Z.setAttribute("y",-1);Z.setAttribute("width",Aa.w+2);Z.setAttribute("height",Aa.h+2);Z.setAttribute("fill",L)}else Ha(L)};this.update=function(F){if(Q){var J=this.type;switch(Q.tagName){case "use":case "image":case "foreignObject":return;
case "g":case "a":for(var L=null,Z=Q.getElementsByTagName("*"),ba=0,T=Z.length;ba<T;ba++){var X=Z[ba].getAttribute(J);if(ba===0)L=X;else if(L!==X){L=null;break}}if(L===null){Z=null;return}Z=L;L=1;break;default:L=parseFloat(Q.getAttribute(J+"-opacity"));if(isNaN(L))L=1;Z=J==="fill"?"black":"none";Z=Q.getAttribute(J)||Z}if(F){h.setColor(J,Z,true);h.setPaintOpacity(J,L,true)}L*=100;this.setPaint(Ga(Z,L,J))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var F=
new a.jGraduate.Paint({copy:this.paint});h.setPaint(n,F)}}};b.paintBox.fill=new l("#fill_color","fill");b.paintBox.stroke=new l("#stroke_color","stroke");b.paintBox.canvas=new l("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);l=b.paintBox.fill.rect.cloneNode(false);l.setAttribute("style","vector-effect:non-scaling-stroke");var C=l.style.vectorEffect==="non-scaling-stroke";l.removeAttribute("style");l=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof l.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(l).remove();setTimeout(function(){h.embedImage("images/placeholder.svg",function(g){if(!g){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);u.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))m(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))m(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){m(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");m(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");m(a("#fill_color"))});a("#zoom_select").on("change",function(){var g=this.options[this.selectedIndex].text;g=g.split("%")[0];a("#zoom").val(g).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){H.css("line-height",H.height()+"px")});var z=function(){var g=a("#canvas_width"),n=a("#canvas_height"),s=g.val(),A=n.val();if(s!="fit"&&!svgedit.units.isValidUnit("width",s)){a.alert(uiStrings.notification.invalidAttrValGiven);g.parent().addClass("error");return false}g.parent().removeClass("error");if(A!="fit"&&!svgedit.units.isValidUnit("height",A)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");
if(!h.setResolution(s,A)){a.alert(uiStrings.notification.noContentToFitTo);s=h.getResolution();g.val(s.w);n.val(s.h);return false}D()};a("#resolution").change(function(){var g=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){g.value="fit";n.value="fit";z();var s=h.getResolution();g.value=s.w;n.value=s.h}else{var A=this.value.split("x");A[0]=parseInt(A[0]);A[1]=parseInt(A[1]);var F=A[0]-g.value,J=A[1]-n.value,L=Date.now(),Z=function(ba){ba=(ba-L)/1E3;ba=
Math.pow(ba-1,3)+1;g.value=(A[0]-F+ba*F).toFixed(0);n.value=(A[1]-J+ba*J).toFixed(0);z();if(ba>=1){ba=h.getResolution();a("#canvas_width").val(ba.w.toFixed());a("#canvas_height").val(ba.h.toFixed());a("#resolution_label").html("<div class='pull'>"+ba.w+"<span>\u00d7</span></br>"+ba.h+"</div>")}else requestAnimationFrame(Z)};Z(Date.now())}else{a("#resolution_label").html("Custom");g.removeAttribute("readonly");g.focus();g.select();if(g.value=="fit"){g.value=100;n.value=100}}});a("#zoom").change(function(){Fa(this)});
a("input,select").attr("autocomplete","off");var G=function(){var g=[{sel:"#tool_select",fn:Wa,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Ba,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:va,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:cb,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ka,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Xa,evt:"click",key:["P",true]},{sel:"#tool_text",fn:pb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:Ta,evt:"mouseup"},
{sel:"#tool_zoom",fn:Ca,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:bb,evt:"mouseup",key:[B+"N",true]},{sel:"#tool_save",fn:function(){xa?ib():h.save({images:u.img_save,round_digits:6})},evt:"mouseup",key:[B+"S",true]},{sel:"#tool_export",fn:nb,evt:"mouseup"},{sel:"#tool_open",fn:Pa,evt:"mouseup"},{sel:"#tool_import",fn:rb,evt:"mouseup"},{sel:"#tool_source",fn:zb,evt:"click",key:[B+"U",true]},{sel:"#tool_wireframe",fn:Lb,evt:"click"},{sel:"#tool_snap",fn:Ob,evt:"click"},{sel:"#tool_rulers",
fn:Gb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:Fb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:ib,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:Ya,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:vb,evt:"click"},{sel:"#tool_node_link",fn:aa,evt:"click"},{sel:"#tool_node_clone",fn:ka,evt:"click"},{sel:"#tool_node_delete",fn:N,evt:"click"},{sel:"#tool_openclose_path",fn:da,evt:"click"},
{sel:"#tool_add_subpath",fn:P,evt:"click"},{sel:"#tool_move_top",fn:fb,evt:"click",key:B+"shift+up"},{sel:"#tool_move_bottom",fn:sb,evt:"click",key:B+"shift+down"},{sel:"#tool_move_up",fn:kb,evt:"click",key:[B+"up",true]},{sel:"#tool_move_down",fn:db,evt:"click",key:[B+"down",true]},{sel:"#tool_topath",fn:qb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:wb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:La,evt:"click",key:[B+"D",true]},{sel:"#tool_group",fn:ab,evt:"click",key:[B+
"G",true]},{sel:"#tool_ungroup",fn:ab,evt:"click",key:B+"shift+G"},{sel:"#tool_unlink_use",fn:ab,evt:"click"},{sel:"[id^=tool_align]",fn:Nb,evt:"click"},{sel:"#tool_undo",fn:Eb,evt:"click",key:B+"z"},{sel:"#tool_redo",fn:Db,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:ub,evt:"click",key:[B+"x",true]},{sel:"#tool_copy",fn:ta,evt:"click",key:B+"c"},{sel:"#tool_paste",fn:jb,evt:"click",key:B+"v"},{sel:"#tool_switch",fn:Kb,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:ob,evt:"mousedown",key:[B+
"B",true]},{sel:"#tool_italic",fn:Sa,evt:"mousedown",key:[B+"I",true]},{sel:"#copy_save_done",fn:Fb,evt:"click"},{key:"ctrl+left",fn:function(){Ra(0,1)}},{key:"ctrl+right",fn:function(){Ra(1,1)}},{key:"ctrl+shift+left",fn:function(){Ra(0,5)}},{key:"ctrl+shift+right",fn:function(){Ra(1,5)}},{key:"shift+O",fn:Na},{key:"shift+P",fn:Ea},{key:[B+"+",true],fn:function(){yb(2)}},{key:[B+"-",true],fn:function(){yb(0.5)}},{key:["up",true],fn:function(){ia(0,-1)}},{key:["down",true],fn:function(){ia(0,1)}},
{key:["left",true],fn:function(){ia(-1,0)}},{key:["right",true],fn:function(){ia(1,0)}},{key:"shift+up",fn:function(){ia(0,-10)}},{key:"shift+down",fn:function(){ia(0,10)}},{key:"shift+left",fn:function(){ia(-10,0)}},{key:"shift+right",fn:function(){ia(10,0)}},{key:["alt+up",true],fn:function(){h.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){h.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){h.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){h.cloneSelectedElements(1,
0)}},{key:["alt+shift+up",true],fn:function(){h.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){h.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){h.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){h.cloneSelectedElements(10,0)}},{key:B+"A",fn:function(){h.selectAllInCurrentLayer()}},{key:"I",fn:function(){var s=a(".tool_button_current");if(s.length&&s[0].id!=="tool_eyedropper"){s.removeClass("tool_button_current").addClass("tool_button");
a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}h.setMode("eyedropper")}},{key:B+"shift+z",fn:Db},{key:"esc",fn:Ab}],n={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var s={};a.each(g,function(A,F){if(F.sel){var J=a(F.sel);if(J.length==0)return true;if(F.evt){if(svgedit.browser.isTouch()&&F.evt==="click")F.evt="mousedown";J[F.evt](F.fn)}if(F.parent&&a(F.parent+"_show").length!=0){var L=a(F.parent);L.length||(L=qa(F.parent.substr(1)));
L.append(J);a.isArray(s[F.parent])||(s[F.parent]=[]);s[F.parent].push(F)}}if(F.key){var Z=F.fn,ba=false;if(a.isArray(F.key)){L=F.key[0];if(F.key.length>1)ba=F.key[1]}else L=F.key;L+="";svgedit.browser.isMac&&L.indexOf("+")!=-1&&L.split("+")[0]=="ctrl"&&L.replace("ctrl","cmd");a.each(L.split("/"),function(X,ha){a(document).bind("keydown",ha,function(pa){Z();ba&&pa.preventDefault();return false})});if(F.sel&&!F.hidekey&&J.attr("title")){var T=J.attr("title").split("[")[0]+" ("+L+")";n[L]=F.sel;J.parents("#main_menu").length||
J.attr("title",T)}}});na(s);a(window).bind("keydown","tab",function(A){if(ga==="canvas"){A.preventDefault();Ea()}}).bind("keydown","shift+tab",function(A){if(ga==="canvas"){A.preventDefault();Na()}});a("#tool_zoom").dblclick(gb)},setTitles:function(){a.each(n,function(s,A){var F=a(A).parents("#main_menu").length;a(A).each(function(){var J=F?a(this).text().split(" [")[0]:this.title.split(" [")[0],L="";a.each(s.split("/"),function(Z,ba){var T=ba.split("+"),X="";if(T.length>1){X=T[0]+"+";ba=T[1]}L+=
(Z?"/":"")+X+(uiStrings["key_"+ba]||ba)});if(F)this.lastChild.textContent=J+" ["+L+"]";else this.title=J+" ["+L+"]"})})},getButtonData:function(s){var A;a.each(g,function(F,J){if(J.sel===s)A=J});return A}}}();G.setAll();b.ready(function(){var g=curConfig.initTool,n=a("#tools_left, #svg_editor .tools_flyout"),s=n.find("#tool_"+g);g=n.find("#"+g);(s.length?s:g.length?g:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});
a("#canvas_height").dragInput({min:10,max:null,step:10,callback:z,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:z,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,max:null,
step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").dragInput({min:1,
max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(g){var n=g.value;if(n==0&&
Q&&["line","polyline"].indexOf(Q.nodeName)>=0)n=g.value=1;h.setStrokeWidth(n)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(g){h.setRotationAngle(g.value);rotateCursor(g.value);a("#tool_reorient").toggleClass("disabled",g.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(g){h.setFontSize(g.value)},cursor:true,stepfunc:function(g,n){var s=g.value-0,A=s+n,F=A>=s;if(n===0)return s;return s>=
24?F?Math.round(s*1.1):Math.round(s/1.1):s<=1?F?s*2:s/2:A},dragAdjust:0.15});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(g){val=g.value;a("#blur").val(val);h.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(h.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(g){switch(g){case "delete":Ya();break;case "cut":ub();break;case "copy":ta();break;
case "paste":h.pasteElements();break;case "paste_in_place":h.pasteElements("in_place");break;case "group":h.groupSelectedElements();break;case "ungroup":h.ungroupSelectedElement();break;case "move_front":fb();break;case "move_up":mb("Up");break;case "move_down":mb("Down");break;case "move_back":sb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(g)&&svgedit.contextmenu.getCustomHandler(g).call()}});a(".contextMenu li").mousedown(function(g){g.preventDefault()});a("#cmenu_canvas li").disableContextMenu();
R.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(K.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(g){a("#main_menu").hide();K.getUndoStackSize()===0?g(true):a.confirm(uiStrings.notification.QwantToOpen,g)};if(window.FileReader){l=a('<input type="file">').change(function(){var g=this;b.openPrep(function(n){if(n){h.clear();if(g.files.length==1){n=new FileReader;
n.onloadend=function(s){p(s.target.result);D()};n.readAsText(g.files[0])}}})});a("#tool_open").show().prepend(l);l=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var g=new FileReader;g.onloadend=function(n){h.importSvgString(n.target.result,true);D()};g.readAsText(this.files[0])}});a("#tool_import").show().prepend(l)}var D=b.updateCanvas=function(g,n){var s=H.width(),A=H.height(),F=s,J=A,L=h.getZoom(),Z=a("#svgcanvas"),ba={x:H[0].scrollLeft+F/2,y:H[0].scrollTop+
J/2},T=curConfig.canvas_expansion;s=Math.max(F,h.contentW*L*T);A=Math.max(J,h.contentH*L*T);s==F&&A==J?H.css("overflow","hidden"):H.css("overflow","scroll");T=Z.height()/2;var X=Z.width()/2;Z.width(s).height(A);var ha=A/2,pa=s/2,fa=h.updateCanvas(s,A),ua=pa/X;s=s/2-F/2;A=A/2-J/2;if(n){n.x+=fa.x;n.y+=fa.y}else n={x:pa+(ba.x-X)*ua,y:ha+(ba.y-T)*ua};if(g)if(h.contentW>H.width()){H[0].scrollLeft=fa.x-10;H[0].scrollTop=fa.y-10}else{H[0].scrollLeft=s;H[0].scrollTop=A}else{H[0].scrollLeft=n.x-F/2;H[0].scrollTop=
n.y-J/2}if(curConfig.showRulers){F=Z;L=L;document.getElementById("workarea");document.getElementById("title_show");L||(L=h.getZoom());F||(F=a("#svgcanvas"));J=h.getContentElem();Z=svgedit.units.getTypeMap()[curConfig.baseUnit];for(ba=0;ba<2;ba++){ha=(T=ba===0)?"x":"y";s=T?"width":"height";X=J.getAttribute(ha)-0;ha=a("#ruler_"+ha+" canvas:first");$hcanv=ha.clone();ha.replaceWith($hcanv);A=$hcanv[0];pa=ha=F[s]()*2;A.parentNode.style[s]=pa+"px";fa=0;var Ma;ua=A.getContext("2d");ua.fillStyle="rgb(200,0,0)";
ua.fillRect(0,0,A.width,A.height);$hcanv.siblings().remove();if(ha>=3E4){var sa=parseInt(ha/3E4)+1;Ma=Array(sa);Ma[0]=ua;for(var ra=1;ra<sa;ra++){A[s]=3E4;var Za=A.cloneNode(true);A.parentNode.appendChild(Za);Ma[ra]=Za.getContext("2d")}Za[s]=ha%3E4;ha=3E4}A[s]=ha;s=Z*L;var Qa=50/s;A=1;for(ra=0;ra<w.length;ra++){A=sa=w[ra];if(Qa<=sa)break}Qa=A*s;ua.font="normal 9px 'Lucida Grande', sans-serif";ua.fillStyle="#777";for(var Oa=X/s%A*s,lb=Oa-Qa;Oa<pa;Oa+=Qa){lb+=Qa;ra=Math.round(Oa)+0.5;if(T){ua.moveTo(ra,
15);ua.lineTo(ra,0)}else{ua.moveTo(15,ra);ua.lineTo(0,ra)}sa=(lb-X)/s;if(A>=1)ra=Math.round(sa);else{ra=(A+"").split(".")[1].length;ra=sa.toFixed(ra)-0}if(ra!==0&&ra!==1E3&&ra%1E3===0)ra=ra/1E3+"K";if(T){ua.fillText(ra,Oa+2,8);ua.fillStyle="#777"}else{sa=(ra+"").split("");for(ra=0;ra<sa.length;ra++){ua.fillText(sa[ra],1,Oa+9+ra*9);ua.fillStyle="#777"}}sa=Qa/10;for(ra=1;ra<10;ra++){var xb=Math.round(Oa+sa*ra)+0.5;if(Ma&&xb>ha){fa++;ua.stroke();if(fa>=Ma.length){ra=10;Oa=pa;continue}ua=Ma[fa];Oa-=3E4;
xb=Math.round(Oa+sa*ra)+0.5}var Cb=ra%2?12:10;if(T){ua.moveTo(xb,15);ua.lineTo(xb,Cb)}else{ua.moveTo(15,xb);ua.lineTo(Cb,xb)}}}ua.strokeStyle="#666";ua.stroke()}H.scroll()}},w=[];for(l=0.1;l<1E5;l*=10){w.push(1*l);w.push(2*l);w.push(5*l)}D(true);try{var E=function(g){if(window.JSON&&JSON.stringify)return JSON.stringify(g);var n=arguments.callee;if(typeof g=="boolean"||typeof g=="number")return g+"";else if(typeof g=="string")return'"'+g.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
function(F){return"\\u"+("0000"+F.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(g.length){for(var s=0;s<g.length;s++)g[s]=n(g[s]);return"["+g.join(",")+"]"}else{s=[];for(var A in g)s.push(n(A)+":"+n(g[A]));return"{"+s.join(",")+"}"}};window.addEventListener("message",function(g){var n=parseInt(g.data.substr(0,g.data.indexOf(";")));try{g.source.postMessage("SVGe"+n+";"+E(eval(g.data)),"*")}catch(s){g.source.postMessage("SVGe"+n+";error:"+s.message,"*")}},false)}catch(I){window.embed_error=I}a(function(){window.svgCanvas=
h;h.ready=svgEditor.ready});b.setLang=function(g,n){a.pref("lang",g);a("#lang_select").val(g);if(n){h.runExtensions("langChanged",g);la();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,A){a(A).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 f=[];b.ready=function(d){o?d():f.push(d)};b.runCallbacks=function(){a.each(f,function(){this()});o=true};b.loadFromString=function(d){b.ready(function(){p(d)})};b.loadFromURL=function(d,l){l||(l={});var v=l.cache,B=l.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!v,success:function(q){p(q,B)},error:function(q,K,S){q.status!=404&&q.responseText?p(q.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+S+"",B)}})})};b.loadFromDataURI=function(d){b.ready(function(){var l=
d.substring(26);p(svgedit.utilities.decode64(l))})};b.addExtension=function(){var d=arguments;a(function(){h&&h.addExtension.apply(this,d)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var p=this.dragCfg.dragAdjust,h=$(this).parent(),b=$(this),o=this.dragCfg.height,u=this.dragCfg.min,c=this.dragCfg.max,f=this.dragCfg.step,d=c-u>0?(c-u)/f:200,l=d/o*f,v=0,B=this.getAttribute("data-attr"),q=svgEditor.canvas,K=q.getSelectedElems(),S=svgedit.browser.isTouch(),O=true,H=d&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(h):false;b.attr("readonly","readonly");H&&!isNaN(this.dragCfg.start)&&H.css("top",this.dragCfg.start*
-1/l+o);this.adjustValue=function(R,U){var M;R=parseFloat(R);if(isNaN(this.value))M=this.dragCfg.reset;else if($.isFunction(this.dragCfg.stepfunc)){M=this.dragCfg.stepfunc(this,R);console.log(M)}else M=Number((Number(this.value)+Number(R)).toFixed(5));if(c!==null)M=Math.min(M,c);if(u!==null)M=Math.max(M,u);H&&this.updateCursor(M);this.value=M;h.attr("data-value",M);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,U)};h.toggleClass("draginput",h.is("label"));this.move=function(R,U,M){if(S)R=
R.originalEvent.touches[0];if(v===0)v=U;U=(R.pageY-v)*-1;v=R.pageY;M=U*l*p;this.adjustValue(M.toFixed(f<1?1:0))};this.stop=function(){$("body").removeClass("dragging");h.removeClass("active");O=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");v=0;if(K[0]){var R=q.undoMgr.finishUndoableChange();R.isEmpty()||q.undoMgr.addCommandToHistory(R)}this.adjustValue(0,O)};this.updateCursor=function(){var R=parseFloat(this.value)*-1/l+o;H.css("top",R)};this.start=
function(R){if(S)R=R.originalEvent.touches[0];var U=R.pageY,M=this.value,ga=this;q.undoMgr.beginUndoableChange(B,K);$("body").addClass("dragging");h.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(oa){ga.move(oa,U,parseFloat(M))});$(window).bind("mouseup.draginput touchend.draginput",function(){ga.stop()})};$(this).attr("readonly","readonly").attr("data-scale",l).attr("data-domain",o).attr("data-cursor",H!=false).bind("mousedown touchstart",function(R){this.blur();
this.start(R)}).bind("dblclick taphold",function(){this.removeAttribute("readonly","readonly");this.focus();this.select()}).keydown(function(R){switch(R.keyCode){case 13:this.adjustValue(0);this.blur()}}).focus(function(){this.getAttribute("readonly")==="readonly"&&this.blur()}).blur(function(){this.setAttribute("readonly","readonly")}).bind("mousewheel",function(R,U,M,ga){O&&q.undoMgr.beginUndoableChange(B,K);O=false;clearTimeout(window.undoTimeout);window.undoTimeout=setTimeout(function(){oa.stop()},
1E3);var oa=this;if(ga>0)this.adjustValue(this.dragCfg.step);else ga<0&&this.adjustValue(-this.dragCfg.step);R.preventDefault()})})};$.fn.dragInput.updateCursor=function(a){var p=parseFloat(a.value),h=parseFloat(a.getAttribute("data-scale")),b=parseFloat(a.getAttribute("data-domain"));p=p*-1/h+b+"px";a=a.parentNode.lastChild;if(a.className=="draginput_cursor")a.style.top=p};svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var p=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var h=p.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+p.id+"'>"+p.label+"<span class='shortcut'>"+h+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(p){if(p&&p.id&&p.label&&p.action&&typeof p.action=="function")if(p.id in a.contextMenuExtensions)console.error('Cannot add extension "'+p.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+p.id+", label:"+p.label+"}");a.contextMenuExtensions[p.id]=p}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=
function(p){return a.contextMenuExtensions[p]&&true};svgedit.contextmenu.getCustomHandler=function(p){return a.contextMenuExtensions[p].action}})();(function(a,p){function h(o){return!a(o).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function b(o,u){var c=o.nodeName.toLowerCase();if("area"===c){c=o.parentNode;var f=c.name;if(!o.href||!f||c.nodeName.toLowerCase()!=="map")return false;c=a("img[usemap=#"+f+"]")[0];return!!c&&h(c)}return(/input|select|textarea|button|object/.test(c)?!o.disabled:"a"==c?o.href||u:u)&&h(o)}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(o,u){return typeof o=="number"?this.each(function(){var c=
this;setTimeout(function(){a(c).focus();u&&u.call(c)},o)}):this._focus.apply(this,arguments)},scrollParent:function(){var o;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?o=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):o=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"))||!o.length?a(document):o},zIndex:function(o){if(o!==p)return this.css("zIndex",o);if(this.length){o=a(this[0]);for(var u;o.length&&o[0]!==document;){u=o.css("position");if(u==="absolute"||u==="relative"||u==="fixed"){u=parseInt(o.css("zIndex"),10);if(!isNaN(u)&&u!==0)return u}o=o.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":
"mousedown")+".ui-disableSelection",function(o){o.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(o,u){function c(v,B,q,K){a.each(f,function(){B-=parseFloat(a.curCSS(v,"padding"+this,true))||0;q&&(B-=parseFloat(a.curCSS(v,"border"+this+"Width",true))||0);K&&(B-=parseFloat(a.curCSS(v,"margin"+this,true))||0)});return B}var f=u==="Width"?["Left","Right"]:["Top","Bottom"],d=u.toLowerCase(),l={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,
outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+u]=function(v){if(v===p)return l["inner"+u].call(this);return this.each(function(){a(this).css(d,c(this,v)+"px")})};a.fn["outer"+u]=function(v,B){if(typeof v!="number")return l["outer"+u].call(this,v);return this.each(function(){a(this).css(d,c(this,v,true,B)+"px")})}}),a.extend(a.expr[":"],{data:function(o,u,c){return!!a.data(o,c[3])},focusable:function(o){return b(o,!isNaN(a.attr(o,"tabindex")))},tabbable:function(o){var u=a.attr(o,
"tabindex"),c=isNaN(u);return(c||u>=0)&&b(o,!c)}}),a(function(){var o=document.body,u=o.appendChild(u=document.createElement("div"));a.extend(u.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=u.offsetHeight===100;a.support.selectstart="onselectstart"in u;o.removeChild(u).style.display="none"}),a.extend(a.ui,{plugin:{add:function(o,u,c){o=a.ui[o].prototype;for(var f in c){o.plugins[f]=o.plugins[f]||[];o.plugins[f].push([u,c[f]])}},call:function(o,u,c){if((u=o.plugins[u])&&
o.element[0].parentNode)for(var f=0;f<u.length;f++)o.options[u[f][0]]&&u[f][1].apply(o.element,c)}},contains:function(o,u){return document.compareDocumentPosition?o.compareDocumentPosition(u)&16:o!==u&&o.contains(u)},hasScroll:function(o,u){if(a(o).css("overflow")==="hidden")return false;var c=u&&u==="left"?"scrollLeft":"scrollTop",f=false;if(o[c]>0)return true;o[c]=1;f=o[c]>0;o[c]=0;return f},isOverAxis:function(o,u,c){return o>u&&o<u+c},isOver:function(o,u,c,f,d,l){return a.ui.isOverAxis(o,c,d)&&
2012-07-31 00:49:46 +00:00
a.ui.isOverAxis(u,f,l)}}))})(jQuery);
2012-07-31 19:01:03 +00:00
(function(a,p){if(a.cleanData){var h=a.cleanData;a.cleanData=function(o){for(var u=0,c;(c=o[u])!=null;u++)try{a(c).triggerHandler("remove")}catch(f){}h(o)}}else{var b=a.fn.remove;a.fn.remove=function(o,u){return this.each(function(){u||(!o||a.filter(o,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(c){}});return b.call(a(this),o,u)})}}a.widget=function(o,u,c){var f=o.split(".")[0],d;o=o.split(".")[1];d=f+"-"+o;c||(c=u,u=a.Widget);a.expr[":"][d]=
function(l){return!!a.data(l,o)};a[f]=a[f]||{};a[f][o]=function(l,v){arguments.length&&this._createWidget(l,v)};u=new u;u.options=a.extend(true,{},u.options);a[f][o].prototype=a.extend(true,u,{namespace:f,widgetName:o,widgetEventPrefix:a[f][o].prototype.widgetEventPrefix||o,widgetBaseClass:d},c);a.widget.bridge(o,a[f][o])};a.widget.bridge=function(o,u){a.fn[o]=function(c){var f=typeof c=="string",d=Array.prototype.slice.call(arguments,1),l=this;c=!f&&d.length?a.extend.apply(null,[true,c].concat(d)):
c;if(f&&c.charAt(0)==="_")return l;f?this.each(function(){var v=a.data(this,o),B=v&&a.isFunction(v[c])?v[c].apply(v,d):v;if(B!==v&&B!==p){l=B;return false}}):this.each(function(){var v=a.data(this,o);v?v.option(c||{})._init():a.data(this,o,new u(c,this))});return l}};a.Widget=function(o,u){arguments.length&&this._createWidget(o,u)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(o,u){a.data(u,this.widgetName,this);this.element=a(u);this.options=
a.extend(true,{},this.options,this._getCreateOptions(),o);var c=this;this.element.bind("remove."+this.widgetName,function(){c.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(o,u){var c=o;if(arguments.length===0)return a.extend({},this.options);if(typeof o=="string"){if(u===p)return this.options[o];c={};c[o]=u}this._setOptions(c);return this},_setOptions:function(o){var u=this;a.each(o,function(c,f){u._setOption(c,f)});return this},_setOption:function(o,u){this.options[o]=u;o==="disabled"&&this.widget()[u?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
u);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(o,u,c){var f,d=this.options[o];c=c||{};u=a.Event(u);u.type=(o===this.widgetEventPrefix?o:this.widgetEventPrefix+o).toLowerCase();u.target=this.element[0];if(o=u.originalEvent)for(f in o)f in u||(u[f]=o[f]);this.element.trigger(u,c);return!(a.isFunction(d)&&d.call(this.element[0],u,c)===false||u.isDefaultPrevented())}}})(jQuery);
(function(a){var p=false;a(document).mouseup(function(){p=false});a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var h=this;this.element.bind("mousedown."+this.widgetName,function(b){return h._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(true===a.data(b.target,h.widgetName+".preventClickEvent")){a.removeData(b.target,h.widgetName+".preventClickEvent");b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
this.widgetName)},_mouseDown:function(h){if(!p){this._mouseStarted&&this._mouseUp(h);this._mouseDownEvent=h;var b=this,o=h.which==1,u=typeof this.options.cancel=="string"&&h.target.nodeName?a(h.target).closest(this.options.cancel).length:false;if(!o||u||!this._mouseCapture(h))return true;(this.mouseDelayMet=!this.options.delay)||(this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay));if(this._mouseDistanceMet(h)&&this._mouseDelayMet(h)){this._mouseStarted=this._mouseStart(h)!==
false;if(!this._mouseStarted){h.preventDefault();return true}}true===a.data(h.target,this.widgetName+".preventClickEvent")&&a.removeData(h.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(c){return b._mouseMove(c)};this._mouseUpDelegate=function(c){return b._mouseUp(c)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);h.preventDefault();return p=true}},_mouseMove:function(h){if(a.browser.msie&&
2012-07-31 00:49:46 +00:00
!(document.documentMode>=9)&&!h.button)return this._mouseUp(h);if(this._mouseStarted){this._mouseDrag(h);return h.preventDefault()}this._mouseDistanceMet(h)&&this._mouseDelayMet(h)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,h)!==false,this._mouseStarted?this._mouseDrag(h):this._mouseUp(h));return!this._mouseStarted},_mouseUp:function(h){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);this._mouseStarted&&
(this._mouseStarted=false,h.target==this._mouseDownEvent.target&&a.data(h.target,this.widgetName+".preventClickEvent",true),this._mouseStop(h));return false},_mouseDistanceMet:function(h){return Math.max(Math.abs(this._mouseDownEvent.pageX-h.pageX),Math.abs(this._mouseDownEvent.pageY-h.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"&&
2012-07-31 19:01:03 +00:00
!/^(?: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(p){var h=this.options;
if(this.helper||h.disabled||a(p.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(p);if(!this.handle)return false;h.iframeFix&&a(h.iframeFix===true?"iframe":h.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(p){var h=this.options;this.helper=
this._createHelper(p);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:p.pageX-this.offset.left,top:p.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
this.originalPosition=this.position=this._generatePosition(p);this.originalPageX=p.pageX;this.originalPageY=p.pageY;h.cursorAt&&this._adjustOffsetFromHelper(h.cursorAt);h.containment&&this._setContainment();if(this._trigger("start",p)===false){this._clear();return false}this._cacheHelperProportions();a.ui.ddmanager&&!h.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,p);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(p,true);a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,p);return true},
_mouseDrag:function(p,h){this.position=this._generatePosition(p);this.positionAbs=this._convertPositionTo("absolute");if(!h){var b=this._uiHash();if(this._trigger("drag",p,b)===false){this._mouseUp({});return false}this.position=b.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,p);return false},_mouseStop:function(p){var h=
false;a.ui.ddmanager&&!this.options.dropBehaviour&&(h=a.ui.ddmanager.drop(this,p));this.dropped&&(h=this.dropped,this.dropped=false);if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!h||this.options.revert=="valid"&&h||this.options.revert===true||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,h)){var b=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),
function(){b._trigger("stop",p)!==false&&b._clear()})}else this._trigger("stop",p)!==false&&this._clear();return false},_mouseUp:function(p){this.options.iframeFix===true&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,p);return a.ui.mouse.prototype._mouseUp.call(this,p)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(p){var h=!this.options.handle||
!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){this==p.target&&(h=true)});return h},_createHelper:function(p){var h=this.options;p=a.isFunction(h.helper)?a(h.helper.apply(this.element[0],[p])):h.helper=="clone"?this.element.clone().removeAttr("id"):this.element;p.parents("body").length||p.appendTo(h.appendTo=="parent"?this.element[0].parentNode:h.appendTo);p[0]!=this.element[0]&&!/(fixed|absolute)/.test(p.css("position"))&&
p.css("position","absolute");return p},_adjustOffsetFromHelper:function(p){typeof p=="string"&&(p=p.split(" "));a.isArray(p)&&(p={left:+p[0],top:+p[1]||0});"left"in p&&(this.offset.click.left=p.left+this.margins.left);"right"in p&&(this.offset.click.left=this.helperProportions.width-p.right+this.margins.left);"top"in p&&(this.offset.click.top=p.top+this.margins.top);"bottom"in p&&(this.offset.click.top=this.helperProportions.height-p.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=
this.helper.offsetParent();var p=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(p.left+=this.scrollParent.scrollLeft(),p.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)p={top:0,left:0};return{top:p.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:p.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var p=this.element.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.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 p=this.options;p.containment=="parent"&&(p.containment=this.helper[0].parentNode);if(p.containment=="document"||p.containment=="window")this.containment=[p.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,p.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
(p.containment=="document"?0:a(window).scrollLeft())+a(p.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(p.containment=="document"?0:a(window).scrollTop())+(a(p.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(p.containment)&&p.containment.constructor!=Array){p=a(p.containment);var h=p[0];if(h){p.offset();var b=a(h).css("overflow")!=
2012-07-31 00:49:46 +00:00
"hidden";this.containment=[(parseInt(a(h).css("borderLeftWidth"),10)||0)+(parseInt(a(h).css("paddingLeft"),10)||0),(parseInt(a(h).css("borderTopWidth"),10)||0)+(parseInt(a(h).css("paddingTop"),10)||0),(b?Math.max(h.scrollWidth,h.offsetWidth):h.offsetWidth)-(parseInt(a(h).css("borderLeftWidth"),10)||0)-(parseInt(a(h).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(b?Math.max(h.scrollHeight,h.offsetHeight):h.offsetHeight)-(parseInt(a(h).css("borderTopWidth"),
2012-07-31 19:01:03 +00:00
10)||0)-(parseInt(a(h).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=p}}else p.containment.constructor==Array&&(this.containment=p.containment)},_convertPositionTo:function(p,h){h||(h=this.position);var b=p=="absolute"?1:-1,o=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,u=/(html|body)/i.test(o[0].tagName);return{top:h.top+
this.offset.relative.top*b+this.offset.parent.top*b-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():u?0:o.scrollTop())*b),left:h.left+this.offset.relative.left*b+this.offset.parent.left*b-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():u?0:o.scrollLeft())*b)}},_generatePosition:function(p){var h=this.options,b=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(b[0].tagName),u=p.pageX,c=p.pageY;if(this.originalPosition){var f;if(this.containment){if(this.relative_container){f=this.relative_container.offset();f=[this.containment[0]+f.left,this.containment[1]+f.top,this.containment[2]+f.left,this.containment[3]+f.top]}else f=this.containment;p.pageX-this.offset.click.left<f[0]&&(u=f[0]+this.offset.click.left);
p.pageY-this.offset.click.top<f[1]&&(c=f[1]+this.offset.click.top);p.pageX-this.offset.click.left>f[2]&&(u=f[2]+this.offset.click.left);p.pageY-this.offset.click.top>f[3]&&(c=f[3]+this.offset.click.top)}if(h.grid){c=h.grid[1]?this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1]:this.originalPageY;c=f?c-this.offset.click.top<f[1]||c-this.offset.click.top>f[3]?c-this.offset.click.top<f[1]?c+h.grid[1]:c-h.grid[1]:c:c;u=h.grid[0]?this.originalPageX+Math.round((u-this.originalPageX)/
h.grid[0])*h.grid[0]:this.originalPageX;u=f?u-this.offset.click.left<f[0]||u-this.offset.click.left>f[2]?u-this.offset.click.left<f[0]?u+h.grid[0]:u-h.grid[0]:u:u}}return{top:c-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():o?0:b.scrollTop()),left:u-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():o?0:b.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(p,h,b){b=b||this._uiHash();a.ui.plugin.call(this,p,[h,b]);p=="drag"&&(this.positionAbs=this._convertPositionTo("absolute"));return a.Widget.prototype._trigger.call(this,p,h,
b)},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(p,h){var b=a(this).data("draggable"),o=b.options,u=a.extend({},h,{item:b.element});b.sortables=[];a(o.connectToSortable).each(function(){var c=a.data(this,"sortable");c&&!c.options.disabled&&(b.sortables.push({instance:c,shouldRevert:c.options.revert}),
c.refreshPositions(),c._trigger("activate",p,u))})},stop:function(p,h){var b=a(this).data("draggable"),o=a.extend({},h,{item:b.element});a.each(b.sortables,function(){this.instance.isOver?(this.instance.isOver=0,b.cancelHelperRemoval=true,this.instance.cancelHelperRemoval=false,this.shouldRevert&&(this.instance.options.revert=true),this.instance._mouseStop(p),this.instance.options.helper=this.instance.options._helper,b.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):
(this.instance.cancelHelperRemoval=false,this.instance._trigger("deactivate",p,o))})},drag:function(p,h){var b=a(this).data("draggable"),o=this;a.each(b.sortables,function(){this.instance.positionAbs=b.positionAbs;this.instance.helperProportions=b.helperProportions;this.instance.offset.click=b.offset.click;this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(o).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 h.helper[0]},p.target=this.instance.currentItem[0],this.instance._mouseCapture(p,true),this.instance._mouseStart(p,true,true),this.instance.offset.click.top=b.offset.click.top,this.instance.offset.click.left=b.offset.click.left,this.instance.offset.parent.left-=b.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=b.offset.parent.top-this.instance.offset.parent.top,
b._trigger("toSortable",p),b.dropped=this.instance.element,b.currentItem=b.element,this.instance.fromOutside=b),this.instance.currentItem&&this.instance._mouseDrag(p)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=true,this.instance.options.revert=false,this.instance._trigger("out",p,this.instance._uiHash(this.instance)),this.instance._mouseStop(p,true),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&
this.instance.placeholder.remove(),b._trigger("fromSortable",p),b.dropped=false)})}});a.ui.plugin.add("draggable","cursor",{start:function(){var p=a("body"),h=a(this).data("draggable").options;p.css("cursor")&&(h._cursor=p.css("cursor"));p.css("cursor",h.cursor)},stop:function(){var p=a(this).data("draggable").options;p._cursor&&a("body").css("cursor",p._cursor)}});a.ui.plugin.add("draggable","opacity",{start:function(p,h){var b=a(h.helper),o=a(this).data("draggable").options;b.css("opacity")&&(o._opacity=
b.css("opacity"));b.css("opacity",o.opacity)},stop:function(p,h){var b=a(this).data("draggable").options;b._opacity&&a(h.helper).css("opacity",b._opacity)}});a.ui.plugin.add("draggable","scroll",{start:function(){var p=a(this).data("draggable");p.scrollParent[0]!=document&&p.scrollParent[0].tagName!="HTML"&&(p.overflowOffset=p.scrollParent.offset())},drag:function(p){var h=a(this).data("draggable"),b=h.options,o=false;if(h.scrollParent[0]!=document&&h.scrollParent[0].tagName!="HTML"){if(!b.axis||
b.axis!="x")h.overflowOffset.top+h.scrollParent[0].offsetHeight-p.pageY<b.scrollSensitivity?h.scrollParent[0].scrollTop=o=h.scrollParent[0].scrollTop+b.scrollSpeed:p.pageY-h.overflowOffset.top<b.scrollSensitivity&&(h.scrollParent[0].scrollTop=o=h.scrollParent[0].scrollTop-b.scrollSpeed);if(!b.axis||b.axis!="y")h.overflowOffset.left+h.scrollParent[0].offsetWidth-p.pageX<b.scrollSensitivity?h.scrollParent[0].scrollLeft=o=h.scrollParent[0].scrollLeft+b.scrollSpeed:p.pageX-h.overflowOffset.left<b.scrollSensitivity&&
(h.scrollParent[0].scrollLeft=o=h.scrollParent[0].scrollLeft-b.scrollSpeed)}else{if(!b.axis||b.axis!="x")p.pageY-a(document).scrollTop()<b.scrollSensitivity?o=a(document).scrollTop(a(document).scrollTop()-b.scrollSpeed):a(window).height()-(p.pageY-a(document).scrollTop())<b.scrollSensitivity&&(o=a(document).scrollTop(a(document).scrollTop()+b.scrollSpeed));if(!b.axis||b.axis!="y")p.pageX-a(document).scrollLeft()<b.scrollSensitivity?o=a(document).scrollLeft(a(document).scrollLeft()-b.scrollSpeed):
a(window).width()-(p.pageX-a(document).scrollLeft())<b.scrollSensitivity&&(o=a(document).scrollLeft(a(document).scrollLeft()+b.scrollSpeed))}o!==false&&a.ui.ddmanager&&!b.dropBehaviour&&a.ui.ddmanager.prepareOffsets(h,p)}});a.ui.plugin.add("draggable","snap",{start:function(){var p=a(this).data("draggable"),h=p.options;p.snapElements=[];a(h.snap.constructor!=String?h.snap.items||":data(draggable)":h.snap).each(function(){var b=a(this),o=b.offset();this!=p.element[0]&&p.snapElements.push({item:this,
width:b.outerWidth(),height:b.outerHeight(),top:o.top,left:o.left})})},drag:function(p,h){for(var b=a(this).data("draggable"),o=b.options,u=o.snapTolerance,c=h.offset.left,f=c+b.helperProportions.width,d=h.offset.top,l=d+b.helperProportions.height,v=b.snapElements.length-1;v>=0;v--){var B=b.snapElements[v].left,q=B+b.snapElements[v].width,K=b.snapElements[v].top,S=K+b.snapElements[v].height;if(B-u<c&&c<q+u&&K-u<d&&d<S+u||B-u<c&&c<q+u&&K-u<l&&l<S+u||B-u<f&&f<q+u&&K-u<d&&d<S+u||B-u<f&&f<q+u&&K-u<l&&
l<S+u){if(o.snapMode!="inner"){var O=Math.abs(K-l)<=u,H=Math.abs(S-d)<=u,R=Math.abs(B-f)<=u,U=Math.abs(q-c)<=u;O&&(h.position.top=b._convertPositionTo("relative",{top:K-b.helperProportions.height,left:0}).top-b.margins.top);H&&(h.position.top=b._convertPositionTo("relative",{top:S,left:0}).top-b.margins.top);R&&(h.position.left=b._convertPositionTo("relative",{top:0,left:B-b.helperProportions.width}).left-b.margins.left);U&&(h.position.left=b._convertPositionTo("relative",{top:0,left:q}).left-b.margins.left)}var M=
O||H||R||U;if(o.snapMode!="outer"){O=Math.abs(K-d)<=u;H=Math.abs(S-l)<=u;R=Math.abs(B-c)<=u;U=Math.abs(q-f)<=u;O&&(h.position.top=b._convertPositionTo("relative",{top:K,left:0}).top-b.margins.top);H&&(h.position.top=b._convertPositionTo("relative",{top:S-b.helperProportions.height,left:0}).top-b.margins.top);R&&(h.position.left=b._convertPositionTo("relative",{top:0,left:B}).left-b.margins.left);U&&(h.position.left=b._convertPositionTo("relative",{top:0,left:q-b.helperProportions.width}).left-b.margins.left)}!b.snapElements[v].snapping&&
(O||H||R||U||M)&&b.options.snap.snap&&b.options.snap.snap.call(b.element,p,a.extend(b._uiHash(),{snapItem:b.snapElements[v].item}));b.snapElements[v].snapping=O||H||R||U||M}else{b.snapElements[v].snapping&&b.options.snap.release&&b.options.snap.release.call(b.element,p,a.extend(b._uiHash(),{snapItem:b.snapElements[v].item}));b.snapElements[v].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var p=a(this).data("draggable").options;p=a.makeArray(a(p.stack)).sort(function(b,
o){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(o).css("zIndex"),10)||0)});if(p.length){var h=parseInt(p[0].style.zIndex)||0;a(p).each(function(b){this.style.zIndex=h+b});this[0].style.zIndex=h+p.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(p,h){var b=a(h.helper),o=a(this).data("draggable").options;b.css("zIndex")&&(o._zIndex=b.css("zIndex"));b.css("zIndex",o.zIndex)},stop:function(p,h){var b=a(this).data("draggable").options;b._zIndex&&a(h.helper).css("zIndex",b._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 p=this,h=this.options,b=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),o=h.values&&h.values.length||1,u=[];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"+(h.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);h.range&&(h.range===true&&(h.values||(h.values=[this._valueMin(),this._valueMin()]),h.values.length&&h.values.length!==2&&(h.values=[h.values[0],h.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(h.range==="min"||h.range==="max"?" ui-slider-range-"+h.range:"")));for(var c=b.length;c<o;c+=1)u.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
this.handles=b.add(a(u.join("")).appendTo(p.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(f){f.preventDefault()}).hover(function(){h.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){h.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(f){a(this).data("index.ui-slider-handle",
f)});this.handles.keydown(function(f){var d=true,l=a(this).data("index.ui-slider-handle"),v,B,q;if(!p.options.disabled){switch(f.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:d=false;if(!p._keySliding){p._keySliding=true;a(this).addClass("ui-state-active");v=p._start(f,l);if(v===false)return}}v=p.options.step;p.options.values&&p.options.values.length?
B=q=p.values(l):B=q=p.value();switch(f.keyCode){case a.ui.keyCode.HOME:q=p._valueMin();break;case a.ui.keyCode.END:q=p._valueMax();break;case a.ui.keyCode.PAGE_UP:q=p._trimAlignValue(B+(p._valueMax()-p._valueMin())/5);break;case a.ui.keyCode.PAGE_DOWN:q=p._trimAlignValue(B-(p._valueMax()-p._valueMin())/5);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(B===p._valueMax())return;q=p._trimAlignValue(B+v);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(B===p._valueMin())return;q=p._trimAlignValue(B-
v)}p._slide(f,l,q);return d}}).keyup(function(f){var d=a(this).data("index.ui-slider-handle");p._keySliding&&(p._keySliding=false,p._stop(f,d),p._change(f,d),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(p){var h=this.options,b,o,u,c,f;if(h.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();b=this._normValueFromMouse({x:p.pageX,y:p.pageY});o=this._valueMax()-this._valueMin()+1;c=this;this.handles.each(function(d){var l=Math.abs(b-c.values(d));o>l&&(o=l,u=a(this),f=d)});h.range===true&&this.values(1)===h.min&&(f+=1,u=a(this.handles[f]));if(this._start(p,f)===false)return false;
this._mouseSliding=true;c._handleIndex=f;u.addClass("ui-state-active").focus();h=u.offset();this._clickOffset=!a(p.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:p.pageX-h.left-u.width()/2,top:p.pageY-h.top-u.height()/2-(parseInt(u.css("borderTopWidth"),10)||0)-(parseInt(u.css("borderBottomWidth"),10)||0)+(parseInt(u.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(p,f,b);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(p){var h=
this._normValueFromMouse({x:p.pageX,y:p.pageY});this._slide(p,this._handleIndex,h);return false},_mouseStop:function(p){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(p,this._handleIndex);this._change(p,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(p){var h,b;this.orientation==="horizontal"?
(h=this.elementSize.width,b=p.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(h=this.elementSize.height,b=p.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));p=b/h;p>1&&(p=1);p<0&&(p=0);this.orientation==="vertical"&&(p=1-p);h=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+p*h)},_start:function(p,h){var b={handle:this.handles[h],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(h),
b.values=this.values());return this._trigger("start",p,b)},_slide:function(p,h,b){var o,u,c;this.options.values&&this.options.values.length?(o=this.values(h?0:1),this.options.values.length===2&&this.options.range===true&&(h===0&&b>o||h===1&&b<o)&&(b=o),b!==this.values(h)&&(u=this.values(),u[h]=b,c=this._trigger("slide",p,{handle:this.handles[h],value:b,values:u}),this.values(h?0:1),c!==false&&this.values(h,b,true))):b!==this.value()&&(c=this._trigger("slide",p,{handle:this.handles[h],value:b}),c!==
false&&this.value(b))},_stop:function(p,h){var b={handle:this.handles[h],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(h),b.values=this.values());this._trigger("stop",p,b)},_change:function(p,h){if(!this._keySliding&&!this._mouseSliding){var b={handle:this.handles[h],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(h),b.values=this.values());this._trigger("change",p,b)}},value:function(p){if(arguments.length){this.options.value=
this._trimAlignValue(p);this._refreshValue();this._change(null,0)}else return this._value()},values:function(p,h){var b,o,u;if(arguments.length>1){this.options.values[p]=this._trimAlignValue(h);this._refreshValue();this._change(null,p)}else{if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(p):this.value();b=this.options.values;o=arguments[0];for(u=0;u<b.length;u+=1){b[u]=this._trimAlignValue(o[u]);this._change(null,
u)}this._refreshValue()}},_setOption:function(p,h){var b,o=0;a.isArray(this.options.values)&&(o=this.options.values.length);a.Widget.prototype._setOption.apply(this,arguments);switch(p){case "disabled":h?(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(b=0;b<o;b+=1)this._change(null,b);this._animateOff=false}},_value:function(){var p=this.options.value;return p=this._trimAlignValue(p)},_values:function(p){var h,b;if(arguments.length){h=this.options.values[p];
return h=this._trimAlignValue(h)}h=this.options.values.slice();for(b=0;b<h.length;b+=1)h[b]=this._trimAlignValue(h[b]);return h},_trimAlignValue:function(p){if(p<=this._valueMin())return this._valueMin();if(p>=this._valueMax())return this._valueMax();var h=this.options.step>0?this.options.step:1,b=(p-this._valueMin())%h;p=p-b;Math.abs(b)*2>=h&&(p+=b>0?h:-h);return parseFloat(p.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var p=
this.options.range,h=this.options,b=this,o=this._animateOff?false:h.animate,u,c={},f,d,l,v;this.options.values&&this.options.values.length?this.handles.each(function(B){u=(b.values(B)-b._valueMin())/(b._valueMax()-b._valueMin())*100;c[b.orientation==="horizontal"?"left":"bottom"]=u+"%";a(this).stop(1,1)[o?"animate":"css"](c,h.animate);b.options.range===true&&(b.orientation==="horizontal"?(B===0&&b.range.stop(1,1)[o?"animate":"css"]({left:u+"%"},h.animate),B===1&&b.range[o?"animate":"css"]({width:u-
f+"%"},{queue:false,duration:h.animate})):(B===0&&b.range.stop(1,1)[o?"animate":"css"]({bottom:u+"%"},h.animate),B===1&&b.range[o?"animate":"css"]({height:u-f+"%"},{queue:false,duration:h.animate})));f=u}):(d=this.value(),l=this._valueMin(),v=this._valueMax(),u=v!==l?(d-l)/(v-l)*100:0,c[b.orientation==="horizontal"?"left":"bottom"]=u+"%",this.handle.stop(1,1)[o?"animate":"css"](c,h.animate),p==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[o?"animate":"css"]({width:u+"%"},h.animate),
p==="max"&&this.orientation==="horizontal"&&this.range[o?"animate":"css"]({width:100-u+"%"},{queue:false,duration:h.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[o?"animate":"css"]({height:u+"%"},h.animate),p==="max"&&this.orientation==="vertical"&&this.range[o?"animate":"css"]({height:100-u+"%"},{queue:false,duration:h.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,f){if(f===undefined)f=0;return Math.round(c*Math.pow(10,f))/Math.pow(10,f)};var p=function(c,f){var d=this,l=c.find("img:first"),v=0,B=100,q=100,K=0,S=100,O=100,H=0,R=0,U,M,ga=[],oa=function(V){for(var W=0;W<ga.length;W++)ga[W].call(d,d,V)},ea=function(V){var W=c.offset();U={l:W.left|0,t:W.top|0};clearTimeout(M);M=setTimeout(function(){xa.call(d,V)},0);a(document).bind("mousemove",Q).bind("mouseup",Y);V.preventDefault()},Q=function(V){clearTimeout(M);M=setTimeout(function(){xa.call(d,
V)},0);V.stopPropagation();V.preventDefault();return false},Y=function(V){a(document).unbind("mouseup",Y).unbind("mousemove",Q);V.stopPropagation();V.preventDefault();return false},xa=function(V){var W=V.pageX-U.l;V=V.pageY-U.t;var na=c.w,qa=c.h;if(W<0)W=0;else if(W>na)W=na;if(V<0)V=0;else if(V>qa)V=qa;ja.call(d,"xy",{x:W/na*q+v,y:V/qa*O+K})},ja=function(V,W,na){if(W===undefined){if(V===undefined||V==null)V="xy";switch(V.toLowerCase()){case "x":return H;case "y":return R;default:return{x:H,y:R}}}if(!(na!=
null&&na==d)){var qa=false,ma,la;if(V==null)V="xy";switch(V.toLowerCase()){case "x":ma=W&&(W.x&&W.x|0||W|0)||0;break;case "y":la=W&&(W.y&&W.y|0||W|0)||0;break;default:ma=W&&W.x&&W.x|0||0;la=W&&W.y&&W.y|0||0}if(ma!=null){if(ma<v)ma=v;else if(ma>B)ma=B;if(H!=ma){H=ma;qa=true}}if(la!=null){if(la<K)la=K;else if(la>S)la=S;if(R!=la){R=la;qa=true}}qa&&oa.call(d,na||d)}},ca=function(V){a.isFunction(V)&&ga.push(V)};a.extend(true,d,{val:ja,range:function(V,W){if(W===undefined){if(V===undefined||V==null)V="all";
switch(V.toLowerCase()){case "minx":return v;case "maxx":return B;case "rangex":return{minX:v,maxX:B,rangeX:q};case "miny":return K;case "maxy":return S;case "rangey":return{minY:K,maxY:S,rangeY:O};default:return{minX:v,maxX:B,rangeX:q,minY:K,maxY:S,rangeY:O}}}var na,qa,ma,la;if(V==null)V="all";switch(V.toLowerCase()){case "minx":na=W&&(W.minX&&W.minX|0||W|0)||0;break;case "maxx":qa=W&&(W.maxX&&W.maxX|0||W|0)||0;break;case "rangex":na=W&&W.minX&&W.minX|0||0;qa=W&&W.maxX&&W.maxX|0||0;break;case "miny":ma=
W&&(W.minY&&W.minY|0||W|0)||0;break;case "maxy":la=W&&(W.maxY&&W.maxY|0||W|0)||0;break;case "rangey":ma=W&&W.minY&&W.minY|0||0;la=W&&W.maxY&&W.maxY|0||0;break;default:na=W&&W.minX&&W.minX|0||0;qa=W&&W.maxX&&W.maxX|0||0;ma=W&&W.minY&&W.minY|0||0;la=W&&W.maxY&&W.maxY|0||0}if(na!=null&&v!=na){v=na;q=B-v}if(qa!=null&&B!=qa){B=qa;q=B-v}if(ma!=null&&K!=ma){K=ma;O=S-K}if(la!=null&&S!=la){S=la;O=S-K}},bind:ca,unbind:function(V){if(a.isFunction(V))for(var W;(W=a.inArray(V,ga))!=-1;)ga.splice(W,1)},destroy:function(){a(document).unbind("mouseup",
Y).unbind("mousemove",Q);c.unbind("mousedown",ea);ga=l=c=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();c.w=f.map&&f.map.width||c.width();c.h=f.map&&f.map.height||c.height();c.bind("mousedown",ea);ca.call(d,function(){var V=0,W=0,na=c.w,qa=c.h,ma=l.w,la=l.h;setTimeout(function(){if(q>0)V=H==B?na:H/q*na|0;if(O>0)W=R==S?qa:R/O*qa|0;if(ma>=na)V=(na>>1)-(ma>>1);else V-=ma>>1;if(la>=qa)W=(qa>>1)-(la>>1);else W-=la>>1;l.css({left:V+"px",
top:W+"px"})},0)})},h=function(c,f,d,l){var v=this;c=c.find("td.Text input");var B=c.eq(3),q=c.eq(4),K=c.eq(5),S=c.length>7?c.eq(6):null,O=c.eq(0),H=c.eq(1),R=c.eq(2),U=c.eq(c.length>7?7:6),M=c.length>7?c.eq(8):null,ga=function(ja){if(!(ja.target.value==""&&ja.target!=U.get(0)&&(d!=null&&ja.target!=d.get(0)||d==null))){if(!Q(ja))return ja;switch(ja.target){case B.get(0):switch(ja.keyCode){case 38:B.val(Y.call(v,(B.val()<<0)+1,0,255));f.val("r",B.val(),ja.target);return false;case 40:B.val(Y.call(v,
(B.val()<<0)-1,0,255));f.val("r",B.val(),ja.target);return false}break;case q.get(0):switch(ja.keyCode){case 38:q.val(Y.call(v,(q.val()<<0)+1,0,255));f.val("g",q.val(),ja.target);return false;case 40:q.val(Y.call(v,(q.val()<<0)-1,0,255));f.val("g",q.val(),ja.target);return false}break;case K.get(0):switch(ja.keyCode){case 38:K.val(Y.call(v,(K.val()<<0)+1,0,255));f.val("b",K.val(),ja.target);return false;case 40:K.val(Y.call(v,(K.val()<<0)-1,0,255));f.val("b",K.val(),ja.target);return false}break;
case S&&S.get(0):switch(ja.keyCode){case 38:S.val(Y.call(v,parseFloat(S.val())+1,0,100));f.val("a",Math.precision(S.val()*255/100,l),ja.target);return false;case 40:S.val(Y.call(v,parseFloat(S.val())-1,0,100));f.val("a",Math.precision(S.val()*255/100,l),ja.target);return false}break;case O.get(0):switch(ja.keyCode){case 38:O.val(Y.call(v,(O.val()<<0)+1,0,360));f.val("h",O.val(),ja.target);return false;case 40:O.val(Y.call(v,(O.val()<<0)-1,0,360));f.val("h",O.val(),ja.target);return false}break;case H.get(0):switch(ja.keyCode){case 38:H.val(Y.call(v,
(H.val()<<0)+1,0,100));f.val("s",H.val(),ja.target);return false;case 40:H.val(Y.call(v,(H.val()<<0)-1,0,100));f.val("s",H.val(),ja.target);return false}break;case R.get(0):switch(ja.keyCode){case 38:R.val(Y.call(v,(R.val()<<0)+1,0,100));f.val("v",R.val(),ja.target);return false;case 40:R.val(Y.call(v,(R.val()<<0)-1,0,100));f.val("v",R.val(),ja.target);return false}}}},oa=function(ja){if(!(ja.target.value==""&&ja.target!=U.get(0)&&(d!=null&&ja.target!=d.get(0)||d==null))){if(!Q(ja))return ja;switch(ja.target){case B.get(0):B.val(Y.call(v,
B.val(),0,255));f.val("r",B.val(),ja.target);break;case q.get(0):q.val(Y.call(v,q.val(),0,255));f.val("g",q.val(),ja.target);break;case K.get(0):K.val(Y.call(v,K.val(),0,255));f.val("b",K.val(),ja.target);break;case S&&S.get(0):S.val(Y.call(v,S.val(),0,100));f.val("a",Math.precision(S.val()*255/100,l),ja.target);break;case O.get(0):O.val(Y.call(v,O.val(),0,360));f.val("h",O.val(),ja.target);break;case H.get(0):H.val(Y.call(v,H.val(),0,100));f.val("s",H.val(),ja.target);break;case R.get(0):R.val(Y.call(v,
R.val(),0,100));f.val("v",R.val(),ja.target);break;case U.get(0):U.val(U.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(U.val());f.val("hex",U.val()!=""?U.val():null,ja.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));U.val(d.val());f.val("hex",d.val()!=""?d.val():null,ja.target);break;case M&&M.get(0):M.val(M.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",M.val()!=null?parseInt(M.val(),16):
null,ja.target)}}},ea=function(ja){if(f.val()!=null)switch(ja.target){case B.get(0):B.val(f.val("r"));break;case q.get(0):q.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case S&&S.get(0):S.val(Math.precision(f.val("a")*100/255,l));break;case O.get(0):O.val(f.val("h"));break;case H.get(0):H.val(f.val("s"));break;case R.get(0):R.val(f.val("v"));break;case U.get(0):case d&&d.get(0):U.val(f.val("hex"));d&&d.val(f.val("hex"));break;case M&&M.get(0):M.val(f.val("ahex").substring(6))}},Q=function(ja){switch(ja.keyCode){case 9:case 16:case 29:case 37:case 39:return false;
case "c".charCodeAt():case "v".charCodeAt():if(ja.ctrlKey)return false}return true},Y=function(ja,ca,V){if(ja==""||isNaN(ja))return ca;if(ja>V)return V;if(ja<ca)return ca;return ja},xa=function(ja,ca){var V=ja.val("all");if(ca!=B.get(0))B.val(V!=null?V.r:"");if(ca!=q.get(0))q.val(V!=null?V.g:"");if(ca!=K.get(0))K.val(V!=null?V.b:"");if(S&&ca!=S.get(0))S.val(V!=null?Math.precision(V.a*100/255,l):"");if(ca!=O.get(0))O.val(V!=null?V.h:"");if(ca!=H.get(0))H.val(V!=null?V.s:"");if(ca!=R.get(0))R.val(V!=
null?V.v:"");if(ca!=U.get(0)&&(d&&ca!=d.get(0)||!d))U.val(V!=null?V.hex:"");if(d&&ca!=d.get(0)&&ca!=U.get(0))d.val(V!=null?V.hex:"");if(M&&ca!=M.get(0))M.val(V!=null?V.ahex.substring(6):"")};a.extend(true,v,{destroy:function(){B.add(q).add(K).add(S).add(O).add(H).add(R).add(U).add(d).add(M).unbind("keyup",oa).unbind("blur",ea);B.add(q).add(K).add(S).add(O).add(H).add(R).unbind("keydown",ga);f.unbind(xa);M=U=R=H=O=S=K=q=B=null}});B.add(q).add(K).add(S).add(O).add(H).add(R).add(U).add(d).add(M).bind("keyup",
oa).bind("blur",ea);B.add(q).add(K).add(S).add(O).add(H).add(R).bind("keydown",ga);f.bind(xa)};a.jPicker={List:[],Color:function(c){var f=this,d,l,v,B,q,K,S,O=[],H=function(U){for(var M=0;M<O.length;M++)O[M].call(f,f,U)},R=function(U,M,ga){if(M===undefined){if(U===undefined||U==null||U=="")U="all";if(d==null)return null;switch(U.toLowerCase()){case "ahex":return u.rgbaToHex({r:d,g:l,b:v,a:B});case "hex":return R("ahex").substring(0,6);case "all":return{r:d,g:l,b:v,a:B,h:q,s:K,v:S,hex:R.call(f,"hex"),
ahex:R.call(f,"ahex")};default:M={};for(var oa=0;oa<U.length;oa++)switch(U.charAt(oa)){case "r":if(U.length==1)M=d;else M.r=d;break;case "g":if(U.length==1)M=l;else M.g=l;break;case "b":if(U.length==1)M=v;else M.b=v;break;case "a":if(U.length==1)M=B;else M.a=B;break;case "h":if(U.length==1)M=q;else M.h=q;break;case "s":if(U.length==1)M=K;else M.s=K;break;case "v":if(U.length==1)M=S;else M.v=S}return M=={}?R.call(f,"all"):M}}if(!(ga!=null&&ga==f)){var ea=false;if(U==null)U="";if(M==null){if(d!=null){d=
null;ea=true}if(l!=null){l=null;ea=true}if(v!=null){v=null;ea=true}if(B!=null){B=null;ea=true}if(q!=null){q=null;ea=true}if(K!=null){K=null;ea=true}if(S!=null){S=null;ea=true}ea&&H.call(f,ga||f)}else switch(U.toLowerCase()){case "ahex":case "hex":M=u.hexToRgba(M&&(M.ahex||M.hex)||M||"00000000");R.call(f,"rgba",{r:M.r,g:M.g,b:M.b,a:U=="ahex"?M.a:B!=null?B:255},ga);break;default:if(M&&(M.ahex!=null||M.hex!=null)){R.call(f,"ahex",M.ahex||M.hex||"00000000",ga);break}var Q={},Y=false,xa=false;if(M.r!==
undefined&&!U.indexOf("r")==-1)U+="r";if(M.g!==undefined&&!U.indexOf("g")==-1)U+="g";if(M.b!==undefined&&!U.indexOf("b")==-1)U+="b";if(M.a!==undefined&&!U.indexOf("a")==-1)U+="a";if(M.h!==undefined&&!U.indexOf("h")==-1)U+="h";if(M.s!==undefined&&!U.indexOf("s")==-1)U+="s";if(M.v!==undefined&&!U.indexOf("v")==-1)U+="v";for(oa=0;oa<U.length;oa++)switch(U.charAt(oa)){case "r":if(xa)continue;Y=true;Q.r=M&&M.r&&M.r|0||M&&M|0||0;if(Q.r<0)Q.r=0;else if(Q.r>255)Q.r=255;if(d!=Q.r){d=Q.r;ea=true}break;case "g":if(xa)continue;
Y=true;Q.g=M&&M.g&&M.g|0||M&&M|0||0;if(Q.g<0)Q.g=0;else if(Q.g>255)Q.g=255;if(l!=Q.g){l=Q.g;ea=true}break;case "b":if(xa)continue;Y=true;Q.b=M&&M.b&&M.b|0||M&&M|0||0;if(Q.b<0)Q.b=0;else if(Q.b>255)Q.b=255;if(v!=Q.b){v=Q.b;ea=true}break;case "a":Q.a=M&&M.a!=null?M.a|0:M!=null?M|0:255;if(Q.a<0)Q.a=0;else if(Q.a>255)Q.a=255;if(B!=Q.a){B=Q.a;ea=true}break;case "h":if(Y)continue;xa=true;Q.h=M&&M.h&&M.h|0||M&&M|0||0;if(Q.h<0)Q.h=0;else if(Q.h>360)Q.h=360;if(q!=Q.h){q=Q.h;ea=true}break;case "s":if(Y)continue;
xa=true;Q.s=M&&M.s!=null?M.s|0:M!=null?M|0:100;if(Q.s<0)Q.s=0;else if(Q.s>100)Q.s=100;if(K!=Q.s){K=Q.s;ea=true}break;case "v":if(Y)continue;xa=true;Q.v=M&&M.v!=null?M.v|0:M!=null?M|0:100;if(Q.v<0)Q.v=0;else if(Q.v>100)Q.v=100;if(S!=Q.v){S=Q.v;ea=true}}if(ea){if(Y){d=d||0;l=l||0;v=v||0;M=u.rgbToHsv({r:d,g:l,b:v});q=M.h;K=M.s;S=M.v}else if(xa){q=q||0;K=K!=null?K:100;S=S!=null?S:100;M=u.hsvToRgb({h:q,s:K,v:S});d=M.r;l=M.g;v=M.b}B=B!=null?B:255;H.call(f,ga||f)}}}};a.extend(true,f,{val:R,bind:function(U){a.isFunction(U)&&
O.push(U)},unbind:function(U){if(a.isFunction(U))for(var M;(M=a.inArray(U,O))!=-1;)O.splice(M,1)},destroy:function(){O=null}});if(c)if(c.ahex!=null)R("ahex",c);else if(c.hex!=null)R((c.a!=null?"a":"")+"hex",c.a!=null?{ahex:c.hex+u.intToHex(c.a)}:c);else if(c.r!=null&&c.g!=null&&c.b!=null)R("rgb"+(c.a!=null?"a":""),c);else if(c.h!=null&&c.s!=null&&c.v!=null)R("hsv"+(c.a!=null?"a":""),c)},ColorMethods:{hexToRgba:function(c){c=this.validateHex(c);if(c=="")return{r:null,g:null,b:null,a:null};var f="00",
d="00",l="00",v="255";if(c.length==6)c+="ff";if(c.length>6){f=c.substring(0,2);d=c.substring(2,4);l=c.substring(4,6);v=c.substring(6,c.length)}else{if(c.length>4){f=c.substring(4,c.length);c=c.substring(0,4)}if(c.length>2){d=c.substring(2,c.length);c=c.substring(0,2)}if(c.length>0)l=c.substring(0,c.length)}return{r:this.hexToInt(f),g:this.hexToInt(d),b:this.hexToInt(l),a:this.hexToInt(v)}},validateHex:function(c){if(typeof c=="object")return"";c=c.toLowerCase().replace(/[^a-f0-9]/g,"");if(c.length>
8)c=c.substring(0,8);return c},rgbaToHex:function(c){return this.intToHex(c.r)+this.intToHex(c.g)+this.intToHex(c.b)+this.intToHex(c.a)},intToHex:function(c){c=(c|0).toString(16);if(c.length==1)c="0"+c;return c.toLowerCase()},hexToInt:function(c){return parseInt(c,16)},rgbToHsv:function(c){var f=c.r/255,d=c.g/255;c=c.b/255;var l={h:0,s:0,v:0},v=0,B=0;if(f>=d&&f>=c){B=f;v=d>c?c:d}else if(d>=c&&d>=f){B=d;v=f>c?c:f}else{B=c;v=d>f?f:d}l.v=B;l.s=B?(B-v)/B:0;if(l.s){v=B-v;l.h=f==B?(d-c)/v:d==B?2+(c-f)/
v:4+(f-d)/v;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(c){var f={r:0,g:0,b:0,a:100},d=c.h,l=c.s;c=c.v;if(l==0)f.r=c==0?f.g=f.b=0:f.g=f.b=c*255/100|0;else{if(d==360)d=0;d/=60;l/=100;c/=100;var v=d|0,B=d-v;d=c*(1-l);var q=c*(1-l*B);l=c*(1-l*(1-B));switch(v){case 0:f.r=c;f.g=l;f.b=d;break;case 1:f.r=q;f.g=c;f.b=d;break;case 2:f.r=d;f.g=c;f.b=l;break;case 3:f.r=d;f.g=q;f.b=c;break;case 4:f.r=l;f.g=d;f.b=c;break;case 5:f.r=c;f.g=d;f.b=q}f.r=
f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var b=a.jPicker.Color,o=a.jPicker.List,u=a.jPicker.ColorMethods;a.fn.jPicker=function(c){var f=arguments;return this.each(function(){var d=this,l=a.extend(true,{},a.fn.jPicker.defaults,c);if(a(d).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,input:a(d)}});if(a(d).val()==""){l.color.active=new b({hex:null});l.color.current=new b({hex:null})}else if(u.validateHex(a(d).val())){l.color.active=new b({hex:a(d).val(),
a:l.color.active.val("a")});l.color.current=new b({hex:a(d).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(d).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');else l.window.liveUpdate=false;var v=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,q=null,K=null,S=null,O=
null,H=null,R=null,U=null,M=null,ga=null,oa=null,ea=null,Q=null,Y=null,xa=null,ja=null,ca=null,V=null,W=null,na=null,qa=null,ma=null,la=null,za=null,Ga=null,Aa=null,Ha=null,Ja=null,Ia=function(N){var P=ka.active,da=P.val("hex"),Ea,Na;l.color.mode=N;switch(N){case "h":setTimeout(function(){Va.call(d,q,"transparent");Ba.call(d,S,0);va.call(d,S,100);Ba.call(d,O,260);va.call(d,O,100);Va.call(d,K,"transparent");Ba.call(d,R,0);va.call(d,R,100);Ba.call(d,U,260);va.call(d,U,100);Ba.call(d,M,260);va.call(d,
M,100);Ba.call(d,ga,260);va.call(d,ga,100);Ba.call(d,ea,260);va.call(d,ea,100)},0);Q.range("all",{minX:0,maxX:100,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:360});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("s"),y:100-P.val("v")},Q);Y.val("y",360-P.val("h"),Y);break;case "s":setTimeout(function(){Va.call(d,q,"transparent");Ba.call(d,S,-260);Ba.call(d,O,-520);Ba.call(d,R,-260);Ba.call(d,U,-520);Ba.call(d,ea,260);va.call(d,ea,100)},0);Q.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",
{minY:0,maxY:100});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("h"),y:100-P.val("v")},Q);Y.val("y",100-P.val("s"),Y);break;case "v":setTimeout(function(){Va.call(d,q,"000000");Ba.call(d,S,-780);Ba.call(d,O,260);Va.call(d,K,da);Ba.call(d,R,-520);Ba.call(d,U,260);va.call(d,U,100);Ba.call(d,ea,260);va.call(d,ea,100)},0);Q.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("h"),y:100-P.val("s")},Q);Y.val("y",100-P.val("v"),
Y);break;case "r":Ea=-1040;Na=-780;Q.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("b"),y:255-P.val("g")},Q);Y.val("y",255-P.val("r"),Y);break;case "g":Ea=-1560;Na=-1820;Q.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("b"),y:255-P.val("r")},Q);Y.val("y",255-P.val("g"),Y);break;case "b":Ea=-2080;Na=-2860;Q.range("all",{minX:0,maxX:255,
minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("r"),y:255-P.val("g")},Q);Y.val("y",255-P.val("b"),Y);break;case "a":setTimeout(function(){Va.call(d,q,"transparent");Ba.call(d,S,-260);Ba.call(d,O,-520);Ba.call(d,R,260);Ba.call(d,U,260);va.call(d,U,100);Ba.call(d,ea,0);va.call(d,ea,100)},0);Q.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;Q.val("xy",{x:P.val("h"),y:100-P.val("v")},
Q);Y.val("y",255-P.val("a"),Y);break;default:throw"Invalid Mode";}switch(N){case "s":case "v":case "a":setTimeout(function(){va.call(d,S,100);va.call(d,R,100);Ba.call(d,M,260);va.call(d,M,100);Ba.call(d,ga,260);va.call(d,ga,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Va.call(d,q,"transparent");Va.call(d,K,"transparent");va.call(d,R,100);va.call(d,S,100);Ba.call(d,S,Ea);Ba.call(d,O,Ea-260);Ba.call(d,R,Na-780);Ba.call(d,U,Na-520);Ba.call(d,M,Na);Ba.call(d,ga,Na-260);Ba.call(d,ea,
260);va.call(d,ea,100)},0)}P.val("ahex")!=null&&Da.call(d,P)},Da=function(N,P){if(P==null||P!=Y&&P!=Q)wa.call(d,N,P);setTimeout(function(){Ua.call(d,N);tb.call(d,N);eb.call(d,N)},0)},ya=function(N,P){var da=ka.active;if(!(P!=Q&&da.val()==null)){var Ea=N.val("all");switch(l.color.mode){case "h":da.val("sv",{s:Ea.x,v:100-Ea.y},P);break;case "s":case "a":da.val("hv",{h:Ea.x,v:100-Ea.y},P);break;case "v":da.val("hs",{h:Ea.x,s:100-Ea.y},P);break;case "r":da.val("gb",{g:255-Ea.y,b:Ea.x},P);break;case "g":da.val("rb",
{r:255-Ea.y,b:Ea.x},P);break;case "b":da.val("rg",{r:Ea.x,g:255-Ea.y},P)}}},Fa=function(N,P){var da=ka.active;if(!(P!=Y&&da.val()==null))switch(l.color.mode){case "h":da.val("h",{h:360-N.val("y")},P);break;case "s":da.val("s",{s:100-N.val("y")},P);break;case "v":da.val("v",{v:100-N.val("y")},P);break;case "r":da.val("r",{r:255-N.val("y")},P);break;case "g":da.val("g",{g:255-N.val("y")},P);break;case "b":da.val("b",{b:255-N.val("y")},P);break;case "a":da.val("a",255-N.val("y"),P)}},wa=function(N,P){if(P!=
Q)switch(l.color.mode){case "h":var da=N.val("sv");Q.val("xy",{x:da!=null?da.s:100,y:100-(da!=null?da.v:100)},P);break;case "s":case "a":da=N.val("hv");Q.val("xy",{x:da&&da.h||0,y:100-(da!=null?da.v:100)},P);break;case "v":da=N.val("hs");Q.val("xy",{x:da&&da.h||0,y:100-(da!=null?da.s:100)},P);break;case "r":da=N.val("bg");Q.val("xy",{x:da&&da.b||0,y:255-(da&&da.g||0)},P);break;case "g":da=N.val("br");Q.val("xy",{x:da&&da.b||0,y:255-(da&&da.r||0)},P);break;case "b":da=N.val("rg");Q.val("xy",{x:da&&
da.r||0,y:255-(da&&da.g||0)},P)}if(P!=Y)switch(l.color.mode){case "h":Y.val("y",360-(N.val("h")||0),P);break;case "s":da=N.val("s");Y.val("y",100-(da!=null?da:100),P);break;case "v":da=N.val("v");Y.val("y",100-(da!=null?da:100),P);break;case "r":Y.val("y",255-(N.val("r")||0),P);break;case "g":Y.val("y",255-(N.val("g")||0),P);break;case "b":Y.val("y",255-(N.val("b")||0),P);break;case "a":da=N.val("a");Y.val("y",255-(da!=null?da:255),P)}},Ua=function(N){try{var P=N.val("all");na.css({backgroundColor:P&&
"#"+P.hex||"transparent"});va.call(d,na,P&&Math.precision(P.a*100/255,4)||0)}catch(da){}},tb=function(N){switch(l.color.mode){case "h":Va.call(d,q,(new b({h:N.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var P=N.val("s");va.call(d,O,100-(P!=null?P:100));break;case "v":P=N.val("v");va.call(d,S,P!=null?P:100);break;case "r":va.call(d,O,Math.precision((N.val("r")||0)/255*100,4));break;case "g":va.call(d,O,Math.precision((N.val("g")||0)/255*100,4));break;case "b":va.call(d,O,Math.precision((N.val("b")||
0)/255*100))}N=N.val("a");va.call(d,H,Math.precision((255-(N||0))*100/255,4))},eb=function(N){switch(l.color.mode){case "h":var P=N.val("a");va.call(d,oa,Math.precision((255-(P||0))*100/255,4));break;case "s":P=N.val("hva");var da=new b({h:P&&P.h||0,s:100,v:P!=null?P.v:100});Va.call(d,K,da.val("hex"));va.call(d,U,100-(P!=null?P.v:100));va.call(d,oa,Math.precision((255-(P&&P.a||0))*100/255,4));break;case "v":P=N.val("hsa");da=new b({h:P&&P.h||0,s:P!=null?P.s:100,v:100});Va.call(d,K,da.val("hex"));
va.call(d,oa,Math.precision((255-(P&&P.a||0))*100/255,4));break;case "r":case "g":case "b":da=P=0;N=N.val("rgba");if(l.color.mode=="r"){P=N&&N.b||0;da=N&&N.g||0}else if(l.color.mode=="g"){P=N&&N.b||0;da=N&&N.r||0}else if(l.color.mode=="b"){P=N&&N.r||0;da=N&&N.g||0}var Ea=da>P?P:da;va.call(d,U,P>da?Math.precision((P-da)/(255-da)*100,4):0);va.call(d,M,da>P?Math.precision((da-P)/(255-P)*100,4):0);va.call(d,ga,Math.precision(Ea/255*100,4));va.call(d,oa,Math.precision((255-(N&&N.a||0))*100/255,4));break;
case "a":P=N.val("a");Va.call(d,K,N.val("hex")||"000000");va.call(d,oa,P!=null?0:100);va.call(d,ea,P!=null?100:0)}},Va=function(N,P){N.css({backgroundColor:P&&P.length==6&&"#"+P||"transparent"})},Wa=function(N,P){if(v&&(P.indexOf("AlphaBar.png")!=-1||P.indexOf("Bars.png")!=-1||P.indexOf("Maps.png")!=-1)){N.attr("pngSrc",P);N.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+P+"', sizingMethod='scale')"})}else N.css({backgroundImage:"url('"+P+"')"})},Ba=
function(N,P){N.css({top:P+"px"})},va=function(N,P){N.css({visibility:P>0?"visible":"hidden"});if(P>0&&P<100)if(v){var da=N.attr("pngSrc");da!=null&&(da.indexOf("AlphaBar.png")!=-1||da.indexOf("Bars.png")!=-1||da.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+da+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+P+")"}):N.css({opacity:Math.precision(P/100,4)})}else N.css({opacity:Math.precision(P/100,4)});else if(P==0||P==
100)if(v){da=N.attr("pngSrc");da!=null&&(da.indexOf("AlphaBar.png")!=-1||da.indexOf("Bars.png")!=-1||da.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+da+"', sizingMethod='scale')"}):N.css({opacity:""})}else N.css({opacity:""})},cb=function(){ka.active.val("ahex",ka.current.val("ahex"))},Ka=function(){ka.current.val("ahex",ka.active.val("ahex"))},Ta=function(N){a(this).parents("tbody:first").find('input:radio[value!="'+N.target.value+'"]').removeAttr("checked");
Ia.call(d,N.target.value)},Ca=function(){cb.call(d)},gb=function(){cb.call(d);l.window.expandable&&vb.call(d);a.isFunction(mb)&&mb.call(d,ka.active,la)},pb=function(){Ka.call(d);l.window.expandable&&vb.call(d);a.isFunction(kb)&&kb.call(d,ka.active,ma)},Xa=function(){qb.call(d)},Ya=function(N){var P=N.val("hex");qa.css({backgroundColor:P&&"#"+P||"transparent"});va.call(d,qa,Math.precision((N.val("a")||0)*100/255,4))},ub=function(N){var P=N.val("hex");N=N.val("va");Ga.css({backgroundColor:P&&"#"+P||
"transparent"});va.call(d,Aa,Math.precision((255-(N&&N.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:P&&"#"+P||"transparent",color:N==null||N.v>75?"#000000":"#ffffff"})},ta=function(N){ja=parseInt(B.css("left"));ca=parseInt(B.css("top"));V=N.pageX;W=N.pageY;a(document).bind("mousemove",jb).bind("mouseup",fb);N.preventDefault()},jb=function(N){B.css({left:ja-(V-N.pageX)+"px",top:ca-(W-N.pageY)+"px"});l.window.expandable&&!a.support.boxModel&&
B.prev().css({left:B.css("left"),top:B.css("top")});N.stopPropagation();N.preventDefault();return false},fb=function(N){a(document).unbind("mousemove",jb).unbind("mouseup",fb);N.stopPropagation();N.preventDefault();return false},sb=function(N){N.preventDefault();N.stopPropagation();ka.active.val("ahex",a(this).attr("title")||null,N.target);return false},kb=a.isFunction(f[1])&&f[1]||null,db=a.isFunction(f[2])&&f[2]||null,mb=a.isFunction(f[3])&&f[3]||null,qb=function(){ka.current.val("ahex",ka.active.val("ahex"));
var N=function(){if(!(!l.window.expandable||a.support.boxModel)){var P=B.find("table:first");B.before("<iframe/>");B.prev().css({width:P.width(),height:B.height(),opacity:0,position:"absolute",left:B.css("left"),top:B.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})}switch(l.window.effects.type){case "fade":B.fadeIn(l.window.effects.speed.show,N);break;case "slide":B.slideDown(l.window.effects.speed.show,N);break;default:B.show(l.window.effects.speed.show,
N)}},vb=function(){var N=function(){l.window.expandable&&B.css({zIndex:10});!l.window.expandable||a.support.boxModel||B.prev().remove()};switch(l.window.effects.type){case "fade":B.fadeOut(l.window.effects.speed.hide,N);break;case "slide":B.slideUp(l.window.effects.speed.hide,N);break;default:B.hide(l.window.effects.speed.hide,N)}},wb=function(){var N=l.window,P=N.expandable?a(d).next().find(".Container:first"):null;B=N.expandable?a("<div/>"):a(d);B.addClass("jPicker Container");N.expandable&&B.hide();
B.get(0).onselectstart=function(Pa){if(Pa.target.nodeName.toLowerCase()!=="input")return false};var da=ka.active.val("all");if(N.alphaPrecision<0)N.alphaPrecision=0;else if(N.alphaPrecision>2)N.alphaPrecision=2;var Ea='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(N.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(N.title||aa.text.title)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+
ia.clientPath+ia.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="'+ia.clientPath+ia.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+aa.text.newColor+'<div class="color_preview"><span class="Active" title="'+aa.tooltips.colors.newColor+
'">&nbsp;</span><span class="Current" title="'+aa.tooltips.colors.currentColor+'">&nbsp;</span></div></div>'+aa.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+aa.text.ok+'" title="'+aa.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+aa.text.cancel+'" title="'+aa.tooltips.buttons.cancel+'"/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="'+aa.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="'+(da!=null?da.h:"")+'" title="'+aa.tooltips.hue.textbox+'"/>&nbsp;\u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+aa.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="'+(da!=null?da.s:"")+'" title="'+aa.tooltips.saturation.textbox+
'"/>&nbsp;%</td></tr><tr class="Value"><td class="Radio"><label title="'+aa.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="'+(da!=null?da.v:"")+'" title="'+aa.tooltips.value.textbox+'"/>&nbsp;%<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="'+aa.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="'+
(da!=null?da.r:"")+'" title="'+aa.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+aa.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="'+(da!=null?da.g:"")+'" title="'+aa.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+aa.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="'+(da!=null?da.b:"")+'" title="'+aa.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(N.alphaSupport?'<label title="'+aa.tooltips.alpha.radio+'"><input type="radio" value="a"'+(l.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":"&nbsp;")+'</td><td class="Text">'+(N.alphaSupport?'<input type="text" maxlength="'+(3+N.alphaPrecision)+'" value="'+(da!=null?Math.precision(da.a*100/255,N.alphaPrecision):
"")+'" title="'+aa.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+aa.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(da!=null?da.hex:"")+'"/></label>'+(N.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(da!=null?da.ahex.substring(6):"")+'" title="'+aa.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";if(N.expandable){B.html(Ea);a(document.body).children("div.jPicker.Container").length==
0?a(document.body).prepend(B):a(document.body).children("div.jPicker.Container:last").after(B);B.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})});B.css({left:N.position.x=="left"?P.offset().left-530-(N.position.y=="center"?25:0)+"px":N.position.x=="center"?P.offset().left-260+"px":N.position.x=="right"?P.offset().left-10+(N.position.y=="center"?25:0)+"px":N.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":P.offset().left+parseInt(N.position.x)+
"px",position:"absolute",top:N.position.y=="top"?P.offset().top-312+"px":N.position.y=="center"?P.offset().top-156+"px":N.position.y=="bottom"?P.offset().top+25+"px":P.offset().top+parseInt(N.position.y)+"px"})}else{B=a(d);B.html(Ea)}Ea=B.find("tbody:first");q=Ea.find("div.Map:first");K=Ea.find("div.Bar:first");var Na=q.find("span"),Ra=K.find("span");S=Na.filter(".Map1:first");O=Na.filter(".Map2:first");H=Na.filter(".Map3:first");R=Ra.filter(".Map1:first");U=Ra.filter(".Map2:first");M=Ra.filter(".Map3:first");
ga=Ra.filter(".Map4:first");oa=Ra.filter(".Map5:first");ea=Ra.filter(".Map6:first");Q=new p(q,{map:{width:ia.colorMap.width,height:ia.colorMap.height},arrow:{image:ia.clientPath+ia.colorMap.arrow.file,width:ia.colorMap.arrow.width,height:ia.colorMap.arrow.height}});Q.bind(ya);Y=new p(K,{map:{width:ia.colorBar.width,height:ia.colorBar.height},arrow:{image:ia.clientPath+ia.colorBar.arrow.file,width:ia.colorBar.arrow.width,height:ia.colorBar.arrow.height}});Y.bind(Fa);xa=new h(Ea,ka.active,N.expandable&&
N.bindToInput?N.input:null,N.alphaPrecision);Na=da!=null?da.hex:null;var bb=Ea.find(".Preview");Ra=Ea.find(".Button");na=bb.find(".Active:first").css({backgroundColor:Na&&"#"+Na||"transparent"});qa=bb.find(".Current:first").css({backgroundColor:Na&&"#"+Na||"transparent"}).bind("click",Ca);va.call(d,qa,Math.precision(ka.current.val("a")*100)/255,4);ma=Ra.find(".Ok:first").bind("click touchstart",pb);la=Ra.find(".Cancel:first").bind("click touchstart",gb);za=Ra.find(".Grid:first");setTimeout(function(){Wa.call(d,
S,ia.clientPath+"Maps.png");Wa.call(d,O,ia.clientPath+"Maps.png");Wa.call(d,H,ia.clientPath+"map-opacity.png");Wa.call(d,R,ia.clientPath+"Bars.png");Wa.call(d,U,ia.clientPath+"Bars.png");Wa.call(d,M,ia.clientPath+"Bars.png");Wa.call(d,ga,ia.clientPath+"Bars.png");Wa.call(d,oa,ia.clientPath+"bar-opacity.png");Wa.call(d,ea,ia.clientPath+"AlphaBar.png");Wa.call(d,bb.find("div:last"),ia.clientPath+"preview-opacity.png")},0);Ea.find("td.Radio input").bind("click touchstart",Ta);if(ka.quickList&&ka.quickList.length>
0){Ra="";for(i=0;i<ka.quickList.length;i++){if((typeof ka.quickList[i]).toString().toLowerCase()=="string")ka.quickList[i]=new b({hex:ka.quickList[i]});var ob=ka.quickList[i].val("a"),Sa=ka.quickList[i].val("ahex");if(!N.alphaSupport&&Sa)Sa=Sa.substring(0,6)+"ff";var nb=ka.quickList[i].val("hex");Ra+='<span class="QuickColor"'+(Sa&&' title="#'+Sa+'"'||"")+' style="background-color:'+(nb&&"#"+nb||"")+";"+(nb?"":"background-image:url("+ia.clientPath+"NoColor.png)")+(N.alphaSupport&&ob&&ob<255?";opacity:"+
Math.precision(ob/255,4)+";filter:Alpha(opacity="+Math.precision(ob/2.55,4)+")":"")+'">&nbsp;</span>'}Wa.call(d,za,ia.clientPath+"bar-opacity.png");za.html(Ra);za.find(".QuickColor").click(sb)}Ia.call(d,l.color.mode);ka.active.bind(Da);a.isFunction(db)&&ka.active.bind(db);ka.current.bind(Ya);if(N.expandable){d.icon=P.parents(".Icon:first");Ga=d.icon.find(".Color:first").css({backgroundColor:Na&&"#"+Na||"transparent"});Aa=d.icon.find(".Alpha:first");Wa.call(d,Aa,ia.clientPath+"bar-opacity.png");va.call(d,
Aa,Math.precision((255-(da!=null?da.a:0))*100/255,4));Ha=d.icon.find(".Image:first").css({backgroundImage:"url('"+ia.clientPath+ia.picker.file+"')"}).bind("click",Xa);if(N.bindToInput&&N.updateInputColor)N.input.css({backgroundColor:Na&&"#"+Na||"transparent",color:da==null||da.v>75?"#000000":"#ffffff"});Ja=Ea.find(".Move:first").bind("mousedown",ta);ka.active.bind(ub)}else qb.call(d)},ia=l.images,aa=l.localization,ka={active:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&
2012-07-29 03:56:15 +00:00
l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),
2012-07-31 19:01:03 +00:00
quickList:l.color.quickList};a.extend(true,d,{commitCallback:kb,liveCallback:db,cancelCallback:mb,color:ka,show:qb,hide:vb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Ta);qa.unbind("click touchstart",Ca);la.unbind("click touchstart",gb);ma.unbind("click touchstart",pb);if(l.window.expandable){Ha.unbind("click",Xa);Ja.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",sb);ea=oa=ga=M=U=R=H=O=S=K=q=null;Q.destroy();Q=null;Y.destroy();Y=null;xa.destroy();
db=mb=kb=za=la=ma=qa=na=xa=null;B.html("");for(i=0;i<o.length;i++)o[i]==d&&o.splice(i,1)}});o.push(d);setTimeout(function(){wb.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new b({ahex:"#ffcc00ff"}),quickList:[new b({h:360,s:33,v:100}),new b({h:360,s:66,v:100}),new b({h:360,s:100,v:100}),
2012-07-27 23:32:02 +00:00
new b({h:360,s:100,v:75}),new b({h:360,s:100,v:50}),new b({h:180,s:0,v:100}),new b({h:30,s:33,v:100}),new b({h:30,s:66,v:100}),new b({h:30,s:100,v:100}),new b({h:30,s:100,v:75}),new b({h:30,s:100,v:50}),new b({h:180,s:0,v:90}),new b({h:60,s:33,v:100}),new b({h:60,s:66,v:100}),new b({h:60,s:100,v:100}),new b({h:60,s:100,v:75}),new b({h:60,s:100,v:50}),new b({h:180,s:0,v:80}),new b({h:90,s:33,v:100}),new b({h:90,s:66,v:100}),new b({h:90,s:100,v:100}),new b({h:90,s:100,v:75}),new b({h:90,s:100,v:50}),
new b({h:180,s:0,v:70}),new b({h:120,s:33,v:100}),new b({h:120,s:66,v:100}),new b({h:120,s:100,v:100}),new b({h:120,s:100,v:75}),new b({h:120,s:100,v:50}),new b({h:180,s:0,v:60}),new b({h:150,s:33,v:100}),new b({h:150,s:66,v:100}),new b({h:150,s:100,v:100}),new b({h:150,s:100,v:75}),new b({h:150,s:100,v:50}),new b({h:180,s:0,v:50}),new b({h:180,s:33,v:100}),new b({h:180,s:66,v:100}),new b({h:180,s:100,v:100}),new b({h:180,s:100,v:75}),new b({h:180,s:100,v:50}),new b({h:180,s:0,v:40}),new b({h:210,
s:33,v:100}),new b({h:210,s:66,v:100}),new b({h:210,s:100,v:100}),new b({h:210,s:100,v:75}),new b({h:210,s:100,v:50}),new b({h:180,s:0,v:30}),new b({h:240,s:33,v:100}),new b({h:240,s:66,v:100}),new b({h:240,s:100,v:100}),new b({h:240,s:100,v:75}),new b({h:240,s:100,v:50}),new b({h:180,s:0,v:20}),new b({h:270,s:33,v:100}),new b({h:270,s:66,v:100}),new b({h:270,s:100,v:100}),new b({h:270,s:100,v:75}),new b({h:270,s:100,v:50}),new b({h:180,s:0,v:10}),new b({h:300,s:33,v:100}),new b({h:300,s:66,v:100}),
new b({h:300,s:100,v:100}),new b({h:300,s:100,v:75}),new b({h:300,s:100,v:50}),new b({h:180,s:0,v:0}),new b({h:330,s:33,v:100}),new b({h:330,s:66,v:100}),new b({h:330,s:100,v:100}),new b({h:330,s:100,v:75}),new b({h:330,s:100,v:50}),new b]},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",
2012-07-25 08:56:15 +00:00
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)"},
2012-07-31 19:01:03 +00:00
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 p(o){var u=o||window.event,c=[].slice.call(arguments,1),f=0,d=0,l=0;o=a.event.fix(u);o.type="mousewheel";if(u.wheelDelta)f=u.wheelDelta/120;if(u.detail)f=-u.detail/3;l=f;if(u.axis!==undefined&&u.axis===u.HORIZONTAL_AXIS){l=0;d=-1*f}if(u.wheelDeltaY!==undefined)l=u.wheelDeltaY/120;if(u.wheelDeltaX!==undefined)d=-1*u.wheelDeltaX/120;c.unshift(o,f,d,l);return(a.event.dispatch||a.event.handle).apply(this,c)}var h=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var b=h.length;b;)a.event.fixHooks[h[--b]]=
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var o=h.length;o;)this.addEventListener(h[--o],p,false);else this.onmousewheel=p},teardown:function(){if(this.removeEventListener)for(var o=h.length;o;)this.removeEventListener(h[--o],p,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(o){return o?this.bind("mousewheel",o):this.trigger("mousewheel")},unmousewheel:function(o){return this.unbind("mousewheel",o)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){var p=svgEditor.canvas,h=svgedit.history.ChangeElementCommand,b={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},o=function(u,c,f){var d=null;if(u.indexOf("url(#")===0){u=(u=p.getRefElem(u))?u.cloneNode(true):$("#"+f+"_color defs *")[0];d={alpha:c};d[u.tagName]=u}else d=u.indexOf("#")===0?{alpha:c,solidColor:u.substr(1)}:{alpha:c,solidColor:"none"};
return new $.jGraduate.Paint(d)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",position:8,key:"I",icon:"extensions/eyedropper.png",events:{click:function(){p.setMode("eyedropper")}}}],mouseDown:function(u){var c=p.getMode(),f=u.event;f=f.target.id==="svgroot"?document.getElementById("canvas_background"):f.target;if(c=="eyedropper"&&f){b.fillPaint=f.getAttribute("fill")||"white";b.fillOpacity=f.getAttribute("fill-opacity")||
1;b.strokePaint=f.getAttribute("stroke")||"none";b.strokeOpacity=f.getAttribute("stroke-opacity")||1;b.strokeWidth=f.getAttribute("stroke-width");b.strokeDashArray=f.getAttribute("stroke-dasharray");b.strokeLinecap=f.getAttribute("stroke-linecap");b.strokeLinejoin=f.getAttribute("stroke-linejoin");b.opacity=f.getAttribute("opacity")||1;u.selectedElements=u.selectedElements.filter(Boolean);if(u.selectedElements.length){if($.inArray(u.selectedElements.nodeName,["g","use"])==-1){var d={},l=function(B,
q,K){d[q]=B.getAttribute(q);B.setAttribute(q,K)},v=new a.BatchCommand;u.selectedElements.forEach(function(B){b.fillPaint&&l(B,"fill",b.fillPaint);b.fillOpacity&&l(B,"fill-opacity",b.fillOpacity);b.strokePaint&&l(B,"stroke",b.strokePaint);b.strokeOpacity&&l(B,"stroke-opacity",b.strokeOpacity);b.strokeWidth&&l(B,"stroke-width",b.strokeWidth);b.strokeDashArray&&l(B,"stroke-dasharray",b.strokeDashArray);b.opacity&&l(B,"opacity",b.opacity);b.strokeLinecap&&l(B,"stroke-linecap",b.strokeLinecap);b.strokeLinejoin&&
l(B,"stroke-linejoin",b.strokeLinejoin);v.addSubCommand(new h(B,d));d={}});u=o(b.fillPaint,b.fillOpacity*100,"fill");c=o(b.strokePaint,b.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);p.undoMgr.addCommandToHistory(v)}}else{u=o(b.fillPaint,b.fillOpacity*100,"fill");c=o(b.strokePaint,b.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.setPaint(u);svgEditor.paintBox.stroke.setPaint(c)}}}}});svgEditor.addExtension("view_grid",function(a){function p(d){c.attr("width");c.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],v=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var B=o;l=l*d;var q=100/l,K=1;for(d=0;d<v.length;d++){var S=v[d];K=S;if(q<=S)break}v=K*l;B.width=v;B.height=v;l=B.getContext("2d");q=v/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(q*d)+0.5;l.moveTo(K,v);l.lineTo(K,0);l.moveTo(v,K);l.lineTo(0,K)}l.stroke();
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,v);l.lineTo(0.5,0);l.moveTo(v,0.5);l.lineTo(0,0.5);l.stroke();B=B.toDataURL("image/png");f.setAttribute("width",v);f.setAttribute("height",v);f.parentNode.setAttribute("width",v);f.parentNode.setAttribute("height",v);svgCanvas.setHref(f,B)}if(!document.getElementById("canvasGrid")){var h=document.getElementById("svgcanvas").ownerDocument,b=false;a=a.assignAttributes;var o=document.createElement("canvas");$(o).hide().appendTo("body");var u=h.createElementNS("http://www.w3.org/2000/svg",
2012-07-31 00:49:46 +00:00
"g");a(u,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var c=$("#canvas_background");c.after(u);u=h.createElementNS("http://www.w3.org/2000/svg","pattern");a(u,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var f=h.createElementNS("http://www.w3.org/2000/svg","image");a(f,{x:0,y:0,width:100,height:100});u.appendChild(f);$("#svgroot defs").append(u);h=h.createElementNS("http://www.w3.org/2000/svg","rect");a(h,{width:"100%",height:"100%",
2012-07-31 19:01:03 +00:00
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(h)}return{name:"view_grid",zoomChanged:function(d){b&&p(d)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){svgEditor.curConfig.showGrid=b=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
b=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(O){var H=q[O];if(H){K=H;H.buttons.length||h(O,H);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+O+".json",function(R){K=q[O]={data:R.data,size:R.size,fill:R.fill};h(O,R);a()})}}function h(O,H){var R=K.size||300,U=K.fill||false,M=R*0.05;M=[-M,-M,R+M*2,R+M*2].join(" ");R=U?0:R/30;R=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
M+'"><path fill="#333" stroke="transparent" stroke-width="'+R+'" /></svg></svg>',"text/xml");R.documentElement.setAttribute("width",40);R.documentElement.setAttribute("height",40);U=$(document.importNode(R.documentElement,true));var ga=H.data;K.buttons=[];for(var oa in ga){var ea=ga[oa],Q=U.clone();if(ea.charAt(ea.length-1)=="x"){R=32;M=R*0.05;M=[-M,-M,R+M*2,R+M*2].join(" ");Q.find("svg").attr("viewBox",M);ea.replace("x","")}Q.find("path").attr("d",ea);R=Q.wrap('<div class="tool_button">').parent().attr({id:S+
"_"+oa,title:oa});K.buttons.push(R[0])}}var b,o,u=svgEditor.canvas,c,f,d,l=u.getRootElem(),v={},B={basic:"Basic",object:"Objects",symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},q={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",
2012-07-19 15:25:04 +00:00
donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z",triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",
pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",heptagon:"m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z",
decagon:"m1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z",dodecagon:"m1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z",trapezoid:"m1,299l55.875,-298l186.25001,0l55.87498,298z",dialog_balloon_1:"m0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z",
heart:"m150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z",cylinder:"m299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z",arrow_up:"m1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z",
arrow_u_turn:"m1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z",arrow_left_up:"m0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z",
plaque:"m-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z",page:"m249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234",cross:"m0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z",
divide:"m150,0.99785l0,0c25.17819,0 45.58916,20.41097 45.58916,45.58916c0,25.17821 -20.41096,45.58916 -45.58916,45.58916c-25.17822,0 -45.58916,-20.41093 -45.58916,-45.58916c0,-25.1782 20.41093,-45.58916 45.58916,-45.58916zm0,296.25203c-25.17822,0 -45.58916,-20.41095 -45.58916,-45.58917c0,-25.17819 20.41093,-45.58916 45.58916,-45.58916c25.17819,0 45.58916,20.41096 45.58916,45.58916c0,25.17822 -20.41096,45.58917 -45.58916,45.58917zm-134.06754,-193.71518l268.13507,0l0,91.17833l-268.13507,0z",minus:"m0.99887,102.39503l297.49445,0l0,95.2112l-297.49445,0z",
2012-07-31 19:01:03 +00:00
times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z"},buttons:[]}},K=q.basic,S="shapelib";return{svgicons:"extensions/ext-shapes.xml",buttons:[{id:"tool_shapelib",type:"mode_flyout",position:6,title:"Shape library",icon:"extensions/ext-shapes.png",events:{click:function(){u.setMode(S)}}}],callback:function(){var O=
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(O);var H=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(U){U=$(U.target).closest("div.tool_button");if(U.length){var M=U.children().clone().attr({width:24,height:24});H.children(":not(.flyout_arrow_horiz)").remove();H.append(M).attr("data-curopt","#"+U[0].id).mouseup();u.setMode(S);o=U[0].id.substr((S+"_").length);b=K.data[o];$(".tools_flyout").fadeOut()}});O=$('<div id="shape_cats">');var R="";$.each(B,function(U,
M){R+="<div data-cat="+U+">"+M+"</div>"});O.html(R).children().bind("mouseup",function(){var U=$(this);U.siblings().removeClass("current");U.addClass("current");p(U.attr("data-cat"));return false});O.children().eq(0).addClass("current");$("#tools_shapelib").prepend(O);H.mouseup(function(){u.setMode(b?S:"select")});$("#tool_shapelib").remove();O=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(O/2),"margin-left":3})},mouseDown:function(O){if(u.getMode()===S){var H=f=O.start_x;
O=d=O.start_y;var R=u.getStyle();c=u.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:b,id:u.getNextId(),opacity:R.opacity/2,style:"pointer-events:none"}});c.setAttribute("d",b);if(/[a-z]/.test(b)){b=K.data[o]=u.pathActions.convertPath(c);c.setAttribute("d",b);u.pathActions.fixEnd(c)}c.setAttribute("transform","translate("+H+","+O+") scale(0.005) translate("+-H+","+-O+")");u.recalculateDimensions(c);u.getTransformList(c);v=c.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(O){if(u.getMode()===
S){var H=u.getZoom(),R=O.event,U=O.mouse_x/H,M=O.mouse_y/H;O=u.getTransformList(c);var ga=c.getBBox();H=ga.x;var oa=ga.y,ea=ga.width,Q=ga.height,Y=U-f,xa=M-d,ja={x:Math.min(f,U),y:Math.min(d,M),width:Math.abs(U-f),height:Math.abs(M-d)},ca=ga=0;Q=Q?(Q+xa)/Q:1;ea=ea?(ea+Y)/ea:1;ea=ja.width/v.width;Q=ja.height/v.height;ea=ea||1;Q=Q||1;if(U<f)ga=v.width;if(M<d)ca=v.height;U=l.createSVGTransform();M=l.createSVGTransform();ja=l.createSVGTransform();U.setTranslate(-(H+ga),-(oa+ca));if(R.shiftKey){replaced=
true;R=Math.min(Math.abs(ea),Math.abs(Q));ea=R*(ea<0?-1:1);Q=R*(Q<0?-1:1);if(totalScale.sx!=totalScale.sy){R=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;ea*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;Q*=R}}totalScale.sx*=ea;totalScale.sy*=Q;M.setScale(ea,Q);ja.setTranslate(H+ga,oa+ca);O.appendItem(ja);O.appendItem(M);O.appendItem(U);u.recalculateDimensions(c);v=c.getBBox()}},mouseUp:function(O){if(u.getMode()===S){if(O.mouse_x==f&&O.mouse_y==d)return{keep:false,element:c,
started:false};u.setMode("select");return{keep:true,element:c,started:false}}}}});(function(){for(var a=0,p=["ms","moz","webkit","o"],h=0;h<p.length&&!window.requestAnimationFrame;++h){window.requestAnimationFrame=window[p[h]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[p[h]+"CancelAnimationFrame"]||window[p[h]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var o=(new Date).getTime(),u=Math.max(0,16-(o-a)),c=window.setTimeout(function(){b(o+u)},u);a=o+u;return c};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
function(b){clearTimeout(b)}})();(function(a){function p(q){var K=q.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){c.call(this,q);q=a(this);q.bind(v,h);q.bind(l,b)}else{clearTimeout(B);u.call(this)}}function h(q){if(B!=null){var K=q.originalEvent;q=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var S=a(this).data("taphold.point");q=q-S.x;K=K-S.y;if(Math.sqrt(q*q+K*K)>d){clearTimeout(B);u.call(this)}}}function b(){clearTimeout(B);u.call(this)}
function o(q){u.call(this);a(this).data("taphold.handler").call(this,q)}function u(){B=null;a(this).unbind(v,h);a(this).unbind(l,b)}function c(q){if(B==null){var K=this;B=setTimeout(function(){o.call(K,q)},f);var S=q.originalEvent,O={};O.x=S.changedTouches?S.changedTouches[0].pageX:S.pageX;O.y=S.changedTouches?S.changedTouches[0].pageY:S.pageY;a(this).data("taphold.point",O)}}var f=1E3,d=5,l="touchend",v="touchmove",B=null;a.event.special.taphold={setup:function(){},add:function(q){a(this).data("taphold.handler",
q.handler);q.data?a(this).bind("touchstart",q.data,p):a(this).bind("touchstart",p)},remove:function(q){clearTimeout(B);u.call(this);q.data?a(this).unbind("touchstart",q.data,p):a(this).unbind("touchstart",p)},teardown:function(){}}})(jQuery);