687 lines
347 KiB
JavaScript
687 lines
347 KiB
JavaScript
function touchHandler(a){var p=a.changedTouches,g=p[0],b="";switch(a.type){case "touchstart":b="mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(b,true,true,window,1,g.screenX,g.screenY,g.clientX,g.clientY,false,false,false,false,0,null);if(p.length<2){g.target.dispatchEvent(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var b=g.handler,n=g.data.toLowerCase().split(" ");g.handler=function(s){if(!(this!==s.target&&(/textarea|select/i.test(s.target.nodeName)||s.target.type==="text"))){var c=s.type!=="keypress"&&a.hotkeys.specialKeys[s.which],f=String.fromCharCode(s.which).toLowerCase(),d="",k={};if(s.altKey&&c!=="alt")d+="alt+";if(s.ctrlKey&&c!=="ctrl")d+="ctrl+";if(s.metaKey&&!s.ctrlKey&&c!=="meta")d+="meta+";if(s.shiftKey&&c!=="shift")d+="shift+";if(c)k[d+c]=
|
|
true;else{k[d+f]=true;k[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")k[a.hotkeys.shiftNums[f]]=true}c=0;for(f=n.length;c<f;c++)if(k[n[c]])return b.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
|
|
106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function b(da){var X=d.call(arguments,1);return function(){return da.apply(this,X.concat(d.call(arguments)))}}function n(da,X,Z,pa,ra){var na;if(pa!==f){X=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=X[3]||"";if(ra===2&&g(pa))pa=pa.replace(da?Y:ba,"");else{na=o(X[2]);pa=g(pa)?o[da?ha:O](pa):pa;pa=ra===2?pa:ra===1?a.extend({},pa,na):a.extend({},na,pa);pa=q(pa);if(da)pa=pa.replace(ta,k)}da=X[1]+(da?"#":pa||!X[1]?"?":"")+pa+Z}else da=
|
|
X(Z!==f?Z:p[oa][ga]);return da}function s(da,X,Z){if(X===f||typeof X==="boolean"){Z=X;X=q[da?ha:O]()}else X=g(X)?X.replace(da?Y:ba,""):X;return o(X,Z)}function c(da,X,Z,pa){if(!g(Z)&&typeof Z!=="object"){pa=Z;Z=X;X=f}return this.each(function(){var ra=a(this),na=X||R()[(this.nodeName||"").toLowerCase()]||"",ma=na&&ra.attr(na)||"";ra.attr(na,q[da](ma,Z,pa))})}var f,d=Array.prototype.slice,k=decodeURIComponent,q=a.param,B,o,K,U=a.bbq=a.bbq||{},P,J,R,W=a.event.special,O="querystring",ha="fragment",oa=
|
|
"location",ga="href",ba=/^.*\?|#.*$/g,Y=/^.*\#/,ta,ja={};q[O]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ha]=B=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);ta=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,X){var Z={},pa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ra,na){var ma=na.split("="),Ca=k(ma[0]),Ja=Z,Ka=
|
|
0,Fa=Ca.split("]["),Ia=Fa.length-1;if(/\[/.test(Fa[0])&&/\]$/.test(Fa[Ia])){Fa[Ia]=Fa[Ia].replace(/\]$/,"");Fa=Fa.shift().split("[").concat(Fa);Ia=Fa.length-1}else Ia=0;if(ma.length===2){ma=k(ma[1]);if(X)ma=ma&&!isNaN(ma)?+ma:ma==="undefined"?f:pa[ma]!==f?pa[ma]:ma;if(Ia)for(;Ka<=Ia;Ka++){Ca=Fa[Ka]===""?Ja.length:Fa[Ka];Ja=Ja[Ca]=Ka<Ia?Ja[Ca]||(Fa[Ka+1]&&isNaN(Fa[Ka+1])?{}:[]):ma}else if(a.isArray(Z[Ca]))Z[Ca].push(ma);else Z[Ca]=Z[Ca]!==f?[Z[Ca],ma]:ma}else if(Ca)Z[Ca]=X?f:""});return Z};o[O]=b(s,
|
|
0);o[ha]=K=b(s,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(ja,da)})({a:ga,base:ga,iframe:"src",img:"src",input:"src",form:"action",link:ga,script:"src"});R=a.elemUrlAttr;a.fn[O]=b(c,O);a.fn[ha]=b(c,ha);U.pushState=P=function(da,X){if(g(da)&&/^#/.test(da)&&X===f)X=2;var Z=da!==f;Z=B(p[oa][ga],Z?da:{},Z?X:2);p[oa][ga]=Z+(/#/.test(Z)?"":"#")};U.getState=J=function(da,X){return da===f||typeof da==="boolean"?K(da):K(X)[da]};U.removeState=function(da){var X={};if(da!==f){X=J();a.each(a.isArray(da)?
|
|
da:arguments,function(Z,pa){delete X[pa]})}P(X,2)};W.hashchange=a.extend(W.hashchange,{add:function(da){function X(pa){var ra=pa[ha]=B();pa.getState=function(na,ma){return na===f||typeof na==="boolean"?o(ra,na):o(ra,ma)[na]};Z.apply(this,arguments)}var Z;if(a.isFunction(da)){Z=da;return X}else{Z=da.handler;da.handler=X}}})})(jQuery,this);
|
|
(function(a,p,g){function b(B){B=B||p[c][f];return B.replace(/^[^#]*#?(.*)$/,"$1")}var n,s=a.event.special,c="location",f="href",d=document.documentMode,k=a.browser.msie&&(d===g||d<8),q="onhashchange"in p&&!k;a.hashchangeDelay=100;s.hashchange=a.extend(s.hashchange,{setup:function(){if(q)return false;a(n.start)},teardown:function(){if(q)return false;a(n.stop)}});n=function(){function B(){P=J=function(R){return R};if(k){U=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
|
|
J=function(){return b(U.document[c][f])};P=function(R,W){if(R!==W){var O=U.document;O.open().close();O[c].hash="#"+R}};P(b())}}var o={},K,U,P,J;o.start=function(){if(!K){var R=b();P||B();(function W(){var O=b(),ha=J(R);if(O!==R){P(R=O,ha);a(p).trigger("hashchange")}else if(ha!==R)p[c][f]=p[c][f].replace(/#.*/,"")+"#"+ha;K=setTimeout(W,a.hashchangeDelay)})()}};o.stop=function(){if(!U){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(b,n){function s(da,X){if(da!=="ajax"){if(R)return;var Z=(U=ga[0].contentDocument)&&U.getElementById("svg_eof");if(!Z&&!(X&&Z)){W++;if(W<50)setTimeout(s,20);else{f();R=true}return}R=true}K=a(U.firstChild).children();if(n.no_img)setTimeout(function(){J||c()},500);else{Z=oa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";P=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){c(true)}).error(function(){c()})}}
|
|
function c(da,X){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(X){var pa=n.fallback_path?n.fallback_path:"";a.each(X,function(Ia,Oa){a("#"+Ia);var Ea=a(new Image).attr({"class":"svg_icon",src:pa+Oa,width:B,height:o,alt:"icon"});ja(Ea,Ia)})}else for(var ra=K.length,na=0;na<ra;na++){var ma=K[na],Ca=ma.id;if(Ca==="svg_eof")break;a("#"+Ca);ma=ma.getElementsByTagNameNS(k,"svg")[0];var Ja=document.createElementNS(k,"svg");Ja.setAttributeNS(k,"viewBox",
|
|
[0,0,B,o].join(" "));var Ka=ma.getAttribute("width"),Fa=ma.getAttribute("height");ma.removeAttribute("width");ma.removeAttribute("height");ma.getAttribute("viewBox")||ma.setAttribute("viewBox",[0,0,Ka,Fa].join(" "));Ja.setAttribute("xmlns",k);Ja.setAttribute("width",B);Ja.setAttribute("height",o);Ja.setAttribute("xmlns:xlink",q);Ja.setAttribute("class","svg_icon");ha||(ma=ma.cloneNode(true));Ja.appendChild(ma);if(da){ha||Ja.cloneNode(true);Z.empty().append(Ja);ma=oa+d(Z.html());ma=a(new Image).attr({"class":"svg_icon",
|
|
src:ma})}else ma=g(a(Ja),na);ja(ma,Ca)}n.placement&&a.each(n.placement,function(Ia,Oa){p[Oa]&&a(Ia).each(function(Ea){var wa=p[Oa].clone();if(Ea>0&&!da)wa=g(wa,Ea,true);ta(a(this),wa,Oa)})});if(!X){da&&Z.remove();ga&&ga.remove();P&&P.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)}
|
|
function d(da){if(window.btoa)return window.btoa(da);var X=Array(Math.floor((da.length+2)/3)*4),Z,pa,ra,na,ma,Ca,Ja=0,Ka=0;do{Z=da.charCodeAt(Ja++);pa=da.charCodeAt(Ja++);ra=da.charCodeAt(Ja++);na=Z>>2;Z=(Z&3)<<4|pa>>4;ma=(pa&15)<<2|ra>>6;Ca=ra&63;if(isNaN(pa))ma=Ca=64;else if(isNaN(ra))Ca=64;X[Ka++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na);X[Ka++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);X[Ka++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);
|
|
X[Ka++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Ca)}while(Ja<da.length);return X.join("")}var k="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,U,P,J=false,R=false,W=0,O=navigator.userAgent,ha=!!window.opera;O.indexOf("Safari/")>-1&&O.indexOf("Chrome/");var oa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var ga=a('<object data="'+b+'" type=image/svg+xml>').appendTo("body").hide();try{U=ga[0].contentDocument;ga.load(s);
|
|
s(0,true)}catch(ba){f()}}else{var Y=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){U=Y.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){U=Y.parseFromString(da.responseText,"text/xml");U.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var ta=function(da,X,Z,pa){ha&&X.css("visibility","hidden");if(n.replace){pa&&X.attr("id",Z);(Z=da.attr("class"))&&X.attr("class",
|
|
"svg_icon "+Z);da.replaceWith(X)}else da.append(X);ha&&setTimeout(function(){X.removeAttr("style")},1)},ja=function(da,X){if(n.id_match===undefined||n.id_match!==false)ta(holder,da,X,true);p[X]=da};g=function(da,X){var Z=da.find("defs");if(!Z.length)return da;Z=ha?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var pa=da[0].getElementsByTagName("*"),ra=pa.length;Z.each(function(na){var ma=this.id;a(U).find("#"+ma);this.id=na="x"+ma+X+na;ma="url(#"+ma+")";var Ca="url(#"+na+")";for(na=
|
|
0;na<ra;na++){var Ja=pa[na];Ja.getAttribute("fill")===ma&&Ja.setAttribute("fill",Ca);Ja.getAttribute("stroke")===ma&&Ja.setAttribute("stroke",Ca);Ja.getAttribute("filter")===ma&&Ja.setAttribute("filter",Ca)}});return da}};a.getSvgIcon=function(b,n){var s=p[b];if(n&&s)s=g(s,0,true).clone(true);return s};a.resizeSvgIcons=function(b){var n=!a(".svg_icon:first").length;a.each(b,function(s,c){var f=a.isArray(c),d=f?c[0]:c,k=f?c[1]:c;if(n)s=s.replace(/\.svg_icon/g,"svg");a(s).each(function(){this.setAttribute("width",
|
|
d);this.setAttribute("height",k);if(window.opera&&window.widget){this.parentNode.style.width=d+"px";this.parentNode.style.height=k+"px"}})})}})(jQuery);(function(){function a(b,n,s){b=document.createElementNS(p.svg,b);if(g)for(var c in n)b.setAttribute(c,n[c]);else for(c in n){var f=n[c],d=b[c];if(d&&d.constructor==="SVGLength")d.baseVal.value=f;else b.setAttribute(c,f)}s&&s.appendChild(b);return b}var p={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(b){b=b||{};this.alpha=isNaN(b.alpha)?100:b.alpha;if(b.copy){this.type=
|
|
b.copy.type;this.alpha=b.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=b.copy.solidColor;break;case "linearGradient":this.linearGradient=b.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=b.copy.radialGradient.cloneNode(true)}}else if(b.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=b.linearGradient.cloneNode(true)}else if(b.radialGradient){this.type=
|
|
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=b.radialGradient.cloneNode(true)}else if(b.solidColor){this.type="solidColor";this.solidColor=b.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var g=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(b){var n=
|
|
arguments;return this.each(function(){function s(ka,ca,la,M,T){var ea=T||a("stop",{"stop-color":ca,"stop-opacity":la,offset:ka},Y);if(T){ca=T.getAttribute("stop-color");la=T.getAttribute("stop-opacity");ka=T.getAttribute("offset")}else Y.appendChild(ea);if(la===null)la=1;T=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+ka*ha)+", 26)"},nb);var Ga=
|
|
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":la,transform:"translate("+(10+ka*ha)+", 26)",stroke:"#000","stroke-width":1.5},nb);$(Ga).mousedown(function(Pa){c(this);Ya=Qa;R.mousemove(k).mouseup(f);xa=Ab.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",T).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Za=+ea.getAttribute("stop-opacity")||
|
|
1,gb=ea.getAttribute("stop-color")||1,pb=(parseFloat(Za)*255).toString(16);pb.length<2;)pb="0"+pb;ca=gb.substr(1)+pb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Ra){gb=Ra.val("hex")?"#"+Ra.val("hex"):"none";Za=Ra.val("a")!==null?Ra.val("a")/256:1;Pa.setAttribute("fill",gb);Pa.setAttribute("fill-opacity",Za);ea.setAttribute("stop-color",
|
|
gb);ea.setAttribute("stop-opacity",Za);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(Y).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>ka){if(!ca){var Za=this.getAttribute("stop-color"),gb=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Za);Ga.setAttribute("fill",Za);ea.setAttribute("stop-opacity",gb===null?1:gb);Ga.setAttribute("fill-opacity",
|
|
gb===null?1:gb)}Pa.before(ea);return false}});M&&c(Ga);return ea}function c(ka){Qa&&Qa.setAttribute("stroke","#000");ka.setAttribute("stroke","blue");Qa=ka;Qa.parentNode.appendChild(Qa)}function f(){R.unbind("mousemove",k);if(Ba.getAttribute("display")!=="none"){Ba.setAttribute("display","none");var ka=$(Qa),ca=ka.data("stop");ka=ka.data("bg");$([Qa,ca,ka]).remove()}Ya=null}function d(){var ka=Va?"rotate("+Va+","+Da+","+kb+") ":"";ib===1&&La===1?Y.removeAttribute("gradientTransform"):Y.setAttribute("gradientTransform",
|
|
ka+"translate("+-Da*(ib-1)+","+-kb*(La-1)+") scale("+ib+","+La+")")}function k(ka){var ca=ka.pageX-xa.left;ka=ka.pageY-xa.top;ca=ca<10?10:ca>ha+10?ha+10:ca;var la="translate("+ca+", 26)";if(ka<-60||ka>130){Ba.setAttribute("display","block");Ba.setAttribute("transform",la)}else Ba.setAttribute("display","none");Ya.setAttribute("transform",la);$.data(Ya,"bg").setAttribute("transform",la);$.data(Ya,"stop").setAttribute("offset",(ca-10)/ha);var M=0;$(Y).find("stop").each(function(){var T=this.getAttribute("offset"),
|
|
ea=$(this);if(T<M){ea.prev().before(ea);za=$(Y).find("stop")}M=T})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var U=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},P=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
|
|
q.hide()};$.extend(true,q,{paint:new $.jGraduate.Paint({copy:B.paint}),okCallback:$.isFunction(n[1])&&n[1]||null,cancelCallback:$.isFunction(n[2])&&n[2]||null});q.position();var J=null,R=$(window);if(q.paint.type=="none")q.paint=$.jGraduate.Paint({solidColor:"ffffff"});q.addClass("jGraduate_Picker");q.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+
|
|
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var W=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
|
|
o+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_y1" size="3" title="Enter starting y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">End Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
|
|
o+'_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="'+o+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_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="'+
|
|
o+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+o+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_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="'+
|
|
o+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+o+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+o+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+
|
|
o+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+o+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+o+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+B.images.clientPath+
|
|
'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba </label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+o+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+o+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+B.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+o+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
|
|
o+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+o+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ha=256,oa=ha-0,ga=ha-0,ba,Y,ta,ja={};$(".jGraduate_SliderBar").width(145);var da=$("#"+o+"_jGraduate_GradContainer")[0],X=a("svg",{id:o+"_jgraduate_svg",width:ha,height:ha,xmlns:p.svg},da);ba=ba||q.paint.type;var Z=Y=q.paint[ba],pa=q.paint.alpha,ra=ba==="solidColor";switch(ba){case "solidColor":case "linearGradient":if(!ra){Y.id=o+"_lg_jgraduate_grad";
|
|
Z=Y=X.appendChild(Y)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},X);if(ba==="linearGradient")break;case "radialGradient":if(!ra){Y.id=o+"_rg_jgraduate_grad";Z=Y=X.appendChild(Y)}a("linearGradient",{id:o+"_lg_jgraduate_grad"},X)}if(ra){Z=Y=$("#"+o+"_lg_jgraduate_grad")[0];J=q.paint[ba];s(0,"#"+J,1);var na=typeof B.newstop;if(na==="string")switch(B.newstop){case "same":s(1,"#"+J,1);break;case "inverse":na="";for(var ma=0;ma<6;ma+=2){J.substr(ma,2);var Ca=(255-parseInt(J.substr(ma,2),16)).toString(16);
|
|
if(Ca.length<2)Ca=0+Ca;na+=Ca}s(1,"#"+na,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(na==="object")s(1,B.newstop.color||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(Z.getAttribute("x1")||0);na=parseFloat(Z.getAttribute("y1")||0);ma=parseFloat(Z.getAttribute("x2")||1);Ca=parseFloat(Z.getAttribute("y2")||0);var Ja=parseFloat(Z.getAttribute("cx")||0.5),Ka=parseFloat(Z.getAttribute("cy")||0.5),Fa=parseFloat(Z.getAttribute("fx")||Ja),Ia=parseFloat(Z.getAttribute("fy")||
|
|
Ka);ta=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:oa,height:ga,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":pa/100},X);var Oa=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:na*ha,left:J*ha}).data("coord","start").appendTo(da),Ea=Oa.clone().text(2).css({top:Ca*ha,left:ma*ha}).attr("title","End stop").data("coord","end").appendTo(da),wa=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ka*ha,left:Ja*
|
|
ha}).data("coord","center").appendTo(da),Ha=wa.clone().text("F").css({top:Ia*ha,left:Fa*ha,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ka,ca){var la=Y.getAttribute(ca),M=isNaN(ca[1]);la||(la=M?"0.5":ca==="x2"?"1.0":"0.0");ja[ca]=$("#"+o+"_jGraduate_"+ca).val(la).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
|
|
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(M&&ba==="radialGradient"||!M&&ba==="linearGradient")Y.setAttribute(ca,this.value);var T=M?ca[0]==="c"?wa:Ha:ca[1]==="1"?Oa:Ea,ea=ca.indexOf("x")>=0?"left":"top";T.css(ea,this.value*ha)}).change()});var za,nb,Ab=$("#"+o+"_jGraduate_StopSlider"),Qa,Wa,Ya,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"},Wa),xa,ib=1,La=1,Va=0,Da=Ja,kb=Ka;Wa=a("svg",{width:"100%",height:45},Ab[0]);da=a("pattern",{width:16,
|
|
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(ka){xa=Ab.offset();if(ka.target.tagName!=="path"){var ca=ka.pageX-xa.left-8;ca=ca<10?10:ca>ha+10?ha+10:ca;s(ca/ha,0,0,true);ka.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Ba)});nb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ha+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb=
|
|
O.find(".jGraduate_spreadMethod").change(function(){Y.setAttribute("spreadMethod",$(this).val())}),$a=null,cb=function(ka){var ca=ka.pageX-lb.left,la=ka.pageY-lb.top;ca=ca<0?0:ca>ha?ha:ca;la=la<0?0:la>ha?ha:la;$a.css("left",ca).css("top",la);ca=ca/oa;la=la/ga;var M=$a.data("coord"),T=Y;switch(M){case "start":ja.x1.val(ca);ja.y1.val(la);T.setAttribute("x1",ca);T.setAttribute("y1",la);break;case "end":ja.x2.val(ca);ja.y2.val(la);T.setAttribute("x2",ca);T.setAttribute("y2",la);break;case "center":ja.cx.val(ca);
|
|
ja.cy.val(la);T.setAttribute("cx",ca);T.setAttribute("cy",la);Da=ca;kb=la;d();break;case "focus":ja.fx.val(ca);ja.fy.val(la);T.setAttribute("fx",ca);T.setAttribute("fy",la);d()}ka.preventDefault()},Cb=function(){$a=null;R.unbind("mousemove",cb).unbind("mouseup",Cb)};za=Y.getElementsByTagNameNS(p.svg,"stop");if(ua<2){for(;ua<2;){Y.appendChild(document.createElementNS(p.svg,"stop"));++ua}za=Y.getElementsByTagNameNS(p.svg,"stop")}var ua=za.length;for(ma=0;ma<ua;ma++)s(0,0,0,0,za[ma]);sb.val(Y.getAttribute("spreadMethod")||
|
|
"pad");var lb,jb=false;ta.setAttribute("fill-opacity",pa/100);$("#"+o+" div.grad_coord").mousedown(function(ka){ka.preventDefault();$a=$(this);$a.offset();lb=$a.parent().offset();R.mousemove(cb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=Y.cloneNode(true);q.paint.solidColor=null;U()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){P()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ja.fx.val("");ja.fy.val("")}$("#"+
|
|
o+"_jGraduate_match_ctr")[0].checked=!jb;var wb,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ja.fx.val("");ja.fy.val("");var ka=Y;if(jb){var ca=wb||0.5,la=ob||0.5;ka.setAttribute("fx",ca);ka.setAttribute("fy",la);ja.fx.val(ca);ja.fy.val(la)}else{wb=ka.getAttribute("fx");ob=ka.getAttribute("fy");ka.removeAttribute("fx");ka.removeAttribute("fy")}});za=Y.getElementsByTagNameNS(p.svg,"stop");ua=za.length;if(ua<2){for(;ua<2;){Y.appendChild(document.createElementNS(p.svg,
|
|
"stop"));++ua}za=Y.getElementsByTagNameNS(p.svg,"stop")}var hb;pa=O=0;if(ba==="radialGradient"){X=Y.gradientTransform.baseVal;if(X.numberOfItems===2){ua=X.getItem(0);X=X.getItem(1);if(ua.type===2&&X.type===3){ua=X.matrix;if(ua.a!==1)O=Math.round(-(1-ua.a)*100);else if(ua.d!==1)O=Math.round((1-ua.d)*100)}}else if(X.numberOfItems===3){da=X.getItem(0);ua=X.getItem(1);X=X.getItem(2);if(da.type===4&&ua.type===2&&X.type===3){pa=Math.round(da.angle);ua=X.matrix;if(ua.a!==1)O=Math.round(-(1-ua.a)*100);else if(ua.d!==
|
|
1)O=Math.round((1-ua.d)*100)}}}O={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(Y.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:O},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:pa}};$.each(O,function(ka,ca){var la=$(ca.handle);la.mousedown(function(M){var T=
|
|
la.parent();hb={type:ka,elem:la,input:$(ca.input),parent:T,offset:T.offset()};R.mousemove(qb).mouseup(tb);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,T=0,ea=ba==="radialGradient";switch(ka){case "radius":ea&&Y.setAttribute("r",M/100);T=Math.pow(M/100,0.4)/2*145;break;case "opacity":q.paint.alpha=M;ta.setAttribute("fill-opacity",M/100);T=M*1.45;break;case "ellip":ib=La=1;if(M===0){T=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else ib=-(M/100)-1;T=145*((M+100)/
|
|
2)/100;ea&&d();break;case "angle":Va=M;T=Va/180;T+=0.5;T*=145;ea&&d()}if(T>145)T=145;else if(T<0)T=0;la.css({"margin-left":T-5})}).change()});var qb=function(ka){var ca=ka.pageX-hb.offset.left-parseInt(hb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var la=ca-5;ca/=145;switch(hb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;Y.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);ta.setAttribute("fill-opacity",ca);break;
|
|
case "ellip":La=ib=1;if(ca<0.5){ca/=0.5;ib=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}hb.elem.css({"margin-left":la});ca=Math.round(ca*100);hb.input.val(ca);ka.preventDefault()},tb=function(){R.unbind("mousemove",qb).unbind("mouseup",tb);hb=null};for(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;ra||(J=za[0].getAttribute("stop-color"));
|
|
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});W.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(ka){q.paint.type="solidColor";q.paint.alpha=ka.val("ahex")?Math.round(ka.val("a")/255*100):100;q.paint.solidColor=ka.val("hex")?ka.val("hex"):"none";q.paint.radialGradient=null;U()},null,function(){P()});var Bb=$(K+" .jGraduate_tabs li");Bb.on("click touchstart",function(){Bb.removeClass("jGraduate_tab_current");
|
|
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var ka=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(ka==="rg"||ka==="lg"){$(".jGraduate_"+ka+"_field").show();$(".jGraduate_"+(ka==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+ka+"_jgraduate_grad)");ba=ka==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+ka+"_jgraduate_grad")[0];if(Y!==ca){var la=
|
|
$(Y).find("stop");$(ca).empty().append(la);Y=ca;ca=sb.val();Y.setAttribute("spreadMethod",ca)}jb=ka==="rg"&&Y.getAttribute("fx")!=null&&!(Ja==Fa&&Ka==Ia);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();Bb.removeClass("jGraduate_tab_current");var xb;switch(q.paint.type){case "linearGradient":xb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":xb=
|
|
$(K+" .jGraduate_tab_radgrad");break;default:xb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){xb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,b){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),c=$("#"+g.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(k){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
|
|
g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(k,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var k=$(this);k.unbind("mouseup");f(d,d,k)});var f=function(d,k,q){if(typeof k=="undefined")k=d;d.stopPropagation();if(n.hasClass("disabled")||k.altKey)return false;var B=d.pageX,o=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;o=d.originalEvent.touches[0].pageY}d=a.width()-c.width();k=a.height()-c.height();if(B>d-15)B=d-15;
|
|
if(o>k-30)o=k-30;if(svgedit.browser.isTouch())o-=c.height()/2;p.unbind("click");c.css({top:o,left:B}).fadeIn(g.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
|
|
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),
|
|
$(q),{x:B-s.left,y:o-s.top,docX:B,docY:o});return false});setTimeout(function(){p.click(function(){p.unbind("click").unbind("keypress");c.fadeOut(g.outSpeed);return false})},0)};if($.browser.mozilla)$("#"+g.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+g.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+g.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})});$(n).add($("UL.contextMenu")).bind("contextmenu",
|
|
function(){return false})});return $(this)},disableContextMenuItems:function(g){if(g==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(g!=undefined)for(var b=g.split(","),n=0;n<b.length;n++)$(this).find('A[href="'+b[n]+'"]').parent().addClass("disabled")});return $(this)},enableContextMenuItems:function(g){if(g==undefined){$(this).find("LI.disabled").removeClass("disabled");return $(this)}$(this).each(function(){if(g!=undefined)for(var b=g.split(","),n=
|
|
0;n<b.length;n++)$(this).find('A[href="'+b[n]+'"]').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,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),b=!!window.opera,n=p.indexOf("AppleWebKit")>=0,s=p.indexOf("Gecko/")>=0,c=p.indexOf("MSIE")>=0,f=p.indexOf("Chrome/")>=0,d=p.indexOf("Windows")>=0,k=p.indexOf("Macintosh")>=
|
|
0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var ga=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{ga.replaceItem(oa,0);return true}catch(ba){}return false}(),U=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","path");oa.setAttribute("d","M0,0 10,10");var ga=oa.pathSegList;oa=oa.createSVGPathSegLinetoAbs(5,5);try{ga.insertItemBefore(oa,
|
|
0);return true}catch(ba){}return false}(),P=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg"),ga=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);ga.setAttribute("x",5);oa.appendChild(ga);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";ga.appendChild(ba);ga=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(oa);return ga===0}(),J=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg",
|
|
"svg");document.documentElement.appendChild(oa);var ga=document.createElementNS("http://www.w3.org/2000/svg","path");ga.setAttribute("d","M0,0 C0,0 10,10 10,0");oa.appendChild(ga);ga=ga.getBBox();document.documentElement.removeChild(oa);return ga.height>4&&ga.height<5}(),R=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(oa);var ga=document.createElementNS("http://www.w3.org/2000/svg","path");ga.setAttribute("d","M0,0 10,0");var ba=
|
|
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(ga);Y.appendChild(ba);oa.appendChild(Y);ga=Y.getBBox();document.documentElement.removeChild(oa);return ga.width==15}(),W=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}(),O=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"}(),ha=function(){var oa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,ga=g.createSVGTransform();oa.appendItem(ga);return oa.getItem(0)==ga}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return s};
|
|
svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return k};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return U};svgedit.browser.supportsPathBBox=function(){return J};
|
|
svgedit.browser.supportsHVLineContainerBBox=function(){return R};svgedit.browser.supportsGoodTextCharPos=function(){return P};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return W};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ha}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),p={};svgedit.transformlist.SVGTransformList=function(g){this._elem=g||null;this._xforms=[];this._update=function(){var b="";a.createSVGMatrix();for(var n=0;n<this.numberOfItems;++n){var s=this._list.getItem(n);b=b;s=s;var c=s.matrix,f="";switch(s.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(s.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("+s.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 n=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,s=true;s;){s=b.match(n);b=b.replace(n,"");if(s&&s[1]){var c=s[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(/[, ]+/),k="abcdef".split(""),q=a.createSVGMatrix();$.each(d,function(K,U){d[K]=parseFloat(U);if(f=="matrix")q[k[K]]=d[K]});c=a.createSVGTransform();var B="set"+f.charAt(0).toUpperCase()+f.slice(1),o=f=="matrix"?[q]:d;if(f=="scale"&&o.length==1)o.push(o[0]);else if(f=="translate"&&o.length==1)o.push(0);else if(f=="rotate"&&o.length==1){o.push(0);o.push(0)}c[B].apply(c,o);this._list.appendItem(c)}}};this._removeFromOtherLists=function(b){if(b){var n=
|
|
false,s;for(s in p){for(var c=p[s],f=0,d=c._xforms.length;f<d;++f)if(c._xforms[f]==b){n=true;c.removeItem(f);break}if(n)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,n){var s=null;if(n>=0)if(n<this.numberOfItems){this._removeFromOtherLists(b);
|
|
s=Array(this.numberOfItems+1);for(var c=0;c<n;++c)s[c]=this._xforms[c];s[c]=b;for(var f=c+1;c<this.numberOfItems;++f,++c)s[f]=this._xforms[c];this.numberOfItems++;this._xforms=s;s=b;this._list._update()}else s=this._list.appendItem(b);return s};this.replaceItem=function(b,n){var s=null;if(n<this.numberOfItems&&n>=0){this._removeFromOtherLists(b);s=this._xforms[n]=b;this._list._update()}return s};this.removeItem=function(b){if(b<this.numberOfItems&&b>=0){for(var n=this._xforms[b],s=Array(this.numberOfItems-
|
|
1),c=0;c<b;++c)s[c]=this._xforms[c];for(b=c;b<this.numberOfItems-1;++b,++c)s[b]=this._xforms[c+1];this.numberOfItems--;this._xforms=s;this._list._update();return n}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(g){g.id&&p[g.id]&&delete p[g.id]};svgedit.transformlist.getTransformList=function(g){if(svgedit.browser.supportsNativeTransformLists())if(g.transform)return g.transform.baseVal;
|
|
else if(g.gradientTransform)return g.gradientTransform.baseVal;else{if(g.patternTransform)return g.patternTransform.baseVal}else{var b=g.id;b||(b="temp");var n=p[b];if(!n||b=="temp"){p[b]=new svgedit.transformlist.SVGTransformList(g);p[b]._init();n=p[b]}return n}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,g,b){return{x:b.a*p+b.c*g+b.e,y:b.b*p+b.d*g+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,g=p.length,b=p[g-1];g-- >1;)b=p[g-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 g=p.numberOfItems;g--;){var b=p.getItem(g);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(p,g,b,n,s){var c={x:p,y:g},f={x:p+b,y:g};b={x:p+b,y:g+n};p={x:p,y:g+n};g=svgedit.math.transformPoint;c=g(c.x,c.y,s);var d=n=c.x,k=c.y,q=c.y;f=g(f.x,f.y,s);n=Math.min(n,f.x);d=Math.max(d,f.x);
|
|
k=Math.min(k,f.y);q=Math.max(q,f.y);p=g(p.x,p.y,s);n=Math.min(n,p.x);d=Math.max(d,p.x);k=Math.min(k,p.y);q=Math.max(q,p.y);b=g(b.x,b.y,s);n=Math.min(n,b.x);d=Math.max(d,b.x);k=Math.min(k,b.y);q=Math.max(q,b.y);return{tl:c,tr:f,bl:p,br:b,aabox:{x:n,y:k,width:d-n,height:q-k}}};svgedit.math.transformListToTransform=function(p,g,b){if(p==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());g=g==undefined?0:g;b=b==undefined?p.numberOfItems-1:b;g=parseInt(g);b=parseInt(b);if(g>b){var n=b;b=g;
|
|
g=n}n=a.createSVGMatrix();for(g=g;g<=b;++g){var s=g>=0&&g<p.numberOfItems?p.getItem(g).matrix:a.createSVGMatrix();n=svgedit.math.matrixMultiply(n,s)}return a.createSVGTransformFromMatrix(n)};svgedit.math.getMatrix=function(p){p=svgedit.transformlist.getTransformList(p);return svgedit.math.transformListToTransform(p).matrix};svgedit.math.snapToAngle=function(p,g,b,n){var s=Math.PI/4;b=b-p;var c=n-g;n=Math.sqrt(b*b+c*c);s=Math.round(Math.atan2(c,b)/s)*s;return{x:p+n*Math.cos(s),y:g+n*Math.sin(s),a:s}};
|
|
svgedit.math.rectsIntersect=function(p,g){return g.x<p.x+p.width&&g.x+g.width>p.x&&g.y<p.y+p.height&&g.y+g.height>p.y}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],p=["y","y1","cy","ry","height"],g=$.merge(["r","radius"],a);$.merge(g,p);var b,n={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;n.em=f.width;n.ex=f.height;n["in"]=c;n.cm=c/2.54;n.mm=c/25.4;n.pt=c/72;n.pc=c/6;n["%"]=0};svgedit.units.getTypeMap=function(){return n};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/n[f])};svgedit.units.setUnitAttr=function(c,
|
|
f,d){isNaN(d)||c.getAttribute(f);c.setAttribute(f,d)};var s={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=s[f])for(var k=f.length,q=0;q<k;q++){var B=f[q],o=c.getAttribute(B);if(o)isNaN(o)||c.setAttribute(B,o/n[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,k=b.getWidth(),q=b.getHeight();return a.indexOf(c)>=0?d*k:p.indexOf(c)>=0?d*q:d*Math.sqrt(k*k+q*q)/Math.sqrt(2)}else{k=f.substr(-2);d=f.substr(0,f.length-2);return d*n[k]}};svgedit.units.isValidUnit=function(c,f,d){var k=false;if(g.indexOf(c)>=0)if(isNaN(f)){f=f.toLowerCase();$.each(n,function(o){if(!k)if(RegExp("^-?[\\d\\.]+"+o+"$").test(f))k=true})}else k=true;else if(c=="id"){c=false;try{var q=b.getElement(f);
|
|
c=q==null||q===d}catch(B){}return c}else k=true;return k}})();svgedit=svgedit||{};
|
|
(function(){function a(c){if(svgedit.browser.supportsHVLineContainerBBox())try{return c.getBBox()}catch(f){}var d=$.data(c,"ref"),k=null;if(d){var q=$(d).children().clone().attr("visibility","hidden");$(s).append(q);k=q.filter("line, path")}else k=$(c).find("line, path");var B=false;if(k.length){k.each(function(){var o=this.getBBox();if(!o.width||!o.height)B=true});if(B){c=d?q:$(c).children();ret=getStrokedBBox(c)}else ret=c.getBBox()}else ret=c.getBBox();d&&q.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(","),g=null,b=null,n=null,s=null;svgedit.utilities.init=function(c){g=c;b=c.getDOMDocument();n=c.getDOMContainer();s=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,k,q,B,o,K,U=0,P=0;do{d=c.charCodeAt(U++);k=c.charCodeAt(U++);q=c.charCodeAt(U++);B=d>>2;d=(d&3)<<4|k>>4;o=(k&15)<<2|q>>6;K=q&63;if(isNaN(k))o=K=64;else if(isNaN(q))K=64;f[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);f[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);f[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(o);f[P++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(K)}while(U<
|
|
c.length);return f.join("")};svgedit.utilities.decode64=function(c){if(window.atob)return window.atob(c);var f="",d,k,q="",B,o="",K=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));
|
|
d=d<<2|k>>4;k=(k&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+=String.fromCharCode(k);if(o!=64)f+=String.fromCharCode(q)}while(K<c.length);return unescape(f)};svgedit.utilities.convertToXMLReferences=function(c){for(var f="",d=0;d<c.length;d++){var k=c.charCodeAt(d);if(k<128)f+=c[d];else if(k>127)f+="&#"+k+";"}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(k){throw Error("XML Parser could not be instantiated");}try{f=d.loadXML?d.loadXML(c)?d:false:d.parseFromString(c,"text/xml")}catch(q){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)}};
|
|
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",
|
|
"href")};svgedit.utilities.setHref=function(c,f){c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(c){c=g.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 k=f.getItem(0),
|
|
q=[k.x,k.y];for(k=0;k<d;k++){var B=f.getItem(k);if(typeof B.x!="undefined"){c[0].push(q[0]);c[1].push(q[1]);if(B.x1){for(var o=[B.x1,B.y1],K=[B.x2,B.y2],U=[B.x,B.y],P=0;P<2;P++){B=function(ha){return Math.pow(1-ha,3)*q[P]+3*Math.pow(1-ha,2)*ha*o[P]+3*(1-ha)*Math.pow(ha,2)*K[P]+Math.pow(ha,3)*U[P]};var J=6*q[P]-12*o[P]+6*K[P],R=-3*q[P]+9*o[P]-9*K[P]+3*U[P],W=3*o[P]-3*q[P];if(R==0){if(J!=0){J=-W/J;0<J&&J<1&&c[P].push(B(J))}}else{W=Math.pow(J,2)-4*W*R;if(!(W<0)){var O=(-J+Math.sqrt(W))/(2*R);0<O&&O<
|
|
1&&c[P].push(B(O));J=(-J-Math.sqrt(W))/(2*R);0<J&&J<1&&c[P].push(B(J))}}}q=U}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;k=Math.min.apply(null,c[1]);c=Math.max.apply(null,c[1])-k;return{x:f,y:k,width:d,height:c}};svgedit.utilities.getBBox=function(c){var f=c||g.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(k){}break;
|
|
case "path":if(svgedit.browser.supportsPathBBox())try{c=f.getBBox()}catch(q){}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(o){c=
|
|
null}else c=null}}if(c)c=svgedit.utilities.bboxToObj(c);return c};svgedit.utilities.getRotationAngle=function(c,f){var d=c||g.getSelectedElements()[0];d=svgedit.transformlist.getTransformList(d);if(!d)return 0;for(var k=d.numberOfItems,q=0;q<k;++q){var B=d.getItem(q);if(B.type==4)return f?B.angle*Math.PI/180:B.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(c){return s.querySelector("#"+c)}:svgedit.browser.supportsXpath()?function(c){return b.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
|
|
c+'"]',n,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(c){return $(s).find("[id="+c+"]")[0]};svgedit.utilities.assignAttributes=function(c,f,d,k){d||(d=0);svgedit.browser.isOpera()||s.suspendRedraw(d);for(var q in f)if(d=q.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":q.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)c.setAttributeNS(d,q,f[q]);else k?svgedit.units.setUnitAttr(c,q,f[q]):c.setAttribute(q,f[q]);svgedit.browser.isOpera()||s.unsuspendRedraw(null)};
|
|
svgedit.utilities.cleanupElement=function(c){var f=s.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},k;for(k in d){var q=d[k];c.getAttribute(k)==q&&c.removeAttribute(k)}s.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(n,s){p[s]=n});var g={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray",
|
|
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class",
|
|
"clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters",
|
|
"filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage",
|
|
"transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
|
|
"stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class",
|
|
"clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class",
|
|
"clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points",
|
|
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray",
|
|
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],
|
|
symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity",
|
|
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight",
|
|
"id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width",
|
|
"style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth",
|
|
"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},b={};$.each(g,function(n,s){var c={};$.each(s,function(f,d){if(d.indexOf(":")>=
|
|
0){var k=d.split(":");c[k[1]]=p[k[0]]}else c[d]=d=="xmlns"?"http://www.w3.org/2000/xmlns/":null});b[n]=c});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(n){if(n.nodeType==3){n.nodeValue=n.nodeValue.replace(/^\s+|\s+$/g,"");n.nodeValue.length||n.parentNode.removeChild(n)}if(n.nodeType==1){var s=n.parentNode;if(n.ownerDocument&&s){var c=g[n.nodeName],f=b[n.nodeName];if(c!=undefined){for(var d=[],k=n.attributes.length;k--;){var q=n.attributes.item(k),B=q.nodeName,
|
|
o=q.localName,K=q.namespaceURI;if(!(f.hasOwnProperty(o)&&K==f[o]&&K!="http://www.w3.org/2000/xmlns/")&&!(K=="http://www.w3.org/2000/xmlns/"&&a[q.nodeValue])){B.indexOf("se:")==0&&d.push([B,q.nodeValue]);n.removeAttributeNS(K,o)}if(svgedit.browser.isGecko())switch(B){case "transform":case "gradientTransform":case "patternTransform":o=q.nodeValue.replace(/(\d)-/g,"$1 -");n.setAttribute(B,o)}if(B=="style"){q=q.nodeValue.split(";");for(B=q.length;B--;){o=q[B].split(":");c.indexOf(o[0])>=0&&n.setAttribute(o[0],
|
|
o[1])}n.removeAttribute("style")}}$.each(d,function(U,P){n.setAttributeNS("http://svg-edit.googlecode.com",P[0],P[1])});if((k=svgedit.utilities.getHref(n))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(n.nodeName)>=0)if(k[0]!="#"){svgedit.utilities.setHref(n,"");n.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(n.nodeName=="use"&&!svgedit.utilities.getHref(n))s.removeChild(n);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start",
|
|
"mask","stroke"],function(U,P){var J=n.getAttribute(P);if(J)if((J=svgedit.utilities.getUrlFromAttr(J))&&J[0]!=="#"){n.setAttribute(P,"");n.removeAttribute(P)}});for(k=n.childNodes.length;k--;)svgedit.sanitize.sanitizeSvg(n.childNodes.item(k))}}else{for(c=[];n.hasChildNodes();)c.push(s.insertBefore(n.firstChild,n));s.removeChild(n);for(k=c.length;k--;)svgedit.sanitize.sanitizeSvg(c[k])}}}}})();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,g,b){this.elem=a;this.text=b?"Move "+a.tagName+" to "+b:"Move "+a.tagName;this.oldNextSibling=p;this.oldParent=g;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};svgedit.history.MoveElementCommand.prototype.type=
|
|
svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
|
|
this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,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,
|
|
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,g,b){this.elem=a;this.text=b||"Delete "+a.tagName;this.nextSibling=p;this.parent=g;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};
|
|
svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
|
|
this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};
|
|
svgedit.history.ChangeElementCommand=function(a,p,g){this.elem=a;this.text=g?"Change "+a.tagName+" "+g:"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,g;for(g in this.newValues){if(this.newValues[g])if(g=="#text")this.elem.textContent=this.newValues[g];else g=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[g]):this.elem.setAttribute(g,this.newValues[g]);else if(g=="#text")this.elem.textContent="";else{this.elem.setAttribute(g,"");this.elem.removeAttribute(g)}if(g==
|
|
"transform")p=true}if(!p)if(p=svgedit.utilities.getRotationAngle(this.elem)){g=elem.getBBox();p=["rotate(",p," ",g.x+g.width/2,",",g.y+g.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,g;for(g in this.oldValues){if(this.oldValues[g])if(g==
|
|
"#text")this.elem.textContent=this.oldValues[g];else g=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[g]):this.elem.setAttribute(g,this.oldValues[g]);else if(g=="#text")this.elem.textContent="";else this.elem.removeAttribute(g);if(g=="transform")p=true}if(!p)if(p=svgedit.utilities.getRotationAngle(this.elem)){g=this.elem.getBBox();p=["rotate(",p," ",g.x+g.width/2,",",g.y+g.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=
|
|
function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);for(var p=this.stack.length,g=0;g<p;++g)this.stack[g].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 g=this.stack[p].elements(),b=g.length;b--;)a.indexOf(g[b])==-1&&a.push(g[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_)};
|
|
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 g=++this.undoChangeStackPointer,b=p.length,n=Array(b),s=Array(b);b--;){var c=p[b];if(c!=null){s[b]=c;n[b]=c.getAttribute(a)}}this.undoableChangeStack[g]=
|
|
{attrName:a,oldValues:n,elements:s}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,p=this.undoableChangeStack[a],g=p.elements.length,b=p.attrName,n=new svgedit.history.BatchCommand("Change "+b);g--;){var s=p.elements[g];if(s!=null){var c={};c[b]=p.oldValues[g];c[b]!=s.getAttribute(b)&&n.addSubCommand(new svgedit.history.ChangeElementCommand(s,c,b))}}this.undoableChangeStack[a]=null;return n}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.select)svgedit.select={};var a,p,g;svgedit.select.Selector=function(b,n){this.id=b;this.selectedElement=n;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 n=[];b=Math.round(b/45);if(b<0)b+=8;for(var s in g.selectorGrips)n.push(s);for(;b>0;){n.push(n.shift());b--}b=0;for(s in g.selectorGrips){g.selectorGrips[s].setAttribute("style",
|
|
"cursor:"+n[b]+"-resize");b++}};svgedit.select.Selector.prototype.showGrips=function(b){g.selectorGripsGroup.setAttribute("display",b?"inline":"none");var n=this.selectedElement;this.hasGrips=b;if(n&&b){this.selectorGroup.appendChild(g.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(n))}};svgedit.select.Selector.prototype.resize=function(){var b=this.selectorRect,n=g,s=n.selectorGrips,c=this.selectedElement,f=c.getAttribute("stroke-width"),d=a.currentZoom(),k=1/d;if(c.getAttribute("stroke")!==
|
|
"none"&&!isNaN(f))k+=f/2;var q=c.tagName;if(q==="text")k+=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(q==="g"&&!$.data(c,"gsvg"))if(q=a.getStrokedBBox(c.childNodes))B=q;q=B.x;var o=B.y,K=B.width;B=B.height;k*=d;d=svgedit.math.transformBox(q*d,o*d,K*d,B*d,f);f=d.aabox;q=f.x-k;o=f.y-k;K=f.width+k*2;var U=f.height+k*2;f=q+K/2;B=o+U/2;if(c=svgedit.utilities.getRotationAngle(c)){q=a.svgRoot().createSVGTransform();
|
|
q.setRotate(-c,f,B);q=q.matrix;d.tl=svgedit.math.transformPoint(d.tl.x,d.tl.y,q);d.tr=svgedit.math.transformPoint(d.tr.x,d.tr.y,q);d.bl=svgedit.math.transformPoint(d.bl.x,d.bl.y,q);d.br=svgedit.math.transformPoint(d.br.x,d.br.y,q);q=d.tl;K=q.x;U=q.y;var P=q.x,J=q.y;q=Math.min;o=Math.max;K=q(K,q(d.tr.x,q(d.bl.x,d.br.x)))-k;U=q(U,q(d.tr.y,q(d.bl.y,d.br.y)))-k;P=o(P,o(d.tr.x,o(d.bl.x,d.br.x)))+k;J=o(J,o(d.tr.y,o(d.bl.y,d.br.y)))+k;q=K;o=U;K=P-K;U=J-U}k=a.svgRoot().suspendRedraw(100);b.setAttribute("d",
|
|
"M"+q+","+o+" L"+(q+K)+","+o+" "+(q+K)+","+(o+U)+" "+q+","+(o+U)+"z");this.selectorGroup.setAttribute("transform",c?"rotate("+[c,f,B].join(",")+")":"");if(svgedit.browser.isTouch()){q-=15.75;o-=15.75}else{q-=4;o-=4}this.gripCoords={nw:[q,o].map(Math.round),ne:[q+K,o].map(Math.round),sw:[q,o+U].map(Math.round),se:[q+K,o+U].map(Math.round),n:[q+K/2,o].map(Math.round),w:[q,o+U/2].map(Math.round),e:[q+K,o+U/2].map(Math.round),s:[q+K/2,o+U].map(Math.round)};for(var R in this.gripCoords){b=this.gripCoords[R];
|
|
s[R].setAttribute("x",b[0]);s[R].setAttribute("y",b[1])}this.rotateCoords={nw:[q,o],ne:[q+K+8,o],sw:[q,o+U+8],se:[q+K+8,o+U+8]};for(R in this.rotateCoords){b=this.rotateCoords[R];n.rotateGrips[R].setAttribute("cx",b[0]);n.rotateGrips[R].setAttribute("cy",b[1])}a.svgRoot().unsuspendRedraw(k)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};
|
|
this.selectorGripsGroup=null;this.rotateGrips={nw:null,ne:null,se:null,sw:null};this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);
|
|
a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var b in this.rotateGrips){var n=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(n,"dir",b);$.data(n,"type","rotate");this.rotateGrips[b]=this.selectorGripsGroup.appendChild(n)}for(b in this.selectorGrips){n=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()){n.setAttribute("width",30.5);n.setAttribute("height",30.5);n.setAttribute("fill-opacity",0.3)}$.data(n,"dir",b);$.data(n,"type","resize");this.selectorGrips[b]=this.selectorGripsGroup.appendChild(n)}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"}});n=a.createSVGElement({element:"defs",attr:{id:"placeholder_defs"}});var s=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"}}),k=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(n);n.appendChild(s);s.appendChild(c);s.appendChild(f);s.appendChild(d);b.appendChild(k);a.svgRoot().insertBefore(b,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(b){if(b==null)return null;var n=this.selectors.length;
|
|
if(typeof this.selectorMap[b.id]=="object"){this.selectorMap[b.id].locked=true;return this.selectorMap[b.id]}for(var s=0;s<n;++s)if(this.selectors[s]&&!this.selectors[s].locked){this.selectors[s].locked=true;this.selectors[s].reset(b);this.selectorMap[b.id]=this.selectors[s];return this.selectors[s]}this.selectors[n]=new svgedit.select.Selector(n,b);this.selectorParentGroup.appendChild(this.selectors[n].selectorGroup);this.selectorMap[b.id]=this.selectors[n];return this.selectors[n]};svgedit.select.SelectorManager.prototype.releaseSelector=
|
|
function(b){if(b!=null)for(var n=this.selectors.length,s=this.selectorMap[b.id],c=0;c<n;++c)if(this.selectors[c]&&this.selectors[c]==s){s.locked==false&&console.log("WARNING! selector was released but was already unlocked");delete this.selectorMap[b.id];s.locked=false;s.selectedElement=null;s.showGrips(false);try{s.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,n){p=b;a=n;g=new svgedit.select.SelectorManager;a.createSVGElement({element:"g",attr:{id:"hover_group"}})};svgedit.select.getSelectorManager=function(){return g}})();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},g=p.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(b,n){this.name_=b;this.group_=n};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(b,n){g=b==false?p.NEVER_RANDOMIZE:
|
|
p.ALWAYS_RANDOMIZE;if(g==p.ALWAYS_RANDOMIZE&&!n.getNonce())n.setNonce(Math.floor(Math.random()*100001));else g==p.NEVER_RANDOMIZE&&n.getNonce()&&n.clearNonce()};svgedit.draw.Drawing=function(b,n){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=n||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
|
|
"";var s=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(s&&g!=p.NEVER_RANDOMIZE)this.nonce_=s;else g==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_};
|
|
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=
|
|
this.obj_num,n=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();n=true}else this.obj_num++;for(var s=this.getId();this.getElem_(s);){if(n){this.obj_num=b;n=false}this.obj_num++;s=this.getId()}if(n)this.obj_num=b;return s};svgedit.draw.Drawing.prototype.releaseId=function(b){var n=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof b!="string"||b.indexOf(n)!=0)return false;b=parseInt(b.substr(n.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 n=0;n<this.getNumLayers();n++)if(this.all_layers[n][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 n=0;n<this.getNumLayers();++n)if(b==this.getLayerName(n)){if(this.current_layer!=this.all_layers[n][1]){this.current_layer.setAttribute("style","pointer-events:none");this.current_layer=this.all_layers[n][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,n=[],s=[],c=null,f=false,d=0;d<b;++d){var k=this.svgElem_.childNodes.item(d);if(k&&k.nodeType==1)if(k.tagName=="g"){f=true;var q=$("title",k).text();if(!q&&svgedit.browser.isOpera()&&k.querySelectorAll)q=$(k.querySelectorAll("title")).text();
|
|
if(q){s.push(q);this.all_layers.push([q,k]);c=k;svgedit.utilities.walkTree(k,function(B){B.setAttribute("style","pointer-events:inherit")});c.setAttribute("style","pointer-events:none")}else n.push(k)}else if(~a.indexOf(k.nodeName)){svgedit.utilities.getBBox(k);n.push(k)}}b=this.svgElem_.ownerDocument;if(n.length>0||!f){for(d=1;s.indexOf("Layer "+d)>=0;)d++;s="Layer "+d;c=b.createElementNS("http://www.w3.org/2000/svg","g");f=b.createElementNS("http://www.w3.org/2000/svg","title");f.textContent=s;
|
|
c.appendChild(f);for(f=0;f<n.length;++f)c.appendChild(n[f]);this.svgElem_.appendChild(c);this.all_layers.push([s,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 n=this.svgElem_.ownerDocument,s=n.createElementNS("http://www.w3.org/2000/svg","g");n=n.createElementNS("http://www.w3.org/2000/svg","title");n.textContent=
|
|
b;s.appendChild(n);this.svgElem_.appendChild(s);this.identifyLayers();return s};svgedit.draw.Drawing.prototype.getLayerVisibility=function(b){for(var n=null,s=0;s<this.getNumLayers();++s)if(this.getLayerName(s)==b){n=this.all_layers[s][1];break}if(!n)return false;return n.getAttribute("display")!="none"};svgedit.draw.Drawing.prototype.setLayerVisibility=function(b,n){if(typeof n!="boolean")return null;for(var s=null,c=0;c<this.getNumLayers();++c)if(this.getLayerName(c)==b){s=this.all_layers[c][1];
|
|
break}if(!s)return null;s.getAttribute("display");s.setAttribute("display",n?"inline":"none");return s};svgedit.draw.Drawing.prototype.getLayerOpacity=function(b){for(var n=0;n<this.getNumLayers();++n)if(this.getLayerName(n)==b){(b=this.all_layers[n][1].getAttribute("opacity"))||(b="1.0");return parseFloat(b)}return null};svgedit.draw.Drawing.prototype.setLayerOpacity=function(b,n){if(!(typeof n!="number"||n<0||n>1))for(var s=0;s<this.getNumLayers();++s)if(this.getLayerName(s)==b){this.all_layers[s][1].setAttribute("opacity",
|
|
n);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"]},g=[],b=true,n={};svgedit.path.setLinkControlPoints=function(f){b=f};var s=svgedit.path.path=null;svgedit.path.init=
|
|
function(f){s=f;g=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(d,k){g.push(k+"Abs");g.push(k+"Rel")})};svgedit.path.insertItemBefore=function(f,d,k){f=f.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())f.insertItemBefore(d,k);else{for(var q=f.numberOfItems,B=[],o=0;o<q;o++){var K=f.getItem(o);B.push(K)}f.clear();for(o=0;o<q;o++){o==k&&f.appendItem(d);f.appendItem(B[o])}}};
|
|
svgedit.path.ptObjToArr=function(f,d){for(var k=p[f],q=k.length,B=Array(q),o=0;o<q;o++)B[o]=d[k[o]];return B};svgedit.path.getGripPt=function(f,d){var k={x:d?d.x:f.item.x,y:d?d.y:f.item.y},q=f.path;if(q.matrix)k=svgedit.math.transformPoint(k.x,k.y,q.matrix);k.x*=s.getCurrentZoom();k.y*=s.getCurrentZoom();return k};svgedit.path.getPointFromGrip=function(f,d){var k={x:f.x,y:f.y};if(d.matrix){f=svgedit.math.transformPoint(k.x,k.y,d.imatrix);k.x=f.x;k.y=f.y}k.x/=s.getCurrentZoom();k.y/=s.getCurrentZoom();
|
|
return k};svgedit.path.addPointGrip=function(f,d,k){var q=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=q.appendChild(B);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&k)svgedit.utilities.assignAttributes(B,{x:d-(svgedit.browser.isTouch()?15:2.5),y:k-(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=
|
|
"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=
|
|
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 k=svgedit.path.addPointGrip(f.index);if(d){var q=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(k,{x:q.x-(svgedit.browser.isTouch()?15:2.5),y:q.y-(svgedit.browser.isTouch()?
|
|
15:2.5),display:"inline"})}return k};svgedit.path.getControlPoints=function(f){var d=f.item,k=f.index;if(!("x1"in d)||!("x2"in d))return null;var q={};svgedit.path.getGripContainer();for(var B=[svgedit.path.path.segs[k-1].item,d],o=1;o<3;o++){var K=k+"c"+o,U=q["c"+o+"_line"]=svgedit.path.getCtrlLine(K),P=svgedit.path.getGripPt(f,{x:d["x"+o],y:d["y"+o]}),J=svgedit.path.getGripPt(f,{x:B[o-1].x,y:B[o-1].y});svgedit.utilities.assignAttributes(U,{x1:P.x,y1:P.y,x2:J.x,y2:J.y,display:"inline"});q["c"+o+
|
|
"_line"]=U;pointGrip=q["c"+o]=svgedit.path.addCtrlGrip(K);svgedit.utilities.assignAttributes(pointGrip,{cx:P.x,cy:P.y,display:"inline"});q["c"+o]=pointGrip}return q};svgedit.path.replacePathSeg=function(f,d,k,q){q=q||svgedit.path.path.elem;f=q["createSVGPathSeg"+g[f]].apply(q,k);if(svgedit.browser.supportsPathReplaceItem())q.pathSegList.replaceItem(f,d);else{k=q.pathSegList;q=k.numberOfItems;for(var B=[],o=0;o<q;o++){var K=k.getItem(o);B.push(K)}k.clear();for(o=0;o<q;o++)o==d?k.appendItem(f):k.appendItem(B[o])}};
|
|
svgedit.path.getSegSelector=function(f,d){var k=f.index,q=svgedit.utilities.getElem("segline_"+k);if(!q){var B=svgedit.path.getGripContainer();q=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(q,{id:"segline_"+k,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});B.appendChild(q)}if(d){k=f.prev;if(!k){q.setAttribute("display","none");return q}k=svgedit.path.getGripPt(k);svgedit.path.replacePathSeg(2,
|
|
0,[k.x,k.y],q);B=svgedit.path.ptObjToArr(f.type,f.item,true);for(var o=0;o<B.length;o+=2){k=svgedit.path.getGripPt(f,{x:B[o],y:B[o+1]});B[o]=k.x;B[o+1]=k.y}svgedit.path.replacePathSeg(f.type,1,B,q)}return q};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,d,k){var q=f.x-k.x,B=f.y-k.y,o=d.x-k.x,K=d.y-k.y;if((q!=0||B!=0)&&(o!=0||K!=0)){f=Math.atan2(B,q);d=Math.atan2(K,o);q=Math.sqrt(q*q+B*B);o=Math.sqrt(o*o+K*K);B=s.getSVGRoot().createSVGPoint();K=s.getSVGRoot().createSVGPoint();
|
|
if(f<0)f+=2*Math.PI;if(d<0)d+=2*Math.PI;var U=Math.abs(f-d),P=Math.abs(Math.PI-U)/2;if(f-d>0){f=U<Math.PI?f+P:f-P;d=U<Math.PI?d-P:d+P}else{f=U<Math.PI?f-P:f+P;d=U<Math.PI?d+P:d-P}B.x=q*Math.cos(f)+k.x;B.y=q*Math.sin(f)+k.y;K.x=o*Math.cos(d)+k.x;K.y=o*Math.sin(d)+k.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=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),k=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:d.x-k,y:d.y-
|
|
k}:{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 k=this.item;k=this.ctrlpts?[k.x+=f,k.y+=d,k.x1,k.y1,k.x2+=f,k.y2+=d]:[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.type,this.index,k);if(this.next&&this.next.ctrlpts){k=this.next.item;k=[k.x,k.y,k.x1+=f,k.y1+=d,k.x2,k.y2];svgedit.path.replacePathSeg(this.next.type,
|
|
this.next.index,k)}if(this.mate){k=this.mate.item;k=[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,k)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var d,k,q;if(f==2){k=1;d=this.next;if(!d)return;q=this.item}else{k=2;d=this.prev;if(!d)return;q=d.item}var B=d.item;B["x"+k]=q.x+(q.x-this.item["x"+f]);B["y"+k]=q.y+(q.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,k){var q=this.item;q["x"+f]+=d;q["y"+f]+=k;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.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 k=0;k<d;k++){var q=f.getItem(k);q=new svgedit.path.Segment(k,q);q.path=this;this.segs.push(q)}f=this.segs;q=null;for(k=0;k<d;k++){var B=
|
|
f[k],o=k+1>=d?null:f[k+1],K=k-1<0?null:f[k-1];if(B.type===2){if(K&&K.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=k}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=
|
|
this.segs.length,k=0;k<d;k++)if(f.call(this.segs[k],k)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var k=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+k.item.x)/2,o=(d.item.y+k.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(k.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,U=(d.item.x2+d.item.x)/2,P=(q+K)/2;K=(K+U)/2;B=(P+K)/2;var J=(k.item.y+d.item.y1)/2,R=(d.item.y1+d.item.y2)/2;k=(d.item.y2+d.item.y)/2;var W=(J+
|
|
R)/2;R=(R+k)/2;o=(W+R)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,J,P,W);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,K,R,U,k])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],k=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);k.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
|
|
d.next.index,B)}k.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(k){if(k<=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,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 k=this.selected_pts.length;k--;)this.segs[this.selected_pts[k]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=function(f,d){var k=this.segs[this.selected_pts[0]];k.moveCtrl(this.dragctrl,f,d);b&&k.setLinked(this.dragctrl)};
|
|
svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,k;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){k="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,K=q.item.y,U=B.item.x;B=B.item.y;var P;switch(f){case 6:if(q.olditem){U=q.olditem;P=[o,K,U.x1,U.y1,U.x2,U.y2]}else{P=o-U;var J=K-B;P=[o,K,U+P/3,B+J/3,o-P/3,K-J/3]}break;case 4:P=[o,K];q.olditem=q.item}q.setType(f,P)}}svgedit.path.path.endChanges(k)};svgedit.path.Path.prototype.selectPt=
|
|
function(f,d){this.clearSelection();f==null&&this.eachSeg(function(k){if(this.prev)f=k});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=
|
|
n[f.id];d||(d=n[f.id]=new svgedit.path.Path(f));return d};svgedit.path.removePath_=function(f){f in n&&delete n[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 k=svgedit.utilities.getBBox(f),q=svgedit.path.path.oldbbox,B=q.x+q.width/2,o=q.y+q.height/2;q=k.x+k.width/2;k=k.y+k.height/2;q=q-B;var K=k-o;k=Math.sqrt(q*q+K*K);K=Math.atan2(K,q)+d;q=k*Math.cos(K)+B;k=k*Math.sin(K)+o;B=f.pathSegList;for(o=B.numberOfItems;o;){o-=1;K=B.getItem(o);var U=K.pathSegType;if(U!=1){var P=c(K.x,K.y);P=[P.x,P.y];if(K.x1!=null&&K.x2!=null){c_vals1=c(K.x1,K.y1);c_vals2=c(K.x2,K.y2);P.splice(P.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(U,
|
|
o,P)}}svgedit.utilities.getBBox(f);B=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);B.setRotate(d*180/Math.PI,q,k);f.replaceItem(B,0)}};svgedit.path.clearData=function(){n={}}})();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,g){var b=this.length;if(!b)return a.apply(this,arguments);for(var n=0;n<b;n++){var s=this[n];if(s.namespaceURI==="http://www.w3.org/2000/svg")if(g!==undefined)s.setAttribute(p,g);else if($.isArray(p)){b=p.length;for(n={};b--;){var c=p[b],f=s.getAttribute(c);if(f||f==="0")f=isNaN(f)?f:f-0;n[c]=f}return n}else if(typeof p==="object")for(c in p)s.setAttribute(c,p[c]);else{if((f=s.getAttribute(p))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,
|
|
arguments)}return this}})();
|
|
$.SvgCanvas=function(a,p){function g(e,h){for(var l=svgedit.utilities.getBBox(e),z=0;z<2;z++){var v=z===0?"fill":"stroke",G=e.getAttribute(v);if(G&&G.indexOf("url(")===0){G=T(G);if(G.tagName==="linearGradient"){var A=G.getAttribute("x1")||0,u=G.getAttribute("y1")||0,F=G.getAttribute("x2")||1,H=G.getAttribute("y2")||0;A=l.width*A+l.x;u=l.height*u+l.y;F=l.width*F+l.x;H=l.height*H+l.y;A=O(A,u,h);H=O(F,H,h);F={};F.x1=(A.x-l.x)/l.width;F.y1=(A.y-l.y)/l.height;F.x2=(H.x-l.x)/l.width;F.y2=(H.y-l.y)/l.height;
|
|
G=G.cloneNode(true);$(G).attr(F);G.id=la();mb().appendChild(G);e.setAttribute(v,"url(#"+G.id+")")}}}}var b="http://www.w3.org/2000/svg",n={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};p&&$.extend(n,p);var s=n.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="'+s[0]+'" height="'+s[1]+'" x="'+s[0]+'" y="'+s[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 k=f.createElementNS(b,"svg");(c.clearSvgContentElement=function(){for(;k.firstChild;)k.removeChild(k.firstChild);$(k).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:n.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/ ");k.appendChild(e)})();var q="svg_";c.setIdPrefix=
|
|
function(e){q=e};c.current_drawing_=new svgedit.draw.Drawing(k,q);var B=c.getCurrentDrawing=function(){return c.current_drawing_},o=1,K=null,U={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};U.text=$.extend(true,{},U.shape);$.extend(U.text,
|
|
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var P=U.shape,J=Array(1),R=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),l=B().getCurrentLayer();if(h&&e.element!=h.tagName){l.removeChild(h);h=null}if(!h){h=f.createElementNS(b,e.element);if(l)(K||l).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:P.fill,stroke:P.stroke,"stroke-width":P.stroke_width,"stroke-dasharray":P.stroke_dasharray,"stroke-linejoin":P.stroke_linejoin,
|
|
"stroke-linecap":P.stroke_linecap,"stroke-opacity":P.stroke_opacity,"fill-opacity":P.fill_opacity,opacity:P.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},W=c.getTransformList=svgedit.transformlist.getTransformList,O=svgedit.math.transformPoint,ha=c.matrixMultiply=svgedit.math.matrixMultiply,oa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,ga=c.transformListToTransform=svgedit.math.transformListToTransform,
|
|
ba=svgedit.math.snapToAngle,Y=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return k.getAttribute("height")/o},getWidth:function(){return k.getAttribute("width")/o},getRoundDigits:function(){return ib.round_digits}});var ta=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
|
|
getSVGContent:function(){return k}});var ja=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,X=c.setHref=svgedit.utilities.setHref,Z=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var pa=c.getRotationAngle=svgedit.utilities.getRotationAngle,ra=c.getElem=svgedit.utilities.getElem,na=c.assignAttributes=svgedit.utilities.assignAttributes,ma=this.cleanupElement=svgedit.utilities.cleanupElement,Ca=svgedit.sanitize.getNSMap(),Ja=c.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
|
|
Ka=svgedit.history.MoveElementCommand,Fa=svgedit.history.InsertElementCommand,Ia=svgedit.history.RemoveElementCommand,Oa=svgedit.history.ChangeElementCommand,Ea=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var l=svgedit.history.HistoryEventTypes;if(e==l.BEFORE_UNAPPLY||e==l.BEFORE_APPLY)c.clearSelection();else if(e==l.AFTER_APPLY||e==l.AFTER_UNAPPLY){var z=h.elements();c.pathActions.clear();M("changed",z);z=h.type();l=e==l.AFTER_APPLY;if(z==
|
|
Ka.type()){l=l?h.newParent:h.oldParent;l==k&&c.identifyLayers()}else if(z==Fa.type()||z==Ia.type()){h.parent==k&&c.identifyLayers();if(z==Fa.type())l&&Wa(h.elem);else l||Wa(h.elem);h.elem.tagName==="use"&&Nb(h.elem)}else if(z==Oa.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==k&&c.identifyLayers();l=l?h.newValues:h.oldValues;l.stdDeviation&&c.setBlurOffsets(h.elem.parentNode,l.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){l=
|
|
z.parentNode;var v=z.nextSibling;l.removeChild(z);l.insertBefore(z,v)}}}}}});var wa=function(e){c.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return c.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return k},currentZoom:function(){return o},getStrokedBBox:function(e){return c.getStrokedBBox([e])}});var Ha=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return d}});
|
|
svgedit.utilities.snapToGrid=function(e){var h=n.snappingStep,l=n.baseUnit;if(l!=="px")h*=svgedit.units.getTypeMap()[l];return e=Math.round(e/h)*h};var za=svgedit.utilities.snapToGrid,nb={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"},Ab=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],Qa=$.data,
|
|
Wa=function(e){var h=$(e).attr(Ab),l;for(l in h){var z=h[l];if(z&&z.indexOf("url(")===0){z=ja(z).substr(1);if(!ra(z)){mb().appendChild(wb[z]);delete wb[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(l=e.length;h<l;h++)Wa(e[h])}},Ya={},Ba=n.imgPath+"logo.png",xa=[],ib={round_digits:5},La=false,Va=null,Da="select",kb="none",sb={},$a=U.text,cb=P,Cb=null,ua=null,lb=[],jb={},wb={};c.clipBoard=[];var ob=this.runExtensions=function(e,h,l){var z=false;if(l)z=[];$.each(jb,function(v,G){if(e in G)if(l)z.push(G[e](h));
|
|
else z=G[e](h)});return z};this.addExtension=function(e,h){if(e in jb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var l=$.isFunction(h)?h($.extend(c.getPrivateMethods(),{svgroot:d,svgcontent:k,nonce:B().getNonce(),selectorManager:Ha})):h;jb[e]=l;M("extension_added",l)}};var hb=this.round=function(e){return parseInt(e*o)/o},qb=this.getIntersectionList=function(e){if(ua==null)return null;var h=K||B().getCurrentLayer();lb.length||(lb=Bb(h));var l=null;
|
|
try{l=h.getIntersectionList(e,null)}catch(z){}if(l==null||typeof l.item!="function"){l=[];if(e)e=e;else{e=ua.getBBox();h={};for(var v in e)h[v]=e[v]/o;e=h}for(v=lb.length;v--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,lb[v].bbox)&&l.push(lb[v].elem)}return l};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=tb());if(!e.length)return false;var h=function(H){try{var D=svgedit.utilities.getBBox(H),E=svgedit.utilities.getRotationAngle(H);if(E&&E%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(H))){E=
|
|
false;if(["ellipse","path","line","polyline","polygon"].indexOf(H.tagName)>=0)D=E=c.convertToPath(H,true);else if(H.tagName=="rect"){var L=H.getAttribute("rx"),N=H.getAttribute("ry");if(L||N)D=E=c.convertToPath(H,true)}if(!E){var m=H.cloneNode(true),w=document.createElementNS(b,"g"),C=H.parentNode;C.appendChild(w);w.appendChild(m);D=svgedit.utilities.bboxToObj(w.getBBox());C.removeChild(w)}}return D}catch(I){console.log(H,I);return null}},l;$.each(e,function(){if(!l)if(this.parentNode)l=h(this)});
|
|
if(l==null)return null;var z=l.x+l.width,v=l.y+l.height,G=l.x,A=l.y,u=function(H){var D=H.getAttribute("stroke-width"),E=0;if(H.getAttribute("stroke")!="none"&&!isNaN(D))E+=D/2;return E},F=[];$.each(e,function(H,D){var E=h(D);if(E){var L=u(D);G=Math.min(G,E.x-L);A=Math.min(A,E.y-L);F.push(E)}});l.x=G;l.y=A;$.each(e,function(H,D){var E=F[H];if(E&&D.nodeType==1){var L=u(D);z=Math.max(z,E.x+E.width+L);v=Math.max(v,E.y+E.height+L)}});l.width=z-G;l.height=v-A;return l};var tb=this.getVisibleElements=function(e){e||
|
|
(e=$(k).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(l,z){try{z.getBBox()&&h.push(z)}catch(v){}});return h.reverse()},Bb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(k).children());var h=[];$(e).children().each(function(l,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(v){}});return h.reverse()},xb=this.groupSvgElem=function(e){var h=document.createElementNS(b,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg",
|
|
e)[0].id=la()},ka=function(e){var h=document.createElementNS(e.namespaceURI,e.nodeName);h.removeAttribute("id");$.each(e.attributes,function(z,v){v.localName!="-moz-math-font-style"&&h.setAttributeNS(v.namespaceURI,v.nodeName,v.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var l=Ma.convertPath(e);h.setAttribute("d",l)}$.each(e.childNodes,function(z,v){switch(v.nodeType){case 1:h.appendChild(ka(v));break;case 3:h.textContent=v.nodeValue}});if($(e).data("gsvg"))$(h).data("gsvg",h.firstChild);
|
|
else if($(e).data("symbol")){e=$(e).data("symbol");$(h).data("ref",e).data("symbol",e)}else h.tagName=="image"&&Jb(h);h.id=la();return h},ca,la,M;(function(e){var h={};ca=e.getId=function(){return B().getId()};la=e.getNextId=function(){return B().getNextId()};M=e.call=function(l,z){if(h[l])return h[l](this,z)};e.bind=function(l,z){var v=h[l];h[l]=z;return v}})(c);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(b,"path");for(var h=0,l=e.length;h<l;++h){var z=
|
|
e[h];z.setAttribute("d",Ma.convertPath(z));Ma.fixEnd(z)}};var T=this.getRefElem=function(e){return ra(ja(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var l=J[0],z=l.getAttribute("transform"),v=svgedit.utilities.getBBox(l),G=v.x+v.width/2,A=v.y+v.height/2;v=W(l);v.numberOfItems>
|
|
0&&v.getItem(0).type==4&&v.removeItem(0);if(e!=0){G=O(G,A,ga(v).matrix);A=d.createSVGTransform();A.setRotate(e,G.x,G.y);v.numberOfItems?v.insertItemBefore(A,0):v.appendItem(A)}else v.numberOfItems==0&&l.removeAttribute("transform");if(!h){v=l.getAttribute("transform");l.setAttribute("transform",z);eb("transform",v,J);M("changed",J)}ra("pathpointgrip_container");l=Ha.requestSelector(J[0]);l.resize();l.updateGripCursors(e)};var Ga=this.recalculateAllSelectedDimensions=function(){for(var e=new Ea(kb==
|
|
"none"?"position":"size"),h=J.length;h--;){var l=Ra(J[h]);l&&e.addSubCommand(l)}if(!e.isEmpty()){wa(e);M("changed",J)}},Pa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Za=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},gb=this.remapElement=function(e,h,l){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",v=function(){if(z)for(var E in h)h[E]=za(h[E]);na(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var G=0;G<2;G++){var A=G===0?"fill":"stroke",
|
|
u=e.getAttribute(A);if(u&&u.indexOf("url(")===0)if(l.a<0||l.d<0){u=T(u).cloneNode(true);if(l.a<0){var F=u.getAttribute("x1"),H=u.getAttribute("x2");u.setAttribute("x1",-(F-1));u.setAttribute("x2",-(H-1))}if(l.d<0){F=u.getAttribute("y1");H=u.getAttribute("y2");u.setAttribute("y1",-(F-1));u.setAttribute("y2",-(H-1))}u.id=la();mb().appendChild(u);e.setAttribute(A,"url(#"+u.id+")")}}G=e.tagName;if(G==="g"||G==="text"||G==="use")if(l.a==1&&l.b==0&&l.c==0&&l.d==1&&(l.e!=0||l.f!=0)){A=ga(e).matrix;A=ha(A.inverse(),
|
|
l,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=W(e);u=d.createSVGTransform();u.setMatrix(ha(ga(A).matrix,l));A.clear();A.appendItem(u)}switch(G){case "foreignObject":case "rect":case "image":if(G==="image"&&(l.a<0||l.d<0)){A=W(e);u=d.createSVGTransform();u.setMatrix(ha(ga(A).matrix,l));A.clear();A.appendItem(u)}else{A=O(h.x,h.y,l);h.width=l.a*h.width;h.height=l.d*h.height;h.x=A.x+Math.min(0,h.width);h.y=A.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}v();
|
|
break;case "ellipse":G=O(h.cx,h.cy,l);h.cx=G.x;h.cy=G.y;h.rx=l.a*h.rx;h.ry=l.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);v();break;case "circle":G=O(h.cx,h.cy,l);h.cx=G.x;h.cy=G.y;G=svgedit.math.transformBox(box.x,box.y,box.width,box.height,l);h.r=Math.min((G.tr.x-G.tl.x)/2,(G.bl.y-G.tl.y)/2);if(h.r)h.r=Math.abs(h.r);v();break;case "line":A=O(h.x1,h.y1,l);F=O(h.x2,h.y2,l);h.x1=A.x;h.y1=A.y;h.x2=F.x;h.y2=F.y;case "text":l=e.querySelectorAll("tspan");for(G=l.length;G--;){A=ta("x",e.getAttribute("x"));
|
|
u=ta("x",l[G].getAttribute("x"));F=ta("y",e.getAttribute("y"));H=ta("y",l[G].getAttribute("y"));var D={};if(!isNaN(A)&&!isNaN(u)&&A!=0&&u!=0&&h.x)D.x=h.x-(A-u);if(!isNaN(F)&&!isNaN(H)&&F!=0&&H!=0&&h.y)D.y=h.y-(F-H);if(D.x||D.y)na(l[G],D,1E3,true)}v();break;case "use":v();break;case "g":(v=$(e).data("gsvg"))&&na(v,h,1E3,true);break;case "polyline":case "polygon":v=h.points.length;for(G=0;G<v;++G){H=h.points[G];H=O(H.x,H.y,l);h.points[G].x=H.x;h.points[G].y=H.y}v=h.points.length;l="";for(G=0;G<v;++G){H=
|
|
h.points[G];l+=H.x+","+H.y+" "}e.setAttribute("points",l);break;case "path":A=e.pathSegList;v=A.numberOfItems;h.d=Array(v);for(G=0;G<v;++G){u=A.getItem(G);h.d[G]={type:u.pathSegType,x:u.x,y:u.y,x1:u.x1,y1:u.y1,x2:u.x2,y2:u.y2,r1:u.r1,r2:u.r2,angle:u.angle,largeArcFlag:u.largeArcFlag,sweepFlag:u.sweepFlag}}v=h.d.length;G=h.d[0];D=O(G.x,G.y,l);h.d[0].x=D.x;h.d[0].y=D.y;for(G=1;G<v;++G){u=h.d[G];A=u.type;if(A%2==0){H=O(u.x!=undefined?u.x:D.x,u.y!=undefined?u.y:D.y,l);A=O(u.x1,u.y1,l);F=O(u.x2,u.y2,l);
|
|
u.x=H.x;u.y=H.y;u.x1=A.x;u.y1=A.y;u.x2=F.x;u.y2=F.y}else{u.x=l.a*u.x;u.y=l.d*u.y;u.x1=l.a*u.x1;u.y1=l.d*u.y1;u.x2=l.a*u.x2;u.y2=l.d*u.y2}u.r1=l.a*u.r1;u.r2=l.d*u.r2}l="";v=h.d.length;for(G=0;G<v;++G){u=h.d[G];A=u.type;l+=Pa[A];switch(A){case 13:case 12:l+=u.x+" ";break;case 15:case 14:l+=u.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:l+=u.x+","+u.y+" ";break;case 7:case 6:l+=u.x1+","+u.y1+" "+u.x2+","+u.y2+" "+u.x+","+u.y+" ";break;case 9:case 8:l+=u.x1+","+u.y1+" "+u.x+","+u.y+" ";break;
|
|
case 11:case 10:l+=u.r1+","+u.r2+" "+u.angle+" "+ +u.largeArcFlag+" "+ +u.sweepFlag+" "+u.x+","+u.y+" ";break;case 17:case 16:l+=u.x2+","+u.y2+" "+u.x+","+u.y+" "}}e.setAttribute("d",l)}},pb=function(e,h,l){e=T(e).firstChild;var z=W(e),v=d.createSVGTransform();v.setTranslate(h,l);z.appendItem(v);Ra(e)},Ra=this.recalculateDimensions=function(e){if(e==null)return null;var h=W(e);if(h&&h.numberOfItems>0){for(var l=h.numberOfItems;l--;){var z=h.getItem(l);if(z.type===0)h.removeItem(l);else if(z.type===
|
|
1)svgedit.math.isIdentity(z.matrix)&&h.removeItem(l);else z.type===4&&z.angle===0&&h.removeItem(l)}if(h.numberOfItems===1&&pa(e))return null}if(!h||h.numberOfItems==0){e.removeAttribute("transform");return null}if(h){l=h.numberOfItems;for(var v=[];l--;){z=h.getItem(l);if(z.type===1)v.push([z.matrix,l]);else if(v.length)v=[]}if(v.length===2){l=d.createSVGTransformFromMatrix(ha(v[1][0],v[0][0]));h.removeItem(v[0][1]);h.removeItem(v[1][1]);h.insertItemBefore(l,v[1][1])}l=h.numberOfItems;if(l>=2&&h.getItem(l-
|
|
2).type===1&&h.getItem(l-1).type===2){v=d.createSVGTransform();z=ha(h.getItem(l-2).matrix,h.getItem(l-1).matrix);v.setMatrix(z);h.removeItem(l-2);h.removeItem(l-2);h.appendItem(v)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var G=$(e).data("gsvg");l=new Ea("Transform");var A={},u=null;z=[];switch(e.tagName){case "line":z=["x1","y1",
|
|
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":u={};u.points=e.getAttribute("points");v=e.points;var F=v.numberOfItems;A.points=Array(F);for(var H=0;H<F;++H){var D=v.getItem(H);A.points[H]={x:D.x,y:D.y}}break;case "path":u={};u.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
|
|
$(e).attr(z);$.each(A,function(Aa,ia){A[Aa]=ta(Aa,ia)})}else if(G)A={x:$(G).attr("x")||0,y:$(G).attr("y")||0};if(u==null){u=$.extend(true,{},A);$.each(u,function(Aa,ia){u[Aa]=ta(Aa,ia)})}u.transform=Va?Va:"";if(e.tagName=="g"&&!G||e.tagName=="a"){v=svgedit.utilities.getBBox(e);var E={x:v.x+v.width/2,y:v.y+v.height/2},L=O(v.x+v.width/2,v.y+v.height/2,ga(h).matrix);z=d.createSVGMatrix();if(v=pa(e)){H=v*Math.PI/180;F=Math.abs(H)>1.0E-10?Math.sin(H)/(1-Math.cos(H)):2/H;for(H=0;H<h.numberOfItems;++H){z=
|
|
h.getItem(H);if(z.type==4){z=z.matrix;E.y=(F*z.e+z.f)/2;E.x=(z.e-F*z.f)/2;h.removeItem(H);break}}}H=z=G=0;var N=h.numberOfItems;if(N)var m=h.getItem(0).matrix;if(N>=3&&h.getItem(N-2).type==3&&h.getItem(N-3).type==2&&h.getItem(N-1).type==2){H=3;var w=h.getItem(N-3).matrix,C=h.getItem(N-2).matrix,I=h.getItem(N-1).matrix;F=e.childNodes;for(D=F.length;D--;){var S=F.item(D);z=G=0;if(S.nodeType==1){var Q=W(S);if(Q){z=ga(Q).matrix;G=pa(S);var V=Va,aa=[];Va=S.getAttribute("transform");if(G||oa(Q)){var fa=
|
|
d.createSVGTransform();fa.setMatrix(ha(w,C,I,z));Q.clear();Q.appendItem(fa);aa.push(fa)}else{G=ha(z.inverse(),I,z);fa=d.createSVGMatrix();fa.e=-G.e;fa.f=-G.f;z=ha(fa.inverse(),z.inverse(),w,C,I,z,G.inverse());var qa=d.createSVGTransform(),sa=d.createSVGTransform(),ab=d.createSVGTransform();qa.setTranslate(G.e,G.f);sa.setScale(z.a,z.d);ab.setTranslate(fa.e,fa.f);Q.appendItem(ab);Q.appendItem(sa);Q.appendItem(qa);aa.push(ab);aa.push(sa);aa.push(qa)}l.addSubCommand(Ra(S));Va=V}}}h.removeItem(N-1);h.removeItem(N-
|
|
2);h.removeItem(N-3)}else if(N>=3&&h.getItem(N-1).type==1){H=3;z=ga(h).matrix;fa=d.createSVGTransform();fa.setMatrix(z);h.clear();h.appendItem(fa)}else if((N==1||N>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){H=2;G=ga(h).matrix;h.removeItem(0);z=ga(h).matrix.inverse();z=ha(z,G);G=z.e;z=z.f;if(G!=0||z!=0){F=e.childNodes;D=F.length;for(N=[];D--;){S=F.item(D);if(S.nodeType==1){if(S.getAttribute("clip-path")){V=S.getAttribute("clip-path");if(N.indexOf(V)===-1){pb(V,G,z);N.push(V)}}V=Va;Va=S.getAttribute("transform");
|
|
if(Q=W(S)){w=d.createSVGTransform();w.setTranslate(G,z);Q.numberOfItems?Q.insertItemBefore(w,0):Q.appendItem(w);l.addSubCommand(Ra(S));Q=e.getElementsByTagNameNS(b,"use");S="#"+S.id;for(w=Q.length;w--;){C=Q.item(w);if(S==da(C)){I=d.createSVGTransform();I.setTranslate(-G,-z);W(C).insertItemBefore(I,0);l.addSubCommand(Ra(C))}}Va=V}}}N=[];Va=V}}else if(N==1&&h.getItem(0).type==1&&!v){H=1;z=h.getItem(0).matrix;F=e.childNodes;for(D=F.length;D--;){S=F.item(D);if(S.nodeType==1){V=Va;Va=S.getAttribute("transform");
|
|
if(Q=W(S)){G=ha(z,ga(Q).matrix);N=d.createSVGTransform();N.setMatrix(G);Q.clear();Q.appendItem(N,0);l.addSubCommand(Ra(S));Va=V;V=S.getAttribute("stroke-width");S.getAttribute("stroke")!=="none"&&!isNaN(V)&&S.setAttribute("stroke-width",V*((Math.abs(G.a)+Math.abs(G.d))/2))}}}h.clear()}else{if(v){E=d.createSVGTransform();E.setRotate(v,L.x,L.y);h.numberOfItems?h.insertItemBefore(E,0):h.appendItem(E)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(H==2){if(v){L={x:E.x+m.e,y:E.y+m.f};
|
|
E=d.createSVGTransform();E.setRotate(v,L.x,L.y);h.numberOfItems?h.insertItemBefore(E,0):h.appendItem(E)}}else if(H==3){z=ga(h).matrix;m=d.createSVGTransform();m.setRotate(v,E.x,E.y);m=m.matrix;E=d.createSVGTransform();E.setRotate(v,L.x,L.y);L=E.matrix.inverse();V=z.inverse();L=ha(V,L,m,z);G=L.e;z=L.f;if(G!=0||z!=0){F=e.childNodes;for(D=F.length;D--;){S=F.item(D);if(S.nodeType==1){V=Va;Va=S.getAttribute("transform");Q=W(S);w=d.createSVGTransform();w.setTranslate(G,z);Q.numberOfItems?Q.insertItemBefore(w,
|
|
0):Q.appendItem(w);l.addSubCommand(Ra(S));Va=V}}}if(v)h.numberOfItems?h.insertItemBefore(E,0):h.appendItem(E)}}else{v=svgedit.utilities.getBBox(e);if(!v&&e.tagName!="path")return null;z=d.createSVGMatrix();if(G=pa(e)){E={x:v.x+v.width/2,y:v.y+v.height/2};L=O(v.x+v.width/2,v.y+v.height/2,ga(h).matrix);H=G*Math.PI/180;F=Math.abs(H)>1.0E-10?Math.sin(H)/(1-Math.cos(H)):2/H;for(H=0;H<h.numberOfItems;++H){z=h.getItem(H);if(z.type==4){z=z.matrix;E.y=(F*z.e+z.f)/2;E.x=(z.e-F*z.f)/2;h.removeItem(H);break}}}H=
|
|
0;N=h.numberOfItems;if(!svgedit.browser.isWebkit())if((m=e.getAttribute("fill"))&&m.indexOf("url(")===0){m=T(m);V="pattern";if(m.tagName!==V)V="gradient";if(m.getAttribute(V+"Units")==="userSpaceOnUse"){z=ga(h).matrix;v=W(m);v=ga(v).matrix;z=ha(z,v);v="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";m.setAttribute(V+"Transform",v)}}if(N>=3&&h.getItem(N-2).type==3&&h.getItem(N-3).type==2&&h.getItem(N-1).type==2){H=3;z=ga(h,N-3,N-1).matrix;h.removeItem(N-1);h.removeItem(N-2);h.removeItem(N-3)}else if(N==
|
|
4&&h.getItem(N-1).type==1){H=3;z=ga(h).matrix;fa=d.createSVGTransform();fa.setMatrix(z);h.clear();h.appendItem(fa);z=d.createSVGMatrix()}else if((N==1||N>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){H=2;m=h.getItem(0).matrix;V=ga(h,1).matrix;v=V.inverse();z=ha(v,m,V);h.removeItem(0)}else if(N==1&&h.getItem(0).type==1&&!G){z=ga(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){v=e.points;F=v.numberOfItems;
|
|
A.points=Array(F);for(H=0;H<F;++H){D=v.getItem(H);A.points[H]={x:D.x,y:D.y}}}case "path":A.d=e.getAttribute("d");H=1;h.clear()}}else{H=4;if(G){E=d.createSVGTransform();E.setRotate(G,L.x,L.y);h.numberOfItems?h.insertItemBefore(E,0):h.appendItem(E)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(H==1||H==2||H==3)gb(e,A,z);if(H==2){if(G){oa(h)||(L={x:E.x+z.e,y:E.y+z.f});E=d.createSVGTransform();E.setRotate(G,L.x,L.y);h.numberOfItems?h.insertItemBefore(E,0):h.appendItem(E)}}else if(H==
|
|
3&&G){z=ga(h).matrix;m=d.createSVGTransform();m.setRotate(G,E.x,E.y);m=m.matrix;E=d.createSVGTransform();E.setRotate(G,L.x,L.y);L=E.matrix.inverse();V=z.inverse();L=ha(V,L,m,z);gb(e,A,L);if(G)h.numberOfItems?h.insertItemBefore(E,0):h.appendItem(E)}}h.numberOfItems==0&&e.removeAttribute("transform");l.addSubCommand(new Oa(e,u));return l},rb=null,Sa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,l=0;l<h;++l){var z=J[l];if(z==null)break;Ha.releaseSelector(z);J[l]=null}e||M("selected",
|
|
J)},ub=this.addToSelection=function(e,h){if(e.length!=0){for(var l=0;l<J.length;){if(J[l]==null)break;++l}for(var z=e.length;z--;){var v=e[z];if(v&&svgedit.utilities.getBBox(v)){if(v.tagName==="a"&&v.childNodes.length===1)v=v.firstChild;if(J.indexOf(v)==-1){J[l]=v;l++;v=Ha.requestSelector(v);J.length>1&&v.showGrips(false)}}}M("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(G,A){if(G&&A&&G.compareDocumentPosition)return 3-
|
|
(A.compareDocumentPosition(G)&6);else if(G==null)return 1});J[0]==null;)J.shift(0)}},yb=this.selectOnly=function(e,h){Sa(true);ub(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var l=0;l<len;++l){var z=J[l];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Da="select";yb($(K||e).children())}};var Kb=this.getMouseTarget=function(e){if(e==
|
|
null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,k,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,l=null,z=
|
|
null,v=null,G={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(u){if(!(u.originalEvent.touches&&u.originalEvent.touches>1)){var F=u.button===2;rb=k.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var H=O(u.pageX,u.pageY,rb),D=H.x*(isBotchedZoom?1:o);H=H.y*(isBotchedZoom?1:o);u.preventDefault();if(F)Da="select";D=D/o;H=H/o;var E=Kb(u);if(E.tagName==="a"&&E.childNodes.length===1)E=E.firstChild;var L=z=h=D,N=v=l=H;if(n.gridSnapping){D=za(D);H=za(H);h=za(h);l=za(l)}if(E==
|
|
Ha.selectorParentGroup&&J[0]!=null){E=u.target;var m=Qa(E,"type");if(m=="rotate"){Da="rotate";current_rotate_mode=Qa(E,"dir")}else if(m=="resize"){Da="resize";kb=Qa(E,"dir")}E=J[0]}Va=E.getAttribute("transform");m=W(E);switch(Da){case "select":La=true;kb="none";if(F)La=false;if(E!=d){if(J.indexOf(E)==-1){u.shiftKey||Sa(true);ub([E]);Cb=E;Ma.clear()}if(!F)for(F=0;F<J.length;++F)if(J[F]!=null){var w=W(J[F]);w.numberOfItems?w.insertItemBefore(d.createSVGTransform(),0):w.appendItem(d.createSVGTransform())}}else if(!F){Sa();
|
|
Da="multiselect";if(ua==null)ua=Ha.getRubberBandBox();z*=o;v*=o;na(ua,{x:z,y:v,width:0,height:0,display:"inline"},100)}break;case "zoom":La=true;if(ua==null)ua=Ha.getRubberBandBox();na(ua,{x:L*o,y:L*o,width:0,height:0,display:"inline"},100);break;case "resize":La=true;h=D;l=H;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var C={};$.each(G,function(I,S){C[I]=S/o});G=C;F=pa(E)?1:0;if(oa(m)){m.insertItemBefore(d.createSVGTransform(),F);m.insertItemBefore(d.createSVGTransform(),F);m.insertItemBefore(d.createSVGTransform(),
|
|
F)}else{m.appendItem(d.createSVGTransform());m.appendItem(d.createSVGTransform());m.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(D=svgedit.browser.isChrome())w=function(I){var S=I.getAttributeNS(null,"stroke");I.removeAttributeNS(null,"stroke");setTimeout(function(){I.setAttributeNS(null,"stroke",S)},1)};E.style.vectorEffect="non-scaling-stroke";D&&w(E);H=E.getElementsByTagName("*");L=H.length;for(F=0;F<L;F++){H[F].style.vectorEffect="non-scaling-stroke";D&&
|
|
w(H[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":La=true;e=L+","+N+" ";w=P.stroke_width==0?1:P.stroke_width;R({element:"polyline",curStyles:true,attr:{points:e,id:la(),fill:"none",opacity:P.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});A.minx=L;A.maxx=L;A.miny=N;A.maxy=N;break;case "image":La=true;w=R({element:"image",attr:{x:D,y:H,width:0,height:0,id:la(),opacity:P.opacity/2,style:"pointer-events:inherit"}});X(w,Ba);Jb(w);break;case "square":case "rect":La=true;h=
|
|
D;l=H;R({element:"rect",curStyles:true,attr:{x:D,y:H,width:0,height:0,id:la(),opacity:P.opacity/2}});break;case "line":La=true;w=P.stroke_width==0?1:P.stroke_width;R({element:"line",curStyles:true,attr:{x1:D,y1:H,x2:D,y2:H,id:la(),stroke:P.stroke,"stroke-width":w,"stroke-dasharray":P.stroke_dasharray,"stroke-linejoin":P.stroke_linejoin,"stroke-linecap":P.stroke_linecap,"stroke-opacity":P.stroke_opacity,fill:"none",opacity:P.opacity/2,style:"pointer-events:none"}});break;case "circle":La=true;R({element:"circle",
|
|
curStyles:true,attr:{cx:D,cy:H,r:0,id:la(),opacity:P.opacity/2}});break;case "ellipse":La=true;R({element:"ellipse",curStyles:true,attr:{cx:D,cy:H,rx:0,ry:0,id:la(),opacity:P.opacity/2}});break;case "text":La=true;R({element:"text",curStyles:true,attr:{x:D,y:H,id:la(),fill:$a.fill,"stroke-width":$a.stroke_width,"font-size":$a.font_size,"font-family":$a.font_family,"text-anchor":"left","xml:space":"preserve",opacity:P.opacity}});break;case "path":case "pathedit":h*=o;l*=o;Ma.mouseDown(u,E,h,l);La=
|
|
true;break;case "textedit":h*=o;l*=o;Ua.mouseDown(u,E,h,l);La=true;break;case "rotate":La=true;c.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}w=ob("mouseDown",{event:u,start_x:h,start_y:l,selectedElements:J},true);$.each(w,function(I,S){if(S&&S.started)La=true});if(Da)document.getElementById("workarea").className=Da=="resize"?u.target.style.cursor:Da}}).mousemove(function(u){if(!(u.originalEvent.touches&&u.originalEvent.touches.length>1))if(La)if(!(u.button===
|
|
1||c.spaceKey)){var F=J[0],H=O(u.pageX,u.pageY,rb),D=H.x*(isBotchedZoom?1:o);H=H.y*(isBotchedZoom?1:o);var E=ra(ca()),L=x=D/o,N=y=H/o;if(n.gridSnapping){x=za(x);y=za(y)}u.preventDefault();switch(Da){case "select":if(J[0]!==null){L=x-h;var m=y-l;if(n.gridSnapping){L=za(L);m=za(m)}if(u.shiftKey){var w=ba(h,l,x,y);x=w.x;y=w.y}if(L!=0||m!=0){w=J.length;for(N=0;N<w;++N){F=J[N];if(F==null)break;var C=d.createSVGTransform();E=W(F);C.setTranslate(L,m);E.numberOfItems?E.replaceItem(C,0):E.appendItem(C);Ha.requestSelector(F).resize()}if(u.altKey)if(!c.addClones){c.addClones=
|
|
c.cloneSelectedElements(0,0,C);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(sa){sa.parentNode&&sa.parentNode.removeChild(sa);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",J)}}break;case "multiselect":L*=o;N*=o;na(ua,{x:Math.min(z,L),y:Math.min(v,N),width:Math.abs(L-z),height:Math.abs(N-v)},100);E=[];L=[];C=qb();w=J.length;for(N=0;N<w;++N){m=C.indexOf(J[N]);if(m==-1)E.push(J[N]);else C[m]=null}w=C.length;for(N=0;N<w;++N)C[N]&&L.push(C[N]);
|
|
E.length>0&&c.removeFromSelection(E);L.length>0&&ub(L);break;case "resize":E=W(F);L=(C=oa(E))?G:svgedit.utilities.getBBox(F);w=L.x;N=L.y;var I=L.width,S=L.height;L=x-h;m=y-l;if(n.gridSnapping){L=za(L);m=za(m);S=za(S);I=za(I)}var Q=pa(F);if(Q){var V=Math.sqrt(L*L+m*m);m=Math.atan2(m,L)-Q*Math.PI/180;L=V*Math.cos(m);m=V*Math.sin(m)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)m=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=V=0,fa=S?(S+m)/S:1,qa=I?(I+L)/I:1;if(kb.indexOf("n")>=0){fa=S?(S-m)/
|
|
S:1;aa=S}if(kb.indexOf("w")>=0){qa=I?(I-L)/I:1;V=I}L=d.createSVGTransform();m=d.createSVGTransform();I=d.createSVGTransform();if(n.gridSnapping){w=za(w);V=za(V);N=za(N);aa=za(aa)}L.setTranslate(-(w+V),-(N+aa));if(u.shiftKey)if(qa==1)qa=fa;else fa=qa;m.setScale(qa,fa);I.setTranslate(w+V,N+aa);if(C){C=Q?1:0;E.replaceItem(L,2+C);E.replaceItem(m,1+C);E.replaceItem(I,0+C)}else{C=E.numberOfItems;E.replaceItem(I,C-3);E.replaceItem(m,C-2);E.replaceItem(L,C-1)}Ha.requestSelector(F).resize();M("transition",
|
|
J);break;case "zoom":L*=o;N*=o;na(ua,{x:Math.min(z*o,L),y:Math.min(v*o,N),width:Math.abs(L-z*o),height:Math.abs(N-v*o)},100);break;case "text":na(E,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=za(x);y=za(y)}C=x;w=y;if(u.shiftKey){w=ba(h,l,C,w);C=w.x;w=w.y}E.setAttributeNS(null,"x2",C);E.setAttributeNS(null,"y2",w);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);C=Math.abs(y-l);if(Da==
|
|
"square"||u.shiftKey){L=C=Math.max(L,C);w=h<x?h:h-L;N=l<y?l:l-C}else{w=Math.min(h,x);N=Math.min(l,y)}if(u.altKey){L*=2;C*=2;w=h-L/2;N=l-C/2}if(n.gridSnapping){L=za(L);C=za(C);w=za(w);N=za(N)}na(E,{width:L,height:C,x:w,y:N},1E3);break;case "circle":L=$(E).attr(["cx","cy"]);C=L.cx;w=L.cy;L=Math.sqrt((x-C)*(x-C)+(y-w)*(y-w));if(n.gridSnapping)L=za(L);E.setAttributeNS(null,"r",L);break;case "ellipse":L=$(E).attr(["cx","cy"]);C=Math.abs(h+(x-h)/2);w=Math.abs(l+(y-l)/2);L=null;window.opera||d.suspendRedraw(1E3);
|
|
if(n.gridSnapping){x=za(x);C=za(C);y=za(y);w=za(w)}N=Math.abs(h-C);m=Math.abs(l-w);if(u.shiftKey){m=N;w=y>l?l+N:l-N}if(u.altKey){C=h;w=l;N=Math.abs(x-C);m=u.shiftKey?N:Math.abs(y-w)}E.setAttributeNS(null,"rx",N);E.setAttributeNS(null,"ry",m);E.setAttributeNS(null,"cx",C);E.setAttributeNS(null,"cy",w);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(N,A.miny);A.maxy=Math.max(N,A.maxy);case "fhpath":e+=+L+","+
|
|
N+" ";E.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=za(x);y=za(y);h=za(h);l=za(l)}if(u.shiftKey){if(C=svgedit.path.path){E=C.dragging?C.dragging[0]:h;C=C.dragging?C.dragging[1]:l}else{E=h;C=l}w=ba(E,C,x,y);x=w.x;y=w.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;N*=o;na(ua,{x:Math.min(z*o,L),y:Math.min(v*o,N),width:Math.abs(L-z*o),height:Math.abs(N-v*o)},100)}Ma.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;Ua.mouseMove(D,H);break;case "rotate":L=
|
|
svgedit.utilities.getBBox(F);C=L.x+L.width/2;w=L.y+L.height/2;E=Y(F);E=O(C,w,E);C=E.x;w=E.y;E=L.x;N=L.y;if(current_rotate_mode=="nw")E=L.x+L.width;if(current_rotate_mode=="se")N=L.y+L.height;if(current_rotate_mode=="sw"){E=L.x+L.width;N=L.y+L.height}compensation_angle=(Math.atan2(w-N,C-E)*(180/Math.PI)-90)%360;Q=(Math.atan2(w-y,C-x)*(180/Math.PI)-90)%360;Q+=compensation_angle;if(n.gridSnapping)Q=za(Q);if(u.shiftKey)Q=Math.round(Q/45)*45;c.setRotationAngle(Q<-180?360+Q:Q,true);M("transition",J)}ob("mouseMove",
|
|
{event:u,mouse_x:D,mouse_y:H,selected:F})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var F=u.target.parentNode;if(F!==K){var H=Kb(u),D=H.tagName;if(D==="text"&&Da!=="textedit"){u=O(u.pageX,u.pageY,rb);Ua.select(H,u.x,u.y)}if((D==="g"||D==="a")&&pa(H)){Gb(H);H=J[0];Sa(true)}K&&Lb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||H===Ha.selectorParentGroup||Sb(H)}}).mouseup(function(u){c.addClones=false;window.removeEventListener("keyup",c.removeClones);
|
|
if(u.button!==2){var F=Cb;Cb=null;if(La){var H=O(u.pageX,u.pageY,rb),D=H.x*o;H=H.y*o;var E=D/o,L=H/o,N=ra(ca()),m=false;La=false;switch(Da){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");lb=[]}Da="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:cb.fill=D.getAttribute("fill");cb.fill_opacity=D.getAttribute("fill-opacity");cb.stroke=D.getAttribute("stroke");cb.stroke_opacity=
|
|
D.getAttribute("stroke-opacity");cb.stroke_width=D.getAttribute("stroke-width");cb.stroke_dasharray=D.getAttribute("stroke-dasharray");cb.stroke_linejoin=D.getAttribute("stroke-linejoin");cb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){$a.font_size=D.getAttribute("font-size");$a.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(E!=z||L!=v){u=J.length;for(D=0;D<u;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=
|
|
u.target;if(J[0].nodeName==="path"&&J[1]==null)Ma.select(J[0]);else u.shiftKey&&F!=D&&c.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(u=J[0]){u.removeAttribute("style");svgedit.utilities.walkTree(u,function(I){I.removeAttribute("style")})}}return;case "zoom":ua!=null&&ua.setAttribute("display","none");M("zoomed",{x:Math.min(z,E),y:Math.min(v,L),width:Math.abs(E-z),height:Math.abs(L-v),factor:u.altKey?0.5:2});return;case "fhpath":F=N.getAttribute("points");E=F.indexOf(",");
|
|
if(m=E>=0?F.indexOf(",",E+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)N=Ma.smoothPolylineIntoPath(N);break;case "line":F=$(N).attr(["x1","x2","y1","y2"]);m=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(N).attr(["width","height"]);m=F.width!=0||F.height!=0||Da==="image";break;case "circle":m=N.getAttribute("r")!=0;break;case "ellipse":F=$(N).attr(["rx","ry"]);m=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){N=R({element:"ellipse",
|
|
curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});M("changed",[N]);m=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){N=R({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});M("changed",[N]);m=true}break;case "text":m=true;yb([N]);Ua.start(N);break;case "path":N=null;La=true;F=Ma.mouseUp(u,N,D,H);N=F.element;m=F.keep;break;case "pathedit":m=true;N=null;Ma.mouseUp(u);
|
|
break;case "textedit":m=false;N=null;Ua.mouseUp(u,D,H);break;case "rotate":m=true;N=null;Da="select";F=c.undoMgr.finishUndoableChange();F.isEmpty()||wa(F);Ga();M("changed",J)}D=ob("mouseUp",{event:u,mouse_x:D,mouse_y:H},true);$.each(D,function(I,S){if(S){m=S.keep||m;N=S.element;La=S.started||La}});if(!m&&N!=null){B().releaseId(ca());N.parentNode.removeChild(N);N=null;for(D=u.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Da!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&
|
|
D.id!="svgcanvas"&&D.id!="svgroot"){c.setMode("select");yb([D],true)}}else if(N!=null){c.addedNew=true;u=0.2;var w;if(false.beginElement&&N.getAttribute("opacity")!=P.opacity){w=$(false).clone().attr({to:P.opacity,dur:u}).appendTo(N);try{w[0].beginElement()}catch(C){}}else u=0;setTimeout(function(){w&&w.remove();N.setAttribute("opacity",P.opacity);N.setAttribute("style","pointer-events:inherit");ma(N);if(Da==="path")Ma.toEditMode(N);else n.selectNew&&yb([N],true);wa(new Fa(N));M("changed",[N])},u*
|
|
1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",function(u){if(u.shiftKey){u.preventDefault();rb=k.getScreenCTM().inverse();var F=O(u.pageX,u.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(u.wheelDelta)if(u.wheelDelta>=120)F.factor=2;else{if(u.wheelDelta<=-120)F.factor=0.5}else if(u.detail)if(u.detail>0)F.factor=0.5;else if(u.detail<0)F.factor=2;F.factor&&M("zoomed",F)}})})();var Jb=function(e){$(e).click(function(h){h.preventDefault()})},Ua=c.textActions=function(){function e(Q){var V=H.value===
|
|
"";$(H).focus();if(!arguments.length)if(V)Q=0;else{if(H.selectionEnd!==H.selectionStart)return;Q=H.selectionEnd}var aa;aa=N[Q];V||H.setSelectionRange(Q,Q);D=ra("text_cursor");if(!D){D=document.createElementNS(b,"line");na(D,{id:"text_cursor",stroke:"#333","stroke-width":1});D=ra("selectorParentGroup").appendChild(D)}L||(L=setInterval(function(){var fa=D.getAttribute("display")==="none";D.setAttribute("display",fa?"inline":"none")},600));V=G(aa.x,m.y);aa=G(aa.x,m.y+m.height);na(D,{x1:V.x,y1:V.y,x2:aa.x,
|
|
y2:aa.y,visibility:"visible",display:"inline"});E&&E.setAttribute("d","")}function h(Q,V,aa){if(Q===V)e(V);else{aa||H.setSelectionRange(Q,V);E=ra("text_selectblock");if(!E){E=document.createElementNS(b,"path");na(E,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});ra("selectorParentGroup").appendChild(E)}Q=N[Q];var fa=N[V];D.setAttribute("visibility","hidden");V=G(Q.x,m.y);aa=G(Q.x+(fa.x-Q.x),m.y);var qa=G(Q.x,m.y+m.height);Q=G(Q.x+(fa.x-Q.x),m.y+m.height);na(E,{d:"M"+
|
|
V.x+","+V.y+" L"+aa.x+","+aa.y+" "+Q.x+","+Q.y+" "+qa.x+","+qa.y+"z",display:"inline"})}}function l(Q,V){var aa=d.createSVGPoint();aa.x=Q;aa.y=V;if(N.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=N.length-2;if(Q<=N[0].x)aa=0}else if(aa>=N.length-2)aa=N.length-2;var fa=N[aa];Q>fa.x+fa.width/2&&aa++;return aa}function z(Q,V,aa){var fa=H.selectionStart;Q=l(Q,V);h(Math.min(fa,Q),Math.max(fa,Q),!aa)}function v(Q,V){var aa={x:Q,y:V};aa.x/=o;aa.y/=o;if(w){var fa=O(aa.x,aa.y,w.inverse());aa.x=
|
|
fa.x;aa.y=fa.y}return aa}function G(Q,V){var aa={x:Q,y:V};if(w){var fa=O(aa.x,aa.y,w);aa.x=fa.x;aa.y=fa.y}aa.x*=o;aa.y*=o;return aa}function A(Q){h(0,F.textContent.length);$(this).unbind(Q)}function u(Q){if(S&&F){var V=O(Q.pageX,Q.pageY,rb);V=v(V.x*o,V.y*o);V=l(V.x,V.y);var aa=F.textContent,fa=aa.substr(0,V).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(V).match(/^[a-z0-9]+/i);h(fa,(aa?aa[0].length:0)+V);$(Q.target).click(A);setTimeout(function(){$(Q.target).unbind("click",A)},300)}}var F,H,D,E,L,
|
|
N=[],m,w,C,I,S;return{select:function(Q,V,aa){F=Q;Ua.toEditMode(V,aa)},start:function(Q){F=Q;Ua.toEditMode()},mouseDown:function(Q,V,aa,fa){Q=v(aa,fa);H.focus();e(l(Q.x,Q.y));C=aa;I=fa},mouseMove:function(Q,V){var aa=v(Q,V);z(aa.x,aa.y)},mouseUp:function(Q,V,aa){var fa=v(V,aa);z(fa.x,fa.y,true);Q.target!==F&&V<C+2&&V>C-2&&aa<I+2&&aa>I-2&&Ua.toSelectMode(true)},setCursor:e,toEditMode:function(Q,V){yb([F],false);S=false;Da="textedit";Ha.requestSelector(F);Ua.init();$(F).css("cursor","text");if(arguments.length){var aa=
|
|
v(Q,V);e(l(aa.x,aa.y))}else e();setTimeout(function(){S=true},300)},toSelectMode:function(Q){Da="select";clearInterval(L);L=null;E&&$(E).attr("display","none");D&&$(D).attr("visibility","hidden");$(F).css("cursor","move");if(Q){Sa();$(F).css("cursor","move");M("selected",[F]);ub([F],true)}F&&!F.textContent.length&&c.deleteSelectedElements();$(H).blur();F=false},setInputElem:function(Q){H=Q},clear:function(){Da=="textedit"&&Ua.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var Q=
|
|
F.textContent.length,V=F.getAttribute("transform");m=svgedit.utilities.getBBox(F);w=V?Y(F):null;N=Array(Q);H.focus();$(F).unbind("dblclick",u).dblclick(u);if(!Q)var aa={x:m.x+m.width/2,width:0};for(V=0;V<Q;V++){var fa=F.getStartPositionOfChar(V);aa=F.getEndPositionOfChar(V);if(!svgedit.browser.supportsGoodTextCharPos()){var qa=c.contentW*o;fa.x-=qa;aa.x-=qa;fa.x/=o;aa.x/=o}N[V]={x:fa.x,y:m.y,width:aa.x-fa.x,height:m.height}}N.push({x:aa.x,width:0});h(H.selectionStart,H.selectionEnd,true)}}}}(),Ma=
|
|
c.pathActions=function(){var e=false,h,l,z;svgedit.path.Path.prototype.endChanges=function(A){if(svgedit.browser.isWebkit()){var u=this.elem;u.setAttribute("d",Ma.convertPath(u))}A=new Oa(this.elem,{d:this.last_d},A);wa(A);M("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var u=0;u<A.length;u++){var F=A[u],H=this.segs[F];H.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();u=this.selected_pts.length;
|
|
for(A=Array(u);u--;){H=this.segs[this.selected_pts[u]];H.select(true);A[u]=H.ptgrip}Ma.canDeleteNodes=true;Ma.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",A)};var v=h=null,G=false;return{mouseDown:function(A,u,F,H){if(Da==="path"){mouse_x=F;mouse_y=H;H=mouse_x/o;u=mouse_y/o;F=ra("path_stretch_line");l=[H,u];if(n.gridSnapping){H=za(H);u=za(u);mouse_x=za(mouse_x);mouse_y=za(mouse_y)}if(!F){F=document.createElementNS(b,"path");na(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",
|
|
fill:"none"});F=ra("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var D=null;if(v){D=v.pathSegList;for(var E=D.numberOfItems,L=6/o,N=false;E;){E--;var m=D.getItem(E),w=m.x;m=m.y;if(H>=w-L&&H<=w+L&&u>=m-L&&u<=m+L){N=true;break}}L=ca();svgedit.path.removePath_(L);L=ra(L);w=D.numberOfItems;if(N){if(E<=1&&w>=2){H=D.getItem(0).x;u=D.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?v.createSVGPathSegLinetoAbs(H,u):v.createSVGPathSegCurvetoCubicAbs(H,u,A.x1/o,A.y1/o,
|
|
H,u);H=v.createSVGPathSegClosePath();D.appendItem(A);D.appendItem(H)}else if(w<3)return D=false;$(F).remove();element=L;v=null;La=false;if(e){svgedit.path.path.matrix&&gb(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ma.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,
|
|
Kb(A))){console.log("Clicked outside canvas");return false}D=v.pathSegList.numberOfItems;E=v.pathSegList.getItem(D-1);L=E.x;E=E.y;if(A.shiftKey){A=ba(L,E,H,u);H=A.x;u=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?v.createSVGPathSegLinetoAbs(hb(H),hb(u)):v.createSVGPathSegCurvetoCubicAbs(hb(H),hb(u),A.x1/o,A.y1/o,A.x2/o,A.y2/o);v.pathSegList.appendItem(A);H*=o;u*=o;F.setAttribute("d",["M",H,u,H,u].join(" "));F=D;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,H,u)}}else{d_attr=
|
|
"M"+H+","+u+" ";v=R({element:"path",curStyles:true,attr:{d:d_attr,id:la(),opacity:P.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){u=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,H];D=svgedit.path.path.segs[u];if(A.shiftKey)D.selected?svgedit.path.path.removePtFromSelection(u):
|
|
svgedit.path.path.addPtsToSelection(u);else{if(svgedit.path.path.selected_pts.length<=1||!D.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(u)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,H];A=L.split("_")[1].split("c");u=A[0]-0;svgedit.path.path.selectPt(u,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();na(ua,{x:F*o,y:H*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,u,F){G=true;if(Da==="path"){if(v){var H=
|
|
v.pathSegList;A=H.numberOfItems-1;if(l){var D=svgedit.path.addCtrlGrip("1c1"),E=svgedit.path.addCtrlGrip("0c2");E.getAttribute("cx");E.getAttribute("cy");D.setAttribute("cx",u);D.setAttribute("cy",F);D.setAttribute("display","inline");D=l[0];var L=l[1];H.getItem(A);var N=D+(D-u/o),m=L+(L-F/o);E.setAttribute("cx",N*o);E.setAttribute("cy",m*o);E.setAttribute("display","inline");E=svgedit.path.getCtrlLine(1);var w=svgedit.path.getCtrlLine(2);na(E,{x1:u,y1:F,x2:D*o,y2:L*o,display:"inline"});na(w,{x1:N*
|
|
o,y1:m*o,x2:D*o,y2:L*o,display:"inline"});if(A===0)z=[u,F];else{H=H.getItem(A-1);u=H.x;F=H.y;if(H.pathSegType===6){u+=u-H.x2;F+=F-H.y2}else if(z){u=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[D,L,u,F,N,m],v)}}else if(D=ra("path_stretch_line")){A=H.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[u,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,u,F],D);else z?svgedit.path.replacePathSeg(6,1,[u,F,z[0],z[1],u,F],D):svgedit.path.replacePathSeg(4,1,[u,F],D)}}}else if(svgedit.path.path.dragging){D=
|
|
svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:u,y:F},svgedit.path.path);A=L.x-D.x;D=L.y-D.y;svgedit.path.path.dragging=[u,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,D):svgedit.path.path.movePts(A,D)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var C=ua.getBBox(),I=svgedit.path.getGripPt(this);C=svgedit.math.rectsIntersect(C,
|
|
{x:I.x,y:I.y,width:0,height:0});this.select(C);C&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(A,u){if(Da==="path"){l=null;if(!v){u=ra(ca());La=false;z=null}return{keep:true,element:u}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!G&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!=
|
|
"none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<=2&&Ma.toSelectMode(A.target)}else Ma.toSelectMode(A.target);G=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Da="pathedit";Sa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var u=A==svgedit.path.path.elem;Da="select";svgedit.path.path.show(false);h=false;Sa();svgedit.path.path.matrix&&
|
|
svgedit.path.recalcRotatedPath();if(u){M("selected",[A]);ub([A],true)}},addSubPath:function(A){if(A){Da="path";e=true}else{Ma.clear(true);Ma.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ma.toEditMode(A);Da="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(pa(A)!=0){var u=new Ea("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};u.addSubCommand(new Oa(A,F));Sa();this.resetOrientation(A);wa(u);svgedit.path.getPath_(A).show(false).matrix=null;
|
|
this.clear();ub([A],true);M("changed",J)}},clear:function(){h=null;if(v){var A=ra(ca());$(ra("path_stretch_line")).remove();$(A).remove();$(ra("pathpointgrip_container")).find("*").attr("display","none");v=z=null;La=false}else Da=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var u=W(A),F=ga(u).matrix;u.clear();A.removeAttribute("transform");u=A.pathSegList;for(var H=u.numberOfItems,
|
|
D=0;D<H;++D){var E=u.getItem(D),L=E.pathSegType;if(L!=1){var N=[];$.each(["",1,2],function(m,w){var C=E["x"+w],I=E["y"+w];if(C!==undefined&&I!==undefined){C=O(C,I,F);N.splice(N.length,0,C.x,C.y)}});svgedit.path.replacePathSeg(L,D,N,A)}}g(A,F)},zoomChange:function(){Da=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var A=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:A.item.x,y:A.item.y,type:A.type}},linkControlPoints:function(A){svgedit.path.setLinkControlPoints(A)},
|
|
clonePathNode:function(){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,u=A.length,F=[];u--;){var H=A[u];svgedit.path.path.addSeg(H);F.push(H+u);F.push(H+u+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var A=svgedit.path.path.selected_pts;if(A.length===1){var u=svgedit.path.path.elem,F=u.pathSegList,H=A[0],D=null,E=null;svgedit.path.path.eachSeg(function(w){if(this.type===2&&w<=H)E=this.item;if(w<=
|
|
H)return true;if(this.type===2){D=w;return false}else if(this.type===1)return D=false});if(D==null)D=svgedit.path.path.segs.length-1;if(D!==false){var L=u.createSVGPathSegLinetoAbs(E.x,E.y),N=u.createSVGPathSegClosePath();if(D==svgedit.path.path.segs.length-1){F.appendItem(L);F.appendItem(N)}else{svgedit.path.insertItemBefore(u,N,D);svgedit.path.insertItemBefore(u,L,D)}svgedit.path.path.init().selectPt(D+1)}else if(svgedit.path.path.segs[H].mate){F.removeItem(H);F.removeItem(H);svgedit.path.path.init().selectPt(H-
|
|
1)}else{for(A=0;A<F.numberOfItems;A++){var m=F.getItem(A);if(m.pathSegType===2)L=A;else if(A===H)F.removeItem(L);else if(m.pathSegType===1&&H<A){N=A-1;F.removeItem(A);break}}for(A=H-L-1;A--;)svgedit.path.insertItemBefore(u,F.getItem(L),N);u=F.getItem(L);svgedit.path.replacePathSeg(2,L,[u.x,u.y]);A=H;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ma.canDeleteNodes){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,u=A.length;u--;)svgedit.path.path.deleteSeg(A[u]);
|
|
var F=function(){var H=svgedit.path.path.elem.pathSegList,D=H.numberOfItems,E=function(m,w){for(;w--;)H.removeItem(m)};if(D<=1)return true;for(;D--;){var L=H.getItem(D);if(L.pathSegType===1){L=H.getItem(D-1);var N=H.getItem(D-2);if(L.pathSegType===2){E(D-1,2);F();break}else if(N.pathSegType===2){E(D-2,3);F();break}}else if(L.pathSegType===2)if(D>0){L=H.getItem(D-1).pathSegType;if(L===2){E(D-1,1);F();break}else if(L===1&&H.numberOfItems-1===D){E(D,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=
|
|
1){Ma.toSelectMode(svgedit.path.path.elem);c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var u=A.points,F=u.numberOfItems;if(F>=4){var H=u.getItem(0),D=null;A=[];A.push(["M",H.x,",",H.y," C"].join(""));for(var E=1;E<=F-4;E+=3){var L=u.getItem(E),N=u.getItem(E+1),m=u.getItem(E+2);if(D)if((H=svgedit.path.smoothControlPoints(D,
|
|
L,H))&&H.length==2){L=A[A.length-1].split(",");L[2]=H[0].x;L[3]=H[0].y;A[A.length-1]=L.join(",");L=H[1]}A.push([L.x,L.y,N.x,N.y,m.x,m.y].join(","));H=m;D=N}for(A.push("L");E<F;++E){N=u.getItem(E);A.push([N.x,N.y].join(","))}A=A.join(" ");A=R({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,u){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];
|
|
var H={x:0,y:0};H[A]=u-F.item[A];F.move(H.x,H.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var u=A.pathSegList,F=u.numberOfItems,H,D=0;D<F;++D){var E=u.getItem(D);if(E.pathSegType===2)H=E;if(E.pathSegType===1){E=u.getItem(D-1);if(E.x!=H.x||E.y!=H.y){u=A.createSVGPathSegLinetoAbs(H.x,H.y);svgedit.path.insertItemBefore(A,u,D);Ma.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ma.convertPath(A))},convertPath:function(A,u){for(var F=A.pathSegList,H=F.numberOfItems,
|
|
D=0,E=0,L="",N=null,m=0;m<H;++m){var w=F.getItem(m),C=w.x||0,I=w.y||0,S=w.x1||0,Q=w.y1||0,V=w.x2||0,aa=w.y2||0,fa=w.pathSegType,qa=Pa[fa]["to"+(u?"Lower":"Upper")+"Case"](),sa=function(ab,Aa,ia){Aa=Aa?" "+Aa.join(" "):"";ia=ia?" "+svgedit.units.shortFloat(ia):"";$.each(ab,function(fb,Ta){ab[fb]=svgedit.units.shortFloat(Ta)});L+=qa+ab.join(" ")+Aa+ia};switch(fa){case 1:L+="z";break;case 12:C-=D;case 13:if(u){D+=C;qa="l"}else{C+=D;D=C;qa="L"}sa([[C,E]]);break;case 14:I-=E;case 15:if(u){E+=I;qa="l"}else{I+=
|
|
E;E=I;qa="L"}sa([[D,I]]);break;case 2:case 4:case 18:C-=D;I-=E;case 5:case 3:if(N&&F.getItem(m-1).pathSegType===1&&!u){D=N[0];E=N[1]}case 19:if(u){D+=C;E+=I}else{C+=D;I+=E;D=C;E=I}if(fa===3)N=[D,E];sa([[C,I]]);break;case 6:C-=D;S-=D;V-=D;I-=E;Q-=E;aa-=E;case 7:if(u){D+=C;E+=I}else{C+=D;S+=D;V+=D;I+=E;Q+=E;aa+=E;D=C;E=I}sa([[S,Q],[V,aa],[C,I]]);break;case 8:C-=D;S-=D;I-=E;Q-=E;case 9:if(u){D+=C;E+=I}else{C+=D;S+=D;I+=E;Q+=E;D=C;E=I}sa([[S,Q],[C,I]]);break;case 10:C-=D;I-=E;case 11:if(u){D+=C;E+=I}else{C+=
|
|
D;I+=E;D=C;E=I}sa([[w.r1,w.r2]],[w.angle,w.largeArcFlag?1:0,w.sweepFlag?1:0],[C,I]);break;case 16:C-=D;V-=D;I-=E;aa-=E;case 17:if(u){D+=C;E+=I}else{C+=D;V+=D;I+=E;aa+=E;D=C;E=I}sa([[V,aa],[C,I]])}}return L}}}(),Ob=this.removeUnusedDefElems=function(){var e=k.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var h=[],l=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],v=z.length,G=k.getElementsByTagNameNS(b,"*"),A=G.length,u=0;u<A;u++){for(var F=G[u],H=0;H<v;H++){var D=
|
|
ja(F.getAttribute(z[H]));D&&h.push(D.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(u=e.length;u--;){z=e[u];v=z.id;if(h.indexOf(v)<0){wb[v]=z;z.parentNode.removeChild(z);l++}}return l};this.svgCanvasToString=function(){for(;Ob()>0;);Ma.clear(true);$.each(k.childNodes,function(l,z){l&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&k.insertBefore(z,k.firstChild)});if(K){Lb();yb([K])}var e=
|
|
[];$(k).find("g:data(gsvg)").each(function(){for(var l=this.attributes,z=l.length,v=0;v<z;v++)if(l[v].nodeName=="id"||l[v].nodeName=="style")z--;if(z<=0){l=this.firstChild;e.push(l);$(this).replaceWith(l)}});var h=this.svgToString(k,0);e.length&&$(e).each(function(){xb(this)});return h};this.svgToString=function(e,h){var l=[],z=svgedit.utilities.toXml,v=n.baseUnit,G=RegExp("^-?[\\d\\.]+"+v+"$");if(e){ma(e);var A=e.attributes,u,F,H=e.childNodes;for(F=0;F<h;F++)l.push(" ");l.push("<");l.push(e.nodeName);
|
|
if(e.id==="svgcontent"){F=Eb();if(v!=="px"){F.w=svgedit.units.convertUnit(F.w,v)+v;F.h=svgedit.units.convertUnit(F.h,v)+v}l.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+b+'"');var D={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(m,w){var C=w.namespaceURI;if(C&&!D[C]&&Ca[C]!=="xmlns"&&Ca[C]!=="xml"){D[C]=true;l.push(" xmlns:"+Ca[C]+'="'+C+'"')}})});F=A.length;for(v=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){u=A.item(F);var E=z(u.nodeValue);if(u.nodeName.indexOf("xmlns:")!==
|
|
0)if(E!=""&&v.indexOf(u.localName)==-1)if(!u.namespaceURI||Ca[u.namespaceURI]){l.push(" ");l.push(u.nodeName);l.push('="');l.push(E);l.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var L=["-moz-math-font-style","_moz-math-font-style"];for(F=A.length-1;F>=0;F--){u=A.item(F);E=z(u.nodeValue);if(!(L.indexOf(u.localName)>=0))if(E!="")if(E.indexOf("pointer-events")!==0)if(!(u.localName==="class"&&E.indexOf("se_")===0)){l.push(" ");if(u.localName==="d")E=Ma.convertPath(e,true);if(isNaN(E)){if(G.test(E))E=
|
|
svgedit.units.shortFloat(E)+v}else E=svgedit.units.shortFloat(E);if(ib.apply&&e.nodeName==="image"&&u.localName==="href"&&ib.images&&ib.images==="embed"){var N=Ya[E];if(N)E=N}if(!u.namespaceURI||u.namespaceURI==b||Ca[u.namespaceURI]){l.push(u.nodeName);l.push('="');l.push(E);l.push('"')}}}}if(e.hasChildNodes()){l.push(">");h++;A=false;for(F=0;F<H.length;F++){v=H.item(F);switch(v.nodeType){case 1:l.push("\n");l.push(this.svgToString(H.item(F),h));break;case 3:v=v.nodeValue.replace(/^\s+|\s+$/g,"");
|
|
if(v!=""){A=true;l.push(z(v)+"")}break;case 4:l.push("\n");l.push(Array(h+1).join(" "));l.push("<![CDATA[");l.push(v.nodeValue);l.push("]]\>");break;case 8:l.push("\n");l.push(Array(h+1).join(" "));l.push("<!--");l.push(v.data);l.push("--\>")}}h--;if(!A){l.push("\n");for(F=0;F<h;F++)l.push(" ")}l.push("</");l.push(e.nodeName);l.push(">")}else l.push("/>")}return l.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var l=document.createElement("canvas");l.width=this.width;l.height=
|
|
this.height;l.getContext("2d").drawImage(this,0,0);try{var z=";svgedit_url="+encodeURIComponent(e);z=l.toDataURL().replace(";base64",z+";base64");Ya[e]=z}catch(v){Ya[e]=false}Ba=e;h&&h(Ya[e])}).attr("src",e)};this.setGoodImage=function(e){Ba=e};this.open=function(){};this.save=function(e){Sa();e&&$.extend(ib,e);ib.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){Sa();var e=[],h={feGaussianBlur:nb.exportNoBlur,foreignObject:nb.exportNoforeignObject,"[stroke-dasharray]":nb.exportNoDashArray},
|
|
l=$(k);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=nb.exportNoText;$.each(h,function(z,v){l.find(z).length&&e.push(v)});h=this.svgCanvasToString();M("exported",{svg:h,issues:e})};this.getSvgString=function(){ib.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 Hb=this.uniquifyElems=function(e){var h={},l=["filter","linearGradient","pattern","radialGradient",
|
|
"symbol","textPath","use"];svgedit.utilities.walkTree(e,function(u){if(u.nodeType==1){if(u.id){u.id in h||(h[u.id]={elem:null,attrs:[],hrefs:[]});h[u.id].elem=u}$.each(Ab,function(H,D){var E=u.getAttributeNode(D);if(E){var L=svgedit.utilities.getUrlFromAttr(E.value);if(L=L?L.substr(1):null){L in h||(h[L]={elem:null,attrs:[],hrefs:[]});h[L].attrs.push(E)}}});var F=svgedit.utilities.getHref(u);if(F&&l.indexOf(u.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(u)}}});
|
|
for(var z in h)if(z){var v=h[z].elem;if(v){e=la();v.id=e;v=h[z].attrs;for(var G=v.length;G--;){var A=v[G];A.ownerElement.setAttribute(A.name,"url(#"+e+")")}v=h[z].hrefs;for(G=v.length;G--;)svgedit.utilities.setHref(v[G],"#"+e)}}},Nb=this.setUseData=function(e){var h=$(e);if(e.tagName!=="use")h=h.find("use");h.each(function(){var l=da(this).substr(1);if(l=ra(l)){$(this).data("ref",l);if(l.tagName=="symbol"||l.tagName=="svg")$(this).data("symbol",l).data("ref",l)}})},Pb=this.convertGradients=function(e){var h=
|
|
$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var l=$(k).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(l.length)if(l=svgedit.utilities.getBBox(l[0]))if(this.tagName==="linearGradient"){var z=$(this).attr(["x1","y1","x2","y2"]),v=this.gradientTransform.baseVal;if(v&&v.numberOfItems>0){var G=
|
|
ga(v).matrix;v=O(z.x1,z.y1,G);G=O(z.x2,z.y2,G);z.x1=v.x;z.y1=v.y;z.x2=G.x;z.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(z.x1-l.x)/l.width,y1:(z.y1-l.y)/l.height,x2:(z.x2-l.x)/l.width,y2:(z.y2-l.y)/l.height});this.removeAttribute("gradientUnits")}}})},Rb=this.convertToGroup=function(e){e||(e=J[0]);var h=$(e),l=new Ea,z;if(h.data("gsvg")){l=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");z=W(e);var v=d.createSVGTransform();v.setTranslate(l.x,
|
|
l.y);z.appendItem(v);Ra(e);M("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");z=h.attr("transform");v=h.attr(["x","y"]);var G=e.getAttribute("viewBox");if(G){G=G.split(" ");v.x-=+G[0];v.y-=+G[1]}z+=" translate("+(v.x||0)+","+(v.y||0)+")";v=h.prev();l.addSubCommand(new Ia(h[0],h[0].nextSibling,h[0].parentNode));h.remove();G=$(k).find("use:data(symbol)").length;h=f.createElementNS(b,"g");for(var A=e.childNodes,u=0;u<A.length;u++)h.appendChild(A[u].cloneNode(true));if(svgedit.browser.isGecko()){A=
|
|
$(mb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(A)}z&&h.setAttribute("transform",z);z=e.parentNode;Hb(h);svgedit.browser.isGecko()&&$(mb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=la();v.after(h);if(z){if(!G){v=e.nextSibling;z.removeChild(e);l.addSubCommand(new Ia(e,v,z))}l.addSubCommand(new Fa(h))}Nb(h);svgedit.browser.isGecko()?Pb(mb()):Pb(h);svgedit.utilities.walkTreePost(h,function(F){try{Ra(F)}catch(H){console.log(H)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
|
|
la()});yb([h]);(e=Gb(h,true))&&l.addSubCommand(e);wa(l)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);this.prepareSvg(h);var l=new Ea("Change Source"),z=k.nextSibling,v=d.removeChild(k);l.addSubCommand(new Ia(v,z,d));k=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);d.appendChild(k);var G=$(k);c.current_drawing_=new svgedit.draw.Drawing(k,q);var A=B().getNonce();A?M("setnonce",A):M("unsetnonce");
|
|
G.find("image").each(function(){var N=this;Jb(N);var m=da(this);if(m.indexOf("data:")===0){var w=m.match(/svgedit_url=(.*?);/);if(w){var C=decodeURIComponent(w[1]);$(new Image).load(function(){N.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",C)}).attr("src",C)}}c.embedImage(m)});G.find("svg").each(function(){if(!$(this).closest("defs").length){Hb(this);var N=this.parentNode;if(N.childNodes.length===1&&N.nodeName==="g"){$(N).data("gsvg",this);N.id=N.id||la()}else xb(this)}});svgedit.browser.isGecko()&&
|
|
G.find("linearGradient, radialGradient, pattern").appendTo(mb());Nb(G);Pb(G[0]);svgedit.utilities.walkTreePost(k,function(N){try{Ra(N)}catch(m){console.log(m)}});var u={id:"svgcontent",overflow:n.show_outside_canvas?"visible":"hidden"},F=false;if(G.attr("viewBox")){var H=G.attr("viewBox").split(" ");u.width=H[2];u.height=H[3]}else $.each(["width","height"],function(N,m){var w=G.attr(m);w||(w="100%");if((w+"").substr(-1)==="%")F=true;else u[m]=ta(m,w)});vb();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=
|
|
la()});if(F){var D=getStrokedBBox();u.width=D.width+D.x;u.height=D.height+D.y}if(u.width<=0)u.width=100;if(u.height<=0)u.height=100;G.attr(u);this.contentW=u.width;this.contentH=u.height;l.addSubCommand(new Fa(k));var E=G.attr(["width","height"]);l.addSubCommand(new Oa(d,E));o=1;svgedit.transformlist.resetListMap();Sa();svgedit.path.clearData();d.appendChild(Ha.selectorParentGroup);wa(l);M("changed",[k])}catch(L){console.log(L);return false}return true};this.importSvgString=function(e){try{var h=
|
|
svgedit.utilities.encode64(e.length+e).substr(0,32),l=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)l=true;var z=new Ea("Import SVG");if(l)var v=sb[h].symbol,G=sb[h].xform;else{var A=svgedit.utilities.text2xml(e);this.prepareSvg(A);var u;u=f.adoptNode?f.adoptNode(A.documentElement):f.importNode(A.documentElement,true);Hb(u);var F=ta("width",u.getAttribute("width")),H=ta("height",u.getAttribute("height")),D=u.getAttribute("viewBox"),E=D?D.split(" "):[0,0,F,H];for(e=0;e<4;++e)E[e]=+E[e];
|
|
k.getAttribute("width");var L=+k.getAttribute("height");G=H>F?"scale("+L/3/E[3]+")":"scale("+L/3/E[2]+")";G="translate(0) "+G+" translate(0)";v=f.createElementNS(b,"symbol");var N=mb();for(svgedit.browser.isGecko()&&$(u).find("linearGradient, radialGradient, pattern").appendTo(N);u.firstChild;)v.appendChild(u.firstChild);var m=u.attributes;for(u=0;u<m.length;u++){var w=m[u];v.setAttribute(w.nodeName,w.nodeValue)}v.id=la();sb[h]={symbol:v,xform:G};mb().appendChild(v);z.addSubCommand(new Fa(v))}var C=
|
|
f.createElementNS(b,"use");C.id=la();X(C,"#"+v.id);(K||B().getCurrentLayer()).appendChild(C);z.addSubCommand(new Fa(C));Sa();C.setAttribute("transform",G);Ra(C);$(C).data("symbol",v).data("ref",v);ub([C]);wa(z);M("changed",[k])}catch(I){console.log(I);return false}return true};var vb=c.identifyLayers=function(){Lb();B().identifyLayers()};this.createLayer=function(e){var h=new Ea("Create Layer");e=B().createLayer(e);h.addSubCommand(new Fa(e));wa(h);Sa();M("changed",[e])};this.cloneLayer=function(e){var h=
|
|
new Ea("Duplicate Layer"),l=f.createElementNS(b,"g"),z=f.createElementNS(b,"title");z.textContent=e;l.appendChild(z);z=B().getCurrentLayer();$(z).after(l);z=z.childNodes;for(var v=0;v<z.length;v++){var G=z[v];G.localName!="title"&&l.appendChild(ka(G))}Sa();vb();h.addSubCommand(new Fa(l));wa(h);c.setCurrentLayer(e);M("changed",[l])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),h=e.nextSibling,l=e.parentNode;if(e=B().deleteCurrentLayer()){var z=new Ea("Delete Layer");z.addSubCommand(new Ia(e,
|
|
h,l));wa(z);Sa();M("changed",[l]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&Sa();return e};this.renameCurrentLayer=function(e){var h=B();if(h.current_layer){var l=h.current_layer;if(!c.setCurrentLayer(e)){for(var z=new Ea("Rename Layer"),v=0;v<h.getNumLayers();++v)if(h.all_layers[v][1]==l)break;var G=h.getLayerName(v);h.all_layers[v][0]=svgedit.utilities.toXml(e);var A=l.childNodes.length;for(v=0;v<A;++v){var u=l.childNodes.item(v);
|
|
if(u&&u.tagName=="title"){for(;u.firstChild;)u.removeChild(u.firstChild);u.textContent=e;z.addSubCommand(new Oa(u,{"#text":G}));wa(z);M("changed",[l]);return true}}}h.current_layer=l}return false};this.setCurrentLayerPosition=function(e){var h=B();if(h.current_layer&&e>=0&&e<h.getNumLayers()){for(var l=0;l<h.getNumLayers();++l)if(h.all_layers[l][1]==h.current_layer)break;if(l==h.getNumLayers())return false;if(l!=e){var z=null,v=h.current_layer.nextSibling;if(e>l){if(e<h.getNumLayers()-1)z=h.all_layers[e+
|
|
1][1]}else z=h.all_layers[e][1];k.insertBefore(h.current_layer,z);wa(new Ka(h.current_layer,v,k));vb();c.setCurrentLayer(h.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,h){var l=B(),z=l.getLayerVisibility(e),v=l.setLayerVisibility(e,h);if(v)wa(new Oa(v,{display:z?"inline":"none"},"Layer Visibility"));else return false;if(v==l.getCurrentLayer()){Sa();Ma.clear()}return true};this.moveSelectedToLayer=function(e){for(var h=null,l=B(),z=0;z<l.getNumLayers();++z)if(l.getLayerName(z)==
|
|
e){h=l.all_layers[z][1];break}if(!h)return false;e=new Ea("Move Elements to Layer");l=J;for(z=l.length;z--;){var v=l[z];if(v){var G=v.nextSibling,A=v.parentNode;h.appendChild(v);e.addSubCommand(new Ka(v,G,A))}}wa(e);return true};this.mergeLayer=function(e){var h=new Ea("Merge Layer"),l=B(),z=$(l.current_layer).prev()[0];if(z){for(h.addSubCommand(new Ia(l.current_layer,l.current_layer.nextSibling,k));l.current_layer.firstChild;){var v=l.current_layer.firstChild;if(v.localName=="title"){h.addSubCommand(new Ia(v,
|
|
v.nextSibling,l.current_layer));l.current_layer.removeChild(v)}else{var G=v.nextSibling;z.appendChild(v);h.addSubCommand(new Ka(v,G,l.current_layer))}}k.removeChild(l.current_layer);if(!e){Sa();vb();M("changed",[k]);wa(h)}l.current_layer=z;return h}};this.mergeAllLayers=function(){var e=new Ea("Merge all Layers"),h=B();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(k).children("g").length>1;)e.addSubCommand(c.mergeLayer(true));Sa();vb();M("changed",[k]);wa(e)};var Lb=this.leaveContext=
|
|
function(){var e=xa.length;if(e){for(var h=0;h<e;h++){var l=xa[h],z=Qa(l,"orig_opac");z!==1?l.setAttribute("opacity",z):l.removeAttribute("opacity");l.setAttribute("style","pointer-events: inherit")}xa=[];Sa(true);M("contextset",null)}K=null},Sb=this.setContext=function(e){Lb();if(typeof e==="string")e=ra(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;Qa(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style",
|
|
"pointer-events: none");xa.push(this)});Sa();M("contextset",K)};this.clear=function(){Ma.clear();Sa();c.clearSvgContentElement();c.current_drawing_=new svgedit.draw.Drawing(k);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();Ha.initGroup();ua=Ha.getRubberBandBox();M("cleared")};this.linkControlPoints=Ma.linkControlPoints;this.getContentElem=function(){return k};this.getRootElem=function(){return d};this.getSelectedElems=function(){return J};var Eb=this.getResolution=function(){var e=k.getAttribute("width")/
|
|
o,h=k.getAttribute("height")/o;return{w:e,h:h,zoom:o}};this.getZoom=function(){return o};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(nb,e.notification)};this.setConfig=function(e){$.extend(n,e)};this.getTitle=function(e){if(e=e||J[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var h=0;h<e.length;h++)if(e[h].nodeName=="title")return e[h].textContent;return""}};this.setGroupTitle=function(e){var h=J[0];h=$(h).data("gsvg")||
|
|
h;var l=$(h).children("title"),z=new Ea("Set Label");if(e.length)if(l.length){l=l[0];z.addSubCommand(new Oa(l,{"#text":l.textContent}));l.textContent=e}else{l=f.createElementNS(b,"title");l.textContent=e;$(h).prepend(l);z.addSubCommand(new Fa(l))}else{z.addSubCommand(new Ia(l[0],l.nextSibling,h));l.remove()}wa(z)};this.getDocumentTitle=function(){return c.getTitle(k)};this.setDocumentTitle=function(e){for(var h=k.childNodes,l=false,z="",v=new Ea("Change Image Title"),G=0;G<h.length;G++)if(h[G].nodeName==
|
|
"title"){l=h[G];z=l.textContent;break}if(!l){l=f.createElementNS(b,"title");k.insertBefore(l,k.firstChild)}if(e.length)l.textContent=e;else l.parentNode.removeChild(l);v.addSubCommand(new Oa(l,{"#text":z}));wa(v)};this.getEditorNS=function(e){e&&k.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,h){var l=Eb(),z=l.w;l=l.h;var v;if(e=="fit"){var G=getStrokedBBox();if(G){v=new Ea("Fit Canvas to Content");var A=tb();ub(A);
|
|
var u=[],F=[];$.each(A,function(){u.push(G.x*-1);F.push(G.y*-1)});A=c.moveSelectedElements(u,F,true);v.addSubCommand(A);Sa();e=Math.round(G.width);h=Math.round(G.height)}else return false}if(e!=z||h!=l){A=d.suspendRedraw(1E3);v||(v=new Ea("Change Image Dimensions"));e=ta("width",e);h=ta("height",h);k.setAttribute("width",e);k.setAttribute("height",h);this.contentW=e;this.contentH=h;v.addSubCommand(new Oa(k,{width:z,height:l}));k.setAttribute("viewBox",[0,0,e/o,h/o].join(" "));v.addSubCommand(new Oa(k,
|
|
{viewBox:["0 0",z,l].join(" ")}));wa(v);d.unsuspendRedraw(A);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",h+2)}M("changed",[k])}return[e,h]};this.getOffset=function(){return $(k).attr(["x","y"])};this.setBBoxZoom=function(e,h,l){var z=0.85,v=function(G){if(!G)return false;var A=Math.min(Math.round(h/G.width*100*z)/100,Math.round(l/G.height*100*z)/100);
|
|
c.setZoom(A);return{zoom:A,bbox:G}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:o*e.factor);return{zoom:o,bbox:e}}return v(e)}switch(e){case "selection":if(!J[0])return;e=$.map(J,function(G){if(G)return G});e=getStrokedBBox(e);break;case "canvas":e=Eb();z=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(tb(B().getCurrentLayer()));break;default:return}return v(e)};this.setZoom=function(e){var h=Eb();
|
|
k.setAttribute("viewBox","0 0 "+h.w/e+" "+h.h/e);o=e;$.each(J,function(l,z){z&&Ha.requestSelector(z).resize()});Ma.zoomChange();ob("zoomChanged",e)};this.getMode=function(){return Da};this.setMode=function(e){Ma.clear(true);Ua.clear();$("#workarea").attr("class",e);cb=J[0]&&J[0].nodeName=="text"?$a:P;Da=e};this.getColor=function(e){return cb[e]};this.setColor=function(e,h,l){P[e]=h;cb[e+"_paint"]={type:"solidColor"};for(var z=[],v=J.length;v--;){var G=J[v];if(G)if(G.tagName=="g")svgedit.utilities.walkTree(G,
|
|
function(A){A.nodeName!="g"&&z.push(A)});else if(e=="fill")G.tagName!="polyline"&&G.tagName!="line"&&z.push(G);else z.push(G)}if(z.length>0)if(l)Db(e,h,z);else{eb(e,h,z);M("changed",z)}};var mb=function(){var e=k.getElementsByTagNameNS(b,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(b,"defs");k.firstChild?k.insertBefore(e,k.firstChild.nextSibling):k.appendChild(e)}return e},Mb=this.setGradient=function(e){if(!(!cb[e+"_paint"]||cb[e+"_paint"].type=="solidColor")){var h=c[e+"Grad"],l=Qb(h),
|
|
z=mb();if(l)h=l;else{h=z.appendChild(f.importNode(h,true));h.id=la()}c.setColor(e,"url(#"+h.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+h.id+")")}},Qb=function(e){var h=mb();h=$(h).find("linearGradient, radialGradient");for(var l=h.length,z=["r","cx","cy","fx","fy"];l--;){var v=h[l];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=v.getAttribute("x1")||e.getAttribute("y1")!=v.getAttribute("y1")||e.getAttribute("x2")!=v.getAttribute("x2")||
|
|
e.getAttribute("y2")!=v.getAttribute("y2"))continue}else{var G=$(e).attr(z),A=$(v).attr(z),u=false;$.each(z,function(N,m){if(G[m]!=A[m])u=true});if(u)continue}var F=e.getElementsByTagNameNS(b,"stop"),H=v.getElementsByTagNameNS(b,"stop");if(F.length==H.length){for(var D=F.length;D--;){var E=F[D],L=H[D];if(E.getAttribute("offset")!=L.getAttribute("offset")||E.getAttribute("stop-opacity")!=L.getAttribute("stop-opacity")||E.getAttribute("stop-color")!=L.getAttribute("stop-color"))break}if(D==-1)return v}}return null};
|
|
this.setPaint=function(e,h){var l=new $.jGraduate.Paint(h);this.setPaintOpacity(e,l.alpha/100,true);cb[e+"_paint"]=l;switch(l.type){case "solidColor":if(l.solidColor!="none"&&l.solidColor!="#none")this.setColor(e,"#"+l.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"]=l[l.type];Mb(e)}};this.getStrokeWidth=function(){return cb.stroke_width};this.setStrokeWidth=
|
|
function(e){if(e==0&&["line","path"].indexOf(Da)>=0)c.setStrokeWidth(1);else{cb.stroke_width=e;for(var h=[],l=J.length;l--;){var z=J[l];if(z)z.tagName=="g"?svgedit.utilities.walkTree(z,function(v){v.nodeName!="g"&&h.push(v)}):h.push(z)}if(h.length>0){eb("stroke-width",e,h);M("changed",J)}}};this.setStrokeAttr=function(e,h){P[e.replace("-","_")]=h;for(var l=[],z=J.length;z--;){var v=J[z];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(G){G.nodeName!="g"&&l.push(G)}):l.push(v)}if(l.length>
|
|
0){eb(e,h,l);M("changed",J)}};this.getStyle=function(){return P};this.getOpacity=function(){return P.opacity};this.setOpacity=function(e){P.opacity=e;eb("opacity",e)};this.getFillOpacity=function(){return P.fill_opacity};this.getStrokeOpacity=function(){return P.stroke_opacity};this.setPaintOpacity=function(e,h,l){P[e+"_opacity"]=h;l?Db(e+"-opacity",h):eb(e+"-opacity",h)};this.getBlur=function(e){var h=0;if(e)if(e.getAttribute("filter"))if(e=ra(e.id+"_blur"))h=e.firstChild.getAttribute("stdDeviation");
|
|
return h};(function(){function e(){var v=c.undoMgr.finishUndoableChange();h.addSubCommand(v);wa(h);l=h=null}var h=null,l=null,z=false;c.setBlurNoUndo=function(v){if(l)if(v===0){Db("filter","");z=true}else{var G=J[0];z&&Db("filter","url(#"+G.id+"_blur)");if(svgedit.browser.isWebkit()){G.removeAttribute("filter");G.setAttribute("filter","url(#"+G.id+"_blur)")}Db("stdDeviation",v,[l.firstChild]);c.setBlurOffsets(l,v)}else c.setBlur(v)};c.setBlurOffsets=function(v,G){if(G>3)na(v,{x:"-50%",y:"-50%",width:"200%",
|
|
height:"200%"},100);else if(!svgedit.browser.isWebkit()){v.removeAttribute("x");v.removeAttribute("y");v.removeAttribute("width");v.removeAttribute("height")}};c.setBlur=function(v,G){if(h)e();else{var A=J[0],u=A.id;l=ra(u+"_blur");v-=0;var F=new Ea;if(l){if(v===0)l=null}else{var H=R({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:v}});l=R({element:"filter",attr:{id:u+"_blur"}});l.appendChild(H);mb().appendChild(l);F.addSubCommand(new Fa(l))}H={filter:A.getAttribute("filter")};if(v===
|
|
0){A.removeAttribute("filter");F.addSubCommand(new Oa(A,H))}else{eb("filter","url(#"+u+"_blur)");F.addSubCommand(new Oa(A,H));c.setBlurOffsets(l,v);h=F;c.undoMgr.beginUndoableChange("stdDeviation",[l?l.firstChild:null]);if(G){c.setBlurNoUndo(v);e()}}}}})();this.getBold=function(){var e=J[0];if(e!=null&&e.tagName=="text"&&J[1]==null)return e.getAttribute("font-weight")=="bold";return false};this.setBold=function(e){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)eb("font-weight",e?"bold":"normal");
|
|
J[0].textContent||Ua.setCursor()};this.getItalic=function(){var e=J[0];if(e!=null&&e.tagName=="text"&&J[1]==null)return e.getAttribute("font-style")=="italic";return false};this.setItalic=function(e){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)eb("font-style",e?"italic":"normal");J[0].textContent||Ua.setCursor()};this.getFontFamily=function(){return $a.font_family};this.setFontFamily=function(e){$a.font_family=e;eb("font-family",e);J[0]&&!J[0].textContent&&Ua.setCursor()};this.setFontColor=
|
|
function(e){$a.fill=e;eb("fill",e)};this.getFontSize=function(){return $a.fill};this.getFontSize=function(){return $a.font_size};this.setFontSize=function(e){$a.font_size=e;eb("font-size",e);J[0].textContent||Ua.setCursor()};this.getText=function(){var e=J[0];if(e==null)return"";return e.textContent};this.setTextContent=function(e){eb("#text",e);Ua.init(e);Ua.setCursor()};this.setImageURL=function(e){var h=J[0];if(h){var l=$(h).attr(["width","height"]);l=!l.width||!l.height;var z=da(h);if(z!==e)l=
|
|
true;else if(!l)return;var v=new Ea("Change Image URL");X(h,e);v.addSubCommand(new Oa(h,{"#href":z}));l?$(new Image).load(function(){var G=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Ha.requestSelector(h).resize();v.addSubCommand(new Oa(h,G));wa(v);M("changed",[h])}).attr("src",e):wa(v)}};this.setLinkURL=function(e){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var l=da(h);if(l!==e){var z=new Ea("Change Link URL");X(h,e);
|
|
z.addSubCommand(new Oa(h,{"#href":l}));wa(z)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:J.every(function(h){return h&&J[0]?h.nodeName==J[0].nodeName:null})};this.setRectRadius=function(e){c.elementsAreSame(J)&&J[0].tagName=="rect"&&J.forEach(function(h){var l=h.getAttribute("rx");if(l!=e){h.setAttribute("rx",e);h.setAttribute("ry",e);wa(new Oa(h,{rx:l,ry:l},"Radius"));M("changed",[h])}})};this.makeHyperlink=function(e){c.groupSelectedElements("a",e)};this.removeHyperlink=
|
|
function(){c.ungroupSelectedElement()};this.setSegType=function(e){Ma.setSegType(e)};this.convertToPath=function(e,h){if(e==null)$.each(J,function(S,Q){Q&&c.convertToPath(Q)});else{if(!h)var l=new Ea("Convert element to Path");var z=h?{}:{fill:P.fill,"fill-opacity":P.fill_opacity,stroke:P.stroke,"stroke-width":P.stroke_width,"stroke-dasharray":P.stroke_dasharray,"stroke-linejoin":P.stroke_linejoin,"stroke-linecap":P.stroke_linecap,"stroke-opacity":P.stroke_opacity,opacity:P.opacity,visibility:"hidden"};
|
|
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var v=R({element:"path",attr:z}),G=e.getAttribute("transform");G&&v.setAttribute("transform",G);var A=e.id,u=e.parentNode;e.nextSibling?u.insertBefore(v,e):u.appendChild(v);var F="",H=function(S){$.each(S,function(Q,V){var aa=V[1];F+=V[0];for(var fa=0;fa<aa.length;fa+=2)F+=aa[fa]+","+aa[fa+1]+" "})},D=1.81;switch(e.tagName){case "ellipse":case "circle":var E=$(e).attr(["rx",
|
|
"ry","cx","cy"]),L=E.cx,N=E.cy,m=E.rx;E=E.ry;if(e.tagName=="circle")m=E=$(e).attr("r");H([["M",[L-m,N]],["C",[L-m,N-E/D,L-m/D,N-E,L,N-E]],["C",[L+m/D,N-E,L+m,N-E/D,L+m,N]],["C",[L+m,N+E/D,L+m/D,N+E,L,N+E]],["C",[L-m/D,N+E,L-m,N+E/D,L-m,N]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":E=$(e).attr(["x1","y1","x2","y2"]);F="M"+E.x1+","+E.y1+"L"+E.x2+","+E.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":E=$(e).attr(["rx","ry"]);m=E.rx;E=
|
|
E.ry;var w=e.getBBox();L=w.x;N=w.y;var C=w.width;w=w.height;D=4-D;!m&&!E?H([["M",[L,N]],["L",[L+C,N]],["L",[L+C,N+w]],["L",[L,N+w]],["L",[L,N]],["Z",[]]]):H([["M",[L,N+E]],["C",[L,N+E/D,L+m/D,N,L+m,N]],["L",[L+C-m,N]],["C",[L+C-m/D,N,L+C,N+E/D,L+C,N+E]],["L",[L+C,N+w-E]],["C",[L+C,N+w-E/D,L+C-m/D,N+w,L+C-m,N+w]],["L",[L+m,N+w]],["C",[L+m/D,N+w,L,N+w-E/D,L,N+w-E]],["L",[L,N+E]],["Z",[]]]);break;default:v.parentNode.removeChild(v)}F&&v.setAttribute("d",F);if(h){Ma.resetOrientation(v);l=false;try{l=
|
|
v.getBBox()}catch(I){}v.parentNode.removeChild(v);return l}else{if(G){G=W(v);oa(G)&&Ma.resetOrientation(v)}l.addSubCommand(new Ia(e,e.nextSibling,u));l.addSubCommand(new Fa(v));Sa();e.parentNode.removeChild(e);v.setAttribute("id",A);v.removeAttribute("visibility");ub([v],true);wa(l)}}};var Db=this.changeSelectedAttributeNoUndo=function(e,h,l){var z=d.suspendRedraw(1E3);Da=="pathedit"&&Ma.moveNode(e,h);l=l||J;for(var v=l.length,G=["g","polyline","path"];v--;){var A=l[v];if(A!=null){Da==="textedit"&&
|
|
e!=="#text"&&A.textContent.length&&Ua.toSelectMode(A);if((e==="x"||e==="y")&&G.indexOf(A.tagName)>=0){var u=getStrokedBBox([A]);c.moveSelectedElements((e==="x"?h-u.x:0)*o,(e==="y"?h-u.y:0)*o,true)}else{u=e==="#text"?A.textContent:A.getAttribute(e);if(u==null)u="";if(u!==String(h)){if(e=="#text"){svgedit.utilities.getBBox(A);A.textContent=h}else e=="#href"?X(A,h):A.setAttribute(e,h);J.indexOf(A)>=0&&setTimeout(function(){A.parentNode&&Ha.requestSelector(A).resize()},0);u=pa(A);if(u!=0&&e!="transform")for(var F=
|
|
W(A),H=F.numberOfItems;H--;)if(F.getItem(H).type==4){F.removeItem(H);var D=svgedit.utilities.getBBox(A),E=O(D.x+D.width/2,D.y+D.height/2,ga(F).matrix);D=E.x;E=E.y;var L=d.createSVGTransform();L.setRotate(u,D,E);F.insertItemBefore(L,H);break}}}}}d.unsuspendRedraw(z)},eb=this.changeSelectedAttribute=function(e,h,l){l=l||J;c.undoMgr.beginUndoableChange(e,l);Db(e,h,l);e=c.undoMgr.finishUndoableChange();e.isEmpty()||wa(e)};this.deleteSelectedElements=function(){for(var e=new Ea("Delete Elements"),h=J.length,
|
|
l=[],z=0;z<h;++z){var v=J[z];if(v==null)break;var G=v.parentNode,A=v;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);if(G.tagName==="a"&&G.childNodes.length===1){A=G;G=G.parentNode}var u=A.nextSibling;A=G.removeChild(A);l.push(v);J[z]=null;e.addSubCommand(new Ia(A,u,G))}e.isEmpty()||wa(e);M("changed",l);Sa()};this.cutSelectedElements=function(){for(var e=new Ea("Cut Elements"),h=J.length,l=[],z=0;z<h;++z){var v=J[z];if(v==null)break;var G=v.parentNode,A=v;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);
|
|
var u=A.nextSibling;A=G.removeChild(A);l.push(v);J[z]=null;e.addSubCommand(new Ia(A,u,G))}e.isEmpty()||wa(e);M("changed",l);Sa();c.clipBoard=l};this.copySelectedElements=function(){c.clipBoard=$.merge([],J)};this.pasteElements=function(){var e=c.clipBoard,h=e.length;if(h){for(var l=[],z=new Ea("Paste elements");h--;){var v=e[h];if(v){var G=ka(v);if(!ra(v.id))G.id=v.id;l.push(G);(K||B().getCurrentLayer()).appendChild(G);z.addSubCommand(new Fa(G))}}svgCanvas.clearSelection();setTimeout(function(){yb(l)},
|
|
100);wa(z);M("changed",l)}};this.groupSelectedElements=function(e){e||(e="g");var h="";switch(e){case "a":h="Make hyperlink";var l="";if(arguments.length>1)l=arguments[1];break;default:e="g";h="Group Elements"}h=new Ea(h);var z=R({element:e,attr:{id:la()}});e==="a"&&X(z,l);h.addSubCommand(new Fa(z));for(l=J.length;l--;){var v=J[l];if(v!=null){if(v.parentNode.tagName==="a"&&v.parentNode.childNodes.length===1)v=v.parentNode;var G=v.nextSibling,A=v.parentNode;z.appendChild(v);h.addSubCommand(new Ka(v,
|
|
G,A))}}h.isEmpty()||wa(h);yb([z],true)};var Gb=this.pushGroupProperties=function(e,h){var l=e.childNodes,z=l.length,v=e.getAttribute("transform"),G=W(e),A=ga(G).matrix,u=new Ea("Push group properties"),F=0,H=pa(e),D=$(e).attr(["filter","opacity"]),E,L;for(F=0;F<z;F++){var N=l[F];if(N.nodeType===1){if(D.opacity!==null&&D.opacity!==1){N.getAttribute("opacity");var m=Math.round((N.getAttribute("opacity")||1)*D.opacity*100)/100;eb("opacity",m,[N])}if(D.filter){var w=m=this.getBlur(N);L||(L=this.getBlur(e));
|
|
if(m)m=L-0+(m-0);else if(m===0)m=L;if(w)E=T(N.getAttribute("filter"));else if(E){E=ka(E);mb().appendChild(E)}else E=T(D.filter);E.id=N.id+"_"+(E.firstChild.tagName==="feGaussianBlur"?"blur":"filter");eb("filter","url(#"+E.id+")",[N]);if(m){eb("stdDeviation",m,[E.firstChild]);c.setBlurOffsets(E,m)}}m=W(N);if(~N.tagName.indexOf("Gradient"))m=null;if(m)if(N.tagName!=="defs")if(G.numberOfItems){if(H&&G.numberOfItems==1){var C=G.getItem(0).matrix,I=d.createSVGMatrix();if(w=pa(N))I=m.getItem(0).matrix;
|
|
var S=svgedit.utilities.getBBox(N),Q=ga(m).matrix,V=O(S.x+S.width/2,S.y+S.height/2,Q);S=H+w;Q=d.createSVGTransform();Q.setRotate(S,V.x,V.y);C=ha(C,I,Q.matrix.inverse());w&&m.removeItem(0);if(S)m.numberOfItems?m.insertItemBefore(Q,0):m.appendItem(Q);if(C.e||C.f){w=d.createSVGTransform();w.setTranslate(C.e,C.f);m.numberOfItems?m.insertItemBefore(w,0):m.appendItem(w)}}else{w=N.getAttribute("transform");C={};C.transform=w?w:"";w=d.createSVGTransform();C=ga(m).matrix;I=C.inverse();C=ha(I,A,C);w.setMatrix(C);
|
|
m.appendItem(w)}(N=Ra(N))&&u.addSubCommand(N)}}}if(v){C={};C.transform=v;e.setAttribute("transform","");e.removeAttribute("transform");u.addSubCommand(new Oa(e,C))}if(h&&!u.isEmpty())return u};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Rb(e);else if(e.tagName==="use"){var h=ra(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Rb(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new Ea("Ungroup Elements");var l=
|
|
Gb(e,true);l&&h.addSubCommand(l);l=e.parentNode;for(var z=e.nextSibling,v=Array(e.childNodes.length),G=0;e.firstChild;){var A=e.firstChild,u=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ia(A,A.nextSibling,F));F.removeChild(A)}else{v[G++]=A=l.insertBefore(A,z);h.addSubCommand(new Ka(A,u,F))}}Sa();z=e.nextSibling;e=l.removeChild(e);h.addSubCommand(new Ia(e,z,l));h.isEmpty()||wa(h);ub(v)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
|
|
l=e.nextSibling;e=e.parentNode.appendChild(e);if(l!=e.nextSibling){wa(new Ka(e,l,h,"top"));M("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,l=e.nextSibling,z=e.parentNode.firstChild;if(z.tagName=="title")z=z.nextSibling;if(z.tagName=="defs")z=z.nextSibling;e=e.parentNode.insertBefore(e,z);if(l!=e.nextSibling){wa(new Ka(e,l,h,"bottom"));M("changed",[e])}}};this.moveUpDownSelected=function(e){var h=J[0];if(h){lb=[];var l,z,v=$(qb(getStrokedBBox([h]))).toArray();
|
|
e=="Down"&&v.reverse();$.each(v,function(){if(z){l=this;return false}else if(this==h)z=true});if(l){v=h.parentNode;var G=h.nextSibling;$(l)[e=="Down"?"before":"after"](h);if(G!=h.nextSibling){wa(new Ka(h,G,v,"Move "+e));M("changed",[h])}}}};this.moveSelectedElements=function(e,h,l){if(e.constructor!=Array){e/=o;h/=o}l=l||true;for(var z=new Ea("position"),v=J.length;v--;){var G=J[v];if(G!=null){var A=d.createSVGTransform(),u=W(G);e.constructor==Array?A.setTranslate(e[v],h[v]):A.setTranslate(e,h);u.numberOfItems?
|
|
u.insertItemBefore(A,0):u.appendItem(A);(A=Ra(G))&&z.addSubCommand(A);Ha.requestSelector(G).resize()}}if(!z.isEmpty()){l&&wa(z);M("changed",J);return z}};this.cloneSelectedElements=function(e,h,l){for(var z=new Ea("Clone Elements"),v=J.length,G=0;G<v;++G)if(J[G]==null)break;v=J.slice(0,G);this.clearSelection(true);G=v.length;for(clones=[];G--;){var A=ka(v[G]);if(l){tlist=W(A);tlist.removeItem(l);Ra(A)}(K||B().getCurrentLayer()).appendChild(A);clones.push(A);z.addSubCommand(new Fa(A))}if(!z.isEmpty()){ub(v.reverse());
|
|
l||this.moveSelectedElements(e,h,false);wa(z)}return clones};this.alignSelectedElements=function(e,h){var l=[],z=Number.MAX_VALUE,v=Number.MIN_VALUE,G=Number.MAX_VALUE,A=Number.MIN_VALUE,u=Number.MIN_VALUE,F=Number.MIN_VALUE,H=J.length;if(H){for(var D=0;D<H;++D){if(J[D]==null)break;l[D]=getStrokedBBox([J[D]]);switch(h){case "smallest":if((e=="l"||e=="c"||e=="r")&&(u==Number.MIN_VALUE||u>l[D].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F>l[D].height)){z=l[D].x;G=l[D].y;v=l[D].x+l[D].width;
|
|
A=l[D].y+l[D].height;u=l[D].width;F=l[D].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(u==Number.MIN_VALUE||u<l[D].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F<l[D].height)){z=l[D].x;G=l[D].y;v=l[D].x+l[D].width;A=l[D].y+l[D].height;u=l[D].width;F=l[D].height}break;default:if(l[D].x<z)z=l[D].x;if(l[D].y<G)G=l[D].y;if(l[D].x+l[D].width>v)v=l[D].x+l[D].width;if(l[D].y+l[D].height>A)A=l[D].y+l[D].height}}if(h=="page"){G=z=0;v=c.contentW;A=c.contentH}u=Array(H);F=Array(H);for(D=
|
|
0;D<H;++D){if(J[D]==null)break;var E=l[D];u[D]=0;F[D]=0;switch(e){case "l":u[D]=z-E.x;break;case "c":u[D]=(z+v)/2-(E.x+E.width/2);break;case "r":u[D]=v-(E.x+E.width);break;case "t":F[D]=G-E.y;break;case "m":F[D]=(G+A)/2-(E.y+E.height/2);break;case "b":F[D]=A-(E.y+E.height)}}this.moveSelectedElements(u,F)}};this.contentW=Eb().w;this.contentH=Eb().h;this.updateCanvas=function(e,h){d.setAttribute("width",e);d.setAttribute("height",h);var l=$("#canvasBackground")[0],z=k.getAttribute("x"),v=k.getAttribute("y"),
|
|
G=e/2-this.contentW*o/2,A=h/2-this.contentH*o/2;na(k,{width:this.contentW*o,height:this.contentH*o,x:G,y:A,viewBox:"0 0 "+this.contentW+" "+this.contentH});na(l,{width:k.getAttribute("width"),height:k.getAttribute("height"),x:G,y:A});(l=ra("background_image"))&&na(l,{width:"100%",height:"100%"});Ha.selectorParentGroup.setAttribute("transform","translate("+G+","+A+")");return{x:G,y:A,old_x:z,old_y:v,d_x:G-z,d_y:A-v}};this.setBackground=function(e,h){var l=ra("canvasBackground"),z=$(l).find("rect")[0],
|
|
v=ra("background_image");z.setAttribute("fill",e);if(h){if(!v){v=f.createElementNS(b,"image");na(v,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}X(v,h);l.appendChild(v)}else v&&v.parentNode.removeChild(v)};this.cycleElement=function(e){var h=J[0],l=false,z=tb(K||B().getCurrentLayer());if(z.length){if(h==null){e=e?z.length-1:0;l=z[e]}else for(var v=z.length;v--;)if(z[v]==h){e=e?v-1:v+1;if(e>=z.length)e=0;else if(e<0)e=z.length-1;l=z[e];
|
|
break}yb([l],true);M("selected",J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:wa,setGradient:Mb,addSvgElementFromJson:R,assignAttributes:na,BatchCommand:Ea,call:M,ChangeElementCommand:Oa,copyElem:ka,ffClone:ea,findDefs:mb,findDuplicateGradient:Qb,getElem:ra,getId:ca,getIntersectionList:qb,getMouseTarget:Kb,getNextId:la,getPathBBox:Z,getUrlFromAttr:ja,hasMatrixTransform:oa,identifyLayers:vb,InsertElementCommand:Fa,isIdentity:svgedit.math.isIdentity,logMatrix:Za,matrixMultiply:ha,
|
|
MoveElementCommand:Ka,preventClickDefault:Jb,recalculateAllSelectedDimensions:Ga,recalculateDimensions:Ra,remapElement:gb,RemoveElementCommand:Ia,removeUnusedDefElems:Ob,round:hb,runExtensions:ob,sanitizeSvg:Ja,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:ga,transformPoint:O,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,k){var q=g.setSvgString(d)!==false;k=k||a.noop;q?k(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){k(false)})}var g,b={},n=false;curConfig={canvas_expansion:1,dimensions:[580,400],
|
|
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",
|
|
key_down:"Down",key_backspace:"Backspace",key_del:"Del"},layers:{layer:"Layer"},notification:{invalidAttrValGiven:"Invalid value given",noContentToFitTo:"No content to fit to",dupeLayerName:"There is already a layer named that!",enterUniqueLayerName:"Please enter a unique layer name",enterNewLayerName:"Please enter the new layer name",layerHasThatName:"Layer already has that name",QmoveElemsToLayer:'Move selected elements to layer "%s"?',QwantToClear:"Do you want to clear the drawing?\nThis will also erase your undo history!",
|
|
QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo history!",QerrorsRevertToSource:"There were parsing errors in your SVG source.\nRevert back to original SVG source?",QignoreSourceChanges:"Ignore changes made to SVG source?",featNotSupported:"Feature not supported",enterNewImgURL:"Enter the new image URL",defsFailOnSave:"NOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.",loadingImage:"Loading image, please wait...",
|
|
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};var s={},c={};b.curConfig=curConfig;b.tool_scale=1;b.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
|
|
b.setCustomHandlers=function(d){b.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){b.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);c=d})};b.randomizeIds=function(){g.randomizeIds(arguments)};b.init=function(){function d(m,w){var C=m.id,I=C.split("_"),S=I[0];I=I[1];w&&g.setStrokeAttr("stroke-"+S,I);Ab();eb("#cur_"+S,C,20);a(m).addClass("current").siblings().removeClass("current")}function k(m,
|
|
w){var C=document.getElementById("ruler_x_cursor"),I=document.getElementById("ruler_y_cursor"),S=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Tb){Tb.stopPropagation();C.style.left=Tb.pageX-66+S.scrollLeft+"px";I.style.top=Tb.pageY-48+S.scrollTop+"px"});w||(w=g.getZoom());m||(m=a("#svgcanvas"));for(var Q=g.getContentElem(),V=svgedit.units.getTypeMap()[curConfig.baseUnit],
|
|
aa=0;aa<2;aa++){var fa=aa===0,qa=fa?"x":"y",sa=fa?"width":"height",ab=Q.getAttribute(qa)-0;qa=a("#ruler_"+qa+" canvas:first");$hcanv=qa.clone();qa.replaceWith($hcanv);var Aa=$hcanv[0];var ia=qa=m[sa]()*2;Aa.parentNode.style[sa]=ia+"px";var fb=0,Ta,va=Aa.getContext("2d");va.fillStyle="rgb(200,0,0)";va.fillRect(0,0,Aa.width,Aa.height);$hcanv.siblings().remove();if(qa>=3E4){var Na=parseInt(qa/3E4)+1;Ta=Array(Na);Ta[0]=va;for(var ya=1;ya<Na;ya++){Aa[sa]=3E4;var bb=Aa.cloneNode(true);Aa.parentNode.appendChild(bb);
|
|
Ta[ya]=bb.getContext("2d")}bb[sa]=qa%3E4;qa=3E4}Aa[sa]=qa;sa=V*w;var Xa=50/sa;Aa=1;for(ya=0;ya<D.length;ya++){Aa=Na=D[ya];if(Xa<=Na)break}Xa=Aa*sa;va.font="normal 9px 'Lucida Grande', sans-serif";va.fillStyle="#777";for(var db=ab/sa%Aa*sa,Ib=db-Xa;db<ia;db+=Xa){Ib+=Xa;ya=Math.round(db)+0.5;if(fa){va.moveTo(ya,15);va.lineTo(ya,0)}else{va.moveTo(15,ya);va.lineTo(0,ya)}Na=(Ib-ab)/sa;if(Aa>=1)ya=Math.round(Na);else{ya=(Aa+"").split(".")[1].length;ya=Na.toFixed(ya)-0}if(ya!==0&&ya!==1E3&&ya%1E3===0)ya=
|
|
ya/1E3+"K";if(fa){va.fillText(ya,db+2,8);va.fillStyle="#777"}else{Na=(ya+"").split("");for(ya=0;ya<Na.length;ya++){va.fillText(Na[ya],1,db+9+ya*9);va.fillStyle="#777"}}Na=Xa/10;for(ya=1;ya<10;ya++){var zb=Math.round(db+Na*ya)+0.5;if(Ta&&zb>qa){fb++;va.stroke();if(fb>=Ta.length){ya=10;db=ia;continue}va=Ta[fb];db-=3E4;zb=Math.round(db+Na*ya)+0.5}var Fb=ya%2?12:10;if(fa){va.moveTo(zb,15);va.lineTo(zb,Fb)}else{va.moveTo(15,zb);va.lineTo(Fb,zb)}}}va.strokeStyle="#666";va.stroke()}}(function(){var m=window.opener;
|
|
if(m)try{var w=m.document.createEvent("Event");w.initEvent("svgEditorReady",true,true);m.document.documentElement.dispatchEvent(w)}catch(C){}})();(function(){a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);a("body").toggleClass("touch",svgedit.browser.isTouch());var m=a.deparam.querystring(true);if(!a.isEmptyObject(m)){if(m.dimensions)m.dimensions=m.dimensions.split(",");if(m.extensions)m.extensions=m.extensions.split(",");if(m.bkgd_color)m.bkgd_color=
|
|
"#"+m.bkgd_color;svgEditor.setConfig(m);var w=m.source,C=a.param.querystring();if(!w)if(C.indexOf("source=data:")>=0)w=C.match(/source=(data:[^&]*)/)[1];if(w)if(w.indexOf("data:")===0){w=w.replace(/ /g,"+");b.loadFromDataURI(w)}else b.loadFromString(w);else if(C.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(C.substr(9));else m.url&&svgEditor.loadFromURL(m.url)}})();var q=function(){a.each(curConfig.extensions,function(){var m=this;a.getScript(curConfig.extPath+m,function(w){if(!w){w=document.createElement("script");
|
|
w.src=curConfig.extPath+m;document.querySelector("head").appendChild(w)}})})};document.location.protocol==="file:"?setTimeout(q,100):q();a.svgIcons(curConfig.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:!svgedit.browser.isWebkit(),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 m=a("#tools_left");if(m.length!=0){m.offset();m.outerHeight()}a(".tools_flyout").each(function(){var w=a("#"+this.id+"_show"),C=w.attr("data-curopt");if(!w.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");w.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},1)}});a("#rulers").on("dblclick",function(m){a("#base_unit_container").css({top:m.pageY-
|
|
10,left:m.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});b.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=
|
|
0,o=q?"meta+":"ctrl+",K=g.pathActions,U=g.undoMgr,P=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",R=a("#workarea"),W=a("#cmenu_canvas"),O=null,ha=1,oa="toolbars",ga="";q||a(".shortcut").each(function(){var m=a(this).text();a(this).text(m.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var m=a("#dialog_box"),w=a("#dialog_buttons"),C=function(I,S,Q,V){a("#dialog_content").html("<p>"+S.replace(/\n/g,
|
|
"</p><p>")+"</p>").toggleClass("prompt",I=="prompt");w.empty();var aa=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(w);I!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(w).on("click, touchstart",function(){m.hide();Q(false)});if(I=="prompt"){var fa=a('<input type="text">').prependTo(w);fa.val(V||"");fa.bind("keydown","return",function(){aa.trigger("click touchstart")})}I=="process"&&aa.hide();m.show();aa.on("click touchstart",function(){m.hide();
|
|
var qa=I=="prompt"?fa.val():true;Q&&Q(qa)}).focus();I=="prompt"&&fa.focus()};a.alert=function(I,S){C("alert",I,S)};a.confirm=function(I,S){C("confirm",I,S)};a.process_cancel=function(I,S){C("process",I,S)};a.prompt=function(I,S,Q){C("prompt",I,Q,S)}})();var ba=function(){var m=a(".tool_button_current");if(m.length&&m[0].id!=="tool_select"){m.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},
|
|
Y=null,ta=false,ja=false,da="",X=function(m,w){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";if(!C){Y=w.length==1||w[1]==null?w[0]:null;w=w.filter(Boolean);ta=w.length>=2?w:false;if(g.elementsAreSame(ta))Y=ta[0];if(Y!=null){if(!C){a("#multiselected_panel").hide();if(Y!=null)switch(Y.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var I=null,S=Y.getElementsByTagName("*"),Q=0,V=S.length;Q<V;Q++){var aa=S[Q].getAttribute("stroke-width");if(Q===0)I=aa;else if(I!==
|
|
aa)I=null}a("#stroke_width").val(I===null?"":I);break;default:a("#stroke_width").val(Y.getAttribute("stroke-width")||1);I=Y.getAttribute("stroke-dasharray")||"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+I+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);I=Y.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+I).length!=0&&d(a("#linejoin_"+I)[0]);I=Y.getAttribute("stroke-linecap")||
|
|
"butt";a("#linecap_"+I).length!=0&&d(a("#linecap_"+I)[0])}if(Y!=null){I=(Y.getAttribute("opacity")||1)*100;a("#group_opacity").val(I);a.fn.dragInput.updateCursor(a("#group_opacity")[0])}}ta.length&&a("#tools_top").addClass("multiselected")}else if(ta.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")}}I=w;a("#tools_bottom_2,#tools_bottom_3").toggle(!C);
|
|
if(C){a(".context_panel").hide();a("#path_node_panel").show();a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");eb("#tool_select","select_node");ta=false}else{if(I[0]){C=g.selectorManager.requestSelector(I[0]);C.reset(I[0]);C.selectorRect.setAttribute("display","inline")}eb("#tool_select","select")}g.runExtensions("selectedChanged",{elems:w,selectedElement:Y,multiselected:ta})},Z=function(m,
|
|
w){var C=g.getResolution();a("#svgcanvas").position();var I=g.setBBoxZoom(w,R.width()-15,R.height()-15);if(I){var S=I.zoom;I=I.bbox;if(S<0.0010)nb({value:0.1});else{var Q=Date.now(),V=S-C.zoom;a("#zoom");var aa=C.zoom,fa=function(qa){qa=(qa-Q)/500;qa=Math.pow(qa-1,3)+1;g.setZoom(aa+V*qa);H();if(qa<1)requestAnimationFrame(fa);else{a("#zoom").val(S*100);a("option","#zoom_select").removeAttr("selected");a("option[value="+S*100+"]","#zoom_select").attr("selected","selected")}};fa(Date.now());g.getMode()==
|
|
"zoom"&&I.width&&ba();Mb()}}};a("#cur_context_panel").delegate("a","click",function(){var m=a(this);m.attr("data-root")?g.leaveContext():g.setContext(m.text());return false});var pa=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},ra={},na=function(m){a.each(m,function(w,C){var I=a(w).children(),S=w+"_show",Q=a(S),V=false;I.addClass("tool_button").unbind("click mousedown mouseup").each(function(qa){var sa=C[qa];ra[sa.sel]=sa.fn;if(sa.isDefault)V=qa;qa=function(ab){var Aa=sa;if(ab.type===
|
|
"keydown"){var ia=a(Aa.parent+"_show").hasClass("tool_button_current"),fb=a(Aa.parent+"_show").attr("data-curopt");a.each(m[sa.parent],function(va,Na){if(Na.sel==fb)Aa=!ab.shiftKey||!ia?Na:m[sa.parent][va+1]||m[sa.parent][0]})}if(a(this).hasClass("disabled"))return false;Qa(S)&&Aa.fn();var Ta=Aa.icon?a.getSvgIcon(Aa.icon,true):a(Aa.sel).children().eq(0).clone();Ta[0].setAttribute("width",Q.width());Ta[0].setAttribute("height",Q.height());Q.children(":not(.flyout_arrow_horiz)").remove();Q.append(Ta).attr("data-curopt",
|
|
Aa.sel)};a(this).mouseup(qa);sa.key&&a(document).bind("keydown",sa.key[0]+" shift+"+sa.key[0],qa)});if(V)Q.attr("data-curopt",C[V].sel);else Q.attr("data-curopt")||Q.attr("data-curopt",C[0].sel);var aa,fa=a(S).position();a(w).css({left:fa.left+34,top:fa.top+77});Q.mousedown(function(qa){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&Qa(S,false);if(Q.hasClass("disabled"))return false;var sa=a(w),ab=fa.left+34,Aa=sa.width()*-1,ia=sa.data("shown_popop")?
|
|
200:0;aa=setTimeout(function(){Q.data("isLibrary")?sa.css("left",ab).show():sa.css("left",Aa).show().animate({left:ab},50);sa.data("shown_popop",true)},ia);qa.preventDefault()}).mouseup(function(){clearTimeout(aa);var qa=a(this).attr("data-curopt");if(Q.data("isLibrary")&&a(S.replace("_show","")).is(":visible"))Qa(S,true);else Qa(S)&&qa in ra&&ra[qa]()})});Ja()},ma=function(m,w){return a("<div>",{"class":"tools_flyout",id:m}).appendTo("#svg_editor").append(w)},Ca=function(){a(".tools_flyout").each(function(){var m=
|
|
a("#"+this.id+"_show"),w=m.offset();m=m.outerWidth();a(this).css({left:(w.left+m)*ha,top:w.top})})},Ja=function(){a(".tools_flyout").each(function(){var m=a("#"+this.id+"_show");if(!m.data("isLibrary")){var w=[];a(this).children().each(function(){w.push(this.title)});m[0].title=w.join(" / ")}})},Ka,Fa=function(m,w,C){var I=null;if(m.indexOf("url(#")===0){m=(m=g.getRefElem(m))?m.cloneNode(true):a("#"+C+"_color defs *")[0];I={alpha:w};I[m.tagName]=m}else I=m.indexOf("#")===0?{alpha:w,solidColor:m.substr(1)}:
|
|
{alpha:w,solidColor:"none"};return new a.jGraduate.Paint(I)},Ia=g.getResolution();if(curConfig.baseUnit!=="px"){Ia.w=svgedit.units.convertUnit(Ia.w)+curConfig.baseUnit;Ia.h=svgedit.units.convertUnit(Ia.h)+curConfig.baseUnit}var Oa=function(m){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ia.w+2,height:Ia.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:m||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};
|
|
document.getElementById("canvas_background")||Oa();document.getElementById("canvas_background").getAttribute("fill");var Ea=b.setImageURL=function(m){m||(m=J);g.setImageURL(m);a("#image_url").val(m)},wa=function(){var m=Y;if(m!=null&&!m.parentNode)m=null;if(ta&&ta[0]!=null&&!ta[0].parentNode)ta=false;var w=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),I=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,S=C=="pathedit",Q=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");
|
|
a(".menu_item","#object_menu").addClass("disabled");if(ta){ta=ta.filter(Boolean);(m=g.elementsAreSame(ta)?ta[0]:null)&&a("#tools_top").addClass("multiselected")}if(!m&&!ta){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(m!=null){a("#stroke_panel").show();var V=m.nodeName,aa=g.getRotationAngle(m);a("#angle").val(Math.round(aa));aa=g.getBlur(m);a("#blur").val(aa);if(!S&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");
|
|
var fa,qa;if(["g","polyline","path"].indexOf(V)>=0)if(C=g.getStrokedBBox([m])){fa=C.x;qa=C.y}if(I){fa=svgedit.units.convertUnit(fa);qa=svgedit.units.convertUnit(qa)}a("#"+V+"_x").val(Math.round(fa));a("#"+V+"_y").val(Math.round(qa));if(V==="polyline"){a("#path_x").val(Math.round(fa));a("#path_y").val(Math.round(qa))}["image","text","path","g","use"].indexOf(V)==-1&&a(".action_path_convert_selected").removeClass("disabled");V==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();
|
|
a("#stroke_panel").hide();w=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);eb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(w){S=a("#seg_type");if(I){w.x=svgedit.units.convertUnit(w.x);w.y=svgedit.units.convertUnit(w.y)}a("#path_node_x").val(Math.round(w.x));a("#path_node_y").val(Math.round(w.y));w.type?S.val(w.type).removeAttr("disabled"):S.val(4).attr("disabled",
|
|
"disabled")}return}I=null;if(sa==="a"){I=g.getHref(m);a("#g_panel").show()}if(m.parentNode.tagName==="a")if(!a(m).siblings().length){a("#a_panel").show();I=g.getHref(m.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!I);I&&a("#link_url").val(I);I={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 sa=m.tagName;a(m).data("gsvg")&&a("#g_panel").show();
|
|
if(sa=="path"||sa=="polyline")a("#path_panel").show();if(I[sa]){I=I[sa];a("#"+sa+"_panel").show();sa=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(I,function(ab,Aa){var ia=m.getAttribute(Aa);if(curConfig.baseUnit!=="px"&&m[Aa])ia=svgedit.units.convertUnit(m[Aa].baseVal.value);var fb=document.getElementById(sa+"_"+Aa);fb.value=Math.round(ia)||0;fb.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(fb)});if(sa=="text"){I=m.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=
|
|
3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active",g.getBold());a("#font_family").val(I);a("#font_size").val(m.getAttribute("font-size"));a("#text").val(m.textContent);a("#preview_font").text(I.split(",")[0].replace(/'/g,"")).css("font-family",I);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(sa=="image")Ea(g.getHref(m));else if(sa==="g"||sa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");
|
|
g.getTitle()}}Q[(sa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");Q[(sa==="g"||!ta?"dis":"en")+"ableContextMenuItems"]("#group")}if(ta){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");Q.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}m||Q.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");U.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");
|
|
U.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(m&&!S||ta){a("#selLayerNames").removeAttr("disabled").val(w);W.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",X);g.bind("transition",function(m,w){var C=g.getMode(),I=w[0];if(I){ta=w.length>=2&&w[1]!=null?w:null;if(!ta)switch(C){case "rotate":C=g.getRotationAngle(I);
|
|
a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",{elems:w})}});g.bind("changed",function(m,w){var C=g.getMode();C==="select"&&ba();for(var I=0;I<w.length;++I){var S=w[I];if(S&&S.tagName==="svg")H();else if(S&&Y&&Y.parentNode==null)Y=S}b.show_save_warning=true;wa();if(Y&&C==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:w})});g.bind("saved",function(m,w){b.show_save_warning=
|
|
false;w='<?xml version="1.0"?>\n'+w;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var I=m.open("data:image/svg+xml;base64,"+P.encode64(w)),S=a.pref("save_notice_done");if(S!=="all"){var Q=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(w.indexOf("<defs")!==-1){Q+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");S="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done",
|
|
"all");S!=="part"&&I.alert(Q)}}});g.bind("exported",function(m,w){var C=w.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var I=a("#export_canvas")[0];I.width=g.contentW;I.height=g.contentH;canvg(I,w.svg,{renderCallback:function(){var S=I.toDataURL("image/png");O.location.href=S;if(a.pref("export_notice_done")!=="all"){S=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)S+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+
|
|
C.join("\n \u2022 ");a.pref("export_notice_done","all");O.alert(S)}}})});g.bind("zoomed",Z);g.bind("contextset",function(m,w){var C="";if(w){var I="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(w).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){I+=" > "+this.id;C+=this!==w?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=I}else da=null;a("#cur_context_panel").toggle(!!w).html(C)});g.bind("extension_added",function(m,w){function C(){if(Ka){clearTimeout(Ka);
|
|
Ka=null}S||(Ka=setTimeout(function(){S=true;h(s.iconsize)},50))}var I=false,S=false,Q=true,V=function(){if(w.callback&&!I&&Q){I=true;w.callback()}},aa=[];w.context_tools&&a.each(w.context_tools,function(Aa,ia){var fb=ia.container_id?' id="'+ia.container_id+'"':"",Ta=a("#"+ia.panel);Ta.length||(Ta=a("<div>",{id:ia.panel}).appendTo("#tools_top").hide());switch(ia.type){case "tool_button":var va='<div class="tool_button">'+ia.id+"</div>",Na=a(va).appendTo(Ta);ia.events&&a.each(ia.events,function(Xa,
|
|
db){a(Na).bind(Xa,db)});break;case "select":va="<label"+fb+'><select id="'+ia.id+'">';a.each(ia.options,function(Xa,db){va+='<option value="'+Xa+'"'+(Xa==ia.defval?" selected":"")+">"+db+"</option>"});va+="</select></label>";var ya=a(va).appendTo(Ta).find("select");a.each(ia.events,function(Xa,db){a(ya).bind(Xa,db)});break;case "button-select":va='<div id="'+ia.id+'" class="dropdown toolset" title="'+ia.title+'"><div id="cur_'+ia.id+'" class="icon_label"></div><button></button></div>';fb=a('<ul id="'+
|
|
ia.id+'_opts"></ul>').appendTo("#option_lists");ia.colnum&&fb.addClass("optcols"+ia.colnum);a(va).appendTo(Ta).children();aa.push({elem:"#"+ia.id,list:"#"+ia.id+"_opts",title:ia.title,callback:ia.events.change,cur:"#cur_"+ia.id});break;case "input":va="<label"+fb+'><span id="'+ia.id+'_label">'+ia.label+':</span><input id="'+ia.id+'" title="'+ia.title+'" size="'+(ia.size||"4")+'" value="'+(ia.defval||"")+'" type="text"/></label>';var bb=a(va).appendTo(Ta).find("input");ia.spindata&&bb.SpinButton(ia.spindata);
|
|
ia.events&&a.each(ia.events,function(Xa,db){bb.bind(Xa,db)})}});if(w.buttons){var fa={},qa={},sa=w.svgicons,ab={};a.each(w.buttons,function(Aa,ia){for(var fb,Ta=ia.id,va=Aa;a("#"+Ta).length;)Ta=ia.id+"_"+ ++va;if(sa){fa[Ta]=ia.icon;va=ia.svgicon?ia.svgicon:ia.id;if(ia.type=="app_menu")qa["#"+Ta+" > div"]=va;else qa["#"+Ta]=va}else fb=ia.type=="menu"?"":a('<img src="'+ia.icon+'">');var Na,ya;switch(ia.type){case "mode_flyout":case "mode":Na="tool_button";if(ia.cls)Na+=" "+ia.cls;ya="#tools_left";break;
|
|
case "context":Na="tool_button";ya="#"+ia.panel;a(ya).length||a("<div>",{id:ia.panel}).appendTo("#tools_top");break;case "menu":Na="menu_item tool_button";ya="#"+(ia.after||ia.panel);break;case "app_menu":Na="";ya=ia.parent||"#main_menu ul";a(ya).length||a("<div>",{id:ia.panel}).appendTo("#tools_top")}var bb=a(ia.list||ia.type=="app_menu"?"<li/>":"<div/>").attr("id",Ta).attr("title",ia.title).addClass(Na);if(!ia.includeWith&&!ia.list){if("position"in ia)a(ya).children().eq(ia.position).before(bb);
|
|
else ia.type!="menu"||!ia.after?bb.appendTo(ya):a(ya).after(bb);if(ia.type=="mode_flyout"){va=a(bb);Na=va.parent();if(!va.parent().hasClass("tools_flyout")){var Xa=va[0].id.replace("tool_","tools_"),db=va.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));va.before(db);Na=ma(Xa,va);Na.data("isLibrary",true);db.data("isLibrary",true)}qa["#"+Xa+"_show"]=ia.id;Ta=ab["#"+Na[0].id]=[{sel:"#"+Ta,fn:ia.events.click,icon:ia.id,isDefault:true},Ib]}else if(ia.type=="app_menu"||
|
|
ia.type=="menu")bb.append(ia.title)}else if(ia.list){bb.addClass("push_button");a("#"+ia.list+"_opts").append(bb);if(ia.isDefault){a("#cur_"+ia.list).append(bb.children().clone());va=ia.svgicon?ia.svgicon:ia.id;qa["#cur_"+ia.list]=va}}else if(ia.includeWith){ya=ia.includeWith;va=a(ya.button);Na=va.parent();if(!va.parent().hasClass("tools_flyout")){Xa=va[0].id.replace("tool_","tools_");db=va.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));va.before(db);Na=ma(Xa,va)}var Ib=
|
|
F.getButtonData(ya.button);if(ya.isDefault)qa["#"+Xa+"_show"]=ia.id;Ta=ab["#"+Na[0].id]=[{sel:"#"+Ta,fn:ia.events.click,icon:ia.id,key:ia.key,isDefault:ia.includeWith?ia.includeWith.isDefault:0},Ib];Xa="position"in ya?ya.position:"last";Ib=Na.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Ib)Na.children().eq(Xa).before(bb);else{Na.append(bb);Ta.reverse()}}sa||bb.append(fb);ia.list||a.each(ia.events,function(zb,Fb){if(zb=="click")if(ia.type=="mode"){ia.includeWith?bb.bind(zb,Fb):bb.bind(zb,function(){Qa(bb)&&
|
|
Fb()});if(ia.key){a(document).bind("keydown",ia.key,Fb);ia.title&&bb.attr("title",ia.title+" ["+ia.key+"]")}}else bb.bind(zb,Fb);else bb.bind(zb,Fb)});na(ab)});a.each(aa,function(){xa(this.elem,this.list,this.callback,{seticon:true})});if(sa)Q=false;a.svgIcons(sa,{w:27,h:27,id_match:false,no_img:!B,fallback:fa,placement:qa,callback:function(){s.iconsize&&s.iconsize!="m"&&C();Q=true;V()}})}V()});g.textActions.setInputElem(a("#text")[0]);var Ha='<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(m,w){Ha+='<div class="palette_item" style="background-color: '+w+';" data-rgb="'+w+'"></div>'});a("#palette").append(Ha);var za=a("#tool_angle_indicator");
|
|
a("#tool_reorient");rotateCursor=function(m){m="rotate("+m+"deg)";za.css({"-webkit-transform":m,"-moz-transform":m,"-o-transform":m,"-ms-transform":m,transform:m})};var nb=function(m){var w=m.value/100;if(w<0.0010)m.value=0.1;else{m=g.getZoom();Z(window,{width:0,height:0,x:(R[0].scrollLeft+R.width()/2)/m,y:(R[0].scrollTop+R.height()/2)/m,zoom:w},true)}},Ab=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());
|
|
a("#stroke_style_label").html(this.options[this.selectedIndex].text);Ab()});a("#seg_type").change(function(){g.setSegType(a(this).val());a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(m){var w=m.getAttribute("data-attr"),C=m.getAttribute("data-multiplier")||1;C=parseFloat(C);C=m.value*
|
|
C;if(!svgedit.units.isValidUnit(w,C,Y)){a.alert(uiStrings.notification.invalidAttrValGiven);m.value=Y.getAttribute(w);return false}g.changeSelectedAttributeNoUndo(w,C)};a("#palette").mouseover(function(){var m=a('<input type="hidden">');a(this).append(m);m.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var m=a("#tool_stroke").hasClass("active"),w=m?"stroke":"fill",C=a(this).attr("data-rgb"),I=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";I=new a.jGraduate.Paint}else I=
|
|
new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});b.paintBox[w].setPaint(I);if(m){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(m){m.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");v()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");
|
|
v()});var Qa=function(m,w){if(a(m).hasClass("disabled"))return false;if(a(m).parent().hasClass("tools_flyout"))return true;var C=C||"normal";w||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(m).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var m=null,w=null,C=R[0],I=false,S=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(Q){if(I!==false){C.scrollLeft-=
|
|
Q.clientX-m;C.scrollTop-=Q.clientY-w;m=Q.clientX;w=Q.clientY;if(Q.type==="mouseup"||Q.type==="touchend")I=false;return false}}).on("mousedown touchmove",function(Q){if(Q.button===1||S===true||Q.originalEvent.touches&&Q.originalEvent.touches.length>=2){I=true;m=Q.clientX;w=Q.clientY;return false}});a(window).mouseup(function(){I=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(Q){Q.preventDefault();g.spaceKey=S=true}).bind("keyup","space",function(Q){Q.preventDefault();
|
|
g.spaceKey=S=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&R.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&R.removeClass("out")})})();var Wa=a(".menu"),Ya=function(m){m.target.style.background="#fff";setTimeout(function(){m.target.style.background="#ddd"},50);setTimeout(function(){m.target.style.background="#fff"},150);setTimeout(function(){m.target.style.background="#ddd"},200);setTimeout(function(){m.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},
|
|
220);return false};a(".menu_item").on("mousedown touchstart",function(m){Ya(m)});a("svg, body").on("mousedown touchstart",function(m){if(m.target.nodeName.toLowerCase()!=="input")if(!a(m.target).hasClass("menu_title")&&!a(m.target).parent().hasClass("menu_title"))!a(m.target).hasClass("disabled")&&a(m.target).hasClass("menu_item")?Ya(m):a("#menu_bar").removeClass("active")});var Ba=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(m,w,C,I){if(m.altKey){m.preventDefault();
|
|
m=g.getZoom()*100;w=Ba.length;for(E=0;E<w;E++){C=Math.min(w,E+1);if(I>0)zoom=Ba[E]<=m?Ba[C]:zoom;if(I<0)zoom=Ba[E]<m?Ba[E]:zoom}zoom&&nb({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");Wa.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){Wa.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(m,w,C){if(a(m).length!=0){var I=a(m).find("button"),S=a(m).find("ul").attr("id",
|
|
a(m)[0].id+"-list");C||a("#option_lists").append(S);var Q=false;C&&a(m).addClass("dropup");S.find("li").bind("mouseup",w);a(window).mouseup(function(){if(!Q){I.removeClass("down");S.hide()}Q=false});I.bind("mousedown",function(){if(I.hasClass("down")){I.removeClass("down");S.hide()}else{I.addClass("down");if(!C){var V=a(m).offset();S.css({top:V.top,left:V.left-110})}S.show();Q=true}}).hover(function(){Q=true}).mouseout(function(){Q=false})}};var xa=function(m,w,C,I){var S=a(m);w=a(w);var Q=false,
|
|
V=I.dropUp;V&&a(m).addClass("dropup");w.find("li").bind("mouseup",function(){if(I.seticon){eb("#cur_"+S[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!Q){S.removeClass("down");w.hide();w.css({top:0,left:0})}Q=false});w.height();a(m).bind("mousedown",function(){var aa=a(m).offset();if(V){aa.top-=w.height();aa.left+=8}else aa.top+=a(m).height();a(w).offset(aa);if(S.hasClass("down")){S.removeClass("down");
|
|
w.hide();w.css({top:0,left:0})}else{S.addClass("down");w.show();Q=true;return false}}).hover(function(){Q=true}).mouseout(function(){Q=false});I.multiclick&&w.mousedown(function(){Q=true})};a("#font_family_dropdown").change(function(){var m=this.options[this.selectedIndex].value,w=this.options[this.selectedIndex].text;a("#preview_font").html(w).css("font-family",m);a("#font_family").val(m).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var m=this.id.replace("tool_pos",
|
|
"").charAt(0);g.alignSelectedElements(m,"page")})});(function(){var m,w=function(){a(m).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){m=this;oa="toolbars";R.mousedown(w)}).blur(function(){oa="canvas";R.unbind("mousedown",w);g.getMode()=="textedit"&&a("#text").focus()})})();var ib=function(){Qa("#tool_select")&&g.setMode("select")},La=function(){Qa("#tool_fhpath")&&g.setMode("fhpath")},Va=function(){Qa("#tool_line")&&g.setMode("line")},Da=function(){Qa("#tool_rect")&&
|
|
g.setMode("rect")},kb=function(){Qa("#tool_ellipse")&&g.setMode("ellipse")},sb=function(){Qa("#tool_image")&&g.setMode("image")},$a=function(){Qa("#tool_zoom")&&g.setMode("zoom")},cb=function(){if(Qa("#tool_zoom")){vb();ba()}},Cb=function(){Qa("#tool_text")&&g.setMode("text")},ua=function(){Qa("#tool_path")&&g.setMode("path")},lb=function(){if(Y!=null||ta)g.deleteSelectedElements()},jb=function(){if(Y!=null||ta){window.event.type==="keydown"&&Ua(a("#edit_menu"));g.cutSelectedElements()}},wb=function(){if(Y!=
|
|
null||ta){window.event.type==="keydown"&&Ua(a("#edit_menu"));g.copySelectedElements()}},ob=function(){window.event.type==="keydown"&&Ua(a("#edit_menu"));var m=g.getZoom(),w=(R[0].scrollLeft+R.width()/2)/m-g.contentW;m=(R[0].scrollTop+R.height()/2)/m-g.contentH;g.pasteElements("point",w,m)},hb=function(){if(Y!=null){window.event.type==="keydown"&&Ua(a("#object_menu"));g.moveToTopSelectedElement()}},qb=function(){if(Y!=null){window.event.type==="keydown"&&Ua(a("#object_menu"));g.moveToBottomSelectedElement()}},
|
|
tb=function(){if(Y!=null){window.event.type==="keydown"&&Ua(a("#object_menu"));g.moveUpDownSelected("Up")}},Bb=function(){if(Y!=null){window.event.type==="keydown"&&Ua(a("#object_menu"));g.moveUpDownSelected("Down")}},xb=function(m){if(Y!=null){window.event.type==="keydown"&&Ua(a("#object_menu"));g.moveUpDownSelected(m)}},ka=function(){if(Y!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");
|
|
K.toEditMode(elems[0]);g.clearSelection();X()}},ca=function(){Y!=null&&K.reorient()},la=function(){if(Y!=null||ta)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(m){m&&g.makeHyperlink(m)})},M=function(m,w){if(Y!=null||ta){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;m*=C;w*=C}a("input").blur();g.moveSelectedElements(m,w)}},T=function(){var m=!a("#tool_node_link").hasClass("checked");m?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):
|
|
a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);K.linkControlPoints(m)},ea=function(){K.getNodePoint()&&K.clonePathNode()},Ga=function(){K.getNodePoint()&&K.deletePathNode()},Pa=function(){var m=a("#tool_add_subpath"),w=!m.hasClass("push_button_pressed");w?m.addClass("push_button_pressed").removeClass("tool_button"):m.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(w)},Za=function(){K.opencloseSubPath()},gb=function(){g.cycleElement(1)},pb=function(){g.cycleElement(0)},
|
|
Ra=function(m,w){if(!(Y==null||ta)){m||(w*=-1);var C=a("#angle").val()*1+w;g.setRotationAngle(C);wa()}},rb=function(){var m=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(w){if(w){ba();g.clear();g.setResolution(m[0],m[1]);H(true);vb();wa();pa();g.runExtensions("onNewDocument")}})},Sa=function(){g.setBold(!g.getBold());wa();return false},ub=function(){g.setItalic(!g.getItalic());wa();return false},yb=function(){if(!c.pngsave){var m=uiStrings.notification.loadingImage;O=
|
|
window.open("data:text/html;charset=utf-8,<title>"+m+"</title><h1>"+m+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Kb=function(){g.open()},Jb=function(){},Ua=function(m){var w=m.prev();w.css("background","#09f");setTimeout(function(){w.css("background","")},200)},Ma=function(){if(U.getUndoStackSize()>0){window.event.type==="keydown"&&Ua(a("#edit_menu"));U.undo()}},Ob=function(){if(U.getRedoStackSize()>
|
|
0){window.event.type==="keydown"&&Ua(a("#edit_menu"));U.redo()}},Hb=function(){if(ta)g.groupSelectedElements();else Y&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&Ua(a("#edit_menu"));g.cloneSelectedElements(20,20)},Pb=function(){var m=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(m,a("#align_relative_to").val())},Rb=function(){var m=document.querySelector("#tool_stroke rect"),w=document.querySelector("#tool_fill rect"),C=w.getAttribute("fill"),I=m.getAttribute("fill");
|
|
m=parseFloat(m.getAttribute("stroke-opacity"));if(isNaN(m))m=100;w=parseFloat(w.getAttribute("fill-opacity"));if(isNaN(w))w=100;I=Fa(I,m,"stroke");C=Fa(C,w,"fill");b.paintBox.fill.setPaint(I,true);b.paintBox.stroke.setPaint(C,true)},vb=function(m){var w=g.getResolution();m=m?w.zoom*m:1;a("#zoom").val(m*100);g.setZoom(m);Mb();H(true)},Lb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");
|
|
R.toggleClass("wireframe");if(!A){var m=a("#wireframe_rules");m.length?m.empty():a('<style id="wireframe_rules"></style>').appendTo("head");Mb()}},Sb=function(){var m=!a("#tool_snap").hasClass("push_button_pressed");m?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=m},Eb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},mb=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)},Mb=function(){if(!A){var m="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(R.hasClass("wireframe")?m:"")}},Qb=function(m,w){if(!ja){ja=true;a("#save_output_btns").toggle(!!w);a("#tool_source_back").toggle(!w);var C=
|
|
ga=g.getSvgString();a("#svg_source_textarea").val(C);a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Db=function(){if(ja){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();z();vb();pa()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(m){if(!m)return false;g.clearSelection();z();vb();pa()});ba()}},eb=b.setIcon=function(m,w){var C=typeof w==="string"?a.getSvgIcon(w,
|
|
true):w.clone();C?a(m).find("img").replaceWith(C):console.log("NOTE: Icon image missing: "+w)},Gb;Gb=function(){var m=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,w=document.getElementsByTagName("script")[0],C;for(C in w.style)if(m.test(C))return C.match(m)[0];if("WebkitOpacity"in w.style)return"Webkit";if("KhtmlOpacity"in w.style)return"Khtml";return""}();var e=function(m,w){Gb.toLowerCase();var C=["top","left","bottom","right"];m.each(function(){for(var I=a(this),S=I.outerWidth()*(w-1),Q=I.outerHeight()*
|
|
(w-1),V=0;V<4;V++){var aa=C[V],fa=I.data("orig_margin-"+aa);if(fa==null){fa=parseInt(I.css("margin-"+aa));I.data("orig_margin-"+aa,fa)}fa=fa*w;if(aa==="right")fa+=S;else if(aa==="bottom")fa+=Q;I.css("margin-"+aa,fa)}})},h=b.setIconSize=function(m,w){if(!(m==s.size&&!w)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),I=1;I=typeof m=="number"?
|
|
m:{s:0.75,m:1,l:1.25,xl:1.5}[m];b.tool_scale=ha=I;Ca();var S=C.parents(":hidden");S.css("visibility","hidden").show();e(C,I);S.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(m!="m"){var Q="";a.each(cssResizeRules,function(V,aa){V="#svg_editor "+V.replace(/,/g,", #svg_editor");Q+=V+"{";a.each(aa,function(fa,qa){if(typeof qa==="number")var sa=qa*I+"px";else if(qa[m]||qa.all)sa=qa[m]||qa.all;Q+=fa+
|
|
":"+sa+";"});Q+="}"});S="-"+Gb.toLowerCase()+"-";Q+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+S+"transform: scale("+I+");} #svg_editor div.toolset .toolset {"+S+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+S+"transform: scale("+1/I+");}";C.text(Q)}Ca()}},l=function(){a("#dialog_box").hide();if(ja){if(ja)ga!==
|
|
a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(m){m&&z()}):z();v()}else da&&g.leaveContext()},z=function(){a("#svg_source_editor").hide();ja=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var v=a.noop;a(window).resize(function(){H()});(function(){R.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=R[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=R[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
|
|
a("#change_image_url").click(function(){var m=g.getHref(Y);m=m.indexOf("data:")===0?"":m;a.prompt(uiStrings.notification.enterNewImgURL,m,function(w){w&&Ea(w)})});var G=function(m){var w=m[0].id=="stroke_color"?"stroke":"fill",C=m[0].id=="canvas_color";if(C)w="canvas";var I=b.paintBox[w].paint;m=w=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{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(C).jGraduate({paint:I,window:{pickerTitle:m},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(S){I=new a.jGraduate.Paint(S);b.paintBox[w].setPaint(I);g.setPaint(w,I);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(m,w){var C=document.getElementById("canvas_background"),I={color:"fff",opacity:1};if(w=="stroke")I=curConfig.initStroke;if(w=="fill")I=curConfig.initFill;if(w=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))I=
|
|
{color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+I.color+'" opacity="'+I.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(m)[0].appendChild(document.importNode(C,true));w==="canvas"?C.setAttribute("width",60.5):
|
|
C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:I.color});this.type=w;this.setPaint=function(S,Q){this.paint=S;var V="none",aa=S.type,fa=S.alpha/100;switch(aa){case "solidColor":V=S[aa]=="none"||S[aa]=="one"?"none":"#"+S[aa];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(S[aa]);V="url(#"+(this.grad.id="gradbox_"+
|
|
this.type)+")"}this.rect.setAttribute("fill",V);this.rect.setAttribute("opacity",fa);if(Q){g.setColor(this.type,V,true);g.setPaintOpacity(this.type,fa,true)}if(this.type=="canvas")(aa=document.getElementById("canvas_background"))?aa.setAttribute("fill",V):Oa(V)};this.update=function(S){if(Y){var Q=this.type;switch(Y.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var V=null,aa=Y.getElementsByTagName("*"),fa=0,qa=aa.length;fa<qa;fa++){var sa=aa[fa].getAttribute(Q);
|
|
if(fa===0)V=sa;else if(V!==sa){V=null;break}}if(V===null){aa=null;return}aa=V;V=1;break;default:V=parseFloat(Y.getAttribute(Q+"-opacity"));if(isNaN(V))V=1;aa=Q==="fill"?"black":"none";aa=Y.getAttribute(Q)||aa}if(S){g.setColor(Q,aa,true);g.setPaintOpacity(Q,V,true)}V*=100;this.setPaint(Fa(aa,V,Q))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var S=new a.jGraduate.Paint({copy:this.paint});g.setPaint(w,S)}}};b.paintBox.fill=new q("#fill_color","fill");b.paintBox.stroke=
|
|
new q("#stroke_color","stroke");b.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=b.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var A=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();
|
|
a(q).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(m){if(!m){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))G(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"))G(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){G(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");G(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");G(a("#fill_color"))});
|
|
a("#zoom_select").on("change",function(){var m=this.options[this.selectedIndex].text;m=m.split("%")[0];a("#zoom").val(m).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(){R.css("line-height",
|
|
R.height()+"px")});var u=function(){var m=a("#canvas_width"),w=a("#canvas_height"),C=m.val(),I=w.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);m.parent().addClass("error");return false}m.parent().removeClass("error");if(I!="fit"&&!svgedit.units.isValidUnit("height",I)){a.alert(uiStrings.notification.invalidAttrValGiven);w.parent().addClass("error");return false}w.parent().removeClass("error");if(!g.setResolution(C,I)){a.alert(uiStrings.notification.noContentToFitTo);
|
|
C=g.getResolution();m.val(C.w);w.val(C.h);return false}H()};a("#resolution").change(function(){var m=a("#canvas_width")[0],w=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){m.value="fit";w.value="fit";u();var C=g.getResolution();m.value=C.w;w.value=C.h}else{var I=this.value.split("x");I[0]=parseInt(I[0]);I[1]=parseInt(I[1]);var S=I[0]-m.value,Q=I[1]-w.value,V=Date.now(),aa=function(fa){fa=(fa-V)/1E3;fa=Math.pow(fa-1,3)+1;m.value=(I[0]-S+fa*S).toFixed(0);w.value=(I[1]-Q+fa*Q).toFixed(0);
|
|
u();if(fa>=1){fa=g.getResolution();a("#canvas_width").val(fa.w.toFixed());a("#canvas_height").val(fa.h.toFixed());a("#resolution_label").html("<div class='pull'>"+fa.w+"<span>\u00d7</span></br>"+fa.h+"</div>")}else requestAnimationFrame(aa)};aa(Date.now())}else{a("#resolution_label").html("Custom");m.removeAttribute("readonly");m.focus();m.select();if(m.value=="fit"){m.value=100;w.value=100}}});a("#zoom").change(function(){nb(this)});a("input,select").attr("autocomplete","off");var F=function(){var m=
|
|
[{sel:"#tool_select",fn:ib,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:La,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Va,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Da,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:kb,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:ua,evt:"click",key:["P",true]},{sel:"#tool_text",fn:Cb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:sb,evt:"mouseup"},{sel:"#tool_zoom",fn:$a,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",
|
|
fn:rb,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ja?Db():g.save({images:s.img_save,round_digits:6})},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:yb,evt:"mouseup"},{sel:"#tool_open",fn:Kb,evt:"mouseup"},{sel:"#tool_import",fn:Jb,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Lb,evt:"click"},{sel:"#tool_snap",fn:Sb,evt:"click"},{sel:"#tool_rulers",fn:mb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
|
|
fn:l,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Db,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:lb,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:ca,evt:"click"},{sel:"#tool_node_link",fn:T,evt:"click"},{sel:"#tool_node_clone",fn:ea,evt:"click"},{sel:"#tool_node_delete",fn:Ga,evt:"click"},{sel:"#tool_openclose_path",fn:Za,evt:"click"},{sel:"#tool_add_subpath",fn:Pa,evt:"click"},{sel:"#tool_move_top",fn:hb,evt:"click",key:o+"shift+up"},
|
|
{sel:"#tool_move_bottom",fn:qb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:Bb,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:ka,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:la,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Hb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Hb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Hb,evt:"click"},
|
|
{sel:"[id^=tool_align]",fn:Pb,evt:"click"},{sel:"#tool_undo",fn:Ma,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ob,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:jb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:wb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:ob,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Rb,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:Sa,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:ub,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:l,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:pb},{key:"shift+P",fn:gb},{key:[o+"+",true],fn:function(){vb(2)}},{key:[o+"-",true],fn:function(){vb(0.5)}},{key:["up",true],fn:function(){M(0,-1)}},{key:["down",true],fn:function(){M(0,1)}},{key:["left",true],fn:function(){M(-1,0)}},{key:["right",true],fn:function(){M(1,0)}},{key:"shift+up",fn:function(){M(0,
|
|
-10)}},{key:"shift+down",fn:function(){M(0,10)}},{key:"shift+left",fn:function(){M(-10,0)}},{key:"shift+right",fn:function(){M(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",
|
|
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:"I",fn:function(){var C=a(".tool_button_current");if(C.length&&C[0].id!=="tool_eyedropper"){C.removeClass("tool_button_current").addClass("tool_button");a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}g.setMode("eyedropper")}},
|
|
{key:o+"shift+z",fn:Ob},{key:"esc",fn:Eb}],w={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(m,function(I,S){if(S.sel){var Q=a(S.sel);if(Q.length==0)return true;if(S.evt){if(svgedit.browser.isTouch()&&S.evt==="click")S.evt="mousedown";Q[S.evt](S.fn)}if(S.parent&&a(S.parent+"_show").length!=0){var V=a(S.parent);V.length||(V=ma(S.parent.substr(1)));V.append(Q);a.isArray(C[S.parent])||(C[S.parent]=[]);C[S.parent].push(S)}}if(S.key){var aa=S.fn,
|
|
fa=false;if(a.isArray(S.key)){V=S.key[0];if(S.key.length>1)fa=S.key[1]}else V=S.key;V+="";svgedit.browser.isMac&&V.indexOf("+")!=-1&&V.split("+")[0]=="ctrl"&&V.replace("ctrl","cmd");a.each(V.split("/"),function(sa,ab){a(document).bind("keydown",ab,function(Aa){aa();fa&&Aa.preventDefault();return false})});if(S.sel&&!S.hidekey&&Q.attr("title")){var qa=Q.attr("title").split("[")[0]+" ("+V+")";w[V]=S.sel;Q.parents("#main_menu").length||Q.attr("title",qa)}}});na(C);a(window).bind("keydown","tab",function(I){if(oa===
|
|
"canvas"){I.preventDefault();gb()}}).bind("keydown","shift+tab",function(I){if(oa==="canvas"){I.preventDefault();pb()}});a("#tool_zoom").dblclick(cb)},setTitles:function(){a.each(w,function(C,I){var S=a(I).parents("#main_menu").length;a(I).each(function(){var Q=S?a(this).text().split(" [")[0]:this.title.split(" [")[0],V="";a.each(C.split("/"),function(aa,fa){var qa=fa.split("+"),sa="";if(qa.length>1){sa=qa[0]+"+";fa=qa[1]}V+=(aa?"/":"")+sa+(uiStrings["key_"+fa]||fa)});if(S)this.lastChild.textContent=
|
|
Q+" ["+V+"]";else this.title=Q+" ["+V+"]"})})},getButtonData:function(C){var I;a.each(m,function(S,Q){if(Q.sel===C)I=Q});return I}}}();F.setAll();b.ready(function(){var m=curConfig.initTool,w=a("#tools_left, #svg_editor .tools_flyout"),C=w.find("#tool_"+m);m=w.find("#"+m);(C.length?C:m.length?m: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:u,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:u,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(m){var w=m.value;if(w==0&&Y&&["line","polyline"].indexOf(Y.nodeName)>=
|
|
0)w=m.value=1;g.setStrokeWidth(w)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(m){g.setRotationAngle(m.value);rotateCursor(m.value);a("#tool_reorient").toggleClass("disabled",m.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(m){g.setFontSize(m.value)},cursor:true,stepfunc:function(m,w){var C=m.value-0,I=C+w,S=I>=C;if(w===0)return C;return C>=24?S?Math.round(C*1.1):Math.round(C/1.1):
|
|
C<=1?S?C*2:C/2:I},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(m){val=m.value;a("#blur").val(val);g.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(m){switch(m){case "delete":lb();break;case "cut":jb();break;case "copy":wb();break;case "paste":g.pasteElements();break;case "paste_in_place":g.pasteElements("in_place");
|
|
break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":hb();break;case "move_up":xb("Up");break;case "move_down":xb("Down");break;case "move_back":qb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(m)&&svgedit.contextmenu.getCustomHandler(m).call()}});a(".contextMenu li").mousedown(function(m){m.preventDefault()});a("#cmenu_canvas li").disableContextMenu();W.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=
|
|
function(){if(U.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(m){a("#main_menu").hide();U.getUndoStackSize()===0?m(true):a.confirm(uiStrings.notification.QwantToOpen,m)};if(window.FileReader){q=a('<input type="file">').change(function(){var m=this;b.openPrep(function(w){if(w){g.clear();if(m.files.length==1){w=new FileReader;w.onloadend=function(C){p(C.target.result);H()};w.readAsText(m.files[0])}}})});
|
|
a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var m=new FileReader;m.onloadend=function(w){g.importSvgString(w.target.result,true);H()};m.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var H=b.updateCanvas=function(m,w){var C=R.width(),I=R.height(),S=C,Q=I,V=g.getZoom(),aa=a("#svgcanvas"),fa={x:R[0].scrollLeft+S/2,y:R[0].scrollTop+Q/2},qa=curConfig.canvas_expansion;C=Math.max(S,g.contentW*V*qa);
|
|
I=Math.max(Q,g.contentH*V*qa);C==S&&I==Q?R.css("overflow","hidden"):R.css("overflow","scroll");qa=aa.height()/2;var sa=aa.width()/2;aa.width(C).height(I);var ab=I/2,Aa=C/2,ia=g.updateCanvas(C,I),fb=Aa/sa;C=C/2-S/2;I=I/2-Q/2;if(w){w.x+=ia.x;w.y+=ia.y}else w={x:Aa+(fa.x-sa)*fb,y:ab+(fa.y-qa)*fb};if(m)if(g.contentW>R.width()){R[0].scrollLeft=ia.x-10;R[0].scrollTop=ia.y-10}else{R[0].scrollLeft=C;R[0].scrollTop=I}else{R[0].scrollLeft=w.x-S/2;R[0].scrollTop=w.y-Q/2}if(curConfig.showRulers){k(aa,V);R.scroll()}},
|
|
D=[],E=0.1;E<1E5;E*=10){D.push(1*E);D.push(2*E);D.push(5*E)}H(true);try{var L=function(m){if(window.JSON&&JSON.stringify)return JSON.stringify(m);var w=arguments.callee;if(typeof m=="boolean"||typeof m=="number")return m+"";else if(typeof m=="string")return'"'+m.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(S){return"\\u"+("0000"+S.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(m.length){for(var C=0;C<
|
|
m.length;C++)m[C]=w(m[C]);return"["+m.join(",")+"]"}else{C=[];for(var I in m)C.push(w(I)+":"+w(m[I]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(m){var w=parseInt(m.data.substr(0,m.data.indexOf(";")));try{m.source.postMessage("SVGe"+w+";"+L(eval(m.data)),"*")}catch(C){m.source.postMessage("SVGe"+w+";error:"+C.message,"*")}},false)}catch(N){window.embed_error=N}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});b.setLang=function(m,w){a.pref("lang",m);a("#lang_select").val(m);
|
|
if(w){g.runExtensions("langChanged",m);Ja();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,I){a(I).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];b.ready=function(d){n?d():f.push(d)};b.runCallbacks=function(){a.each(f,function(){this()});
|
|
n=true};b.loadFromString=function(d){b.ready(function(){p(d)})};b.loadFromURL=function(d,k){k||(k={});var q=k.cache,B=k.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,U){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+U+"",B)}})})};b.loadFromDataURI=function(d){b.ready(function(){var k=d.substring(26);p(svgedit.utilities.decode64(k))})};b.addExtension=function(){var d=arguments;
|
|
a(function(){g&&g.addExtension.apply(this,d)})};return b}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=
|
|
a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var p=this.dragCfg.dragAdjust,g=$(this).parent(),b=$(this),n=this.dragCfg.height,s=this.dragCfg.min,c=this.dragCfg.max,f=this.dragCfg.step,d=c-s>0?(c-s)/f:200,k=d/n*f,q=0,B=this.getAttribute("data-attr"),o=svgEditor.canvas,K=o.getSelectedElems(),U=svgedit.browser.isTouch(),P=true,J=d&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(g):false;b.attr("readonly","readonly");J&&!isNaN(this.dragCfg.start)&&J.css("top",this.dragCfg.start*
|
|
-1/k+n);this.adjustValue=function(R,W){var O;R=parseFloat(R);if(isNaN(this.value))O=this.dragCfg.reset;else if($.isFunction(this.dragCfg.stepfunc)){O=this.dragCfg.stepfunc(this,R);console.log(O)}else O=Number((Number(this.value)+Number(R)).toFixed(5));if(c!==null)O=Math.min(O,c);if(s!==null)O=Math.max(O,s);J&&this.updateCursor(O);this.value=O;g.attr("data-value",O);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,W)};g.toggleClass("draginput",g.is("label"));this.move=function(R,W,O){if(U)R=
|
|
R.originalEvent.touches[0];if(q===0)q=W;W=(R.pageY-q)*-1;q=R.pageY;O=W*k*p;this.adjustValue(O.toFixed(f<1?1:0))};this.stop=function(){$("body").removeClass("dragging");g.removeClass("active");P=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");q=0;if(K[0]){var R=o.undoMgr.finishUndoableChange();R.isEmpty()||o.undoMgr.addCommandToHistory(R)}this.adjustValue(0,P)};this.updateCursor=function(){var R=parseFloat(this.value)*-1/k+n;J.css("top",R)};this.start=
|
|
function(R){if(U)R=R.originalEvent.touches[0];var W=R.pageY,O=this.value,ha=this;o.undoMgr.beginUndoableChange(B,K);$("body").addClass("dragging");g.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(oa){ha.move(oa,W,parseFloat(O))});$(window).bind("mouseup.draginput touchend.draginput",function(){ha.stop()})};$(this).attr("readonly","readonly").attr("data-scale",k).attr("data-domain",n).attr("data-cursor",J!=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,W,O,ha){P&&o.undoMgr.beginUndoableChange(B,K);P=false;clearTimeout(window.undoTimeout);window.undoTimeout=setTimeout(function(){oa.stop()},
|
|
1E3);var oa=this;if(ha>0)this.adjustValue(this.dragCfg.step);else ha<0&&this.adjustValue(-this.dragCfg.step);R.preventDefault()})})};$.fn.dragInput.updateCursor=function(a){var p=parseFloat(a.value),g=parseFloat(a.getAttribute("data-scale")),b=parseFloat(a.getAttribute("data-domain"));p=p*-1/g+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 g=p.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+p.id+"'>"+p.label+"<span class='shortcut'>"+g+"</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 g(n){return!a(n).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function b(n,s){var c=n.nodeName.toLowerCase();if("area"===c){c=n.parentNode;var f=c.name;if(!n.href||!f||c.nodeName.toLowerCase()!=="map")return false;c=a("img[usemap=#"+f+"]")[0];return!!c&&g(c)}return(/input|select|textarea|button|object/.test(c)?!n.disabled:"a"==c?n.href||s:s)&&g(n)}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(n,s){return typeof n=="number"?this.each(function(){var c=
|
|
this;setTimeout(function(){a(c).focus();s&&s.call(c)},n)}):this._focus.apply(this,arguments)},scrollParent:function(){var n;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?n=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):n=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"))||!n.length?a(document):n},zIndex:function(n){if(n!==p)return this.css("zIndex",n);if(this.length){n=a(this[0]);for(var s;n.length&&n[0]!==document;){s=n.css("position");if(s==="absolute"||s==="relative"||s==="fixed"){s=parseInt(n.css("zIndex"),10);if(!isNaN(s)&&s!==0)return s}n=n.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":
|
|
"mousedown")+".ui-disableSelection",function(n){n.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(n,s){function c(q,B,o,K){a.each(f,function(){B-=parseFloat(a.curCSS(q,"padding"+this,true))||0;o&&(B-=parseFloat(a.curCSS(q,"border"+this+"Width",true))||0);K&&(B-=parseFloat(a.curCSS(q,"margin"+this,true))||0)});return B}var f=s==="Width"?["Left","Right"]:["Top","Bottom"],d=s.toLowerCase(),k={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,
|
|
outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+s]=function(q){if(q===p)return k["inner"+s].call(this);return this.each(function(){a(this).css(d,c(this,q)+"px")})};a.fn["outer"+s]=function(q,B){if(typeof q!="number")return k["outer"+s].call(this,q);return this.each(function(){a(this).css(d,c(this,q,true,B)+"px")})}}),a.extend(a.expr[":"],{data:function(n,s,c){return!!a.data(n,c[3])},focusable:function(n){return b(n,!isNaN(a.attr(n,"tabindex")))},tabbable:function(n){var s=a.attr(n,
|
|
"tabindex"),c=isNaN(s);return(c||s>=0)&&b(n,!c)}}),a(function(){var n=document.body,s=n.appendChild(s=document.createElement("div"));a.extend(s.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=s.offsetHeight===100;a.support.selectstart="onselectstart"in s;n.removeChild(s).style.display="none"}),a.extend(a.ui,{plugin:{add:function(n,s,c){n=a.ui[n].prototype;for(var f in c){n.plugins[f]=n.plugins[f]||[];n.plugins[f].push([s,c[f]])}},call:function(n,s,c){if((s=n.plugins[s])&&
|
|
n.element[0].parentNode)for(var f=0;f<s.length;f++)n.options[s[f][0]]&&s[f][1].apply(n.element,c)}},contains:function(n,s){return document.compareDocumentPosition?n.compareDocumentPosition(s)&16:n!==s&&n.contains(s)},hasScroll:function(n,s){if(a(n).css("overflow")==="hidden")return false;var c=s&&s==="left"?"scrollLeft":"scrollTop",f=false;if(n[c]>0)return true;n[c]=1;f=n[c]>0;n[c]=0;return f},isOverAxis:function(n,s,c){return n>s&&n<s+c},isOver:function(n,s,c,f,d,k){return a.ui.isOverAxis(n,c,d)&&
|
|
a.ui.isOverAxis(s,f,k)}}))})(jQuery);
|
|
(function(a,p){if(a.cleanData){var g=a.cleanData;a.cleanData=function(n){for(var s=0,c;(c=n[s])!=null;s++)try{a(c).triggerHandler("remove")}catch(f){}g(n)}}else{var b=a.fn.remove;a.fn.remove=function(n,s){return this.each(function(){s||(!n||a.filter(n,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(c){}});return b.call(a(this),n,s)})}}a.widget=function(n,s,c){var f=n.split(".")[0],d;n=n.split(".")[1];d=f+"-"+n;c||(c=s,s=a.Widget);a.expr[":"][d]=
|
|
function(k){return!!a.data(k,n)};a[f]=a[f]||{};a[f][n]=function(k,q){arguments.length&&this._createWidget(k,q)};s=new s;s.options=a.extend(true,{},s.options);a[f][n].prototype=a.extend(true,s,{namespace:f,widgetName:n,widgetEventPrefix:a[f][n].prototype.widgetEventPrefix||n,widgetBaseClass:d},c);a.widget.bridge(n,a[f][n])};a.widget.bridge=function(n,s){a.fn[n]=function(c){var f=typeof c=="string",d=Array.prototype.slice.call(arguments,1),k=this;c=!f&&d.length?a.extend.apply(null,[true,c].concat(d)):
|
|
c;if(f&&c.charAt(0)==="_")return k;f?this.each(function(){var q=a.data(this,n),B=q&&a.isFunction(q[c])?q[c].apply(q,d):q;if(B!==q&&B!==p){k=B;return false}}):this.each(function(){var q=a.data(this,n);q?q.option(c||{})._init():a.data(this,n,new s(c,this))});return k}};a.Widget=function(n,s){arguments.length&&this._createWidget(n,s)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(n,s){a.data(s,this.widgetName,this);this.element=a(s);this.options=
|
|
a.extend(true,{},this.options,this._getCreateOptions(),n);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(n,s){var c=n;if(arguments.length===0)return a.extend({},this.options);if(typeof n=="string"){if(s===p)return this.options[n];c={};c[n]=s}this._setOptions(c);return this},_setOptions:function(n){var s=this;a.each(n,function(c,f){s._setOption(c,f)});return this},_setOption:function(n,s){this.options[n]=s;n==="disabled"&&this.widget()[s?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
|
|
s);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(n,s,c){var f,d=this.options[n];c=c||{};s=a.Event(s);s.type=(n===this.widgetEventPrefix?n:this.widgetEventPrefix+n).toLowerCase();s.target=this.element[0];if(n=s.originalEvent)for(f in n)f in s||(s[f]=n[f]);this.element.trigger(s,c);return!(a.isFunction(d)&&d.call(this.element[0],s,c)===false||s.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 g=this;this.element.bind("mousedown."+this.widgetName,function(b){return g._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(true===a.data(b.target,g.widgetName+".preventClickEvent")){a.removeData(b.target,g.widgetName+".preventClickEvent");b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
|
|
this.widgetName)},_mouseDown:function(g){if(!p){this._mouseStarted&&this._mouseUp(g);this._mouseDownEvent=g;var b=this,n=g.which==1,s=typeof this.options.cancel=="string"&&g.target.nodeName?a(g.target).closest(this.options.cancel).length:false;if(!n||s||!this._mouseCapture(g))return true;(this.mouseDelayMet=!this.options.delay)||(this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay));if(this._mouseDistanceMet(g)&&this._mouseDelayMet(g)){this._mouseStarted=this._mouseStart(g)!==
|
|
false;if(!this._mouseStarted){g.preventDefault();return true}}true===a.data(g.target,this.widgetName+".preventClickEvent")&&a.removeData(g.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);g.preventDefault();return p=true}},_mouseMove:function(g){if(a.browser.msie&&
|
|
!(document.documentMode>=9)&&!g.button)return this._mouseUp(g);if(this._mouseStarted){this._mouseDrag(g);return g.preventDefault()}this._mouseDistanceMet(g)&&this._mouseDelayMet(g)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,g)!==false,this._mouseStarted?this._mouseDrag(g):this._mouseUp(g));return!this._mouseStarted},_mouseUp:function(g){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);this._mouseStarted&&
|
|
(this._mouseStarted=false,g.target==this._mouseDownEvent.target&&a.data(g.target,this.widgetName+".preventClickEvent",true),this._mouseStop(g));return false},_mouseDistanceMet:function(g){return Math.max(Math.abs(this._mouseDownEvent.pageX-g.pageX),Math.abs(this._mouseDownEvent.pageY-g.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
|
|
(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){this.options.helper=="original"&&
|
|
!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative");this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(p){var g=this.options;
|
|
if(this.helper||g.disabled||a(p.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(p);if(!this.handle)return false;g.iframeFix&&a(g.iframeFix===true?"iframe":g.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 g=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;g.cursorAt&&this._adjustOffsetFromHelper(g.cursorAt);g.containment&&this._setContainment();if(this._trigger("start",p)===false){this._clear();return false}this._cacheHelperProportions();a.ui.ddmanager&&!g.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,g){this.position=this._generatePosition(p);this.positionAbs=this._convertPositionTo("absolute");if(!g){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 g=
|
|
false;a.ui.ddmanager&&!this.options.dropBehaviour&&(g=a.ui.ddmanager.drop(this,p));this.dropped&&(g=this.dropped,this.dropped=false);if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!g||this.options.revert=="valid"&&g||this.options.revert===true||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,g)){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 g=!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&&(g=true)});return g},_createHelper:function(p){var g=this.options;p=a.isFunction(g.helper)?a(g.helper.apply(this.element[0],[p])):g.helper=="clone"?this.element.clone().removeAttr("id"):this.element;p.parents("body").length||p.appendTo(g.appendTo=="parent"?this.element[0].parentNode:g.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 g=p[0];if(g){p.offset();var b=a(g).css("overflow")!=
|
|
"hidden";this.containment=[(parseInt(a(g).css("borderLeftWidth"),10)||0)+(parseInt(a(g).css("paddingLeft"),10)||0),(parseInt(a(g).css("borderTopWidth"),10)||0)+(parseInt(a(g).css("paddingTop"),10)||0),(b?Math.max(g.scrollWidth,g.offsetWidth):g.offsetWidth)-(parseInt(a(g).css("borderLeftWidth"),10)||0)-(parseInt(a(g).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(b?Math.max(g.scrollHeight,g.offsetHeight):g.offsetHeight)-(parseInt(a(g).css("borderTopWidth"),
|
|
10)||0)-(parseInt(a(g).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,g){g||(g=this.position);var b=p=="absolute"?1:-1,n=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,s=/(html|body)/i.test(n[0].tagName);return{top:g.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():s?0:n.scrollTop())*b),left:g.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():s?0:n.scrollLeft())*b)}},_generatePosition:function(p){var g=this.options,b=this.cssPosition=="absolute"&&
|
|
(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,n=/(html|body)/i.test(b[0].tagName),s=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]&&(s=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]&&(s=f[2]+this.offset.click.left);p.pageY-this.offset.click.top>f[3]&&(c=f[3]+this.offset.click.top)}if(g.grid){c=g.grid[1]?this.originalPageY+Math.round((c-this.originalPageY)/g.grid[1])*g.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+g.grid[1]:c-g.grid[1]:c:c;s=g.grid[0]?this.originalPageX+Math.round((s-this.originalPageX)/
|
|
g.grid[0])*g.grid[0]:this.originalPageX;s=f?s-this.offset.click.left<f[0]||s-this.offset.click.left>f[2]?s-this.offset.click.left<f[0]?s+g.grid[0]:s-g.grid[0]:s:s}}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():n?0:b.scrollTop()),left:s-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():n?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,g,b){b=b||this._uiHash();a.ui.plugin.call(this,p,[g,b]);p=="drag"&&(this.positionAbs=this._convertPositionTo("absolute"));return a.Widget.prototype._trigger.call(this,p,g,
|
|
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,g){var b=a(this).data("draggable"),n=b.options,s=a.extend({},g,{item:b.element});b.sortables=[];a(n.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,s))})},stop:function(p,g){var b=a(this).data("draggable"),n=a.extend({},g,{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,n))})},drag:function(p,g){var b=a(this).data("draggable"),n=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(n).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 g.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"),g=a(this).data("draggable").options;p.css("cursor")&&(g._cursor=p.css("cursor"));p.css("cursor",g.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,g){var b=a(g.helper),n=a(this).data("draggable").options;b.css("opacity")&&(n._opacity=
|
|
b.css("opacity"));b.css("opacity",n.opacity)},stop:function(p,g){var b=a(this).data("draggable").options;b._opacity&&a(g.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 g=a(this).data("draggable"),b=g.options,n=false;if(g.scrollParent[0]!=document&&g.scrollParent[0].tagName!="HTML"){if(!b.axis||
|
|
b.axis!="x")g.overflowOffset.top+g.scrollParent[0].offsetHeight-p.pageY<b.scrollSensitivity?g.scrollParent[0].scrollTop=n=g.scrollParent[0].scrollTop+b.scrollSpeed:p.pageY-g.overflowOffset.top<b.scrollSensitivity&&(g.scrollParent[0].scrollTop=n=g.scrollParent[0].scrollTop-b.scrollSpeed);if(!b.axis||b.axis!="y")g.overflowOffset.left+g.scrollParent[0].offsetWidth-p.pageX<b.scrollSensitivity?g.scrollParent[0].scrollLeft=n=g.scrollParent[0].scrollLeft+b.scrollSpeed:p.pageX-g.overflowOffset.left<b.scrollSensitivity&&
|
|
(g.scrollParent[0].scrollLeft=n=g.scrollParent[0].scrollLeft-b.scrollSpeed)}else{if(!b.axis||b.axis!="x")p.pageY-a(document).scrollTop()<b.scrollSensitivity?n=a(document).scrollTop(a(document).scrollTop()-b.scrollSpeed):a(window).height()-(p.pageY-a(document).scrollTop())<b.scrollSensitivity&&(n=a(document).scrollTop(a(document).scrollTop()+b.scrollSpeed));if(!b.axis||b.axis!="y")p.pageX-a(document).scrollLeft()<b.scrollSensitivity?n=a(document).scrollLeft(a(document).scrollLeft()-b.scrollSpeed):
|
|
a(window).width()-(p.pageX-a(document).scrollLeft())<b.scrollSensitivity&&(n=a(document).scrollLeft(a(document).scrollLeft()+b.scrollSpeed))}n!==false&&a.ui.ddmanager&&!b.dropBehaviour&&a.ui.ddmanager.prepareOffsets(g,p)}});a.ui.plugin.add("draggable","snap",{start:function(){var p=a(this).data("draggable"),g=p.options;p.snapElements=[];a(g.snap.constructor!=String?g.snap.items||":data(draggable)":g.snap).each(function(){var b=a(this),n=b.offset();this!=p.element[0]&&p.snapElements.push({item:this,
|
|
width:b.outerWidth(),height:b.outerHeight(),top:n.top,left:n.left})})},drag:function(p,g){for(var b=a(this).data("draggable"),n=b.options,s=n.snapTolerance,c=g.offset.left,f=c+b.helperProportions.width,d=g.offset.top,k=d+b.helperProportions.height,q=b.snapElements.length-1;q>=0;q--){var B=b.snapElements[q].left,o=B+b.snapElements[q].width,K=b.snapElements[q].top,U=K+b.snapElements[q].height;if(B-s<c&&c<o+s&&K-s<d&&d<U+s||B-s<c&&c<o+s&&K-s<k&&k<U+s||B-s<f&&f<o+s&&K-s<d&&d<U+s||B-s<f&&f<o+s&&K-s<k&&
|
|
k<U+s){if(n.snapMode!="inner"){var P=Math.abs(K-k)<=s,J=Math.abs(U-d)<=s,R=Math.abs(B-f)<=s,W=Math.abs(o-c)<=s;P&&(g.position.top=b._convertPositionTo("relative",{top:K-b.helperProportions.height,left:0}).top-b.margins.top);J&&(g.position.top=b._convertPositionTo("relative",{top:U,left:0}).top-b.margins.top);R&&(g.position.left=b._convertPositionTo("relative",{top:0,left:B-b.helperProportions.width}).left-b.margins.left);W&&(g.position.left=b._convertPositionTo("relative",{top:0,left:o}).left-b.margins.left)}var O=
|
|
P||J||R||W;if(n.snapMode!="outer"){P=Math.abs(K-d)<=s;J=Math.abs(U-k)<=s;R=Math.abs(B-c)<=s;W=Math.abs(o-f)<=s;P&&(g.position.top=b._convertPositionTo("relative",{top:K,left:0}).top-b.margins.top);J&&(g.position.top=b._convertPositionTo("relative",{top:U-b.helperProportions.height,left:0}).top-b.margins.top);R&&(g.position.left=b._convertPositionTo("relative",{top:0,left:B}).left-b.margins.left);W&&(g.position.left=b._convertPositionTo("relative",{top:0,left:o-b.helperProportions.width}).left-b.margins.left)}!b.snapElements[q].snapping&&
|
|
(P||J||R||W||O)&&b.options.snap.snap&&b.options.snap.snap.call(b.element,p,a.extend(b._uiHash(),{snapItem:b.snapElements[q].item}));b.snapElements[q].snapping=P||J||R||W||O}else{b.snapElements[q].snapping&&b.options.snap.release&&b.options.snap.release.call(b.element,p,a.extend(b._uiHash(),{snapItem:b.snapElements[q].item}));b.snapElements[q].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,
|
|
n){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(n).css("zIndex"),10)||0)});if(p.length){var g=parseInt(p[0].style.zIndex)||0;a(p).each(function(b){this.style.zIndex=g+b});this[0].style.zIndex=g+p.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(p,g){var b=a(g.helper),n=a(this).data("draggable").options;b.css("zIndex")&&(n._zIndex=b.css("zIndex"));b.css("zIndex",n.zIndex)},stop:function(p,g){var b=a(this).data("draggable").options;b._zIndex&&a(g.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,g=this.options,b=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),n=g.values&&g.values.length||1,s=[];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"+(g.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);g.range&&(g.range===true&&(g.values||(g.values=[this._valueMin(),this._valueMin()]),g.values.length&&g.values.length!==2&&(g.values=[g.values[0],g.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(g.range==="min"||g.range==="max"?" ui-slider-range-"+g.range:"")));for(var c=b.length;c<n;c+=1)s.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
|
|
this.handles=b.add(a(s.join("")).appendTo(p.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(f){f.preventDefault()}).hover(function(){g.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){g.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,k=a(this).data("index.ui-slider-handle"),q,B,o;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");q=p._start(f,k);if(q===false)return}}q=p.options.step;p.options.values&&p.options.values.length?
|
|
B=o=p.values(k):B=o=p.value();switch(f.keyCode){case a.ui.keyCode.HOME:o=p._valueMin();break;case a.ui.keyCode.END:o=p._valueMax();break;case a.ui.keyCode.PAGE_UP:o=p._trimAlignValue(B+(p._valueMax()-p._valueMin())/5);break;case a.ui.keyCode.PAGE_DOWN:o=p._trimAlignValue(B-(p._valueMax()-p._valueMin())/5);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(B===p._valueMax())return;o=p._trimAlignValue(B+q);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(B===p._valueMin())return;o=p._trimAlignValue(B-
|
|
q)}p._slide(f,k,o);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 g=this.options,b,n,s,c,f;if(g.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});n=this._valueMax()-this._valueMin()+1;c=this;this.handles.each(function(d){var k=Math.abs(b-c.values(d));n>k&&(n=k,s=a(this),f=d)});g.range===true&&this.values(1)===g.min&&(f+=1,s=a(this.handles[f]));if(this._start(p,f)===false)return false;
|
|
this._mouseSliding=true;c._handleIndex=f;s.addClass("ui-state-active").focus();g=s.offset();this._clickOffset=!a(p.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:p.pageX-g.left-s.width()/2,top:p.pageY-g.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.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 g=
|
|
this._normValueFromMouse({x:p.pageX,y:p.pageY});this._slide(p,this._handleIndex,g);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 g,b;this.orientation==="horizontal"?
|
|
(g=this.elementSize.width,b=p.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(g=this.elementSize.height,b=p.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));p=b/g;p>1&&(p=1);p<0&&(p=0);this.orientation==="vertical"&&(p=1-p);g=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+p*g)},_start:function(p,g){var b={handle:this.handles[g],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(g),
|
|
b.values=this.values());return this._trigger("start",p,b)},_slide:function(p,g,b){var n,s,c;this.options.values&&this.options.values.length?(n=this.values(g?0:1),this.options.values.length===2&&this.options.range===true&&(g===0&&b>n||g===1&&b<n)&&(b=n),b!==this.values(g)&&(s=this.values(),s[g]=b,c=this._trigger("slide",p,{handle:this.handles[g],value:b,values:s}),this.values(g?0:1),c!==false&&this.values(g,b,true))):b!==this.value()&&(c=this._trigger("slide",p,{handle:this.handles[g],value:b}),c!==
|
|
false&&this.value(b))},_stop:function(p,g){var b={handle:this.handles[g],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(g),b.values=this.values());this._trigger("stop",p,b)},_change:function(p,g){if(!this._keySliding&&!this._mouseSliding){var b={handle:this.handles[g],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(g),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,g){var b,n,s;if(arguments.length>1){this.options.values[p]=this._trimAlignValue(g);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;n=arguments[0];for(s=0;s<b.length;s+=1){b[s]=this._trimAlignValue(n[s]);this._change(null,
|
|
s)}this._refreshValue()}},_setOption:function(p,g){var b,n=0;a.isArray(this.options.values)&&(n=this.options.values.length);a.Widget.prototype._setOption.apply(this,arguments);switch(p){case "disabled":g?(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<n;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 g,b;if(arguments.length){g=this.options.values[p];
|
|
return g=this._trimAlignValue(g)}g=this.options.values.slice();for(b=0;b<g.length;b+=1)g[b]=this._trimAlignValue(g[b]);return g},_trimAlignValue:function(p){if(p<=this._valueMin())return this._valueMin();if(p>=this._valueMax())return this._valueMax();var g=this.options.step>0?this.options.step:1,b=(p-this._valueMin())%g;p=p-b;Math.abs(b)*2>=g&&(p+=b>0?g:-g);return parseFloat(p.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var p=
|
|
this.options.range,g=this.options,b=this,n=this._animateOff?false:g.animate,s,c={},f,d,k,q;this.options.values&&this.options.values.length?this.handles.each(function(B){s=(b.values(B)-b._valueMin())/(b._valueMax()-b._valueMin())*100;c[b.orientation==="horizontal"?"left":"bottom"]=s+"%";a(this).stop(1,1)[n?"animate":"css"](c,g.animate);b.options.range===true&&(b.orientation==="horizontal"?(B===0&&b.range.stop(1,1)[n?"animate":"css"]({left:s+"%"},g.animate),B===1&&b.range[n?"animate":"css"]({width:s-
|
|
f+"%"},{queue:false,duration:g.animate})):(B===0&&b.range.stop(1,1)[n?"animate":"css"]({bottom:s+"%"},g.animate),B===1&&b.range[n?"animate":"css"]({height:s-f+"%"},{queue:false,duration:g.animate})));f=s}):(d=this.value(),k=this._valueMin(),q=this._valueMax(),s=q!==k?(d-k)/(q-k)*100:0,c[b.orientation==="horizontal"?"left":"bottom"]=s+"%",this.handle.stop(1,1)[n?"animate":"css"](c,g.animate),p==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[n?"animate":"css"]({width:s+"%"},g.animate),
|
|
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,f){if(f===undefined)f=0;return Math.round(c*Math.pow(10,f))/Math.pow(10,f)};var p=function(c,f){var d=this,k=c.find("img:first"),q=0,B=100,o=100,K=0,U=100,P=100,J=0,R=0,W,O,ha=[],oa=function(X){for(var Z=0;Z<ha.length;Z++)ha[Z].call(d,d,X)},ga=function(X){var Z=c.offset();W={l:Z.left|0,t:Z.top|0};clearTimeout(O);O=setTimeout(function(){ta.call(d,X)},0);a(document).bind("mousemove",ba).bind("mouseup",Y);X.preventDefault()},ba=function(X){clearTimeout(O);O=setTimeout(function(){ta.call(d,
|
|
X)},0);X.stopPropagation();X.preventDefault();return false},Y=function(X){a(document).unbind("mouseup",Y).unbind("mousemove",ba);X.stopPropagation();X.preventDefault();return false},ta=function(X){var Z=X.pageX-W.l;X=X.pageY-W.t;var pa=c.w,ra=c.h;if(Z<0)Z=0;else if(Z>pa)Z=pa;if(X<0)X=0;else if(X>ra)X=ra;ja.call(d,"xy",{x:Z/pa*o+q,y:X/ra*P+K})},ja=function(X,Z,pa){if(Z===undefined){if(X===undefined||X==null)X="xy";switch(X.toLowerCase()){case "x":return J;case "y":return R;default:return{x:J,y:R}}}if(!(pa!=
|
|
null&&pa==d)){var ra=false,na,ma;if(X==null)X="xy";switch(X.toLowerCase()){case "x":na=Z&&(Z.x&&Z.x|0||Z|0)||0;break;case "y":ma=Z&&(Z.y&&Z.y|0||Z|0)||0;break;default:na=Z&&Z.x&&Z.x|0||0;ma=Z&&Z.y&&Z.y|0||0}if(na!=null){if(na<q)na=q;else if(na>B)na=B;if(J!=na){J=na;ra=true}}if(ma!=null){if(ma<K)ma=K;else if(ma>U)ma=U;if(R!=ma){R=ma;ra=true}}ra&&oa.call(d,pa||d)}},da=function(X){a.isFunction(X)&&ha.push(X)};a.extend(true,d,{val:ja,range:function(X,Z){if(Z===undefined){if(X===undefined||X==null)X="all";
|
|
switch(X.toLowerCase()){case "minx":return q;case "maxx":return B;case "rangex":return{minX:q,maxX:B,rangeX:o};case "miny":return K;case "maxy":return U;case "rangey":return{minY:K,maxY:U,rangeY:P};default:return{minX:q,maxX:B,rangeX:o,minY:K,maxY:U,rangeY:P}}}var pa,ra,na,ma;if(X==null)X="all";switch(X.toLowerCase()){case "minx":pa=Z&&(Z.minX&&Z.minX|0||Z|0)||0;break;case "maxx":ra=Z&&(Z.maxX&&Z.maxX|0||Z|0)||0;break;case "rangex":pa=Z&&Z.minX&&Z.minX|0||0;ra=Z&&Z.maxX&&Z.maxX|0||0;break;case "miny":na=
|
|
Z&&(Z.minY&&Z.minY|0||Z|0)||0;break;case "maxy":ma=Z&&(Z.maxY&&Z.maxY|0||Z|0)||0;break;case "rangey":na=Z&&Z.minY&&Z.minY|0||0;ma=Z&&Z.maxY&&Z.maxY|0||0;break;default:pa=Z&&Z.minX&&Z.minX|0||0;ra=Z&&Z.maxX&&Z.maxX|0||0;na=Z&&Z.minY&&Z.minY|0||0;ma=Z&&Z.maxY&&Z.maxY|0||0}if(pa!=null&&q!=pa){q=pa;o=B-q}if(ra!=null&&B!=ra){B=ra;o=B-q}if(na!=null&&K!=na){K=na;P=U-K}if(ma!=null&&U!=ma){U=ma;P=U-K}},bind:da,unbind:function(X){if(a.isFunction(X))for(var Z;(Z=a.inArray(X,ha))!=-1;)ha.splice(Z,1)},destroy:function(){a(document).unbind("mouseup",
|
|
Y).unbind("mousemove",ba);c.unbind("mousedown",ga);ha=k=c=null}});k.src=f.arrow&&f.arrow.image;k.w=f.arrow&&f.arrow.width||k.width();k.h=f.arrow&&f.arrow.height||k.height();c.w=f.map&&f.map.width||c.width();c.h=f.map&&f.map.height||c.height();c.bind("mousedown",ga);da.call(d,function(){var X=0,Z=0,pa=c.w,ra=c.h,na=k.w,ma=k.h;setTimeout(function(){if(o>0)X=J==B?pa:J/o*pa|0;if(P>0)Z=R==U?ra:R/P*ra|0;if(na>=pa)X=(pa>>1)-(na>>1);else X-=na>>1;if(ma>=ra)Z=(ra>>1)-(ma>>1);else Z-=ma>>1;k.css({left:X+"px",
|
|
top:Z+"px"})},0)})},g=function(c,f,d,k){var q=this;c=c.find("td.Text input");var B=c.eq(3),o=c.eq(4),K=c.eq(5),U=c.length>7?c.eq(6):null,P=c.eq(0),J=c.eq(1),R=c.eq(2),W=c.eq(c.length>7?7:6),O=c.length>7?c.eq(8):null,ha=function(ja){if(!(ja.target.value==""&&ja.target!=W.get(0)&&(d!=null&&ja.target!=d.get(0)||d==null))){if(!ba(ja))return ja;switch(ja.target){case B.get(0):switch(ja.keyCode){case 38:B.val(Y.call(q,(B.val()<<0)+1,0,255));f.val("r",B.val(),ja.target);return false;case 40:B.val(Y.call(q,
|
|
(B.val()<<0)-1,0,255));f.val("r",B.val(),ja.target);return false}break;case o.get(0):switch(ja.keyCode){case 38:o.val(Y.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ja.target);return false;case 40:o.val(Y.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ja.target);return false}break;case K.get(0):switch(ja.keyCode){case 38:K.val(Y.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ja.target);return false;case 40:K.val(Y.call(q,(K.val()<<0)-1,0,255));f.val("b",K.val(),ja.target);return false}break;
|
|
case U&&U.get(0):switch(ja.keyCode){case 38:U.val(Y.call(q,parseFloat(U.val())+1,0,100));f.val("a",Math.precision(U.val()*255/100,k),ja.target);return false;case 40:U.val(Y.call(q,parseFloat(U.val())-1,0,100));f.val("a",Math.precision(U.val()*255/100,k),ja.target);return false}break;case P.get(0):switch(ja.keyCode){case 38:P.val(Y.call(q,(P.val()<<0)+1,0,360));f.val("h",P.val(),ja.target);return false;case 40:P.val(Y.call(q,(P.val()<<0)-1,0,360));f.val("h",P.val(),ja.target);return false}break;case J.get(0):switch(ja.keyCode){case 38:J.val(Y.call(q,
|
|
(J.val()<<0)+1,0,100));f.val("s",J.val(),ja.target);return false;case 40:J.val(Y.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ja.target);return false}break;case R.get(0):switch(ja.keyCode){case 38:R.val(Y.call(q,(R.val()<<0)+1,0,100));f.val("v",R.val(),ja.target);return false;case 40:R.val(Y.call(q,(R.val()<<0)-1,0,100));f.val("v",R.val(),ja.target);return false}}}},oa=function(ja){if(!(ja.target.value==""&&ja.target!=W.get(0)&&(d!=null&&ja.target!=d.get(0)||d==null))){if(!ba(ja))return ja;switch(ja.target){case B.get(0):B.val(Y.call(q,
|
|
B.val(),0,255));f.val("r",B.val(),ja.target);break;case o.get(0):o.val(Y.call(q,o.val(),0,255));f.val("g",o.val(),ja.target);break;case K.get(0):K.val(Y.call(q,K.val(),0,255));f.val("b",K.val(),ja.target);break;case U&&U.get(0):U.val(Y.call(q,U.val(),0,100));f.val("a",Math.precision(U.val()*255/100,k),ja.target);break;case P.get(0):P.val(Y.call(q,P.val(),0,360));f.val("h",P.val(),ja.target);break;case J.get(0):J.val(Y.call(q,J.val(),0,100));f.val("s",J.val(),ja.target);break;case R.get(0):R.val(Y.call(q,
|
|
R.val(),0,100));f.val("v",R.val(),ja.target);break;case W.get(0):W.val(W.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(W.val());f.val("hex",W.val()!=""?W.val():null,ja.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));W.val(d.val());f.val("hex",d.val()!=""?d.val():null,ja.target);break;case O&&O.get(0):O.val(O.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",O.val()!=null?parseInt(O.val(),16):
|
|
null,ja.target)}}},ga=function(ja){if(f.val()!=null)switch(ja.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case U&&U.get(0):U.val(Math.precision(f.val("a")*100/255,k));break;case P.get(0):P.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case R.get(0):R.val(f.val("v"));break;case W.get(0):case d&&d.get(0):W.val(f.val("hex"));d&&d.val(f.val("hex"));break;case O&&O.get(0):O.val(f.val("ahex").substring(6))}},ba=
|
|
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,da,X){if(ja==""||isNaN(ja))return da;if(ja>X)return X;if(ja<da)return da;return ja},ta=function(ja,da){var X=ja.val("all");if(da!=B.get(0))B.val(X!=null?X.r:"");if(da!=o.get(0))o.val(X!=null?X.g:"");if(da!=K.get(0))K.val(X!=null?X.b:"");if(U&&da!=U.get(0))U.val(X!=null?Math.precision(X.a*100/255,k):"");if(da!=P.get(0))P.val(X!=
|
|
null?X.h:"");if(da!=J.get(0))J.val(X!=null?X.s:"");if(da!=R.get(0))R.val(X!=null?X.v:"");if(da!=W.get(0)&&(d&&da!=d.get(0)||!d))W.val(X!=null?X.hex:"");if(d&&da!=d.get(0)&&da!=W.get(0))d.val(X!=null?X.hex:"");if(O&&da!=O.get(0))O.val(X!=null?X.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(U).add(P).add(J).add(R).add(W).add(d).add(O).unbind("keyup",oa).unbind("blur",ga);B.add(o).add(K).add(U).add(P).add(J).add(R).unbind("keydown",ha);f.unbind(ta);O=W=R=J=P=U=K=o=B=
|
|
null}});B.add(o).add(K).add(U).add(P).add(J).add(R).add(W).add(d).add(O).bind("keyup",oa).bind("blur",ga);B.add(o).add(K).add(U).add(P).add(J).add(R).bind("keydown",ha);f.bind(ta)};a.jPicker={List:[],Color:function(c){var f=this,d,k,q,B,o,K,U,P=[],J=function(W){for(var O=0;O<P.length;O++)P[O].call(f,f,W)},R=function(W,O,ha){if(O===undefined){if(W===undefined||W==null||W=="")W="all";if(d==null)return null;switch(W.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:k,b:q,a:B});case "hex":return R("ahex").substring(0,
|
|
6);case "all":return{r:d,g:k,b:q,a:B,h:o,s:K,v:U,hex:R.call(f,"hex"),ahex:R.call(f,"ahex")};default:O={};for(var oa=0;oa<W.length;oa++)switch(W.charAt(oa)){case "r":if(W.length==1)O=d;else O.r=d;break;case "g":if(W.length==1)O=k;else O.g=k;break;case "b":if(W.length==1)O=q;else O.b=q;break;case "a":if(W.length==1)O=B;else O.a=B;break;case "h":if(W.length==1)O=o;else O.h=o;break;case "s":if(W.length==1)O=K;else O.s=K;break;case "v":if(W.length==1)O=U;else O.v=U}return O=={}?R.call(f,"all"):O}}if(!(ha!=
|
|
null&&ha==f)){var ga=false;if(W==null)W="";if(O==null){if(d!=null){d=null;ga=true}if(k!=null){k=null;ga=true}if(q!=null){q=null;ga=true}if(B!=null){B=null;ga=true}if(o!=null){o=null;ga=true}if(K!=null){K=null;ga=true}if(U!=null){U=null;ga=true}ga&&J.call(f,ha||f)}else switch(W.toLowerCase()){case "ahex":case "hex":O=s.hexToRgba(O&&(O.ahex||O.hex)||O||"00000000");R.call(f,"rgba",{r:O.r,g:O.g,b:O.b,a:W=="ahex"?O.a:B!=null?B:255},ha);break;default:if(O&&(O.ahex!=null||O.hex!=null)){R.call(f,"ahex",O.ahex||
|
|
O.hex||"00000000",ha);break}var ba={},Y=false,ta=false;if(O.r!==undefined&&!W.indexOf("r")==-1)W+="r";if(O.g!==undefined&&!W.indexOf("g")==-1)W+="g";if(O.b!==undefined&&!W.indexOf("b")==-1)W+="b";if(O.a!==undefined&&!W.indexOf("a")==-1)W+="a";if(O.h!==undefined&&!W.indexOf("h")==-1)W+="h";if(O.s!==undefined&&!W.indexOf("s")==-1)W+="s";if(O.v!==undefined&&!W.indexOf("v")==-1)W+="v";for(oa=0;oa<W.length;oa++)switch(W.charAt(oa)){case "r":if(ta)continue;Y=true;ba.r=O&&O.r&&O.r|0||O&&O|0||0;if(ba.r<0)ba.r=
|
|
0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;ga=true}break;case "g":if(ta)continue;Y=true;ba.g=O&&O.g&&O.g|0||O&&O|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(k!=ba.g){k=ba.g;ga=true}break;case "b":if(ta)continue;Y=true;ba.b=O&&O.b&&O.b|0||O&&O|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;ga=true}break;case "a":ba.a=O&&O.a!=null?O.a|0:O!=null?O|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;ga=true}break;case "h":if(Y)continue;ta=true;ba.h=O&&O.h&&
|
|
O.h|0||O&&O|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;ga=true}break;case "s":if(Y)continue;ta=true;ba.s=O&&O.s!=null?O.s|0:O!=null?O|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;ga=true}break;case "v":if(Y)continue;ta=true;ba.v=O&&O.v!=null?O.v|0:O!=null?O|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(U!=ba.v){U=ba.v;ga=true}}if(ga){if(Y){d=d||0;k=k||0;q=q||0;O=s.rgbToHsv({r:d,g:k,b:q});o=O.h;K=O.s;U=O.v}else if(ta){o=o||0;K=K!=null?K:100;U=U!=
|
|
null?U:100;O=s.hsvToRgb({h:o,s:K,v:U});d=O.r;k=O.g;q=O.b}B=B!=null?B:255;J.call(f,ha||f)}}}};a.extend(true,f,{val:R,bind:function(W){a.isFunction(W)&&P.push(W)},unbind:function(W){if(a.isFunction(W))for(var O;(O=a.inArray(W,P))!=-1;)P.splice(O,1)},destroy:function(){P=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+s.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",k="00",q="255";if(c.length==6)c+="ff";if(c.length>6){f=c.substring(0,2);d=c.substring(2,4);k=c.substring(4,6);q=c.substring(6,c.length)}else{if(c.length>4){f=c.substring(4,c.length);c=c.substring(0,4)}if(c.length>2){d=c.substring(2,c.length);c=c.substring(0,2)}if(c.length>0)k=c.substring(0,c.length)}return{r:this.hexToInt(f),g:this.hexToInt(d),
|
|
b:this.hexToInt(k),a:this.hexToInt(q)}},validateHex:function(c){if(typeof c=="object")return"";c=c.toLowerCase().replace(/[^a-f0-9]/g,"");if(c.length>8)c=c.substring(0,8);return c},rgbaToHex:function(c){return this.intToHex(c.r)+this.intToHex(c.g)+this.intToHex(c.b)+this.intToHex(c.a)},intToHex:function(c){c=(c|0).toString(16);if(c.length==1)c="0"+c;return c.toLowerCase()},hexToInt:function(c){return parseInt(c,16)},rgbToHsv:function(c){var f=c.r/255,d=c.g/255;c=c.b/255;var k={h:0,s:0,v:0},q=0,B=
|
|
0;if(f>=d&&f>=c){B=f;q=d>c?c:d}else if(d>=c&&d>=f){B=d;q=f>c?c:f}else{B=c;q=d>f?f:d}k.v=B;k.s=B?(B-q)/B:0;if(k.s){q=B-q;k.h=f==B?(d-c)/q:d==B?2+(c-f)/q:4+(f-d)/q;k.h=parseInt(k.h*60);if(k.h<0)k.h+=360}else k.h=0;k.s=k.s*100|0;k.v=k.v*100|0;return k},hsvToRgb:function(c){var f={r:0,g:0,b:0,a:100},d=c.h,k=c.s;c=c.v;if(k==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;k/=100;c/=100;var q=d|0,B=d-q;d=c*(1-k);var o=c*(1-k*B);k=c*(1-k*(1-B));switch(q){case 0:f.r=c;f.g=k;f.b=d;break;case 1:f.r=
|
|
o;f.g=c;f.b=d;break;case 2:f.r=d;f.g=c;f.b=k;break;case 3:f.r=d;f.g=o;f.b=c;break;case 4:f.r=k;f.g=d;f.b=c;break;case 5:f.r=c;f.g=d;f.b=o}f.r=f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var b=a.jPicker.Color,n=a.jPicker.List,s=a.jPicker.ColorMethods;a.fn.jPicker=function(c){var f=arguments;return this.each(function(){var d=this,k=a.extend(true,{},a.fn.jPicker.defaults,c);if(a(d).get(0).nodeName.toLowerCase()=="input"){a.extend(true,k,{window:{bindToInput:true,expandable:true,input:a(d)}});if(a(d).val()==
|
|
""){k.color.active=new b({hex:null});k.color.current=new b({hex:null})}else if(s.validateHex(a(d).val())){k.color.active=new b({hex:a(d).val(),a:k.color.active.val("a")});k.color.current=new b({hex:a(d).val(),a:k.color.active.val("a")})}}if(k.window.expandable)a(d).after('<span class="jPicker"><span class="Icon"><span class="Color"> </span><span class="Alpha"> </span><span class="Image" title="Click To Open Color Picker"> </span><span class="Container"> </span></span></span>');
|
|
else k.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,U=null,P=null,J=null,R=null,W=null,O=null,ha=null,oa=null,ga=null,ba=null,Y=null,ta=null,ja=null,da=null,X=null,Z=null,pa=null,ra=null,na=null,ma=null,Ca=null,Ja=null,Ka=null,Fa=null,Ia=null,Oa=function(M){var T=la.active,ea=T.val("hex"),Ga,Pa;k.color.mode=M;switch(M){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Ba.call(d,U,0);xa.call(d,U,100);Ba.call(d,
|
|
P,260);xa.call(d,P,100);Wa.call(d,K,"transparent");Ba.call(d,R,0);xa.call(d,R,100);Ba.call(d,W,260);xa.call(d,W,100);Ba.call(d,O,260);xa.call(d,O,100);Ba.call(d,ha,260);xa.call(d,ha,100);Ba.call(d,ga,260);xa.call(d,ga,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:360});if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("s"),y:100-T.val("v")},ba);Y.val("y",360-T.val("h"),Y);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Ba.call(d,U,-260);Ba.call(d,
|
|
P,-520);Ba.call(d,R,-260);Ba.call(d,W,-520);Ba.call(d,ga,260);xa.call(d,ga,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("h"),y:100-T.val("v")},ba);Y.val("y",100-T.val("s"),Y);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Ba.call(d,U,-780);Ba.call(d,P,260);Wa.call(d,K,ea);Ba.call(d,R,-520);Ba.call(d,W,260);xa.call(d,W,100);Ba.call(d,ga,260);xa.call(d,ga,100)},0);ba.range("all",{minX:0,maxX:360,
|
|
minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:100});if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("h"),y:100-T.val("s")},ba);Y.val("y",100-T.val("v"),Y);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("b"),y:255-T.val("g")},ba);Y.val("y",255-T.val("r"),Y);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});
|
|
if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("b"),y:255-T.val("r")},ba);Y.val("y",255-T.val("g"),Y);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});Y.range("rangeY",{minY:0,maxY:255});if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("r"),y:255-T.val("g")},ba);Y.val("y",255-T.val("b"),Y);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Ba.call(d,U,-260);Ba.call(d,P,-520);Ba.call(d,R,260);Ba.call(d,W,260);xa.call(d,W,100);Ba.call(d,ga,0);xa.call(d,
|
|
ga,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});Y.range("rangeY",{minY:0,maxY:255});if(T.val("ahex")==null)break;ba.val("xy",{x:T.val("h"),y:100-T.val("v")},ba);Y.val("y",255-T.val("a"),Y);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){xa.call(d,U,100);xa.call(d,R,100);Ba.call(d,O,260);xa.call(d,O,100);Ba.call(d,ha,260);xa.call(d,ha,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
|
|
xa.call(d,R,100);xa.call(d,U,100);Ba.call(d,U,Ga);Ba.call(d,P,Ga-260);Ba.call(d,R,Pa-780);Ba.call(d,W,Pa-520);Ba.call(d,O,Pa);Ba.call(d,ha,Pa-260);Ba.call(d,ga,260);xa.call(d,ga,100)},0)}T.val("ahex")!=null&&Ea.call(d,T)},Ea=function(M,T){if(T==null||T!=Y&&T!=ba)za.call(d,M,T);setTimeout(function(){nb.call(d,M);Ab.call(d,M);Qa.call(d,M)},0)},wa=function(M,T){var ea=la.active;if(!(T!=ba&&ea.val()==null)){var Ga=M.val("all");switch(k.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},T);break;case "s":case "a":ea.val("hv",
|
|
{h:Ga.x,v:100-Ga.y},T);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},T);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},T);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},T);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},T)}}},Ha=function(M,T){var ea=la.active;if(!(T!=Y&&ea.val()==null))switch(k.color.mode){case "h":ea.val("h",{h:360-M.val("y")},T);break;case "s":ea.val("s",{s:100-M.val("y")},T);break;case "v":ea.val("v",{v:100-M.val("y")},T);break;case "r":ea.val("r",{r:255-M.val("y")},T);break;case "g":ea.val("g",
|
|
{g:255-M.val("y")},T);break;case "b":ea.val("b",{b:255-M.val("y")},T);break;case "a":ea.val("a",255-M.val("y"),T)}},za=function(M,T){if(T!=ba)switch(k.color.mode){case "h":var ea=M.val("sv");ba.val("xy",{x:ea!=null?ea.s:100,y:100-(ea!=null?ea.v:100)},T);break;case "s":case "a":ea=M.val("hv");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.v:100)},T);break;case "v":ea=M.val("hs");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.s:100)},T);break;case "r":ea=M.val("bg");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&
|
|
ea.g||0)},T);break;case "g":ea=M.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},T);break;case "b":ea=M.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},T)}if(T!=Y)switch(k.color.mode){case "h":Y.val("y",360-(M.val("h")||0),T);break;case "s":ea=M.val("s");Y.val("y",100-(ea!=null?ea:100),T);break;case "v":ea=M.val("v");Y.val("y",100-(ea!=null?ea:100),T);break;case "r":Y.val("y",255-(M.val("r")||0),T);break;case "g":Y.val("y",255-(M.val("g")||0),T);break;case "b":Y.val("y",255-(M.val("b")||
|
|
0),T);break;case "a":ea=M.val("a");Y.val("y",255-(ea!=null?ea:255),T)}},nb=function(M){try{var T=M.val("all");pa.css({backgroundColor:T&&"#"+T.hex||"transparent"});xa.call(d,pa,T&&Math.precision(T.a*100/255,4)||0)}catch(ea){}},Ab=function(M){switch(k.color.mode){case "h":Wa.call(d,o,(new b({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var T=M.val("s");xa.call(d,P,100-(T!=null?T:100));break;case "v":T=M.val("v");xa.call(d,U,T!=null?T:100);break;case "r":xa.call(d,P,Math.precision((M.val("r")||
|
|
0)/255*100,4));break;case "g":xa.call(d,P,Math.precision((M.val("g")||0)/255*100,4));break;case "b":xa.call(d,P,Math.precision((M.val("b")||0)/255*100))}M=M.val("a");xa.call(d,J,Math.precision((255-(M||0))*100/255,4))},Qa=function(M){switch(k.color.mode){case "h":var T=M.val("a");xa.call(d,oa,Math.precision((255-(T||0))*100/255,4));break;case "s":T=M.val("hva");var ea=new b({h:T&&T.h||0,s:100,v:T!=null?T.v:100});Wa.call(d,K,ea.val("hex"));xa.call(d,W,100-(T!=null?T.v:100));xa.call(d,oa,Math.precision((255-
|
|
(T&&T.a||0))*100/255,4));break;case "v":T=M.val("hsa");ea=new b({h:T&&T.h||0,s:T!=null?T.s:100,v:100});Wa.call(d,K,ea.val("hex"));xa.call(d,oa,Math.precision((255-(T&&T.a||0))*100/255,4));break;case "r":case "g":case "b":ea=T=0;M=M.val("rgba");if(k.color.mode=="r"){T=M&&M.b||0;ea=M&&M.g||0}else if(k.color.mode=="g"){T=M&&M.b||0;ea=M&&M.r||0}else if(k.color.mode=="b"){T=M&&M.r||0;ea=M&&M.g||0}var Ga=ea>T?T:ea;xa.call(d,W,T>ea?Math.precision((T-ea)/(255-ea)*100,4):0);xa.call(d,O,ea>T?Math.precision((ea-
|
|
T)/(255-T)*100,4):0);xa.call(d,ha,Math.precision(Ga/255*100,4));xa.call(d,oa,Math.precision((255-(M&&M.a||0))*100/255,4));break;case "a":T=M.val("a");Wa.call(d,K,M.val("hex")||"000000");xa.call(d,oa,T!=null?0:100);xa.call(d,ga,T!=null?100:0)}},Wa=function(M,T){M.css({backgroundColor:T&&T.length==6&&"#"+T||"transparent"})},Ya=function(M,T){if(q&&(T.indexOf("AlphaBar.png")!=-1||T.indexOf("Bars.png")!=-1||T.indexOf("Maps.png")!=-1)){M.attr("pngSrc",T);M.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
|
|
T+"', sizingMethod='scale')"})}else M.css({backgroundImage:"url('"+T+"')"})},Ba=function(M,T){M.css({top:T+"px"})},xa=function(M,T){M.css({visibility:T>0?"visible":"hidden"});if(T>0&&T<100)if(q){var ea=M.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?M.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+T+")"}):M.css({opacity:Math.precision(T/
|
|
100,4)})}else M.css({opacity:Math.precision(T/100,4)});else if(T==0||T==100)if(q){ea=M.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?M.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale')"}):M.css({opacity:""})}else M.css({opacity:""})},ib=function(){la.active.val("ahex",la.current.val("ahex"))},La=function(){la.current.val("ahex",la.active.val("ahex"))},Va=function(M){a(this).parents("tbody:first").find('input:radio[value!="'+
|
|
M.target.value+'"]').removeAttr("checked");Oa.call(d,M.target.value)},Da=function(){ib.call(d)},kb=function(){ib.call(d);k.window.expandable&&Bb.call(d);a.isFunction(qb)&&qb.call(d,la.active,ma)},sb=function(){La.call(d);k.window.expandable&&Bb.call(d);a.isFunction(ob)&&ob.call(d,la.active,na)},$a=function(){tb.call(d)},cb=function(M){var T=M.val("hex");ra.css({backgroundColor:T&&"#"+T||"transparent"});xa.call(d,ra,Math.precision((M.val("a")||0)*100/255,4))},Cb=function(M){var T=M.val("hex");M=M.val("va");
|
|
Ja.css({backgroundColor:T&&"#"+T||"transparent"});xa.call(d,Ka,Math.precision((255-(M&&M.a||0))*100/255,4));if(k.window.bindToInput&&k.window.updateInputColor)k.window.input.css({backgroundColor:T&&"#"+T||"transparent",color:M==null||M.v>75?"#000000":"#ffffff"})},ua=function(M){ja=parseInt(B.css("left"));da=parseInt(B.css("top"));X=M.pageX;Z=M.pageY;a(document).bind("mousemove",lb).bind("mouseup",jb);M.preventDefault()},lb=function(M){B.css({left:ja-(X-M.pageX)+"px",top:da-(Z-M.pageY)+"px"});k.window.expandable&&
|
|
!a.support.boxModel&&B.prev().css({left:B.css("left"),top:B.css("top")});M.stopPropagation();M.preventDefault();return false},jb=function(M){a(document).unbind("mousemove",lb).unbind("mouseup",jb);M.stopPropagation();M.preventDefault();return false},wb=function(M){M.preventDefault();M.stopPropagation();la.active.val("ahex",a(this).attr("title")||null,M.target);return false},ob=a.isFunction(f[1])&&f[1]||null,hb=a.isFunction(f[2])&&f[2]||null,qb=a.isFunction(f[3])&&f[3]||null,tb=function(){la.current.val("ahex",
|
|
la.active.val("ahex"));var M=function(){if(!(!k.window.expandable||a.support.boxModel)){var T=B.find("table:first");B.before("<iframe/>");B.prev().css({width:T.width(),height:B.height(),opacity:0,position:"absolute",left:B.css("left"),top:B.css("top")})}};if(k.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})}switch(k.window.effects.type){case "fade":B.fadeIn(k.window.effects.speed.show,M);break;case "slide":B.slideDown(k.window.effects.speed.show,
|
|
M);break;default:B.show(k.window.effects.speed.show,M)}},Bb=function(){var M=function(){k.window.expandable&&B.css({zIndex:10});!k.window.expandable||a.support.boxModel||B.prev().remove()};switch(k.window.effects.type){case "fade":B.fadeOut(k.window.effects.speed.hide,M);break;case "slide":B.slideUp(k.window.effects.speed.hide,M);break;default:B.hide(k.window.effects.speed.hide,M)}},xb=function(){var M=k.window,T=M.expandable?a(d).next().find(".Container:first"):null;B=M.expandable?a("<div/>"):a(d);
|
|
B.addClass("jPicker Container");M.expandable&&B.hide();B.get(0).onselectstart=function(Sa){if(Sa.target.nodeName.toLowerCase()!=="input")return false};var ea=la.active.val("all");if(M.alphaPrecision<0)M.alphaPrecision=0;else if(M.alphaPrecision>2)M.alphaPrecision=2;var Ga='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(M.expandable?'<tr><td class="Move" colspan="5"> </td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(M.title||ca.text.title)+'</h2><div class="Map"><span class="Map1"> </span><span class="Map2"> </span><span class="Map3"> </span><img src="'+
|
|
ka.clientPath+ka.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1"> </span><span class="Map2"> </span><span class="Map3"> </span><span class="Map4"> </span><span class="Map5"> </span><span class="Map6"> </span><img src="'+ka.clientPath+ka.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+ca.text.newColor+'<div class="color_preview"><span class="Active" title="'+ca.tooltips.colors.newColor+
|
|
'"> </span><span class="Current" title="'+ca.tooltips.colors.currentColor+'"> </span></div></div>'+ca.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+ca.text.ok+'" title="'+ca.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+ca.text.cancel+'" title="'+ca.tooltips.buttons.cancel+'"/><div class="Grid"> </div></td></tr><tr class="Hue"><td class="Radio"><label title="'+ca.tooltips.hue.radio+'"><input type="radio" value="h"'+
|
|
(k.color.mode=="h"?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.h:"")+'" title="'+ca.tooltips.hue.textbox+'"/> \u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+ca.tooltips.saturation.radio+'"><input type="radio" value="s"'+(k.color.mode=="s"?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.s:"")+'" title="'+ca.tooltips.saturation.textbox+
|
|
'"/> %</td></tr><tr class="Value"><td class="Radio"><label title="'+ca.tooltips.value.radio+'"><input type="radio" value="v"'+(k.color.mode=="v"?' checked="checked"':"")+'/>V:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.v:"")+'" title="'+ca.tooltips.value.textbox+'"/> %<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="'+ca.tooltips.red.radio+'"><input type="radio" value="r"'+(k.color.mode=="r"?' checked="checked"':"")+'/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+
|
|
(ea!=null?ea.r:"")+'" title="'+ca.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+ca.tooltips.green.radio+'"><input type="radio" value="g"'+(k.color.mode=="g"?' checked="checked"':"")+'/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.g:"")+'" title="'+ca.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+ca.tooltips.blue.radio+'"><input type="radio" value="b"'+(k.color.mode=="b"?' checked="checked"':
|
|
"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.b:"")+'" title="'+ca.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(M.alphaSupport?'<label title="'+ca.tooltips.alpha.radio+'"><input type="radio" value="a"'+(k.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":" ")+'</td><td class="Text">'+(M.alphaSupport?'<input type="text" maxlength="'+(3+M.alphaPrecision)+'" value="'+(ea!=null?Math.precision(ea.a*100/255,M.alphaPrecision):
|
|
"")+'" title="'+ca.tooltips.alpha.textbox+'"/> %':" ")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ca.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(ea!=null?ea.hex:"")+'"/></label>'+(M.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(ea!=null?ea.ahex.substring(6):"")+'" title="'+ca.tooltips.hex.alpha+'"/></td>':" ")+"</tr></tbody></table>";if(M.expandable){B.html(Ga);a(document.body).children("div.jPicker.Container").length==
|
|
0?a(document.body).prepend(B):a(document.body).children("div.jPicker.Container:last").after(B);B.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})});B.css({left:M.position.x=="left"?T.offset().left-530-(M.position.y=="center"?25:0)+"px":M.position.x=="center"?T.offset().left-260+"px":M.position.x=="right"?T.offset().left-10+(M.position.y=="center"?25:0)+"px":M.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":T.offset().left+parseInt(M.position.x)+
|
|
"px",position:"absolute",top:M.position.y=="top"?T.offset().top-312+"px":M.position.y=="center"?T.offset().top-156+"px":M.position.y=="bottom"?T.offset().top+25+"px":T.offset().top+parseInt(M.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Pa=o.find("span"),Za=K.find("span");U=Pa.filter(".Map1:first");P=Pa.filter(".Map2:first");J=Pa.filter(".Map3:first");R=Za.filter(".Map1:first");W=Za.filter(".Map2:first");O=Za.filter(".Map3:first");
|
|
ha=Za.filter(".Map4:first");oa=Za.filter(".Map5:first");ga=Za.filter(".Map6:first");ba=new p(o,{map:{width:ka.colorMap.width,height:ka.colorMap.height},arrow:{image:ka.clientPath+ka.colorMap.arrow.file,width:ka.colorMap.arrow.width,height:ka.colorMap.arrow.height}});ba.bind(wa);Y=new p(K,{map:{width:ka.colorBar.width,height:ka.colorBar.height},arrow:{image:ka.clientPath+ka.colorBar.arrow.file,width:ka.colorBar.arrow.width,height:ka.colorBar.arrow.height}});Y.bind(Ha);ta=new g(Ga,la.active,M.expandable&&
|
|
M.bindToInput?M.input:null,M.alphaPrecision);Pa=ea!=null?ea.hex:null;var gb=Ga.find(".Preview");Za=Ga.find(".Button");pa=gb.find(".Active:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});ra=gb.find(".Current:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"}).bind("click",Da);xa.call(d,ra,Math.precision(la.current.val("a")*100)/255,4);na=Za.find(".Ok:first").bind("click touchstart",sb);ma=Za.find(".Cancel:first").bind("click touchstart",kb);Ca=Za.find(".Grid:first");setTimeout(function(){Ya.call(d,
|
|
U,ka.clientPath+"Maps.png");Ya.call(d,P,ka.clientPath+"Maps.png");Ya.call(d,J,ka.clientPath+"map-opacity.png");Ya.call(d,R,ka.clientPath+"Bars.png");Ya.call(d,W,ka.clientPath+"Bars.png");Ya.call(d,O,ka.clientPath+"Bars.png");Ya.call(d,ha,ka.clientPath+"Bars.png");Ya.call(d,oa,ka.clientPath+"bar-opacity.png");Ya.call(d,ga,ka.clientPath+"AlphaBar.png");Ya.call(d,gb.find("div:last"),ka.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Va);if(la.quickList&&la.quickList.length>
|
|
0){Za="";for(i=0;i<la.quickList.length;i++){if((typeof la.quickList[i]).toString().toLowerCase()=="string")la.quickList[i]=new b({hex:la.quickList[i]});var pb=la.quickList[i].val("a"),Ra=la.quickList[i].val("ahex");if(!M.alphaSupport&&Ra)Ra=Ra.substring(0,6)+"ff";var rb=la.quickList[i].val("hex");Za+='<span class="QuickColor"'+(Ra&&' title="#'+Ra+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+ka.clientPath+"NoColor.png)")+(M.alphaSupport&&pb&&pb<255?";opacity:"+
|
|
Math.precision(pb/255,4)+";filter:Alpha(opacity="+Math.precision(pb/2.55,4)+")":"")+'"> </span>'}Ya.call(d,Ca,ka.clientPath+"bar-opacity.png");Ca.html(Za);Ca.find(".QuickColor").click(wb)}Oa.call(d,k.color.mode);la.active.bind(Ea);a.isFunction(hb)&&la.active.bind(hb);la.current.bind(cb);if(M.expandable){d.icon=T.parents(".Icon:first");Ja=d.icon.find(".Color:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});Ka=d.icon.find(".Alpha:first");Ya.call(d,Ka,ka.clientPath+"bar-opacity.png");xa.call(d,
|
|
Ka,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Fa=d.icon.find(".Image:first").css({backgroundImage:"url('"+ka.clientPath+ka.picker.file+"')"}).bind("click",$a);if(M.bindToInput&&M.updateInputColor)M.input.css({backgroundColor:Pa&&"#"+Pa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ia=Ga.find(".Move:first").bind("mousedown",ua);la.active.bind(Cb)}else tb.call(d)},ka=k.images,ca=k.localization,la={active:(typeof k.color.active).toString().toLowerCase()=="string"?new b({ahex:!k.window.alphaSupport&&
|
|
k.color.active?k.color.active.substring(0,6)+"ff":k.color.active}):new b({ahex:!k.window.alphaSupport&&k.color.active.val("ahex")?k.color.active.val("ahex").substring(0,6)+"ff":k.color.active.val("ahex")}),current:(typeof k.color.active).toString().toLowerCase()=="string"?new b({ahex:!k.window.alphaSupport&&k.color.active?k.color.active.substring(0,6)+"ff":k.color.active}):new b({ahex:!k.window.alphaSupport&&k.color.active.val("ahex")?k.color.active.val("ahex").substring(0,6)+"ff":k.color.active.val("ahex")}),
|
|
quickList:k.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:hb,cancelCallback:qb,color:la,show:tb,hide:Bb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);ra.unbind("click touchstart",Da);ma.unbind("click touchstart",kb);na.unbind("click touchstart",sb);if(k.window.expandable){Fa.unbind("click",$a);Ia.unbind("mousedown",ua);d.icon=null}B.find(".QuickColor").unbind("click",wb);ga=oa=ha=O=W=R=J=P=U=K=o=null;ba.destroy();ba=null;Y.destroy();Y=null;ta.destroy();
|
|
hb=qb=ob=Ca=ma=na=ra=pa=ta=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){xb.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new b({ahex:"#ffcc00ff"}),quickList:[new b({h:360,s:33,v:100}),new b({h:360,s:66,v:100}),new b({h:360,s:100,v:100}),
|
|
new b({h:360,s:100,v:75}),new b({h:360,s:100,v:50}),new b({h:180,s:0,v:100}),new b({h:30,s:33,v:100}),new b({h:30,s:66,v:100}),new b({h:30,s:100,v:100}),new b({h:30,s:100,v:75}),new b({h:30,s:100,v:50}),new b({h:180,s:0,v:90}),new b({h:60,s:33,v:100}),new b({h:60,s:66,v:100}),new b({h:60,s:100,v:100}),new b({h:60,s:100,v:75}),new b({h:60,s:100,v:50}),new b({h:180,s:0,v:80}),new b({h:90,s:33,v:100}),new b({h:90,s:66,v:100}),new b({h:90,s:100,v:100}),new b({h:90,s:100,v:75}),new b({h:90,s:100,v:50}),
|
|
new b({h:180,s:0,v:70}),new b({h:120,s:33,v:100}),new b({h:120,s:66,v:100}),new b({h:120,s:100,v:100}),new b({h:120,s:100,v:75}),new b({h:120,s:100,v:50}),new b({h:180,s:0,v:60}),new b({h:150,s:33,v:100}),new b({h:150,s:66,v:100}),new b({h:150,s:100,v:100}),new b({h:150,s:100,v:75}),new b({h:150,s:100,v:50}),new b({h:180,s:0,v:50}),new b({h:180,s:33,v:100}),new b({h:180,s:66,v:100}),new b({h:180,s:100,v:100}),new b({h:180,s:100,v:75}),new b({h:180,s:100,v:50}),new b({h:180,s:0,v:40}),new b({h:210,
|
|
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",
|
|
newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press “OK” 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 “Hue” Color Mode",textbox:"Enter A “Hue” Value (0-360°)"},saturation:{radio:"Set To “Saturation” Color Mode",textbox:"Enter A “Saturation” Value (0-100%)"},
|
|
value:{radio:"Set To “Value” Color Mode",textbox:"Enter A “Value” Value (0-100%)"},red:{radio:"Set To “Red” Color Mode",textbox:"Enter A “Red” Value (0-255)"},green:{radio:"Set To “Green” Color Mode",textbox:"Enter A “Green” Value (0-255)"},blue:{radio:"Set To “Blue” Color Mode",textbox:"Enter A “Blue” Value (0-255)"},alpha:{radio:"Set To “Alpha” Color Mode",textbox:"Enter A “Alpha” Value (0-100)"},
|
|
hex:{textbox:"Enter A “Hex” Color Value (#000000-#ffffff)",alpha:"Enter A “Alpha” Value (#00-#ff)"}}}}})(jQuery,"1.1.6");(function(a){function p(n){var s=n||window.event,c=[].slice.call(arguments,1),f=0,d=0,k=0;n=a.event.fix(s);n.type="mousewheel";if(s.wheelDelta)f=s.wheelDelta/120;if(s.detail)f=-s.detail/3;k=f;if(s.axis!==undefined&&s.axis===s.HORIZONTAL_AXIS){k=0;d=-1*f}if(s.wheelDeltaY!==undefined)k=s.wheelDeltaY/120;if(s.wheelDeltaX!==undefined)d=-1*s.wheelDeltaX/120;c.unshift(n,f,d,k);return(a.event.dispatch||a.event.handle).apply(this,c)}var g=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var b=g.length;b;)a.event.fixHooks[g[--b]]=
|
|
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=g.length;n;)this.addEventListener(g[--n],p,false);else this.onmousewheel=p},teardown:function(){if(this.removeEventListener)for(var n=g.length;n;)this.removeEventListener(g[--n],p,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){var p=svgEditor.canvas,g=svgedit.history.ChangeElementCommand,b={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},n=function(s,c,f){var d=null;if(s.indexOf("url(#")===0){s=(s=p.getRefElem(s))?s.cloneNode(true):$("#"+f+"_color defs *")[0];d={alpha:c};d[s.tagName]=s}else d=s.indexOf("#")===0?{alpha:c,solidColor:s.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(s){var c=p.getMode(),f=s.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;s.selectedElements=s.selectedElements.filter(Boolean);if(s.selectedElements.length){if($.inArray(s.selectedElements.nodeName,["g","use"])==-1){var d={},k=function(B,
|
|
o,K){d[o]=B.getAttribute(o);B.setAttribute(o,K)},q=new a.BatchCommand;s.selectedElements.forEach(function(B){b.fillPaint&&k(B,"fill",b.fillPaint);b.fillOpacity&&k(B,"fill-opacity",b.fillOpacity);b.strokePaint&&k(B,"stroke",b.strokePaint);b.strokeOpacity&&k(B,"stroke-opacity",b.strokeOpacity);b.strokeWidth&&k(B,"stroke-width",b.strokeWidth);b.strokeDashArray&&k(B,"stroke-dasharray",b.strokeDashArray);b.opacity&&k(B,"opacity",b.opacity);b.strokeLinecap&&k(B,"stroke-linecap",b.strokeLinecap);b.strokeLinejoin&&
|
|
k(B,"stroke-linejoin",b.strokeLinejoin);q.addSubCommand(new g(B,d));d={}});s=n(b.fillPaint,b.fillOpacity*100,"fill");c=n(b.strokePaint,b.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);p.undoMgr.addCommandToHistory(q)}}else{s=n(b.fillPaint,b.fillOpacity*100,"fill");c=n(b.strokePaint,b.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.setPaint(s);svgEditor.paintBox.stroke.setPaint(c)}}}}});svgEditor.addExtension("view_grid",function(a){function p(d){c.attr("width");c.attr("height");var k=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],q=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var B=n;k=k*d;var o=100/k,K=1;for(d=0;d<q.length;d++){var U=q[d];K=U;if(o<=U)break}q=K*k;B.width=q;B.height=q;k=B.getContext("2d");o=q/10;k.globalAlpha=0.2;k.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(o*d)+0.5;k.moveTo(K,q);k.lineTo(K,0);k.moveTo(q,K);k.lineTo(0,K)}k.stroke();
|
|
k.beginPath();k.globalAlpha=0.5;k.moveTo(0.5,q);k.lineTo(0.5,0);k.moveTo(q,0.5);k.lineTo(0,0.5);k.stroke();B=B.toDataURL("image/png");f.setAttribute("width",q);f.setAttribute("height",q);f.parentNode.setAttribute("width",q);f.parentNode.setAttribute("height",q);svgCanvas.setHref(f,B)}if(!document.getElementById("canvasGrid")){var g=document.getElementById("svgcanvas").ownerDocument,b=false;a=a.assignAttributes;var n=document.createElement("canvas");$(n).hide().appendTo("body");var s=g.createElementNS("http://www.w3.org/2000/svg",
|
|
"g");a(s,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var c=$("#canvas_background");c.after(s);s=g.createElementNS("http://www.w3.org/2000/svg","pattern");a(s,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var f=g.createElementNS("http://www.w3.org/2000/svg","image");a(f,{x:0,y:0,width:100,height:100});s.appendChild(f);$("#svgroot defs").append(s);g=g.createElementNS("http://www.w3.org/2000/svg","rect");a(g,{width:"100%",height:"100%",
|
|
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(g)}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(P){var J=o[P];if(J){K=J;J.buttons.length||g(P,J);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+P+".json",function(R){K=o[P]={data:R.data,size:R.size,fill:R.fill};g(P,R);a()})}}function g(P,J){var R=K.size||300,W=K.fill||false,O=R*0.05;O=[-O,-O,R+O*2,R+O*2].join(" ");R=W?0:R/30;R=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
|
|
O+'"><path fill="#333" stroke="transparent" stroke-width="'+R+'" /></svg></svg>',"text/xml");R.documentElement.setAttribute("width",40);R.documentElement.setAttribute("height",40);W=$(document.importNode(R.documentElement,true));var ha=J.data;K.buttons=[];for(var oa in ha){var ga=ha[oa],ba=W.clone();if(ga.charAt(ga.length-1)=="x"){R=32;O=R*0.05;O=[-O,-O,R+O*2,R+O*2].join(" ");ba.find("svg").attr("viewBox",O);ga.replace("x","")}ba.find("path").attr("d",ga);R=ba.wrap('<div class="tool_button">').parent().attr({id:U+
|
|
"_"+oa,title:oa});K.buttons.push(R[0])}}var b,n,s=svgEditor.canvas,c,f,d,k=s.getRootElem(),q={},B={basic:"Basic",object:"Objects",symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather & Time",ui:"User Interface",social:"Social Web"},o={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",
|
|
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",
|
|
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=o.basic,U="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(){s.setMode(U)}}}],callback:function(){var P=
|
|
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(P);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(W){W=$(W.target).closest("div.tool_button");if(W.length){var O=W.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(O).attr("data-curopt","#"+W[0].id).mouseup();s.setMode(U);n=W[0].id.substr((U+"_").length);b=K.data[n];$(".tools_flyout").fadeOut()}});P=$('<div id="shape_cats">');var R="";$.each(B,function(W,
|
|
O){R+="<div data-cat="+W+">"+O+"</div>"});P.html(R).children().bind("mouseup",function(){var W=$(this);W.siblings().removeClass("current");W.addClass("current");p(W.attr("data-cat"));return false});P.children().eq(0).addClass("current");$("#tools_shapelib").prepend(P);J.mouseup(function(){s.setMode(b?U:"select")});$("#tool_shapelib").remove();P=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(P/2),"margin-left":3})},mouseDown:function(P){if(s.getMode()===U){var J=f=P.start_x;
|
|
P=d=P.start_y;var R=s.getStyle();c=s.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:b,id:s.getNextId(),opacity:R.opacity/2,style:"pointer-events:none"}});c.setAttribute("d",b);if(/[a-z]/.test(b)){b=K.data[n]=s.pathActions.convertPath(c);c.setAttribute("d",b);s.pathActions.fixEnd(c)}c.setAttribute("transform","translate("+J+","+P+") scale(0.005) translate("+-J+","+-P+")");s.recalculateDimensions(c);s.getTransformList(c);q=c.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(P){if(s.getMode()===
|
|
U){var J=s.getZoom(),R=P.event,W=P.mouse_x/J,O=P.mouse_y/J;P=s.getTransformList(c);var ha=c.getBBox();J=ha.x;var oa=ha.y,ga=ha.width,ba=ha.height,Y=W-f,ta=O-d,ja={x:Math.min(f,W),y:Math.min(d,O),width:Math.abs(W-f),height:Math.abs(O-d)},da=ha=0;ba=ba?(ba+ta)/ba:1;ga=ga?(ga+Y)/ga:1;ga=ja.width/q.width;ba=ja.height/q.height;ga=ga||1;ba=ba||1;if(W<f)ha=q.width;if(O<d)da=q.height;W=k.createSVGTransform();O=k.createSVGTransform();ja=k.createSVGTransform();W.setTranslate(-(J+ha),-(oa+da));if(R.shiftKey){replaced=
|
|
true;R=Math.min(Math.abs(ga),Math.abs(ba));ga=R*(ga<0?-1:1);ba=R*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){R=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;ga*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=R}}totalScale.sx*=ga;totalScale.sy*=ba;O.setScale(ga,ba);ja.setTranslate(J+ha,oa+da);P.appendItem(ja);P.appendItem(O);P.appendItem(W);s.recalculateDimensions(c);q=c.getBBox()}},mouseUp:function(P){if(s.getMode()===U){if(P.mouse_x==f&&P.mouse_y==d)return{keep:false,
|
|
element:c,started:false};s.setMode("select");return{keep:true,element:c,started:false}}}}});(function(){for(var a=0,p=["ms","moz","webkit","o"],g=0;g<p.length&&!window.requestAnimationFrame;++g){window.requestAnimationFrame=window[p[g]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[p[g]+"CancelAnimationFrame"]||window[p[g]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var n=(new Date).getTime(),s=Math.max(0,16-(n-a)),c=window.setTimeout(function(){b(n+s)},s);a=n+s;return c};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
|
|
function(b){clearTimeout(b)}})();(function(a){function p(o){var K=o.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){c.call(this,o);o=a(this);o.bind(q,g);o.bind(k,b)}else{clearTimeout(B);s.call(this)}}function g(o){if(B!=null){var K=o.originalEvent;o=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var U=a(this).data("taphold.point");o=o-U.x;K=K-U.y;if(Math.sqrt(o*o+K*K)>d){clearTimeout(B);s.call(this)}}}function b(){clearTimeout(B);s.call(this)}
|
|
function n(o){s.call(this);a(this).data("taphold.handler").call(this,o)}function s(){B=null;a(this).unbind(q,g);a(this).unbind(k,b)}function c(o){if(B==null){var K=this;B=setTimeout(function(){n.call(K,o)},f);var U=o.originalEvent,P={};P.x=U.changedTouches?U.changedTouches[0].pageX:U.pageX;P.y=U.changedTouches?U.changedTouches[0].pageY:U.pageY;a(this).data("taphold.point",P)}}var f=1E3,d=5,k="touchend",q="touchmove",B=null;a.event.special.taphold={setup:function(){},add:function(o){a(this).data("taphold.handler",
|
|
o.handler);o.data?a(this).bind("touchstart",o.data,p):a(this).bind("touchstart",p)},remove:function(o){clearTimeout(B);s.call(this);o.data?a(this).unbind("touchstart",o.data,p):a(this).unbind("touchstart",p)},teardown:function(){}}})(jQuery);
|