715 lines
363 KiB
JavaScript
715 lines
363 KiB
JavaScript
(function(a){function o(f){if(typeof f.data==="string"){var c=f.handler,m=f.data.toLowerCase().split(" ");f.handler=function(p){if(!(this!==p.target&&(/textarea|select/i.test(p.target.nodeName)||p.target.type==="text"))){var b=p.type!=="keypress"&&a.hotkeys.specialKeys[p.which],d=String.fromCharCode(p.which).toLowerCase(),e="",l={};if(p.altKey&&b!=="alt")e+="alt+";if(p.ctrlKey&&b!=="ctrl")e+="ctrl+";if(p.metaKey&&!p.ctrlKey&&b!=="meta")e+="meta+";if(p.shiftKey&&b!=="shift")e+="shift+";if(b)l[e+b]=
|
|
true;else{l[e+d]=true;l[e+a.hotkeys.shiftNums[d]]=true;if(e==="shift+")l[a.hotkeys.shiftNums[d]]=true}b=0;for(d=m.length;b<d;b++)if(l[m[b]])return c.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
|
|
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:o}})})(jQuery);(function(a,o){function f(da){return typeof da==="string"}function c(da){var Y=e.call(arguments,1);return function(){return da.apply(this,Y.concat(e.call(arguments)))}}function m(da,Y,V,ma,ua){var ga;if(ma!==d){Y=V.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);V=Y[3]||"";if(ua===2&&f(ma))ma=ma.replace(da?ba:Z,"");else{ga=n(Y[2]);ma=f(ma)?n[da?R:Q](ma):ma;ma=ua===2?ma:ua===1?a.extend({},ma,ga):a.extend({},ga,ma);ma=q(ma);if(da)ma=ma.replace(ka,l)}da=Y[1]+(da?"#":ma||!Y[1]?"?":"")+ma+V}else da=
|
|
Y(V!==d?V:o[ha][W]);return da}function p(da,Y,V){if(Y===d||typeof Y==="boolean"){V=Y;Y=q[da?R:Q]()}else Y=f(Y)?Y.replace(da?ba:Z,""):Y;return n(Y,V)}function b(da,Y,V,ma){if(!f(V)&&typeof V!=="object"){ma=V;V=Y;Y=d}return this.each(function(){var ua=a(this),ga=Y||ea()[(this.nodeName||"").toLowerCase()]||"",qa=ga&&ua.attr(ga)||"";ua.attr(ga,q[da](qa,V,ma))})}var d,e=Array.prototype.slice,l=decodeURIComponent,q=a.param,u,n,I,S=a.bbq=a.bbq||{},O,H,ea,X=a.event.special,Q="querystring",R="fragment",ha=
|
|
"location",W="href",Z=/^.*\?|#.*$/g,ba=/^.*\#/,ka,la={};q[Q]=c(m,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[R]=u=c(m,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});u.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);ka=RegExp(da.join("|"),"g")};u.noEscape(",/");a.deparam=n=function(da,Y){var V={},ma={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(ua,ga){var qa=ga.split("="),Ga=l(qa[0]),Ma=V,Ra=
|
|
0,Qa=Ga.split("]["),Va=Qa.length-1;if(/\[/.test(Qa[0])&&/\]$/.test(Qa[Va])){Qa[Va]=Qa[Va].replace(/\]$/,"");Qa=Qa.shift().split("[").concat(Qa);Va=Qa.length-1}else Va=0;if(qa.length===2){qa=l(qa[1]);if(Y)qa=qa&&!isNaN(qa)?+qa:qa==="undefined"?d:ma[qa]!==d?ma[qa]:qa;if(Va)for(;Ra<=Va;Ra++){Ga=Qa[Ra]===""?Ma.length:Qa[Ra];Ma=Ma[Ga]=Ra<Va?Ma[Ga]||(Qa[Ra+1]&&isNaN(Qa[Ra+1])?{}:[]):qa}else if(a.isArray(V[Ga]))V[Ga].push(qa);else V[Ga]=V[Ga]!==d?[V[Ga],qa]:qa}else if(Ga)V[Ga]=Y?d:""});return V};n[Q]=c(p,
|
|
0);n[R]=I=c(p,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(la,da)})({a:W,base:W,iframe:"src",img:"src",input:"src",form:"action",link:W,script:"src"});ea=a.elemUrlAttr;a.fn[Q]=c(b,Q);a.fn[R]=c(b,R);S.pushState=O=function(da,Y){if(f(da)&&/^#/.test(da)&&Y===d)Y=2;var V=da!==d;V=u(o[ha][W],V?da:{},V?Y:2);o[ha][W]=V+(/#/.test(V)?"":"#")};S.getState=H=function(da,Y){return da===d||typeof da==="boolean"?I(da):I(Y)[da]};S.removeState=function(da){var Y={};if(da!==d){Y=H();a.each(a.isArray(da)?
|
|
da:arguments,function(V,ma){delete Y[ma]})}O(Y,2)};X.hashchange=a.extend(X.hashchange,{add:function(da){function Y(ma){var ua=ma[R]=u();ma.getState=function(ga,qa){return ga===d||typeof ga==="boolean"?n(ua,ga):n(ua,qa)[ga]};V.apply(this,arguments)}var V;if(a.isFunction(da)){V=da;return Y}else{V=da.handler;da.handler=Y}}})})(jQuery,this);
|
|
(function(a,o,f){function c(u){u=u||o[b][d];return u.replace(/^[^#]*#?(.*)$/,"$1")}var m,p=a.event.special,b="location",d="href",e=document.documentMode,l=a.browser.msie&&(e===f||e<8),q="onhashchange"in o&&!l;a.hashchangeDelay=100;p.hashchange=a.extend(p.hashchange,{setup:function(){if(q)return false;a(m.start)},teardown:function(){if(q)return false;a(m.stop)}});m=function(){function u(){O=H=function(ea){return ea};if(l){S=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
|
|
H=function(){return c(S.document[b][d])};O=function(ea,X){if(ea!==X){var Q=S.document;Q.open().close();Q[b].hash="#"+ea}};O(c())}}var n={},I,S,O,H;n.start=function(){if(!I){var ea=c();O||u();(function X(){var Q=c(),R=H(ea);if(Q!==ea){O(ea=Q,R);a(o).trigger("hashchange")}else if(R!==ea)o[b][d]=o[b][d].replace(/#.*/,"")+"#"+R;I=setTimeout(X,a.hashchangeDelay)})()}};n.stop=function(){if(!S){I&&clearTimeout(I);I=0}};return n}()})(jQuery,this);(function(a){var o={},f;a.svgIcons=function(c,m){function p(da,Y){if(da!=="ajax"){if(ea)return;var V=(S=W[0].contentDocument)&&S.getElementById("svg_eof");if(!V&&!(Y&&V)){X++;if(X<50)setTimeout(p,20);else{d();ea=true}return}ea=true}I=a(S.firstChild).children();if(m.no_img)setTimeout(function(){H||b()},500);else{V=ha+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:V,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
|
|
function b(da,Y){if(!H){if(m.no_img)da=false;if(da){var V=a(document.createElement("div"));V.hide().appendTo("body")}if(Y){var ma=m.fallback_path?m.fallback_path:"";a.each(Y,function(Va,Xa){a("#"+Va);var Na=a(new Image).attr({"class":"svg_icon",src:ma+Xa,width:u,height:n,alt:"icon"});la(Na,Va)})}else for(var ua=I.length,ga=0;ga<ua;ga++){var qa=I[ga],Ga=qa.id;if(Ga==="svg_eof")break;a("#"+Ga);qa=qa.getElementsByTagNameNS(l,"svg")[0];var Ma=document.createElementNS(l,"svg");Ma.setAttributeNS(l,"viewBox",
|
|
[0,0,u,n].join(" "));var Ra=qa.getAttribute("width"),Qa=qa.getAttribute("height");qa.removeAttribute("width");qa.removeAttribute("height");qa.getAttribute("viewBox")||qa.setAttribute("viewBox",[0,0,Ra,Qa].join(" "));Ma.setAttribute("xmlns",l);Ma.setAttribute("width",u);Ma.setAttribute("height",n);Ma.setAttribute("xmlns:xlink",q);Ma.setAttribute("class","svg_icon");R||(qa=qa.cloneNode(true));Ma.appendChild(qa);if(da){R||Ma.cloneNode(true);V.empty().append(Ma);qa=ha+e(V.html());qa=a(new Image).attr({"class":"svg_icon",
|
|
src:qa})}else qa=f(a(Ma),ga);la(qa,Ga)}m.placement&&a.each(m.placement,function(Va,Xa){o[Xa]&&a(Va).each(function(Na){var Ha=o[Xa].clone();if(Na>0&&!da)Ha=f(Ha,Na,true);ka(a(this),Ha,Xa)})});if(!Y){da&&V.remove();W&&W.remove();O&&O.remove()}m.resize&&a.resizeSvgIcons(m.resize);H=true;m.callback&&m.callback(o)}}function d(){if(c.indexOf(".svgz")!=-1){var da=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,m)}else m.fallback&&b(false,m.fallback)}
|
|
function e(da){if(window.btoa)return window.btoa(da);var Y=Array(Math.floor((da.length+2)/3)*4),V,ma,ua,ga,qa,Ga,Ma=0,Ra=0;do{V=da.charCodeAt(Ma++);ma=da.charCodeAt(Ma++);ua=da.charCodeAt(Ma++);ga=V>>2;V=(V&3)<<4|ma>>4;qa=(ma&15)<<2|ua>>6;Ga=ua&63;if(isNaN(ma))qa=Ga=64;else if(isNaN(ua))Ga=64;Y[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ga);Y[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(V);Y[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(qa);
|
|
Y[Ra++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Ga)}while(Ma<da.length);return Y.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",u=m.w?m.w:24,n=m.h?m.h:24,I,S,O,H=false,ea=false,X=0,Q=navigator.userAgent,R=!!window.opera;Q.indexOf("Safari/")>-1&&Q.indexOf("Chrome/");var ha="data:image/svg+xml;charset=utf-8;base64,";if(m.svgz){var W=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{S=W[0].contentDocument;W.load(p);
|
|
p(0,true)}catch(Z){d()}}else{var ba=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){S=ba.parseFromString(da,"text/xml");a(function(){p("ajax")})}else a(d)},error:function(da){if(window.opera)a(function(){d()});else if(da.responseText){S=ba.parseFromString(da.responseText,"text/xml");S.childNodes.length||a(d);a(function(){p("ajax")})}else a(d)}})}var ka=function(da,Y,V,ma){R&&Y.css("visibility","hidden");if(m.replace){ma&&Y.attr("id",V);(V=da.attr("class"))&&Y.attr("class",
|
|
"svg_icon "+V);da.replaceWith(Y)}else da.append(Y);R&&setTimeout(function(){Y.removeAttr("style")},1)},la=function(da,Y){if(m.id_match===undefined||m.id_match!==false)ka(holder,da,Y,true);o[Y]=da};f=function(da,Y){var V=da.find("defs");if(!V.length)return da;V=R?V.find("*").filter(function(){return!!this.id}):V.find("[id]");var ma=da[0].getElementsByTagName("*"),ua=ma.length;V.each(function(ga){var qa=this.id;a(S).find("#"+qa);this.id=ga="x"+qa+Y+ga;qa="url(#"+qa+")";var Ga="url(#"+ga+")";for(ga=
|
|
0;ga<ua;ga++){var Ma=ma[ga];Ma.getAttribute("fill")===qa&&Ma.setAttribute("fill",Ga);Ma.getAttribute("stroke")===qa&&Ma.setAttribute("stroke",Ga);Ma.getAttribute("filter")===qa&&Ma.setAttribute("filter",Ga)}});return da}};a.getSvgIcon=function(c,m){var p=o[c];if(m&&p)p=f(p,0,true).clone(true);return p};a.resizeSvgIcons=function(c){var m=!a(".svg_icon:first").length;a.each(c,function(p,b){var d=a.isArray(b),e=d?b[0]:b,l=d?b[1]:b;if(m)p=p.replace(/\.svg_icon/g,"svg");a(p).each(function(){this.setAttribute("width",
|
|
e);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=e+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(c,m,p){c=document.createElementNS(o.svg,c);if(f)for(var b in m)c.setAttribute(b,m[b]);else for(b in m){var d=m[b],e=c[b];if(e&&e.constructor==="SVGLength")e.baseVal.value=d;else c.setAttribute(b,d)}p&&p.appendChild(c);return c}var o={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(c){c=c||{};this.alpha=isNaN(c.alpha)?100:c.alpha;if(c.copy){this.type=
|
|
c.copy.type;this.alpha=c.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=c.copy.solidColor;break;case "linearGradient":this.linearGradient=c.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=c.copy.radialGradient.cloneNode(true)}}else if(c.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=c.linearGradient.cloneNode(true)}else if(c.radialGradient){this.type=
|
|
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=c.radialGradient.cloneNode(true)}else if(c.solidColor){this.type="solidColor";this.solidColor=c.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var f=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(c){var m=
|
|
arguments;return this.each(function(){function p(ra,ia,va,P,J){var fa=J||a("stop",{"stop-color":ia,"stop-opacity":va,offset:ra},ba);if(J){ia=J.getAttribute("stop-color");va=J.getAttribute("stop-opacity");ra=J.getAttribute("offset")}else ba.appendChild(fa);if(va===null)va=1;J=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+ra*R)+", 26)"},Ja);var Oa=
|
|
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ia,"fill-opacity":va,transform:"translate("+(10+ra*R)+", 26)",stroke:"#000","stroke-width":1.5},Ja);$(Oa).mousedown(function(Za){b(this);$a=tb;ea.mousemove(l).mouseup(d);Da=Jb.offset();Za.preventDefault();return false}).data("stop",fa).data("bg",J).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Za=this,fb=+fa.getAttribute("stop-opacity")||
|
|
1,wb=fa.getAttribute("stop-color")||1,xb=(parseFloat(fb)*255).toString(16);xb.length<2;)xb="0"+xb;ia=wb.substr(1)+xb;$("#"+n+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:u.images.clientPath},color:{active:ia,alphaSupport:true}},function(Db){wb=Db.val("hex")?"#"+Db.val("hex"):"none";fb=Db.val("a")!==null?Db.val("a")/256:1;Za.setAttribute("fill",wb);Za.setAttribute("fill-opacity",fb);fa.setAttribute("stop-color",
|
|
wb);fa.setAttribute("stop-opacity",fb);$("div.jGraduate_LightBox").hide();$("#"+n+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+n+"_jGraduate_stopPicker").hide()})});$(ba).find("stop").each(function(){var Za=$(this);if(+this.getAttribute("offset")>ra){if(!ia){var fb=this.getAttribute("stop-color"),wb=this.getAttribute("stop-opacity");fa.setAttribute("stop-color",fb);Oa.setAttribute("fill",fb);fa.setAttribute("stop-opacity",wb===null?1:wb);Oa.setAttribute("fill-opacity",
|
|
wb===null?1:wb)}Za.before(fa);return false}});P&&b(Oa);return fa}function b(ra){tb&&tb.setAttribute("stroke","#000");ra.setAttribute("stroke","blue");tb=ra;tb.parentNode.appendChild(tb)}function d(){ea.unbind("mousemove",l);if(Ka.getAttribute("display")!=="none"){Ka.setAttribute("display","none");var ra=$(tb),ia=ra.data("stop");ra=ra.data("bg");$([tb,ia,ra]).remove()}$a=null}function e(){var ra=Sa?"rotate("+Sa+","+gb+","+Ia+") ":"";yb===1&&bb===1?ba.removeAttribute("gradientTransform"):ba.setAttribute("gradientTransform",
|
|
ra+"translate("+-gb*(yb-1)+","+-Ia*(bb-1)+") scale("+yb+","+bb+")")}function l(ra){var ia=ra.pageX-Da.left;ra=ra.pageY-Da.top;ia=ia<10?10:ia>R+10?R+10:ia;var va="translate("+ia+", 26)";if(ra<-60||ra>130){Ka.setAttribute("display","block");Ka.setAttribute("transform",va)}else Ka.setAttribute("display","none");$a.setAttribute("transform",va);$.data($a,"bg").setAttribute("transform",va);$.data($a,"stop").setAttribute("offset",(ia-10)/R);var P=0;$(ba).find("stop").each(function(){var J=this.getAttribute("offset"),
|
|
fa=$(this);if(J<P){fa.prev().before(fa);zb=$(ba).find("stop")}P=J})}var q=$(this),u=$.extend(true,{},jQuery.fn.jGraduateDefaults,c),n=q.attr("id"),I="#"+q.attr("id")+" ";if(I){var S=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},O=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
|
|
q.hide()};$.extend(true,q,{paint:new $.jGraduate.Paint({copy:u.paint}),okCallback:$.isFunction(m[1])&&m[1]||null,cancelCallback:$.isFunction(m[2])&&m[2]||null});q.position();var H=null,ea=$(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="'+
|
|
n+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var X=$(I+"> .jGraduate_colPick"),Q=$(I+"> .jGraduate_gradPick");Q.html('<div id="'+n+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+u.window.pickerTitle+'</h2><div id="'+n+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+n+'_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="'+
|
|
n+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+n+'_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="'+n+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
|
|
n+'_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="'+n+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+n+'_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="'+
|
|
n+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+n+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+n+'_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="'+
|
|
n+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+n+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+u.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+n+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+n+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+
|
|
n+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+u.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+n+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+n+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+n+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+u.images.clientPath+
|
|
'rangearrows2.gif"></div><label><input type="text" id="'+n+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba </label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+n+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+n+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+u.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+n+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
|
|
n+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+n+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var R=256,ha=R-0,W=R-0,Z,ba,ka,la={};$(".jGraduate_SliderBar").width(145);var da=$("#"+n+"_jGraduate_GradContainer")[0],Y=a("svg",{id:n+"_jgraduate_svg",width:R,height:R,xmlns:o.svg},da);Z=Z||q.paint.type;var V=ba=q.paint[Z],ma=q.paint.alpha,ua=Z==="solidColor";switch(Z){case "solidColor":case "linearGradient":if(!ua){ba.id=n+"_lg_jgraduate_grad";V=
|
|
ba=Y.appendChild(ba)}a("radialGradient",{id:n+"_rg_jgraduate_grad"},Y);if(Z==="linearGradient")break;case "radialGradient":if(!ua){ba.id=n+"_rg_jgraduate_grad";V=ba=Y.appendChild(ba)}a("linearGradient",{id:n+"_lg_jgraduate_grad"},Y)}if(ua){V=ba=$("#"+n+"_lg_jgraduate_grad")[0];H=q.paint[Z];p(0,"#"+H,1);var ga=typeof u.newstop;if(ga==="string")switch(u.newstop){case "same":p(1,"#"+H,1);break;case "inverse":ga="";for(var qa=0;qa<6;qa+=2){H.substr(qa,2);var Ga=(255-parseInt(H.substr(qa,2),16)).toString(16);
|
|
if(Ga.length<2)Ga=0+Ga;ga+=Ga}p(1,"#"+ga,1);break;case "white":p(1,"#ffffff",1);break;case "black":p(1,"#000000",1)}else if(ga==="object")p(1,u.newstop.color||"#"+H,"opac"in u.newstop?u.newstop.opac:1)}H=parseFloat(V.getAttribute("x1")||0);ga=parseFloat(V.getAttribute("y1")||0);qa=parseFloat(V.getAttribute("x2")||1);Ga=parseFloat(V.getAttribute("y2")||0);var Ma=parseFloat(V.getAttribute("cx")||0.5),Ra=parseFloat(V.getAttribute("cy")||0.5),Qa=parseFloat(V.getAttribute("fx")||Ma),Va=parseFloat(V.getAttribute("fy")||
|
|
Ra);ka=a("rect",{id:n+"_jgraduate_rect",x:0,y:0,width:ha,height:W,fill:"url(#"+n+"_jgraduate_grad)","fill-opacity":ma/100},Y);var Xa=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ga*R,left:H*R}).data("coord","start").appendTo(da),Na=Xa.clone().text(2).css({top:Ga*R,left:qa*R}).attr("title","End stop").data("coord","end").appendTo(da),Ha=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ra*R,left:Ma*
|
|
R}).data("coord","center").appendTo(da),Pa=Ha.clone().text("F").css({top:Va*R,left:Qa*R,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Pa[0].id=n+"_jGraduate_focusCoord";$(I+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ra,ia){var va=ba.getAttribute(ia),P=isNaN(ia[1]);va||(va=P?"0.5":ia==="x2"?"1.0":"0.0");la[ia]=$("#"+n+"_jGraduate_"+ia).val(va).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
|
|
1)this.value=1;if(!(ia[0]==="f"&&!jb))if(P&&Z==="radialGradient"||!P&&Z==="linearGradient")ba.setAttribute(ia,this.value);var J=P?ia[0]==="c"?Ha:Pa:ia[1]==="1"?Xa:Na,fa=ia.indexOf("x")>=0?"left":"top";J.css(fa,this.value*R)}).change()});var zb,Ja,Jb=$("#"+n+"_jGraduate_StopSlider"),tb,ab,$a,Ka=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},ab),Da,yb=1,bb=1,Sa=0,gb=Ma,Ia=Ra;ab=a("svg",{width:"100%",height:45},Jb[0]);da=a("pattern",{width:16,
|
|
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ab);a("image",{width:16,height:16},da).setAttributeNS(o.xlink,"xlink:href",u.images.clientPath+"map-opacity.png");$(ab).click(function(ra){Da=Jb.offset();if(ra.target.tagName!=="path"){var ia=ra.pageX-Da.left-8;ia=ia<10?10:ia>R+10?R+10:ia;p(ia/R,0,0,true);ra.stopPropagation()}});$(ab).mouseover(function(){ab.appendChild(Ka)});Ja=a("g",{},ab);a("line",{x1:10,y1:15,x2:R+10,y2:15,"stroke-width":2,stroke:"#000"},ab);var rb=Q.find(".jGraduate_spreadMethod").change(function(){ba.setAttribute("spreadMethod",
|
|
$(this).val())}),sb=null,mb=function(ra){var ia=ra.pageX-Wa.left,va=ra.pageY-Wa.top;ia=ia<0?0:ia>R?R:ia;va=va<0?0:va>R?R:va;sb.css("left",ia).css("top",va);ia/=ha;va/=W;var P=sb.data("coord"),J=ba;switch(P){case "start":la.x1.val(ia);la.y1.val(va);J.setAttribute("x1",ia);J.setAttribute("y1",va);break;case "end":la.x2.val(ia);la.y2.val(va);J.setAttribute("x2",ia);J.setAttribute("y2",va);break;case "center":la.cx.val(ia);la.cy.val(va);J.setAttribute("cx",ia);J.setAttribute("cy",va);gb=ia;Ia=va;e();
|
|
break;case "focus":la.fx.val(ia);la.fy.val(va);J.setAttribute("fx",ia);J.setAttribute("fy",va);e()}ra.preventDefault()},hb=function(){sb=null;ea.unbind("mousemove",mb).unbind("mouseup",hb)};zb=ba.getElementsByTagNameNS(o.svg,"stop");if(La<2){for(;La<2;){ba.appendChild(document.createElementNS(o.svg,"stop"));++La}zb=ba.getElementsByTagNameNS(o.svg,"stop")}var La=zb.length;for(qa=0;qa<La;qa++)p(0,0,0,0,zb[qa]);rb.val(ba.getAttribute("spreadMethod")||"pad");var Wa,jb=false;ka.setAttribute("fill-opacity",
|
|
ma/100);$("#"+n+" div.grad_coord").mousedown(function(ra){ra.preventDefault();sb=$(this);sb.offset();Wa=sb.parent().offset();ea.mousemove(mb).mouseup(hb)});$("#"+n+"_jGraduate_Ok").bind("click",function(){q.paint.type=Z;q.paint[Z]=ba.cloneNode(true);q.paint.solidColor=null;S()});$("#"+n+"_jGraduate_Cancel").bind("click",function(){O()});if(Z==="radialGradient")if(jb)Pa.show();else{Pa.hide();la.fx.val("");la.fy.val("")}$("#"+n+"_jGraduate_match_ctr")[0].checked=!jb;var Eb,Fb;$("#"+n+"_jGraduate_match_ctr").change(function(){jb=
|
|
!this.checked;Pa.toggle(jb);la.fx.val("");la.fy.val("");var ra=ba;if(jb){var ia=Eb||0.5,va=Fb||0.5;ra.setAttribute("fx",ia);ra.setAttribute("fy",va);la.fx.val(ia);la.fy.val(va)}else{Eb=ra.getAttribute("fx");Fb=ra.getAttribute("fy");ra.removeAttribute("fx");ra.removeAttribute("fy")}});zb=ba.getElementsByTagNameNS(o.svg,"stop");La=zb.length;if(La<2){for(;La<2;){ba.appendChild(document.createElementNS(o.svg,"stop"));++La}zb=ba.getElementsByTagNameNS(o.svg,"stop")}var nb;ma=Q=0;if(Z==="radialGradient"){Y=
|
|
ba.gradientTransform.baseVal;if(Y.numberOfItems===2){La=Y.getItem(0);Y=Y.getItem(1);if(La.type===2&&Y.type===3){La=Y.matrix;if(La.a!==1)Q=Math.round(-(1-La.a)*100);else if(La.d!==1)Q=Math.round((1-La.d)*100)}}else if(Y.numberOfItems===3){da=Y.getItem(0);La=Y.getItem(1);Y=Y.getItem(2);if(da.type===4&&La.type===2&&Y.type===3){ma=Math.round(da.angle);La=Y.matrix;if(La.a!==1)Q=Math.round(-(1-La.a)*100);else if(La.d!==1)Q=Math.round((1-La.d)*100)}}}Q={radius:{handle:"#"+n+"_jGraduate_RadiusArrows",input:"#"+
|
|
n+"_jGraduate_RadiusInput",val:(ba.getAttribute("r")||0.5)*100},opacity:{handle:"#"+n+"_jGraduate_OpacArrows",input:"#"+n+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+n+"_jGraduate_EllipArrows",input:"#"+n+"_jGraduate_EllipInput",val:Q},angle:{handle:"#"+n+"_jGraduate_AngleArrows",input:"#"+n+"_jGraduate_AngleInput",val:ma}};$.each(Q,function(ra,ia){var va=$(ia.handle);va.mousedown(function(P){var J=va.parent();nb={type:ra,elem:va,input:$(ia.input),parent:J,offset:J.offset()};
|
|
ea.mousemove(Gb).mouseup(Ob);P.preventDefault()});$(ia.input).val(ia.val).change(function(){var P=+this.value,J=0,fa=Z==="radialGradient";switch(ra){case "radius":fa&&ba.setAttribute("r",P/100);J=Math.pow(P/100,0.4)/2*145;break;case "opacity":q.paint.alpha=P;ka.setAttribute("fill-opacity",P/100);J=P*1.45;break;case "ellip":yb=bb=1;if(P===0){J=72.5;break}if(P>99.5)P=99.5;if(P>0)bb=1-P/100;else yb=-(P/100)-1;J=145*((P+100)/2)/100;fa&&e();break;case "angle":Sa=P;J=Sa/180;J+=0.5;J*=145;fa&&e()}if(J>145)J=
|
|
145;else if(J<0)J=0;va.css({"margin-left":J-5})}).change()});var Gb=function(ra){var ia=ra.pageX-nb.offset.left-parseInt(nb.parent.css("border-left-width"));if(ia>145)ia=145;if(ia<=0)ia=0;var va=ia-5;ia/=145;switch(nb.type){case "radius":ia=Math.pow(ia*2,2.5);if(ia>0.98&&ia<1.02)ia=1;if(ia<=0.01)ia=0.01;ba.setAttribute("r",ia);break;case "opacity":q.paint.alpha=parseInt(ia*100);ka.setAttribute("fill-opacity",ia);break;case "ellip":bb=yb=1;if(ia<0.5){ia/=0.5;yb=ia<=0?0.01:ia}else if(ia>0.5){ia/=0.5;
|
|
ia=2-ia;bb=ia<=0?0.01:ia}e();ia-=1;if(bb===ia+1)ia=Math.abs(ia);break;case "angle":ia-=0.5;Sa=ia*=180;e();ia/=100}nb.elem.css({"margin-left":va});ia=Math.round(ia*100);nb.input.val(ia);ra.preventDefault()},Ob=function(){ea.unbind("mousemove",Gb).unbind("mouseup",Ob);nb=null};for(Q=(q.paint.alpha*255/100).toString(16);Q.length<2;)Q="0"+Q;Q=Q.split(".")[0];H=q.paint.solidColor=="none"?"":q.paint.solidColor+Q;ua||(H=zb[0].getAttribute("stop-color"));$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,
|
|
effects:{type:"show",speed:0}});X.jPicker({window:{title:u.window.pickerTitle},images:{clientPath:u.images.clientPath},color:{active:H,alphaSupport:true}},function(ra){q.paint.type="solidColor";q.paint.alpha=ra.val("ahex")?Math.round(ra.val("a")/255*100):100;q.paint.solidColor=ra.val("hex")?ra.val("hex"):"none";q.paint.radialGradient=null;S()},null,function(){O()});var Kb=$(I+" .jGraduate_tabs li");Kb.click(function(){Kb.removeClass("jGraduate_tab_current");$(this).addClass("jGraduate_tab_current");
|
|
$(I+" > div").hide();var ra=$(this).attr("data-type");$(I+" .jGraduate_gradPick").show();if(ra==="rg"||ra==="lg"){$(".jGraduate_"+ra+"_field").show();$(".jGraduate_"+(ra==="lg"?"rg":"lg")+"_field").hide();$("#"+n+"_jgraduate_rect")[0].setAttribute("fill","url(#"+n+"_"+ra+"_jgraduate_grad)");Z=ra==="lg"?"linearGradient":"radialGradient";$("#"+n+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ia=$("#"+n+"_"+ra+"_jgraduate_grad")[0];if(ba!==ia){var va=$(ba).find("stop");$(ia).empty().append(va);
|
|
ba=ia;ia=rb.val();ba.setAttribute("spreadMethod",ia)}jb=ra==="rg"&&ba.getAttribute("fx")!=null&&!(Ma==Qa&&Ra==Va);$("#"+n+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+n+"_jGraduate_match_ctr")[0].checked=false}else{$(I+" .jGraduate_gradPick").hide();$(I+" .jGraduate_colPick").show()}});$(I+" > div").hide();Kb.removeClass("jGraduate_tab_current");var Ub;switch(q.paint.type){case "linearGradient":Ub=$(I+" .jGraduate_tab_lingrad");break;case "radialGradient":Ub=$(I+" .jGraduate_tab_radgrad");break;
|
|
default:Ub=$(I+" .jGraduate_tab_color")}q.show();setTimeout(function(){Ub.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();$.fn.SpinButton=function(a){function o(f,c){for(var m=f[c],p=document.body;(f=f.offsetParent)&&f!=p;)if(!$.browser.msie||f.currentStyle.position!="relative")m+=f[c];return m}return this.each(function(){this.repeating=false;this.spinCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&a.step?Number(a.step):1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,upClass:a&&a.upClass?a.upClass:"up",downClass:a&&a.downClass?
|
|
a.downClass:"down",reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.spinCfg.smallStep=a&&a.smallStep?a.smallStep:this.spinCfg.step/2;this.adjustValue=function(f){f=isNaN(this.value)?this.spinCfg.reset:$.isFunction(this.spinCfg.stepfunc)?this.spinCfg.stepfunc(this,f):Number((Number(this.value)+Number(f)).toFixed(5));if(this.spinCfg.min!==
|
|
null)f=Math.max(f,this.spinCfg.min);if(this.spinCfg.max!==null)f=Math.min(f,this.spinCfg.max);this.value=f;$.isFunction(this.spinCfg.callback)&&this.spinCfg.callback(this)};$(this).addClass(a&&a.spinClass?a.spinClass:"spin-button").mousemove(function(f){var c=f.pageX||f.x,m=f.pageY||f.y;f=f.target||f.srcElement;var p=svgEditor.tool_scale||1,b=$(f).height()/2;c=c>o(f,"offsetLeft")+f.offsetWidth*p-this.spinCfg._btn_width?m<o(f,"offsetTop")+b*p?1:-1:0;if(c!==this.spinCfg._direction){switch(c){case 1:$(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);
|
|
break;case -1:$(this).removeClass(this.spinCfg.upClass).addClass(this.spinCfg.downClass);break;default:$(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass)}this.spinCfg._direction=c}}).mouseout(function(){$(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);this.spinCfg._direction=null;window.clearInterval(this.spinCfg._repeat);window.clearTimeout(this.spinCfg._delay)}).mousedown(function(f){if(f.button===0&&this.spinCfg._direction!=0){var c=this,
|
|
m=f.shiftKey?c.spinCfg.smallStep:c.spinCfg.step,p=function(){c.adjustValue(c.spinCfg._direction*m)};p();c.spinCfg._delay=window.setTimeout(function(){p();c.spinCfg._repeat=window.setInterval(p,c.spinCfg.interval)},c.spinCfg.delay)}}).mouseup(function(){window.clearInterval(this.spinCfg._repeat);window.clearTimeout(this.spinCfg._delay)}).dblclick(function(){$.browser.msie&&this.adjustValue(this.spinCfg._direction*this.spinCfg.step)}).keydown(function(f){switch(f.keyCode){case 38:this.adjustValue(this.spinCfg.step);
|
|
break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page)}}).keypress(function(f){if(this.repeating)switch(f.keyCode){case 38:this.adjustValue(this.spinCfg.step);break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page)}else this.repeating=true}).keyup(function(f){this.repeating=false;switch(f.keyCode){case 38:case 40:case 33:case 34:case 13:this.adjustValue(0)}}).bind("mousewheel",
|
|
function(f){if(f.wheelDelta>=120)this.adjustValue(this.spinCfg.step);else f.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step);f.preventDefault()}).change(function(){this.adjustValue(0)});this.addEventListener&&this.addEventListener("DOMMouseScroll",function(f){if(f.detail>0)this.adjustValue(-this.spinCfg.step);else f.detail<0&&this.adjustValue(this.spinCfg.step);f.preventDefault()},false)})};function touchHandler(a){var o=a.changedTouches,f=o[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var m=document.createEvent("MouseEvent");m.initMouseEvent(c,true,true,window,1,f.screenX,f.screenY,f.clientX,f.clientY,false,false,false,false,0,null);if(o.length<2){f.target.dispatchEvent(m);a.preventDefault()}};jQuery&&function(){var a=$(window),o=$(document);$.extend($.fn,{contextMenu:function(f,c){if(f.menu==undefined)return false;if(f.inSpeed==undefined)f.inSpeed=150;if(f.outSpeed==undefined)f.outSpeed=75;if(f.inSpeed==0)f.inSpeed=-1;if(f.outSpeed==0)f.outSpeed=-1;$(this).each(function(){var m=$(this),p=$(m).offset(),b=$("#"+f.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).mouseup(function(e){var l=$(this);l.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||f.allowLeft||
|
|
d.ctrlKey&&svgedit.browser.isMac()){e.stopPropagation();if(m.hasClass("disabled")||d.altKey)return false;var q=e.pageX,u=e.pageY;e=a.width()-b.width();var n=a.height()-b.height();if(q>e-15)q=e-15;if(u>n-30)u=n-30;o.unbind("click");b.css({top:u,left:q}).fadeIn(f.inSpeed);b.find("A").mouseover(function(){b.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){b.find("LI.hover").removeClass("hover")});o.keypress(function(I){switch(I.keyCode){case 38:if(b.find("LI.hover").length){b.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");
|
|
b.find("LI.hover").length||b.find("LI:last").addClass("hover")}else b.find("LI:last").addClass("hover");break;case 40:if(b.find("LI.hover").length==0)b.find("LI:first").addClass("hover");else{b.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");b.find("LI.hover").length||b.find("LI:first").addClass("hover")}break;case 13:b.find("LI.hover A").trigger("click");break;case 27:o.trigger("click")}});b.find("A").unbind("mouseup");b.find("LI:not(.disabled) A").mouseup(function(){o.unbind("click").unbind("keypress");
|
|
$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),$(l),{x:q-p.left,y:u-p.top,docX:q,docY:u});return false});setTimeout(function(){o.click(function(){o.unbind("click").unbind("keypress");b.fadeOut(f.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+f.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+f.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+f.menu).each(function(){$(this).bind("mousedown.disableTextSelect",
|
|
function(){return false})});$(m).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(f){if(f==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(f!=undefined)for(var c=f.split(","),m=0;m<c.length;m++)$(this).find('A[href="'+c[m]+'"]').parent().addClass("disabled")});return $(this)},enableContextMenuItems:function(f){if(f==undefined){$(this).find("LI.disabled").removeClass("disabled");return $(this)}$(this).each(function(){if(f!=
|
|
undefined)for(var c=f.split(","),m=0;m<c.length;m++)$(this).find('A[href="'+c[m]+'"]').parent().removeClass("disabled")});return $(this)},disableContextMenu:function(){$(this).each(function(){$(this).addClass("disabled")});return $(this)},enableContextMenu:function(){$(this).each(function(){$(this).removeClass("disabled")});return $(this)},destroyContextMenu:function(){$(this).each(function(){$(this).unbind("mousedown").unbind("mouseup")});return $(this)}})}(jQuery);var svgedit=svgedit||{};
|
|
(function(){if(!svgedit.browser)svgedit.browser={};var a=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;svgedit.browser.supportsSvg=function(){return a};if(svgedit.browser.supportsSvg()){var o=navigator.userAgent,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),c=!!window.opera,m=o.indexOf("AppleWebKit")>=0,p=o.indexOf("Gecko/")>=0,b=o.indexOf("MSIE")>=0,d=o.indexOf("Chrome/")>=0,e=o.indexOf("Windows")>=0,l=o.indexOf("Macintosh")>=
|
|
0,q="ontouchstart"in window,u=!!f.querySelector,n=!!document.evaluate,I=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","path");ha.setAttribute("d","M0,0 10,10");var W=ha.pathSegList;ha=ha.createSVGPathSegLinetoAbs(5,5);try{W.replaceItem(ha,0);return true}catch(Z){}return false}(),S=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","path");ha.setAttribute("d","M0,0 10,10");var W=ha.pathSegList;ha=ha.createSVGPathSegLinetoAbs(5,5);try{W.insertItemBefore(ha,
|
|
0);return true}catch(Z){}return false}(),O=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","svg"),W=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(ha);W.setAttribute("x",5);ha.appendChild(W);var Z=document.createElementNS("http://www.w3.org/2000/svg","text");Z.textContent="a";W.appendChild(Z);W=Z.getStartPositionOfChar(0).x;document.documentElement.removeChild(ha);return W===0}(),H=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg",
|
|
"svg");document.documentElement.appendChild(ha);var W=document.createElementNS("http://www.w3.org/2000/svg","path");W.setAttribute("d","M0,0 C0,0 10,10 10,0");ha.appendChild(W);W=W.getBBox();document.documentElement.removeChild(ha);return W.height>4&&W.height<5}(),ea=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(ha);var W=document.createElementNS("http://www.w3.org/2000/svg","path");W.setAttribute("d","M0,0 10,0");var Z=document.createElementNS("http://www.w3.org/2000/svg",
|
|
"path");Z.setAttribute("d","M5,0 15,0");var ba=document.createElementNS("http://www.w3.org/2000/svg","g");ba.appendChild(W);ba.appendChild(Z);ha.appendChild(ba);W=ba.getBBox();document.documentElement.removeChild(ha);return W.width==15}(),X=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","rect");ha.setAttribute("x",0.1);(ha=ha.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 ha}(),Q=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","rect");ha.setAttribute("style","vector-effect:non-scaling-stroke");return ha.style.vectorEffect==="non-scaling-stroke"}(),R=function(){var ha=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,W=f.createSVGTransform();ha.appendItem(W);return ha.getItem(0)==W}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return m};svgedit.browser.isGecko=function(){return p};
|
|
svgedit.browser.isIE=function(){return b};svgedit.browser.isChrome=function(){return d};svgedit.browser.isWindows=function(){return e};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return u};svgedit.browser.supportsXpath=function(){return n};svgedit.browser.supportsPathReplaceItem=function(){return I};svgedit.browser.supportsPathInsertItemBefore=function(){return S};svgedit.browser.supportsPathBBox=function(){return H};
|
|
svgedit.browser.supportsHVLineContainerBBox=function(){return ea};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return X};svgedit.browser.supportsNonScalingStroke=function(){return Q};svgedit.browser.supportsNativeTransformLists=function(){return R}}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"),o={};svgedit.transformlist.SVGTransformList=function(f){this._elem=f||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();for(var m=0;m<this.numberOfItems;++m){var p=this._list.getItem(m);c=c;p=p;var b=p.matrix,d="";switch(p.type){case 1:d="matrix("+[b.a,b.b,b.c,b.d,b.e,b.f].join(",")+")";break;case 2:d="translate("+b.e+","+b.f+")";break;case 3:d=
|
|
b.a==b.d?"scale("+b.a+")":"scale("+b.a+","+b.d+")";break;case 4:var e=0;d=0;if(p.angle!=0){e=1-b.a;d=(e*b.f+b.b*b.e)/(e*e+b.b*b.b);e=(b.e-b.b*d)/e}d="rotate("+p.angle+" "+e+","+d+")"}c=c+(d+" ")}this._elem.setAttribute("transform",c)};this._list=this;this._init=function(){var c=this._elem.getAttribute("transform");if(c)for(var m=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,p=true;p;){p=c.match(m);c=c.replace(m,"");if(p&&p[1]){var b=p[1].split(/\s*\(/),d=b[0];b=b[1].match(/\s*(.*?)\s*\)/);
|
|
b[1]=b[1].replace(/(\d)-/g,"$1 -");var e=b[1].split(/[, ]+/),l="abcdef".split(""),q=a.createSVGMatrix();$.each(e,function(I,S){e[I]=parseFloat(S);if(d=="matrix")q[l[I]]=e[I]});b=a.createSVGTransform();var u="set"+d.charAt(0).toUpperCase()+d.slice(1),n=d=="matrix"?[q]:e;if(d=="scale"&&n.length==1)n.push(n[0]);else if(d=="translate"&&n.length==1)n.push(0);else if(d=="rotate"&&n.length==1){n.push(0);n.push(0)}b[u].apply(b,n);this._list.appendItem(b)}}};this._removeFromOtherLists=function(c){if(c){var m=
|
|
false,p;for(p in o){for(var b=o[p],d=0,e=b._xforms.length;d<e;++d)if(b._xforms[d]==c){m=true;b.removeItem(d);break}if(m)break}}};this.numberOfItems=0;this.clear=function(){this.numberOfItems=0;this._xforms=[]};this.initialize=function(c){this.numberOfItems=1;this._removeFromOtherLists(c);this._xforms=[c]};this.getItem=function(c){if(c<this.numberOfItems&&c>=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,m){var p=null;if(m>=0)if(m<this.numberOfItems){this._removeFromOtherLists(c);
|
|
p=Array(this.numberOfItems+1);for(var b=0;b<m;++b)p[b]=this._xforms[b];p[b]=c;for(var d=b+1;b<this.numberOfItems;++d,++b)p[d]=this._xforms[b];this.numberOfItems++;this._xforms=p;p=c;this._list._update()}else p=this._list.appendItem(c);return p};this.replaceItem=function(c,m){var p=null;if(m<this.numberOfItems&&m>=0){this._removeFromOtherLists(c);p=this._xforms[m]=c;this._list._update()}return p};this.removeItem=function(c){if(c<this.numberOfItems&&c>=0){for(var m=this._xforms[c],p=Array(this.numberOfItems-
|
|
1),b=0;b<c;++b)p[b]=this._xforms[b];for(c=b;c<this.numberOfItems-1;++c,++b)p[c]=this._xforms[b+1];this.numberOfItems--;this._xforms=p;this._list._update();return m}else throw{code:1};};this.appendItem=function(c){this._removeFromOtherLists(c);this._xforms.push(c);this.numberOfItems++;this._list._update();return c}};svgedit.transformlist.resetListMap=function(){o={}};svgedit.transformlist.removeElementFromListMap=function(f){f.id&&o[f.id]&&delete o[f.id]};svgedit.transformlist.getTransformList=function(f){if(svgedit.browser.supportsNativeTransformLists())if(f.transform)return f.transform.baseVal;
|
|
else if(f.gradientTransform)return f.gradientTransform.baseVal;else{if(f.patternTransform)return f.patternTransform.baseVal}else{var c=f.id;c||(c="temp");var m=o[c];if(!m||c=="temp"){o[c]=new svgedit.transformlist.SVGTransformList(f);o[c]._init();m=o[c]}return m}return null}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.math)svgedit.math={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg");svgedit.math.transformPoint=function(o,f,c){return{x:c.a*o+c.c*f+c.e,y:c.b*o+c.d*f+c.f}};svgedit.math.isIdentity=function(o){return o.a===1&&o.b===0&&o.c===0&&o.d===1&&o.e===0&&o.f===0};svgedit.math.matrixMultiply=function(){for(var o=arguments,f=o.length,c=o[f-1];f-- >1;)c=o[f-1].multiply(c);if(Math.abs(c.a)<1.0E-14)c.a=0;if(Math.abs(c.b)<1.0E-14)c.b=0;if(Math.abs(c.c)<1.0E-14)c.c=0;if(Math.abs(c.d)<
|
|
1.0E-14)c.d=0;if(Math.abs(c.e)<1.0E-14)c.e=0;if(Math.abs(c.f)<1.0E-14)c.f=0;return c};svgedit.math.hasMatrixTransform=function(o){if(!o)return false;for(var f=o.numberOfItems;f--;){var c=o.getItem(f);if(c.type==1&&!svgedit.math.isIdentity(c.matrix))return true}return false};svgedit.math.transformBox=function(o,f,c,m,p){var b={x:o,y:f},d={x:o+c,y:f};c={x:o+c,y:f+m};o={x:o,y:f+m};f=svgedit.math.transformPoint;b=f(b.x,b.y,p);var e=m=b.x,l=b.y,q=b.y;d=f(d.x,d.y,p);m=Math.min(m,d.x);e=Math.max(e,d.x);
|
|
l=Math.min(l,d.y);q=Math.max(q,d.y);o=f(o.x,o.y,p);m=Math.min(m,o.x);e=Math.max(e,o.x);l=Math.min(l,o.y);q=Math.max(q,o.y);c=f(c.x,c.y,p);m=Math.min(m,c.x);e=Math.max(e,c.x);l=Math.min(l,c.y);q=Math.max(q,c.y);return{tl:b,tr:d,bl:o,br:c,aabox:{x:m,y:l,width:e-m,height:q-l}}};svgedit.math.transformListToTransform=function(o,f,c){if(o==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());f=f==undefined?0:f;c=c==undefined?o.numberOfItems-1:c;f=parseInt(f);c=parseInt(c);if(f>c){var m=c;c=f;
|
|
f=m}m=a.createSVGMatrix();for(f=f;f<=c;++f){var p=f>=0&&f<o.numberOfItems?o.getItem(f).matrix:a.createSVGMatrix();m=svgedit.math.matrixMultiply(m,p)}return a.createSVGTransformFromMatrix(m)};svgedit.math.getMatrix=function(o){o=svgedit.transformlist.getTransformList(o);return svgedit.math.transformListToTransform(o).matrix};svgedit.math.snapToAngle=function(o,f,c,m){var p=Math.PI/4;c=c-o;var b=m-f;m=Math.sqrt(c*c+b*b);p=Math.round(Math.atan2(b,c)/p)*p;return{x:o+m*Math.cos(p),y:f+m*Math.sin(p),a:p}};
|
|
svgedit.math.rectsIntersect=function(o,f){return f.x<o.x+o.width&&f.x+f.width>o.x&&f.y<o.y+o.height&&f.y+f.height>o.y}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],o=["y","y1","cy","ry","height"],f=$.merge(["r","radius"],a);$.merge(f,o);var c,m={px:1};svgedit.units.init=function(b){c=b;b=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(b);var d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("width","1em");d.setAttribute("height","1ex");d.setAttribute("x","1in");b.appendChild(d);d=d.getBBox();document.body.removeChild(b);
|
|
b=d.x;m.em=d.width;m.ex=d.height;m["in"]=b;m.cm=b/2.54;m.mm=b/25.4;m.pt=b/72;m.pc=b/6;m["%"]=0};svgedit.units.getTypeMap=function(){return m};svgedit.units.shortFloat=function(b){var d=c.getRoundDigits();if(isNaN(b)){if($.isArray(b))return svgedit.units.shortFloat(b[0])+","+svgedit.units.shortFloat(b[1])}else return+(+b).toFixed(d);return parseFloat(b).toFixed(d)-0};svgedit.units.convertUnit=function(b,d){d=d||c.getBaseUnit();return svgedit.unit.shortFloat(b/m[d])};svgedit.units.setUnitAttr=function(b,
|
|
d,e){isNaN(e)||b.getAttribute(d);b.setAttribute(d,e)};var p={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(b){var d=b.tagName,e=c.getBaseUnit();if(d=p[d])for(var l=d.length,q=0;q<l;q++){var u=d[q],n=b.getAttribute(u);if(n)isNaN(n)||b.setAttribute(u,n/m[e]+e)}};svgedit.units.convertToNum=
|
|
function(b,d){if(!isNaN(d))return d-0;if(d.substr(-1)==="%"){var e=d.substr(0,d.length-1)/100,l=c.getWidth(),q=c.getHeight();return a.indexOf(b)>=0?e*l:o.indexOf(b)>=0?e*q:e*Math.sqrt(l*l+q*q)/Math.sqrt(2)}else{l=d.substr(-2);e=d.substr(0,d.length-2);return e*m[l]}};svgedit.units.isValidUnit=function(b,d,e){var l=false;if(f.indexOf(b)>=0)if(isNaN(d)){d=d.toLowerCase();$.each(m,function(n){if(!l)if(RegExp("^-?[\\d\\.]+"+n+"$").test(d))l=true})}else l=true;else if(b=="id"){b=false;try{var q=c.getElement(d);
|
|
b=q==null||q===e}catch(u){}return b}else l=true;return l}})();svgedit=svgedit||{};
|
|
(function(){function a(b){if(svgedit.browser.supportsHVLineContainerBBox())try{return b.getBBox()}catch(d){}var e=$.data(b,"ref"),l=null;if(e){var q=$(e).children().clone().attr("visibility","hidden");$(p).append(q);l=q.filter("line, path")}else l=$(b).find("line, path");var u=false;if(l.length){l.each(function(){var n=this.getBBox();if(!n.width||!n.height)u=true});if(u){b=e?q:$(b).children();ret=getStrokedBBox(b)}else ret=b.getBBox()}else ret=b.getBBox();e&&q.remove();return ret}if(!svgedit.utilities)svgedit.utilities=
|
|
{};var o="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),f=null,c=null,m=null,p=null;svgedit.utilities.init=function(b){f=b;c=b.getDOMDocument();m=b.getDOMContainer();p=b.getSVGRoot()};svgedit.utilities.toXml=function(b){return $("<p/>").text(b).html()};svgedit.utilities.fromXml=function(b){return $("<p/>").html(b).text()};svgedit.utilities.encode64=function(b){b=svgedit.utilities.convertToXMLReferences(b);if(window.btoa)return window.btoa(b);
|
|
var d=Array(Math.floor((b.length+2)/3)*4),e,l,q,u,n,I,S=0,O=0;do{e=b.charCodeAt(S++);l=b.charCodeAt(S++);q=b.charCodeAt(S++);u=e>>2;e=(e&3)<<4|l>>4;n=(l&15)<<2|q>>6;I=q&63;if(isNaN(l))n=I=64;else if(isNaN(q))I=64;d[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(u);d[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e);d[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(n);d[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(I)}while(S<
|
|
b.length);return d.join("")};svgedit.utilities.decode64=function(b){if(window.atob)return window.atob(b);var d="",e,l,q="",u,n="",I=0;b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(I++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(I++));u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(I++));n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(I++));
|
|
e=e<<2|l>>4;l=(l&15)<<4|u>>2;q=(u&3)<<6|n;d+=String.fromCharCode(e);if(u!=64)d+=String.fromCharCode(l);if(n!=64)d+=String.fromCharCode(q)}while(I<b.length);return unescape(d)};svgedit.utilities.convertToXMLReferences=function(b){for(var d="",e=0;e<b.length;e++){var l=b.charCodeAt(e);if(l<128)d+=b[e];else if(l>127)d+="&#"+l+";"}return d};svgedit.utilities.text2xml=function(b){if(b.indexOf("<svg:svg")>=0)b=b.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var d;try{var e=window.DOMParser?
|
|
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");e.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{d=e.loadXML?e.loadXML(b)?e:false:e.parseFromString(b,"text/xml")}catch(q){throw Error("Error parsing XML string");}return d};svgedit.utilities.bboxToObj=function(b){return{x:b.x,y:b.y,width:b.width,height:b.height}};svgedit.utilities.walkTree=function(b,d){if(b&&b.nodeType==1){d(b);for(var e=b.childNodes.length;e--;)svgedit.utilities.walkTree(b.childNodes.item(e),d)}};
|
|
svgedit.utilities.walkTreePost=function(b,d){if(b&&b.nodeType==1){for(var e=b.childNodes.length;e--;)svgedit.utilities.walkTree(b.childNodes.item(e),d);d(b)}};svgedit.utilities.getUrlFromAttr=function(b){if(b)if(b.indexOf('url("')===0)return b.substring(5,b.indexOf('"',6));else if(b.indexOf("url('")===0)return b.substring(5,b.indexOf("'",6));else if(b.indexOf("url(")===0)return b.substring(4,b.indexOf(")"));return null};svgedit.utilities.getHref=function(b){return b.getAttributeNS("http://www.w3.org/1999/xlink",
|
|
"href")};svgedit.utilities.setHref=function(b,d){b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d)};svgedit.utilities.findDefs=function(b){b=f.getSVGContent().documentElement;var d=b.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return d=d.length>0?d[0]:b.insertBefore(b.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),b.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(b){var d=b.pathSegList,e=d.numberOfItems;b=[[],[]];var l=d.getItem(0),
|
|
q=[l.x,l.y];for(l=0;l<e;l++){var u=d.getItem(l);if(typeof u.x!="undefined"){b[0].push(q[0]);b[1].push(q[1]);if(u.x1){for(var n=[u.x1,u.y1],I=[u.x2,u.y2],S=[u.x,u.y],O=0;O<2;O++){u=function(R){return Math.pow(1-R,3)*q[O]+3*Math.pow(1-R,2)*R*n[O]+3*(1-R)*Math.pow(R,2)*I[O]+Math.pow(R,3)*S[O]};var H=6*q[O]-12*n[O]+6*I[O],ea=-3*q[O]+9*n[O]-9*I[O]+3*S[O],X=3*n[O]-3*q[O];if(ea==0){if(H!=0){H=-X/H;0<H&&H<1&&b[O].push(u(H))}}else{X=Math.pow(H,2)-4*X*ea;if(!(X<0)){var Q=(-H+Math.sqrt(X))/(2*ea);0<Q&&Q<1&&
|
|
b[O].push(u(Q));H=(-H-Math.sqrt(X))/(2*ea);0<H&&H<1&&b[O].push(u(H))}}}q=S}else{b[0].push(u.x);b[1].push(u.y)}}}d=Math.min.apply(null,b[0]);e=Math.max.apply(null,b[0])-d;l=Math.min.apply(null,b[1]);b=Math.max.apply(null,b[1])-l;return{x:d,y:l,width:e,height:b}};svgedit.utilities.getBBox=function(b){var d=b||f.geSelectedElements()[0];if(b.nodeType!=1)return null;b=null;var e=d.nodeName;switch(e){case "text":if(d.textContent===""){d.textContent="a";b=d.getBBox();d.textContent=""}else try{b=d.getBBox()}catch(l){}break;
|
|
case "path":if(svgedit.browser.supportsPathBBox())try{b=d.getBBox()}catch(q){}else b=svgedit.utilities.getPathBBox(d);break;case "g":case "a":b=a(d);break;default:if(e==="use")b=a(d,true);if(e==="use"){b||(b=d.getBBox());if(!svgedit.browser.isWebkit()){e={};e.width=b.width;e.height=b.height;e.x=b.x+parseFloat(d.getAttribute("x")||0);e.y=b.y+parseFloat(d.getAttribute("y")||0);b=e}}else if(~o.indexOf(e))try{b=d.getBBox()}catch(u){d=$(d).closest("foreignObject");if(d.length)try{b=d[0].getBBox()}catch(n){b=
|
|
null}else b=null}}if(b)b=svgedit.utilities.bboxToObj(b);return b};svgedit.utilities.getRotationAngle=function(b,d){var e=b||f.getSelectedElements()[0];e=svgedit.transformlist.getTransformList(e);if(!e)return 0;for(var l=e.numberOfItems,q=0;q<l;++q){var u=e.getItem(q);if(u.type==4)return d?u.angle*Math.PI/180:u.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(b){return p.querySelector("#"+b)}:svgedit.browser.supportsXpath()?function(b){return c.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
|
|
b+'"]',m,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(b){return $(p).find("[id="+b+"]")[0]};svgedit.utilities.assignAttributes=function(b,d,e,l){e||(e=0);svgedit.browser.isOpera()||p.suspendRedraw(e);for(var q in d)if(e=q.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":q.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)b.setAttributeNS(e,q,d[q]);else l?svgedit.units.setUnitAttr(b,q,d[q]):b.setAttribute(q,d[q]);svgedit.browser.isOpera()||p.unsuspendRedraw(null)};
|
|
svgedit.utilities.cleanupElement=function(b){var d=p.suspendRedraw(60),e={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none","stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0},l;for(l in e){var q=e[l];b.getAttribute(l)==q&&b.removeAttribute(l)}p.unsuspendRedraw(d)}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a={};a["http://www.w3.org/1999/xlink"]="xlink";a["http://www.w3.org/XML/1998/namespace"]="xml";a["http://www.w3.org/2000/xmlns/"]="xmlns";a["http://svg-edit.googlecode.com"]="se";a["http://www.w3.org/1999/xhtml"]="xhtml";a["http://www.w3.org/1998/Math/MathML"]="mathml";var o={};$.each(a,function(m,p){o[p]=m});var f={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray",
|
|
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class",
|
|
"clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters",
|
|
"filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage",
|
|
"transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
|
|
"stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class",
|
|
"clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class",
|
|
"clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points",
|
|
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray",
|
|
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],
|
|
symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity",
|
|
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight",
|
|
"id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width",
|
|
"style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth",
|
|
"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},c={};$.each(f,function(m,p){var b={};$.each(p,function(d,e){if(e.indexOf(":")>=
|
|
0){var l=e.split(":");b[l[1]]=o[l[0]]}else b[e]=e=="xmlns"?"http://www.w3.org/2000/xmlns/":null});c[m]=b});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(m){if(m.nodeType==3){m.nodeValue=m.nodeValue.replace(/^\s+|\s+$/g,"");m.nodeValue.length||m.parentNode.removeChild(m)}if(m.nodeType==1){var p=m.parentNode;if(m.ownerDocument&&p){var b=f[m.nodeName],d=c[m.nodeName];if(b!=undefined){for(var e=[],l=m.attributes.length;l--;){var q=m.attributes.item(l),u=q.nodeName,
|
|
n=q.localName,I=q.namespaceURI;if(!(d.hasOwnProperty(n)&&I==d[n]&&I!="http://www.w3.org/2000/xmlns/")&&!(I=="http://www.w3.org/2000/xmlns/"&&a[q.nodeValue])){u.indexOf("se:")==0&&e.push([u,q.nodeValue]);m.removeAttributeNS(I,n)}if(svgedit.browser.isGecko())switch(u){case "transform":case "gradientTransform":case "patternTransform":n=q.nodeValue.replace(/(\d)-/g,"$1 -");m.setAttribute(u,n)}if(u=="style"){q=q.nodeValue.split(";");for(u=q.length;u--;){n=q[u].split(":");b.indexOf(n[0])>=0&&m.setAttribute(n[0],
|
|
n[1])}m.removeAttribute("style")}}$.each(e,function(S,O){m.setAttributeNS("http://svg-edit.googlecode.com",O[0],O[1])});if((l=svgedit.utilities.getHref(m))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(m.nodeName)>=0)if(l[0]!="#"){svgedit.utilities.setHref(m,"");m.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(m.nodeName=="use"&&!svgedit.utilities.getHref(m))p.removeChild(m);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start",
|
|
"mask","stroke"],function(S,O){var H=m.getAttribute(O);if(H)if((H=svgedit.utilities.getUrlFromAttr(H))&&H[0]!=="#"){m.setAttribute(O,"");m.removeAttribute(O)}});for(l=m.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(m.childNodes.item(l))}}else{for(b=[];m.hasChildNodes();)b.push(p.insertBefore(m.firstChild,m));p.removeChild(m);for(l=b.length;l--;)svgedit.sanitize.sanitizeSvg(b[l])}}}}})();svgedit=svgedit||{};
|
|
(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,o,f,c){this.elem=a;this.text=c?"Move "+a.tagName+" to "+c:"Move "+a.tagName;this.oldNextSibling=o;this.oldParent=f;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};svgedit.history.MoveElementCommand.prototype.type=
|
|
svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
|
|
this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,o){this.elem=a;this.text=o||"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,o,f,c){this.elem=a;this.text=c||"Delete "+a.tagName;this.nextSibling=o;this.parent=f;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};
|
|
svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
|
|
this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};
|
|
svgedit.history.ChangeElementCommand=function(a,o,f){this.elem=a;this.text=f?"Change "+a.tagName+" "+f:"Change "+a.tagName;this.newValues={};this.oldValues=o;for(var c in o)this.newValues[c]=c=="#text"?a.textContent:c=="#href"?svgedit.utilities.getHref(a):a.getAttribute(c)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=
|
|
function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var o=false,f;for(f in this.newValues){if(this.newValues[f])if(f=="#text")this.elem.textContent=this.newValues[f];else f=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[f]):this.elem.setAttribute(f,this.newValues[f]);else if(f=="#text")this.elem.textContent="";else{this.elem.setAttribute(f,"");this.elem.removeAttribute(f)}if(f==
|
|
"transform")o=true}if(!o)if(o=svgedit.utilities.getRotationAngle(this.elem)){f=elem.getBBox();o=["rotate(",o," ",f.x+f.width/2,",",f.y+f.height/2,")"].join("");o!=elem.getAttribute("transform")&&elem.setAttribute("transform",o)}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 o=false,f;for(f in this.oldValues){if(this.oldValues[f])if(f==
|
|
"#text")this.elem.textContent=this.oldValues[f];else f=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[f]):this.elem.setAttribute(f,this.oldValues[f]);else if(f=="#text")this.elem.textContent="";else this.elem.removeAttribute(f);if(f=="transform")o=true}if(!o)if(o=svgedit.utilities.getRotationAngle(this.elem)){f=elem.getBBox();o=["rotate(",o," ",f.x+f.width/2,",",f.y+f.height/2,")"].join("");o!=elem.getAttribute("transform")&&elem.setAttribute("transform",o)}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 o=this.stack.length,f=0;f<o;++f)this.stack[f].apply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.BatchCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);for(var o=this.stack.length-1;o>=0;o--)this.stack[o].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,
|
|
this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],o=this.stack.length;o--;)for(var f=this.stack[o].elements(),c=f.length;c--;)a.indexOf(f[c])==-1&&a.push(f[c]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=
|
|
-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():
|
|
""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""};svgedit.history.UndoManager.prototype.undo=function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};
|
|
svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,o){for(var f=++this.undoChangeStackPointer,c=o.length,m=Array(c),p=Array(c);c--;){var b=o[c];if(b!=null){p[c]=b;m[c]=b.getAttribute(a)}}this.undoableChangeStack[f]=
|
|
{attrName:a,oldValues:m,elements:p}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,o=this.undoableChangeStack[a],f=o.elements.length,c=o.attrName,m=new svgedit.history.BatchCommand("Change "+c);f--;){var p=o.elements[f];if(p!=null){var b={};b[c]=o.oldValues[f];b[c]!=p.getAttribute(c)&&m.addSubCommand(new svgedit.history.ChangeElementCommand(p,b,c))}}this.undoableChangeStack[a]=null;return m}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.select)svgedit.select={};var a,o,f;svgedit.select.Selector=function(c,m){this.id=c;this.selectedElement=m;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));this.gripCoords={nw:null,n:null,ne:null,e:null,
|
|
se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(c){this.locked=true;this.selectedElement=c;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(c){var m=[];c=Math.round(c/45);if(c<0)c+=8;for(var p in f.selectorGrips)m.push(p);for(;c>0;){m.push(m.shift());c--}c=0;for(p in f.selectorGrips){f.selectorGrips[p].setAttribute("style","cursor:"+m[c]+"-resize");c++}};
|
|
svgedit.select.Selector.prototype.showGrips=function(c){f.selectorGripsGroup.setAttribute("display",c?"inline":"none");var m=this.selectedElement;this.hasGrips=c;if(m&&c){this.selectorGroup.appendChild(f.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(m))}};svgedit.select.Selector.prototype.resize=function(){var c=this.selectorRect,m=f,p=m.selectorGrips,b=this.selectedElement,d=b.getAttribute("stroke-width"),e=a.currentZoom(),l=1/e;if(b.getAttribute("stroke")!=="none"&&
|
|
!isNaN(d))l+=d/2;var q=b.tagName;if(q==="text")l+=2/e;d=svgedit.transformlist.getTransformList(b);d=svgedit.math.transformListToTransform(d).matrix;d.e*=e;d.f*=e;var u=svgedit.utilities.getBBox(b);if(q==="g"&&!$.data(b,"gsvg"))if(q=a.getStrokedBBox(b.childNodes))u=q;q=u.x;var n=u.y,I=u.width;u=u.height;l*=e;e=svgedit.math.transformBox(q*e,n*e,I*e,u*e,d);d=e.aabox;q=d.x-l;n=d.y-l;I=d.width+l*2;var S=d.height+l*2;d=q+I/2;u=n+S/2;if(b=svgedit.utilities.getRotationAngle(b)){q=a.svgRoot().createSVGTransform();
|
|
q.setRotate(-b,d,u);q=q.matrix;e.tl=svgedit.math.transformPoint(e.tl.x,e.tl.y,q);e.tr=svgedit.math.transformPoint(e.tr.x,e.tr.y,q);e.bl=svgedit.math.transformPoint(e.bl.x,e.bl.y,q);e.br=svgedit.math.transformPoint(e.br.x,e.br.y,q);q=e.tl;I=q.x;S=q.y;var O=q.x,H=q.y;q=Math.min;n=Math.max;I=q(I,q(e.tr.x,q(e.bl.x,e.br.x)))-l;S=q(S,q(e.tr.y,q(e.bl.y,e.br.y)))-l;O=n(O,n(e.tr.x,n(e.bl.x,e.br.x)))+l;H=n(H,n(e.tr.y,n(e.bl.y,e.br.y)))+l;q=I;n=S;I=O-I;S=H-S}l=a.svgRoot().suspendRedraw(100);c.setAttribute("d",
|
|
"M"+q+","+n+" L"+(q+I)+","+n+" "+(q+I)+","+(n+S)+" "+q+","+(n+S)+"z");this.selectorGroup.setAttribute("transform",b?"rotate("+[b,d,u].join(",")+")":"");q-=3.5;n-=3.5;this.gripCoords={nw:[q,n],ne:[q+I,n],sw:[q,n+S],se:[q+I,n+S],n:[q+I/2,n],w:[q,n+S/2],e:[q+I,n+S/2],s:[q+I/2,n+S]};for(var ea in this.gripCoords){c=this.gripCoords[ea];p[ea].setAttribute("x",c[0]);p[ea].setAttribute("y",c[1])}this.rotateCoords={nw:[q,n],ne:[q+I+8,n],sw:[q,n+S+8],se:[q+I+8,n+S+8]};for(ea in this.rotateCoords){c=this.rotateCoords[ea];
|
|
m.rotateGrips[ea].setAttribute("cx",c[0]);m.rotateGrips[ea].setAttribute("cy",c[1])}a.svgRoot().unsuspendRedraw(l)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.selectorGripsGroup=null;this.rotateGrips={nw:null,ne:null,se:null,sw:null};this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&
|
|
this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var c in this.rotateGrips){var m=a.createSVGElement({element:"circle",
|
|
attr:{id:"selectorGrip_rotate_"+c,fill:"#000",r:8,stroke:"#000","fill-opacity":0,"stroke-opacity":0,"stroke-width":0,style:"cursor:url("+o.imgPath+"rotate.png) 12 12, auto;"}});$.data(m,"dir",c);$.data(m,"type","rotate");this.rotateGrips[c]=this.selectorGripsGroup.appendChild(m)}for(c in this.selectorGrips){m=a.createSVGElement({element:"rect",attr:{id:"selectorGrip_resize_"+c,width:7,height:7,fill:"#4F80FF",stroke:"transparent","stroke-width":2,style:"cursor:"+c+"-resize","pointer-events":"all"}});
|
|
$.data(m,"dir",c);$.data(m,"type","resize");this.selectorGrips[c]=this.selectorGripsGroup.appendChild(m)}if(!$("#canvasBackground").length){c=o.dimensions;c=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:c[0],height:c[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});m=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});c.appendChild(m);
|
|
a.svgRoot().insertBefore(c,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(c){if(c==null)return null;var m=this.selectors.length;if(typeof this.selectorMap[c.id]=="object"){this.selectorMap[c.id].locked=true;return this.selectorMap[c.id]}for(var p=0;p<m;++p)if(this.selectors[p]&&!this.selectors[p].locked){this.selectors[p].locked=true;this.selectors[p].reset(c);this.selectorMap[c.id]=this.selectors[p];return this.selectors[p]}this.selectors[m]=new svgedit.select.Selector(m,
|
|
c);this.selectorParentGroup.appendChild(this.selectors[m].selectorGroup);this.selectorMap[c.id]=this.selectors[m];return this.selectors[m]};svgedit.select.SelectorManager.prototype.releaseSelector=function(c){if(c!=null)for(var m=this.selectors.length,p=this.selectorMap[c.id],b=0;b<m;++b)if(this.selectors[b]&&this.selectors[b]==p){p.locked==false&&console.log("WARNING! selector was released but was already unlocked");delete this.selectorMap[c.id];p.locked=false;p.selectedElement=null;p.showGrips(false);
|
|
try{p.selectorGroup.setAttribute("display","none")}catch(d){}break}};svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){if(!this.rubberBandBox)this.rubberBandBox=this.selectorParentGroup.appendChild(a.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"transparent",stroke:"#666","stroke-width":1,"stroke-dasharray":"3,2",display:"none",style:"pointer-events:none"}}));return this.rubberBandBox};svgedit.select.init=function(c,m){o=c;a=m;f=new svgedit.select.SelectorManager};
|
|
svgedit.select.getSelectorManager=function(){return f}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.draw)svgedit.draw={};var a="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),o={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},f=o.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(c,m){this.name_=c;this.group_=m};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(c,m){f=c==false?o.NEVER_RANDOMIZE:
|
|
o.ALWAYS_RANDOMIZE;if(f==o.ALWAYS_RANDOMIZE&&!m.getNonce())m.setNonce(Math.floor(Math.random()*100001));else f==o.NEVER_RANDOMIZE&&m.getNonce()&&m.clearNonce()};svgedit.draw.Drawing=function(c,m){if(!c||!c.tagName||!c.namespaceURI||c.tagName!="svg"||c.namespaceURI!="http://www.w3.org/2000/svg")throw"Error: svgedit.draw.Drawing instance initialized without a <svg> element";this.svgElem_=c;this.obj_num=0;this.idPrefix=m||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
|
|
"";var p=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(p&&f!=o.NEVER_RANDOMIZE)this.nonce_=p;else f==o.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(c){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+c):$(this.svgElem_).find("[id="+c+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};
|
|
svgedit.draw.Drawing.prototype.setNonce=function(c){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",c);this.nonce_=c};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var c=
|
|
this.obj_num,m=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();m=true}else this.obj_num++;for(var p=this.getId();this.getElem_(p);){if(m){this.obj_num=c;m=false}this.obj_num++;p=this.getId()}if(m)this.obj_num=c;return p};svgedit.draw.Drawing.prototype.releaseId=function(c){var m=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof c!="string"||c.indexOf(m)!=0)return false;c=parseInt(c.substr(m.length));if(typeof c!="number"||c<=0||this.releasedNums.indexOf(c)!=-1)return false;
|
|
this.releasedNums.push(c);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(c){for(var m=0;m<this.getNumLayers();m++)if(this.all_layers[m][0]==c)return true;return false};svgedit.draw.Drawing.prototype.getLayerName=function(c){if(c>=0&&c<this.getNumLayers())return this.all_layers[c][0];return""};svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer};svgedit.draw.Drawing.prototype.getCurrentLayerName=
|
|
function(){for(var c=0;c<this.getNumLayers();++c)if(this.all_layers[c][1]==this.current_layer)return this.getLayerName(c);return""};svgedit.draw.Drawing.prototype.setCurrentLayer=function(c){for(var m=0;m<this.getNumLayers();++m)if(c==this.getLayerName(m)){if(this.current_layer!=this.all_layers[m][1]){this.current_layer.setAttribute("style","pointer-events:none");this.current_layer=this.all_layers[m][1];this.current_layer.setAttribute("style","pointer-events:all")}return true}return false};svgedit.draw.Drawing.prototype.deleteCurrentLayer=
|
|
function(){if(this.current_layer&&this.getNumLayers()>1){var c=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return c}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var c=this.svgElem_.childNodes.length,m=[],p=[],b=null,d=false,e=0;e<c;++e){var l=this.svgElem_.childNodes.item(e);if(l&&l.nodeType==1)if(l.tagName=="g"){d=true;var q=$("title",l).text();if(!q&&svgedit.browser.isOpera()&&l.querySelectorAll)q=$(l.querySelectorAll("title")).text();
|
|
if(q){p.push(q);this.all_layers.push([q,l]);b=l;svgedit.utilities.walkTree(l,function(u){u.setAttribute("style","pointer-events:inherit")});b.setAttribute("style","pointer-events:none")}else m.push(l)}else if(~a.indexOf(l.nodeName)){svgedit.utilities.getBBox(l);m.push(l)}}c=this.svgElem_.ownerDocument;if(m.length>0||!d){for(e=1;p.indexOf("Layer "+e)>=0;)e++;p="Layer "+e;b=c.createElementNS("http://www.w3.org/2000/svg","g");d=c.createElementNS("http://www.w3.org/2000/svg","title");d.textContent=p;
|
|
b.appendChild(d);for(d=0;d<m.length;++d)b.appendChild(m[d]);this.svgElem_.appendChild(b);this.all_layers.push([p,b])}svgedit.utilities.walkTree(b,function(u){u.setAttribute("style","pointer-events:inherit")});this.current_layer=b;this.current_layer.setAttribute("style","pointer-events:all")};svgedit.draw.Drawing.prototype.createLayer=function(c){var m=this.svgElem_.ownerDocument,p=m.createElementNS("http://www.w3.org/2000/svg","g");m=m.createElementNS("http://www.w3.org/2000/svg","title");m.textContent=
|
|
c;p.appendChild(m);this.svgElem_.appendChild(p);this.identifyLayers();return p};svgedit.draw.Drawing.prototype.getLayerVisibility=function(c){for(var m=null,p=0;p<this.getNumLayers();++p)if(this.getLayerName(p)==c){m=this.all_layers[p][1];break}if(!m)return false;return m.getAttribute("display")!="none"};svgedit.draw.Drawing.prototype.setLayerVisibility=function(c,m){if(typeof m!="boolean")return null;for(var p=null,b=0;b<this.getNumLayers();++b)if(this.getLayerName(b)==c){p=this.all_layers[b][1];
|
|
break}if(!p)return null;p.getAttribute("display");p.setAttribute("display",m?"inline":"none");return p};svgedit.draw.Drawing.prototype.getLayerOpacity=function(c){for(var m=0;m<this.getNumLayers();++m)if(this.getLayerName(m)==c){(c=this.all_layers[m][1].getAttribute("opacity"))||(c="1.0");return parseFloat(c)}return null};svgedit.draw.Drawing.prototype.setLayerOpacity=function(c,m){if(!(typeof m!="number"||m<0||m>1))for(var p=0;p<this.getNumLayers();++p)if(this.getLayerName(p)==c){this.all_layers[p][1].setAttribute("opacity",
|
|
m);break}}})();svgedit=svgedit||{};
|
|
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},o={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},f=[],c=true,m={};svgedit.path.setLinkControlPoints=function(d){c=d};var p=svgedit.path.path=null;svgedit.path.init=
|
|
function(d){p=d;f=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,l){f.push(l+"Abs");f.push(l+"Rel")})};svgedit.path.insertItemBefore=function(d,e,l){d=d.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())d.insertItemBefore(e,l);else{for(var q=d.numberOfItems,u=[],n=0;n<q;n++){var I=d.getItem(n);u.push(I)}d.clear();for(n=0;n<q;n++){n==l&&d.appendItem(e);d.appendItem(u[n])}}};
|
|
svgedit.path.ptObjToArr=function(d,e){for(var l=o[d],q=l.length,u=Array(q),n=0;n<q;n++)u[n]=e[l[n]];return u};svgedit.path.getGripPt=function(d,e){var l={x:e?e.x:d.item.x,y:e?e.y:d.item.y},q=d.path;if(q.matrix)l=svgedit.math.transformPoint(l.x,l.y,q.matrix);l.x*=p.getCurrentZoom();l.y*=p.getCurrentZoom();return l};svgedit.path.getPointFromGrip=function(d,e){var l={x:d.x,y:d.y};if(e.matrix){d=svgedit.math.transformPoint(l.x,l.y,e.imatrix);l.x=d.x;l.y=d.y}l.x/=p.getCurrentZoom();l.y/=p.getCurrentZoom();
|
|
return l};svgedit.path.addPointGrip=function(d,e,l){var q=svgedit.path.getGripContainer(),u=svgedit.utilities.getElem("pathpointgrip_"+d);if(!u){u=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(u,{id:"pathpointgrip_"+d,display:"none",width:5,height:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});u=q.appendChild(u);$("#pathpointgrip_"+d).dblclick(function(){svgedit.path.path&&
|
|
svgedit.path.path.setSegType()})}e&&l&&svgedit.utilities.assignAttributes(u,{x:e-2.5,y:l-2.5,display:"inline"});return u};svgedit.path.getGripContainer=function(){var d=svgedit.utilities.getElem("pathpointgrip_container");if(!d){d=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));d.id="pathpointgrip_container"}return d};svgedit.path.addCtrlGrip=function(d){var e=svgedit.utilities.getElem("ctrlpointgrip_"+d);if(e)return e;e=document.createElementNS("http://www.w3.org/2000/svg",
|
|
"circle");svgedit.utilities.assignAttributes(e,{id:"ctrlpointgrip_"+d,display:"none",r:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(e);return e};svgedit.path.getCtrlLine=function(d){var e=svgedit.utilities.getElem("ctrlLine_"+d);if(e)return e;e=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(e,{id:"ctrlLine_"+d,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});
|
|
svgedit.path.getGripContainer().appendChild(e);return e};svgedit.path.getPointGrip=function(d,e){var l=svgedit.path.addPointGrip(d.index);if(e){var q=svgedit.path.getGripPt(d);svgedit.utilities.assignAttributes(l,{x:q.x-2.5,y:q.y-2.5,display:"inline"})}return l};svgedit.path.getControlPoints=function(d){var e=d.item,l=d.index;if(!("x1"in e)||!("x2"in e))return null;var q={};svgedit.path.getGripContainer();for(var u=[svgedit.path.path.segs[l-1].item,e],n=1;n<3;n++){var I=l+"c"+n,S=q["c"+n+"_line"]=
|
|
svgedit.path.getCtrlLine(I),O=svgedit.path.getGripPt(d,{x:e["x"+n],y:e["y"+n]}),H=svgedit.path.getGripPt(d,{x:u[n-1].x,y:u[n-1].y});svgedit.utilities.assignAttributes(S,{x1:O.x,y1:O.y,x2:H.x,y2:H.y,display:"inline"});q["c"+n+"_line"]=S;pointGrip=q["c"+n]=svgedit.path.addCtrlGrip(I);svgedit.utilities.assignAttributes(pointGrip,{cx:O.x,cy:O.y,display:"inline"});q["c"+n]=pointGrip}return q};svgedit.path.replacePathSeg=function(d,e,l,q){q=q||svgedit.path.path.elem;d=q["createSVGPathSeg"+f[d]].apply(q,
|
|
l);if(svgedit.browser.supportsPathReplaceItem())q.pathSegList.replaceItem(d,e);else{l=q.pathSegList;q=l.numberOfItems;for(var u=[],n=0;n<q;n++){var I=l.getItem(n);u.push(I)}l.clear();for(n=0;n<q;n++)n==e?l.appendItem(d):l.appendItem(u[n])}};svgedit.path.getSegSelector=function(d,e){var l=d.index,q=svgedit.utilities.getElem("segline_"+l);if(!q){var u=svgedit.path.getGripContainer();q=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(q,{id:"segline_"+l,
|
|
display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});u.appendChild(q)}if(e){l=d.prev;if(!l){q.setAttribute("display","none");return q}l=svgedit.path.getGripPt(l);svgedit.path.replacePathSeg(2,0,[l.x,l.y],q);u=svgedit.path.ptObjToArr(d.type,d.item,true);for(var n=0;n<u.length;n+=2){l=svgedit.path.getGripPt(d,{x:u[n],y:u[n+1]});u[n]=l.x;u[n+1]=l.y}svgedit.path.replacePathSeg(d.type,1,u,q)}return q};svgedit.path.smoothControlPoints=this.smoothControlPoints=
|
|
function(d,e,l){var q=d.x-l.x,u=d.y-l.y,n=e.x-l.x,I=e.y-l.y;if((q!=0||u!=0)&&(n!=0||I!=0)){d=Math.atan2(u,q);e=Math.atan2(I,n);q=Math.sqrt(q*q+u*u);n=Math.sqrt(n*n+I*I);u=p.getSVGRoot().createSVGPoint();I=p.getSVGRoot().createSVGPoint();if(d<0)d+=2*Math.PI;if(e<0)e+=2*Math.PI;var S=Math.abs(d-e),O=Math.abs(Math.PI-S)/2;if(d-e>0){d=S<Math.PI?d+O:d-O;e=S<Math.PI?e-O:e+O}else{d=S<Math.PI?d-O:d+O;e=S<Math.PI?e+O:e-O}u.x=q*Math.cos(d)+l.x;u.y=q*Math.sin(d)+l.y;I.x=n*Math.cos(e)+l.x;I.y=n*Math.sin(e)+l.y;
|
|
return[u,I]}};svgedit.path.Segment=function(d,e){this.selected=false;this.index=d;this.item=e;this.type=e.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=function(d){for(var e in this.ctrlpts)this.ctrlpts[e].setAttribute("display",d?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(d){if(this.ptgrip){this.ptgrip.setAttribute("display",
|
|
d?"inline":"none");this.segsel.setAttribute("display",d?"inline":"none");this.showCtrlPts(d)}};svgedit.path.Segment.prototype.select=function(d){if(this.ptgrip){this.ptgrip.setAttribute("stroke",d?"#0FF":"#00F");this.segsel.setAttribute("display",d?"inline":"none");this.ctrlpts&&this.selectCtrls(d);this.selected=d}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,
|
|
true)};svgedit.path.Segment.prototype.update=function(d){if(this.ptgrip){var e=svgedit.path.getGripPt(this);svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:e.x-2.5,y:e.y-2.5}:{cx:e.x,cy:e.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(d){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(d,e){var l=this.item;l=this.ctrlpts?
|
|
[l.x+=d,l.y+=e,l.x1,l.y1,l.x2+=d,l.y2+=e]:[l.x+=d,l.y+=e];svgedit.path.replacePathSeg(this.type,this.index,l);if(this.next&&this.next.ctrlpts){l=this.next.item;l=[l.x,l.y,l.x1+=d,l.y1+=e,l.x2,l.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,l)}if(this.mate){l=this.mate.item;l=[l.x+=d,l.y+=e];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,l)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(d){var e,l,q;if(d==2){l=1;e=
|
|
this.next;if(!e)return;q=this.item}else{l=2;e=this.prev;if(!e)return;q=e.item}var u=e.item;u["x"+l]=q.x+(q.x-this.item["x"+d]);u["y"+l]=q.y+(q.y-this.item["y"+d]);svgedit.path.replacePathSeg(e.type,e.index,[u.x,u.y,u.x1,u.y1,u.x2,u.y2]);e.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(d,e,l){var q=this.item;q["x"+d]+=e;q["y"+d]+=l;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(d,e){svgedit.path.replacePathSeg(d,
|
|
this.index,e);this.type=d;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(d===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(d){if(!d||d.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=d;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var d=
|
|
this.elem.pathSegList,e=d.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l<e;l++){var q=d.getItem(l);q=new svgedit.path.Segment(l,q);q.path=this;this.segs.push(q)}d=this.segs;q=null;for(l=0;l<e;l++){var u=d[l],n=l+1>=e?null:d[l+1],I=l-1<0?null:d[l-1];if(u.type===2){if(I&&I.type!==1){n=d[q];n.next=d[q+1];n.next.prev=n;n.addGrip()}q=l}else if(n&&n.type===1){u.next=d[q+1];u.next.prev=u;u.mate=d[q];u.addGrip();if(this.first_seg==null)this.first_seg=u}else if(n){if(u.type!==
|
|
1){u.addGrip();if(n&&n.type!==2){u.next=n;u.next.prev=u}}}else if(u.type!==1){n=d[q];n.next=d[q+1];n.next.prev=n;n.addGrip();u.addGrip();if(!this.first_seg)this.first_seg=d[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(d){for(var e=this.segs.length,l=0;l<e;l++)if(d.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(d){var e=this.segs[d];if(e.prev){var l=e.prev,q;switch(e.item.pathSegType){case 4:var u=(e.item.x+l.item.x)/2,n=(e.item.y+l.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(u,
|
|
n);break;case 6:q=(l.item.x+e.item.x1)/2;var I=(e.item.x1+e.item.x2)/2,S=(e.item.x2+e.item.x)/2,O=(q+I)/2;I=(I+S)/2;u=(O+I)/2;var H=(l.item.y+e.item.y1)/2,ea=(e.item.y1+e.item.y2)/2;l=(e.item.y2+e.item.y)/2;var X=(H+ea)/2;ea=(ea+l)/2;n=(X+ea)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(u,n,q,H,O,X);svgedit.path.replacePathSeg(e.type,d,[e.item.x,e.item.y,I,ea,S,l])}svgedit.path.insertItemBefore(this.elem,q,d)}};svgedit.path.Path.prototype.deleteSeg=function(d){var e=this.segs[d],l=this.elem.pathSegList;
|
|
e.show(false);var q=e.next;if(e.mate){var u=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,u);svgedit.path.replacePathSeg(4,e.index,u);l.removeItem(e.mate.index)}else{if(!e.prev){u=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,e.next.index,u)}l.removeItem(d)}};svgedit.path.Path.prototype.subpathIsClosed=function(d){var e=false;svgedit.path.path.eachSeg(function(l){if(l<=d)return true;if(this.type===2)return false;else if(this.type===1){e=true;return false}});return e};svgedit.path.Path.prototype.removePtFromSelection=
|
|
function(d){var e=this.selected_pts.indexOf(d);if(e!=-1){this.segs[d].select(false);this.selected_pts.splice(e,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(d){this.eachSeg(function(){this.show(d)});d&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(d,
|
|
e){for(var l=this.selected_pts.length;l--;)this.segs[this.selected_pts[l]].move(d,e)};svgedit.path.Path.prototype.moveCtrl=function(d,e){var l=this.segs[this.selected_pts[0]];l.moveCtrl(this.dragctrl,d,e);c&&l.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(d){this.storeD();for(var e=this.selected_pts.length,l;e--;){var q=this.segs[this.selected_pts[e]],u=q.prev;if(u){if(!d){l="Toggle Path Segment Type";d=q.type==6?4:6}d-=0;var n=q.item.x,I=q.item.y,S=u.item.x;u=u.item.y;
|
|
var O;switch(d){case 6:if(q.olditem){S=q.olditem;O=[n,I,S.x1,S.y1,S.x2,S.y2]}else{O=n-S;var H=I-u;O=[n,I,S+O/3,u+H/3,n-O/3,I-H/3]}break;case 4:O=[n,I];q.olditem=q.item}q.setType(d,O)}}svgedit.path.path.endChanges(l)};svgedit.path.Path.prototype.selectPt=function(d,e){this.clearSelection();d==null&&this.eachSeg(function(l){if(this.prev)d=l});this.addPtsToSelection(d);if(e){this.dragctrl=e;c&&this.segs[d].setLinked(e)}};svgedit.path.Path.prototype.update=function(){var d=this.elem;if(svgedit.utilities.getRotationAngle(d)){this.matrix=
|
|
svgedit.math.getMatrix(d);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=null;this.eachSeg(function(e){this.item=d.pathSegList.getItem(e);this.update()});return this};svgedit.path.getPath_=function(d){var e=m[d.id];e||(e=m[d.id]=new svgedit.path.Path(d));return e};svgedit.path.removePath_=function(d){d in m&&delete m[d]};var b=function(d,e){dx=d-oldcx;dy=e-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;
|
|
dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var d=svgedit.path.path.elem,e=svgedit.utilities.getRotationAngle(d,true);if(e){var l=svgedit.utilities.getBBox(d),q=svgedit.path.path.oldbbox,u=q.x+q.width/2,n=q.y+q.height/2;q=l.x+l.width/2;l=l.y+l.height/2;q=q-u;var I=l-n;l=Math.sqrt(q*q+I*I);I=Math.atan2(I,q)+e;q=l*Math.cos(I)+u;l=l*Math.sin(I)+n;u=d.pathSegList;for(n=u.numberOfItems;n;){n-=
|
|
1;I=u.getItem(n);var S=I.pathSegType;if(S!=1){var O=b(I.x,I.y);O=[O.x,O.y];if(I.x1!=null&&I.x2!=null){c_vals1=b(I.x1,I.y1);c_vals2=b(I.x2,I.y2);O.splice(O.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(S,n,O)}}svgedit.utilities.getBBox(d);u=svgroot.createSVGTransform();d=svgedit.transformlist.getTransformList(d);u.setRotate(e*180/Math.PI,q,l);d.replaceItem(u,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
|
|
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(o,f){var c=this.length;if(!c)return a.apply(this,arguments);for(var m=0;m<c;m++){var p=this[m];if(p.namespaceURI==="http://www.w3.org/2000/svg")if(f!==undefined)p.setAttribute(o,f);else if($.isArray(o)){c=o.length;for(m={};c--;){var b=o[c],d=p.getAttribute(b);if(d||d==="0")d=isNaN(d)?d:d-0;m[b]=d}return m}else if(typeof o==="object")for(b in o)p.setAttribute(b,o[b]);else{if((d=p.getAttribute(o))||d==="0")d=isNaN(d)?d:d-0;return d}else return a.apply(this,
|
|
arguments)}return this}})();
|
|
$.SvgCanvas=function(a,o){function f(g,h){for(var k=svgedit.utilities.getBBox(g),w=0;w<2;w++){var v=w===0?"fill":"stroke",G=g.getAttribute(v);if(G&&G.indexOf("url(")===0){G=fa(G);if(G.tagName==="linearGradient"){var z=G.getAttribute("x1")||0,A=G.getAttribute("y1")||0,C=G.getAttribute("x2")||1,F=G.getAttribute("y2")||0;z=k.width*z+k.x;A=k.height*A+k.y;C=k.width*C+k.x;F=k.height*F+k.y;z=Q(z,A,h);F=Q(C,F,h);C={};C.x1=(z.x-k.x)/k.width;C.y1=(z.y-k.y)/k.height;C.x2=(F.x-k.x)/k.width;C.y2=(F.y-k.y)/k.height;
|
|
G=G.cloneNode(true);$(G).attr(C);G.id=P();Bb().appendChild(G);g.setAttribute(v,"url(#"+G.id+")")}}}}var c="http://www.w3.org/2000/svg",m={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};o&&$.extend(m,o);var p=m.dimensions,b=this,d=a.ownerDocument,e=d.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+c+'" xlinkns="http://www.w3.org/1999/xlink" width="'+p[0]+'" height="'+p[1]+'" x="'+p[0]+'" y="'+p[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,
|
|
true);a.appendChild(e);var l=d.createElementNS(c,"svg");(b.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:p[0],height:p[1],x:p[0],y:p[1],overflow:m.show_outside_canvas?"visible":"hidden",xmlns:c,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(e);var g=d.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(g)})();var q="svg_";b.setIdPrefix=
|
|
function(g){q=g};b.current_drawing_=new svgedit.draw.Drawing(l,q);var u=b.getCurrentDrawing=function(){return b.current_drawing_},n=1,I=null,S={shape:{fill:(m.initFill.color=="none"?"":"#")+m.initFill.color,fill_paint:null,fill_opacity:m.initFill.opacity,stroke:"#"+m.initStroke.color,stroke_paint:null,stroke_opacity:m.initStroke.opacity,stroke_width:m.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:m.initOpacity}};S.text=$.extend(true,{},S.shape);$.extend(S.text,
|
|
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Junction"});var O=S.shape,H=Array(1),ea=this.addSvgElementFromJson=function(g){var h=svgedit.utilities.getElem(g.attr.id),k=u().getCurrentLayer();if(h&&g.element!=h.tagName){k.removeChild(h);h=null}if(!h){h=d.createElementNS(c,g.element);if(k)(I||k).appendChild(h)}g.curStyles&&svgedit.utilities.assignAttributes(h,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,
|
|
"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,g.attr,100);svgedit.utilities.cleanupElement(h);return h},X=b.getTransformList=svgedit.transformlist.getTransformList,Q=svgedit.math.transformPoint,R=b.matrixMultiply=svgedit.math.matrixMultiply,ha=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,W=b.transformListToTransform=svgedit.math.transformListToTransform,
|
|
Z=svgedit.math.snapToAngle,ba=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return m.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/n},getWidth:function(){return l.getAttribute("width")/n},getRoundDigits:function(){return bb.round_digits}});var ka=b.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return d},getDOMContainer:function(){return a},getSVGRoot:function(){return e},getSelectedElements:function(){return H},
|
|
getSVGContent:function(){return l}});var la=b.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=b.getHref=svgedit.utilities.getHref,Y=b.setHref=svgedit.utilities.setHref,V=svgedit.utilities.getPathBBox;b.getBBox=svgedit.utilities.getBBox;var ma=b.getRotationAngle=svgedit.utilities.getRotationAngle,ua=b.getElem=svgedit.utilities.getElem,ga=b.assignAttributes=svgedit.utilities.assignAttributes,qa=this.cleanupElement=svgedit.utilities.cleanupElement,Ga=svgedit.sanitize.getNSMap(),Ma=b.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
|
|
Ra=svgedit.history.MoveElementCommand,Qa=svgedit.history.InsertElementCommand,Va=svgedit.history.RemoveElementCommand,Xa=svgedit.history.ChangeElementCommand,Na=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(g,h){var k=svgedit.history.HistoryEventTypes;if(g==k.BEFORE_UNAPPLY||g==k.BEFORE_APPLY)b.clearSelection();else if(g==k.AFTER_APPLY||g==k.AFTER_UNAPPLY){var w=h.elements();b.pathActions.clear();J("changed",w);w=h.type();k=g==k.AFTER_APPLY;if(w==
|
|
Ra.type()){k=k?h.newParent:h.oldParent;k==l&&b.identifyLayers()}else if(w==Qa.type()||w==Va.type()){h.parent==l&&b.identifyLayers();if(w==Qa.type())k&&$a(h.elem);else k||$a(h.elem);h.elem.tagName==="use"&&gc(h.elem)}else if(w==Xa.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();k=k?h.newValues:h.oldValues;k.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,k.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){w=h.elem;if(!w.getAttribute("x")&&!w.getAttribute("y")){k=
|
|
w.parentNode;var v=w.nextSibling;k.removeChild(w);k.insertBefore(w,v)}}}}}});var Ha=function(g){b.undoMgr.addCommandToHistory(g)};svgedit.select.init(m,{createSVGElement:function(g){return b.addSvgElementFromJson(g)},svgRoot:function(){return e},svgContent:function(){return l},currentZoom:function(){return n},getStrokedBBox:function(g){return b.getStrokedBBox([g])}});var Pa=this.selectorManager=svgedit.select.getSelectorManager(),zb=this.hoverManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return n},
|
|
getSVGRoot:function(){return e}});svgedit.utilities.snapToGrid=function(g){var h=m.snappingStep,k=m.baseUnit;if(k!=="px")h*=svgedit.units.getTypeMap()[k];return g=Math.round(g/h)*h};var Ja=svgedit.utilities.snapToGrid,Jb={exportNoBlur:"Blurred elements will appear as un-blurred",exportNoforeignObject:"foreignObject elements will not appear",exportNoDashArray:"Strokes will appear filled",exportNoText:"Text may not appear as expected"},tb=["clip-path","fill","filter","marker-end","marker-mid","marker-start",
|
|
"mask","stroke"],ab=$.data,$a=function(g){var h=$(g).attr(tb),k;for(k in h){var w=h[k];if(w&&w.indexOf("url(")===0){w=la(w).substr(1);if(!ua(w)){Bb().appendChild(Fb[w]);delete Fb[w]}}}g=g.getElementsByTagName("*");if(g.length){h=0;for(k=g.length;h<k;h++)$a(g[h])}},Ka={},Da=m.imgPath+"logo.png",yb=[],bb={round_digits:5},Sa=false,gb=null,Ia="select",rb="none",sb={},mb=S.text,hb=O,La=null,Wa=null,jb=[],Eb={},Fb={};b.clipBoard=[];var nb=this.runExtensions=function(g,h,k){var w=false;if(k)w=[];$.each(Eb,
|
|
function(v,G){if(g in G)if(k)w.push(G[g](h));else w=G[g](h)});return w};this.addExtension=function(g,h){if(g in Eb)console.log('Cannot add extension "'+g+'", an extension by that name already exists"');else{var k=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:e,svgcontent:l,nonce:u().getNonce(),selectorManager:Pa,hoverManager:zb})):h;Eb[g]=k;J("extension_added",k)}};var Gb=this.round=function(g){return parseInt(g*n)/n},Ob=this.getIntersectionList=function(g){if(Wa==null)return null;var h=
|
|
I||u().getCurrentLayer();jb.length||(jb=Ub(h));var k=null;try{k=h.getIntersectionList(g,null)}catch(w){}if(k==null||typeof k.item!="function"){k=[];if(g)g=g;else{g=Wa.getBBox();h={};for(var v in g)h[v]=g[v]/n;g=h}for(v=jb.length;v--;)g.width&&g.width&&svgedit.math.rectsIntersect(g,jb[v].bbox)&&k.push(jb[v].elem)}return k};getStrokedBBox=this.getStrokedBBox=function(g){g||(g=Kb());if(!g.length)return false;var h=function(F){try{var E=svgedit.utilities.getBBox(F),D=svgedit.utilities.getRotationAngle(F);
|
|
if(D&&D%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(F))){D=false;if(["ellipse","path","line","polyline","polygon"].indexOf(F.tagName)>=0)E=D=b.convertToPath(F,true);else if(F.tagName=="rect"){var M=F.getAttribute("rx"),K=F.getAttribute("ry");if(M||K)E=D=b.convertToPath(F,true)}if(!D){var N=F.cloneNode(true),aa=document.createElementNS(c,"g"),T=F.parentNode;T.appendChild(aa);aa.appendChild(N);E=svgedit.utilities.bboxToObj(aa.getBBox());T.removeChild(aa)}}return E}catch(ta){console.log(F,
|
|
ta);return null}},k;$.each(g,function(){if(!k)if(this.parentNode)k=h(this)});if(k==null)return null;var w=k.x+k.width,v=k.y+k.height,G=k.x,z=k.y,A=function(F){var E=F.getAttribute("stroke-width"),D=0;if(F.getAttribute("stroke")!="none"&&!isNaN(E))D+=E/2;return D},C=[];$.each(g,function(F,E){var D=h(E);if(D){var M=A(E);G=Math.min(G,D.x-M);z=Math.min(z,D.y-M);C.push(D)}});k.x=G;k.y=z;$.each(g,function(F,E){var D=C[F];if(D&&E.nodeType==1){var M=A(E);w=Math.max(w,D.x+D.width+M);v=Math.max(v,D.y+D.height+
|
|
M)}});k.width=w-G;k.height=v-z;return k};var Kb=this.getVisibleElements=function(g){g||(g=$(l).children());var h=[];$(g).children().each(function(k,w){try{w.getBBox()&&h.push(w)}catch(v){}});return h.reverse()},Ub=this.getVisibleElementsAndBBoxes=function(g){g||(g=$(l).children());var h=[];$(g).children().each(function(k,w){try{w.getBBox()&&h.push({elem:w,bbox:getStrokedBBox([w])})}catch(v){}});return h.reverse()},ra=this.groupSvgElem=function(g){var h=document.createElementNS(c,"g");g.parentNode.replaceChild(h,
|
|
g);$(h).append(g).data("gsvg",g)[0].id=P()},ia=function(g){var h=document.createElementNS(g.namespaceURI,g.nodeName);h.removeAttribute("id");$.each(g.attributes,function(w,v){v.localName!="-moz-math-font-style"&&h.setAttributeNS(v.namespaceURI,v.nodeName,v.nodeValue)});if(svgedit.browser.isWebkit()&&g.nodeName=="path"){var k=Ua.convertPath(g);h.setAttribute("d",k)}$.each(g.childNodes,function(w,v){switch(v.nodeType){case 1:h.appendChild(ia(v));break;case 3:h.textContent=v.nodeValue}});if($(g).data("gsvg"))$(h).data("gsvg",
|
|
h.firstChild);else if($(g).data("symbol")){g=$(g).data("symbol");$(h).data("ref",g).data("symbol",g)}else h.tagName=="image"&&Lb(h);h.id=P();return h},va,P,J;(function(g){var h={};va=g.getId=function(){return u().getId()};P=g.getNextId=function(){return u().getNextId()};J=g.call=function(k,w){if(h[k])return h[k](this,w)};g.bind=function(k,w){var v=h[k];h[k]=w;return v}})(b);this.prepareSvg=function(g){this.sanitizeSvg(g.documentElement);g=g.getElementsByTagNameNS(c,"path");for(var h=0,k=g.length;h<
|
|
k;++h){var w=g[h];w.setAttribute("d",Ua.convertPath(w));Ua.fixEnd(w)}};var fa=this.getRefElem=function(g){return ua(la(g).substr(1))},Oa=function(g){if(!svgedit.browser.isGecko())return g;var h=g.cloneNode(true);g.parentNode.insertBefore(h,g);g.parentNode.removeChild(g);Pa.releaseSelector(g);H[0]=h;Pa.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(g,h){g=parseFloat(g);var k=H[0],w=k.getAttribute("transform"),v=svgedit.utilities.getBBox(k),G=v.x+v.width/2,z=v.y+v.height/
|
|
2;v=X(k);v.numberOfItems>0&&v.getItem(0).type==4&&v.removeItem(0);if(g!=0){G=Q(G,z,W(v).matrix);z=e.createSVGTransform();z.setRotate(g,G.x,G.y);v.numberOfItems?v.insertItemBefore(z,0):v.appendItem(z)}else v.numberOfItems==0&&k.removeAttribute("transform");if(!h){v=k.getAttribute("transform");k.setAttribute("transform",w);ub("transform",v,H);J("changed",H)}ua("pathpointgrip_container");k=Pa.requestSelector(H[0]);k.resize();k.updateGripCursors(g)};var Za=this.recalculateAllSelectedDimensions=function(){for(var g=
|
|
new Na(rb=="none"?"position":"size"),h=H.length;h--;){var k=pb(H[h]);k&&g.addSubCommand(k)}if(!g.isEmpty()){Ha(g);J("changed",H)}},fb=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],wb=function(g){console.log([g.a,g.b,g.c,g.d,g.e,g.f])},xb=this.remapElement=function(g,h,k){var w=m.gridSnapping&&g.parentNode.parentNode.localName==="svg",v=function(){if(w)for(var D in h)h[D]=Ja(h[D]);ga(g,h,1E3,true)};box=svgedit.utilities.getBBox(g);for(var G=0;G<2;G++){var z=G===0?
|
|
"fill":"stroke",A=g.getAttribute(z);if(A&&A.indexOf("url(")===0)if(k.a<0||k.d<0){A=fa(A).cloneNode(true);if(k.a<0){var C=A.getAttribute("x1"),F=A.getAttribute("x2");A.setAttribute("x1",-(C-1));A.setAttribute("x2",-(F-1))}if(k.d<0){C=A.getAttribute("y1");F=A.getAttribute("y2");A.setAttribute("y1",-(C-1));A.setAttribute("y2",-(F-1))}A.id=P();Bb().appendChild(A);g.setAttribute(z,"url(#"+A.id+")")}}G=g.tagName;if(G==="g"||G==="text"||G==="use")if(k.a==1&&k.b==0&&k.c==0&&k.d==1&&(k.e!=0||k.f!=0)){z=W(g).matrix;
|
|
z=R(z.inverse(),k,z);h.x=parseFloat(h.x)+z.e;h.y=parseFloat(h.y)+z.f}else{z=X(g);A=e.createSVGTransform();A.setMatrix(R(W(z).matrix,k));z.clear();z.appendItem(A)}switch(G){case "foreignObject":case "rect":case "image":if(G==="image"&&(k.a<0||k.d<0)){z=X(g);A=e.createSVGTransform();A.setMatrix(R(W(z).matrix,k));z.clear();z.appendItem(A)}else{z=Q(h.x,h.y,k);h.width=k.a*h.width;h.height=k.d*h.height;h.x=z.x+Math.min(0,h.width);h.y=z.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}v();
|
|
break;case "ellipse":G=Q(h.cx,h.cy,k);h.cx=G.x;h.cy=G.y;h.rx=k.a*h.rx;h.ry=k.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);v();break;case "circle":G=Q(h.cx,h.cy,k);h.cx=G.x;h.cy=G.y;G=svgedit.math.transformBox(box.x,box.y,box.width,box.height,k);h.r=Math.min((G.tr.x-G.tl.x)/2,(G.bl.y-G.tl.y)/2);if(h.r)h.r=Math.abs(h.r);v();break;case "line":z=Q(h.x1,h.y1,k);C=Q(h.x2,h.y2,k);h.x1=z.x;h.y1=z.y;h.x2=C.x;h.y2=C.y;case "text":k=g.querySelectorAll("tspan");for(G=k.length;G--;){z=ka("x",g.getAttribute("x"));
|
|
A=ka("x",k[G].getAttribute("x"));C=ka("y",g.getAttribute("y"));F=ka("y",k[G].getAttribute("y"));var E={};if(!isNaN(z)&&!isNaN(A)&&z!=0&&A!=0&&h.x)E.x=h.x-(z-A);if(!isNaN(C)&&!isNaN(F)&&C!=0&&F!=0&&h.y)E.y=h.y-(C-F);if(E.x||E.y)ga(k[G],E,1E3,true)}v();break;case "use":v();break;case "g":(v=$(g).data("gsvg"))&&ga(v,h,1E3,true);break;case "polyline":case "polygon":v=h.points.length;for(G=0;G<v;++G){F=h.points[G];F=Q(F.x,F.y,k);h.points[G].x=F.x;h.points[G].y=F.y}v=h.points.length;k="";for(G=0;G<v;++G){F=
|
|
h.points[G];k+=F.x+","+F.y+" "}g.setAttribute("points",k);break;case "path":z=g.pathSegList;v=z.numberOfItems;h.d=Array(v);for(G=0;G<v;++G){A=z.getItem(G);h.d[G]={type:A.pathSegType,x:A.x,y:A.y,x1:A.x1,y1:A.y1,x2:A.x2,y2:A.y2,r1:A.r1,r2:A.r2,angle:A.angle,largeArcFlag:A.largeArcFlag,sweepFlag:A.sweepFlag}}v=h.d.length;G=h.d[0];E=Q(G.x,G.y,k);h.d[0].x=E.x;h.d[0].y=E.y;for(G=1;G<v;++G){A=h.d[G];z=A.type;if(z%2==0){F=Q(A.x!=undefined?A.x:E.x,A.y!=undefined?A.y:E.y,k);z=Q(A.x1,A.y1,k);C=Q(A.x2,A.y2,k);
|
|
A.x=F.x;A.y=F.y;A.x1=z.x;A.y1=z.y;A.x2=C.x;A.y2=C.y}else{A.x=k.a*A.x;A.y=k.d*A.y;A.x1=k.a*A.x1;A.y1=k.d*A.y1;A.x2=k.a*A.x2;A.y2=k.d*A.y2}A.r1=k.a*A.r1;A.r2=k.d*A.r2}k="";v=h.d.length;for(G=0;G<v;++G){A=h.d[G];z=A.type;k+=fb[z];switch(z){case 13:case 12:k+=A.x+" ";break;case 15:case 14:k+=A.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:k+=A.x+","+A.y+" ";break;case 7:case 6:k+=A.x1+","+A.y1+" "+A.x2+","+A.y2+" "+A.x+","+A.y+" ";break;case 9:case 8:k+=A.x1+","+A.y1+" "+A.x+","+A.y+" ";break;
|
|
case 11:case 10:k+=A.r1+","+A.r2+" "+A.angle+" "+ +A.largeArcFlag+" "+ +A.sweepFlag+" "+A.x+","+A.y+" ";break;case 17:case 16:k+=A.x2+","+A.y2+" "+A.x+","+A.y+" "}}g.setAttribute("d",k)}},Db=function(g,h,k){g=fa(g).firstChild;var w=X(g),v=e.createSVGTransform();v.setTranslate(h,k);w.appendItem(v);pb(g)},pb=this.recalculateDimensions=function(g){if(g==null)return null;var h=X(g);if(h&&h.numberOfItems>0){for(var k=h.numberOfItems;k--;){var w=h.getItem(k);if(w.type===0)h.removeItem(k);else if(w.type===
|
|
1)svgedit.math.isIdentity(w.matrix)&&h.removeItem(k);else w.type===4&&w.angle===0&&h.removeItem(k)}if(h.numberOfItems===1&&ma(g))return null}if(!h||h.numberOfItems==0){g.removeAttribute("transform");return null}if(h){k=h.numberOfItems;for(var v=[];k--;){w=h.getItem(k);if(w.type===1)v.push([w.matrix,k]);else if(v.length)v=[]}if(v.length===2){k=e.createSVGTransformFromMatrix(R(v[1][0],v[0][0]));h.removeItem(v[0][1]);h.removeItem(v[1][1]);h.insertItemBefore(k,v[1][1])}k=h.numberOfItems;if(k>=2&&h.getItem(k-
|
|
2).type===1&&h.getItem(k-1).type===2){v=e.createSVGTransform();w=R(h.getItem(k-2).matrix,h.getItem(k-1).matrix);v.setMatrix(w);h.removeItem(k-2);h.removeItem(k-2);h.appendItem(v)}}switch(g.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var G=$(g).data("gsvg");k=new Na("Transform");var z={},A=null;w=[];switch(g.tagName){case "line":w=["x1","y1",
|
|
"x2","y2"];break;case "circle":w=["cx","cy","r"];break;case "ellipse":w=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":w=["width","height","x","y"];break;case "use":case "text":case "tspan":w=["x","y"];break;case "polygon":case "polyline":A={};A.points=g.getAttribute("points");v=g.points;var C=v.numberOfItems;z.points=Array(C);for(var F=0;F<C;++F){var E=v.getItem(F);z.points[F]={x:E.x,y:E.y}}break;case "path":A={};A.d=g.getAttribute("d");z.d=g.getAttribute("d")}if(w.length){z=
|
|
$(g).attr(w);$.each(z,function(Mb,Rb){z[Mb]=ka(Mb,Rb)})}else if(G)z={x:$(G).attr("x")||0,y:$(G).attr("y")||0};if(A==null){A=$.extend(true,{},z);$.each(A,function(Mb,Rb){A[Mb]=ka(Mb,Rb)})}A.transform=gb?gb:"";if(g.tagName=="g"&&!G||g.tagName=="a"){v=svgedit.utilities.getBBox(g);var D={x:v.x+v.width/2,y:v.y+v.height/2},M=Q(v.x+v.width/2,v.y+v.height/2,W(h).matrix);w=e.createSVGMatrix();if(v=ma(g)){F=v*Math.PI/180;C=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){w=
|
|
h.getItem(F);if(w.type==4){w=w.matrix;D.y=(C*w.e+w.f)/2;D.x=(w.e-C*w.f)/2;h.removeItem(F);break}}}F=w=G=0;var K=h.numberOfItems;if(K)var N=h.getItem(0).matrix;if(K>=3&&h.getItem(K-2).type==3&&h.getItem(K-3).type==2&&h.getItem(K-1).type==2){F=3;var aa=h.getItem(K-3).matrix,T=h.getItem(K-2).matrix,ta=h.getItem(K-1).matrix;C=g.childNodes;for(E=C.length;E--;){var xa=C.item(E);w=G=0;if(xa.nodeType==1){var ja=X(xa);if(ja){w=W(ja).matrix;G=ma(xa);var oa=gb,sa=[];gb=xa.getAttribute("transform");if(G||ha(ja)){var za=
|
|
e.createSVGTransform();za.setMatrix(R(aa,T,ta,w));ja.clear();ja.appendItem(za);sa.push(za)}else{G=R(w.inverse(),ta,w);za=e.createSVGMatrix();za.e=-G.e;za.f=-G.f;w=R(za.inverse(),w.inverse(),aa,T,ta,w,G.inverse());var kb=e.createSVGTransform(),ob=e.createSVGTransform(),Vb=e.createSVGTransform();kb.setTranslate(G.e,G.f);ob.setScale(w.a,w.d);Vb.setTranslate(za.e,za.f);ja.appendItem(Vb);ja.appendItem(ob);ja.appendItem(kb);sa.push(Vb);sa.push(ob);sa.push(kb)}k.addSubCommand(pb(xa));gb=oa}}}h.removeItem(K-
|
|
1);h.removeItem(K-2);h.removeItem(K-3)}else if(K>=3&&h.getItem(K-1).type==1){F=3;w=W(h).matrix;za=e.createSVGTransform();za.setMatrix(w);h.clear();h.appendItem(za)}else if((K==1||K>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;G=W(h).matrix;h.removeItem(0);w=W(h).matrix.inverse();w=R(w,G);G=w.e;w=w.f;if(G!=0||w!=0){C=g.childNodes;E=C.length;for(K=[];E--;){xa=C.item(E);if(xa.nodeType==1){if(xa.getAttribute("clip-path")){oa=xa.getAttribute("clip-path");if(K.indexOf(oa)===-1){Db(oa,G,w);K.push(oa)}}oa=
|
|
gb;gb=xa.getAttribute("transform");if(ja=X(xa)){aa=e.createSVGTransform();aa.setTranslate(G,w);ja.numberOfItems?ja.insertItemBefore(aa,0):ja.appendItem(aa);k.addSubCommand(pb(xa));ja=g.getElementsByTagNameNS(c,"use");xa="#"+xa.id;for(aa=ja.length;aa--;){T=ja.item(aa);if(xa==da(T)){ta=e.createSVGTransform();ta.setTranslate(-G,-w);X(T).insertItemBefore(ta,0);k.addSubCommand(pb(T))}}gb=oa}}}K=[];gb=oa}}else if(K==1&&h.getItem(0).type==1&&!v){F=1;w=h.getItem(0).matrix;C=g.childNodes;for(E=C.length;E--;){xa=
|
|
C.item(E);if(xa.nodeType==1){oa=gb;gb=xa.getAttribute("transform");if(ja=X(xa)){G=R(w,W(ja).matrix);K=e.createSVGTransform();K.setMatrix(G);ja.clear();ja.appendItem(K,0);k.addSubCommand(pb(xa));gb=oa;oa=xa.getAttribute("stroke-width");xa.getAttribute("stroke")!=="none"&&!isNaN(oa)&&xa.setAttribute("stroke-width",oa*((Math.abs(G.a)+Math.abs(G.d))/2))}}}h.clear()}else{if(v){D=e.createSVGTransform();D.setRotate(v,M.x,M.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");
|
|
return null}if(F==2){if(v){M={x:D.x+N.e,y:D.y+N.f};D=e.createSVGTransform();D.setRotate(v,M.x,M.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else if(F==3){w=W(h).matrix;N=e.createSVGTransform();N.setRotate(v,D.x,D.y);N=N.matrix;D=e.createSVGTransform();D.setRotate(v,M.x,M.y);M=D.matrix.inverse();oa=w.inverse();M=R(oa,M,N,w);G=M.e;w=M.f;if(G!=0||w!=0){C=g.childNodes;for(E=C.length;E--;){xa=C.item(E);if(xa.nodeType==1){oa=gb;gb=xa.getAttribute("transform");ja=X(xa);aa=e.createSVGTransform();
|
|
aa.setTranslate(G,w);ja.numberOfItems?ja.insertItemBefore(aa,0):ja.appendItem(aa);k.addSubCommand(pb(xa));gb=oa}}}if(v)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else{v=svgedit.utilities.getBBox(g);if(!v&&g.tagName!="path")return null;w=e.createSVGMatrix();if(G=ma(g)){D={x:v.x+v.width/2,y:v.y+v.height/2};M=Q(v.x+v.width/2,v.y+v.height/2,W(h).matrix);F=G*Math.PI/180;C=Math.abs(F)>1.0E-10?Math.sin(F)/(1-Math.cos(F)):2/F;for(F=0;F<h.numberOfItems;++F){w=h.getItem(F);if(w.type==4){w=w.matrix;
|
|
D.y=(C*w.e+w.f)/2;D.x=(w.e-C*w.f)/2;h.removeItem(F);break}}}F=0;K=h.numberOfItems;if(!svgedit.browser.isWebkit())if((N=g.getAttribute("fill"))&&N.indexOf("url(")===0){N=fa(N);oa="pattern";if(N.tagName!==oa)oa="gradient";if(N.getAttribute(oa+"Units")==="userSpaceOnUse"){w=W(h).matrix;v=X(N);v=W(v).matrix;w=R(w,v);v="matrix("+[w.a,w.b,w.c,w.d,w.e,w.f].join(",")+")";N.setAttribute(oa+"Transform",v)}}if(K>=3&&h.getItem(K-2).type==3&&h.getItem(K-3).type==2&&h.getItem(K-1).type==2){F=3;w=W(h,K-3,K-1).matrix;
|
|
h.removeItem(K-1);h.removeItem(K-2);h.removeItem(K-3)}else if(K==4&&h.getItem(K-1).type==1){F=3;w=W(h).matrix;za=e.createSVGTransform();za.setMatrix(w);h.clear();h.appendItem(za);w=e.createSVGMatrix()}else if((K==1||K>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){F=2;N=h.getItem(0).matrix;oa=W(h,1).matrix;v=oa.inverse();w=R(v,N,oa);h.removeItem(0)}else if(K==1&&h.getItem(0).type==1&&!G){w=W(h).matrix;switch(g.tagName){case "line":z=$(g).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":z.points=
|
|
g.getAttribute("points");if(z.points){v=g.points;C=v.numberOfItems;z.points=Array(C);for(F=0;F<C;++F){E=v.getItem(F);z.points[F]={x:E.x,y:E.y}}}case "path":z.d=g.getAttribute("d");F=1;h.clear()}}else{F=4;if(G){D=e.createSVGTransform();D.setRotate(G,M.x,M.y);h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}h.numberOfItems==0&&g.removeAttribute("transform");return null}if(F==1||F==2||F==3)xb(g,z,w);if(F==2){if(G){ha(h)||(M={x:D.x+w.e,y:D.y+w.f});D=e.createSVGTransform();D.setRotate(G,M.x,M.y);
|
|
h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}else if(F==3&&G){w=W(h).matrix;N=e.createSVGTransform();N.setRotate(G,D.x,D.y);N=N.matrix;D=e.createSVGTransform();D.setRotate(G,M.x,M.y);M=D.matrix.inverse();oa=w.inverse();M=R(oa,M,N,w);xb(g,z,M);if(G)h.numberOfItems?h.insertItemBefore(D,0):h.appendItem(D)}}h.numberOfItems==0&&g.removeAttribute("transform");k.addSubCommand(new Xa(g,A));return k},Pb=null,cb=this.clearSelection=function(g){if(H[0]!=null)for(var h=H.length,k=0;k<h;++k){var w=
|
|
H[k];if(w==null)break;Pa.releaseSelector(w);H[k]=null}g||J("selected",H)},Nb=this.addToSelection=function(g,h){if(g.length!=0){for(var k=0;k<H.length;){if(H[k]==null)break;++k}for(var w=g.length;w--;){var v=g[w];if(v&&svgedit.utilities.getBBox(v)){if(v.tagName==="a"&&v.childNodes.length===1)v=v.firstChild;if(H.indexOf(v)==-1){H[k]=v;k++;v=Pa.requestSelector(v);H.length>1&&v.showGrips(false)}}}J("selected",H);h||H.length==1?Pa.requestSelector(H[0]).showGrips(true):Pa.requestSelector(H[0]).showGrips(false);
|
|
for(H.sort(function(G,z){if(G&&z&&G.compareDocumentPosition)return 3-(z.compareDocumentPosition(G)&6);else if(G==null)return 1});H[0]==null;)H.shift(0)}},Sb=this.selectOnly=function(g,h){cb(true);Nb(g,h)};this.removeFromSelection=function(g){if(H[0]!=null)if(g.length!=0){var h=Array(H.length);j=0;len=H.length;for(var k=0;k<len;++k){var w=H[k];if(w)if(g.indexOf(w)==-1){h[j]=w;j++}else Pa.releaseSelector(w)}H=h}};this.selectAllInCurrentLayer=function(){var g=u().getCurrentLayer();if(g){Ia="select";
|
|
Sb($(I||g).children())}};var ac=this.getMouseTarget=function(g){if(g==null)return null;g=g.target;if(g.correspondingUseElement)g=g.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(g.namespaceURI)>=0&&g.id!="svgcanvas")for(;g.nodeName!="foreignObject";){g=g.parentNode;if(!g)return e}var h=u().getCurrentLayer();if([e,a,l,h].indexOf(g)>=0)return e;if($(g).closest("#selectorParentGroup").length)return Pa.selectorParentGroup;for(;g.parentNode!==(I||
|
|
h);)g=g.parentNode;return g};(function(){var g=null,h=null,k=null,w=null,v=null,G={},z={minx:null,miny:null,maxx:null,maxy:null},A=mosueOver=function(C){if(!(b.spaceKey||C.button===1)){var F=C.button===2;C.altKey&&svgCanvas.cloneSelectedElements(0,0);Pb=l.getScreenCTM().inverse();var E=Q(C.pageX,C.pageY,Pb),D=E.x*n;E=E.y*n;C.preventDefault();if(F)Ia="select";D=D/n;E=E/n;var M=ac(C);if(M.tagName==="a"&&M.childNodes.length===1)M=M.firstChild;var K=w=h=D,N=v=k=E;if(m.gridSnapping){D=Ja(D);E=Ja(E);h=
|
|
Ja(h);k=Ja(k)}if(M==Pa.selectorParentGroup&&H[0]!=null){M=C.target;var aa=ab(M,"type");if(aa=="rotate"){Ia="rotate";current_rotate_mode=ab(M,"dir")}else if(aa=="resize"){Ia="resize";rb=ab(M,"dir")}M=H[0]}gb=M.getAttribute("transform");aa=X(M);switch(Ia){case "select":Sa=true;rb="none";if(F)Sa=false;if(M!=e){if(H.indexOf(M)==-1){C.shiftKey||cb(true);Nb([M]);La=M;Ua.clear()}if(!F)for(F=0;F<H.length;++F)if(H[F]!=null){var T=X(H[F]);T.numberOfItems?T.insertItemBefore(e.createSVGTransform(),0):T.appendItem(e.createSVGTransform())}}else if(!F){cb();
|
|
Ia="multiselect";if(Wa==null)Wa=Pa.getRubberBandBox();w*=n;v*=n;ga(Wa,{x:w,y:v,width:0,height:0,display:"inline"},100)}break;case "zoom":Sa=true;if(Wa==null)Wa=Pa.getRubberBandBox();ga(Wa,{x:K*n,y:K*n,width:0,height:0,display:"inline"},100);break;case "resize":Sa=true;h=D;k=E;G=svgedit.utilities.getBBox($("#selectedBox0")[0]);var ta={};$.each(G,function(xa,ja){ta[xa]=ja/n});G=ta;F=ma(M)?1:0;if(ha(aa)){aa.insertItemBefore(e.createSVGTransform(),F);aa.insertItemBefore(e.createSVGTransform(),F);aa.insertItemBefore(e.createSVGTransform(),
|
|
F)}else{aa.appendItem(e.createSVGTransform());aa.appendItem(e.createSVGTransform());aa.appendItem(e.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(D=svgedit.browser.isChrome())T=function(xa){var ja=xa.getAttributeNS(null,"stroke");xa.removeAttributeNS(null,"stroke");setTimeout(function(){xa.setAttributeNS(null,"stroke",ja)},1)};M.style.vectorEffect="non-scaling-stroke";D&&T(M);E=M.getElementsByTagName("*");K=E.length;for(F=0;F<K;F++){E[F].style.vectorEffect="non-scaling-stroke";
|
|
D&&T(E[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":Sa=true;g=K+","+N+" ";T=O.stroke_width==0?1:O.stroke_width;ea({element:"polyline",curStyles:true,attr:{points:g,id:P(),fill:"none",opacity:O.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});z.minx=K;z.maxx=K;z.miny=N;z.maxy=N;break;case "image":Sa=true;T=ea({element:"image",attr:{x:D,y:E,width:0,height:0,id:P(),opacity:O.opacity/2,style:"pointer-events:inherit"}});Y(T,Da);Lb(T);break;case "square":case "rect":Sa=true;
|
|
h=D;k=E;ea({element:"rect",curStyles:true,attr:{x:D,y:E,width:0,height:0,id:P(),opacity:O.opacity/2}});break;case "line":Sa=true;T=O.stroke_width==0?1:O.stroke_width;ea({element:"line",curStyles:true,attr:{x1:D,y1:E,x2:D,y2:E,id:P(),stroke:O.stroke,"stroke-width":T,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,fill:"none",opacity:O.opacity/2,style:"pointer-events:none"}});break;case "circle":Sa=true;ea({element:"circle",
|
|
curStyles:true,attr:{cx:D,cy:E,r:0,id:P(),opacity:O.opacity/2}});break;case "ellipse":Sa=true;ea({element:"ellipse",curStyles:true,attr:{cx:D,cy:E,rx:0,ry:0,id:P(),opacity:O.opacity/2}});break;case "text":Sa=true;ea({element:"text",curStyles:true,attr:{x:D,y:E,id:P(),fill:mb.fill,"stroke-width":mb.stroke_width,"font-size":mb.font_size,"font-family":mb.font_family,"text-anchor":"left","xml:space":"preserve",opacity:O.opacity}});break;case "path":case "pathedit":h*=n;k*=n;Ua.mouseDown(C,M,h,k);Sa=true;
|
|
break;case "textedit":h*=n;k*=n;qb.mouseDown(C,M,h,k);Sa=true;break;case "rotate":Sa=true;b.undoMgr.beginUndoableChange("transform",H);document.getElementById("workarea").className="rotate"}T=nb("mouseDown",{event:C,start_x:h,start_y:k,selectedElements:H},true);$.each(T,function(xa,ja){if(ja&&ja.started)Sa=true});if(Ia)document.getElementById("workarea").className=Ia=="resize"?C.target.style.cursor:Ia}};$(a).mousedown(A).mousemove(function(C){if(Sa)if(!(C.button===1||b.spaceKey)){var F=H[0],E=Q(C.pageX,
|
|
C.pageY,Pb),D=E.x*n;E=E.y*n;var M=ua(va()),K=x=D/n,N=y=E/n;if(m.gridSnapping){x=Ja(x);y=Ja(y)}C.preventDefault();switch(Ia){case "select":if(H[0]!==null){K=x-h;var aa=y-k;if(m.gridSnapping){K=Ja(K);aa=Ja(aa)}if(C.shiftKey){var T=Z(h,k,x,y);x=T.x;y=T.y}if(K!=0||aa!=0){T=H.length;for(N=0;N<T;++N){F=H[N];if(F==null)break;var ta=e.createSVGTransform();M=X(F);ta.setTranslate(K,aa);M.numberOfItems?M.replaceItem(ta,0):M.appendItem(ta);Pa.requestSelector(F).resize()}J("transition",H)}}break;case "multiselect":K*=
|
|
n;N*=n;ga(Wa,{x:Math.min(w,K),y:Math.min(v,N),width:Math.abs(K-w),height:Math.abs(N-v)},100);M=[];K=[];ta=Ob();T=H.length;for(N=0;N<T;++N){aa=ta.indexOf(H[N]);if(aa==-1)M.push(H[N]);else ta[aa]=null}T=ta.length;for(N=0;N<T;++N)ta[N]&&K.push(ta[N]);M.length>0&&b.removeFromSelection(M);K.length>0&&Nb(K);break;case "resize":M=X(F);K=(T=ha(M))?G:svgedit.utilities.getBBox(F);N=K.x;ta=K.y;var xa=K.width,ja=K.height;K=x-h;aa=y-k;if(m.gridSnapping){K=Ja(K);aa=Ja(aa);ja=Ja(ja);xa=Ja(xa)}var oa=ma(F);if(oa){var sa=
|
|
Math.sqrt(K*K+aa*aa);aa=Math.atan2(aa,K)-oa*Math.PI/180;K=sa*Math.cos(aa);aa=sa*Math.sin(aa)}if(rb.indexOf("n")==-1&&rb.indexOf("s")==-1)aa=0;if(rb.indexOf("e")==-1&&rb.indexOf("w")==-1)K=0;var za=sa=0,kb=ja?(ja+aa)/ja:1,ob=xa?(xa+K)/xa:1;if(rb.indexOf("n")>=0){kb=ja?(ja-aa)/ja:1;za=ja}if(rb.indexOf("w")>=0){ob=xa?(xa-K)/xa:1;sa=xa}K=e.createSVGTransform();aa=e.createSVGTransform();xa=e.createSVGTransform();if(m.gridSnapping){N=Ja(N);sa=Ja(sa);ta=Ja(ta);za=Ja(za)}K.setTranslate(-(N+sa),-(ta+za));
|
|
if(C.shiftKey)if(ob==1)ob=kb;else kb=ob;aa.setScale(ob,kb);xa.setTranslate(N+sa,ta+za);if(T){T=oa?1:0;M.replaceItem(K,2+T);M.replaceItem(aa,1+T);M.replaceItem(xa,0+T)}else{T=M.numberOfItems;M.replaceItem(xa,T-3);M.replaceItem(aa,T-2);M.replaceItem(K,T-1)}Pa.requestSelector(F).resize();J("transition",H);break;case "zoom":K*=n;N*=n;ga(Wa,{x:Math.min(w*n,K),y:Math.min(v*n,N),width:Math.abs(K-w*n),height:Math.abs(N-v*n)},100);break;case "text":ga(M,{x:x,y:y},1E3);break;case "line":K=null;window.opera||
|
|
e.suspendRedraw(1E3);if(m.gridSnapping){x=Ja(x);y=Ja(y)}N=x;T=y;if(C.shiftKey){T=Z(h,k,N,T);N=T.x;T=T.y}M.setAttributeNS(null,"x2",N);M.setAttributeNS(null,"y2",T);window.opera||e.unsuspendRedraw(K);break;case "foreignObject":case "square":case "rect":case "image":K=Math.abs(x-h);T=Math.abs(y-k);if(Ia=="square"||C.shiftKey){K=T=Math.max(K,T);N=h<x?h:h-K;ta=k<y?k:k-T}else{N=Math.min(h,x);ta=Math.min(k,y)}if(C.altKey){K*=2;T*=2;N=h-K/2;ta=k-T/2}if(m.gridSnapping){K=Ja(K);T=Ja(T);N=Ja(N);ta=Ja(ta)}ga(M,
|
|
{width:K,height:T,x:N,y:ta},1E3);break;case "circle":K=$(M).attr(["cx","cy"]);T=K.cx;N=K.cy;K=Math.sqrt((x-T)*(x-T)+(y-N)*(y-N));if(m.gridSnapping)K=Ja(K);M.setAttributeNS(null,"r",K);break;case "ellipse":$(M).attr(["cx","cy"]);T=Math.abs(h+(x-h)/2);N=Math.abs(k+(y-k)/2);K=null;window.opera||e.suspendRedraw(1E3);if(m.gridSnapping){x=Ja(x);T=Ja(T);y=Ja(y);N=Ja(N)}ta=Math.abs(h-T);aa=Math.abs(k-N);if(C.shiftKey){aa=ta;N=y>k?k+ta:k-ta}if(C.altKey){T=h;N=k;ta=Math.abs(x-T);aa=C.shiftKey?ta:Math.abs(y-
|
|
N)}M.setAttributeNS(null,"rx",ta);M.setAttributeNS(null,"ry",aa);M.setAttributeNS(null,"cx",T);M.setAttributeNS(null,"cy",N);window.opera||e.unsuspendRedraw(K);break;case "fhellipse":case "fhrect":z.minx=Math.min(K,z.minx);z.maxx=Math.max(K,z.maxx);z.miny=Math.min(N,z.miny);z.maxy=Math.max(N,z.maxy);case "fhpath":g+=+K+","+N+" ";M.setAttributeNS(null,"points",g);break;case "path":case "pathedit":x*=n;y*=n;if(m.gridSnapping){x=Ja(x);y=Ja(y);h=Ja(h);k=Ja(k)}if(C.shiftKey){if(T=svgedit.path.path){M=
|
|
T.dragging?T.dragging[0]:h;T=T.dragging?T.dragging[1]:k}else{M=h;T=k}T=Z(M,T,x,y);x=T.x;y=T.y}if(Wa&&Wa.getAttribute("display")!=="none"){K*=n;N*=n;ga(Wa,{x:Math.min(w*n,K),y:Math.min(v*n,N),width:Math.abs(K-w*n),height:Math.abs(N-v*n)},100)}Ua.mouseMove(C,x,y);break;case "textedit":x*=n;y*=n;qb.mouseMove(D,E);break;case "rotate":K=svgedit.utilities.getBBox(F);T=K.x+K.width/2;N=K.y+K.height/2;M=ba(F);M=Q(T,N,M);T=M.x;N=M.y;M=K.x;ta=K.y;if(current_rotate_mode=="nw")M=K.x+K.width;if(current_rotate_mode==
|
|
"se")ta=K.y+K.height;if(current_rotate_mode=="sw"){M=K.x+K.width;ta=K.y+K.height}compensation_angle=(Math.atan2(N-ta,T-M)*(180/Math.PI)-90)%360;oa=(Math.atan2(N-y,T-x)*(180/Math.PI)-90)%360;oa+=compensation_angle;if(m.gridSnapping)oa=Ja(oa);if(C.shiftKey)oa=Math.round(oa/45)*45;b.setRotationAngle(oa<-180?360+oa:oa,true);J("transition",H)}nb("mouseMove",{event:C,mouse_x:D,mouse_y:E,selected:F})}}).click(function(C){C.preventDefault();return false}).dblclick(function(C){var F=C.target.parentNode;if(F!==
|
|
I){var E=ac(C),D=E.tagName;if(D==="text"&&Ia!=="textedit"){C=Q(C.pageX,C.pageY,Pb);qb.select(E,C.x,C.y)}if((D==="g"||D==="a")&&ma(E)){bc(E);E=H[0];cb(true)}I&&cc();F.tagName!=="g"&&F.tagName!=="a"||F===u().getCurrentLayer()||E===Pa.selectorParentGroup||oc(E)}}).mouseup(function(C){if(C.button!==2){var F=La;La=null;if(Sa){var E=Q(C.pageX,C.pageY,Pb),D=E.x*n;E=E.y*n;var M=D/n,K=E/n,N=ua(va()),aa=false;Sa=false;switch(Ia){case "resize":case "multiselect":if(Wa!=null){Wa.setAttribute("display","none");
|
|
jb=[]}Ia="select";case "select":if(H[0]!=null){if(H[1]==null){D=H[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:hb.fill=D.getAttribute("fill");hb.fill_opacity=D.getAttribute("fill-opacity");hb.stroke=D.getAttribute("stroke");hb.stroke_opacity=D.getAttribute("stroke-opacity");hb.stroke_width=D.getAttribute("stroke-width");hb.stroke_dasharray=D.getAttribute("stroke-dasharray");hb.stroke_linejoin=D.getAttribute("stroke-linejoin");hb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName==
|
|
"text"){mb.font_size=D.getAttribute("font-size");mb.font_family=D.getAttribute("font-family")}Pa.requestSelector(D).showGrips(true)}Za();if(M!=w||K!=v){C=H.length;for(D=0;D<C;++D){if(H[D]==null)break;H[D].firstChild||Pa.requestSelector(H[D]).resize()}}else{D=C.target;if(H[0].nodeName==="path"&&H[1]==null)Ua.select(H[0]);else C.shiftKey&&F!=D&&b.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(C=H[0]){C.removeAttribute("style");svgedit.utilities.walkTree(C,function(xa){xa.removeAttribute("style")})}}return;
|
|
case "zoom":Wa!=null&&Wa.setAttribute("display","none");J("zoomed",{x:Math.min(w,M),y:Math.min(v,K),width:Math.abs(M-w),height:Math.abs(K-v),factor:C.altKey?0.5:2});return;case "fhpath":F=N.getAttribute("points");M=F.indexOf(",");if(aa=M>=0?F.indexOf(",",M+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)N=Ua.smoothPolylineIntoPath(N);break;case "line":F=$(N).attr(["x1","x2","y1","y2"]);aa=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(N).attr(["width","height"]);
|
|
aa=F.width!=0||F.height!=0||Ia==="image";break;case "circle":aa=N.getAttribute("r")!=0;break;case "ellipse":F=$(N).attr(["rx","ry"]);aa=F.rx!=null||F.ry!=null;break;case "fhellipse":if(z.maxx-z.minx>0&&z.maxy-z.miny>0){N=ea({element:"ellipse",curStyles:true,attr:{cx:(z.minx+z.maxx)/2,cy:(z.miny+z.maxy)/2,rx:(z.maxx-z.minx)/2,ry:(z.maxy-z.miny)/2,id:va()}});J("changed",[N]);aa=true}break;case "fhrect":if(z.maxx-z.minx>0&&z.maxy-z.miny>0){N=ea({element:"rect",curStyles:true,attr:{x:z.minx,y:z.miny,
|
|
width:z.maxx-z.minx,height:z.maxy-z.miny,id:va()}});J("changed",[N]);aa=true}break;case "text":aa=true;Sb([N]);qb.start(N);break;case "path":N=null;Sa=true;F=Ua.mouseUp(C,N,D,E);N=F.element;aa=F.keep;break;case "pathedit":aa=true;N=null;Ua.mouseUp(C);break;case "textedit":aa=false;N=null;qb.mouseUp(C,D,E);break;case "rotate":aa=true;N=null;Ia="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||Ha(F);Za();J("changed",H)}D=nb("mouseUp",{event:C,mouse_x:D,mouse_y:E},true);$.each(D,function(xa,ja){if(ja){aa=
|
|
ja.keep||aa;N=ja.element;Sa=ja.started||Sa}});if(!aa&&N!=null){u().releaseId(va());N.parentNode.removeChild(N);N=null;for(D=C.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Ia!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&D.id!="svgcanvas"&&D.id!="svgroot"){b.setMode("select");Sb([D],true)}}else if(N!=null){b.addedNew=true;C=0.2;var T;if(false.beginElement&&N.getAttribute("opacity")!=O.opacity){T=$(false).clone().attr({to:O.opacity,dur:C}).appendTo(N);try{T[0].beginElement()}catch(ta){}}else C=
|
|
0;setTimeout(function(){T&&T.remove();N.setAttribute("opacity",O.opacity);N.setAttribute("style","pointer-events:inherit");qa(N);if(Ia==="path")Ua.toEditMode(N);else m.selectNew&&Sb([N],true);Ha(new Qa(N));J("changed",[N])},C*1E3)}gb=null}}});$(a).bind("mousewheel DOMMouseScroll",function(C){if(C.shiftKey){C.preventDefault();Pb=l.getScreenCTM().inverse();var F=Q(C.pageX,C.pageY,Pb);F={x:F.x,y:F.y,width:0,height:0};if(C.wheelDelta)if(C.wheelDelta>=120)F.factor=2;else{if(C.wheelDelta<=-120)F.factor=
|
|
0.5}else if(C.detail)if(C.detail>0)F.factor=0.5;else if(C.detail<0)F.factor=2;F.factor&&J("zoomed",F)}})})();var Lb=function(g){$(g).click(function(h){h.preventDefault()})},qb=b.textActions=function(){function g(ja){var oa=F.value==="";$(F).focus();if(!arguments.length)if(oa)ja=0;else{if(F.selectionEnd!==F.selectionStart)return;ja=F.selectionEnd}var sa;sa=K[ja];oa||F.setSelectionRange(ja,ja);E=ua("text_cursor");if(!E){E=document.createElementNS(c,"line");ga(E,{id:"text_cursor",stroke:"#333","stroke-width":1});
|
|
E=ua("selectorParentGroup").appendChild(E)}M||(M=setInterval(function(){var za=E.getAttribute("display")==="none";E.setAttribute("display",za?"inline":"none")},600));oa=G(sa.x,N.y);sa=G(sa.x,N.y+N.height);ga(E,{x1:oa.x,y1:oa.y,x2:sa.x,y2:sa.y,visibility:"visible",display:"inline"});D&&D.setAttribute("d","")}function h(ja,oa,sa){if(ja===oa)g(oa);else{sa||F.setSelectionRange(ja,oa);D=ua("text_selectblock");if(!D){D=document.createElementNS(c,"path");ga(D,{id:"text_selectblock",fill:"green",opacity:0.5,
|
|
style:"pointer-events:none"});ua("selectorParentGroup").appendChild(D)}ja=K[ja];var za=K[oa];E.setAttribute("visibility","hidden");oa=G(ja.x,N.y);sa=G(ja.x+(za.x-ja.x),N.y);var kb=G(ja.x,N.y+N.height);ja=G(ja.x+(za.x-ja.x),N.y+N.height);ga(D,{d:"M"+oa.x+","+oa.y+" L"+sa.x+","+sa.y+" "+ja.x+","+ja.y+" "+kb.x+","+kb.y+"z",display:"inline"})}}function k(ja,oa){var sa=e.createSVGPoint();sa.x=ja;sa.y=oa;if(K.length==1)return 0;sa=C.getCharNumAtPosition(sa);if(sa<0){sa=K.length-2;if(ja<=K[0].x)sa=0}else if(sa>=
|
|
K.length-2)sa=K.length-2;var za=K[sa];ja>za.x+za.width/2&&sa++;return sa}function w(ja,oa,sa){var za=F.selectionStart;ja=k(ja,oa);h(Math.min(za,ja),Math.max(za,ja),!sa)}function v(ja,oa){var sa={x:ja,y:oa};sa.x/=n;sa.y/=n;if(aa){var za=Q(sa.x,sa.y,aa.inverse());sa.x=za.x;sa.y=za.y}return sa}function G(ja,oa){var sa={x:ja,y:oa};if(aa){var za=Q(sa.x,sa.y,aa);sa.x=za.x;sa.y=za.y}sa.x*=n;sa.y*=n;return sa}function z(ja){h(0,C.textContent.length);$(this).unbind(ja)}function A(ja){if(xa&&C){var oa=Q(ja.pageX,
|
|
ja.pageY,Pb);oa=v(oa.x*n,oa.y*n);oa=k(oa.x,oa.y);var sa=C.textContent,za=sa.substr(0,oa).replace(/[a-z0-9]+$/i,"").length;sa=sa.substr(oa).match(/^[a-z0-9]+/i);h(za,(sa?sa[0].length:0)+oa);$(ja.target).click(z);setTimeout(function(){$(ja.target).unbind("click",z)},300)}}var C,F,E,D,M,K=[],N,aa,T,ta,xa;return{select:function(ja,oa,sa){C=ja;qb.toEditMode(oa,sa)},start:function(ja){C=ja;qb.toEditMode()},mouseDown:function(ja,oa,sa,za){ja=v(sa,za);F.focus();g(k(ja.x,ja.y));T=sa;ta=za},mouseMove:function(ja,
|
|
oa){var sa=v(ja,oa);w(sa.x,sa.y)},mouseUp:function(ja,oa,sa){var za=v(oa,sa);w(za.x,za.y,true);ja.target!==C&&oa<T+2&&oa>T-2&&sa<ta+2&&sa>ta-2&&qb.toSelectMode(true)},setCursor:g,toEditMode:function(ja,oa){xa=false;Ia="textedit";Pa.requestSelector(C).showGrips(false);Pa.requestSelector(C);qb.init();$(C).css("cursor","text");if(arguments.length){var sa=v(ja,oa);g(k(sa.x,sa.y))}else g();setTimeout(function(){xa=true},300)},toSelectMode:function(ja){Ia="select";clearInterval(M);M=null;D&&$(D).attr("display",
|
|
"none");E&&$(E).attr("visibility","hidden");$(C).css("cursor","move");if(ja){cb();$(C).css("cursor","move");J("selected",[C]);Nb([C],true)}C&&!C.textContent.length&&b.deleteSelectedElements();$(F).blur();C=false},setInputElem:function(ja){F=ja},clear:function(){Ia=="textedit"&&qb.toSelectMode()},init:function(){if(C){if(!C.parentNode){C=H[0];Pa.requestSelector(C).showGrips(false)}var ja=C.textContent.length,oa=C.getAttribute("transform");N=svgedit.utilities.getBBox(C);aa=oa?ba(C):null;K=Array(ja);
|
|
F.focus();$(C).unbind("dblclick",A).dblclick(A);if(!ja)var sa={x:N.x+N.width/2,width:0};for(oa=0;oa<ja;oa++){var za=C.getStartPositionOfChar(oa);sa=C.getEndPositionOfChar(oa);if(!svgedit.browser.supportsGoodTextCharPos()){var kb=b.contentW*n;za.x-=kb;sa.x-=kb;za.x/=n;sa.x/=n}K[oa]={x:za.x,y:N.y,width:sa.x-za.x,height:N.height}}K.push({x:sa.x,width:0});h(F.selectionStart,F.selectionEnd,true)}}}}(),Ua=b.pathActions=function(){var g=false,h,k,w;svgedit.path.Path.prototype.endChanges=function(z){if(svgedit.browser.isWebkit()){var A=
|
|
this.elem;A.setAttribute("d",Ua.convertPath(A))}z=new Xa(this.elem,{d:this.last_d},z);Ha(z);J("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(z){$.isArray(z)||(z=[z]);for(var A=0;A<z.length;A++){var C=z[A],F=this.segs[C];F.ptgrip&&this.selected_pts.indexOf(C)==-1&&C>=0&&this.selected_pts.push(C)}this.selected_pts.sort();A=this.selected_pts.length;for(z=Array(A);A--;){F=this.segs[this.selected_pts[A]];F.select(true);z[A]=F.ptgrip}Ua.canDeleteNodes=true;Ua.closed_subpath=
|
|
this.subpathIsClosed(this.selected_pts[0]);J("selected",z)};var v=h=null,G=false;return{mouseDown:function(z,A,C,F){if(Ia==="path"){mouse_x=C;mouse_y=F;F=mouse_x/n;A=mouse_y/n;C=ua("path_stretch_line");k=[F,A];if(m.gridSnapping){F=Ja(F);A=Ja(A);mouse_x=Ja(mouse_x);mouse_y=Ja(mouse_y)}if(!C){C=document.createElementNS(c,"path");ga(C,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});C=ua("selectorParentGroup").appendChild(C)}C.setAttribute("display","inline");var E=null;if(v){E=
|
|
v.pathSegList;for(var D=E.numberOfItems,M=6/n,K=false;D;){D--;var N=E.getItem(D),aa=N.x;N=N.y;if(F>=aa-M&&F<=aa+M&&A>=N-M&&A<=N+M){K=true;break}}M=va();svgedit.path.removePath_(M);M=ua(M);aa=E.numberOfItems;if(K){if(D<=1&&aa>=2){F=E.getItem(0).x;A=E.getItem(0).y;z=C.pathSegList.getItem(1);z=z.pathSegType===4?v.createSVGPathSegLinetoAbs(F,A):v.createSVGPathSegCurvetoCubicAbs(F,A,z.x1/n,z.y1/n,F,A);F=v.createSVGPathSegClosePath();E.appendItem(z);E.appendItem(F)}else if(aa<3)return E=false;$(C).remove();
|
|
element=M;v=null;Sa=false;if(g){svgedit.path.path.matrix&&xb(M,{},svgedit.path.path.matrix.inverse());C=M.getAttribute("d");z=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",z+C);$(M).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ua.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,ac(z))){console.log("Clicked outside canvas");return false}E=v.pathSegList.numberOfItems;D=v.pathSegList.getItem(E-
|
|
1);M=D.x;D=D.y;if(z.shiftKey){z=Z(M,D,F,A);F=z.x;A=z.y}z=C.pathSegList.getItem(1);z=z.pathSegType===4?v.createSVGPathSegLinetoAbs(Gb(F),Gb(A)):v.createSVGPathSegCurvetoCubicAbs(Gb(F),Gb(A),z.x1/n,z.y1/n,z.x2/n,z.y2/n);v.pathSegList.appendItem(z);F*=n;A*=n;C.setAttribute("d",["M",F,A,F,A].join(" "));C=E;if(g)C+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(C,F,A)}}else{d_attr="M"+F+","+A+" ";v=ea({element:"path",curStyles:true,attr:{d:d_attr,id:P(),opacity:O.opacity/2}});C.setAttribute("d",
|
|
["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));C=g?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(C,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();M=z.target.id;if(M.substr(0,14)=="pathpointgrip_"){A=svgedit.path.path.cur_pt=parseInt(M.substr(14));svgedit.path.path.dragging=[C,F];E=svgedit.path.path.segs[A];if(z.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(A):svgedit.path.path.addPtsToSelection(A);else{if(svgedit.path.path.selected_pts.length<=
|
|
1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(A)}}else if(M.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[C,F];z=M.split("_")[1].split("c");A=z[0]-0;svgedit.path.path.selectPt(A,z[1]-0)}if(!svgedit.path.path.dragging){if(Wa==null)Wa=Pa.getRubberBandBox();ga(Wa,{x:C*n,y:F*n,width:0,height:0,display:"inline"},100)}}},mouseMove:function(z,A,C){G=true;if(Ia==="path"){if(v){var F=v.pathSegList;z=F.numberOfItems-1;if(k){var E=svgedit.path.addCtrlGrip("1c1"),
|
|
D=svgedit.path.addCtrlGrip("0c2");D.getAttribute("cx");D.getAttribute("cy");E.setAttribute("cx",A);E.setAttribute("cy",C);E.setAttribute("display","inline");E=k[0];var M=k[1];F.getItem(z);var K=E+(E-A/n),N=M+(M-C/n);D.setAttribute("cx",K*n);D.setAttribute("cy",N*n);D.setAttribute("display","inline");D=svgedit.path.getCtrlLine(1);var aa=svgedit.path.getCtrlLine(2);ga(D,{x1:A,y1:C,x2:E*n,y2:M*n,display:"inline"});ga(aa,{x1:K*n,y1:N*n,x2:E*n,y2:M*n,display:"inline"});if(z===0)w=[A,C];else{F=F.getItem(z-
|
|
1);A=F.x;C=F.y;if(F.pathSegType===6){A+=A-F.x2;C+=C-F.y2}else if(w){A=w[0]/n;C=w[1]/n}svgedit.path.replacePathSeg(6,z,[E,M,A,C,K,N],v)}}else if(E=ua("path_stretch_line")){z=F.getItem(z);if(z.pathSegType===6)svgedit.path.replacePathSeg(6,1,[A,C,(z.x+(z.x-z.x2))*n,(z.y+(z.y-z.y2))*n,A,C],E);else w?svgedit.path.replacePathSeg(6,1,[A,C,w[0],w[1],A,C],E):svgedit.path.replacePathSeg(4,1,[A,C],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},
|
|
svgedit.path.path);M=svgedit.path.getPointFromGrip({x:A,y:C},svgedit.path.path);z=M.x-E.x;E=M.y-E.y;svgedit.path.path.dragging=[A,C];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(z,E):svgedit.path.path.movePts(z,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var T=Wa.getBBox(),ta=svgedit.path.getGripPt(this);T=svgedit.math.rectsIntersect(T,{x:ta.x,y:ta.y,width:0,height:0});this.select(T);T&&svgedit.path.path.selected_pts.push(this.index)}})}},
|
|
mouseUp:function(z,A){if(Ia==="path"){k=null;if(!v){A=ua(va());Sa=false;w=null}return{keep:true,element:A}}if(svgedit.path.path.dragging){var C=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();G&&svgedit.path.path.endChanges("Move path point(s)");!z.shiftKey&&!G&&svgedit.path.path.selectPt(C)}else if(Wa&&Wa.getAttribute("display")!="none"){Wa.setAttribute("display","none");Wa.getAttribute("width")<=2&&Wa.getAttribute("height")<=
|
|
2&&Ua.toSelectMode(z.target)}else Ua.toSelectMode(z.target);G=false},toEditMode:function(z){svgedit.path.path=svgedit.path.getPath_(z);Ia="pathedit";cb();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);g=false},toSelectMode:function(z){var A=z==svgedit.path.path.elem;Ia="select";svgedit.path.path.show(false);h=false;cb();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(A){J("selected",[z]);Nb([z],true)}},addSubPath:function(z){if(z){Ia=
|
|
"path";g=true}else{Ua.clear(true);Ua.toEditMode(svgedit.path.path.elem)}},select:function(z){if(h===z){Ua.toEditMode(z);Ia="pathedit"}else h=z},reorient:function(){var z=H[0];if(z)if(ma(z)!=0){var A=new Na("Reorient path"),C={d:z.getAttribute("d"),transform:z.getAttribute("transform")};A.addSubCommand(new Xa(z,C));cb();this.resetOrientation(z);Ha(A);svgedit.path.getPath_(z).show(false).matrix=null;this.clear();Nb([z],true);J("changed",H)}},clear:function(){h=null;if(v){var z=ua(va());$(ua("path_stretch_line")).remove();
|
|
$(z).remove();$(ua("pathpointgrip_container")).find("*").attr("display","none");v=w=null;Sa=false}else Ia=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(z){if(z==null||z.nodeName!="path")return false;var A=X(z),C=W(A).matrix;A.clear();z.removeAttribute("transform");A=z.pathSegList;for(var F=A.numberOfItems,E=0;E<F;++E){var D=A.getItem(E),M=D.pathSegType;if(M!=1){var K=[];$.each(["",1,2],function(N,aa){var T=D["x"+aa],ta=D["y"+aa];
|
|
if(T!==undefined&&ta!==undefined){T=Q(T,ta,C);K.splice(K.length,0,T.x,T.y)}});svgedit.path.replacePathSeg(M,E,K,z)}}f(z,C)},zoomChange:function(){Ia=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var z=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:z.item.x,y:z.item.y,type:z.type}},linkControlPoints:function(z){svgedit.path.setLinkControlPoints(z)},clonePathNode:function(){svgedit.path.path.storeD();for(var z=svgedit.path.path.selected_pts,
|
|
A=z.length,C=[];A--;){var F=z[A];svgedit.path.path.addSeg(F);C.push(F+A);C.push(F+A+1)}svgedit.path.path.init().addPtsToSelection(C);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var z=svgedit.path.path.selected_pts;if(z.length===1){var A=svgedit.path.path.elem,C=A.pathSegList,F=z[0],E=null,D=null;svgedit.path.path.eachSeg(function(aa){if(this.type===2&&aa<=F)D=this.item;if(aa<=F)return true;if(this.type===2){E=aa;return false}else if(this.type===1)return E=false});
|
|
if(E==null)E=svgedit.path.path.segs.length-1;if(E!==false){var M=A.createSVGPathSegLinetoAbs(D.x,D.y),K=A.createSVGPathSegClosePath();if(E==svgedit.path.path.segs.length-1){C.appendItem(M);C.appendItem(K)}else{svgedit.path.insertItemBefore(A,K,E);svgedit.path.insertItemBefore(A,M,E)}svgedit.path.path.init().selectPt(E+1)}else if(svgedit.path.path.segs[F].mate){C.removeItem(F);C.removeItem(F);svgedit.path.path.init().selectPt(F-1)}else{for(z=0;z<C.numberOfItems;z++){var N=C.getItem(z);if(N.pathSegType===
|
|
2)M=z;else if(z===F)C.removeItem(M);else if(N.pathSegType===1&&F<z){K=z-1;C.removeItem(z);break}}for(z=F-M-1;z--;)svgedit.path.insertItemBefore(A,C.getItem(M),K);A=C.getItem(M);svgedit.path.replacePathSeg(2,M,[A.x,A.y]);z=F;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ua.canDeleteNodes){svgedit.path.path.storeD();for(var z=svgedit.path.path.selected_pts,A=z.length;A--;)svgedit.path.path.deleteSeg(z[A]);var C=function(){var F=svgedit.path.path.elem.pathSegList,E=F.numberOfItems,
|
|
D=function(N,aa){for(;aa--;)F.removeItem(N)};if(E<=1)return true;for(;E--;){var M=F.getItem(E);if(M.pathSegType===1){M=F.getItem(E-1);var K=F.getItem(E-2);if(M.pathSegType===2){D(E-1,2);C();break}else if(K.pathSegType===2){D(E-2,3);C();break}}else if(M.pathSegType===2)if(E>0){M=F.getItem(E-1).pathSegType;if(M===2){D(E-1,1);C();break}else if(M===1&&F.numberOfItems-1===E){D(E,1);C();break}}}return false};C();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ua.toSelectMode(svgedit.path.path.elem);
|
|
b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){z=$(svgedit.path.path.elem);z.attr("d",z.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(z){var A=z.points,C=A.numberOfItems;if(C>=4){var F=A.getItem(0),E=null;z=[];z.push(["M",F.x,",",F.y," C"].join(""));for(var D=1;D<=C-4;D+=3){var M=A.getItem(D),K=A.getItem(D+1),N=A.getItem(D+2);if(E)if((F=svgedit.path.smoothControlPoints(E,M,F))&&F.length==
|
|
2){M=z[z.length-1].split(",");M[2]=F[0].x;M[3]=F[0].y;z[z.length-1]=M.join(",");M=F[1]}z.push([M.x,M.y,K.x,K.y,N.x,N.y].join(","));F=N;E=K}for(z.push("L");D<C;++D){K=A.getItem(D);z.push([K.x,K.y].join(","))}z=z.join(" ");z=ea({element:"path",curStyles:true,attr:{id:va(),d:z,fill:"none"}})}return z},setSegType:function(z){svgedit.path.path.setSegType(z)},moveNode:function(z,A){var C=svgedit.path.path.selected_pts;if(C.length){svgedit.path.path.storeD();C=svgedit.path.path.segs[C[0]];var F={x:0,y:0};
|
|
F[z]=A-C.item[z];C.move(F.x,F.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(z){for(var A=z.pathSegList,C=A.numberOfItems,F,E=0;E<C;++E){var D=A.getItem(E);if(D.pathSegType===2)F=D;if(D.pathSegType===1){D=A.getItem(E-1);if(D.x!=F.x||D.y!=F.y){A=z.createSVGPathSegLinetoAbs(F.x,F.y);svgedit.path.insertItemBefore(z,A,E);Ua.fixEnd(z);break}}}svgedit.browser.isWebkit()&&z.setAttribute("d",Ua.convertPath(z))},convertPath:function(z,A){for(var C=z.pathSegList,F=C.numberOfItems,E=0,
|
|
D=0,M="",K=null,N=0;N<F;++N){var aa=C.getItem(N),T=aa.x||0,ta=aa.y||0,xa=aa.x1||0,ja=aa.y1||0,oa=aa.x2||0,sa=aa.y2||0,za=aa.pathSegType,kb=fb[za]["to"+(A?"Lower":"Upper")+"Case"](),ob=function(Vb,Mb,Rb){Mb=Mb?" "+Mb.join(" "):"";Rb=Rb?" "+svgedit.units.shortFloat(Rb):"";$.each(Vb,function(Xb,dc){Vb[Xb]=svgedit.units.shortFloat(dc)});M+=kb+Vb.join(" ")+Mb+Rb};switch(za){case 1:M+="z";break;case 12:T-=E;case 13:if(A){E+=T;kb="l"}else{T+=E;E=T;kb="L"}ob([[T,D]]);break;case 14:ta-=D;case 15:if(A){D+=
|
|
ta;kb="l"}else{ta+=D;D=ta;kb="L"}ob([[E,ta]]);break;case 2:case 4:case 18:T-=E;ta-=D;case 5:case 3:if(K&&C.getItem(N-1).pathSegType===1&&!A){E=K[0];D=K[1]}case 19:if(A){E+=T;D+=ta}else{T+=E;ta+=D;E=T;D=ta}if(za===3)K=[E,D];ob([[T,ta]]);break;case 6:T-=E;xa-=E;oa-=E;ta-=D;ja-=D;sa-=D;case 7:if(A){E+=T;D+=ta}else{T+=E;xa+=E;oa+=E;ta+=D;ja+=D;sa+=D;E=T;D=ta}ob([[xa,ja],[oa,sa],[T,ta]]);break;case 8:T-=E;xa-=E;ta-=D;ja-=D;case 9:if(A){E+=T;D+=ta}else{T+=E;xa+=E;ta+=D;ja+=D;E=T;D=ta}ob([[xa,ja],[T,ta]]);
|
|
break;case 10:T-=E;ta-=D;case 11:if(A){E+=T;D+=ta}else{T+=E;ta+=D;E=T;D=ta}ob([[aa.r1,aa.r2]],[aa.angle,aa.largeArcFlag?1:0,aa.sweepFlag?1:0],[T,ta]);break;case 16:T-=E;oa-=E;ta-=D;sa-=D;case 17:if(A){E+=T;D+=ta}else{T+=E;oa+=E;ta+=D;sa+=D;E=T;D=ta}ob([[oa,sa],[T,ta]])}}return M}}}(),kc=this.removeUnusedDefElems=function(){var g=l.getElementsByTagNameNS(c,"defs");if(!g||!g.length)return 0;for(var h=[],k=0,w=["fill","stroke","filter","marker-start","marker-mid","marker-end"],v=w.length,G=l.getElementsByTagNameNS(c,
|
|
"*"),z=G.length,A=0;A<z;A++){for(var C=G[A],F=0;F<v;F++){var E=la(C.getAttribute(w[F]));E&&h.push(E.substr(1))}(C=da(C))&&C.indexOf("#")===0&&h.push(C.substr(1))}g=$(g).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(A=g.length;A--;){w=g[A];v=w.id;if(h.indexOf(v)<0){Fb[v]=w;w.parentNode.removeChild(w);k++}}return k};this.svgCanvasToString=function(){for(;kc()>0;);Ua.clear(true);$.each(l.childNodes,function(k,w){k&&w.nodeType===8&&w.data.indexOf("Created with")>=
|
|
0&&l.insertBefore(w,l.firstChild)});if(I){cc();Sb([I])}var g=[];$(l).find("g:data(gsvg)").each(function(){for(var k=this.attributes,w=k.length,v=0;v<w;v++)if(k[v].nodeName=="id"||k[v].nodeName=="style")w--;if(w<=0){k=this.firstChild;g.push(k);$(this).replaceWith(k)}});var h=this.svgToString(l,0);g.length&&$(g).each(function(){ra(this)});return h};this.svgToString=function(g,h){var k=[],w=svgedit.utilities.toXml,v=m.baseUnit,G=RegExp("^-?[\\d\\.]+"+v+"$");if(g){qa(g);var z=g.attributes,A,C,F=g.childNodes;
|
|
for(C=0;C<h;C++)k.push(" ");k.push("<");k.push(g.nodeName);if(g.id==="svgcontent"){C=Yb();if(v!=="px"){C.w=svgedit.units.convertUnit(C.w,v)+v;C.h=svgedit.units.convertUnit(C.h,v)+v}k.push(' width="'+C.w+'" height="'+C.h+'" xmlns="'+c+'"');var E={};$(g).find("*").andSelf().each(function(){$.each(this.attributes,function(N,aa){var T=aa.namespaceURI;if(T&&!E[T]&&Ga[T]!=="xmlns"&&Ga[T]!=="xml"){E[T]=true;k.push(" xmlns:"+Ga[T]+'="'+T+'"')}})});C=z.length;for(v=["width","height","xmlns","x","y","viewBox",
|
|
"id","overflow"];C--;){A=z.item(C);var D=w(A.nodeValue);if(A.nodeName.indexOf("xmlns:")!==0)if(D!=""&&v.indexOf(A.localName)==-1)if(!A.namespaceURI||Ga[A.namespaceURI]){k.push(" ");k.push(A.nodeName);k.push('="');k.push(D);k.push('"')}}}else{if(g.nodeName==="defs"&&!g.firstChild)return;var M=["-moz-math-font-style","_moz-math-font-style"];for(C=z.length-1;C>=0;C--){A=z.item(C);D=w(A.nodeValue);if(!(M.indexOf(A.localName)>=0))if(D!="")if(D.indexOf("pointer-events")!==0)if(!(A.localName==="class"&&
|
|
D.indexOf("se_")===0)){k.push(" ");if(A.localName==="d")D=Ua.convertPath(g,true);if(isNaN(D)){if(G.test(D))D=svgedit.units.shortFloat(D)+v}else D=svgedit.units.shortFloat(D);if(bb.apply&&g.nodeName==="image"&&A.localName==="href"&&bb.images&&bb.images==="embed"){var K=Ka[D];if(K)D=K}if(!A.namespaceURI||A.namespaceURI==c||Ga[A.namespaceURI]){k.push(A.nodeName);k.push('="');k.push(D);k.push('"')}}}}if(g.hasChildNodes()){k.push(">");h++;z=false;for(C=0;C<F.length;C++){v=F.item(C);switch(v.nodeType){case 1:k.push("\n");
|
|
k.push(this.svgToString(F.item(C),h));break;case 3:v=v.nodeValue.replace(/^\s+|\s+$/g,"");if(v!=""){z=true;k.push(w(v)+"")}break;case 4:k.push("\n");k.push(Array(h+1).join(" "));k.push("<![CDATA[");k.push(v.nodeValue);k.push("]]\>");break;case 8:k.push("\n");k.push(Array(h+1).join(" "));k.push("<!--");k.push(v.data);k.push("--\>")}}h--;if(!z){k.push("\n");for(C=0;C<h;C++)k.push(" ")}k.push("</");k.push(g.nodeName);k.push(">")}else k.push("/>")}return k.join("")};this.embedImage=function(g,h){$(new Image).load(function(){var k=
|
|
document.createElement("canvas");k.width=this.width;k.height=this.height;k.getContext("2d").drawImage(this,0,0);try{var w=";svgedit_url="+encodeURIComponent(g);w=k.toDataURL().replace(";base64",w+";base64");Ka[g]=w}catch(v){Ka[g]=false}Da=g;h&&h(Ka[g])}).attr("src",g)};this.setGoodImage=function(g){Da=g};this.open=function(){};this.save=function(g){cb();g&&$.extend(bb,g);bb.apply=true;g=this.svgCanvasToString();J("saved",g)};this.rasterExport=function(){cb();var g=[],h={feGaussianBlur:Jb.exportNoBlur,
|
|
foreignObject:Jb.exportNoforeignObject,"[stroke-dasharray]":Jb.exportNoDashArray},k=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=Jb.exportNoText;$.each(h,function(w,v){k.find(w).length&&g.push(v)});h=this.svgCanvasToString();J("exported",{svg:h,issues:g})};this.getSvgString=function(){bb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,u()):svgedit.draw.randomizeIds(true,u())};var hc=this.uniquifyElems=
|
|
function(g){var h={},k=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(g,function(A){if(A.nodeType==1){if(A.id){A.id in h||(h[A.id]={elem:null,attrs:[],hrefs:[]});h[A.id].elem=A}$.each(tb,function(F,E){var D=A.getAttributeNode(E);if(D){var M=svgedit.utilities.getUrlFromAttr(D.value);if(M=M?M.substr(1):null){M in h||(h[M]={elem:null,attrs:[],hrefs:[]});h[M].attrs.push(D)}}});var C=svgedit.utilities.getHref(A);if(C&&k.indexOf(A.nodeName)>=
|
|
0)if(C=C.substr(1)){C in h||(h[C]={elem:null,attrs:[],hrefs:[]});h[C].hrefs.push(A)}}});for(var w in h)if(w){var v=h[w].elem;if(v){g=P();v.id=g;v=h[w].attrs;for(var G=v.length;G--;){var z=v[G];z.ownerElement.setAttribute(z.name,"url(#"+g+")")}v=h[w].hrefs;for(G=v.length;G--;)svgedit.utilities.setHref(v[G],"#"+g)}}},gc=this.setUseData=function(g){var h=$(g);if(g.tagName!=="use")h=h.find("use");h.each(function(){var k=da(this).substr(1);if(k=ua(k)){$(this).data("ref",k);if(k.tagName=="symbol"||k.tagName==
|
|
"svg")$(this).data("symbol",k).data("ref",k)}})},ec=this.convertGradients=function(g){var h=$(g).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(g).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var k=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(k.length)if(k=svgedit.utilities.getBBox(k[0]))if(this.tagName==="linearGradient"){var w=$(this).attr(["x1",
|
|
"y1","x2","y2"]),v=this.gradientTransform.baseVal;if(v&&v.numberOfItems>0){var G=W(v).matrix;v=Q(w.x1,w.y1,G);G=Q(w.x2,w.y2,G);w.x1=v.x;w.y1=v.y;w.x2=G.x;w.y2=G.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(w.x1-k.x)/k.width,y1:(w.y1-k.y)/k.height,x2:(w.x2-k.x)/k.width,y2:(w.y2-k.y)/k.height});this.removeAttribute("gradientUnits")}}})},ic=this.convertToGroup=function(g){g||(g=H[0]);var h=$(g),k=new Na,w;if(h.data("gsvg")){k=$(g.firstChild).attr(["x","y"]);$(g.firstChild.firstChild).unwrap();
|
|
$(g).removeData("gsvg");w=X(g);var v=e.createSVGTransform();v.setTranslate(k.x,k.y);w.appendItem(v);pb(g);J("selected",[g])}else if(h.data("symbol")){g=h.data("symbol");w=h.attr("transform");v=h.attr(["x","y"]);var G=g.getAttribute("viewBox");if(G){G=G.split(" ");v.x-=+G[0];v.y-=+G[1]}w+=" translate("+(v.x||0)+","+(v.y||0)+")";v=h.prev();k.addSubCommand(new Va(h[0],h[0].nextSibling,h[0].parentNode));h.remove();G=$(l).find("use:data(symbol)").length;h=d.createElementNS(c,"g");for(var z=g.childNodes,
|
|
A=0;A<z.length;A++)h.appendChild(z[A].cloneNode(true));if(svgedit.browser.isGecko()){z=$(Bb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(z)}w&&h.setAttribute("transform",w);w=g.parentNode;hc(h);svgedit.browser.isGecko()&&$(Bb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=P();v.after(h);if(w){if(!G){v=g.nextSibling;w.removeChild(g);k.addSubCommand(new Va(g,v,w))}k.addSubCommand(new Qa(h))}gc(h);svgedit.browser.isGecko()?ec(Bb()):ec(h);svgedit.utilities.walkTreePost(h,
|
|
function(C){try{pb(C)}catch(F){console.log(F)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=P()});Sb([h]);(g=bc(h,true))&&k.addSubCommand(g);Ha(k)}else console.log("Unexpected element to ungroup:",g)};this.setSvgString=function(g){try{var h=svgedit.utilities.text2xml(g);this.prepareSvg(h);var k=new Na("Change Source"),w=l.nextSibling,v=e.removeChild(l);k.addSubCommand(new Va(v,w,e));l=d.adoptNode?d.adoptNode(h.documentElement):
|
|
d.importNode(h.documentElement,true);e.appendChild(l);var G=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,q);var z=u().getNonce();z?J("setnonce",z):J("unsetnonce");G.find("image").each(function(){var K=this;Lb(K);var N=da(this);if(N.indexOf("data:")===0){var aa=N.match(/svgedit_url=(.*?);/);if(aa){var T=decodeURIComponent(aa[1]);$(new Image).load(function(){K.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",T)}).attr("src",T)}}b.embedImage(N)});G.find("svg").each(function(){if(!$(this).closest("defs").length){hc(this);
|
|
var K=this.parentNode;if(K.childNodes.length===1&&K.nodeName==="g"){$(K).data("gsvg",this);K.id=K.id||P()}else ra(this)}});svgedit.browser.isGecko()&&G.find("linearGradient, radialGradient, pattern").appendTo(Bb());gc(G);ec(G[0]);svgedit.utilities.walkTreePost(l,function(K){try{pb(K)}catch(N){console.log(N)}});var A={id:"svgcontent",overflow:m.show_outside_canvas?"visible":"hidden"},C=false;if(G.attr("viewBox")){var F=G.attr("viewBox").split(" ");A.width=F[2];A.height=F[3]}else $.each(["width","height"],
|
|
function(K,N){var aa=G.attr(N);aa||(aa="100%");if((aa+"").substr(-1)==="%")C=true;else A[N]=ka(N,aa)});Tb();G.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=P()});if(C){var E=getStrokedBBox();A.width=E.width+E.x;A.height=E.height+E.y}if(A.width<=0)A.width=100;if(A.height<=0)A.height=100;G.attr(A);this.contentW=A.width;this.contentH=A.height;k.addSubCommand(new Qa(l));var D=G.attr(["width","height"]);
|
|
k.addSubCommand(new Xa(e,D));n=1;svgedit.transformlist.resetListMap();cb();svgedit.path.clearData();e.appendChild(Pa.selectorParentGroup);Ha(k);J("changed",[l])}catch(M){console.log(M);return false}return true};this.importSvgString=function(g){try{var h=svgedit.utilities.encode64(g.length+g).substr(0,32),k=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)k=true;var w=new Na("Import SVG");if(k)var v=sb[h].symbol,G=sb[h].xform;else{var z=svgedit.utilities.text2xml(g);this.prepareSvg(z);
|
|
var A;A=d.adoptNode?d.adoptNode(z.documentElement):d.importNode(z.documentElement,true);hc(A);var C=ka("width",A.getAttribute("width")),F=ka("height",A.getAttribute("height")),E=A.getAttribute("viewBox"),D=E?E.split(" "):[0,0,C,F];for(g=0;g<4;++g)D[g]=+D[g];l.getAttribute("width");var M=+l.getAttribute("height");G=F>C?"scale("+M/3/D[3]+")":"scale("+M/3/D[2]+")";G="translate(0) "+G+" translate(0)";v=d.createElementNS(c,"symbol");var K=Bb();for(svgedit.browser.isGecko()&&$(A).find("linearGradient, radialGradient, pattern").appendTo(K);A.firstChild;)v.appendChild(A.firstChild);
|
|
var N=A.attributes;for(A=0;A<N.length;A++){var aa=N[A];v.setAttribute(aa.nodeName,aa.nodeValue)}v.id=P();sb[h]={symbol:v,xform:G};Bb().appendChild(v);w.addSubCommand(new Qa(v))}var T=d.createElementNS(c,"use");T.id=P();Y(T,"#"+v.id);(I||u().getCurrentLayer()).appendChild(T);w.addSubCommand(new Qa(T));cb();T.setAttribute("transform",G);pb(T);$(T).data("symbol",v).data("ref",v);Nb([T]);Ha(w);J("changed",[l])}catch(ta){console.log(ta);return false}return true};var Tb=b.identifyLayers=function(){cc();
|
|
u().identifyLayers()};this.createLayer=function(g){var h=new Na("Create Layer");g=u().createLayer(g);h.addSubCommand(new Qa(g));Ha(h);cb();J("changed",[g])};this.cloneLayer=function(g){var h=new Na("Duplicate Layer"),k=d.createElementNS(c,"g"),w=d.createElementNS(c,"title");w.textContent=g;k.appendChild(w);w=u().getCurrentLayer();$(w).after(k);w=w.childNodes;for(var v=0;v<w.length;v++){var G=w[v];G.localName!="title"&&k.appendChild(ia(G))}cb();Tb();h.addSubCommand(new Qa(k));Ha(h);b.setCurrentLayer(g);
|
|
J("changed",[k])};this.deleteCurrentLayer=function(){var g=u().getCurrentLayer(),h=g.nextSibling,k=g.parentNode;if(g=u().deleteCurrentLayer()){var w=new Na("Delete Layer");w.addSubCommand(new Va(g,h,k));Ha(w);cb();J("changed",[k]);return true}return false};this.setCurrentLayer=function(g){(g=u().setCurrentLayer(svgedit.utilities.toXml(g)))&&cb();return g};this.renameCurrentLayer=function(g){var h=u();if(h.current_layer){var k=h.current_layer;if(!b.setCurrentLayer(g)){for(var w=new Na("Rename Layer"),
|
|
v=0;v<h.getNumLayers();++v)if(h.all_layers[v][1]==k)break;var G=h.getLayerName(v);h.all_layers[v][0]=svgedit.utilities.toXml(g);var z=k.childNodes.length;for(v=0;v<z;++v){var A=k.childNodes.item(v);if(A&&A.tagName=="title"){for(;A.firstChild;)A.removeChild(A.firstChild);A.textContent=g;w.addSubCommand(new Xa(A,{"#text":G}));Ha(w);J("changed",[k]);return true}}}h.current_layer=k}return false};this.setCurrentLayerPosition=function(g){var h=u();if(h.current_layer&&g>=0&&g<h.getNumLayers()){for(var k=
|
|
0;k<h.getNumLayers();++k)if(h.all_layers[k][1]==h.current_layer)break;if(k==h.getNumLayers())return false;if(k!=g){var w=null,v=h.current_layer.nextSibling;if(g>k){if(g<h.getNumLayers()-1)w=h.all_layers[g+1][1]}else w=h.all_layers[g][1];l.insertBefore(h.current_layer,w);Ha(new Ra(h.current_layer,v,l));Tb();b.setCurrentLayer(h.getLayerName(g));return true}}return false};this.setLayerVisibility=function(g,h){var k=u(),w=k.getLayerVisibility(g),v=k.setLayerVisibility(g,h);if(v)Ha(new Xa(v,{display:w?
|
|
"inline":"none"},"Layer Visibility"));else return false;if(v==k.getCurrentLayer()){cb();Ua.clear()}return true};this.moveSelectedToLayer=function(g){for(var h=null,k=u(),w=0;w<k.getNumLayers();++w)if(k.getLayerName(w)==g){h=k.all_layers[w][1];break}if(!h)return false;g=new Na("Move Elements to Layer");k=H;for(w=k.length;w--;){var v=k[w];if(v){var G=v.nextSibling,z=v.parentNode;h.appendChild(v);g.addSubCommand(new Ra(v,G,z))}}Ha(g);return true};this.mergeLayer=function(g){var h=new Na("Merge Layer"),
|
|
k=u(),w=$(k.current_layer).prev()[0];if(w){for(h.addSubCommand(new Va(k.current_layer,k.current_layer.nextSibling,l));k.current_layer.firstChild;){var v=k.current_layer.firstChild;if(v.localName=="title"){h.addSubCommand(new Va(v,v.nextSibling,k.current_layer));k.current_layer.removeChild(v)}else{var G=v.nextSibling;w.appendChild(v);h.addSubCommand(new Ra(v,G,k.current_layer))}}l.removeChild(k.current_layer);if(!g){cb();Tb();J("changed",[l]);Ha(h)}k.current_layer=w;return h}};this.mergeAllLayers=
|
|
function(){var g=new Na("Merge all Layers"),h=u();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)g.addSubCommand(b.mergeLayer(true));cb();Tb();J("changed",[l]);Ha(g)};var cc=this.leaveContext=function(){var g=yb.length;if(g){for(var h=0;h<g;h++){var k=yb[h],w=ab(k,"orig_opac");w!==1?k.setAttribute("opacity",w):k.removeAttribute("opacity");k.setAttribute("style","pointer-events: inherit")}yb=[];cb(true);J("contextset",null)}I=null},oc=this.setContext=function(g){cc();
|
|
if(typeof g==="string")g=ua(g);I=g;$(g).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;ab(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style","pointer-events: none");yb.push(this)});cb();J("contextset",I)};this.clear=function(){Ua.clear();cb();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Pa.initGroup();Wa=Pa.getRubberBandBox();J("cleared")};
|
|
this.linkControlPoints=Ua.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return e};this.getSelectedElems=function(){return H};var Yb=this.getResolution=function(){var g=l.getAttribute("width")/n,h=l.getAttribute("height")/n;return{w:g,h:h,zoom:n}};this.getZoom=function(){return n};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(g){$.extend(Jb,g.notification)};this.setConfig=function(g){$.extend(m,g)};this.getTitle=
|
|
function(g){if(g=g||H[0]){g=$(g).data("gsvg")||$(g).data("symbol")||g;g=g.childNodes;for(var h=0;h<g.length;h++)if(g[h].nodeName=="title")return g[h].textContent;return""}};this.setGroupTitle=function(g){var h=H[0];h=$(h).data("gsvg")||h;var k=$(h).children("title"),w=new Na("Set Label");if(g.length)if(k.length){k=k[0];w.addSubCommand(new Xa(k,{"#text":k.textContent}));k.textContent=g}else{k=d.createElementNS(c,"title");k.textContent=g;$(h).prepend(k);w.addSubCommand(new Qa(k))}else{w.addSubCommand(new Va(k[0],
|
|
k.nextSibling,h));k.remove()}Ha(w)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(g){for(var h=l.childNodes,k=false,w="",v=new Na("Change Image Title"),G=0;G<h.length;G++)if(h[G].nodeName=="title"){k=h[G];w=k.textContent;break}if(!k){k=d.createElementNS(c,"title");l.insertBefore(k,l.firstChild)}if(g.length)k.textContent=g;else k.parentNode.removeChild(k);v.addSubCommand(new Xa(k,{"#text":w}));Ha(v)};this.getEditorNS=function(g){g&&l.setAttribute("xmlns:se",
|
|
"http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(g,h){var k=Yb(),w=k.w;k=k.h;var v;if(g=="fit"){var G=getStrokedBBox();if(G){v=new Na("Fit Canvas to Content");var z=Kb();Nb(z);var A=[],C=[];$.each(z,function(){A.push(G.x*-1);C.push(G.y*-1)});z=b.moveSelectedElements(A,C,true);v.addSubCommand(z);cb();g=Math.round(G.width);h=Math.round(G.height)}else return false}if(g!=w||h!=k){z=e.suspendRedraw(1E3);v||(v=new Na("Change Image Dimensions"));g=ka("width",
|
|
g);h=ka("height",h);l.setAttribute("width",g);l.setAttribute("height",h);this.contentW=g;this.contentH=h;v.addSubCommand(new Xa(l,{width:w,height:k}));l.setAttribute("viewBox",[0,0,g/n,h/n].join(" "));v.addSubCommand(new Xa(l,{viewBox:["0 0",w,k].join(" ")}));Ha(v);e.unsuspendRedraw(z);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",g+2);background.setAttribute("height",h+2)}J("changed",[l])}return true};
|
|
this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var w=0.85,v=function(G){if(!G)return false;var z=Math.min(Math.round(h/G.width*100*w)/100,Math.round(k/G.height*100*w)/100);b.setZoom(z);return{zoom:z,bbox:G}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:n*g.factor);return{zoom:n,bbox:g}}return v(g)}switch(g){case "selection":if(!H[0])return;g=$.map(H,function(G){if(G)return G});g=getStrokedBBox(g);break;case "canvas":g=Yb();
|
|
w=0.95;g={width:g.w,height:g.h,x:0,y:0};break;case "content":g=getStrokedBBox();break;case "layer":g=getStrokedBBox(Kb(u().getCurrentLayer()));break;default:return}return v(g)};this.setZoom=function(g){var h=Yb();l.setAttribute("viewBox","0 0 "+h.w/g+" "+h.h/g);n=g;$.each(H,function(k,w){w&&Pa.requestSelector(w).resize()});Ua.zoomChange();nb("zoomChanged",g)};this.getMode=function(){return Ia};this.setMode=function(g){Ua.clear(true);qb.clear();$("#workarea").attr("class",g);hb=H[0]&&H[0].nodeName==
|
|
"text"?mb:O;Ia=g};this.getColor=function(g){return hb[g]};this.setColor=function(g,h,k){O[g]=h;hb[g+"_paint"]={type:"solidColor"};for(var w=[],v=H.length;v--;){var G=H[v];if(G)if(G.tagName=="g")svgedit.utilities.walkTree(G,function(z){z.nodeName!="g"&&w.push(z)});else if(g=="fill")G.tagName!="polyline"&&G.tagName!="line"&&w.push(G);else w.push(G)}if(w.length>0)if(k)vb(g,h,w);else{ub(g,h,w);J("changed",w)}};var Bb=function(){var g=l.getElementsByTagNameNS(c,"defs");if(g.length>0)g=g[0];else{g=d.createElementNS(c,
|
|
"defs");l.firstChild?l.insertBefore(g,l.firstChild.nextSibling):l.appendChild(g)}return g},mc=this.setGradient=function(g){if(!(!hb[g+"_paint"]||hb[g+"_paint"].type=="solidColor")){var h=b[g+"Grad"],k=lc(h),w=Bb();if(k)h=k;else{h=w.appendChild(d.importNode(h,true));h.id=P()}b.setColor(g,"url(#"+h.id+")");if(g=="canvas")(g=document.getElementById("canvas_background"))&&g.setAttribute("fill","url(#"+h.id+")")}},lc=function(g){var h=Bb();h=$(h).find("linearGradient, radialGradient");for(var k=h.length,
|
|
w=["r","cx","cy","fx","fy"];k--;){var v=h[k];if(g.tagName=="linearGradient"){if(g.getAttribute("x1")!=v.getAttribute("x1")||g.getAttribute("y1")!=v.getAttribute("y1")||g.getAttribute("x2")!=v.getAttribute("x2")||g.getAttribute("y2")!=v.getAttribute("y2"))continue}else{var G=$(g).attr(w),z=$(v).attr(w),A=false;$.each(w,function(K,N){if(G[N]!=z[N])A=true});if(A)continue}var C=g.getElementsByTagNameNS(c,"stop"),F=v.getElementsByTagNameNS(c,"stop");if(C.length==F.length){for(var E=C.length;E--;){var D=
|
|
C[E],M=F[E];if(D.getAttribute("offset")!=M.getAttribute("offset")||D.getAttribute("stop-opacity")!=M.getAttribute("stop-opacity")||D.getAttribute("stop-color")!=M.getAttribute("stop-color"))break}if(E==-1)return v}}return null};this.setPaint=function(g,h){var k=new $.jGraduate.Paint(h);this.setPaintOpacity(g,k.alpha/100,true);hb[g+"_paint"]=k;switch(k.type){case "solidColor":if(k.solidColor!="none"&&k.solidColor!="#none")this.setColor(g,"#"+k.solidColor);else{this.setColor(g,"none");document.querySelector(g==
|
|
"fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","none")}break;case "linearGradient":case "radialGradient":b[g+"Grad"]=k[k.type];mc(g)}};this.getStrokeWidth=function(){return hb.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Ia)>=0)b.setStrokeWidth(1);else{hb.stroke_width=g;for(var h=[],k=H.length;k--;){var w=H[k];if(w)w.tagName=="g"?svgedit.utilities.walkTree(w,function(v){v.nodeName!="g"&&h.push(v)}):h.push(w)}if(h.length>0){ub("stroke-width",g,
|
|
h);J("changed",H)}}};this.setStrokeAttr=function(g,h){O[g.replace("-","_")]=h;for(var k=[],w=H.length;w--;){var v=H[w];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(G){G.nodeName!="g"&&k.push(G)}):k.push(v)}if(k.length>0){ub(g,h,k);J("changed",H)}};this.getStyle=function(){return O};this.getOpacity=function(){return O.opacity};this.setOpacity=function(g){O.opacity=g;ub("opacity",g)};this.getFillOpacity=function(){return O.fill_opacity};this.getStrokeOpacity=function(){return O.stroke_opacity};
|
|
this.setPaintOpacity=function(g,h,k){O[g+"_opacity"]=h;k?vb(g+"-opacity",h):ub(g+"-opacity",h)};this.getBlur=function(g){var h=0;if(g)if(g.getAttribute("filter"))if(g=ua(g.id+"_blur"))h=g.firstChild.getAttribute("stdDeviation");return h};(function(){function g(){var v=b.undoMgr.finishUndoableChange();h.addSubCommand(v);Ha(h);k=h=null}var h=null,k=null,w=false;b.setBlurNoUndo=function(v){if(k)if(v===0){vb("filter","");w=true}else{var G=H[0];w&&vb("filter","url(#"+G.id+"_blur)");if(svgedit.browser.isWebkit()){G.removeAttribute("filter");
|
|
G.setAttribute("filter","url(#"+G.id+"_blur)")}vb("stdDeviation",v,[k.firstChild]);b.setBlurOffsets(k,v)}else b.setBlur(v)};b.setBlurOffsets=function(v,G){if(G>3)ga(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")}};b.setBlur=function(v,G){if(h)g();else{var z=H[0],A=z.id;k=ua(A+"_blur");v-=0;var C=new Na;if(k){if(v===0)k=null}else{var F=ea({element:"feGaussianBlur",
|
|
attr:{"in":"SourceGraphic",stdDeviation:v}});k=ea({element:"filter",attr:{id:A+"_blur"}});k.appendChild(F);Bb().appendChild(k);C.addSubCommand(new Qa(k))}F={filter:z.getAttribute("filter")};if(v===0){z.removeAttribute("filter");C.addSubCommand(new Xa(z,F))}else{ub("filter","url(#"+A+"_blur)");C.addSubCommand(new Xa(z,F));b.setBlurOffsets(k,v);h=C;b.undoMgr.beginUndoableChange("stdDeviation",[k?k.firstChild:null]);if(G){b.setBlurNoUndo(v);g()}}}}})();this.getBold=function(){var g=H[0];if(g!=null&&
|
|
g.tagName=="text"&&H[1]==null)return g.getAttribute("font-weight")=="bold";return false};this.setBold=function(g){var h=H[0];if(h!=null&&h.tagName=="text"&&H[1]==null)ub("font-weight",g?"bold":"normal");H[0].textContent||qb.setCursor()};this.getItalic=function(){var g=H[0];if(g!=null&&g.tagName=="text"&&H[1]==null)return g.getAttribute("font-style")=="italic";return false};this.setItalic=function(g){var h=H[0];if(h!=null&&h.tagName=="text"&&H[1]==null)ub("font-style",g?"italic":"normal");H[0].textContent||
|
|
qb.setCursor()};this.getFontFamily=function(){return mb.font_family};this.setFontFamily=function(g){mb.font_family=g;ub("font-family",g);H[0]&&!H[0].textContent&&qb.setCursor()};this.setFontColor=function(g){mb.fill=g;ub("fill",g)};this.getFontSize=function(){return mb.fill};this.getFontSize=function(){return mb.font_size};this.setFontSize=function(g){mb.font_size=g;ub("font-size",g);H[0].textContent||qb.setCursor()};this.getText=function(){var g=H[0];if(g==null)return"";return g.textContent};this.setTextContent=
|
|
function(g){ub("#text",g);qb.init(g);qb.setCursor()};this.setImageURL=function(g){var h=H[0];if(h){var k=$(h).attr(["width","height"]);k=!k.width||!k.height;var w=da(h);if(w!==g)k=true;else if(!k)return;var v=new Na("Change Image URL");Y(h,g);v.addSubCommand(new Xa(h,{"#href":w}));k?$(new Image).load(function(){var G=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Pa.requestSelector(h).resize();v.addSubCommand(new Xa(h,G));Ha(v);J("changed",[h])}).attr("src",g):Ha(v)}};
|
|
this.setLinkURL=function(g){var h=H[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var k=da(h);if(k!==g){var w=new Na("Change Link URL");Y(h,g);w.addSubCommand(new Xa(h,{"#href":k}));Ha(w)}}};this.setRectRadius=function(g){var h=H[0];if(h!=null&&h.tagName=="rect"){var k=h.getAttribute("rx");if(k!=g){h.setAttribute("rx",g);h.setAttribute("ry",g);Ha(new Xa(h,{rx:k,ry:k},"Radius"));J("changed",[h])}}};this.makeHyperlink=function(g){b.groupSelectedElements("a",g)};this.removeHyperlink=
|
|
function(){b.ungroupSelectedElement()};this.setSegType=function(g){Ua.setSegType(g)};this.convertToPath=function(g,h){if(g==null)$.each(H,function(xa,ja){ja&&b.convertToPath(ja)});else{if(!h)var k=new Na("Convert element to Path");var w=h?{}:{fill:O.fill,"fill-opacity":O.fill_opacity,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,opacity:O.opacity,visibility:"hidden"};
|
|
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(g.getAttribute(this))w[this]=g.getAttribute(this)});var v=ea({element:"path",attr:w}),G=g.getAttribute("transform");G&&v.setAttribute("transform",G);var z=g.id,A=g.parentNode;g.nextSibling?A.insertBefore(v,g):A.appendChild(v);var C="",F=function(xa){$.each(xa,function(ja,oa){var sa=oa[1];C+=oa[0];for(var za=0;za<sa.length;za+=2)C+=sa[za]+","+sa[za+1]+" "})},E=1.81;switch(g.tagName){case "ellipse":case "circle":var D=
|
|
$(g).attr(["rx","ry","cx","cy"]),M=D.cx,K=D.cy,N=D.rx;D=D.ry;if(g.tagName=="circle")N=D=$(g).attr("r");F([["M",[M-N,K]],["C",[M-N,K-D/E,M-N/E,K-D,M,K-D]],["C",[M+N/E,K-D,M+N,K-D/E,M+N,K]],["C",[M+N,K+D/E,M+N/E,K+D,M,K+D]],["C",[M-N/E,K+D,M-N,K+D/E,M-N,K]],["Z",[]]]);break;case "path":C=g.getAttribute("d");break;case "line":D=$(g).attr(["x1","y1","x2","y2"]);C="M"+D.x1+","+D.y1+"L"+D.x2+","+D.y2;break;case "polyline":case "polygon":C="M"+g.getAttribute("points");break;case "rect":D=$(g).attr(["rx",
|
|
"ry"]);N=D.rx;D=D.ry;var aa=g.getBBox();M=aa.x;K=aa.y;var T=aa.width;aa=aa.height;E=4-E;!N&&!D?F([["M",[M,K]],["L",[M+T,K]],["L",[M+T,K+aa]],["L",[M,K+aa]],["L",[M,K]],["Z",[]]]):F([["M",[M,K+D]],["C",[M,K+D/E,M+N/E,K,M+N,K]],["L",[M+T-N,K]],["C",[M+T-N/E,K,M+T,K+D/E,M+T,K+D]],["L",[M+T,K+aa-D]],["C",[M+T,K+aa-D/E,M+T-N/E,K+aa,M+T-N,K+aa]],["L",[M+N,K+aa]],["C",[M+N/E,K+aa,M,K+aa-D/E,M,K+aa-D]],["L",[M,K+D]],["Z",[]]]);break;default:v.parentNode.removeChild(v)}C&&v.setAttribute("d",C);if(h){Ua.resetOrientation(v);
|
|
k=false;try{k=v.getBBox()}catch(ta){}v.parentNode.removeChild(v);return k}else{if(G){G=X(v);ha(G)&&Ua.resetOrientation(v)}k.addSubCommand(new Va(g,g.nextSibling,A));k.addSubCommand(new Qa(v));cb();g.parentNode.removeChild(g);v.setAttribute("id",z);v.removeAttribute("visibility");Nb([v],true);Ha(k)}}};var vb=function(g,h,k){var w=e.suspendRedraw(1E3);Ia=="pathedit"&&Ua.moveNode(g,h);k=k||H;for(var v=k.length,G=["g","polyline","path"];v--;){var z=k[v];if(z!=null){Ia==="textedit"&&g!=="#text"&&z.textContent.length&&
|
|
qb.toSelectMode(z);if((g==="x"||g==="y")&&G.indexOf(z.tagName)>=0){var A=getStrokedBBox([z]);b.moveSelectedElements((g==="x"?h-A.x:0)*n,(g==="y"?h-A.y:0)*n,true)}else{A=g==="#text"?z.textContent:z.getAttribute(g);if(A==null)A="";if(A!==String(h)){if(g=="#text"){svgedit.utilities.getBBox(z);z.textContent=h;if(/rotate/.test(z.getAttribute("transform")))z=Oa(z)}else g=="#href"?Y(z,h):z.setAttribute(g,h);if(svgedit.browser.isGecko()&&z.nodeName==="text"&&/rotate/.test(z.getAttribute("transform")))if((h+
|
|
"").indexOf("url")===0||["font-size","font-family","x","y"].indexOf(g)>=0&&z.textContent)z=Oa(z);H.indexOf(z)>=0&&setTimeout(function(){z.parentNode&&Pa.requestSelector(z).resize()},0);A=ma(z);if(A!=0&&g!="transform")for(var C=X(z),F=C.numberOfItems;F--;)if(C.getItem(F).type==4){C.removeItem(F);var E=svgedit.utilities.getBBox(z),D=Q(E.x+E.width/2,E.y+E.height/2,W(C).matrix);E=D.x;D=D.y;var M=e.createSVGTransform();M.setRotate(A,E,D);C.insertItemBefore(M,F);break}}}}}e.unsuspendRedraw(w)},ub=this.changeSelectedAttribute=
|
|
function(g,h,k){k=k||H;b.undoMgr.beginUndoableChange(g,k);vb(g,h,k);g=b.undoMgr.finishUndoableChange();g.isEmpty()||Ha(g)};this.deleteSelectedElements=function(){for(var g=new Na("Delete Elements"),h=H.length,k=[],w=0;w<h;++w){var v=H[w];if(v==null)break;var G=v.parentNode,z=v;Pa.releaseSelector(z);svgedit.path.removePath_(z.id);if(G.tagName==="a"&&G.childNodes.length===1){z=G;G=G.parentNode}var A=z.nextSibling;z=G.removeChild(z);k.push(v);H[w]=null;g.addSubCommand(new Va(z,A,G))}g.isEmpty()||Ha(g);
|
|
J("changed",k);cb()};this.cutSelectedElements=function(){for(var g=new Na("Cut Elements"),h=H.length,k=[],w=0;w<h;++w){var v=H[w];if(v==null)break;var G=v.parentNode,z=v;Pa.releaseSelector(z);svgedit.path.removePath_(z.id);var A=z.nextSibling;z=G.removeChild(z);k.push(v);H[w]=null;g.addSubCommand(new Va(z,A,G))}g.isEmpty()||Ha(g);J("changed",k);cb();b.clipBoard=k};this.copySelectedElements=function(){b.clipBoard=$.merge([],H)};this.pasteElements=function(){var g=b.clipBoard,h=g.length;if(h){for(var k=
|
|
[],w=new Na("Paste elements");h--;){var v=g[h];if(v){var G=ia(v);if(!ua(v.id))G.id=v.id;k.push(G);(I||u().getCurrentLayer()).appendChild(G);w.addSubCommand(new Qa(G))}}svgCanvas.clearSelection();setTimeout(function(){Sb(k)},100);Ha(w);J("changed",k)}};this.groupSelectedElements=function(g){g||(g="g");var h="";switch(g){case "a":h="Make hyperlink";var k="";if(arguments.length>1)k=arguments[1];break;default:g="g";h="Group Elements"}h=new Na(h);var w=ea({element:g,attr:{id:P()}});g==="a"&&Y(w,k);h.addSubCommand(new Qa(w));
|
|
for(k=H.length;k--;){var v=H[k];if(v!=null){if(v.parentNode.tagName==="a"&&v.parentNode.childNodes.length===1)v=v.parentNode;var G=v.nextSibling,z=v.parentNode;w.appendChild(v);h.addSubCommand(new Ra(v,G,z))}}h.isEmpty()||Ha(h);Sb([w],true)};var bc=this.pushGroupProperties=function(g,h){var k=g.childNodes,w=k.length,v=g.getAttribute("transform"),G=X(g),z=W(G).matrix,A=new Na("Push group properties"),C=0,F=ma(g),E=$(g).attr(["filter","opacity"]),D,M;for(C=0;C<w;C++){var K=k[C];if(K.nodeType===1){if(E.opacity!==
|
|
null&&E.opacity!==1){K.getAttribute("opacity");var N=Math.round((K.getAttribute("opacity")||1)*E.opacity*100)/100;ub("opacity",N,[K])}if(E.filter){var aa=N=this.getBlur(K);M||(M=this.getBlur(g));if(N)N=M-0+(N-0);else if(N===0)N=M;if(aa)D=fa(K.getAttribute("filter"));else if(D){D=ia(D);Bb().appendChild(D)}else D=fa(E.filter);D.id=K.id+"_"+(D.firstChild.tagName==="feGaussianBlur"?"blur":"filter");ub("filter","url(#"+D.id+")",[K]);if(N){ub("stdDeviation",N,[D.firstChild]);b.setBlurOffsets(D,N)}}N=X(K);
|
|
if(~K.tagName.indexOf("Gradient"))N=null;if(N)if(K.tagName!=="defs")if(G.numberOfItems){if(F&&G.numberOfItems==1){var T=G.getItem(0).matrix,ta=e.createSVGMatrix();if(aa=ma(K))ta=N.getItem(0).matrix;var xa=svgedit.utilities.getBBox(K),ja=W(N).matrix,oa=Q(xa.x+xa.width/2,xa.y+xa.height/2,ja);xa=F+aa;ja=e.createSVGTransform();ja.setRotate(xa,oa.x,oa.y);T=R(T,ta,ja.matrix.inverse());aa&&N.removeItem(0);if(xa)N.numberOfItems?N.insertItemBefore(ja,0):N.appendItem(ja);if(T.e||T.f){aa=e.createSVGTransform();
|
|
aa.setTranslate(T.e,T.f);N.numberOfItems?N.insertItemBefore(aa,0):N.appendItem(aa)}}else{aa=K.getAttribute("transform");T={};T.transform=aa?aa:"";aa=e.createSVGTransform();T=W(N).matrix;ta=T.inverse();T=R(ta,z,T);aa.setMatrix(T);N.appendItem(aa)}(K=pb(K))&&A.addSubCommand(K)}}}if(v){T={};T.transform=v;g.setAttribute("transform","");g.removeAttribute("transform");A.addSubCommand(new Xa(g,T))}if(h&&!A.isEmpty())return A};this.ungroupSelectedElement=function(){var g=H[0];if($(g).data("gsvg")||$(g).data("symbol"))ic(g);
|
|
else if(g.tagName==="use"){var h=ua(da(g).substr(1));$(g).data("symbol",h).data("ref",h);ic(g)}else{h=$(g).parents("a");if(h.length)g=h[0];if(g.tagName==="g"||g.tagName==="a"){h=new Na("Ungroup Elements");var k=bc(g,true);k&&h.addSubCommand(k);k=g.parentNode;for(var w=g.nextSibling,v=Array(g.childNodes.length),G=0;g.firstChild;){var z=g.firstChild,A=z.nextSibling,C=z.parentNode;if(z.tagName==="title"){h.addSubCommand(new Va(z,z.nextSibling,C));C.removeChild(z)}else{v[G++]=z=k.insertBefore(z,w);h.addSubCommand(new Ra(z,
|
|
A,C))}}cb();w=g.nextSibling;g=k.removeChild(g);h.addSubCommand(new Va(g,w,k));h.isEmpty()||Ha(h);Nb(v)}}};this.moveToTopSelectedElement=function(){var g=H[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling;g=g.parentNode.appendChild(g);if(k!=g.nextSibling){Ha(new Ra(g,k,h,"top"));J("changed",[g])}}};this.moveToBottomSelectedElement=function(){var g=H[0];if(g!=null){g=g;var h=g.parentNode,k=g.nextSibling,w=g.parentNode.firstChild;if(w.tagName=="title")w=w.nextSibling;if(w.tagName=="defs")w=w.nextSibling;
|
|
g=g.parentNode.insertBefore(g,w);if(k!=g.nextSibling){Ha(new Ra(g,k,h,"bottom"));J("changed",[g])}}};this.moveUpDownSelected=function(g){var h=H[0];if(h){jb=[];var k,w,v=$(Ob(getStrokedBBox([h]))).toArray();g=="Down"&&v.reverse();$.each(v,function(){if(w){k=this;return false}else if(this==h)w=true});if(k){v=h.parentNode;var G=h.nextSibling;$(k)[g=="Down"?"before":"after"](h);if(G!=h.nextSibling){Ha(new Ra(h,G,v,"Move "+g));J("changed",[h])}}}};this.moveSelectedElements=function(g,h,k){if(g.constructor!=
|
|
Array){g/=n;h/=n}k=k||true;for(var w=new Na("position"),v=H.length;v--;){var G=H[v];if(G!=null){var z=e.createSVGTransform(),A=X(G);g.constructor==Array?z.setTranslate(g[v],h[v]):z.setTranslate(g,h);A.numberOfItems?A.insertItemBefore(z,0):A.appendItem(z);(z=pb(G))&&w.addSubCommand(z);Pa.requestSelector(G).resize()}}if(!w.isEmpty()){k&&Ha(w);J("changed",H);return w}};this.cloneSelectedElements=function(g,h){for(var k=new Na("Clone Elements"),w=H.length,v=0;v<w;++v){var G=H[v];if(G==null)break}w=H.slice(0,
|
|
v);this.clearSelection(true);for(v=w.length;v--;){G=w[v]=ia(w[v]);(I||u().getCurrentLayer()).appendChild(G);k.addSubCommand(new Qa(G))}if(!k.isEmpty()){Nb(w.reverse());this.moveSelectedElements(g,h,false);Ha(k)}};this.alignSelectedElements=function(g,h){var k=[],w=Number.MAX_VALUE,v=Number.MIN_VALUE,G=Number.MAX_VALUE,z=Number.MIN_VALUE,A=Number.MIN_VALUE,C=Number.MIN_VALUE,F=H.length;if(F){for(var E=0;E<F;++E){if(H[E]==null)break;k[E]=getStrokedBBox([H[E]]);switch(h){case "smallest":if((g=="l"||
|
|
g=="c"||g=="r")&&(A==Number.MIN_VALUE||A>k[E].width)||(g=="t"||g=="m"||g=="b")&&(C==Number.MIN_VALUE||C>k[E].height)){w=k[E].x;G=k[E].y;v=k[E].x+k[E].width;z=k[E].y+k[E].height;A=k[E].width;C=k[E].height}break;case "largest":if((g=="l"||g=="c"||g=="r")&&(A==Number.MIN_VALUE||A<k[E].width)||(g=="t"||g=="m"||g=="b")&&(C==Number.MIN_VALUE||C<k[E].height)){w=k[E].x;G=k[E].y;v=k[E].x+k[E].width;z=k[E].y+k[E].height;A=k[E].width;C=k[E].height}break;default:if(k[E].x<w)w=k[E].x;if(k[E].y<G)G=k[E].y;if(k[E].x+
|
|
k[E].width>v)v=k[E].x+k[E].width;if(k[E].y+k[E].height>z)z=k[E].y+k[E].height}}if(h=="page"){G=w=0;v=b.contentW;z=b.contentH}A=Array(F);C=Array(F);for(E=0;E<F;++E){if(H[E]==null)break;var D=k[E];A[E]=0;C[E]=0;switch(g){case "l":A[E]=w-D.x;break;case "c":A[E]=(w+v)/2-(D.x+D.width/2);break;case "r":A[E]=v-(D.x+D.width);break;case "t":C[E]=G-D.y;break;case "m":C[E]=(G+z)/2-(D.y+D.height/2);break;case "b":C[E]=z-(D.y+D.height)}}this.moveSelectedElements(A,C)}};this.contentW=Yb().w;this.contentH=Yb().h;
|
|
this.updateCanvas=function(g,h){e.setAttribute("width",g);e.setAttribute("height",h);var k=$("#canvasBackground")[0],w=l.getAttribute("x"),v=l.getAttribute("y"),G=g/2-this.contentW*n/2,z=h/2-this.contentH*n/2;ga(l,{width:this.contentW*n,height:this.contentH*n,x:G,y:z,viewBox:"0 0 "+this.contentW+" "+this.contentH});ga(k,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:G,y:z});(k=ua("background_image"))&&ga(k,{width:"100%",height:"100%"});Pa.selectorParentGroup.setAttribute("transform",
|
|
"translate("+G+","+z+")");return{x:G,y:z,old_x:w,old_y:v,d_x:G-w,d_y:z-v}};this.setBackground=function(g,h){var k=ua("canvasBackground"),w=$(k).find("rect")[0],v=ua("background_image");w.setAttribute("fill",g);if(h){if(!v){v=d.createElementNS(c,"image");ga(v,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}Y(v,h);k.appendChild(v)}else v&&v.parentNode.removeChild(v)};this.cycleElement=function(g){var h=H[0],k=false,w=Kb(I||u().getCurrentLayer());
|
|
if(w.length){if(h==null){g=g?w.length-1:0;k=w[g]}else for(var v=w.length;v--;)if(w[v]==h){g=g?v-1:v+1;if(g>=w.length)g=0;else if(g<0)g=w.length-1;k=w[g];break}Sb([k],true);J("selected",H)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:Ha,setGradient:mc,addSvgElementFromJson:ea,assignAttributes:ga,BatchCommand:Na,call:J,ChangeElementCommand:Xa,copyElem:ia,ffClone:Oa,findDefs:Bb,findDuplicateGradient:lc,getElem:ua,getId:va,getIntersectionList:Ob,getMouseTarget:ac,getNextId:P,
|
|
getPathBBox:V,getUrlFromAttr:la,hasMatrixTransform:ha,identifyLayers:Tb,InsertElementCommand:Qa,isIdentity:svgedit.math.isIdentity,logMatrix:wb,matrixMultiply:R,MoveElementCommand:Ra,preventClickDefault:Lb,recalculateAllSelectedDimensions:Za,recalculateDimensions:pb,remapElement:xb,RemoveElementCommand:Va,removeUnusedDefElems:kc,round:Gb,runExtensions:nb,sanitizeSvg:Ma,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:W,
|
|
transformPoint:Q,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function o(u,n){var I=f.setSvgString(u)!==false;n=n||a.noop;I?n(true):a.alert(e.notification.errorLoadingSVG,function(){n(false)})}var f,c={},m=false,p={lang:"en",iconsize:"m",bkgd_color:"FFF",bkgd_url:"",img_save:"embed"},
|
|
b={},d={canvas_expansion:1,dimensions:[640,480],initFill:{color:"fff",opacity:1},initStroke:{width:1.5,color:"000",opacity:1},initOpacity:1,imgPath:"images/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",extensions:[],initTool:"select",wireframe:false,colorPickerCSS:false,gridSnapping:false,gridColor:"#000",baseUnit:"px",snappingStep:10,showRulers:true,show_outside_canvas:false,no_save_warning:true,initFont:"Sans-serif"},e=c.uiStrings={common:{ok:"OK",cancel:"Cancel",key_up:"Up",key_down:"Down",
|
|
key_backspace:"Backspace",key_del:"Del"},layers:{layer:"Layer"},notification:{invalidAttrValGiven:"Invalid value given",noContentToFitTo:"No content to fit to",dupeLayerName:"There is already a layer named that!",enterUniqueLayerName:"Please enter a unique layer name",enterNewLayerName:"Please enter the new layer name",layerHasThatName:"Layer already has that name",QmoveElemsToLayer:'Move selected elements to layer "%s"?',QwantToClear:"Do you want to clear the drawing?\nThis will also erase your undo history!",
|
|
QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo history!",QerrorsRevertToSource:"There were parsing errors in your SVG source.\nRevert back to original SVG source?",QignoreSourceChanges:"Ignore changes made to SVG source?",featNotSupported:"Feature not supported",enterNewImgURL:"Enter the new image URL",defsFailOnSave:"NOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.",loadingImage:"Loading image, please wait...",
|
|
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};b={};var l={};c.curConfig=d;c.tool_scale=1;a.pref=function(u,n){if(n)b[u]=n;u="svg-edit-"+u;var I=location.hostname,S=I&&I.indexOf(".")>=0,O=n!=undefined,
|
|
H=false;try{if(window.localStorage)H=localStorage}catch(ea){}try{if(window.globalStorage&&S)H=globalStorage[I]}catch(X){}if(H)if(O)H.setItem(u,n);else{if(H.getItem(u))return H.getItem(u)+""}else if(window.widget)if(O)widget.setPreferenceForKey(n,u);else return widget.preferenceForKey(u);else if(O){I=new Date;I.setTime(I.getTime()+31536E6);n=encodeURIComponent(n);document.cookie=u+"="+n+"; expires="+I.toUTCString()}else return(I=document.cookie.match(RegExp(u+"=([^;]+)")))?decodeURIComponent(I[1]):
|
|
""};c.setConfig=function(u){a.each(u,function(n,I){n in p&&a.pref(n,I)});a.extend(true,d,u);if(u.extensions)d.extensions=u.extensions};c.setCustomHandlers=function(u){c.ready(function(){if(u.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();f.open=u.open}if(u.save){c.show_save_warning=false;f.bind("saved",u.save)}u.pngsave&&f.bind("exported",u.pngsave);l=u})};c.randomizeIds=function(){f.randomizeIds(arguments)};c.init=function(){function u(s,B){var L=s.id,U=L.split("_"),ca=
|
|
U[0];U=U[1];B&&f.setStrokeAttr("stroke-"+ca,U);mb();ja("#cur_"+ca,L,20);a(s).addClass("current").siblings().removeClass("current")}function n(s,B){a.pref("bkgd_color",s);a.pref("bkgd_url",B);f.setBackground(s,B)}function I(){var s=f.getHref(ga);s=s.indexOf("data:")===0?"":s;a.prompt(e.notification.enterNewImgURL,s,function(B){B&&Da(B)})}function S(){if(f.deleteCurrentLayer()){bb();Hb();a("#layerlist tr.layer").removeClass("layersel");a("#layerlist tr.layer:first").addClass("layersel")}}function O(){var s=
|
|
f.getCurrentDrawing().getCurrentLayerName()+" copy";a.prompt(e.notification.enterUniqueLayerName,s,function(B){if(B)if(f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.dupeLayerName);else{f.cloneLayer(B);bb();Hb()}})}function H(s){var B=a("#layerlist tr.layersel").index(),L=f.getCurrentDrawing().getNumLayers();if(B>0||B<L-1){B+=s;f.setCurrentLayerPosition(L-B-1);Hb()}}function ea(s,B){var L=document.getElementById("ruler_x_cursor"),U=document.getElementById("ruler_y_cursor"),ca=document.getElementById("workarea");
|
|
document.getElementById("title_show");svgedit.browser.isTouch()||a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(pc){pc.stopPropagation();L.style.left=pc.pageX-66+ca.scrollLeft+"px";U.style.top=pc.pageY-48+ca.scrollTop+"px"});B||(B=f.getZoom());s||(s=a("#svgcanvas"));for(var pa=f.getContentElem(),wa=svgedit.units.getTypeMap()[d.baseUnit],ya=0;ya<2;ya++){var Ca=ya===0,Ba=Ca?"x":"y",Aa=Ca?"width":"height",Ab=pa.getAttribute(Ba)-0;Ba=a("#ruler_"+Ba+" canvas:first");$hcanv=
|
|
Ba.clone();Ba.replaceWith($hcanv);var Ta=$hcanv[0];var na=Ba=s[Aa]()*2;Ta.parentNode.style[Aa]=na+"px";var Cb=0,db,Ea=Ta.getContext("2d");Ea.fillStyle="rgb(200,0,0)";Ea.fillRect(0,0,Ta.width,Ta.height);$hcanv.siblings().remove();if(Ba>=3E4){var Ya=parseInt(Ba/3E4)+1;db=Array(Ya);db[0]=Ea;for(var Fa=1;Fa<Ya;Fa++){Ta[Aa]=3E4;var ib=Ta.cloneNode(true);Ta.parentNode.appendChild(ib);db[Fa]=ib.getContext("2d")}ib[Aa]=Ba%3E4;Ba=3E4}Ta[Aa]=Ba;Aa=wa*B;var eb=50/Aa;Ta=1;for(Fa=0;Fa<jc.length;Fa++){Ta=Ya=jc[Fa];
|
|
if(eb<=Ya)break}eb=Ta*Aa;Ea.font="normal 9px 'Lucida Grande', sans-serif";Ea.fillStyle="#777";for(var lb=Ab/Aa%Ta*Aa,$b=lb-eb;lb<na;lb+=eb){$b+=eb;Fa=Math.round(lb)+0.5;if(Ca){Ea.moveTo(Fa,15);Ea.lineTo(Fa,0)}else{Ea.moveTo(15,Fa);Ea.lineTo(0,Fa)}Ya=($b-Ab)/Aa;if(Ta>=1)Fa=Math.round(Ya);else{Fa=(Ta+"").split(".")[1].length;Fa=Ya.toFixed(Fa)-0}if(Fa!==0&&Fa!==1E3&&Fa%1E3===0)Fa=Fa/1E3+"K";if(Ca){Ea.fillText(Fa,lb+2,8);Ea.fillStyle="#777"}else{Ya=(Fa+"").split("");for(Fa=0;Fa<Ya.length;Fa++){Ea.fillText(Ya[Fa],
|
|
1,lb+9+Fa*9);Ea.fillStyle="#777"}}Ya=eb/10;for(Fa=1;Fa<10;Fa++){var Qb=Math.round(lb+Ya*Fa)+0.5;if(db&&Qb>Ba){Cb++;Ea.stroke();if(Cb>=db.length){Fa=10;lb=na;continue}Ea=db[Cb];lb-=3E4;Qb=Math.round(lb+Ya*Fa)+0.5}var Zb=Fa%2?12:10;if(Ca){Ea.moveTo(Qb,15);Ea.lineTo(Qb,Zb)}else{Ea.moveTo(15,Qb);Ea.lineTo(Zb,Qb)}}}Ea.strokeStyle="#666";Ea.stroke()}}(function(){var s=window.opener;if(s)try{var B=s.document.createEvent("Event");B.initEvent("svgEditorReady",true,true);s.document.documentElement.dispatchEvent(B)}catch(L){}})();
|
|
(function(){var s=a.deparam.querystring(true);if(!a.isEmptyObject(s)){if(s.dimensions)s.dimensions=s.dimensions.split(",");if(s.extensions)s.extensions=s.extensions.split(",");if(s.bkgd_color)s.bkgd_color="#"+s.bkgd_color;svgEditor.setConfig(s);var B=s.source,L=a.param.querystring();if(!B)if(L.indexOf("source=data:")>=0)B=L.match(/source=(data:[^&]*)/)[1];if(B)if(B.indexOf("data:")===0){B=B.replace(/ /g,"+");c.loadFromDataURI(B)}else c.loadFromString(B);else if(L.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(L.substr(9));
|
|
else s.url&&svgEditor.loadFromURL(s.url)}})();var X=function(){a.each(d.extensions,function(){var s=this;a.getScript(d.extPath+s,function(B){if(!B){B=document.createElement("script");B.src=d.extPath+s;document.querySelector("head").appendChild(B)}})})};document.location.protocol==="file:"?setTimeout(X,100):X();a.svgIcons(d.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:!svgedit.browser.isWebkit(),fallback_path:d.imgPath,fallback:{new_image:"clear.png",save:"save.png",open:"open.png",
|
|
source:"source.png",docprops:"document-properties.png",wireframe:"wireframe.png",undo:"undo.png",redo:"redo.png",select:"select.png",select_node:"select_node.png",pencil:"fhpath.png",pen:"line.png",square:"square.png",rect:"rect.png",fh_rect:"freehand-square.png",circle:"circle.png",ellipse:"ellipse.png",fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png",clone:"clone.png",node_clone:"node_clone.png","delete":"delete.png",node_delete:"node_delete.png",
|
|
move_top:"move_top.png",move_bottom:"move_bottom.png",to_path:"to_path.png",link_controls:"link_controls.png",reorient:"reorient.png",align_left:"align-left.png",align_center:"align-center",align_right:"align-right",align_top:"align-top",align_middle:"align-middle",align_bottom:"align-bottom",go_up:"go-up.png",go_down:"go-down.png",ok:"save.png",cancel:"cancel.png",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#tool_docprops > div":"docprops","#tool_select":"select","#tool_fhpath":"pencil",
|
|
"#tool_line":"pen","#tool_rect,#tools_rect_show":"rect","#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_node_clone":"node_clone","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center",
|
|
"#tool_alignright, #tool_posright":"align_right","#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#linecap_butt,#cur_linecap":"linecap_butt","#linecap_round":"linecap_round","#linecap_square":"linecap_square","#linejoin_miter,#cur_linejoin":"linejoin_miter","#linejoin_round":"linejoin_round","#linejoin_bevel":"linejoin_bevel","#url_notice":"warning","#layer_up":"go_up","#layer_down":"go_down",
|
|
"#layer_moreopts":"context_menu","#layerlist td.layervis":"eye","#tool_source_save,#tool_docprops_save,#tool_prefs_save":"ok","#tool_source_cancel,#tool_docprops_cancel,#tool_prefs_cancel":"cancel","#rwidthLabel, #iwidthLabel":"width","#rheightLabel, #iheightLabel":"height","#angleLabel":"angle","#linkLabel,#tool_make_link,#tool_make_link_multi":"globe_link","#zoomLabel":"zoom","#blurLabel":"blur",".flyout_arrow_horiz":"arrow_right","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},
|
|
resize:{"#logo .svg_icon":32,".flyout_arrow_horiz .svg_icon":5,".layer_button .svg_icon, #layerlist td.layervis .svg_icon":14,"#main_button .dropdown .svg_icon":9,"#fill_bg .svg_icon, #stroke_bg .svg_icon":24,".palette_item:first .svg_icon":16,".toolbar_button button .svg_icon":16,".stroke_tool div div .svg_icon":20,"#tools_bottom label .svg_icon":18,"#zoom_dropdown .svg_icon":7},callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});
|
|
a(".tool_button, .tool_button_current").addClass("loaded");var s=a("#tools_left");if(s.length!=0){s.offset();s.outerHeight()}a(".tools_flyout").each(function(){var B=a("#"+this.id+"_show"),L=B.attr("data-curopt");if(!B.children("svg, img").length){L=a(L).children().clone();if(L.length){L[0].removeAttribute("style");B.append(L)}}});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(s){a("#base_unit_container").css({top:s.pageY-10,left:s.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){xa()});c.canvas=f=new a.SvgCanvas(document.getElementById("svgcanvas"),d);c.show_save_warning=false;c.paintBox={fill:null,stroke:null,canvas:null};X=navigator.platform.indexOf("Mac")>=0;var Q=
|
|
navigator.userAgent.indexOf("AppleWebKit")>=0,R=X?"meta+":"ctrl+",ha=f.pathActions,W=f.undoMgr,Z=svgedit.utilities,ba=d.imgPath+"placeholder.svg",ka=a("#workarea"),la=a("#cmenu_canvas");a("#cmenu_layers");var da=null,Y=1,V="toolbars",ma="";X||a(".shortcut").each(function(){var s=a(this).text();a(this).text(s.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var s=a("#dialog_box"),B=a("#dialog_buttons"),
|
|
L=function(U,ca,pa,wa){a("#dialog_content").html("<p>"+ca.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",U=="prompt");B.empty();var ya=a('<input type="button" value="'+e.common.ok+'">').appendTo(B);U!="alert"&&a('<input type="button" value="'+e.common.cancel+'">').appendTo(B).click(function(){s.hide();pa(false)});if(U=="prompt"){var Ca=a('<input type="text">').prependTo(B);Ca.val(wa||"");Ca.bind("keydown","return",function(){ya.click()})}U=="process"&&ya.hide();s.show();ya.click(function(){s.hide();
|
|
var Ba=U=="prompt"?Ca.val():true;pa&&pa(Ba)}).focus();U=="prompt"&&Ca.focus()};a.alert=function(U,ca){L("alert",U,ca)};a.confirm=function(U,ca){L("confirm",U,ca)};a.process_cancel=function(U,ca){L("process",U,ca)};a.prompt=function(U,ca,pa){L("prompt",U,pa,ca)}})();var ua=function(){var s=a(".tool_button_current");if(s.length&&s[0].id!=="tool_select"){s.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}f.setMode("select")},
|
|
ga=null,qa=false,Ga=false,Ma=false,Ra=false,Qa="",Va=a("title:first").text(),Xa=function(s,B,L){f.getResolution();a("#svgcanvas").position();if(B=f.setBBoxZoom(B,ka.width()-15,ka.height()-15)){s=B.zoom;B=B.bbox;if(s<0.0010)Ia({value:0.1});else{a("#zoom").val(s*100);L?Wb():Wb(false,{x:B.x*s+B.width*s/2,y:B.y*s+B.height*s/2});f.getMode()=="zoom"&&B.width&&ua();E()}}};a("#cur_context_panel").delegate("a","click",function(){var s=a(this);s.attr("data-root")?f.leaveContext():f.setContext(s.text());return false});
|
|
var Na=function(){c.paintBox.fill.prep();c.paintBox.stroke.prep()},Ha={},Pa=function(s){a.each(s,function(B,L){var U=a(B).children(),ca=B+"_show",pa=a(ca),wa=false;U.addClass("tool_button").unbind("click mousedown mouseup").each(function(Ba){var Aa=L[Ba];Ha[Aa.sel]=Aa.fn;if(Aa.isDefault)wa=Ba;Ba=function(Ab){var Ta=Aa;if(Ab.type==="keydown"){var na=a(Ta.parent+"_show").hasClass("tool_button_current"),Cb=a(Ta.parent+"_show").attr("data-curopt");a.each(s[Aa.parent],function(Ea,Ya){if(Ya.sel==Cb)Ta=
|
|
!Ab.shiftKey||!na?Ya:s[Aa.parent][Ea+1]||s[Aa.parent][0]})}if(a(this).hasClass("disabled"))return false;La(ca)&&Ta.fn();var db=Ta.icon?a.getSvgIcon(Ta.icon,true):a(Ta.sel).children().eq(0).clone();db[0].setAttribute("width",pa.width());db[0].setAttribute("height",pa.height());pa.children(":not(.flyout_arrow_horiz)").remove();pa.append(db).attr("data-curopt",Ta.sel)};a(this).mouseup(Ba);Aa.key&&a(document).bind("keydown",Aa.key[0]+" shift+"+Aa.key[0],Ba)});if(wa)pa.attr("data-curopt",L[wa].sel);else pa.attr("data-curopt")||
|
|
pa.attr("data-curopt",L[0].sel);var ya,Ca=a(ca).position();a(B).css({left:Ca.left+34,top:Ca.top+77});pa.mousedown(function(Ba){a("#tools_shapelib").is(":visible")&&La(ca,false);if(pa.hasClass("disabled"))return false;var Aa=a(B),Ab=Ca.left+34,Ta=Aa.width()*-1,na=Aa.data("shown_popop")?200:0;ya=setTimeout(function(){pa.data("isLibrary")?Aa.css("left",Ab).show():Aa.css("left",Ta).show().animate({left:Ab},150);Aa.data("shown_popop",true)},na);Ba.preventDefault()}).mouseup(function(){clearTimeout(ya);
|
|
var Ba=a(this).attr("data-curopt");if(pa.data("isLibrary")&&a(ca.replace("_show","")).is(":visible"))La(ca,true);else La(ca)&&Ba in Ha&&Ha[Ba]()})});Jb()},zb=function(s,B){return a("<div>",{"class":"tools_flyout",id:s}).appendTo("#svg_editor").append(B)},Ja=function(){a(".tools_flyout").each(function(){var s=a("#"+this.id+"_show"),B=s.offset();s=s.outerWidth();a(this).css({left:(B.left+s)*Y,top:B.top})})},Jb=function(){a(".tools_flyout").each(function(){var s=a("#"+this.id+"_show");if(!s.data("isLibrary")){var B=
|
|
[];a(this).children().each(function(){B.push(this.title)});s[0].title=B.join(" / ")}})},tb,ab=function(s,B,L){var U=null;if(s.indexOf("url(#")===0){s=(s=f.getRefElem(s))?s.cloneNode(true):a("#"+L+"_color defs *")[0];U={alpha:B};U[s.tagName]=s}else U=s.indexOf("#")===0?{alpha:B,solidColor:s.substr(1)}:{alpha:B,solidColor:"none"};return new a.jGraduate.Paint(U)},$a=f.getResolution();if(d.baseUnit!=="px"){$a.w=svgedit.units.convertUnit($a.w)+d.baseUnit;$a.h=svgedit.units.convertUnit($a.h)+d.baseUnit}a(".canvas_width").val($a.w);
|
|
a(".canvas_height").val($a.h);a("#docprops_button").on("click",function(){M()});var Ka=function(s){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:$a.w+2,height:$a.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:s||"#fff",style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||Ka();document.getElementById("canvas_background").getAttribute("fill");var Da=c.setImageURL=
|
|
function(s){s||(s=ba);f.setImageURL(s);a("#image_url").val(s);if(s.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(s,function(B){B?a("#url_notice").hide():a("#url_notice").show();ba=s});a("#image_url").show();a("#change_image_url").hide()}},yb=function(s){var B=Math.min(Math.max(12+s.value.length*6,50),300);a(s).width(B)},bb=function(){var s=ga;if(s!=null&&!s.parentNode)s=null;var B=f.getCurrentDrawing().getCurrentLayerName(),L=f.getMode(),U=d.baseUnit!==
|
|
"px"?d.baseUnit:null,ca=L=="pathedit",pa=a("#cmenu_canvas li");a("#selected_panel, #multiselected_panel, #g_panel, #path_panel, #rect_panel, #canvas_panel, #circle_panel,\t\t\t\t\t#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");!s&&!qa&&a("#canvas_panel").show();if(s!=null){var wa=s.nodeName,ya=f.getRotationAngle(s);a("#angle").val(Math.round(ya));
|
|
ya=f.getBlur(s);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&wa==="image"&&f.getHref(s).indexOf("data:")!==0&&I();if(!ca&&L!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(wa)>=0)a("#xy_panel").hide();else{var Ca,Ba;if(["g","polyline","path"].indexOf(wa)>=0){if(L=f.getStrokedBBox([s])){Ca=L.x;Ba=L.y}}else{Ca=s.getAttribute("x");Ba=s.getAttribute("y")}if(U){Ca=svgedit.units.convertUnit(Ca);
|
|
Ba=svgedit.units.convertUnit(Ba)}a("#selected_x").val(Math.round(Ba)||0);a("#selected_y").val(Math.round(Ca)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(wa)==-1&&a(".action_path_convert_selected").removeClass("disabled");wa==="path"&&a(".action_path_selected").removeClass("disabled")}else{B=ha.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!ha.canDeleteNodes);ja("#tool_openclose_path",
|
|
ha.closed_subpath?"open_path":"close_path");if(B){ca=a("#seg_type");if(U){B.x=svgedit.units.convertUnit(B.x);B.y=svgedit.units.convertUnit(B.y)}a("#path_node_x").val(Math.round(B.x));a("#path_node_y").val(Math.round(B.y));B.type?ca.val(B.type).removeAttr("disabled"):ca.val(4).attr("disabled","disabled")}return}U={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]};var Aa=s.tagName;a(s).data("gsvg")&&
|
|
a("#g_panel").show();Aa=="path"&&a("#path_panel").show();if(U[Aa]){U=U[Aa];a("#"+Aa+"_panel").show();a.each(U,function(Ab,Ta){var na=s.getAttribute(Ta);if(d.baseUnit!=="px"&&s[Ta])na=svgedit.units.convertUnit(s[Ta].baseVal.value);a("#"+Aa+"_"+Ta).val(Math.round(na)||0)});if(Aa=="text"){a("#text_panel").css("display","inline");f.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");f.getBold()?
|
|
a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(s.getAttribute("font-family"));a("#font_size").val(s.getAttribute("font-size"));a("#text").val(s.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(Aa=="image")Da(f.getHref(s));else if(Aa==="g"||Aa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");U=f.getTitle();
|
|
wa=a("#g_title")[0];wa.value=U;yb(wa);Aa=="use"?wa.setAttribute("disabled","disabled"):wa.removeAttribute("disabled")}}pa[(Aa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");pa[(Aa==="g"||!qa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(qa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");pa.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else pa.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
|
|
W.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");W.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(s&&!ca||qa){a("#selLayerNames").removeAttr("disabled").val(B);la.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else a("#selLayerNames").attr("disabled","disabled")};a("#text").focus(function(){});a("#text").blur(function(){});f.bind("selected",
|
|
function(s,B){var L=f.getMode();L==="select"&&ua();L=L=="pathedit";ga=B.length==1||B[1]==null?B[0]:null;qa=B.length>=2&&B[1]!=null;if(ga!=null)if(!L){if(ga!=null)switch(ga.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var U=null,ca=ga.getElementsByTagName("*"),pa=0,wa=ca.length;pa<wa;pa++){var ya=ca[pa].getAttribute("stroke-width");if(pa===0)U=ya;else if(U!==ya)U=null}a("#stroke_width").val(U===null?"":U);c.paintBox.fill.update(true);c.paintBox.stroke.update(true);
|
|
break;default:c.paintBox.fill.update(true);c.paintBox.stroke.update(true);a("#stroke_width").val(ga.getAttribute("stroke-width")||1);a("#stroke_style").val(ga.getAttribute("stroke-dasharray")||"none");U=ga.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+U).length!=0&&u(a("#linejoin_"+U)[0]);U=ga.getAttribute("stroke-linecap")||"butt";a("#linecap_"+U).length!=0&&u(a("#linecap_"+U)[0])}if(ga!=null){U=(ga.getAttribute("opacity")||1)*100;a("#group_opacity").val(U);a("#opac_slider").slider("option",
|
|
"value",U);a("#elem_id").val(ga.id)}}a("#path_node_panel").toggle(L);a("#tools_bottom_2,#tools_bottom_3").toggle(!L);if(L){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");ja("#tool_select","select_node");qa=false;if(B.length)ga=B[0]}else{if(B[0]){L=f.selectorManager.requestSelector(B[0]);L.reset(B[0]);L.selectorRect.setAttribute("display","inline")}ja("#tool_select","select")}bb();f.runExtensions("selectedChanged",
|
|
{elems:B,selectedElement:ga,multiselected:qa})});f.bind("transition",function(s,B){var L=f.getMode(),U=B[0];if(U){qa=B.length>=2&&B[1]!=null;if(!qa)switch(L){case "rotate":L=f.getRotationAngle(U);a("#angle").val(Math.round(L));a("#tool_reorient").toggleClass("disabled",L==0)}f.runExtensions("elementTransition",{elems:B})}});f.bind("changed",function(s,B){var L=f.getMode();L==="select"&&ua();for(var U=0;U<B.length;++U){var ca=B[U];if(ca&&ca.tagName==="svg"){Hb();Wb()}else if(ca&&ga&&ga.parentNode==
|
|
null)ga=ca}c.show_save_warning=true;bb();if(ga&&L==="select"){c.paintBox.fill.update();c.paintBox.stroke.update()}f.runExtensions("elementChanged",{elems:B})});f.bind("saved",function(s,B){c.show_save_warning=false;B='<?xml version="1.0"?>\n'+B;var L=navigator.userAgent;if(~L.indexOf("Chrome")&&a.browser.version>=533||~L.indexOf("MSIE"))D(0,true);else{var U=s.open("data:image/svg+xml;base64,"+Z.encode64(B)),ca=a.pref("save_notice_done");if(ca!=="all"){var pa=e.notification.saveFromBrowser.replace("%s",
|
|
"SVG");if(L.indexOf("Gecko/")!==-1)if(B.indexOf("<defs")!==-1){pa+="\n\n"+e.notification.defsFailOnSave;a.pref("save_notice_done","all");ca="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");ca!=="part"&&U.alert(pa)}}});f.bind("exported",function(s,B){var L=B.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var U=a("#export_canvas")[0];U.width=f.contentW;U.height=f.contentH;canvg(U,B.svg,{renderCallback:function(){var ca=
|
|
U.toDataURL("image/png");da.location.href=ca;if(a.pref("export_notice_done")!=="all"){ca=e.notification.saveFromBrowser.replace("%s","PNG");if(L.length)ca+="\n\n"+e.notification.noteTheseIssues+"\n \u2022 "+L.join("\n \u2022 ");a.pref("export_notice_done","all");da.alert(ca)}}})});f.bind("zoomed",Xa);f.bind("contextset",function(s,B){var L="";if(B){var U="";L='<a href="#" data-root="y">'+f.getCurrentDrawing().getCurrentLayerName()+"</a>";a(B).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){U+=
|
|
" > "+this.id;L+=this!==B?' > <a href="#">'+this.id+"</a>":" > "+this.id}});Qa=U}else Qa=null;a("#cur_context_panel").toggle(!!B).html(L);T()});f.bind("extension_added",function(s,B){function L(){if(tb){clearTimeout(tb);tb=null}ca||(tb=setTimeout(function(){ca=true;za(b.iconsize)},50))}var U=false,ca=false,pa=true,wa=function(){if(B.callback&&!U&&pa){U=true;B.callback()}},ya=[];B.context_tools&&a.each(B.context_tools,function(Ta,na){var Cb=na.container_id?' id="'+na.container_id+'"':"",db=a("#"+na.panel);
|
|
db.length||(db=a("<div>",{id:na.panel}).appendTo("#tools_top").hide());switch(na.type){case "tool_button":var Ea='<div class="tool_button">'+na.id+"</div>",Ya=a(Ea).appendTo(db);na.events&&a.each(na.events,function(eb,lb){a(Ya).bind(eb,lb)});break;case "select":Ea="<label"+Cb+'><select id="'+na.id+'">';a.each(na.options,function(eb,lb){Ea+='<option value="'+eb+'"'+(eb==na.defval?" selected":"")+">"+lb+"</option>"});Ea+="</select></label>";var Fa=a(Ea).appendTo(db).find("select");a.each(na.events,
|
|
function(eb,lb){a(Fa).bind(eb,lb)});break;case "button-select":Ea='<div id="'+na.id+'" class="dropdown toolset" title="'+na.title+'"><div id="cur_'+na.id+'" class="icon_label"></div><button></button></div>';Cb=a('<ul id="'+na.id+'_opts"></ul>').appendTo("#option_lists");na.colnum&&Cb.addClass("optcols"+na.colnum);a(Ea).appendTo(db).children();ya.push({elem:"#"+na.id,list:"#"+na.id+"_opts",title:na.title,callback:na.events.change,cur:"#cur_"+na.id});break;case "input":Ea="<label"+Cb+'><span id="'+
|
|
na.id+'_label">'+na.label+':</span><input id="'+na.id+'" title="'+na.title+'" size="'+(na.size||"4")+'" value="'+(na.defval||"")+'" type="text"/></label>';var ib=a(Ea).appendTo(db).find("input");na.spindata&&ib.SpinButton(na.spindata);na.events&&a.each(na.events,function(eb,lb){ib.bind(eb,lb)})}});if(B.buttons){var Ca={},Ba={},Aa=B.svgicons,Ab={};a.each(B.buttons,function(Ta,na){for(var Cb,db=na.id,Ea=Ta;a("#"+db).length;)db=na.id+"_"+ ++Ea;if(Aa){Ca[db]=na.icon;Ea=na.svgicon?na.svgicon:na.id;if(na.type==
|
|
"app_menu")Ba["#"+db+" > div"]=Ea;else Ba["#"+db]=Ea}else Cb=na.type=="menu"?"":a('<img src="'+na.icon+'">');var Ya,Fa;switch(na.type){case "mode_flyout":case "mode":Ya="tool_button";if(na.cls)Ya+=" "+na.cls;Fa="#tools_left";break;case "context":Ya="tool_button";Fa="#"+na.panel;a(Fa).length||a("<div>",{id:na.panel}).appendTo("#tools_top");break;case "menu":Ya="menu_item tool_button";Fa="#"+(na.after||na.panel);break;case "app_menu":Ya="";Fa=na.parent||"#main_menu ul";a(Fa).length||a("<div>",{id:na.panel}).appendTo("#tools_top")}var ib=
|
|
a(na.list||na.type=="app_menu"?"<li/>":"<div/>").attr("id",db).attr("title",na.title).addClass(Ya);if(!na.includeWith&&!na.list){if("position"in na)a(Fa).children().eq(na.position).before(ib);else na.type!="menu"||!na.after?ib.appendTo(Fa):a(Fa).after(ib);if(na.type=="mode_flyout"){Ea=a(ib);Ya=Ea.parent();if(!Ea.parent().hasClass("tools_flyout")){var eb=Ea[0].id.replace("tool_","tools_"),lb=Ea.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Ea.before(lb);Ya=zb(eb,Ea);
|
|
Ya.data("isLibrary",true);lb.data("isLibrary",true)}Ba["#"+eb+"_show"]=na.id;db=Ab["#"+Ya[0].id]=[{sel:"#"+db,fn:na.events.click,icon:na.id,isDefault:true},$b]}else if(na.type=="app_menu"||na.type=="menu")ib.append(na.title)}else if(na.list){ib.addClass("push_button");a("#"+na.list+"_opts").append(ib);if(na.isDefault){a("#cur_"+na.list).append(ib.children().clone());Ea=na.svgicon?na.svgicon:na.id;Ba["#cur_"+na.list]=Ea}}else if(na.includeWith){Fa=na.includeWith;Ea=a(Fa.button);Ya=Ea.parent();if(!Ea.parent().hasClass("tools_flyout")){eb=
|
|
Ea[0].id.replace("tool_","tools_");lb=Ea.clone().attr("id",eb+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));Ea.before(lb);Ya=zb(eb,Ea)}var $b=qc.getButtonData(Fa.button);if(Fa.isDefault)Ba["#"+eb+"_show"]=na.id;db=Ab["#"+Ya[0].id]=[{sel:"#"+db,fn:na.events.click,icon:na.id,key:na.key,isDefault:na.includeWith?na.includeWith.isDefault:0},$b];eb="position"in Fa?Fa.position:"last";$b=Ya.children().length;if(!isNaN(eb)&&eb>=0&&eb<$b)Ya.children().eq(eb).before(ib);else{Ya.append(ib);db.reverse()}}Aa||
|
|
ib.append(Cb);na.list||a.each(na.events,function(Qb,Zb){if(Qb=="click")if(na.type=="mode"){na.includeWith?ib.bind(Qb,Zb):ib.bind(Qb,function(){La(ib)&&Zb()});if(na.key){a(document).bind("keydown",na.key,Zb);na.title&&ib.attr("title",na.title+" ["+na.key+"]")}}else ib.bind(Qb,Zb);else ib.bind(Qb,Zb)});Pa(Ab)});a.each(ya,function(){Fb(this.elem,this.list,this.callback,{seticon:true})});if(Aa)pa=false;a.svgIcons(Aa,{w:27,h:27,id_match:false,no_img:!Q,fallback:Ca,placement:Ba,callback:function(){b.iconsize&&
|
|
b.iconsize!="m"&&L();pa=true;wa()}})}wa()});f.textActions.setInputElem(a("#text")[0]);var Sa='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4",
|
|
"#aaffff","#aad4ff"],function(s,B){Sa+='<div class="palette_item" style="background-color: '+B+';" data-rgb="'+B+'"></div>'});a("#palette").append(Sa);Sa="";a.each(["#FFF","#888","#000"],function(){Sa+='<div class="color_block" style="background-color:'+this+';"></div>'});a("#bg_blocks").append(Sa);var gb=a("#bg_blocks div");gb.each(function(){a(this).click(function(){gb.removeClass("cur_background");a(this).addClass("cur_background")})});if(a.pref("bkgd_color"))n(a.pref("bkgd_color"),a.pref("bkgd_url"));
|
|
else a.pref("bkgd_url")&&n(p.bkgd_color,a.pref("bkgd_url"));if(a.pref("img_save")){b.img_save=a.pref("img_save");a("#image_save_opts input").val([b.img_save])}var Ia=function(s){var B=s.value/100;if(B<0.0010)s.value=0.1;else{s=f.getZoom();Xa(window,{width:0,height:0,x:(ka[0].scrollLeft+ka.width()/2)/s,y:(ka[0].scrollTop+ka.height()/2)/s,zoom:B},true)}},rb=function(s,B){if(B==null)B=s.value;a("#group_opacity").val(B);if(!s||!s.handle)a("#opac_slider").slider("option","value",B);f.setOpacity(B/100)},
|
|
sb=function(s,B,L){if(B==null)B=s.value;a("#blur").val(B);var U=false;if(!s||!s.handle){a("#blur_slider").slider("option","value",B);U=true}L?f.setBlurNoUndo(B):f.setBlur(B,U)},mb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){f.setStrokeAttr("stroke-dasharray",a(this).val());mb()});a("#stroke_linejoin").change(function(){f.setStrokeAttr("stroke-linejoin",a(this).val());mb()});a("select").change(function(){a(this).blur()});var hb=false;a("#selLayerNames").change(function(){var s=
|
|
this.options[this.selectedIndex].value,B=e.notification.QmoveElemsToLayer.replace("%s",s),L=function(U){if(U){hb=true;f.moveSelectedToLayer(s);f.clearSelection();Hb()}};if(s)hb?L(true):a.confirm(B,L)});a("#font_family").change(function(){f.setFontFamily(this.value)});a("#seg_type").change(function(){f.setSegType(a(this).val())});a("#text").keyup(function(){f.setTextContent(this.value)});a("#image_url").change(function(){Da(this.value)});a("#link_url").change(function(){this.value.length?f.setLinkURL(this.value):
|
|
f.removeHyperlink()});a("#g_title").change(function(){f.setGroupTitle(this.value)});a(".attr_changer").change(function(){var s=this.getAttribute("data-attr"),B=this.value;if(svgedit.units.isValidUnit(s,B,ga))this.blur();else{a.alert(e.notification.invalidAttrValGiven);this.value=ga.getAttribute(s);return false}if(s!=="id")if(isNaN(B))B=f.convertToNum(s,B);else if(d.baseUnit!=="px"){var L=svgedit.units.getTypeMap();if(ga[s]||f.getMode()==="pathedit"||s==="x"||s==="y")B*=L[d.baseUnit]}if(s==="id"){s=
|
|
ga;f.clearSelection();s.id=B;f.addToSelection([s],true)}else f.changeSelectedAttribute(s,B);this.blur()});a("#palette").mouseover(function(){var s=a('<input type="hidden">');a(this).append(s);s.focus().remove()});a(".palette_item").mousedown(function(){var s=a("#tool_stroke").hasClass("active"),B=s?"stroke":"fill",L=a(this).attr("data-rgb"),U=null;if(L==="transparent"||L==="initial"||L==="#none"){L="none";U=new a.jGraduate.Paint}else U=new a.jGraduate.Paint({alpha:100,solidColor:L.substr(1)});c.paintBox[B].setPaint(U);
|
|
if(s){f.setColor("stroke",L);L!="none"&&f.getStrokeOpacity()!=1&&f.setPaintOpacity("stroke",1)}else{f.setColor("fill",L);L!="none"&&f.getFillOpacity()!=1&&f.setPaintOpacity("fill",1)}}).bind("contextmenu",function(s){s.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");Xb()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");Xb()});var La=function(s,B){if(a(s).hasClass("disabled"))return false;
|
|
if(a(s).parent().hasClass("tools_flyout"))return true;var L=L||"normal";B||a(".tools_flyout").fadeOut(L);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(s).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var s=null,B=null,L=ka[0],U=false,ca=false;a("#svgcanvas").bind("mousemove mouseup",function(pa){if(U!==false){L.scrollLeft-=pa.clientX-s;L.scrollTop-=pa.clientY-B;s=pa.clientX;B=pa.clientY;if(pa.type===
|
|
"mouseup")U=false;return false}}).mousedown(function(pa){if(pa.button===1||ca===true){U=true;s=pa.clientX;B=pa.clientY;return false}});a(window).mouseup(function(){U=false});a(document).bind("keydown","space",function(pa){f.spaceKey=ca=true;pa.preventDefault()}).bind("keyup","space",function(pa){pa.preventDefault();f.spaceKey=ca=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&ka.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&ka.removeClass("out")})})();var Wa=
|
|
a(".menu"),jb=function(s){s.target.style.background="#fff";setTimeout(function(){s.target.style.background="#ddd"},50);setTimeout(function(){s.target.style.background="#fff"},150);setTimeout(function(){s.target.style.background="#ddd"},200);setTimeout(function(){s.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").live("click",function(s){jb(s)});a("svg, body").on("mousedown",function(s){top!=self&&!s.isTrigger&&typeof top.exports.setEditorFocus==
|
|
"function"&&top.exports.setEditorFocus();if(!a(s.target).hasClass("menu_title"))if(!a(s.target).hasClass("disabled")&&a(s.target).hasClass("menu_item"))jb(s);else{a("#menu_bar").removeClass("active");a("#tools_shapelib").is(":visible")&&!a(s.target).parents("#tools_shapelib_show, #tools_shapelib").length&&a("#tools_shapelib").hide();s.target.nodeName.toLowerCase()!="input"&&a("input").blur()}});var Eb=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(s,B,
|
|
L,U){if(s.altKey){s.preventDefault();s=f.getZoom()*100;B=Eb.length;for(Ib=0;Ib<B;Ib++){L=Math.min(B,Ib+1);if(U>0)zoom=Eb[Ib]<=s?Eb[L]:zoom;if(U<0)zoom=Eb[Ib]<s?Eb[Ib]:zoom}zoom&&Ia({value:zoom})}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){Wa.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(s,B,L){if(a(s).length!=0){var U=a(s).find("button"),ca=a(s).find("ul").attr("id",a(s)[0].id+"-list");
|
|
L||a("#option_lists").append(ca);var pa=false;L&&a(s).addClass("dropup");ca.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!pa){U.removeClass("down");ca.hide()}pa=false});U.bind("mousedown",function(){if(U.hasClass("down")){U.removeClass("down");ca.hide()}else{U.addClass("down");if(!L){var wa=a(s).offset();ca.css({top:wa.top,left:wa.left-110})}ca.show();pa=true}}).hover(function(){pa=true}).mouseout(function(){pa=false})}};var Fb=function(s,B,L,U){var ca=a(s);B=a(B);var pa=false,wa=
|
|
U.dropUp;wa&&a(s).addClass("dropup");B.find("li").bind("mouseup",function(){if(U.seticon){ja("#cur_"+ca[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}L.apply(this,arguments)});a(window).mouseup(function(){if(!pa){ca.removeClass("down");B.hide();B.css({top:0,left:0})}pa=false});B.height();a(s).bind("mousedown",function(){var ya=a(s).offset();if(wa){ya.top-=B.height();ya.left+=8}else ya.top+=a(s).height();a(B).offset(ya);if(ca.hasClass("down")){ca.removeClass("down");
|
|
B.hide();B.css({top:0,left:0})}else{ca.addClass("down");B.show();pa=true;return false}}).hover(function(){pa=true}).mouseout(function(){pa=false});U.multiclick&&B.mousedown(function(){pa=true})};c.addDropDown("#font_family_dropdown",function(){a(this).text();a("#font_family").val(a(this).text()).change()});c.addDropDown("#opacity_dropdown",function(){if(!a(this).find("div").length){var s=parseInt(a(this).text().split("%")[0]);rb(false,s)}},false);a("#opac_slider").slider({start:function(){a("#opacity_dropdown li:not(.special)").hide()},
|
|
stop:function(){a("#opacity_dropdown li").show();a(window).mouseup()},slide:function(s,B){rb(B)}});c.addDropDown("#blur_dropdown",a.noop);var nb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(s,B){nb=false;sb(B);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){nb=true},slide:function(s,B){sb(B,null,nb)}});c.addDropDown("#zoom_dropdown",function(){var s=a(this),B=s.attr("data-val");B?Xa(window,B):Ia({value:parseInt(s.text())})},true);Fb("#stroke_linecap","#linecap_opts",
|
|
function(){u(this,true)},{dropUp:true});Fb("#stroke_linejoin","#linejoin_opts",function(){u(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var s=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(s,"page")})});(function(){var s,B=function(){a(s).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){s=this;V="toolbars";ka.mousedown(B)}).blur(function(){V="canvas";ka.unbind("mousedown",B);f.getMode()==
|
|
"textedit"&&a("#text").focus()})})();var Gb=function(){if(La("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},Ob=function(){La("#tool_fhpath")&&f.setMode("fhpath")},Kb=function(){La("#tool_line")&&f.setMode("line")},Ub=function(){La("#tool_rect")&&f.setMode("rect")},ra=function(){La("#tool_ellipse")&&f.setMode("ellipse")},ia=function(){La("#tool_image")&&f.setMode("image")},va=function(){La("#tool_zoom")&&
|
|
f.setMode("zoom")},P=function(){if(La("#tool_zoom")){v();ua()}},J=function(){La("#tool_text")&&f.setMode("text")},fa=function(){La("#tool_path")&&f.setMode("path")},Oa=function(){if(ga!=null||qa)f.deleteSelectedElements()},Za=function(){if(ga!=null||qa){window.event.type==="keydown"&&vb(a("#edit_menu"));f.cutSelectedElements()}},fb=function(){if(ga!=null||qa){window.event.type==="keydown"&&vb(a("#edit_menu"));f.copySelectedElements()}},wb=function(){window.event.type==="keydown"&&vb(a("#edit_menu"));
|
|
var s=f.getZoom(),B=(ka[0].scrollLeft+ka.width()/2)/s-f.contentW;s=(ka[0].scrollTop+ka.height()/2)/s-f.contentH;f.pasteElements("point",B,s)},xb=function(){if(ga!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveToTopSelectedElement()}},Db=function(){if(ga!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveToBottomSelectedElement()}},pb=function(){if(ga!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveUpDownSelected("Up")}},Pb=function(){if(ga!=null){window.event.type===
|
|
"keydown"&&vb(a("#object_menu"));f.moveUpDownSelected("Down")}},cb=function(s){if(ga!=null){window.event.type==="keydown"&&vb(a("#object_menu"));f.moveUpDownSelected(s)}},Nb=function(){if(ga!=null){f.convertToPath();elems=f.getSelectedElems();f.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");f.setMode("pathedit");ha.toEditMode(elems[0]);f.clearSelection()}},Sb=function(){ga!=null&&ha.reorient()},ac=function(){if(ga!=null||qa)a.prompt(e.notification.enterNewLinkURL,
|
|
"http://",function(s){s&&f.makeHyperlink(s)})},Lb=function(s,B){if(ga!=null||qa){if(d.gridSnapping){var L=f.getZoom()*d.snappingStep;s*=L;B*=L}a("input").blur();f.moveSelectedElements(s,B)}},qb=function(){var s=!a("#tool_node_link").hasClass("push_button_pressed");s?a("#tool_node_link").addClass("push_button_pressed").removeClass("tool_button").find("input").attr("checked",true):a("#tool_node_link").removeClass("push_button_pressed").addClass("tool_button").find("input").attr("checked",false);ha.linkControlPoints(s)},
|
|
Ua=function(){ha.getNodePoint()&&ha.clonePathNode()},kc=function(){ha.getNodePoint()&&ha.deletePathNode()},hc=function(){var s=a("#tool_add_subpath"),B=!s.hasClass("push_button_pressed");B?s.addClass("push_button_pressed").removeClass("tool_button"):s.removeClass("push_button_pressed").addClass("tool_button");ha.addSubPath(B)},gc=function(){ha.opencloseSubPath()},ec=function(){f.cycleElement(1)},ic=function(){f.cycleElement(0)},Tb=function(s,B){if(!(ga==null||qa)){s||(B*=-1);var L=a("#angle").val()*
|
|
1+B;f.setRotationAngle(L);bb()}},cc=function(){var s=d.dimensions;a.confirm(e.notification.QwantToClear,function(B){if(B){ua();f.clear();f.setResolution(s[0],s[1]);Wb(true);v();Hb();bb();Na();f.runExtensions("onNewDocument")}})},oc=function(){f.setBold(!f.getBold());bb();return false},Yb=function(){f.setItalic(!f.getItalic());bb();return false},Bb=function(){if(!l.pngsave){var s=e.notification.loadingImage;da=window.open("data:text/html;charset=utf-8,<title>"+s+"</title><h1>"+s+"</h1>")}window.canvg?
|
|
f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},mc=function(){f.open()},lc=function(){},vb=function(s){var B=s.prev();B.css("background","#09f");setTimeout(function(){B.css("background","")},200)},ub=function(){if(W.getUndoStackSize()>0){window.event.type==="keydown"&&vb(a("#edit_menu"));W.undo();Hb()}},bc=function(){if(W.getRedoStackSize()>0){window.event.type==="keydown"&&vb(a("#edit_menu"));W.redo();Hb()}},g=function(){if(qa)f.groupSelectedElements();
|
|
else ga&&f.ungroupSelectedElement()},h=function(){window.event.type==="keydown"&&vb(a("#edit_menu"));f.cloneSelectedElements(20,20)},k=function(){var s=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(s,a("#align_relative_to").val())},w=function(){var s=document.querySelector("#tool_stroke rect"),B=document.querySelector("#tool_fill rect"),L=B.getAttribute("fill"),U=s.getAttribute("fill");s=parseFloat(s.getAttribute("stroke-opacity"));if(isNaN(s))s=100;B=parseFloat(B.getAttribute("fill-opacity"));
|
|
if(isNaN(B))B=100;U=ab(U,s,"stroke");L=ab(L,B,"fill");c.paintBox.fill.setPaint(U,true);c.paintBox.stroke.setPaint(L,true)},v=function(s){var B=f.getResolution();s=s?B.zoom*s:1;a("#zoom").val(s*100);f.setZoom(s);E();Wb(true)},G=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");ka.toggleClass("wireframe");if(!vc){var s=a("#wireframe_rules");s.length?s.empty():a('<style id="wireframe_rules"></style>').appendTo("head");
|
|
E()}},z=function(){var s=!a("#tool_snap").hasClass("push_button_pressed");s?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");d.gridSnapping=s;xa()},A=function(){f.clearSelection();a("#tool_canvas").trigger("click")},C=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},F=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",false);d.showRulers=
|
|
false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);d.showRulers=true}a("#rulers").toggle(!!d.showRulers)},E=function(){if(!vc){var s="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(ka.hasClass("wireframe")?s:"")}},D=function(s,B){if(!Ga){Ga=true;a("#save_output_btns").toggle(!!B);a("#tool_source_back").toggle(!B);var L=ma=f.getSvgString();a("#svg_source_textarea").val(L);a("#svg_source_editor").fadeIn();
|
|
N();a("#svg_source_textarea").focus()}},M=function(){if(!Ma){Ma=true;a("#image_save_opts input").val([b.img_save]);var s=f.getResolution();if(d.baseUnit!=="px"){s.w=svgedit.units.convertUnit(s.w)+d.baseUnit;s.h=svgedit.units.convertUnit(s.h)+d.baseUnit}a(".canvas_width").val(s.w);a(".canvas_height").val(s.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},K=function(){if(!Ra){Ra=true;var s=a("#bg_blocks div"),B=a.pref("bkgd_color"),L=a.pref("bkgd_url");s.each(function(){var U=
|
|
a(this),ca=U.css("background-color")==B;U.toggleClass("cur_background",ca);ca&&a("#canvas_bg_url").removeClass("cur_background")});B||s.eq(0).addClass("cur_background");L&&a("#canvas_bg_url").val(L);a("grid_snapping_step").attr("value",d.snappingStep);d.gridSnapping==true?a("#grid_snapping_on").attr("checked","checked"):a("#grid_snapping_on").removeAttr("checked");a("#svg_prefs").show()}},N=function(){var s=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",s)},aa=function(){if(Ga){var s=
|
|
function(){f.clearSelection();ob();v();Hb();T();Na()};f.setSvgString(a("#svg_source_textarea").val())?s():a.confirm(e.notification.QerrorsRevertToSource,function(B){if(!B)return false;s()});ua()}},T=function(s){s=s||f.getDocumentTitle();s=Va+(s?": "+s:"");a("title:first").text(s)},ta=function(){var s=a("#canvas_width"),B=s.val(),L=a("#canvas_height"),U=L.val();if(B!="fit"&&!svgedit.units.isValidUnit("width",B)){a.alert(e.notification.invalidAttrValGiven);s.parent().addClass("error");return false}s.parent().removeClass("error");
|
|
if(U!="fit"&&!svgedit.units.isValidUnit("height",U)){a.alert(e.notification.invalidAttrValGiven);L.parent().addClass("error");return false}L.parent().removeClass("error");if(!f.setResolution(B,U)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Wb();Vb()},xa=function(){var s=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";n(s,a("#canvas_bg_url").val());za(a("#iconsize").val());d.gridSnapping=a("#tool_snap").hasClass("push_button_pressed");
|
|
d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&ea();d.baseUnit=a("#base_unit").val();f.setConfig(d);Wb();Mb()},ja=c.setIcon=function(s,B){var L=typeof B==="string"?a.getSvgIcon(B,true):B.clone();L?a(s).find("img").replaceWith(L):console.log("NOTE: Icon image missing: "+B)},oa;oa=function(){var s=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,B=document.getElementsByTagName("script")[0],L;for(L in B.style)if(s.test(L))return L.match(s)[0];
|
|
if("WebkitOpacity"in B.style)return"Webkit";if("KhtmlOpacity"in B.style)return"Khtml";return""}();var sa=function(s,B){oa.toLowerCase();var L=["top","left","bottom","right"];s.each(function(){for(var U=a(this),ca=U.outerWidth()*(B-1),pa=U.outerHeight()*(B-1),wa=0;wa<4;wa++){var ya=L[wa],Ca=U.data("orig_margin-"+ya);if(Ca==null){Ca=parseInt(U.css("margin-"+ya));U.data("orig_margin-"+ya,Ca)}Ca=Ca*B;if(ya==="right")Ca+=ca;else if(ya==="bottom")Ca+=pa;U.css("margin-"+ya,Ca)}})},za=c.setIconSize=function(s,
|
|
B){if(!(s==b.size&&!B)){var L=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"),U=1;U=typeof s=="number"?s:{s:0.75,m:1,l:1.25,xl:1.5}[s];c.tool_scale=Y=U;Ja();var ca=L.parents(":hidden");ca.css("visibility","hidden").show();sa(L,U);ca.css("visibility","visible").hide();a.pref("iconsize",s);a("#iconsize").val(s);ca={"#tools_top":{left:50,height:72},
|
|
"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};L=a("#tool_size_rules");if(L.length)L.empty();else L=a('<style id="tool_size_rules"></style>').appendTo("head");if(s!="m"){var pa="";a.each(ca,function(wa,ya){wa="#svg_editor "+wa.replace(/,/g,", #svg_editor");pa+=wa+"{";a.each(ya,function(Ca,Ba){if(typeof Ba==="number")var Aa=Ba*U+"px";else if(Ba[s]||Ba.all)Aa=Ba[s]||Ba.all;pa+=Ca+":"+Aa+";"});pa+="}"});ca="-"+oa.toLowerCase()+"-";pa+="#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{"+
|
|
ca+"transform: scale("+U+");} #svg_editor div.toolset .toolset {"+ca+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+ca+"transform: scale("+1/U+");}";L.text(pa)}Ja()}},kb=function(){a("#dialog_box").hide();if(!Ga&&!Ma&&!Ra)Qa&&f.leaveContext();else{if(Ga)ma!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(s){s&&ob()}):ob();else if(Ma)Vb();else Ra&&Mb();Xb()}},ob=function(){a("#svg_source_editor").hide();Ga=false;a("#svg_source_textarea").blur()},
|
|
Vb=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=0;a("#image_save_opts input").val([b.img_save]);Ma=false},Mb=function(){a("#svg_prefs").hide();Ra=false},Rb={width:a(window).width(),height:a(window).height()},Xb=a.noop,dc;svgedit.browser.isIE()&&function(){Xb=function(){if(ka[0].scrollLeft===0&&ka[0].scrollTop===0){ka[0].scrollLeft=dc.left;ka[0].scrollTop=dc.top}};dc={left:ka[0].scrollLeft,top:ka[0].scrollTop};a(window).resize(Xb);
|
|
svgEditor.ready(function(){setTimeout(function(){Xb()},500)});ka.scroll(function(){dc={left:ka[0].scrollLeft,top:ka[0].scrollTop}})}();a(window).resize(function(){Ga&&N();a.each(Rb,function(s,B){var L=a(window)[s]();ka[0]["scroll"+(s==="width"?"Left":"Top")]-=(L-B)/2;Rb[s]=L})});(function(){ka.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=ka[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=ka[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
|
|
a("#change_image_url").click(I);(function(){var s=["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],B="";a.each(s,function(L,U){B+="#tool_"+U+(L==s.length-1?",":"")});a(B).mousedown(function(){a(this).addClass("tool_button_current")}).bind("mousedown mouseout",function(){a(this).removeClass("tool_button_current")});a("#tool_undo, #tool_redo").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("tool_button_current")}).bind("mousedown mouseout",
|
|
function(){a(this).removeClass("tool_button_current")})})();if(X&&!window.opera){X=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];for(var Ib=X.length;Ib--;){var rc=document.getElementById(X[Ib]);if(rc!=null){var sc=rc.title,wc=sc.indexOf("Ctrl+");rc.title=[sc.substr(0,wc),"Cmd+",sc.substr(wc+5)].join("")}}}var tc=function(s){var B=s[0].id=="stroke_color"?"stroke":"fill",L=s[0].id=="canvas_color";if(L)B="canvas";var U=c.paintBox[B].paint;s=B=="stroke"?"Pick a Stroke Paint and Opacity":
|
|
"Pick a Fill Paint and Opacity";L=L?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(L).jGraduate({paint:U,window:{pickerTitle:s},images:{clientPath:d.jGraduatePath},newstop:"inverse"},function(ca){U=new a.jGraduate.Paint(ca);c.paintBox[B].setPaint(U);f.setPaint(B,U);a("#color_picker").hide()},function(){a("#color_picker").hide()})};X=function(s,B){var L=document.getElementById("canvas_background"),
|
|
U={color:"fff",opacity:1};if(B=="stroke")U=d.initStroke;if(B=="fill")U=d.initFill;if(B=="canvas"&&L)if(L=L.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))U={color:("0"+parseInt(L[1],10).toString(16)).slice(-2)+("0"+parseInt(L[2],10).toString(16)).slice(-2)+("0"+parseInt(L[3],10).toString(16)).slice(-2),opacity:1};L=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+U.color+'" opacity="'+U.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',
|
|
"text/xml").documentElement;L=a(s)[0].appendChild(document.importNode(L,true));L.setAttribute("width",24.5);this.rect=L.firstChild;this.defs=L.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:U.color});this.type=B;this.setPaint=function(ca,pa){this.paint=ca;var wa="none",ya=ca.type,Ca=ca.alpha/100;switch(ya){case "solidColor":wa=ca[ya]=="none"||ca[ya]=="one"?"none":"#"+ca[ya];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);
|
|
this.grad=this.defs.appendChild(ca[ya]);wa="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",wa);this.rect.setAttribute("opacity",Ca);if(pa){f.setColor(this.type,wa,true);f.setPaintOpacity(this.type,Ca,true)}if(this.type=="canvas"){(ya=document.getElementById("canvas_background"))?ya.setAttribute("fill",wa):Ka(wa);console.log(ya.getAttribute("fill"))}};this.update=function(ca){if(ga){var pa=this.type;switch(ga.tagName){case "use":case "image":case "foreignObject":return;
|
|
case "g":case "a":for(var wa=null,ya=ga.getElementsByTagName("*"),Ca=0,Ba=ya.length;Ca<Ba;Ca++){var Aa=ya[Ca].getAttribute(pa);if(Ca===0)wa=Aa;else if(wa!==Aa){wa=null;break}}if(wa===null){ya=null;return}ya=wa;wa=1;break;default:wa=parseFloat(ga.getAttribute(pa+"-opacity"));if(isNaN(wa))wa=1;ya=pa==="fill"?"black":"none";ya=ga.getAttribute(pa)||ya}if(ca){f.setColor(pa,ya,true);f.setPaintOpacity(pa,wa,true)}wa*=100;this.setPaint(ab(ya,wa,pa))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var ca=
|
|
new a.jGraduate.Paint({copy:this.paint});f.setPaint(B,ca)}}};c.paintBox.fill=new X("#fill_color","fill");c.paintBox.stroke=new X("#stroke_color","stroke");c.paintBox.canvas=new X("#canvas_color","canvas");a("#stroke_width").val(d.initStroke.width);a("#group_opacity").val(d.initOpacity*100);X=c.paintBox.fill.rect.cloneNode(false);X.setAttribute("style","vector-effect:non-scaling-stroke");var vc=X.style.vectorEffect==="non-scaling-stroke";X.removeAttribute("style");X=c.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
|
|
"feGaussianBlur");typeof X.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(X).remove();setTimeout(function(){f.embedImage("images/placeholder.svg",function(s){if(!s){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);b.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",e.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))tc(a("#fill_color"));else{a("#tool_fill").addClass("active");
|
|
a("#tool_stroke").removeClass("active")}});a("#tool_canvas").click(function(){tc(a("#canvas_color"))});a("#tool_stroke").click(function(){if(a("#tool_stroke").hasClass("active"))tc(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#group_opacityLabel").click(function(){a("#opacity_dropdown button").mousedown();a(window).mouseup()});a("#zoomLabel").click(function(){a("#zoom_dropdown button").mousedown();a(window).mouseup()});a("#tool_move_top").mousedown(function(s){a("#tools_stacking").show();
|
|
s.preventDefault()});a(".layer_button").mousedown(function(){a(this).addClass("layer_buttonpressed")}).mouseout(function(){a(this).removeClass("layer_buttonpressed")}).mouseup(function(){a(this).removeClass("layer_buttonpressed")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
|
|
a("#layer_new").click(function(){var s=f.getCurrentDrawing().getNumLayers();do var B=e.layers.layer+" "+ ++s;while(f.getCurrentDrawing().hasLayer(B));a.prompt(e.notification.enterUniqueLayerName,B,function(L){if(L)if(f.getCurrentDrawing().hasLayer(L))a.alert(e.notification.dupeLayerName);else{f.createLayer(L);bb();Hb()}})});a("#layer_delete").click(S);a("#layer_up").click(function(){H(-1)});a("#layer_down").click(function(){H(1)});a("#layer_rename").click(function(){a("#layerlist tr.layersel").prevAll();
|
|
var s=a("#layerlist tr.layersel td.layername").text();a.prompt(e.notification.enterNewLayerName,"",function(B){if(B)if(s==B||f.getCurrentDrawing().hasLayer(B))a.alert(e.notification.layerHasThatName);else{f.renameCurrentLayer(B);Hb()}})});var fc=-1,nc=false,uc=false,xc=function(s){if(uc)if(fc!=-1){nc=true;s=fc-s.pageX;var B=a("#sidepanels"),L=parseInt(B.css("width"));if(L+s>300)s=300-L;else if(L+s<2)s=2-L;if(s!=0){fc-=s;L=a("#layerpanel");ka.css("right",parseInt(ka.css("right"))+s);B.css("width",
|
|
parseInt(B.css("width"))+s);L.css("width",parseInt(L.css("width"))+s);B=a("#ruler_x");B.css("right",parseInt(B.css("right"))+s)}}};a("#sidepanel_handle").mousedown(function(s){fc=s.pageX;a(window).mousemove(xc);uc=false;setTimeout(function(){uc=true},20)}).mouseup(function(){nc||yc();fc=-1;nc=false});a(window).mouseup(function(){fc=-1;nc=false;a("#svg_editor").unbind("mousemove",xc)});var yc=function(s){var B=parseInt(a("#sidepanels").css("width"));s=(B>2||s?2:150)-B;B=a("#sidepanels");var L=a("#layerpanel"),
|
|
U=a("#ruler_x");ka.css("right",parseInt(ka.css("right"))+s);B.css("width",parseInt(B.css("width"))+s);L.css("width",parseInt(L.css("width"))+s);U.css("right",parseInt(U.css("right"))+s)},zc=function(s){for(var B=Array(f.getCurrentDrawing().getNumLayers()),L=0;L<B.length;++L)B[L]=f.getCurrentDrawing().getLayerName(L);if(s)for(L=0;L<B.length;++L)B[L]!=s&&f.getCurrentDrawing().setLayerOpacity(B[L],0.5);else for(L=0;L<B.length;++L)f.getCurrentDrawing().setLayerOpacity(B[L],1)},Hb=function(){var s=a("#layerlist tbody"),
|
|
B=a("#selLayerNames");s.empty();B.empty();for(var L=f.getCurrentDrawing().getCurrentLayerName(),U=f.getCurrentDrawing().getNumLayers(),ca=a.getSvgIcon("eye");U--;){var pa=f.getCurrentDrawing().getLayerName(U),wa='<tr class="layer';if(pa==L)wa+=" layersel";wa+='">';wa+=f.getCurrentDrawing().getLayerVisibility(pa)?'<td class="layervis"/><td class="layername" >'+pa+"</td></tr>":'<td class="layervis layerinvis"/><td class="layername" >'+pa+"</td></tr>";s.append(wa);B.append('<option value="'+pa+'">'+
|
|
pa+"</option>")}if(ca!==undefined){ca.clone();a("td.layervis",s).append(ca.clone());a.resizeSvgIcons({"td.layervis .svg_icon":14})}a("#layerlist td.layername").mouseup(function(ya){a("#layerlist tr.layer").removeClass("layersel");a(this.parentNode).addClass("layersel");f.setCurrentLayer(this.textContent);ya.preventDefault()}).mouseover(function(){a(this).css({"font-style":"italic",color:"blue"});zc(this.textContent)}).mouseout(function(){a(this).css({"font-style":"normal",color:"black"});zc()});a("#layerlist td.layervis").click(function(){var ya=
|
|
a(this.parentNode).prevAll().length;ya=a("#layerlist tr.layer:eq("+ya+") td.layername").text();var Ca=a(this).hasClass("layerinvis");f.setLayerVisibility(ya,Ca);Ca?a(this).removeClass("layerinvis"):a(this).addClass("layerinvis")});for(B=5-a("#layerlist tr.layer").size();B-- >0;)s.append('<tr><td style="color:white">_</td><td/></tr>')};Hb();a(window).bind("load resize",function(){ka.css("line-height",ka.height()+"px")});a("#resolution").change(function(){var s=a("#canvas_width,#canvas_height");if(this.selectedIndex)if(this.value==
|
|
"content")s.val("fit").attr("disabled","disabled");else{var B=this.value.split("x");a("#canvas_width").val(B[0]);a("#canvas_height").val(B[1]);s.removeAttr("disabled")}else a("#canvas_width").val()=="fit"&&s.removeAttr("disabled").val(100)});a("input,select").attr("autocomplete","off");var qc=function(){var s=[{sel:"#tool_select",fn:Gb,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Ob,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:Kb,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ub,evt:"click",
|
|
key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:ra,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:fa,evt:"click",key:["P",true]},{sel:"#tool_text",fn:J,evt:"click",key:["T",true]},{sel:"#tool_image",fn:ia,evt:"mouseup"},{sel:"#tool_zoom",fn:va,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:cc,evt:"mouseup",key:[R+"N",true]},{sel:"#tool_save",fn:function(){Ga?aa():f.save({images:b.img_save,round_digits:6})},evt:"mouseup",key:[R+"S",true]},{sel:"#tool_export",fn:Bb,evt:"mouseup"},
|
|
{sel:"#tool_open",fn:mc,evt:"mouseup"},{sel:"#tool_import",fn:lc,evt:"mouseup"},{sel:"#tool_source",fn:D,evt:"click",key:[R+"U",true]},{sel:"#tool_wireframe",fn:G,evt:"click"},{sel:"#tool_snap",fn:z,evt:"click"},{sel:"#tool_rulers",fn:F,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:kb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:aa,evt:"click"},{sel:"#tool_docprops_save",fn:ta,evt:"click"},{sel:"#tool_docprops",
|
|
fn:M,evt:"mouseup"},{sel:"#tool_prefs_save",fn:xa,evt:"click"},{sel:"#tool_prefs_option",fn:function(){K();return false},evt:"mouseup"},{sel:"#tool_delete,#tool_delete_multi",fn:Oa,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:Sb,evt:"click"},{sel:"#tool_node_link",fn:qb,evt:"click"},{sel:"#tool_node_clone",fn:Ua,evt:"click"},{sel:"#tool_node_delete",fn:kc,evt:"click"},{sel:"#tool_openclose_path",fn:gc,evt:"click"},{sel:"#tool_add_subpath",fn:hc,evt:"click"},{sel:"#tool_move_top",
|
|
fn:xb,evt:"click",key:R+"shift+up"},{sel:"#tool_move_bottom",fn:Db,evt:"click",key:R+"shift+down"},{sel:"#tool_move_up",fn:pb,evt:"click",key:[R+"up",true]},{sel:"#tool_move_down",fn:Pb,evt:"click",key:[R+"down",true]},{sel:"#tool_topath",fn:Nb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ac,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:h,evt:"click",key:[R+"D",true]},{sel:"#tool_group",fn:g,evt:"click",key:[R+"G",true]},{sel:"#tool_ungroup",fn:g,evt:"click",key:R+"shift+G"},
|
|
{sel:"#tool_unlink_use",fn:g,evt:"click"},{sel:"[id^=tool_align]",fn:k,evt:"click"},{sel:"#tool_switch",fn:w,evt:"click",key:["shift+x",true]},{sel:"#tool_undo",fn:ub,evt:"click",key:R+"z"},{sel:"#tool_redo",fn:bc,evt:"click",key:["y",true]},{sel:"#tool_canvas_color_menu",fn:A,evt:"click"},{sel:"#tool_cut",fn:Za,evt:"click",key:R+"x"},{sel:"#tool_copy",fn:fb,evt:"click",key:R+"c"},{sel:"#tool_paste",fn:wb,evt:"click",key:R+"v"},{sel:"#tool_bold",fn:oc,evt:"mousedown",key:[R+"B",true]},{sel:"#tool_italic",
|
|
fn:Yb,evt:"mousedown",key:[R+"I",true]},{sel:"#copy_save_done",fn:kb,evt:"click"},{key:"ctrl+left",fn:function(){Tb(0,1)}},{key:"ctrl+right",fn:function(){Tb(1,1)}},{key:"ctrl+shift+left",fn:function(){Tb(0,5)}},{key:"ctrl+shift+right",fn:function(){Tb(1,5)}},{key:"shift+O",fn:ic},{key:"shift+P",fn:ec},{key:[R+"+",true],fn:function(){v(2)}},{key:[R+"-",true],fn:function(){v(0.5)}},{key:["up",true],fn:function(){Lb(0,-1)}},{key:["down",true],fn:function(){Lb(0,1)}},{key:["left",true],fn:function(){Lb(-1,
|
|
0)}},{key:["right",true],fn:function(){Lb(1,0)}},{key:"shift+up",fn:function(){Lb(0,-10)}},{key:"shift+down",fn:function(){Lb(0,10)}},{key:"shift+left",fn:function(){Lb(-10,0)}},{key:"shift+right",fn:function(){Lb(10,0)}},{key:["alt+up",true],fn:function(){f.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){f.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){f.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){f.cloneSelectedElements(1,0)}},{key:["alt+shift+up",
|
|
true],fn:function(){f.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){f.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){f.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){f.cloneSelectedElements(10,0)}},{key:R+"A",fn:function(){f.selectAllInCurrentLayer()}},{key:R+"shift+z",fn:bc},{key:"esc",fn:C}],B={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var L={};a.each(s,function(U,ca){if(ca.sel){var pa=
|
|
a(ca.sel);if(pa.length==0)return true;if(ca.evt){if(svgedit.browser.isTouch()&&ca.evt==="click")ca.evt="mousedown";pa[ca.evt](ca.fn)}if(ca.parent&&a(ca.parent+"_show").length!=0){var wa=a(ca.parent);wa.length||(wa=zb(ca.parent.substr(1)));wa.append(pa);a.isArray(L[ca.parent])||(L[ca.parent]=[]);L[ca.parent].push(ca)}}if(ca.key){var ya=ca.fn,Ca=false;if(a.isArray(ca.key)){wa=ca.key[0];if(ca.key.length>1)Ca=ca.key[1]}else wa=ca.key;wa+="";svgedit.browser.isMac&&wa.indexOf("+")!=-1&&wa.split("+")[0]==
|
|
"ctrl"&&wa.replace("ctrl","cmd");a.each(wa.split("/"),function(Aa,Ab){a(document).bind("keydown",Ab,function(Ta){ya();Ca&&Ta.preventDefault();return false})});if(ca.sel&&!ca.hidekey&&pa.attr("title")){var Ba=pa.attr("title").split("[")[0]+" ("+wa+")";B[wa]=ca.sel;pa.parents("#main_menu").length||pa.attr("title",Ba)}}});Pa(L);a(".attr_changer, #image_url").bind("keydown","return",function(U){a(this).change();U.preventDefault()});a(window).bind("keydown","tab",function(U){if(V==="canvas"){U.preventDefault();
|
|
ec()}}).bind("keydown","shift+tab",function(U){if(V==="canvas"){U.preventDefault();ic()}});a("#tool_zoom").dblclick(P)},setTitles:function(){a.each(B,function(L,U){var ca=a(U).parents("#main_menu").length;a(U).each(function(){var pa=ca?a(this).text().split(" [")[0]:this.title.split(" [")[0],wa="";a.each(L.split("/"),function(ya,Ca){var Ba=Ca.split("+"),Aa="";if(Ba.length>1){Aa=Ba[0]+"+";Ca=Ba[1]}wa+=(ya?"/":"")+Aa+(e["key_"+Ca]||Ca)});if(ca)this.lastChild.textContent=pa+" ["+wa+"]";else this.title=
|
|
pa+" ["+wa+"]"})})},getButtonData:function(L){var U;a.each(s,function(ca,pa){if(pa.sel===L)U=pa});return U}}}();qc.setAll();c.ready(function(){var s=d.initTool,B=a("#tools_left, #svg_editor .tools_flyout"),L=B.find("#tool_"+s);s=B.find("#"+s);(L.length?L:s.length?s:a("#tool_select")).click().mouseup();d.wireframe&&a("#tool_wireframe").click();d.showlayers&&yc();a("#rulers").toggle(!!d.showRulers);if(d.showRulers)a("#show_rulers")[0].checked=true;if(d.gridSnapping)a("#grid_snapping_on")[0].checked=
|
|
true;d.baseUnit&&a("#base_unit").val(d.baseUnit);d.snappingStep&&a("#grid_snapping_step").val(d.snappingStep)});a("#rect_rx").SpinButton({min:0,max:1E3,step:1,callback:function(s){f.setRectRadius(s.value)}});a("#stroke_width").SpinButton({min:0,max:99,step:1,smallStep:0.1,callback:function(s){var B=s.value;if(B==0&&ga&&["line","polyline"].indexOf(ga.nodeName)>=0)B=s.value=1;f.setStrokeWidth(B)}});a("#angle").SpinButton({min:-180,max:180,step:5,callback:function(s){f.setRotationAngle(s.value);a("#tool_reorient").toggleClass("disabled",
|
|
s.value==0)}});a("#font_size").SpinButton({step:1,min:0.0010,stepfunc:function(s,B){var L=s.value-0,U=L+B,ca=U>=L;if(B===0)return L;return L>=24?ca?Math.round(L*1.1):Math.round(L/1.1):L<=1?ca?L*2:L/2:U},callback:function(s){f.setFontSize(s.value)}});a("#group_opacity").SpinButton({step:5,min:0,max:100,callback:rb});a("#blur").SpinButton({step:0.1,min:0,max:10,callback:sb});a("#zoom").SpinButton({min:0.0010,max:1E4,step:50,stepfunc:function(s,B){var L=s.value-0;if(L===0)return 100;var U=L+B;if(B===
|
|
0)return L;return L>=100?U:U>=L?L*2:L/2},callback:Ia}).val(f.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(s){switch(s){case "delete":Oa();break;case "cut":Za();break;case "copy":fb();break;case "paste":f.pasteElements();break;case "paste_in_place":f.pasteElements("in_place");break;case "group":f.groupSelectedElements();break;case "ungroup":f.ungroupSelectedElement();break;case "move_front":xb();break;case "move_up":cb("Up");break;case "move_down":cb("Down");break;
|
|
case "move_back":Db();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(s)&&svgedit.contextmenu.getCustomHandler(s).call()}f.clipBoard.length&&la.enableContextMenuItems("#paste,#paste_in_place")});X=function(s){switch(s){case "dupe":O();break;case "delete":S();break;case "merge_down":if(a("#layerlist tr.layersel").index()!=f.getCurrentDrawing().getNumLayers()-1){f.mergeLayer();bb();Hb()}break;case "merge_all":f.mergeAllLayers();bb();Hb()}};a("#layerlist").contextMenu({menu:"cmenu_layers",
|
|
inSpeed:0},X);a("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:true},X);a(".contextMenu li").mousedown(function(s){s.preventDefault()});a("#cmenu_canvas li").disableContextMenu();la.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(W.getUndoStackSize()===0)c.show_save_warning=false;if(!d.no_save_warning&&c.show_save_warning)return e.notification.unsavedChanges};c.openPrep=function(s){a("#main_menu").hide();W.getUndoStackSize()===0?s(true):a.confirm(e.notification.QwantToOpen,
|
|
s)};if(window.FileReader){X=a('<input type="file">').change(function(){var s=this;c.openPrep(function(B){if(B){f.clear();if(s.files.length==1){B=new FileReader;B.onloadend=function(L){o(L.target.result);Wb()};B.readAsText(s.files[0])}}})});a("#tool_open").show().prepend(X);X=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var s=new FileReader;s.onloadend=function(B){f.importSvgString(B.target.result,true);Wb()};s.readAsText(this.files[0])}});a("#tool_import").show().prepend(X)}var Wb=
|
|
c.updateCanvas=function(s,B){var L=ka.width(),U=ka.height(),ca=L,pa=U,wa=f.getZoom(),ya=a("#svgcanvas"),Ca={x:ka[0].scrollLeft+ca/2,y:ka[0].scrollTop+pa/2},Ba=d.canvas_expansion;L=Math.max(ca,f.contentW*wa*Ba);U=Math.max(pa,f.contentH*wa*Ba);L==ca&&U==pa?ka.css("overflow","hidden"):ka.css("overflow","scroll");Ba=ya.height()/2;var Aa=ya.width()/2;ya.width(L).height(U);var Ab=U/2,Ta=L/2,na=f.updateCanvas(L,U),Cb=Ta/Aa;L=L/2-ca/2;U=U/2-pa/2;if(B){B.x+=na.x;B.y+=na.y}else B={x:Ta+(Ca.x-Aa)*Cb,y:Ab+(Ca.y-
|
|
Ba)*Cb};if(s)if(f.contentW>ka.width()){ka[0].scrollLeft=na.x-10;ka[0].scrollTop=na.y-10}else{ka[0].scrollLeft=L;ka[0].scrollTop=U}else{ka[0].scrollLeft=B.x-ca/2;ka[0].scrollTop=B.y-pa/2}if(d.showRulers){ea(ya,wa);ka.scroll()}},jc=[];for(Ib=0.1;Ib<1E5;Ib*=10){jc.push(1*Ib);jc.push(2*Ib);jc.push(5*Ib)}Wb(true);try{var Ac=function(s){if(window.JSON&&JSON.stringify)return JSON.stringify(s);var B=arguments.callee;if(typeof s=="boolean"||typeof s=="number")return s+"";else if(typeof s=="string")return'"'+
|
|
s.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(ca){return"\\u"+("0000"+ca.charCodeAt(0).toString(16)).slice(-4)})+'"';else if(s.length){for(var L=0;L<s.length;L++)s[L]=B(s[L]);return"["+s.join(",")+"]"}else{L=[];for(var U in s)L.push(B(U)+":"+B(s[U]));return"{"+L.join(",")+"}"}};window.addEventListener("message",function(s){var B=parseInt(s.data.substr(0,s.data.indexOf(";")));try{s.source.postMessage("SVGe"+
|
|
B+";"+Ac(eval(s.data)),"*")}catch(L){s.source.postMessage("SVGe"+B+";error:"+L.message,"*")}},false)}catch(Bc){window.embed_error=Bc}a(function(){window.svgCanvas=f;f.ready=svgEditor.ready});c.setLang=function(s,B){a.pref("lang",s);a("#lang_select").val(s);if(B){var L=a("#layerlist tr.layersel td.layername").text()==e.common.layer+" 1";a.extend(e,B);f.setUiStrings(B);qc.setTitles();if(L){f.renameCurrentLayer(e.common.layer+" 1");Hb()}f.runExtensions("langChanged",s);Jb();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block",
|
|
"#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(U,ca){a(ca).attr("title",a(U)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var q=[];c.ready=function(u){m?u():q.push(u)};c.runCallbacks=function(){a.each(q,function(){this()});m=true};c.loadFromString=function(u){c.ready(function(){o(u)})};c.disableUI=function(){};c.loadFromURL=function(u,
|
|
n){n||(n={});var I=n.cache,S=n.callback;c.ready(function(){a.ajax({url:u,dataType:"text",cache:!!I,success:function(O){o(O,S)},error:function(O,H,ea){O.status!=404&&O.responseText?o(O.responseText,S):a.alert(e.notification.URLloadFail+": \n"+ea+"",S)}})})};c.loadFromDataURI=function(u){c.ready(function(){var n=u.substring(26);o(svgedit.utilities.decode64(n))})};c.addExtension=function(){var u=arguments;a(function(){f&&f.addExtension.apply(this,u)})};return c}(jQuery);$(svgEditor.init)})();svgedit=svgedit||{};
|
|
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var o=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var f=o.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+o.id+"'>"+o.label+"<span class='shortcut'>"+f+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
|
|
{}};svgedit.contextmenu.add=function(o){if(o&&o.id&&o.label&&o.action&&typeof o.action=="function")if(o.id in a.contextMenuExtensions)console.error('Cannot add extension "'+o.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+o.id+", label:"+o.label+"}");a.contextMenuExtensions[o.id]=o}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(o){return a.contextMenuExtensions[o]&&true};svgedit.contextmenu.getCustomHandler=function(o){return a.contextMenuExtensions[o].action}})();var svgEditor=function(a,o){function f(m,p,b){var d=a("#svg_editor").parent(),e;for(e in p){var l=p[e];l||console.log(e);if(b)e="#"+e;if(d.find(e).length){var q=d.find(e)[0];switch(m){case "content":for(var u=0;u<q.childNodes.length;u++){var n=q.childNodes[u];if(n.nodeType===3&&n.textContent.replace(/\s/g,"")){n.textContent=l;break}}break;case "title":q.title=l}}else console.log("Missing: "+e)}}var c;o.readLang=function(m){var p=o.canvas.runExtensions("addlangData",c,true);a.each(p,function(S,O){if(O.data)m=
|
|
a.merge(m,O.data)});if(m.tools){var b=m.tools;p=m.properties;var d=m.config,e=m.layers,l=m.common,q=m.ui;f("content",{copyrightLabel:m.misc.powered_by,curve_segments:p.curve_segments,fitToContent:b.fitToContent,fit_to_all:b.fit_to_all,fit_to_canvas:b.fit_to_canvas,fit_to_layer_content:b.fit_to_layer_content,fit_to_sel:b.fit_to_sel,icon_large:d.icon_large,icon_medium:d.icon_medium,icon_small:d.icon_small,icon_xlarge:d.icon_xlarge,image_opt_embed:d.image_opt_embed,image_opt_ref:d.image_opt_ref,includedImages:d.included_images,
|
|
largest_object:b.largest_object,layersLabel:e.layers,page:b.page,relativeToLabel:b.relativeTo,selLayerLabel:e.move_elems_to,selectedPredefined:d.select_predefined,selected_objects:b.selected_objects,smallest_object:b.smallest_object,straight_segments:p.straight_segments,svginfo_bg_url:d.editor_img_url+":",svginfo_bg_note:d.editor_bg_note,svginfo_change_background:d.background,svginfo_dim:d.doc_dims,svginfo_editor_prefs:d.editor_prefs,svginfo_height:l.height,svginfo_icons:d.icon_size,svginfo_image_props:d.image_props,
|
|
svginfo_lang:d.language,svginfo_title:d.doc_title,svginfo_width:l.width,tool_docprops_cancel:l.cancel,tool_docprops_save:l.ok,tool_source_cancel:l.cancel,tool_source_save:l.ok,tool_prefs_cancel:l.cancel,tool_prefs_save:l.ok,sidepanel_handle:e.layers.split("").join(" "),tool_clear:b.new_doc,tool_docprops:b.docprops,tool_export:b.export_png,tool_import:b.import_doc,tool_imagelib:b.imagelib,tool_open:b.open_doc,tool_save:b.save_doc,svginfo_units_rulers:d.units_and_rulers,svginfo_rulers_onoff:d.show_rulers,
|
|
svginfo_unit:d.base_unit,svginfo_grid_settings:d.grid,svginfo_snap_onoff:d.snapping_onoff,svginfo_snap_step:d.snapping_stepsize},true);var u={},n;for(n in m.shape_cats)u['#shape_cats [data-cat="'+n+'"]']=m.shape_cats[n];setTimeout(function(){f("content",u)},2E3);var I={};a.each(["cut","copy","paste","paste_in_place","delete","group","ungroup","move_front","move_up","move_down","move_back"],function(){I['#cmenu_canvas a[href="#'+this+'"]']=b[this]});a.each(["dupe","merge_down","merge_all"],function(){I['#cmenu_layers a[href="#'+
|
|
this+'"]']=e[this]});I['#cmenu_layers a[href="#delete"]']=e.del;f("content",I);f("title",{align_relative_to:b.align_relative_to,circle_cx:p.circle_cx,circle_cy:p.circle_cy,circle_r:p.circle_r,cornerRadiusLabel:p.corner_radius,ellipse_cx:p.ellipse_cx,ellipse_cy:p.ellipse_cy,ellipse_rx:p.ellipse_rx,ellipse_ry:p.ellipse_ry,fill_color:p.fill_color,font_family:p.font_family,idLabel:p.id,image_height:p.image_height,image_url:p.image_url,image_width:p.image_width,layer_delete:e.del,layer_down:e.move_down,
|
|
layer_new:e["new"],layer_rename:e.rename,layer_moreopts:l.more_opts,layer_up:e.move_up,line_x1:p.line_x1,line_x2:p.line_x2,line_y1:p.line_y1,line_y2:p.line_y2,linecap_butt:p.linecap_butt,linecap_round:p.linecap_round,linecap_square:p.linecap_square,linejoin_bevel:p.linejoin_bevel,linejoin_miter:p.linejoin_miter,linejoin_round:p.linejoin_round,main_icon:b.main_menu,mode_connect:b.mode_connect,tools_shapelib_show:b.mode_shapelib,palette:q.palette_info,zoom_panel:q.zoom_level,path_node_x:p.node_x,path_node_y:p.node_y,
|
|
rect_height_tool:p.rect_height,rect_width_tool:p.rect_width,seg_type:p.seg_type,selLayerNames:e.move_selected,selected_x:p.pos_x,selected_y:p.pos_y,stroke_color:p.stroke_color,stroke_style:p.stroke_style,stroke_width:p.stroke_width,svginfo_title:d.doc_title,text:p.text_contents,toggle_stroke_tools:q.toggle_stroke_tools,tool_add_subpath:b.add_subpath,tool_alignbottom:b.align_bottom,tool_aligncenter:b.align_center,tool_alignleft:b.align_left,tool_alignmiddle:b.align_middle,tool_alignright:b.align_right,
|
|
tool_aligntop:b.align_top,tool_angle:p.angle,tool_blur:p.blur,tool_bold:p.bold,tool_circle:b.mode_circle,tool_clone:b.clone,tool_clone_multi:b.clone,tool_delete:b.del,tool_delete_multi:b.del,tool_ellipse:b.mode_ellipse,tool_eyedropper:b.mode_eyedropper,tool_fhellipse:b.mode_fhellipse,tool_fhpath:b.mode_fhpath,tool_fhrect:b.mode_fhrect,tool_font_size:p.font_size,tool_group:b.group,tool_make_link:b.make_link,tool_link_url:b.set_link_url,tool_image:b.mode_image,tool_italic:p.italic,tool_line:b.mode_line,
|
|
tool_move_bottom:b.move_bottom,tool_move_top:b.move_top,tool_node_clone:b.node_clone,tool_node_delete:b.node_delete,tool_node_link:b.node_link,tool_opacity:p.opacity,tool_openclose_path:b.openclose_path,tool_path:b.mode_path,tool_position:b.align_to_page,tool_rect:b.mode_rect,tool_redo:b.redo,tool_reorient:b.reorient_path,tool_select:b.mode_select,tool_source:b.source_save,tool_square:b.mode_square,tool_text:b.mode_text,tool_topath:b.to_path,tool_undo:b.undo,tool_ungroup:b.ungroup,tool_wireframe:b.wireframe_mode,
|
|
view_grid:b.toggle_grid,tool_zoom:b.mode_zoom,url_notice:b.no_embed},true);o.setLang(c,m)}};o.putLocale=function(m,p){if(m)c=m;else{c=a.pref("lang");if(!c){if(navigator.userLanguage)c=navigator.userLanguage;else if(navigator.language)c=navigator.language;if(c=="")return}console.log("Lang: "+c);if(a.inArray(c,p)==-1&&c!=="test")c="en";if(c.indexOf("en")==0)return}var b=o.curConfig.langPath+"lang."+c+".js";a.getScript(b,function(d){if(!d){d=document.createElement("script");d.src=b;document.querySelector("head").appendChild(d)}})};
|
|
return o}(jQuery,svgEditor);(function(a,o){function f(m){return!a(m).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function c(m,p){var b=m.nodeName.toLowerCase();if("area"===b){b=m.parentNode;var d=b.name;if(!m.href||!d||b.nodeName.toLowerCase()!=="map")return false;b=a("img[usemap=#"+d+"]")[0];return!!b&&f(b)}return(/input|select|textarea|button|object/.test(b)?!m.disabled:"a"==b?m.href||p:p)&&f(m)}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.17",
|
|
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(m,p){return typeof m=="number"?this.each(function(){var b=
|
|
this;setTimeout(function(){a(b).focus();p&&p.call(b)},m)}):this._focus.apply(this,arguments)},scrollParent:function(){var m;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?m=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):m=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,
|
|
"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!m.length?a(document):m},zIndex:function(m){if(m!==o)return this.css("zIndex",m);if(this.length){m=a(this[0]);for(var p;m.length&&m[0]!==document;){p=m.css("position");if(p==="absolute"||p==="relative"||p==="fixed"){p=parseInt(m.css("zIndex"),10);if(!isNaN(p)&&p!==0)return p}m=m.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":
|
|
"mousedown")+".ui-disableSelection",function(m){m.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(m,p){function b(q,u,n,I){a.each(d,function(){u-=parseFloat(a.curCSS(q,"padding"+this,true))||0;n&&(u-=parseFloat(a.curCSS(q,"border"+this+"Width",true))||0);I&&(u-=parseFloat(a.curCSS(q,"margin"+this,true))||0)});return u}var d=p==="Width"?["Left","Right"]:["Top","Bottom"],e=p.toLowerCase(),l={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,
|
|
outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+p]=function(q){if(q===o)return l["inner"+p].call(this);return this.each(function(){a(this).css(e,b(this,q)+"px")})};a.fn["outer"+p]=function(q,u){if(typeof q!="number")return l["outer"+p].call(this,q);return this.each(function(){a(this).css(e,b(this,q,true,u)+"px")})}}),a.extend(a.expr[":"],{data:function(m,p,b){return!!a.data(m,b[3])},focusable:function(m){return c(m,!isNaN(a.attr(m,"tabindex")))},tabbable:function(m){var p=a.attr(m,
|
|
"tabindex"),b=isNaN(p);return(b||p>=0)&&c(m,!b)}}),a(function(){var m=document.body,p=m.appendChild(p=document.createElement("div"));a.extend(p.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=p.offsetHeight===100;a.support.selectstart="onselectstart"in p;m.removeChild(p).style.display="none"}),a.extend(a.ui,{plugin:{add:function(m,p,b){m=a.ui[m].prototype;for(var d in b){m.plugins[d]=m.plugins[d]||[];m.plugins[d].push([p,b[d]])}},call:function(m,p,b){if((p=m.plugins[p])&&
|
|
m.element[0].parentNode)for(var d=0;d<p.length;d++)m.options[p[d][0]]&&p[d][1].apply(m.element,b)}},contains:function(m,p){return document.compareDocumentPosition?m.compareDocumentPosition(p)&16:m!==p&&m.contains(p)},hasScroll:function(m,p){if(a(m).css("overflow")==="hidden")return false;var b=p&&p==="left"?"scrollLeft":"scrollTop",d=false;if(m[b]>0)return true;m[b]=1;d=m[b]>0;m[b]=0;return d},isOverAxis:function(m,p,b){return m>p&&m<p+b},isOver:function(m,p,b,d,e,l){return a.ui.isOverAxis(m,b,e)&&
|
|
a.ui.isOverAxis(p,d,l)}}))})(jQuery);
|
|
(function(a,o){if(a.cleanData){var f=a.cleanData;a.cleanData=function(m){for(var p=0,b;(b=m[p])!=null;p++)try{a(b).triggerHandler("remove")}catch(d){}f(m)}}else{var c=a.fn.remove;a.fn.remove=function(m,p){return this.each(function(){p||(!m||a.filter(m,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}});return c.call(a(this),m,p)})}}a.widget=function(m,p,b){var d=m.split(".")[0],e;m=m.split(".")[1];e=d+"-"+m;b||(b=p,p=a.Widget);a.expr[":"][e]=
|
|
function(l){return!!a.data(l,m)};a[d]=a[d]||{};a[d][m]=function(l,q){arguments.length&&this._createWidget(l,q)};p=new p;p.options=a.extend(true,{},p.options);a[d][m].prototype=a.extend(true,p,{namespace:d,widgetName:m,widgetEventPrefix:a[d][m].prototype.widgetEventPrefix||m,widgetBaseClass:e},b);a.widget.bridge(m,a[d][m])};a.widget.bridge=function(m,p){a.fn[m]=function(b){var d=typeof b=="string",e=Array.prototype.slice.call(arguments,1),l=this;b=!d&&e.length?a.extend.apply(null,[true,b].concat(e)):
|
|
b;if(d&&b.charAt(0)==="_")return l;d?this.each(function(){var q=a.data(this,m),u=q&&a.isFunction(q[b])?q[b].apply(q,e):q;if(u!==q&&u!==o){l=u;return false}}):this.each(function(){var q=a.data(this,m);q?q.option(b||{})._init():a.data(this,m,new p(b,this))});return l}};a.Widget=function(m,p){arguments.length&&this._createWidget(m,p)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(m,p){a.data(p,this.widgetName,this);this.element=a(p);this.options=
|
|
a.extend(true,{},this.options,this._getCreateOptions(),m);var b=this;this.element.bind("remove."+this.widgetName,function(){b.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
|
|
"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(m,p){var b=m;if(arguments.length===0)return a.extend({},this.options);if(typeof m=="string"){if(p===o)return this.options[m];b={};b[m]=p}this._setOptions(b);return this},_setOptions:function(m){var p=this;a.each(m,function(b,d){p._setOption(b,d)});return this},_setOption:function(m,p){this.options[m]=p;m==="disabled"&&this.widget()[p?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
|
|
p);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(m,p,b){var d,e=this.options[m];b=b||{};p=a.Event(p);p.type=(m===this.widgetEventPrefix?m:this.widgetEventPrefix+m).toLowerCase();p.target=this.element[0];if(m=p.originalEvent)for(d in m)d in p||(p[d]=m[d]);this.element.trigger(p,b);return!(a.isFunction(e)&&e.call(this.element[0],p,b)===false||p.isDefaultPrevented())}}})(jQuery);
|
|
(function(a){var o=false;a(document).mouseup(function(){o=false});a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var f=this;this.element.bind("mousedown."+this.widgetName,function(c){return f._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===a.data(c.target,f.widgetName+".preventClickEvent")){a.removeData(c.target,f.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
|
|
this.widgetName)},_mouseDown:function(f){if(!o){this._mouseStarted&&this._mouseUp(f);this._mouseDownEvent=f;var c=this,m=f.which==1,p=typeof this.options.cancel=="string"&&f.target.nodeName?a(f.target).closest(this.options.cancel).length:false;if(!m||p||!this._mouseCapture(f))return true;(this.mouseDelayMet=!this.options.delay)||(this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay));if(this._mouseDistanceMet(f)&&this._mouseDelayMet(f)){this._mouseStarted=this._mouseStart(f)!==
|
|
false;if(!this._mouseStarted){f.preventDefault();return true}}true===a.data(f.target,this.widgetName+".preventClickEvent")&&a.removeData(f.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(b){return c._mouseMove(b)};this._mouseUpDelegate=function(b){return c._mouseUp(b)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);f.preventDefault();return o=true}},_mouseMove:function(f){if(a.browser.msie&&
|
|
!(document.documentMode>=9)&&!f.button)return this._mouseUp(f);if(this._mouseStarted){this._mouseDrag(f);return f.preventDefault()}this._mouseDistanceMet(f)&&this._mouseDelayMet(f)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,f)!==false,this._mouseStarted?this._mouseDrag(f):this._mouseUp(f));return!this._mouseStarted},_mouseUp:function(f){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);this._mouseStarted&&
|
|
(this._mouseStarted=false,f.target==this._mouseDownEvent.target&&a.data(f.target,this.widgetName+".preventClickEvent",true),this._mouseStop(f));return false},_mouseDistanceMet:function(f){return Math.max(Math.abs(this._mouseDownEvent.pageX-f.pageX),Math.abs(this._mouseDownEvent.pageY-f.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
|
|
(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){this.options.helper=="original"&&
|
|
!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative");this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(o){var f=this.options;
|
|
if(this.helper||f.disabled||a(o.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(o);if(!this.handle)return false;f.iframeFix&&a(f.iframeFix===true?"iframe":f.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(a(this).offset()).appendTo("body")});return true},_mouseStart:function(o){var f=this.options;this.helper=
|
|
this._createHelper(o);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:o.pageX-this.offset.left,top:o.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
|
|
this.originalPosition=this.position=this._generatePosition(o);this.originalPageX=o.pageX;this.originalPageY=o.pageY;f.cursorAt&&this._adjustOffsetFromHelper(f.cursorAt);f.containment&&this._setContainment();if(this._trigger("start",o)===false){this._clear();return false}this._cacheHelperProportions();a.ui.ddmanager&&!f.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,o);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(o,true);a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,o);return true},
|
|
_mouseDrag:function(o,f){this.position=this._generatePosition(o);this.positionAbs=this._convertPositionTo("absolute");if(!f){var c=this._uiHash();if(this._trigger("drag",o,c)===false){this._mouseUp({});return false}this.position=c.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";a.ui.ddmanager&&a.ui.ddmanager.drag(this,o);return false},_mouseStop:function(o){var f=
|
|
false;a.ui.ddmanager&&!this.options.dropBehaviour&&(f=a.ui.ddmanager.drop(this,o));this.dropped&&(f=this.dropped,this.dropped=false);if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!f||this.options.revert=="valid"&&f||this.options.revert===true||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,f)){var c=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),
|
|
function(){c._trigger("stop",o)!==false&&c._clear()})}else this._trigger("stop",o)!==false&&this._clear();return false},_mouseUp:function(o){this.options.iframeFix===true&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,o);return a.ui.mouse.prototype._mouseUp.call(this,o)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(o){var f=!this.options.handle||
|
|
!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){this==o.target&&(f=true)});return f},_createHelper:function(o){var f=this.options;o=a.isFunction(f.helper)?a(f.helper.apply(this.element[0],[o])):f.helper=="clone"?this.element.clone().removeAttr("id"):this.element;o.parents("body").length||o.appendTo(f.appendTo=="parent"?this.element[0].parentNode:f.appendTo);o[0]!=this.element[0]&&!/(fixed|absolute)/.test(o.css("position"))&&
|
|
o.css("position","absolute");return o},_adjustOffsetFromHelper:function(o){typeof o=="string"&&(o=o.split(" "));a.isArray(o)&&(o={left:+o[0],top:+o[1]||0});"left"in o&&(this.offset.click.left=o.left+this.margins.left);"right"in o&&(this.offset.click.left=this.helperProportions.width-o.right+this.margins.left);"top"in o&&(this.offset.click.top=o.top+this.margins.top);"bottom"in o&&(this.offset.click.top=this.helperProportions.height-o.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=
|
|
this.helper.offsetParent();var o=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(o.left+=this.scrollParent.scrollLeft(),o.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)o={top:0,left:0};return{top:o.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:o.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
|
|
10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var o=this.element.position();return{top:o.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:o.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 o=this.options;o.containment=="parent"&&(o.containment=this.helper[0].parentNode);if(o.containment=="document"||o.containment=="window")this.containment=[o.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,o.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
|
|
(o.containment=="document"?0:a(window).scrollLeft())+a(o.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(o.containment=="document"?0:a(window).scrollTop())+(a(o.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(o.containment)&&o.containment.constructor!=Array){o=a(o.containment);var f=o[0];if(f){o.offset();var c=a(f).css("overflow")!=
|
|
"hidden";this.containment=[(parseInt(a(f).css("borderLeftWidth"),10)||0)+(parseInt(a(f).css("paddingLeft"),10)||0),(parseInt(a(f).css("borderTopWidth"),10)||0)+(parseInt(a(f).css("paddingTop"),10)||0),(c?Math.max(f.scrollWidth,f.offsetWidth):f.offsetWidth)-(parseInt(a(f).css("borderLeftWidth"),10)||0)-(parseInt(a(f).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(f.scrollHeight,f.offsetHeight):f.offsetHeight)-(parseInt(a(f).css("borderTopWidth"),
|
|
10)||0)-(parseInt(a(f).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=o}}else o.containment.constructor==Array&&(this.containment=o.containment)},_convertPositionTo:function(o,f){f||(f=this.position);var c=o=="absolute"?1:-1,m=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,p=/(html|body)/i.test(m[0].tagName);return{top:f.top+
|
|
this.offset.relative.top*c+this.offset.parent.top*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():p?0:m.scrollTop())*c),left:f.left+this.offset.relative.left*c+this.offset.parent.left*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():p?0:m.scrollLeft())*c)}},_generatePosition:function(o){var f=this.options,c=this.cssPosition=="absolute"&&
|
|
(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,m=/(html|body)/i.test(c[0].tagName),p=o.pageX,b=o.pageY;if(this.originalPosition){var d;if(this.containment){if(this.relative_container){d=this.relative_container.offset();d=[this.containment[0]+d.left,this.containment[1]+d.top,this.containment[2]+d.left,this.containment[3]+d.top]}else d=this.containment;o.pageX-this.offset.click.left<d[0]&&(p=d[0]+this.offset.click.left);
|
|
o.pageY-this.offset.click.top<d[1]&&(b=d[1]+this.offset.click.top);o.pageX-this.offset.click.left>d[2]&&(p=d[2]+this.offset.click.left);o.pageY-this.offset.click.top>d[3]&&(b=d[3]+this.offset.click.top)}if(f.grid){b=f.grid[1]?this.originalPageY+Math.round((b-this.originalPageY)/f.grid[1])*f.grid[1]:this.originalPageY;b=d?b-this.offset.click.top<d[1]||b-this.offset.click.top>d[3]?b-this.offset.click.top<d[1]?b+f.grid[1]:b-f.grid[1]:b:b;p=f.grid[0]?this.originalPageX+Math.round((p-this.originalPageX)/
|
|
f.grid[0])*f.grid[0]:this.originalPageX;p=d?p-this.offset.click.left<d[0]||p-this.offset.click.left>d[2]?p-this.offset.click.left<d[0]?p+f.grid[0]:p-f.grid[0]:p:p}}return{top:b-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():m?0:c.scrollTop()),left:p-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<
|
|
526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():m?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(o,f,c){c=c||this._uiHash();a.ui.plugin.call(this,o,[f,c]);o=="drag"&&(this.positionAbs=this._convertPositionTo("absolute"));return a.Widget.prototype._trigger.call(this,o,f,
|
|
c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});a.extend(a.ui.draggable,{version:"1.8.17"});a.ui.plugin.add("draggable","connectToSortable",{start:function(o,f){var c=a(this).data("draggable"),m=c.options,p=a.extend({},f,{item:c.element});c.sortables=[];a(m.connectToSortable).each(function(){var b=a.data(this,"sortable");b&&!b.options.disabled&&(c.sortables.push({instance:b,shouldRevert:b.options.revert}),
|
|
b.refreshPositions(),b._trigger("activate",o,p))})},stop:function(o,f){var c=a(this).data("draggable"),m=a.extend({},f,{item:c.element});a.each(c.sortables,function(){this.instance.isOver?(this.instance.isOver=0,c.cancelHelperRemoval=true,this.instance.cancelHelperRemoval=false,this.shouldRevert&&(this.instance.options.revert=true),this.instance._mouseStop(o),this.instance.options.helper=this.instance.options._helper,c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):
|
|
(this.instance.cancelHelperRemoval=false,this.instance._trigger("deactivate",o,m))})},drag:function(o,f){var c=a(this).data("draggable"),m=this;a.each(c.sortables,function(){this.instance.positionAbs=c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(m).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",
|
|
true),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return f.helper[0]},o.target=this.instance.currentItem[0],this.instance._mouseCapture(o,true),this.instance._mouseStart(o,true,true),this.instance.offset.click.top=c.offset.click.top,this.instance.offset.click.left=c.offset.click.left,this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top,
|
|
c._trigger("toSortable",o),c.dropped=this.instance.element,c.currentItem=c.element,this.instance.fromOutside=c),this.instance.currentItem&&this.instance._mouseDrag(o)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=true,this.instance.options.revert=false,this.instance._trigger("out",o,this.instance._uiHash(this.instance)),this.instance._mouseStop(o,true),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&
|
|
this.instance.placeholder.remove(),c._trigger("fromSortable",o),c.dropped=false)})}});a.ui.plugin.add("draggable","cursor",{start:function(){var o=a("body"),f=a(this).data("draggable").options;o.css("cursor")&&(f._cursor=o.css("cursor"));o.css("cursor",f.cursor)},stop:function(){var o=a(this).data("draggable").options;o._cursor&&a("body").css("cursor",o._cursor)}});a.ui.plugin.add("draggable","opacity",{start:function(o,f){var c=a(f.helper),m=a(this).data("draggable").options;c.css("opacity")&&(m._opacity=
|
|
c.css("opacity"));c.css("opacity",m.opacity)},stop:function(o,f){var c=a(this).data("draggable").options;c._opacity&&a(f.helper).css("opacity",c._opacity)}});a.ui.plugin.add("draggable","scroll",{start:function(){var o=a(this).data("draggable");o.scrollParent[0]!=document&&o.scrollParent[0].tagName!="HTML"&&(o.overflowOffset=o.scrollParent.offset())},drag:function(o){var f=a(this).data("draggable"),c=f.options,m=false;if(f.scrollParent[0]!=document&&f.scrollParent[0].tagName!="HTML"){if(!c.axis||
|
|
c.axis!="x")f.overflowOffset.top+f.scrollParent[0].offsetHeight-o.pageY<c.scrollSensitivity?f.scrollParent[0].scrollTop=m=f.scrollParent[0].scrollTop+c.scrollSpeed:o.pageY-f.overflowOffset.top<c.scrollSensitivity&&(f.scrollParent[0].scrollTop=m=f.scrollParent[0].scrollTop-c.scrollSpeed);if(!c.axis||c.axis!="y")f.overflowOffset.left+f.scrollParent[0].offsetWidth-o.pageX<c.scrollSensitivity?f.scrollParent[0].scrollLeft=m=f.scrollParent[0].scrollLeft+c.scrollSpeed:o.pageX-f.overflowOffset.left<c.scrollSensitivity&&
|
|
(f.scrollParent[0].scrollLeft=m=f.scrollParent[0].scrollLeft-c.scrollSpeed)}else{if(!c.axis||c.axis!="x")o.pageY-a(document).scrollTop()<c.scrollSensitivity?m=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(o.pageY-a(document).scrollTop())<c.scrollSensitivity&&(m=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed));if(!c.axis||c.axis!="y")o.pageX-a(document).scrollLeft()<c.scrollSensitivity?m=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):
|
|
a(window).width()-(o.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(m=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))}m!==false&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(f,o)}});a.ui.plugin.add("draggable","snap",{start:function(){var o=a(this).data("draggable"),f=o.options;o.snapElements=[];a(f.snap.constructor!=String?f.snap.items||":data(draggable)":f.snap).each(function(){var c=a(this),m=c.offset();this!=o.element[0]&&o.snapElements.push({item:this,
|
|
width:c.outerWidth(),height:c.outerHeight(),top:m.top,left:m.left})})},drag:function(o,f){for(var c=a(this).data("draggable"),m=c.options,p=m.snapTolerance,b=f.offset.left,d=b+c.helperProportions.width,e=f.offset.top,l=e+c.helperProportions.height,q=c.snapElements.length-1;q>=0;q--){var u=c.snapElements[q].left,n=u+c.snapElements[q].width,I=c.snapElements[q].top,S=I+c.snapElements[q].height;if(u-p<b&&b<n+p&&I-p<e&&e<S+p||u-p<b&&b<n+p&&I-p<l&&l<S+p||u-p<d&&d<n+p&&I-p<e&&e<S+p||u-p<d&&d<n+p&&I-p<l&&
|
|
l<S+p){if(m.snapMode!="inner"){var O=Math.abs(I-l)<=p,H=Math.abs(S-e)<=p,ea=Math.abs(u-d)<=p,X=Math.abs(n-b)<=p;O&&(f.position.top=c._convertPositionTo("relative",{top:I-c.helperProportions.height,left:0}).top-c.margins.top);H&&(f.position.top=c._convertPositionTo("relative",{top:S,left:0}).top-c.margins.top);ea&&(f.position.left=c._convertPositionTo("relative",{top:0,left:u-c.helperProportions.width}).left-c.margins.left);X&&(f.position.left=c._convertPositionTo("relative",{top:0,left:n}).left-c.margins.left)}var Q=
|
|
O||H||ea||X;if(m.snapMode!="outer"){O=Math.abs(I-e)<=p;H=Math.abs(S-l)<=p;ea=Math.abs(u-b)<=p;X=Math.abs(n-d)<=p;O&&(f.position.top=c._convertPositionTo("relative",{top:I,left:0}).top-c.margins.top);H&&(f.position.top=c._convertPositionTo("relative",{top:S-c.helperProportions.height,left:0}).top-c.margins.top);ea&&(f.position.left=c._convertPositionTo("relative",{top:0,left:u}).left-c.margins.left);X&&(f.position.left=c._convertPositionTo("relative",{top:0,left:n-c.helperProportions.width}).left-
|
|
c.margins.left)}!c.snapElements[q].snapping&&(O||H||ea||X||Q)&&c.options.snap.snap&&c.options.snap.snap.call(c.element,o,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=O||H||ea||X||Q}else{c.snapElements[q].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,o,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var o=a(this).data("draggable").options;
|
|
o=a.makeArray(a(o.stack)).sort(function(c,m){return(parseInt(a(c).css("zIndex"),10)||0)-(parseInt(a(m).css("zIndex"),10)||0)});if(o.length){var f=parseInt(o[0].style.zIndex)||0;a(o).each(function(c){this.style.zIndex=f+c});this[0].style.zIndex=f+o.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(o,f){var c=a(f.helper),m=a(this).data("draggable").options;c.css("zIndex")&&(m._zIndex=c.css("zIndex"));c.css("zIndex",m.zIndex)},stop:function(o,f){var c=a(this).data("draggable").options;
|
|
c._zIndex&&a(f.helper).css("zIndex",c._zIndex)}})})(jQuery);
|
|
(function(a){a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var o=this,f=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),m=f.values&&f.values.length||1,p=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
|
|
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(f.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);f.range&&(f.range===true&&(f.values||(f.values=[this._valueMin(),this._valueMin()]),f.values.length&&f.values.length!==2&&(f.values=[f.values[0],f.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(f.range==="min"||f.range==="max"?" ui-slider-range-"+f.range:"")));for(var b=c.length;b<m;b+=1)p.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
|
|
this.handles=c.add(a(p.join("")).appendTo(o.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(d){d.preventDefault()}).hover(function(){f.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){f.disabled?a(this).blur():(a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),a(this).addClass("ui-state-focus"))}).blur(function(){a(this).removeClass("ui-state-focus")});this.handles.each(function(d){a(this).data("index.ui-slider-handle",
|
|
d)});this.handles.keydown(function(d){var e=true,l=a(this).data("index.ui-slider-handle"),q,u,n;if(!o.options.disabled){switch(d.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:e=false;if(!o._keySliding){o._keySliding=true;a(this).addClass("ui-state-active");q=o._start(d,l);if(q===false)return}}q=o.options.step;o.options.values&&o.options.values.length?
|
|
u=n=o.values(l):u=n=o.value();switch(d.keyCode){case a.ui.keyCode.HOME:n=o._valueMin();break;case a.ui.keyCode.END:n=o._valueMax();break;case a.ui.keyCode.PAGE_UP:n=o._trimAlignValue(u+(o._valueMax()-o._valueMin())/5);break;case a.ui.keyCode.PAGE_DOWN:n=o._trimAlignValue(u-(o._valueMax()-o._valueMin())/5);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(u===o._valueMax())return;n=o._trimAlignValue(u+q);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(u===o._valueMin())return;n=o._trimAlignValue(u-
|
|
q)}o._slide(d,l,n);return e}}).keyup(function(d){var e=a(this).data("index.ui-slider-handle");o._keySliding&&(o._keySliding=false,o._stop(d,e),o._change(d,e),a(this).removeClass("ui-state-active"))});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();
|
|
return this},_mouseCapture:function(o){var f=this.options,c,m,p,b,d;if(f.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:o.pageX,y:o.pageY});m=this._valueMax()-this._valueMin()+1;b=this;this.handles.each(function(e){var l=Math.abs(c-b.values(e));m>l&&(m=l,p=a(this),d=e)});f.range===true&&this.values(1)===f.min&&(d+=1,p=a(this.handles[d]));if(this._start(o,d)===false)return false;
|
|
this._mouseSliding=true;b._handleIndex=d;p.addClass("ui-state-active").focus();f=p.offset();this._clickOffset=!a(o.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:o.pageX-f.left-p.width()/2,top:o.pageY-f.top-p.height()/2-(parseInt(p.css("borderTopWidth"),10)||0)-(parseInt(p.css("borderBottomWidth"),10)||0)+(parseInt(p.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(o,d,c);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(o){var f=
|
|
this._normValueFromMouse({x:o.pageX,y:o.pageY});this._slide(o,this._handleIndex,f);return false},_mouseStop:function(o){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(o,this._handleIndex);this._change(o,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(o){var f,c;this.orientation==="horizontal"?
|
|
(f=this.elementSize.width,c=o.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(f=this.elementSize.height,c=o.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));o=c/f;o>1&&(o=1);o<0&&(o=0);this.orientation==="vertical"&&(o=1-o);f=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+o*f)},_start:function(o,f){var c={handle:this.handles[f],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(f),
|
|
c.values=this.values());return this._trigger("start",o,c)},_slide:function(o,f,c){var m,p,b;this.options.values&&this.options.values.length?(m=this.values(f?0:1),this.options.values.length===2&&this.options.range===true&&(f===0&&c>m||f===1&&c<m)&&(c=m),c!==this.values(f)&&(p=this.values(),p[f]=c,b=this._trigger("slide",o,{handle:this.handles[f],value:c,values:p}),this.values(f?0:1),b!==false&&this.values(f,c,true))):c!==this.value()&&(b=this._trigger("slide",o,{handle:this.handles[f],value:c}),b!==
|
|
false&&this.value(c))},_stop:function(o,f){var c={handle:this.handles[f],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(f),c.values=this.values());this._trigger("stop",o,c)},_change:function(o,f){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[f],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(f),c.values=this.values());this._trigger("change",o,c)}},value:function(o){if(arguments.length){this.options.value=
|
|
this._trimAlignValue(o);this._refreshValue();this._change(null,0)}else return this._value()},values:function(o,f){var c,m,p;if(arguments.length>1){this.options.values[o]=this._trimAlignValue(f);this._refreshValue();this._change(null,o)}else{if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(o):this.value();c=this.options.values;m=arguments[0];for(p=0;p<c.length;p+=1){c[p]=this._trimAlignValue(m[p]);this._change(null,
|
|
p)}this._refreshValue()}},_setOption:function(o,f){var c,m=0;a.isArray(this.options.values)&&(m=this.options.values.length);a.Widget.prototype._setOption.apply(this,arguments);switch(o){case "disabled":f?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",true),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",false),this.element.removeClass("ui-disabled"));break;case "orientation":this._detectOrientation();
|
|
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(c=0;c<m;c+=1)this._change(null,c);this._animateOff=false}},_value:function(){var o=this.options.value;return o=this._trimAlignValue(o)},_values:function(o){var f,c;if(arguments.length){f=this.options.values[o];
|
|
return f=this._trimAlignValue(f)}f=this.options.values.slice();for(c=0;c<f.length;c+=1)f[c]=this._trimAlignValue(f[c]);return f},_trimAlignValue:function(o){if(o<=this._valueMin())return this._valueMin();if(o>=this._valueMax())return this._valueMax();var f=this.options.step>0?this.options.step:1,c=(o-this._valueMin())%f;o=o-c;Math.abs(c)*2>=f&&(o+=c>0?f:-f);return parseFloat(o.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var o=
|
|
this.options.range,f=this.options,c=this,m=this._animateOff?false:f.animate,p,b={},d,e,l,q;this.options.values&&this.options.values.length?this.handles.each(function(u){p=(c.values(u)-c._valueMin())/(c._valueMax()-c._valueMin())*100;b[c.orientation==="horizontal"?"left":"bottom"]=p+"%";a(this).stop(1,1)[m?"animate":"css"](b,f.animate);c.options.range===true&&(c.orientation==="horizontal"?(u===0&&c.range.stop(1,1)[m?"animate":"css"]({left:p+"%"},f.animate),u===1&&c.range[m?"animate":"css"]({width:p-
|
|
d+"%"},{queue:false,duration:f.animate})):(u===0&&c.range.stop(1,1)[m?"animate":"css"]({bottom:p+"%"},f.animate),u===1&&c.range[m?"animate":"css"]({height:p-d+"%"},{queue:false,duration:f.animate})));d=p}):(e=this.value(),l=this._valueMin(),q=this._valueMax(),p=q!==l?(e-l)/(q-l)*100:0,b[c.orientation==="horizontal"?"left":"bottom"]=p+"%",this.handle.stop(1,1)[m?"animate":"css"](b,f.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[m?"animate":"css"]({width:p+"%"},f.animate),
|
|
o==="max"&&this.orientation==="horizontal"&&this.range[m?"animate":"css"]({width:100-p+"%"},{queue:false,duration:f.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[m?"animate":"css"]({height:p+"%"},f.animate),o==="max"&&this.orientation==="vertical"&&this.range[m?"animate":"css"]({height:100-p+"%"},{queue:false,duration:f.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(b,d){if(d===undefined)d=0;return Math.round(b*Math.pow(10,d))/Math.pow(10,d)};var o=function(b,d){var e=this,l=b.find("img:first"),q=0,u=100,n=100,I=0,S=100,O=100,H=0,ea=0,X,Q,R=[],ha=function(Y){for(var V=0;V<R.length;V++)R[V].call(e,e,Y)},W=function(Y){var V=b.offset();X={l:V.left|0,t:V.top|0};clearTimeout(Q);Q=setTimeout(function(){ka.call(e,Y)},0);a(document).bind("mousemove",Z).bind("mouseup",ba);Y.preventDefault()},Z=function(Y){clearTimeout(Q);Q=setTimeout(function(){ka.call(e,
|
|
Y)},0);Y.stopPropagation();Y.preventDefault();return false},ba=function(Y){a(document).unbind("mouseup",ba).unbind("mousemove",Z);Y.stopPropagation();Y.preventDefault();return false},ka=function(Y){var V=Y.pageX-X.l;Y=Y.pageY-X.t;var ma=b.w,ua=b.h;if(V<0)V=0;else if(V>ma)V=ma;if(Y<0)Y=0;else if(Y>ua)Y=ua;la.call(e,"xy",{x:V/ma*n+q,y:Y/ua*O+I})},la=function(Y,V,ma){if(V===undefined){if(Y===undefined||Y==null)Y="xy";switch(Y.toLowerCase()){case "x":return H;case "y":return ea;default:return{x:H,y:ea}}}if(!(ma!=
|
|
null&&ma==e)){var ua=false,ga,qa;if(Y==null)Y="xy";switch(Y.toLowerCase()){case "x":ga=V&&(V.x&&V.x|0||V|0)||0;break;case "y":qa=V&&(V.y&&V.y|0||V|0)||0;break;default:ga=V&&V.x&&V.x|0||0;qa=V&&V.y&&V.y|0||0}if(ga!=null){if(ga<q)ga=q;else if(ga>u)ga=u;if(H!=ga){H=ga;ua=true}}if(qa!=null){if(qa<I)qa=I;else if(qa>S)qa=S;if(ea!=qa){ea=qa;ua=true}}ua&&ha.call(e,ma||e)}},da=function(Y){a.isFunction(Y)&&R.push(Y)};a.extend(true,e,{val:la,range:function(Y,V){if(V===undefined){if(Y===undefined||Y==null)Y=
|
|
"all";switch(Y.toLowerCase()){case "minx":return q;case "maxx":return u;case "rangex":return{minX:q,maxX:u,rangeX:n};case "miny":return I;case "maxy":return S;case "rangey":return{minY:I,maxY:S,rangeY:O};default:return{minX:q,maxX:u,rangeX:n,minY:I,maxY:S,rangeY:O}}}var ma,ua,ga,qa;if(Y==null)Y="all";switch(Y.toLowerCase()){case "minx":ma=V&&(V.minX&&V.minX|0||V|0)||0;break;case "maxx":ua=V&&(V.maxX&&V.maxX|0||V|0)||0;break;case "rangex":ma=V&&V.minX&&V.minX|0||0;ua=V&&V.maxX&&V.maxX|0||0;break;case "miny":ga=
|
|
V&&(V.minY&&V.minY|0||V|0)||0;break;case "maxy":qa=V&&(V.maxY&&V.maxY|0||V|0)||0;break;case "rangey":ga=V&&V.minY&&V.minY|0||0;qa=V&&V.maxY&&V.maxY|0||0;break;default:ma=V&&V.minX&&V.minX|0||0;ua=V&&V.maxX&&V.maxX|0||0;ga=V&&V.minY&&V.minY|0||0;qa=V&&V.maxY&&V.maxY|0||0}if(ma!=null&&q!=ma){q=ma;n=u-q}if(ua!=null&&u!=ua){u=ua;n=u-q}if(ga!=null&&I!=ga){I=ga;O=S-I}if(qa!=null&&S!=qa){S=qa;O=S-I}},bind:da,unbind:function(Y){if(a.isFunction(Y))for(var V;(V=a.inArray(Y,R))!=-1;)R.splice(V,1)},destroy:function(){a(document).unbind("mouseup",
|
|
ba).unbind("mousemove",Z);b.unbind("mousedown",W);R=l=b=null}});l.src=d.arrow&&d.arrow.image;l.w=d.arrow&&d.arrow.width||l.width();l.h=d.arrow&&d.arrow.height||l.height();b.w=d.map&&d.map.width||b.width();b.h=d.map&&d.map.height||b.height();b.bind("mousedown",W);da.call(e,function(){var Y=0,V=0,ma=b.w,ua=b.h,ga=l.w,qa=l.h;setTimeout(function(){if(n>0)Y=H==u?ma:H/n*ma|0;if(O>0)V=ea==S?ua:ea/O*ua|0;if(ga>=ma)Y=(ma>>1)-(ga>>1);else Y-=ga>>1;if(qa>=ua)V=(ua>>1)-(qa>>1);else V-=qa>>1;l.css({left:Y+"px",
|
|
top:V+"px"})},0)})},f=function(b,d,e,l){var q=this;b=b.find("td.Text input");var u=b.eq(3),n=b.eq(4),I=b.eq(5),S=b.length>7?b.eq(6):null,O=b.eq(0),H=b.eq(1),ea=b.eq(2),X=b.eq(b.length>7?7:6),Q=b.length>7?b.eq(8):null,R=function(la){if(!(la.target.value==""&&la.target!=X.get(0)&&(e!=null&&la.target!=e.get(0)||e==null))){if(!Z(la))return la;switch(la.target){case u.get(0):switch(la.keyCode){case 38:u.val(ba.call(q,(u.val()<<0)+1,0,255));d.val("r",u.val(),la.target);return false;case 40:u.val(ba.call(q,
|
|
(u.val()<<0)-1,0,255));d.val("r",u.val(),la.target);return false}break;case n.get(0):switch(la.keyCode){case 38:n.val(ba.call(q,(n.val()<<0)+1,0,255));d.val("g",n.val(),la.target);return false;case 40:n.val(ba.call(q,(n.val()<<0)-1,0,255));d.val("g",n.val(),la.target);return false}break;case I.get(0):switch(la.keyCode){case 38:I.val(ba.call(q,(I.val()<<0)+1,0,255));d.val("b",I.val(),la.target);return false;case 40:I.val(ba.call(q,(I.val()<<0)-1,0,255));d.val("b",I.val(),la.target);return false}break;
|
|
case S&&S.get(0):switch(la.keyCode){case 38:S.val(ba.call(q,parseFloat(S.val())+1,0,100));d.val("a",Math.precision(S.val()*255/100,l),la.target);return false;case 40:S.val(ba.call(q,parseFloat(S.val())-1,0,100));d.val("a",Math.precision(S.val()*255/100,l),la.target);return false}break;case O.get(0):switch(la.keyCode){case 38:O.val(ba.call(q,(O.val()<<0)+1,0,360));d.val("h",O.val(),la.target);return false;case 40:O.val(ba.call(q,(O.val()<<0)-1,0,360));d.val("h",O.val(),la.target);return false}break;
|
|
case H.get(0):switch(la.keyCode){case 38:H.val(ba.call(q,(H.val()<<0)+1,0,100));d.val("s",H.val(),la.target);return false;case 40:H.val(ba.call(q,(H.val()<<0)-1,0,100));d.val("s",H.val(),la.target);return false}break;case ea.get(0):switch(la.keyCode){case 38:ea.val(ba.call(q,(ea.val()<<0)+1,0,100));d.val("v",ea.val(),la.target);return false;case 40:ea.val(ba.call(q,(ea.val()<<0)-1,0,100));d.val("v",ea.val(),la.target);return false}}}},ha=function(la){if(!(la.target.value==""&&la.target!=X.get(0)&&
|
|
(e!=null&&la.target!=e.get(0)||e==null))){if(!Z(la))return la;switch(la.target){case u.get(0):u.val(ba.call(q,u.val(),0,255));d.val("r",u.val(),la.target);break;case n.get(0):n.val(ba.call(q,n.val(),0,255));d.val("g",n.val(),la.target);break;case I.get(0):I.val(ba.call(q,I.val(),0,255));d.val("b",I.val(),la.target);break;case S&&S.get(0):S.val(ba.call(q,S.val(),0,100));d.val("a",Math.precision(S.val()*255/100,l),la.target);break;case O.get(0):O.val(ba.call(q,O.val(),0,360));d.val("h",O.val(),la.target);
|
|
break;case H.get(0):H.val(ba.call(q,H.val(),0,100));d.val("s",H.val(),la.target);break;case ea.get(0):ea.val(ba.call(q,ea.val(),0,100));d.val("v",ea.val(),la.target);break;case X.get(0):X.val(X.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));e&&e.val(X.val());d.val("hex",X.val()!=""?X.val():null,la.target);break;case e&&e.get(0):e.val(e.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));X.val(e.val());d.val("hex",e.val()!=""?e.val():null,la.target);break;case Q&&Q.get(0):Q.val(Q.val().replace(/[^a-fA-F0-9]/g,
|
|
"").toLowerCase().substring(0,2));d.val("a",Q.val()!=null?parseInt(Q.val(),16):null,la.target)}}},W=function(la){if(d.val()!=null)switch(la.target){case u.get(0):u.val(d.val("r"));break;case n.get(0):n.val(d.val("g"));break;case I.get(0):I.val(d.val("b"));break;case S&&S.get(0):S.val(Math.precision(d.val("a")*100/255,l));break;case O.get(0):O.val(d.val("h"));break;case H.get(0):H.val(d.val("s"));break;case ea.get(0):ea.val(d.val("v"));break;case X.get(0):case e&&e.get(0):X.val(d.val("hex"));e&&e.val(d.val("hex"));
|
|
break;case Q&&Q.get(0):Q.val(d.val("ahex").substring(6))}},Z=function(la){switch(la.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(la.ctrlKey)return false}return true},ba=function(la,da,Y){if(la==""||isNaN(la))return da;if(la>Y)return Y;if(la<da)return da;return la},ka=function(la,da){var Y=la.val("all");if(da!=u.get(0))u.val(Y!=null?Y.r:"");if(da!=n.get(0))n.val(Y!=null?Y.g:"");if(da!=I.get(0))I.val(Y!=null?Y.b:"");if(S&&da!=S.get(0))S.val(Y!=
|
|
null?Math.precision(Y.a*100/255,l):"");if(da!=O.get(0))O.val(Y!=null?Y.h:"");if(da!=H.get(0))H.val(Y!=null?Y.s:"");if(da!=ea.get(0))ea.val(Y!=null?Y.v:"");if(da!=X.get(0)&&(e&&da!=e.get(0)||!e))X.val(Y!=null?Y.hex:"");if(e&&da!=e.get(0)&&da!=X.get(0))e.val(Y!=null?Y.hex:"");if(Q&&da!=Q.get(0))Q.val(Y!=null?Y.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){u.add(n).add(I).add(S).add(O).add(H).add(ea).add(X).add(e).add(Q).unbind("keyup",ha).unbind("blur",W);u.add(n).add(I).add(S).add(O).add(H).add(ea).unbind("keydown",
|
|
R);d.unbind(ka);Q=X=ea=H=O=S=I=n=u=null}});u.add(n).add(I).add(S).add(O).add(H).add(ea).add(X).add(e).add(Q).bind("keyup",ha).bind("blur",W);u.add(n).add(I).add(S).add(O).add(H).add(ea).bind("keydown",R);d.bind(ka)};a.jPicker={List:[],Color:function(b){var d=this,e,l,q,u,n,I,S,O=[],H=function(X){for(var Q=0;Q<O.length;Q++)O[Q].call(d,d,X)},ea=function(X,Q,R){if(Q===undefined){if(X===undefined||X==null||X=="")X="all";if(e==null)return null;switch(X.toLowerCase()){case "ahex":return p.rgbaToHex({r:e,
|
|
g:l,b:q,a:u});case "hex":return ea("ahex").substring(0,6);case "all":return{r:e,g:l,b:q,a:u,h:n,s:I,v:S,hex:ea.call(d,"hex"),ahex:ea.call(d,"ahex")};default:Q={};for(var ha=0;ha<X.length;ha++)switch(X.charAt(ha)){case "r":if(X.length==1)Q=e;else Q.r=e;break;case "g":if(X.length==1)Q=l;else Q.g=l;break;case "b":if(X.length==1)Q=q;else Q.b=q;break;case "a":if(X.length==1)Q=u;else Q.a=u;break;case "h":if(X.length==1)Q=n;else Q.h=n;break;case "s":if(X.length==1)Q=I;else Q.s=I;break;case "v":if(X.length==
|
|
1)Q=S;else Q.v=S}return Q=={}?ea.call(d,"all"):Q}}if(!(R!=null&&R==d)){var W=false;if(X==null)X="";if(Q==null){if(e!=null){e=null;W=true}if(l!=null){l=null;W=true}if(q!=null){q=null;W=true}if(u!=null){u=null;W=true}if(n!=null){n=null;W=true}if(I!=null){I=null;W=true}if(S!=null){S=null;W=true}W&&H.call(d,R||d)}else switch(X.toLowerCase()){case "ahex":case "hex":Q=p.hexToRgba(Q&&(Q.ahex||Q.hex)||Q||"00000000");ea.call(d,"rgba",{r:Q.r,g:Q.g,b:Q.b,a:X=="ahex"?Q.a:u!=null?u:255},R);break;default:if(Q&&
|
|
(Q.ahex!=null||Q.hex!=null)){ea.call(d,"ahex",Q.ahex||Q.hex||"00000000",R);break}var Z={},ba=false,ka=false;if(Q.r!==undefined&&!X.indexOf("r")==-1)X+="r";if(Q.g!==undefined&&!X.indexOf("g")==-1)X+="g";if(Q.b!==undefined&&!X.indexOf("b")==-1)X+="b";if(Q.a!==undefined&&!X.indexOf("a")==-1)X+="a";if(Q.h!==undefined&&!X.indexOf("h")==-1)X+="h";if(Q.s!==undefined&&!X.indexOf("s")==-1)X+="s";if(Q.v!==undefined&&!X.indexOf("v")==-1)X+="v";for(ha=0;ha<X.length;ha++)switch(X.charAt(ha)){case "r":if(ka)continue;
|
|
ba=true;Z.r=Q&&Q.r&&Q.r|0||Q&&Q|0||0;if(Z.r<0)Z.r=0;else if(Z.r>255)Z.r=255;if(e!=Z.r){e=Z.r;W=true}break;case "g":if(ka)continue;ba=true;Z.g=Q&&Q.g&&Q.g|0||Q&&Q|0||0;if(Z.g<0)Z.g=0;else if(Z.g>255)Z.g=255;if(l!=Z.g){l=Z.g;W=true}break;case "b":if(ka)continue;ba=true;Z.b=Q&&Q.b&&Q.b|0||Q&&Q|0||0;if(Z.b<0)Z.b=0;else if(Z.b>255)Z.b=255;if(q!=Z.b){q=Z.b;W=true}break;case "a":Z.a=Q&&Q.a!=null?Q.a|0:Q!=null?Q|0:255;if(Z.a<0)Z.a=0;else if(Z.a>255)Z.a=255;if(u!=Z.a){u=Z.a;W=true}break;case "h":if(ba)continue;
|
|
ka=true;Z.h=Q&&Q.h&&Q.h|0||Q&&Q|0||0;if(Z.h<0)Z.h=0;else if(Z.h>360)Z.h=360;if(n!=Z.h){n=Z.h;W=true}break;case "s":if(ba)continue;ka=true;Z.s=Q&&Q.s!=null?Q.s|0:Q!=null?Q|0:100;if(Z.s<0)Z.s=0;else if(Z.s>100)Z.s=100;if(I!=Z.s){I=Z.s;W=true}break;case "v":if(ba)continue;ka=true;Z.v=Q&&Q.v!=null?Q.v|0:Q!=null?Q|0:100;if(Z.v<0)Z.v=0;else if(Z.v>100)Z.v=100;if(S!=Z.v){S=Z.v;W=true}}if(W){if(ba){e=e||0;l=l||0;q=q||0;Q=p.rgbToHsv({r:e,g:l,b:q});n=Q.h;I=Q.s;S=Q.v}else if(ka){n=n||0;I=I!=null?I:100;S=S!=
|
|
null?S:100;Q=p.hsvToRgb({h:n,s:I,v:S});e=Q.r;l=Q.g;q=Q.b}u=u!=null?u:255;H.call(d,R||d)}}}};a.extend(true,d,{val:ea,bind:function(X){a.isFunction(X)&&O.push(X)},unbind:function(X){if(a.isFunction(X))for(var Q;(Q=a.inArray(X,O))!=-1;)O.splice(Q,1)},destroy:function(){O=null}});if(b)if(b.ahex!=null)ea("ahex",b);else if(b.hex!=null)ea((b.a!=null?"a":"")+"hex",b.a!=null?{ahex:b.hex+p.intToHex(b.a)}:b);else if(b.r!=null&&b.g!=null&&b.b!=null)ea("rgb"+(b.a!=null?"a":""),b);else if(b.h!=null&&b.s!=null&&
|
|
b.v!=null)ea("hsv"+(b.a!=null?"a":""),b)},ColorMethods:{hexToRgba:function(b){b=this.validateHex(b);if(b=="")return{r:null,g:null,b:null,a:null};var d="00",e="00",l="00",q="255";if(b.length==6)b+="ff";if(b.length>6){d=b.substring(0,2);e=b.substring(2,4);l=b.substring(4,6);q=b.substring(6,b.length)}else{if(b.length>4){d=b.substring(4,b.length);b=b.substring(0,4)}if(b.length>2){e=b.substring(2,b.length);b=b.substring(0,2)}if(b.length>0)l=b.substring(0,b.length)}return{r:this.hexToInt(d),g:this.hexToInt(e),
|
|
b:this.hexToInt(l),a:this.hexToInt(q)}},validateHex:function(b){if(typeof b=="object")return"";b=b.toLowerCase().replace(/[^a-f0-9]/g,"");if(b.length>8)b=b.substring(0,8);return b},rgbaToHex:function(b){return this.intToHex(b.r)+this.intToHex(b.g)+this.intToHex(b.b)+this.intToHex(b.a)},intToHex:function(b){b=(b|0).toString(16);if(b.length==1)b="0"+b;return b.toLowerCase()},hexToInt:function(b){return parseInt(b,16)},rgbToHsv:function(b){var d=b.r/255,e=b.g/255;b=b.b/255;var l={h:0,s:0,v:0},q=0,u=
|
|
0;if(d>=e&&d>=b){u=d;q=e>b?b:e}else if(e>=b&&e>=d){u=e;q=d>b?b:d}else{u=b;q=e>d?d:e}l.v=u;l.s=u?(u-q)/u:0;if(l.s){q=u-q;l.h=d==u?(e-b)/q:e==u?2+(b-d)/q:4+(d-e)/q;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(b){var d={r:0,g:0,b:0,a:100},e=b.h,l=b.s;b=b.v;if(l==0)d.r=b==0?d.g=d.b=0:d.g=d.b=b*255/100|0;else{if(e==360)e=0;e/=60;l/=100;b/=100;var q=e|0,u=e-q;e=b*(1-l);var n=b*(1-l*u);l=b*(1-l*(1-u));switch(q){case 0:d.r=b;d.g=l;d.b=e;break;case 1:d.r=
|
|
n;d.g=b;d.b=e;break;case 2:d.r=e;d.g=b;d.b=l;break;case 3:d.r=e;d.g=n;d.b=b;break;case 4:d.r=l;d.g=e;d.b=b;break;case 5:d.r=b;d.g=e;d.b=n}d.r=d.r*255|0;d.g=d.g*255|0;d.b=d.b*255|0}return d}}};var c=a.jPicker.Color,m=a.jPicker.List,p=a.jPicker.ColorMethods;a.fn.jPicker=function(b){var d=arguments;return this.each(function(){var e=this,l=a.extend(true,{},a.fn.jPicker.defaults,b);if(a(e).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,input:a(e)}});if(a(e).val()==
|
|
""){l.color.active=new c({hex:null});l.color.current=new c({hex:null})}else if(p.validateHex(a(e).val())){l.color.active=new c({hex:a(e).val(),a:l.color.active.val("a")});l.color.current=new c({hex:a(e).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(e).after('<span class="jPicker"><span class="Icon"><span class="Color"> </span><span class="Alpha"> </span><span class="Image" title="Click To Open Color Picker"> </span><span class="Container"> </span></span></span>');
|
|
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,u=null,n=null,I=null,S=null,O=null,H=null,ea=null,X=null,Q=null,R=null,ha=null,W=null,Z=null,ba=null,ka=null,la=null,da=null,Y=null,V=null,ma=null,ua=null,ga=null,qa=null,Ga=null,Ma=null,Ra=null,Qa=null,Va=null,Xa=function(P){var J=va.active,fa=J.val("hex"),Oa,Za;l.color.mode=P;switch(P){case "h":setTimeout(function(){ab.call(e,n,"transparent");Ka.call(e,S,0);Da.call(e,S,100);Ka.call(e,
|
|
O,260);Da.call(e,O,100);ab.call(e,I,"transparent");Ka.call(e,ea,0);Da.call(e,ea,100);Ka.call(e,X,260);Da.call(e,X,100);Ka.call(e,Q,260);Da.call(e,Q,100);Ka.call(e,R,260);Da.call(e,R,100);Ka.call(e,W,260);Da.call(e,W,100)},0);Z.range("all",{minX:0,maxX:100,minY:0,maxY:100});ba.range("rangeY",{minY:0,maxY:360});if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("s"),y:100-J.val("v")},Z);ba.val("y",360-J.val("h"),ba);break;case "s":setTimeout(function(){ab.call(e,n,"transparent");Ka.call(e,S,-260);Ka.call(e,
|
|
O,-520);Ka.call(e,ea,-260);Ka.call(e,X,-520);Ka.call(e,W,260);Da.call(e,W,100)},0);Z.range("all",{minX:0,maxX:360,minY:0,maxY:100});ba.range("rangeY",{minY:0,maxY:100});if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("h"),y:100-J.val("v")},Z);ba.val("y",100-J.val("s"),ba);break;case "v":setTimeout(function(){ab.call(e,n,"000000");Ka.call(e,S,-780);Ka.call(e,O,260);ab.call(e,I,fa);Ka.call(e,ea,-520);Ka.call(e,X,260);Da.call(e,X,100);Ka.call(e,W,260);Da.call(e,W,100)},0);Z.range("all",{minX:0,maxX:360,
|
|
minY:0,maxY:100});ba.range("rangeY",{minY:0,maxY:100});if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("h"),y:100-J.val("s")},Z);ba.val("y",100-J.val("v"),ba);break;case "r":Oa=-1040;Za=-780;Z.range("all",{minX:0,maxX:255,minY:0,maxY:255});ba.range("rangeY",{minY:0,maxY:255});if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("b"),y:255-J.val("g")},Z);ba.val("y",255-J.val("r"),ba);break;case "g":Oa=-1560;Za=-1820;Z.range("all",{minX:0,maxX:255,minY:0,maxY:255});ba.range("rangeY",{minY:0,maxY:255});
|
|
if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("b"),y:255-J.val("r")},Z);ba.val("y",255-J.val("g"),ba);break;case "b":Oa=-2080;Za=-2860;Z.range("all",{minX:0,maxX:255,minY:0,maxY:255});ba.range("rangeY",{minY:0,maxY:255});if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("r"),y:255-J.val("g")},Z);ba.val("y",255-J.val("b"),ba);break;case "a":setTimeout(function(){ab.call(e,n,"transparent");Ka.call(e,S,-260);Ka.call(e,O,-520);Ka.call(e,ea,260);Ka.call(e,X,260);Da.call(e,X,100);Ka.call(e,W,0);Da.call(e,
|
|
W,100)},0);Z.range("all",{minX:0,maxX:360,minY:0,maxY:100});ba.range("rangeY",{minY:0,maxY:255});if(J.val("ahex")==null)break;Z.val("xy",{x:J.val("h"),y:100-J.val("v")},Z);ba.val("y",255-J.val("a"),ba);break;default:throw"Invalid Mode";}switch(P){case "s":case "v":case "a":setTimeout(function(){Da.call(e,S,100);Da.call(e,ea,100);Ka.call(e,Q,260);Da.call(e,Q,100);Ka.call(e,R,260);Da.call(e,R,100)},0);break;case "r":case "g":case "b":setTimeout(function(){ab.call(e,n,"transparent");ab.call(e,I,"transparent");
|
|
Da.call(e,ea,100);Da.call(e,S,100);Ka.call(e,S,Oa);Ka.call(e,O,Oa-260);Ka.call(e,ea,Za-780);Ka.call(e,X,Za-520);Ka.call(e,Q,Za);Ka.call(e,R,Za-260);Ka.call(e,W,260);Da.call(e,W,100)},0)}J.val("ahex")!=null&&Na.call(e,J)},Na=function(P,J){if(J==null||J!=ba&&J!=Z)zb.call(e,P,J);setTimeout(function(){Ja.call(e,P);Jb.call(e,P);tb.call(e,P)},0)},Ha=function(P,J){var fa=va.active;if(!(J!=Z&&fa.val()==null)){var Oa=P.val("all");switch(l.color.mode){case "h":fa.val("sv",{s:Oa.x,v:100-Oa.y},J);break;case "s":case "a":fa.val("hv",
|
|
{h:Oa.x,v:100-Oa.y},J);break;case "v":fa.val("hs",{h:Oa.x,s:100-Oa.y},J);break;case "r":fa.val("gb",{g:255-Oa.y,b:Oa.x},J);break;case "g":fa.val("rb",{r:255-Oa.y,b:Oa.x},J);break;case "b":fa.val("rg",{r:Oa.x,g:255-Oa.y},J)}}},Pa=function(P,J){var fa=va.active;if(!(J!=ba&&fa.val()==null))switch(l.color.mode){case "h":fa.val("h",{h:360-P.val("y")},J);break;case "s":fa.val("s",{s:100-P.val("y")},J);break;case "v":fa.val("v",{v:100-P.val("y")},J);break;case "r":fa.val("r",{r:255-P.val("y")},J);break;
|
|
case "g":fa.val("g",{g:255-P.val("y")},J);break;case "b":fa.val("b",{b:255-P.val("y")},J);break;case "a":fa.val("a",255-P.val("y"),J)}},zb=function(P,J){if(J!=Z)switch(l.color.mode){case "h":var fa=P.val("sv");Z.val("xy",{x:fa!=null?fa.s:100,y:100-(fa!=null?fa.v:100)},J);break;case "s":case "a":fa=P.val("hv");Z.val("xy",{x:fa&&fa.h||0,y:100-(fa!=null?fa.v:100)},J);break;case "v":fa=P.val("hs");Z.val("xy",{x:fa&&fa.h||0,y:100-(fa!=null?fa.s:100)},J);break;case "r":fa=P.val("bg");Z.val("xy",{x:fa&&
|
|
fa.b||0,y:255-(fa&&fa.g||0)},J);break;case "g":fa=P.val("br");Z.val("xy",{x:fa&&fa.b||0,y:255-(fa&&fa.r||0)},J);break;case "b":fa=P.val("rg");Z.val("xy",{x:fa&&fa.r||0,y:255-(fa&&fa.g||0)},J)}if(J!=ba)switch(l.color.mode){case "h":ba.val("y",360-(P.val("h")||0),J);break;case "s":fa=P.val("s");ba.val("y",100-(fa!=null?fa:100),J);break;case "v":fa=P.val("v");ba.val("y",100-(fa!=null?fa:100),J);break;case "r":ba.val("y",255-(P.val("r")||0),J);break;case "g":ba.val("y",255-(P.val("g")||0),J);break;case "b":ba.val("y",
|
|
255-(P.val("b")||0),J);break;case "a":fa=P.val("a");ba.val("y",255-(fa!=null?fa:255),J)}},Ja=function(P){try{var J=P.val("all");ma.css({backgroundColor:J&&"#"+J.hex||"transparent"});Da.call(e,ma,J&&Math.precision(J.a*100/255,4)||0)}catch(fa){}},Jb=function(P){switch(l.color.mode){case "h":ab.call(e,n,(new c({h:P.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var J=P.val("s");Da.call(e,O,100-(J!=null?J:100));break;case "v":J=P.val("v");Da.call(e,S,J!=null?J:100);break;case "r":Da.call(e,
|
|
O,Math.precision((P.val("r")||0)/255*100,4));break;case "g":Da.call(e,O,Math.precision((P.val("g")||0)/255*100,4));break;case "b":Da.call(e,O,Math.precision((P.val("b")||0)/255*100))}P=P.val("a");Da.call(e,H,Math.precision((255-(P||0))*100/255,4))},tb=function(P){switch(l.color.mode){case "h":var J=P.val("a");Da.call(e,ha,Math.precision((255-(J||0))*100/255,4));break;case "s":J=P.val("hva");var fa=new c({h:J&&J.h||0,s:100,v:J!=null?J.v:100});ab.call(e,I,fa.val("hex"));Da.call(e,X,100-(J!=null?J.v:
|
|
100));Da.call(e,ha,Math.precision((255-(J&&J.a||0))*100/255,4));break;case "v":J=P.val("hsa");fa=new c({h:J&&J.h||0,s:J!=null?J.s:100,v:100});ab.call(e,I,fa.val("hex"));Da.call(e,ha,Math.precision((255-(J&&J.a||0))*100/255,4));break;case "r":case "g":case "b":fa=J=0;P=P.val("rgba");if(l.color.mode=="r"){J=P&&P.b||0;fa=P&&P.g||0}else if(l.color.mode=="g"){J=P&&P.b||0;fa=P&&P.r||0}else if(l.color.mode=="b"){J=P&&P.r||0;fa=P&&P.g||0}var Oa=fa>J?J:fa;Da.call(e,X,J>fa?Math.precision((J-fa)/(255-fa)*100,
|
|
4):0);Da.call(e,Q,fa>J?Math.precision((fa-J)/(255-J)*100,4):0);Da.call(e,R,Math.precision(Oa/255*100,4));Da.call(e,ha,Math.precision((255-(P&&P.a||0))*100/255,4));break;case "a":J=P.val("a");ab.call(e,I,P.val("hex")||"000000");Da.call(e,ha,J!=null?0:100);Da.call(e,W,J!=null?100:0)}},ab=function(P,J){P.css({backgroundColor:J&&J.length==6&&"#"+J||"transparent"})},$a=function(P,J){if(q&&(J.indexOf("AlphaBar.png")!=-1||J.indexOf("Bars.png")!=-1||J.indexOf("Maps.png")!=-1)){P.attr("pngSrc",J);P.css({backgroundImage:"none",
|
|
filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+J+"', sizingMethod='scale')"})}else P.css({backgroundImage:"url('"+J+"')"})},Ka=function(P,J){P.css({top:J+"px"})},Da=function(P,J){P.css({visibility:J>0?"visible":"hidden"});if(J>0&&J<100)if(q){var fa=P.attr("pngSrc");fa!=null&&(fa.indexOf("AlphaBar.png")!=-1||fa.indexOf("Bars.png")!=-1||fa.indexOf("Maps.png")!=-1)?P.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+fa+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+
|
|
J+")"}):P.css({opacity:Math.precision(J/100,4)})}else P.css({opacity:Math.precision(J/100,4)});else if(J==0||J==100)if(q){fa=P.attr("pngSrc");fa!=null&&(fa.indexOf("AlphaBar.png")!=-1||fa.indexOf("Bars.png")!=-1||fa.indexOf("Maps.png")!=-1)?P.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+fa+"', sizingMethod='scale')"}):P.css({opacity:""})}else P.css({opacity:""})},yb=function(){va.active.val("ahex",va.current.val("ahex"))},bb=function(){va.current.val("ahex",va.active.val("ahex"))},
|
|
Sa=function(P){a(this).parents("tbody:first").find('input:radio[value!="'+P.target.value+'"]').removeAttr("checked");Xa.call(e,P.target.value)},gb=function(){yb.call(e)},Ia=function(){yb.call(e);l.window.expandable&&Kb.call(e);a.isFunction(Gb)&&Gb.call(e,va.active,qa)},rb=function(){bb.call(e);l.window.expandable&&Kb.call(e);a.isFunction(Fb)&&Fb.call(e,va.active,ga)},sb=function(){Ob.call(e)},mb=function(P){var J=P.val("hex");ua.css({backgroundColor:J&&"#"+J||"transparent"});Da.call(e,ua,Math.precision((P.val("a")||
|
|
0)*100/255,4))},hb=function(P){var J=P.val("hex");P=P.val("va");Ma.css({backgroundColor:J&&"#"+J||"transparent"});Da.call(e,Ra,Math.precision((255-(P&&P.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:J&&"#"+J||"transparent",color:P==null||P.v>75?"#000000":"#ffffff"})},La=function(P){la=parseInt(u.css("left"));da=parseInt(u.css("top"));Y=P.pageX;V=P.pageY;a(document).bind("mousemove",Wa).bind("mouseup",jb);P.preventDefault()},Wa=function(P){u.css({left:la-
|
|
(Y-P.pageX)+"px",top:da-(V-P.pageY)+"px"});l.window.expandable&&!a.support.boxModel&&u.prev().css({left:u.css("left"),top:u.css("top")});P.stopPropagation();P.preventDefault();return false},jb=function(P){a(document).unbind("mousemove",Wa).unbind("mouseup",jb);P.stopPropagation();P.preventDefault();return false},Eb=function(P){P.preventDefault();P.stopPropagation();va.active.val("ahex",a(this).attr("title")||null,P.target);return false},Fb=a.isFunction(d[1])&&d[1]||null,nb=a.isFunction(d[2])&&d[2]||
|
|
null,Gb=a.isFunction(d[3])&&d[3]||null,Ob=function(){va.current.val("ahex",va.active.val("ahex"));var P=function(){if(!(!l.window.expandable||a.support.boxModel)){var J=u.find("table:first");u.before("<iframe/>");u.prev().css({width:J.width(),height:u.height(),opacity:0,position:"absolute",left:u.css("left"),top:u.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});u.css({zIndex:20})}switch(l.window.effects.type){case "fade":u.fadeIn(l.window.effects.speed.show,
|
|
P);break;case "slide":u.slideDown(l.window.effects.speed.show,P);break;default:u.show(l.window.effects.speed.show,P)}},Kb=function(){var P=function(){l.window.expandable&&u.css({zIndex:10});!l.window.expandable||a.support.boxModel||u.prev().remove()};switch(l.window.effects.type){case "fade":u.fadeOut(l.window.effects.speed.hide,P);break;case "slide":u.slideUp(l.window.effects.speed.hide,P);break;default:u.hide(l.window.effects.speed.hide,P)}},Ub=function(){var P=l.window,J=P.expandable?a(e).next().find(".Container:first"):
|
|
null;u=P.expandable?a("<div/>"):a(e);u.addClass("jPicker Container");P.expandable&&u.hide();u.get(0).onselectstart=function(Pb){if(Pb.target.nodeName.toLowerCase()!=="input")return false};var fa=va.active.val("all");if(P.alphaPrecision<0)P.alphaPrecision=0;else if(P.alphaPrecision>2)P.alphaPrecision=2;var Oa='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(P.expandable?'<tr><td class="Move" colspan="5"> </td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(P.title||ia.text.title)+
|
|
'</h2><div class="Map"><span class="Map1"> </span><span class="Map2"> </span><span class="Map3"> </span><img src="'+ra.clientPath+ra.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="'+ra.clientPath+ra.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+
|
|
ia.text.newColor+'<div class="color_preview"><span class="Active" title="'+ia.tooltips.colors.newColor+'"> </span><span class="Current" title="'+ia.tooltips.colors.currentColor+'"> </span></div></div>'+ia.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+ia.text.ok+'" title="'+ia.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+ia.text.cancel+'" title="'+ia.tooltips.buttons.cancel+'"/><div class="Grid"> </div></td></tr><tr class="Hue"><td class="Radio"><label title="'+
|
|
ia.tooltips.hue.radio+'"><input type="radio" value="h"'+(l.color.mode=="h"?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(fa!=null?fa.h:"")+'" title="'+ia.tooltips.hue.textbox+'"/> \u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+ia.tooltips.saturation.radio+'"><input type="radio" value="s"'+(l.color.mode=="s"?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(fa!=
|
|
null?fa.s:"")+'" title="'+ia.tooltips.saturation.textbox+'"/> %</td></tr><tr class="Value"><td class="Radio"><label title="'+ia.tooltips.value.radio+'"><input type="radio" value="v"'+(l.color.mode=="v"?' checked="checked"':"")+'/>V:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(fa!=null?fa.v:"")+'" title="'+ia.tooltips.value.textbox+'"/> %<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="'+ia.tooltips.red.radio+'"><input type="radio" value="r"'+
|
|
(l.color.mode=="r"?' checked="checked"':"")+'/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(fa!=null?fa.r:"")+'" title="'+ia.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+ia.tooltips.green.radio+'"><input type="radio" value="g"'+(l.color.mode=="g"?' checked="checked"':"")+'/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(fa!=null?fa.g:"")+'" title="'+ia.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+
|
|
ia.tooltips.blue.radio+'"><input type="radio" value="b"'+(l.color.mode=="b"?' checked="checked"':"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(fa!=null?fa.b:"")+'" title="'+ia.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(P.alphaSupport?'<label title="'+ia.tooltips.alpha.radio+'"><input type="radio" value="a"'+(l.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":" ")+'</td><td class="Text">'+(P.alphaSupport?'<input type="text" maxlength="'+
|
|
(3+P.alphaPrecision)+'" value="'+(fa!=null?Math.precision(fa.a*100/255,P.alphaPrecision):"")+'" title="'+ia.tooltips.alpha.textbox+'"/> %':" ")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ia.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(fa!=null?fa.hex:"")+'"/></label>'+(P.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(fa!=null?fa.ahex.substring(6):"")+'" title="'+ia.tooltips.hex.alpha+'"/></td>':" ")+
|
|
"</tr></tbody></table>";if(P.expandable){u.html(Oa);a(document.body).children("div.jPicker.Container").length==0?a(document.body).prepend(u):a(document.body).children("div.jPicker.Container:last").after(u);u.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});u.css({zIndex:20})});u.css({left:P.position.x=="left"?J.offset().left-530-(P.position.y=="center"?25:0)+"px":P.position.x=="center"?J.offset().left-260+"px":P.position.x=="right"?J.offset().left-10+(P.position.y==
|
|
"center"?25:0)+"px":P.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":J.offset().left+parseInt(P.position.x)+"px",position:"absolute",top:P.position.y=="top"?J.offset().top-312+"px":P.position.y=="center"?J.offset().top-156+"px":P.position.y=="bottom"?J.offset().top+25+"px":J.offset().top+parseInt(P.position.y)+"px"})}else{u=a(e);u.html(Oa)}Oa=u.find("tbody:first");n=Oa.find("div.Map:first");I=Oa.find("div.Bar:first");var Za=n.find("span"),fb=I.find("span");S=Za.filter(".Map1:first");
|
|
O=Za.filter(".Map2:first");H=Za.filter(".Map3:first");ea=fb.filter(".Map1:first");X=fb.filter(".Map2:first");Q=fb.filter(".Map3:first");R=fb.filter(".Map4:first");ha=fb.filter(".Map5:first");W=fb.filter(".Map6:first");Z=new o(n,{map:{width:ra.colorMap.width,height:ra.colorMap.height},arrow:{image:ra.clientPath+ra.colorMap.arrow.file,width:ra.colorMap.arrow.width,height:ra.colorMap.arrow.height}});Z.bind(Ha);ba=new o(I,{map:{width:ra.colorBar.width,height:ra.colorBar.height},arrow:{image:ra.clientPath+
|
|
ra.colorBar.arrow.file,width:ra.colorBar.arrow.width,height:ra.colorBar.arrow.height}});ba.bind(Pa);ka=new f(Oa,va.active,P.expandable&&P.bindToInput?P.input:null,P.alphaPrecision);Za=fa!=null?fa.hex:null;var wb=Oa.find(".Preview");fb=Oa.find(".Button");ma=wb.find(".Active:first").css({backgroundColor:Za&&"#"+Za||"transparent"});ua=wb.find(".Current:first").css({backgroundColor:Za&&"#"+Za||"transparent"}).bind("click",gb);Da.call(e,ua,Math.precision(va.current.val("a")*100)/255,4);ga=fb.find(".Ok:first").bind("click",
|
|
rb);qa=fb.find(".Cancel:first").bind("click",Ia);Ga=fb.find(".Grid:first");setTimeout(function(){$a.call(e,S,ra.clientPath+"Maps.png");$a.call(e,O,ra.clientPath+"Maps.png");$a.call(e,H,ra.clientPath+"map-opacity.png");$a.call(e,ea,ra.clientPath+"Bars.png");$a.call(e,X,ra.clientPath+"Bars.png");$a.call(e,Q,ra.clientPath+"Bars.png");$a.call(e,R,ra.clientPath+"Bars.png");$a.call(e,ha,ra.clientPath+"bar-opacity.png");$a.call(e,W,ra.clientPath+"AlphaBar.png");$a.call(e,wb.find("div:last"),ra.clientPath+
|
|
"preview-opacity.png")},0);Oa.find("td.Radio input").bind("click",Sa);if(va.quickList&&va.quickList.length>0){fb="";for(i=0;i<va.quickList.length;i++){if((typeof va.quickList[i]).toString().toLowerCase()=="string")va.quickList[i]=new c({hex:va.quickList[i]});var xb=va.quickList[i].val("a"),Db=va.quickList[i].val("ahex");if(!P.alphaSupport&&Db)Db=Db.substring(0,6)+"ff";var pb=va.quickList[i].val("hex");fb+='<span class="QuickColor"'+(Db&&' title="#'+Db+'"'||"")+' style="background-color:'+(pb&&"#"+
|
|
pb||"")+";"+(pb?"":"background-image:url("+ra.clientPath+"NoColor.png)")+(P.alphaSupport&&xb&&xb<255?";opacity:"+Math.precision(xb/255,4)+";filter:Alpha(opacity="+Math.precision(xb/2.55,4)+")":"")+'"> </span>'}$a.call(e,Ga,ra.clientPath+"bar-opacity.png");Ga.html(fb);Ga.find(".QuickColor").click(Eb)}Xa.call(e,l.color.mode);va.active.bind(Na);a.isFunction(nb)&&va.active.bind(nb);va.current.bind(mb);if(P.expandable){e.icon=J.parents(".Icon:first");Ma=e.icon.find(".Color:first").css({backgroundColor:Za&&
|
|
"#"+Za||"transparent"});Ra=e.icon.find(".Alpha:first");$a.call(e,Ra,ra.clientPath+"bar-opacity.png");Da.call(e,Ra,Math.precision((255-(fa!=null?fa.a:0))*100/255,4));Qa=e.icon.find(".Image:first").css({backgroundImage:"url('"+ra.clientPath+ra.picker.file+"')"}).bind("click",sb);if(P.bindToInput&&P.updateInputColor)P.input.css({backgroundColor:Za&&"#"+Za||"transparent",color:fa==null||fa.v>75?"#000000":"#ffffff"});Va=Oa.find(".Move:first").bind("mousedown",La);va.active.bind(hb)}else Ob.call(e)},ra=
|
|
l.images,ia=l.localization,va={active:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):
|
|
new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),quickList:l.color.quickList};a.extend(true,e,{commitCallback:Fb,liveCallback:nb,cancelCallback:Gb,color:va,show:Ob,hide:Kb,destroy:function(){u.find("td.Radio input").unbind("click",Sa);ua.unbind("click",gb);qa.unbind("click",Ia);ga.unbind("click",rb);if(l.window.expandable){Qa.unbind("click",sb);Va.unbind("mousedown",La);e.icon=null}u.find(".QuickColor").unbind("click",
|
|
Eb);W=ha=R=Q=X=ea=H=O=S=I=n=null;Z.destroy();Z=null;ba.destroy();ba=null;ka.destroy();nb=Gb=Fb=Ga=qa=ga=ua=ma=ka=null;u.html("");for(i=0;i<m.length;i++)m[i]==e&&m.splice(i,1)}});m.push(e);setTimeout(function(){Ub.call(e)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new c({ahex:"#ffcc00ff"}),
|
|
quickList:[new c({h:360,s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),new c({h:360,s:100,v:75}),new c({h:360,s:100,v:50}),new c({h:180,s:0,v:100}),new c({h:30,s:33,v:100}),new c({h:30,s:66,v:100}),new c({h:30,s:100,v:100}),new c({h:30,s:100,v:75}),new c({h:30,s:100,v:50}),new c({h:180,s:0,v:90}),new c({h:60,s:33,v:100}),new c({h:60,s:66,v:100}),new c({h:60,s:100,v:100}),new c({h:60,s:100,v:75}),new c({h:60,s:100,v:50}),new c({h:180,s:0,v:80}),new c({h:90,s:33,v:100}),new c({h:90,
|
|
s:66,v:100}),new c({h:90,s:100,v:100}),new c({h:90,s:100,v:75}),new c({h:90,s:100,v:50}),new c({h:180,s:0,v:70}),new c({h:120,s:33,v:100}),new c({h:120,s:66,v:100}),new c({h:120,s:100,v:100}),new c({h:120,s:100,v:75}),new c({h:120,s:100,v:50}),new c({h:180,s:0,v:60}),new c({h:150,s:33,v:100}),new c({h:150,s:66,v:100}),new c({h:150,s:100,v:100}),new c({h:150,s:100,v:75}),new c({h:150,s:100,v:50}),new c({h:180,s:0,v:50}),new c({h:180,s:33,v:100}),new c({h:180,s:66,v:100}),new c({h:180,s:100,v:100}),
|
|
new c({h:180,s:100,v:75}),new c({h:180,s:100,v:50}),new c({h:180,s:0,v:40}),new c({h:210,s:33,v:100}),new c({h:210,s:66,v:100}),new c({h:210,s:100,v:100}),new c({h:210,s:100,v:75}),new c({h:210,s:100,v:50}),new c({h:180,s:0,v:30}),new c({h:240,s:33,v:100}),new c({h:240,s:66,v:100}),new c({h:240,s:100,v:100}),new c({h:240,s:100,v:75}),new c({h:240,s:100,v:50}),new c({h:180,s:0,v:20}),new c({h:270,s:33,v:100}),new c({h:270,s:66,v:100}),new c({h:270,s:100,v:100}),new c({h:270,s:100,v:75}),new c({h:270,
|
|
s:100,v:50}),new c({h:180,s:0,v:10}),new c({h:300,s:33,v:100}),new c({h:300,s:66,v:100}),new c({h:300,s:100,v:100}),new c({h:300,s:100,v:75}),new c({h:300,s:100,v:50}),new c({h:180,s:0,v:0}),new c({h:330,s:33,v:100}),new c({h:330,s:66,v:100}),new c({h:330,s:100,v:100}),new c({h:330,s:100,v:75}),new c({h:330,s:100,v:50}),new c]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",
|
|
width:20,height:7}},picker:{file:"picker.gif",width:25,height:24}},localization:{text:{title:"Drag Markers To Pick A Color",newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press “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 o(m){var p=m||window.event,b=[].slice.call(arguments,1),d=0,e=0,l=0;m=a.event.fix(p);m.type="mousewheel";if(p.wheelDelta)d=p.wheelDelta/120;if(p.detail)d=-p.detail/3;l=d;if(p.axis!==undefined&&p.axis===p.HORIZONTAL_AXIS){l=0;e=-1*d}if(p.wheelDeltaY!==undefined)l=p.wheelDeltaY/120;if(p.wheelDeltaX!==undefined)e=-1*p.wheelDeltaX/120;b.unshift(m,d,e,l);return(a.event.dispatch||a.event.handle).apply(this,b)}var f=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=f.length;c;)a.event.fixHooks[f[--c]]=
|
|
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var m=f.length;m;)this.addEventListener(f[--m],o,false);else this.onmousewheel=o},teardown:function(){if(this.removeEventListener)for(var m=f.length;m;)this.removeEventListener(f[--m],o,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(m){return m?this.bind("mousewheel",m):this.trigger("mousewheel")},unmousewheel:function(m){return this.unbind("mousewheel",m)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){function o(b){if(f.getMode()!="eyedropper"){var d=$("#tool_eyedropper");b.elems[0]&&$.inArray(b.elems[0].nodeName,["svg","g","use"])==-1?d.removeClass("disabled"):d.addClass("disabled")}}var f=svgEditor.canvas,c=svgedit.history.ChangeElementCommand,m={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},p=function(b,d,e){var l=null;console.log(b);if(b.indexOf("url(#")===
|
|
0){b=(b=f.getRefElem(b))?b.cloneNode(true):$("#"+e+"_color defs *")[0];l={alpha:d};l[b.tagName]=b}else l=b.indexOf("#")===0?{alpha:d,solidColor:b.substr(1)}:{alpha:d,solidColor:"none"};return new $.jGraduate.Paint(l)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",key:"I","class":"disabled",events:{click:function(){f.setMode("eyedropper")}}}],selectedChanged:o,elementChanged:o,mouseDown:function(b){var d=f.getMode(),
|
|
e=b.event;e=e.target.id==="svgroot"?document.getElementById("canvas_background"):e.target;if(d=="eyedropper"&&e){m.fillPaint=e.getAttribute("fill")||"white";m.fillOpacity=e.getAttribute("fill-opacity")||1;m.strokePaint=e.getAttribute("stroke")||"none";m.strokeOpacity=e.getAttribute("stroke-opacity")||1;m.strokeWidth=e.getAttribute("stroke-width");m.strokeDashArray=e.getAttribute("stroke-dasharray");m.strokeLinecap=e.getAttribute("stroke-linecap");m.strokeLinejoin=e.getAttribute("stroke-linejoin");
|
|
m.opacity=e.getAttribute("opacity")||1;if($.inArray(b.selectedElements.nodeName,["g","use"])==-1){var l={},q=function(n,I,S){l[I]=n.getAttribute(I);n.setAttribute(I,S)},u=new a.BatchCommand;b.selectedElements.forEach(function(n){m.fillPaint&&q(n,"fill",m.fillPaint);m.fillOpacity&&q(n,"fill-opacity",m.fillOpacity);m.strokePaint&&q(n,"stroke",m.strokePaint);m.strokeOpacity&&q(n,"stroke-opacity",m.strokeOpacity);m.strokeWidth&&q(n,"stroke-width",m.strokeWidth);m.strokeDashArray&&q(n,"stroke-dasharray",
|
|
m.strokeDashArray);m.opacity&&q(n,"opacity",m.opacity);m.strokeLinecap&&q(n,"stroke-linecap",m.strokeLinecap);m.strokeLinejoin&&q(n,"stroke-linejoin",m.strokeLinejoin);u.addSubCommand(new c(n,l));console.log(l);l={}});p(m.fillPaint,m.fillOpacity*100,"fill");p(m.strokePaint,m.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);f.undoMgr.addCommandToHistory(u)}}}}});svgEditor.addExtension("Markers",function(a){function o(R,ha){var W=R.getAttribute(ha);if(!W)return null;W=W.match(/\(\#(.*)\)/);if(!W||W.length!==2)return null;return a.getElem(W[1])}function f(R){$("#marker_panel").toggle(R);$("#marker_panel_title").length<1&&$("#marker_panel").prepend("<h4 id='marker_panel_title'>Arrows</h4>");if(R){var ha=S[0],W,Z;$.each(O,function(ba,ka){var la=o(ha,"marker-"+ka),da=$("#"+ka+"_marker");if(la){if(!la.attributes.se_type)return;Z=W="\\"+la.attributes.se_type.textContent;
|
|
if(W=="\\textmarker")W=la.lastChild.textContent;else da.hide()}else{Z=W="\\nomarker";da.hide()}da.val(W);l(ka,Z)})}}function c(R,ha){var W=a.getElem(R);if(!W)if(!(ha==""||ha=="\\nomarker")){var Z=S[0].getAttribute("stroke"),ba=50,ka=50,la="0 0 100 100",da=5,Y=5;se_type=ha.substr(0,1)=="\\"?ha.substr(1):"textmarker";if(X[se_type]){W=I({element:"marker",attr:{id:R,markerUnits:"strokeWidth",orient:"auto",style:"pointer-events:none",se_type:se_type}});if(se_type!="textmarker"){var V=I(X[se_type]),ma=
|
|
Z;if(se_type.substr(-2)=="_o")ma="none";V.setAttribute("fill",ma);V.setAttribute("stroke",Z);V.setAttribute("stroke-width",10);W.appendChild(V)}else{V=I(X[se_type]);V.textContent=ha;ma=V.getBBox();ma.x=0;ma.y=0;ma.width+=2;ma.height+=2;V.setAttribute("x",1);V.setAttribute("y",ma.height-1-ma.height/4);V.setAttribute("fill",Z);ba=ma.width/2+1;ka=ma.height/2+1;la=ma.x+" "+ma.y+" "+ma.width+" "+ma.height;da=ma.width/10;Y=ma.height/10;Z=I({element:"rect",attr:{x:ma.x,y:ma.y,width:ma.width,height:ma.height,
|
|
fill:"#ffffff",stroke:"none","stroke-width":0}});W.setAttribute("orient",0);W.appendChild(Z);W.appendChild(V)}W.setAttribute("viewBox",la);W.setAttribute("markerWidth",da);W.setAttribute("markerHeight",Y);W.setAttribute("refX",ba);W.setAttribute("refY",ka);a.findDefs().appendChild(W);return W}}}function m(){var R={start_marker:"start",mid_marker:"mid",end_marker:"end"}[this.id],ha="marker-"+R,W=this.value,Z=S[0],ba=o(Z,ha);ba&&$(ba).remove();Z.removeAttribute(ha);if(W=="")W="\\nomarker";if(W=="\\nomarker"){l(R,
|
|
W);a.call("changed",S)}else{ba=H+R+"_"+Z.id;c(ba,W);svgCanvas.changeSelectedAttribute(ha,"url(#"+ba+")");Z.tagName=="line"&&R=="mid"&&p(Z);a.call("changed",S);l(R,W)}}function p(R){if(R.tagName!="line")return R;var ha=R.getAttribute("x1")-0,W=R.getAttribute("x2")-0,Z=R.getAttribute("y1")-0,ba=R.getAttribute("y2")-0,ka=R.id,la=I({element:"polyline",attr:{points:ha+","+Z+(" "+(ha+W)/2+","+(Z+ba)/2+" ")+W+","+ba,stroke:R.getAttribute("stroke"),"stroke-width":R.getAttribute("stroke-width"),fill:"none",
|
|
opacity:R.getAttribute("opacity")||1}});$.each(O,function(da,Y){var V="marker-"+Y;R.getAttribute(V)&&la.setAttribute(V,R.getAttribute(V))});ha=new a.BatchCommand;ha.addSubCommand(new a.RemoveElementCommand(R,R.parentNode));ha.addSubCommand(new a.InsertElementCommand(la));$(R).after(la).remove();svgCanvas.clearSelection();la.id=ka;svgCanvas.addToSelection([la]);a.addCommandToHistory(ha);return la}function b(R){var ha=R.getAttribute("stroke");$.each(O,function(W,Z){var ba=o(R,"marker-"+Z);if(ba)if(ba.attributes.se_type)if(ba=
|
|
ba.lastElementChild){var ka=ba.getAttribute("fill"),la=ba.getAttribute("stroke");ka&&ka!="none"&&ba.setAttribute("fill",ha);la&&la!="none"&&ba.setAttribute("stroke",ha)}})}function d(R){$.each(O,function(ha,W){var Z=H+W+"_"+R.id,ba="marker-"+W,ka=o(R,ba);if(ka&&ka.attributes.se_type)if(ka=R.getAttribute(ba)){var la=R.id.length;ka=ka.substr(-la-1,la);if(R.id!=ka){ka=$("#"+W+"_marker").attr("value");c(Z,ka);svgCanvas.changeSelectedAttribute(ba,"url(#"+Z+")");if(R.tagName=="line"&&W=="mid")R=p(R);a.call("changed",
|
|
S)}}})}function e(R,ha){$("#"+R+"_marker").val(ha);$("#"+R+"_marker").change();$("#"+R+"_marker")}function l(R,ha){if(ha.substr(0,1)!="\\")ha="\\textmarker";var W="#"+ea+R+"_"+ha.substr(1);svgEditor.setIcon("#cur_"+R+"_marker_list",$(W).children());$(W).addClass("current").siblings().removeClass("current")}function q(R){var ha=$("#"+R+"_marker").val();if(ha.substr(0,1)=="\\")ha="";$.prompt("Enter text for "+R+" marker",ha,function(W){W&&e(R,W)})}function u(){var R=this.id.split("_"),ha=R[1],W=R[2];
|
|
if(R[3])W+="_"+R[3];W!="textmarker"?e(ha,"\\"+W):q(ha)}function n(R,ha){var W=Q[R],Z;for(Z in W)if(W[Z].id==ha)return W[Z].title;return ha}var I=a.addSvgElementFromJson,S,O=["start","mid","end"],H="se_marker_",ea="mkr_",X={nomarker:{},leftarrow:{element:"path",attr:{d:"M0,50 L100,90 L70,50 L100,10 Z"}},rightarrow:{element:"path",attr:{d:"M100,50 L0,90 L30,50 L0,10 Z"}},textmarker:{element:"text",attr:{x:0,y:0,"stroke-width":0,stroke:"none","font-size":75,"font-family":"serif","text-anchor":"left",
|
|
"xml:space":"preserve"}},forwardslash:{element:"path",attr:{d:"M30,100 L70,0"}},reverseslash:{element:"path",attr:{d:"M30,0 L70,100"}},verticalslash:{element:"path",attr:{d:"M50,0 L50,100"}},box:{element:"path",attr:{d:"M20,20 L20,80 L80,80 L80,20 Z"}},star:{element:"path",attr:{d:"M10,30 L90,30 L20,90 L50,10 L80,90 Z"}},xmark:{element:"path",attr:{d:"M20,80 L80,20 M80,80 L20,20"}},triangle:{element:"path",attr:{d:"M10,80 L50,20 L80,80 Z"}},mcircle:{element:"circle",attr:{r:30,cx:50,cy:50}}},Q={en:[{id:"start_marker_list",
|
|
title:"Select start marker type"},{id:"mid_marker_list",title:"Select mid marker type"},{id:"end_marker_list",title:"Select end marker type"},{id:"nomarker",title:"No Marker"},{id:"leftarrow",title:"Left Arrow"},{id:"rightarrow",title:"Right Arrow"},{id:"textmarker",title:"Text Marker"},{id:"forwardslash",title:"Forward Slash"},{id:"reverseslash",title:"Reverse Slash"},{id:"verticalslash",title:"Vertical Slash"},{id:"box",title:"Box"},{id:"star",title:"Star"},{id:"xmark",title:"X"},{id:"triangle",
|
|
title:"Triangle"},{id:"mcircle",title:"Circle"},{id:"leftarrow_o",title:"Open Left Arrow"},{id:"rightarrow_o",title:"Open Right Arrow"},{id:"box_o",title:"Open Box"},{id:"star_o",title:"Open Star"},{id:"triangle_o",title:"Open Triangle"},{id:"mcircle_o",title:"Open Circle"}]};$.each(["leftarrow","rightarrow","box","star","mcircle","triangle"],function(R,ha){X[ha+"_o"]=X[ha]});return{name:"Markers",svgicons:"extensions/markers-icons.xml",buttons:function(){var R=[];$.each(O,function(ha,W){var Z=W+
|
|
"_marker_list",ba=true;$.each(X,function(ka){var la=n("en",ka);R.push({id:ea+W+"_"+ka,svgicon:ka,title:la,type:"context",events:{click:u},panel:"marker_panel",list:Z,isDefault:ba});ba=false})});return R}(),context_tools:[{type:"input",panel:"marker_panel",title:"Start marker",id:"start_marker",label:"Start",size:3,events:{change:m}},{type:"button-select",panel:"marker_panel",title:n("en","start_marker_list"),id:"start_marker_list",colnum:3,events:{change:u}},{type:"input",panel:"marker_panel",title:"Middle marker",
|
|
id:"mid_marker",label:"Middle",defval:"",size:3,events:{change:m}},{type:"button-select",panel:"marker_panel",title:n("en","mid_marker_list"),id:"mid_marker_list",colnum:3,events:{change:u}},{type:"input",panel:"marker_panel",title:"End marker",id:"end_marker",label:"End",size:3,events:{change:m}},{type:"button-select",panel:"marker_panel",title:n("en","end_marker_list"),id:"end_marker_list",colnum:3,events:{change:u}}],callback:function(){$("#marker_panel").addClass("toolset").hide()},addLangData:function(R){return{data:Q[R]}},
|
|
selectedChanged:function(R){S=R.elems;for(var ha=S.length,W=["line","path","polyline","polygon"];ha--;){var Z=S[ha];if(Z&&$.inArray(Z.tagName,W)!=-1)R.selectedElement&&!R.multiselected?f(true):f(false);else f(false)}},elementChanged:function(R){if((R=R.elems[0])&&(R.getAttribute("marker-start")||R.getAttribute("marker-mid")||R.getAttribute("marker-end"))){b(R);d(R)}changing_flag=false}}});svgEditor.addExtension("view_grid",function(a){function o(e){b.attr("width");b.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],q=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var u=m;l=l*e;var n=100/l,I=1;for(e=0;e<q.length;e++){var S=q[e];I=S;if(n<=S)break}q=I*l;u.width=q;u.height=q;l=u.getContext("2d");n=q/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(e=1;e<10;e++){I=Math.round(n*e)+0.5;l.moveTo(I,q);l.lineTo(I,0);l.moveTo(q,I);l.lineTo(0,I)}l.stroke();
|
|
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,q);l.lineTo(0.5,0);l.moveTo(q,0.5);l.lineTo(0,0.5);l.stroke();u=u.toDataURL("image/png");d.setAttribute("width",q);d.setAttribute("height",q);d.parentNode.setAttribute("width",q);d.parentNode.setAttribute("height",q);svgCanvas.setHref(d,u)}if(!document.getElementById("canvasGrid")){var f=document.getElementById("svgcanvas").ownerDocument,c=false;a=a.assignAttributes;var m=document.createElement("canvas");$(m).hide().appendTo("body");var p=f.createElementNS("http://www.w3.org/2000/svg",
|
|
"g");a(p,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var b=$("#canvas_background");b.after(p);p=f.createElementNS("http://www.w3.org/2000/svg","pattern");a(p,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var d=f.createElementNS("http://www.w3.org/2000/svg","image");a(d,{x:0,y:0,width:100,height:100});p.appendChild(d);$("#svgroot defs").append(p);f=f.createElementNS("http://www.w3.org/2000/svg","rect");a(f,{width:"100%",height:"100%",
|
|
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(f)}return{name:"view_grid",zoomChanged:function(e){c&&o(e)},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=c=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
|
|
c=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");o(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("imagelib",function(){function a(){$("#imgbrowse_holder").hide()}function o(u){var n=svgCanvas.addSvgElementFromJson({element:"image",attr:{x:0,y:0,width:0,height:0,id:svgCanvas.getNextId(),style:"pointer-events:inherit"}});svgCanvas.clearSelection();svgCanvas.addToSelection([n]);svgCanvas.setImageURL(u)}function f(u){$("#lib_framewrap, #imglib_opts").css({right:u?200:10});if(!l){l=$("<div id=imglib_preview>").css({position:"absolute",top:45,right:10,width:180,bottom:45,background:"#fff",
|
|
overflow:"auto"}).insertAfter("#lib_framewrap");q=$("<button disabled>Import selected</button>").appendTo("#imgbrowse").click(function(){$.each(b,function(n){var I=this[1];this[0]=="svg"?svgCanvas.importSvgString(I):o(I);svgCanvas.moveSelectedElements(n*20,n*20,false)});l.empty();b=[];$("#imgbrowse_holder").hide()}).css({position:"absolute",bottom:10,right:-10})}l.toggle(u);q.toggle(u)}var c=svgEditor.uiStrings;$.extend(c,{imagelib:{select_lib:"Select an image library",show_list:"Show library list",
|
|
import_single:"Import single",import_multi:"Import multiple",open:"Open as new document"}});var m=[{name:"Demo library (local)",url:"extensions/imagelib/index.html",description:"Demonstration library for SVG-edit on this server"},{name:"IAN Symbol Libraries",url:"http://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php",description:"Free library of illustrations"}],p="s",b=[],d=false,e={};window.addEventListener("message",function(u){var n=u.data;if(n){u=n.charAt(0);var I,S;if(u!="{"&&d)d=false;
|
|
else{if(u=="|"){u=n.indexOf("|",1);var O=n.substr(1,u-1);n=n.substr(u+1);u=n.charAt(0)}$("#dialog_box").hide();switch(u){case "{":d=false;var H=JSON.parse(n);e[H.id]=H;S=c.notification.retrieving.replace("%s",H.name||"file");if(p!="m")$.process_cancel(S,function(){d=true;$("#dialog_box").hide()});else{var ea=$("<div>"+S+"</div>").data("id",H.id);l.append(ea);H.entry=ea}return;case "<":I=true;break;case "d":if(n.indexOf("data:image/svg+xml")===0){I=n.substring(26);n=svgCanvas.Utils.decode64(I);I=true;
|
|
break}else if(n.indexOf("data:image/")===0){S=true;break}default:p!=="m"?a():e[O].entry.remove();return}switch(p){case "s":if(I)svgCanvas.importSvgString(n);else S&&o(n);a();break;case "m":b.push([I?"svg":"img",n]);H=e[O];if(I){if(H&&H.name)var X=H.name;else{S=(new DOMParser).parseFromString(n,"text/xml").documentElement;X=$(S).children("title").first().text()||"(SVG #"+n.length+")"}if(H)l.children().each(function(){if($(this).data("id")==O){H.preview_url?$(this).html('<img src="'+H.preview_url+'">'+
|
|
X):$(this).text(X);q.removeAttr("disabled")}});else{l.append("<div>"+X+"</div>");q.removeAttr("disabled")}}else{if(H&&H.preview_url)X=H.name||"";ea=H&&H.preview_url?'<img src="'+H.preview_url+'">'+X:'<img src="'+n+'">';if(H)l.children().each(function(){if($(this).data("id")==O){$(this).html(ea);q.removeAttr("disabled")}});else{l.append($("<div>").append(ea));q.removeAttr("disabled")}}break;case "o":if(!I)break;svgEditor.openPrep(function(Q){if(Q){svgCanvas.clear();svgCanvas.setSvgString(n)}});a()}}}},
|
|
true);var l,q;return{buttons:[{id:"tool_imagelib",type:"menu",position:4,panel:"file_menu",title:"Image library",events:{mouseup:function(){var u=$("#imgbrowse");if(u.length)$("#imgbrowse_holder").show();else{$("<div id=imgbrowse_holder><div id=imgbrowse class=toolbar_button>\t\t\t</div></div>").insertAfter("#svg_docprops");u=$("#imgbrowse");var n=c.imagelib.select_lib,I=$("<ul id=imglib_opts>").appendTo(u),S=$("<iframe/>").prependTo(u).hide().wrap("<div id=lib_framewrap>"),O=$("<h1>").prependTo(u).text(n).css({position:"absolute",
|
|
top:0,left:0,width:"100%"}),H=$("<button>"+c.common.cancel+"</button>").appendTo(u).click(function(){$("#imgbrowse_holder").hide()}).css({position:"absolute",top:5,right:-10});u=$("<span>").css({position:"absolute",top:5,left:10}).appendTo(u);var ea=$("<button hidden>"+c.imagelib.show_list+"</button>").appendTo(u).click(function(){S.attr("src","about:blank").hide();I.show();O.text(n);ea.hide()}).css({"margin-right":5}).hide();$("<select><option value=s>"+c.imagelib.import_single+"</option><option value=m>"+
|
|
c.imagelib.import_multi+"</option><option value=o>"+c.imagelib.open+"</option></select>").appendTo(u).change(function(){p=$(this).val();switch(p){case "s":case "o":f(false);break;case "m":f(true)}}).css({"margin-top":10});H.prepend($.getSvgIcon("cancel",true));ea.prepend($.getSvgIcon("tool_imagelib",true));$.each(m,function(X,Q){$("<li>").appendTo(I).text(Q.name).click(function(){S.attr("src",Q.url).show();O.text(Q.name);I.hide();ea.show()}).append("<span>"+Q.description+"</span>")})}}}}],callback:function(){$("<style>").text("\t\t\t\t#imgbrowse_holder {\t\t\t\t\tposition: absolute;\t\t\t\t\ttop: 0;\t\t\t\t\tleft: 0;\t\t\t\t\twidth: 100%;\t\t\t\t\theight: 100%;\t\t\t\t\tbackground-color: rgba(0, 0, 0, .5);\t\t\t\t\tz-index: 5;\t\t\t\t}\t\t\t\t\t\t\t\t#imgbrowse {\t\t\t\t\tposition: absolute;\t\t\t\t\ttop: 25px;\t\t\t\t\tleft: 25px;\t\t\t\t\tright: 25px;\t\t\t\t\tbottom: 25px;\t\t\t\t\tmin-width: 300px;\t\t\t\t\tmin-height: 200px;\t\t\t\t\tbackground: #B0B0B0;\t\t\t\t\tborder: 1px outset #777;\t\t\t\t}\t\t\t\t#imgbrowse h1 {\t\t\t\t\tfont-size: 20px;\t\t\t\t\tmargin: .4em;\t\t\t\t\ttext-align: center;\t\t\t\t}\t\t\t\t#lib_framewrap,\t\t\t\t#imgbrowse > ul {\t\t\t\t\tposition: absolute;\t\t\t\t\ttop: 45px;\t\t\t\t\tleft: 10px;\t\t\t\t\tright: 10px;\t\t\t\t\tbottom: 10px;\t\t\t\t\tbackground: white;\t\t\t\t\tmargin: 0;\t\t\t\t\tpadding: 0;\t\t\t\t}\t\t\t\t#imgbrowse > ul {\t\t\t\t\toverflow: auto;\t\t\t\t}\t\t\t\t#imgbrowse > div {\t\t\t\t\tborder: 1px solid #666;\t\t\t\t}\t\t\t\t#imglib_preview > div {\t\t\t\t\tpadding: 5px;\t\t\t\t\tfont-size: 12px;\t\t\t\t}\t\t\t\t#imglib_preview img {\t\t\t\t\tdisplay: block;\t\t\t\t\tmargin: 0 auto;\t\t\t\t\tmax-height: 100px;\t\t\t\t}\t\t\t\t#imgbrowse li {\t\t\t\t\tlist-style: none;\t\t\t\t\tpadding: .5em;\t\t\t\t\tbackground: #E8E8E8;\t\t\t\t\tborder-bottom: 1px solid #B0B0B0;\t\t\t\t\tline-height: 1.2em;\t\t\t\t\tfont-style: sans-serif;\t\t\t\t\t}\t\t\t\t#imgbrowse li > span {\t\t\t\t\tcolor: #666;\t\t\t\t\tfont-size: 15px;\t\t\t\t\tdisplay: block;\t\t\t\t\t}\t\t\t\t#imgbrowse li:hover {\t\t\t\t\tbackground: #FFC;\t\t\t\t\tcursor: pointer;\t\t\t\t\t}\t\t\t\t#imgbrowse iframe {\t\t\t\t\twidth: 100%;\t\t\t\t\theight: 100%;\t\t\t\t\tborder: 0;\t\t\t\t}\t\t\t").appendTo("head")}}});
|