adding a way of detecting focus within the iframe
parent
70eed2d7ed
commit
f34f258385
|
@ -2055,6 +2055,9 @@
|
|||
return false;
|
||||
}
|
||||
var closer = function(e){
|
||||
if (top != self && !e.isTrigger) {
|
||||
top.exports.setEditorFocus();
|
||||
}
|
||||
if (!$(e.target).hasClass("menu_title") && $('#menu_bar').hasClass("active")) {
|
||||
if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) {
|
||||
blinker(e);
|
||||
|
|
|
@ -140,19 +140,19 @@ this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],n
|
|||
""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""};svgedit.history.UndoManager.prototype.undo=function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};
|
||||
svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,n){for(var f=++this.undoChangeStackPointer,c=n.length,m=Array(c),p=Array(c);c--;){var b=n[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--,n=this.undoableChangeStack[a],f=n.elements.length,c=n.attrName,m=new svgedit.history.BatchCommand("Change "+c);f--;){var p=n.elements[f];if(p!=null){var b={};b[c]=n.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,n,f;svgedit.select.Selector=function(c,m){this.id=c;this.selectedElement=m;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1",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 u=b.tagName;if(u==="text")l+=
|
||||
2/e;d=svgedit.transformlist.getTransformList(b);d=svgedit.math.transformListToTransform(d).matrix;d.e*=e;d.f*=e;var z=svgedit.utilities.getBBox(b);if(u==="g"&&!$.data(b,"gsvg"))if(u=a.getStrokedBBox(b.childNodes))z=u;u=z.x;var o=z.y,L=z.width;z=z.height;l*=e;e=svgedit.math.transformBox(u*e,o*e,L*e,z*e,d);d=e.aabox;u=d.x-l;o=d.y-l;L=d.width+l*2;var T=d.height+l*2;d=u+L/2;z=o+T/2;if(b=svgedit.utilities.getRotationAngle(b)){u=a.svgRoot().createSVGTransform();u.setRotate(-b,d,z);u=u.matrix;e.tl=svgedit.math.transformPoint(e.tl.x,
|
||||
e.tl.y,u);e.tr=svgedit.math.transformPoint(e.tr.x,e.tr.y,u);e.bl=svgedit.math.transformPoint(e.bl.x,e.bl.y,u);e.br=svgedit.math.transformPoint(e.br.x,e.br.y,u);u=e.tl;L=u.x;T=u.y;var N=u.x,J=u.y;u=Math.min;o=Math.max;L=u(L,u(e.tr.x,u(e.bl.x,e.br.x)))-l;T=u(T,u(e.tr.y,u(e.bl.y,e.br.y)))-l;N=o(N,o(e.tr.x,o(e.bl.x,e.br.x)))+l;J=o(J,o(e.tr.y,o(e.bl.y,e.br.y)))+l;u=L;o=T;L=N-L;T=J-T}l=a.svgRoot().suspendRedraw(100);c.setAttribute("d","M"+u+","+o+" L"+(u+L)+","+o+" "+(u+L)+","+(o+T)+" "+u+","+(o+T)+"z");
|
||||
this.selectorGroup.setAttribute("transform",b?"rotate("+[b,d,z].join(",")+")":"");u-=3.5;o-=3.5;this.gripCoords={nw:[u,o],ne:[u+L,o],sw:[u,o+T],se:[u+L,o+T],n:[u+L/2,o],w:[u,o+T/2],e:[u+L,o+T/2],s:[u+L/2,o+T]};for(var da in this.gripCoords){c=this.gripCoords[da];p[da].setAttribute("x",c[0]);p[da].setAttribute("y",c[1])}this.rotateCoords={nw:[u,o],ne:[u+L+8,o],sw:[u,o+T+8],se:[u+L+8,o+T+8]};for(da in this.rotateCoords){c=this.rotateCoords[da];m.rotateGrips[da].setAttribute("cx",c[0]);m.rotateGrips[da].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:"transparent",r:8,stroke:"transparent","stroke-width":0,
|
||||
style:"cursor:url("+n.imgPath+"rotate.png) 12 12, auto;"}});$.data(m,"dir",c);$.data(m,"type","rotate");this.rotateGrips[c]=this.selectorGripsGroup.appendChild(m)}for(c in this.selectorGrips){m=a.createSVGElement({element:"rect",attr:{id:"selectorGrip_resize_"+c,width:7,height:7,fill:"#4F80FF",stroke:"transparent","stroke-width":2,style:"cursor:"+c+"-resize","pointer-events":"all"}});$.data(m,"dir",c);$.data(m,"type","resize");this.selectorGrips[c]=this.selectorGripsGroup.appendChild(m)}if(!$("#canvasBackground").length){c=
|
||||
n.dimensions;c=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:c[0],height:c[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});m=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});c.appendChild(m);a.svgRoot().insertBefore(c,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(c){if(c==null)return null;var m=
|
||||
this.selectors.length;if(typeof this.selectorMap[c.id]=="object"){this.selectorMap[c.id].locked=true;return this.selectorMap[c.id]}for(var 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){n=c;a=m;f=new svgedit.select.SelectorManager};svgedit.select.getSelectorManager=function(){return f}})();svgedit=svgedit||{};
|
||||
(function(){if(!svgedit.select)svgedit.select={};var a,n,f;svgedit.select.Selector=function(c,m){this.id=c;this.selectedElement=m;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));this.gripCoords={nw:null,n:null,ne:null,e:null,
|
||||
se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(c){this.locked=true;this.selectedElement=c;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(c){var m=[];c=Math.round(c/45);if(c<0)c+=8;for(var 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 u=b.tagName;if(u==="text")l+=2/e;d=svgedit.transformlist.getTransformList(b);d=svgedit.math.transformListToTransform(d).matrix;d.e*=e;d.f*=e;var z=svgedit.utilities.getBBox(b);if(u==="g"&&!$.data(b,"gsvg"))if(u=a.getStrokedBBox(b.childNodes))z=u;u=z.x;var o=z.y,L=z.width;z=z.height;l*=e;e=svgedit.math.transformBox(u*e,o*e,L*e,z*e,d);d=e.aabox;u=d.x-l;o=d.y-l;L=d.width+l*2;var T=d.height+l*2;d=u+L/2;z=o+T/2;if(b=svgedit.utilities.getRotationAngle(b)){u=a.svgRoot().createSVGTransform();
|
||||
u.setRotate(-b,d,z);u=u.matrix;e.tl=svgedit.math.transformPoint(e.tl.x,e.tl.y,u);e.tr=svgedit.math.transformPoint(e.tr.x,e.tr.y,u);e.bl=svgedit.math.transformPoint(e.bl.x,e.bl.y,u);e.br=svgedit.math.transformPoint(e.br.x,e.br.y,u);u=e.tl;L=u.x;T=u.y;var N=u.x,J=u.y;u=Math.min;o=Math.max;L=u(L,u(e.tr.x,u(e.bl.x,e.br.x)))-l;T=u(T,u(e.tr.y,u(e.bl.y,e.br.y)))-l;N=o(N,o(e.tr.x,o(e.bl.x,e.br.x)))+l;J=o(J,o(e.tr.y,o(e.bl.y,e.br.y)))+l;u=L;o=T;L=N-L;T=J-T}l=a.svgRoot().suspendRedraw(100);c.setAttribute("d",
|
||||
"M"+u+","+o+" L"+(u+L)+","+o+" "+(u+L)+","+(o+T)+" "+u+","+(o+T)+"z");this.selectorGroup.setAttribute("transform",b?"rotate("+[b,d,z].join(",")+")":"");u-=3.5;o-=3.5;this.gripCoords={nw:[u,o],ne:[u+L,o],sw:[u,o+T],se:[u+L,o+T],n:[u+L/2,o],w:[u,o+T/2],e:[u+L,o+T/2],s:[u+L/2,o+T]};for(var da in this.gripCoords){c=this.gripCoords[da];p[da].setAttribute("x",c[0]);p[da].setAttribute("y",c[1])}this.rotateCoords={nw:[u,o],ne:[u+L+8,o],sw:[u,o+T+8],se:[u+L+8,o+T+8]};for(da in this.rotateCoords){c=this.rotateCoords[da];
|
||||
m.rotateGrips[da].setAttribute("cx",c[0]);m.rotateGrips[da].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:"transparent",r:8,stroke:"transparent","stroke-width":0,style:"cursor:url("+n.imgPath+"rotate.png) 12 12, auto;"}});$.data(m,"dir",c);$.data(m,"type","rotate");this.rotateGrips[c]=this.selectorGripsGroup.appendChild(m)}for(c in this.selectorGrips){m=a.createSVGElement({element:"rect",attr:{id:"selectorGrip_resize_"+c,width:7,height:7,fill:"#4F80FF",stroke:"transparent","stroke-width":2,style:"cursor:"+c+"-resize","pointer-events":"all"}});$.data(m,"dir",c);$.data(m,
|
||||
"type","resize");this.selectorGrips[c]=this.selectorGripsGroup.appendChild(m)}if(!$("#canvasBackground").length){c=n.dimensions;c=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:c[0],height:c[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});m=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});c.appendChild(m);a.svgRoot().insertBefore(c,
|
||||
a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(c){if(c==null)return null;var m=this.selectors.length;if(typeof this.selectorMap[c.id]=="object"){this.selectorMap[c.id].locked=true;return this.selectorMap[c.id]}for(var 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){n=c;a=m;f=new svgedit.select.SelectorManager};svgedit.select.getSelectorManager=function(){return f}})();svgedit=svgedit||{};
|
||||
(function(){if(!svgedit.draw)svgedit.draw={};var a="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),n={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},f=n.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(c,m){this.name_=c;this.group_=m};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(c,m){f=c==false?n.NEVER_RANDOMIZE:
|
||||
n.ALWAYS_RANDOMIZE;if(f==n.ALWAYS_RANDOMIZE&&!m.getNonce())m.setNonce(Math.floor(Math.random()*100001));else f==n.NEVER_RANDOMIZE&&m.getNonce()&&m.clearNonce()};svgedit.draw.Drawing=function(c,m){if(!c||!c.tagName||!c.namespaceURI||c.tagName!="svg"||c.namespaceURI!="http://www.w3.org/2000/svg")throw"Error: svgedit.draw.Drawing instance initialized without a <svg> element";this.svgElem_=c;this.obj_num=0;this.idPrefix=m||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
|
||||
"";var p=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(p&&f!=n.NEVER_RANDOMIZE)this.nonce_=p;else f==n.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(c){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+c):$(this.svgElem_).find("[id="+c+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};
|
||||
|
@ -169,7 +169,7 @@ m);break}}})();svgedit=svgedit||{};
|
|||
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},n={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},f=[],c=true,m={};svgedit.path.setLinkControlPoints=function(d){c=d};var 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 u=d.numberOfItems,z=[],o=0;o<u;o++){var L=d.getItem(o);z.push(L)}d.clear();for(o=0;o<u;o++){o==l&&d.appendItem(e);d.appendItem(z[o])}}};
|
||||
svgedit.path.ptObjToArr=function(d,e){for(var l=n[d],u=l.length,z=Array(u),o=0;o<u;o++)z[o]=e[l[o]];return z};svgedit.path.getGripPt=function(d,e){var l={x:e?e.x:d.item.x,y:e?e.y:d.item.y},u=d.path;if(u.matrix)l=svgedit.math.transformPoint(l.x,l.y,u.matrix);l.x*=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 u=svgedit.path.getGripContainer(),z=svgedit.utilities.getElem("pathpointgrip_"+d);if(!z){z=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(z,{id:"pathpointgrip_"+d,display:"none",width:5,height:5,fill:"#fff",stroke:"#4F80FF","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});z=u.appendChild(z);$("#pathpointgrip_"+d).dblclick(function(){svgedit.path.path&&
|
||||
return l};svgedit.path.addPointGrip=function(d,e,l){var u=svgedit.path.getGripContainer(),z=svgedit.utilities.getElem("pathpointgrip_"+d);if(!z){z=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(z,{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});z=u.appendChild(z);$("#pathpointgrip_"+d).dblclick(function(){svgedit.path.path&&
|
||||
svgedit.path.path.setSegType()})}e&&l&&svgedit.utilities.assignAttributes(z,{x:e-2.5,y:l-2.5,display:"inline"});return z};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 u=svgedit.path.getGripPt(d);svgedit.utilities.assignAttributes(l,{x:u.x-2.5,y:u.y-2.5,display:"inline"})}return l};svgedit.path.getControlPoints=function(d){var e=d.item,l=d.index;if(!("x1"in e)||!("x2"in e))return null;var u={};svgedit.path.getGripContainer();for(var z=[svgedit.path.path.segs[l-1].item,e],o=1;o<3;o++){var L=l+"c"+o,T=u["c"+o+"_line"]=
|
||||
|
@ -408,9 +408,9 @@ var Ha=a(this).attr("data-curopt");if(ia.data("isLibrary")&&a(W.replace("_show",
|
|||
a(".canvas_height").val(Sa.h);a("#docprops_button").on("click",function(){w()});var Ja=c.setImageURL=function(q){q||(q=ea);f.setImageURL(q);a("#image_url").val(q);if(q.indexOf("data:")===0){a("#image_url").hide();a("#change_image_url").show()}else{f.embedImage(q,function(B){B?a("#url_notice").hide():a("#url_notice").show();ea=q});a("#image_url").show();a("#change_image_url").hide()}},Ea=function(q){var B=Math.min(Math.max(12+q.value.length*6,50),300);a(q).width(B)},Za=function(){var q=Y;if(q!=null&&
|
||||
!q.parentNode)q=null;var B=f.getCurrentDrawing().getCurrentLayerName(),K=f.getMode(),Q=d.baseUnit!=="px"?d.baseUnit:null,W=K=="pathedit",ia=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");!q&&!za&&a("#canvas_panel").show();
|
||||
if(q!=null){var va=q.nodeName,ya=f.getRotationAngle(q);a("#angle").val(Math.round(ya));ya=f.getBlur(q);a("#blur").val(ya);a("#blur_slider").slider("option","value",ya);f.addedNew&&va==="image"&&f.getHref(q).indexOf("data:")!==0&&L();if(!W&&K!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=0)a("#xy_panel").hide();else{var Da,Ha;if(["g","polyline","path"].indexOf(va)>=0){if(K=f.getStrokedBBox([q])){Da=K.x;Ha=K.y}}else{Da=
|
||||
q.getAttribute("x");Ha=q.getAttribute("y")}if(Q){Da=svgedit.units.convertUnit(Da);Ha=svgedit.units.convertUnit(Ha)}a("#selected_x").val(Da||0);a("#selected_y").val(Ha||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{B=sa.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",
|
||||
!sa.canDeleteNodes);H("#tool_openclose_path",sa.closed_subpath?"open_path":"close_path");if(B){W=a("#seg_type");if(Q){B.x=svgedit.units.convertUnit(B.x);B.y=svgedit.units.convertUnit(B.y)}a("#path_node_x").val(B.x);a("#path_node_y").val(B.y);B.type?W.val(B.type).removeAttr("disabled"):W.val(4).attr("disabled","disabled")}return}Q={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=q.tagName;
|
||||
a(q).data("gsvg")&&a("#g_panel").show();Aa=="path"&&a("#path_panel").show();if(Q[Aa]){Q=Q[Aa];a("#"+Aa+"_panel").show();a.each(Q,function(fb,gb){var ga=q.getAttribute(gb);if(d.baseUnit!=="px"&&q[gb])ga=svgedit.units.convertUnit(q[gb].baseVal.value);a("#"+Aa+"_"+gb).val(ga||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");
|
||||
q.getAttribute("x");Ha=q.getAttribute("y")}if(Q){Da=svgedit.units.convertUnit(Da);Ha=svgedit.units.convertUnit(Ha)}a("#selected_x").val(Math.round(Ha)||0);a("#selected_y").val(Math.round(Da)||0);a("#xy_panel").show()}["image","text","path","g","use"].indexOf(va)==-1&&a(".action_path_convert_selected").removeClass("disabled");va==="path"&&a(".action_path_selected").removeClass("disabled")}else{B=sa.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",
|
||||
!sa.canDeleteNodes);H("#tool_openclose_path",sa.closed_subpath?"open_path":"close_path");if(B){W=a("#seg_type");if(Q){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?W.val(B.type).removeAttr("disabled"):W.val(4).attr("disabled","disabled")}return}Q={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=q.tagName;a(q).data("gsvg")&&a("#g_panel").show();Aa=="path"&&a("#path_panel").show();if(Q[Aa]){Q=Q[Aa];a("#"+Aa+"_panel").show();a.each(Q,function(fb,gb){var ga=q.getAttribute(gb);if(d.baseUnit!=="px"&&q[gb])ga=svgedit.units.convertUnit(q[gb].baseVal.value);a("#"+Aa+"_"+gb).val(Math.round(ga)||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(q.getAttribute("font-family"));a("#font_size").val(q.getAttribute("font-size"));a("#text").val(q.textContent);f.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(Aa=="image")Ja(f.getHref(q));else if(Aa==="g"||Aa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");
|
||||
Q=f.getTitle();va=a("#g_title")[0];va.value=Q;Ea(va);Aa=="use"?va.setAttribute("disabled","disabled"):va.removeAttribute("disabled")}}ia[(Aa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");ia[(Aa==="g"||!za?"dis":"en")+"ableContextMenuItems"]("#group")}else if(za){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");ia.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else ia.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");
|
||||
ja.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");ja.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");f.addedNew=false;if(q&&!W||za){a("#selLayerNames").removeAttr("disabled").val(B);pa.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",
|
||||
|
@ -440,29 +440,29 @@ B=q?"stroke":"fill",K=a(this).attr("data-rgb"),Q=null;console.log(K);if(K==="tra
|
|||
"table-cell");a(this).addClass("expanded");xa()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");xa()});var kb=function(q,B){if(a(q).hasClass("disabled"))return false;if(a(q).parent().hasClass("tools_flyout"))return true;var K=K||"normal";B||a(".tools_flyout").fadeOut(K);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(q).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var q=
|
||||
null,B=null,K=qa[0],Q=false,W=false;a("#svgcanvas").bind("mousemove mouseup",function(ia){if(Q!==false){K.scrollLeft-=ia.clientX-q;K.scrollTop-=ia.clientY-B;q=ia.clientX;B=ia.clientY;if(ia.type==="mouseup")Q=false;return false}}).mousedown(function(ia){if(ia.button===1||W===true){Q=true;q=ia.clientX;B=ia.clientY;return false}});a(window).mouseup(function(){Q=false});a(document).bind("keydown","space",function(ia){f.spaceKey=W=true;ia.preventDefault()}).bind("keyup","space",function(ia){ia.preventDefault();
|
||||
f.spaceKey=W=false}).bind("keydown","alt",function(){f.getMode()==="zoom"&&qa.addClass("out")}).bind("keyup","alt",function(){f.getMode()==="zoom"&&qa.removeClass("out")})})();var Ca=a(".menu"),wb=function(q){q.target.style.background="#fff";setTimeout(function(){q.target.style.background="#ddd"},50);setTimeout(function(){q.target.style.background="#fff"},150);setTimeout(function(){q.target.style.background="#ddd"},200);setTimeout(function(){q.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},
|
||||
220);return false};a(".menu_item").live("click",function(q){wb(q)});a("svg, body").on("click",function(q){if(!a(q.target).hasClass("menu_title")&&a("#menu_bar").hasClass("active"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))wb(q);else{a("#menu_bar").removeClass("active");a(".tools_flyout").hide();a("input").blur()}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",function(){Ca.removeClass("open");a(this).parent().addClass("open")});
|
||||
c.addDropDown=function(q,B,K){if(a(q).length!=0){var Q=a(q).find("button"),W=a(q).find("ul").attr("id",a(q)[0].id+"-list");K||a("#option_lists").append(W);var ia=false;K&&a(q).addClass("dropup");W.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!ia){Q.removeClass("down");W.hide()}ia=false});Q.bind("mousedown",function(){if(Q.hasClass("down")){Q.removeClass("down");W.hide()}else{Q.addClass("down");if(!K){var va=a(q).offset();W.css({top:va.top,left:va.left-110})}W.show();ia=true}}).hover(function(){ia=
|
||||
true}).mouseout(function(){ia=false})}};var nb=function(q,B,K,Q){var W=a(q);B=a(B);var ia=false,va=Q.dropUp;va&&a(q).addClass("dropup");B.find("li").bind("mouseup",function(){if(Q.seticon){H("#cur_"+W[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}K.apply(this,arguments)});a(window).mouseup(function(){if(!ia){W.removeClass("down");B.hide();B.css({top:0,left:0})}ia=false});B.height();a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=B.height();
|
||||
ya.left+=8}else ya.top+=a(q).height();a(B).offset(ya);if(W.hasClass("down")){W.removeClass("down");B.hide();B.css({top:0,left:0})}else{W.addClass("down");B.show();ia=true;return false}}).hover(function(){ia=true}).mouseout(function(){ia=false});Q.multiclick&&B.mousedown(function(){ia=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 q=parseInt(a(this).text().split("%")[0]);
|
||||
mb(false,q)}},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(q,B){mb(B)}});c.addDropDown("#blur_dropdown",a.noop);var yb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,B){yb=false;Ab(B);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){yb=true},slide:function(q,B){Ab(B,null,yb)}});c.addDropDown("#zoom_dropdown",function(){var q=
|
||||
a(this),B=q.attr("data-val");B?La(window,B):Na({value:parseInt(q.text())})},true);nb("#stroke_linecap","#linecap_opts",function(){z(this,true)},{dropUp:true});nb("#stroke_linejoin","#linejoin_opts",function(){z(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,B=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=
|
||||
this;U="toolbars";qa.mousedown(B)}).blur(function(){U="canvas";qa.unbind("mousedown",B);f.getMode()=="textedit"&&a("#text").focus()})})();var Bb=function(){if(kb("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},ob=function(){kb("#tool_fhpath")&&f.setMode("fhpath")},Cb=function(){kb("#tool_line")&&f.setMode("line")},Kb=function(){kb("#tool_rect")&&f.setMode("rect")},Ib=function(){kb("#tool_ellipse")&&
|
||||
f.setMode("ellipse")},Rb=function(){kb("#tool_image")&&f.setMode("image")},na=function(){kb("#tool_zoom")&&f.setMode("zoom")},Z=function(){if(kb("#tool_zoom")){h();ma()}},ta=function(){kb("#tool_text")&&f.setMode("text")},M=function(){kb("#tool_path")&&f.setMode("path")},I=function(){if(Y!=null||za)f.deleteSelectedElements()},X=function(){if(Y!=null||za)f.cutSelectedElements()},Ma=function(){if(Y!=null||za)f.copySelectedElements()},Xa=function(){var q=f.getZoom(),B=(qa[0].scrollLeft+qa.width()/2)/
|
||||
q-f.contentW;q=(qa[0].scrollTop+qa.height()/2)/q-f.contentH;f.pasteElements("point",B,q)},db=function(){Y!=null&&f.moveToTopSelectedElement()},tb=function(){Y!=null&&f.moveToBottomSelectedElement()},xb=function(){Y!=null&&f.moveUpDownSelected("Up")},Hb=function(){Y!=null&&f.moveUpDownSelected("Down")},pb=function(){Y!=null&&f.convertToPath()},Lb=function(){Y!=null&&sa.reorient()},bb=function(){if(Y!=null||za)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},qb=
|
||||
function(q,B){if(Y!=null||za){if(d.gridSnapping){var K=f.getZoom()*d.snappingStep;q*=K;B*=K}f.moveSelectedElements(q,B)}},Qb=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?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);sa.linkControlPoints(q)},$b=function(){sa.getNodePoint()&&sa.clonePathNode()},
|
||||
Zb=function(){sa.getNodePoint()&&sa.deletePathNode()},rb=function(){var q=a("#tool_add_subpath"),B=!q.hasClass("push_button_pressed");B?q.addClass("push_button_pressed").removeClass("tool_button"):q.removeClass("push_button_pressed").addClass("tool_button");sa.addSubPath(B)},Va=function(){sa.opencloseSubPath()},gc=function(){f.cycleElement(1)},cc=function(){f.cycleElement(0)},Ub=function(q,B){if(!(Y==null||za)){q||(B*=-1);var K=a("#angle").val()*1+B;f.setRotationAngle(K);Za()}},hc=function(){var q=
|
||||
d.dimensions;a.confirm(e.notification.QwantToClear,function(B){if(B){ma();f.clear();f.setResolution(q[0],q[1]);Tb(true);h();Eb();Za();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},lc=function(){f.setBold(!f.getBold());Za();return false},Wb=function(){f.setItalic(!f.getItalic());Za();return false},ac=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+q+"</title><h1>"+q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",
|
||||
function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},nc=function(){f.open()},Vb=function(){},ub=function(q){var B=q.prev();B.css("background","#09f");setTimeout(function(){B.css("background","")},200)},ic=function(){if(ja.getUndoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));ja.undo();Eb()}},dc=function(){if(ja.getRedoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));ja.redo();Eb()}},Sb=function(){if(za)f.groupSelectedElements();else Y&&f.ungroupSelectedElement()},
|
||||
vb=function(){window.event.type==="keydown"&&ub(a("#edit_menu"));f.cloneSelectedElements(20,20)},fc=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},g=function(){var q=document.querySelector("#tool_stroke rect"),B=document.querySelector("#tool_fill rect"),K=B.getAttribute("fill"),Q=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));if(isNaN(q))q=100;B=parseFloat(B.getAttribute("fill-opacity"));if(isNaN(B))B=100;
|
||||
Q=ab(Q,q,"stroke");K=ab(K,B,"fill");la.fill.setPaint(Q,true);la.stroke.setPaint(K,true)},h=function(q){var B=f.getResolution();q=q?B.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);t();Tb(true)},k=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");qa.toggleClass("wireframe");if(!kc){var q=a("#wireframe_rules");q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");
|
||||
t()}},v=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)},t=function(){if(!kc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+"px; }";a("#wireframe_rules").text(qa.hasClass("wireframe")?q:"")}},E=function(q,
|
||||
B){if(!Ia){Ia=true;a("#save_output_btns").toggle(!!B);a("#tool_source_back").toggle(!B);var K=ra=f.getSvgString();a("#svg_source_textarea").val(K);a("#svg_source_editor").fadeIn();A();a("#svg_source_textarea").focus()}},w=function(){if(!Qa){Qa=true;a("#image_save_opts input").val([b.img_save]);var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());
|
||||
a("#svg_docprops").show()}},s=function(){if(!Ka){Ka=true;var q=a("#bg_blocks div"),B=a.pref("bkgd_color"),K=a.pref("bkgd_url");q.each(function(){var Q=a(this),W=Q.css("background-color")==B;Q.toggleClass("cur_background",W);W&&a("#canvas_bg_url").removeClass("cur_background")});B||q.eq(0).addClass("cur_background");K&&a("#canvas_bg_url").val(K);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()}},A=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",q)},F=function(){if(Ia){var q=function(){f.clearSelection();wa();h();Eb();C();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?q():a.confirm(e.notification.QerrorsRevertToSource,function(B){if(!B)return false;q()});ma()}},C=function(q){q=q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},D=function(){var q=a("#canvas_width"),B=
|
||||
q.val(),K=a("#canvas_height"),Q=K.val();if(B!="fit"&&!svgedit.units.isValidUnit("width",B)){a.alert(e.notification.invalidAttrValGiven);q.parent().addClass("error");return false}q.parent().removeClass("error");if(Q!="fit"&&!svgedit.units.isValidUnit("height",Q)){a.alert(e.notification.invalidAttrValGiven);K.parent().addClass("error");return false}K.parent().removeClass("error");if(!f.setResolution(B,Q)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();
|
||||
a.pref("img_save",b.img_save);Tb();ha()},G=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";o(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);aa(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Tb();ka()},H=c.setIcon=function(q,
|
||||
B){var K=typeof B==="string"?a.getSvgIcon(B,true):B.clone();K?a(q).find("img").replaceWith(K):console.log("NOTE: Icon image missing: "+B)},P;P=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,B=document.getElementsByTagName("script")[0],K;for(K in B.style)if(q.test(K))return K.match(q)[0];if("WebkitOpacity"in B.style)return"Webkit";if("KhtmlOpacity"in B.style)return"Khtml";return""}();var R=function(q,B){P.toLowerCase();var K=["top","left","bottom","right"];q.each(function(){for(var Q=a(this),
|
||||
W=Q.outerWidth()*(B-1),ia=Q.outerHeight()*(B-1),va=0;va<4;va++){var ya=K[va],Da=Q.data("orig_margin-"+ya);if(Da==null){Da=parseInt(Q.css("margin-"+ya));Q.data("orig_margin-"+ya,Da)}Da=Da*B;if(ya==="right")Da+=W;else if(ya==="bottom")Da+=ia;Q.css("margin-"+ya,Da)}})},aa=c.setIconSize=function(q,B){if(!(q==b.size&&!B)){console.log("size",q);var K=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"),
|
||||
220);return false};a(".menu_item").live("click",function(q){wb(q)});a("svg, body").on("click",function(q){top!=self&&!q.isTrigger&&top.exports.setEditorFocus();if(!a(q.target).hasClass("menu_title")&&a("#menu_bar").hasClass("active"))if(!a(q.target).hasClass("disabled")&&a(q.target).hasClass("menu_item"))wb(q);else{a("#menu_bar").removeClass("active");a(".tools_flyout").hide();a("input").blur()}});a(".menu_title").on("click",function(){a("#menu_bar").toggleClass("active")});a(".menu_title").on("mouseover",
|
||||
function(){Ca.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(q,B,K){if(a(q).length!=0){var Q=a(q).find("button"),W=a(q).find("ul").attr("id",a(q)[0].id+"-list");K||a("#option_lists").append(W);var ia=false;K&&a(q).addClass("dropup");W.find("li").bind("mouseup",B);a(window).mouseup(function(){if(!ia){Q.removeClass("down");W.hide()}ia=false});Q.bind("mousedown",function(){if(Q.hasClass("down")){Q.removeClass("down");W.hide()}else{Q.addClass("down");if(!K){var va=a(q).offset();
|
||||
W.css({top:va.top,left:va.left-110})}W.show();ia=true}}).hover(function(){ia=true}).mouseout(function(){ia=false})}};var nb=function(q,B,K,Q){var W=a(q);B=a(B);var ia=false,va=Q.dropUp;va&&a(q).addClass("dropup");B.find("li").bind("mouseup",function(){if(Q.seticon){H("#cur_"+W[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}K.apply(this,arguments)});a(window).mouseup(function(){if(!ia){W.removeClass("down");B.hide();B.css({top:0,left:0})}ia=false});B.height();
|
||||
a(q).bind("mousedown",function(){var ya=a(q).offset();if(va){ya.top-=B.height();ya.left+=8}else ya.top+=a(q).height();a(B).offset(ya);if(W.hasClass("down")){W.removeClass("down");B.hide();B.css({top:0,left:0})}else{W.addClass("down");B.show();ia=true;return false}}).hover(function(){ia=true}).mouseout(function(){ia=false});Q.multiclick&&B.mousedown(function(){ia=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 q=parseInt(a(this).text().split("%")[0]);mb(false,q)}},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(q,B){mb(B)}});c.addDropDown("#blur_dropdown",a.noop);var yb=false;a("#blur_slider").slider({max:10,step:0.1,stop:function(q,B){yb=false;Ab(B);a("#blur_dropdown li").show();a(window).mouseup()},start:function(){yb=true},
|
||||
slide:function(q,B){Ab(B,null,yb)}});c.addDropDown("#zoom_dropdown",function(){var q=a(this),B=q.attr("data-val");B?La(window,B):Na({value:parseInt(q.text())})},true);nb("#stroke_linecap","#linecap_opts",function(){z(this,true)},{dropUp:true});nb("#stroke_linejoin","#linejoin_opts",function(){z(this,true)},{dropUp:true});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var q=this.id.replace("tool_pos","").charAt(0);f.alignSelectedElements(q,"page")})});(function(){var q,
|
||||
B=function(){a(q).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){q=this;U="toolbars";qa.mousedown(B)}).blur(function(){U="canvas";qa.unbind("mousedown",B);f.getMode()=="textedit"&&a("#text").focus()})})();var Bb=function(){if(kb("#tool_select")){f.setMode("select");a("#styleoverrides").text("#svgcanvas svg *{cursor:move;pointer-events:all}, #svgcanvas svg{cursor:default}")}},ob=function(){kb("#tool_fhpath")&&f.setMode("fhpath")},Cb=function(){kb("#tool_line")&&
|
||||
f.setMode("line")},Kb=function(){kb("#tool_rect")&&f.setMode("rect")},Ib=function(){kb("#tool_ellipse")&&f.setMode("ellipse")},Rb=function(){kb("#tool_image")&&f.setMode("image")},na=function(){kb("#tool_zoom")&&f.setMode("zoom")},Z=function(){if(kb("#tool_zoom")){h();ma()}},ta=function(){kb("#tool_text")&&f.setMode("text")},M=function(){kb("#tool_path")&&f.setMode("path")},I=function(){if(Y!=null||za)f.deleteSelectedElements()},X=function(){if(Y!=null||za)f.cutSelectedElements()},Ma=function(){if(Y!=
|
||||
null||za)f.copySelectedElements()},Xa=function(){var q=f.getZoom(),B=(qa[0].scrollLeft+qa.width()/2)/q-f.contentW;q=(qa[0].scrollTop+qa.height()/2)/q-f.contentH;f.pasteElements("point",B,q)},db=function(){Y!=null&&f.moveToTopSelectedElement()},tb=function(){Y!=null&&f.moveToBottomSelectedElement()},xb=function(){Y!=null&&f.moveUpDownSelected("Up")},Hb=function(){Y!=null&&f.moveUpDownSelected("Down")},pb=function(){Y!=null&&f.convertToPath()},Lb=function(){Y!=null&&sa.reorient()},bb=function(){if(Y!=
|
||||
null||za)a.prompt(e.notification.enterNewLinkURL,"http://",function(q){q&&f.makeHyperlink(q)})},qb=function(q,B){if(Y!=null||za){if(d.gridSnapping){var K=f.getZoom()*d.snappingStep;q*=K;B*=K}f.moveSelectedElements(q,B)}},Qb=function(){var q=!a("#tool_node_link").hasClass("push_button_pressed");q?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);sa.linkControlPoints(q)},$b=function(){sa.getNodePoint()&&sa.clonePathNode()},Zb=function(){sa.getNodePoint()&&sa.deletePathNode()},rb=function(){var q=a("#tool_add_subpath"),B=!q.hasClass("push_button_pressed");B?q.addClass("push_button_pressed").removeClass("tool_button"):q.removeClass("push_button_pressed").addClass("tool_button");sa.addSubPath(B)},Va=function(){sa.opencloseSubPath()},gc=function(){f.cycleElement(1)},cc=function(){f.cycleElement(0)},Ub=function(q,B){if(!(Y==null||za)){q||
|
||||
(B*=-1);var K=a("#angle").val()*1+B;f.setRotationAngle(K);Za()}},hc=function(){var q=d.dimensions;a.confirm(e.notification.QwantToClear,function(B){if(B){ma();f.clear();f.setResolution(q[0],q[1]);Tb(true);h();Eb();Za();la.fill.prep();la.stroke.prep();f.runExtensions("onNewDocument")}})},lc=function(){f.setBold(!f.getBold());Za();return false},Wb=function(){f.setItalic(!f.getItalic());Za();return false},ac=function(){if(!l.pngsave){var q=e.notification.loadingImage;ba=window.open("data:text/html;charset=utf-8,<title>"+
|
||||
q+"</title><h1>"+q+"</h1>")}window.canvg?f.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){f.rasterExport()})})},nc=function(){f.open()},Vb=function(){},ub=function(q){var B=q.prev();B.css("background","#09f");setTimeout(function(){B.css("background","")},200)},ic=function(){if(ja.getUndoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));ja.undo();Eb()}},dc=function(){if(ja.getRedoStackSize()>0){window.event.type==="keydown"&&ub(a("#edit_menu"));
|
||||
ja.redo();Eb()}},Sb=function(){if(za)f.groupSelectedElements();else Y&&f.ungroupSelectedElement()},vb=function(){window.event.type==="keydown"&&ub(a("#edit_menu"));f.cloneSelectedElements(20,20)},fc=function(){var q=this.id.replace("tool_align","").charAt(0);f.alignSelectedElements(q,a("#align_relative_to").val())},g=function(){var q=document.querySelector("#tool_stroke rect"),B=document.querySelector("#tool_fill rect"),K=B.getAttribute("fill"),Q=q.getAttribute("fill");q=parseFloat(q.getAttribute("stroke-opacity"));
|
||||
if(isNaN(q))q=100;B=parseFloat(B.getAttribute("fill-opacity"));if(isNaN(B))B=100;Q=ab(Q,q,"stroke");K=ab(K,B,"fill");la.fill.setPaint(Q,true);la.stroke.setPaint(K,true)},h=function(q){var B=f.getResolution();q=q?B.zoom*q:1;a("#zoom").val(q*100);f.setZoom(q);t();Tb(true)},k=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");qa.toggleClass("wireframe");if(!kc){var q=a("#wireframe_rules");
|
||||
q.length?q.empty():a('<style id="wireframe_rules"></style>').appendTo("head");t()}},v=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)},t=function(){if(!kc){var q="#workarea.wireframe #svgcontent * { stroke-width: "+1/f.getZoom()+
|
||||
"px; }";a("#wireframe_rules").text(qa.hasClass("wireframe")?q:"")}},E=function(q,B){if(!Ia){Ia=true;a("#save_output_btns").toggle(!!B);a("#tool_source_back").toggle(!B);var K=ra=f.getSvgString();a("#svg_source_textarea").val(K);a("#svg_source_editor").fadeIn();A();a("#svg_source_textarea").focus()}},w=function(){if(!Qa){Qa=true;a("#image_save_opts input").val([b.img_save]);var q=f.getResolution();if(d.baseUnit!=="px"){q.w=svgedit.units.convertUnit(q.w)+d.baseUnit;q.h=svgedit.units.convertUnit(q.h)+
|
||||
d.baseUnit}a(".canvas_width").val(q.w);a(".canvas_height").val(q.h);a("#canvas_title").val(f.getDocumentTitle());a("#svg_docprops").show()}},s=function(){if(!Ka){Ka=true;var q=a("#bg_blocks div"),B=a.pref("bkgd_color"),K=a.pref("bkgd_url");q.each(function(){var Q=a(this),W=Q.css("background-color")==B;Q.toggleClass("cur_background",W);W&&a("#canvas_bg_url").removeClass("cur_background")});B||q.eq(0).addClass("cur_background");K&&a("#canvas_bg_url").val(K);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()}},A=function(){var q=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",q)},F=function(){if(Ia){var q=function(){f.clearSelection();wa();h();Eb();C();la.fill.prep();la.stroke.prep()};f.setSvgString(a("#svg_source_textarea").val())?q():a.confirm(e.notification.QerrorsRevertToSource,function(B){if(!B)return false;q()});ma()}},C=function(q){q=
|
||||
q||f.getDocumentTitle();q=Wa+(q?": "+q:"");a("title:first").text(q)},D=function(){var q=a("#canvas_width"),B=q.val(),K=a("#canvas_height"),Q=K.val();if(B!="fit"&&!svgedit.units.isValidUnit("width",B)){a.alert(e.notification.invalidAttrValGiven);q.parent().addClass("error");return false}q.parent().removeClass("error");if(Q!="fit"&&!svgedit.units.isValidUnit("height",Q)){a.alert(e.notification.invalidAttrValGiven);K.parent().addClass("error");return false}K.parent().removeClass("error");if(!f.setResolution(B,
|
||||
Q)){a.alert(e.notification.noContentToFitTo);return false}b.img_save=a("#image_save_opts :checked").val();a.pref("img_save",b.img_save);Tb();ha()},G=function(){var q=a("#bg_blocks div.cur_background").css("background-color")||"#FFF";o(q,a("#canvas_bg_url").val());q=a("#lang_select").val();q!=b.lang&&c.putLocale(q);aa(a("#iconsize").val());d.gridSnapping=a("#grid_snapping_on")[0].checked;d.snappingStep=a("#grid_snapping_step").val();d.showRulers=a("#show_rulers")[0].checked;a("#rulers").toggle(d.showRulers);
|
||||
d.showRulers&&da();d.baseUnit=a("#base_unit").val();f.setConfig(d);Tb();ka()},H=c.setIcon=function(q,B){var K=typeof B==="string"?a.getSvgIcon(B,true):B.clone();K?a(q).find("img").replaceWith(K):console.log("NOTE: Icon image missing: "+B)},P;P=function(){var q=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,B=document.getElementsByTagName("script")[0],K;for(K in B.style)if(q.test(K))return K.match(q)[0];if("WebkitOpacity"in B.style)return"Webkit";if("KhtmlOpacity"in B.style)return"Khtml";return""}();var R=
|
||||
function(q,B){P.toLowerCase();var K=["top","left","bottom","right"];q.each(function(){for(var Q=a(this),W=Q.outerWidth()*(B-1),ia=Q.outerHeight()*(B-1),va=0;va<4;va++){var ya=K[va],Da=Q.data("orig_margin-"+ya);if(Da==null){Da=parseInt(Q.css("margin-"+ya));Q.data("orig_margin-"+ya,Da)}Da=Da*B;if(ya==="right")Da+=W;else if(ya==="bottom")Da+=ia;Q.css("margin-"+ya,Da)}})},aa=c.setIconSize=function(q,B){if(!(q==b.size&&!B)){console.log("size",q);var K=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"),
|
||||
Q=1;Q=typeof q=="number"?q:{s:0.75,m:1,l:1.25,xl:1.5}[q];c.tool_scale=S=Q;Gb();var W=K.parents(":hidden");W.css("visibility","hidden").show();R(K,Q);W.css("visibility","visible").hide();a.pref("iconsize",q);a("#iconsize").val(q);W={"#tools_top":{left:50,height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};K=a("#tool_size_rules");if(K.length)K.empty();else K=a('<style id="tool_size_rules"></style>').appendTo("head");if(q!="m"){var ia="";a.each(W,function(va,ya){va="#svg_editor "+
|
||||
va.replace(/,/g,", #svg_editor");ia+=va+"{";a.each(ya,function(Da,Ha){if(typeof Ha==="number")var Aa=Ha*Q+"px";else if(Ha[q]||Ha.all)Aa=Ha[q]||Ha.all;ia+=Da+":"+Aa+";"});ia+="}"});W="-"+P.toLowerCase()+"-";ia+="#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{"+W+"transform: scale("+Q+");} #svg_editor div.toolset .toolset {"+W+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+
|
||||
W+"transform: scale("+1/Q+");}";K.text(ia)}Gb()}},ua=function(){a("#dialog_box").hide();if(!Ia&&!Qa&&!Ka)Ua&&f.leaveContext();else{if(Ia)ra!==a("#svg_source_textarea").val()?a.confirm(e.notification.QignoreSourceChanges,function(q){q&&wa()}):wa();else if(Qa)ha();else Ka&&ka();xa()}},wa=function(){a("#svg_source_editor").hide();Ia=false;a("#svg_source_textarea").blur()},ha=function(){a("#svg_docprops").hide();a("#canvas_width,#canvas_height").removeAttr("disabled");a("#resolution")[0].selectedIndex=
|
||||
|
|
Loading…
Reference in New Issue