canvas backround ocasionally had an unbleeded edge, fixed
parent
b2793ba723
commit
2960bfac80
|
@ -49,6 +49,35 @@ svgEditor.addExtension("eyedropper", function(S) {
|
|||
|
||||
}
|
||||
|
||||
var getPaint = function(color, opac, type) {
|
||||
// update the editor's fill paint
|
||||
var opts = null;
|
||||
if (color.indexOf("url(#") === 0) {
|
||||
var refElem = svgCanvas.getRefElem(color);
|
||||
if(refElem) {
|
||||
refElem = refElem.cloneNode(true);
|
||||
} else {
|
||||
refElem = $("#" + type + "_color defs *")[0];
|
||||
}
|
||||
|
||||
opts = { alpha: opac };
|
||||
opts[refElem.tagName] = refElem;
|
||||
}
|
||||
else if (color.indexOf("#") === 0) {
|
||||
opts = {
|
||||
alpha: opac,
|
||||
solidColor: color.substr(1)
|
||||
};
|
||||
}
|
||||
else {
|
||||
opts = {
|
||||
alpha: opac,
|
||||
solidColor: 'none'
|
||||
};
|
||||
}
|
||||
return new $.jGraduate.Paint(opts);
|
||||
};
|
||||
|
||||
return {
|
||||
name: "eyedropper",
|
||||
svgicons: "extensions/eyedropper-icon.xml",
|
||||
|
@ -101,6 +130,12 @@ svgEditor.addExtension("eyedropper", function(S) {
|
|||
if (currentStyle.strokeLinecap) change(opts.selectedElements[0], "stroke-linecap", currentStyle.strokeLinecap);
|
||||
if (currentStyle.strokeLinejoin) change(opts.selectedElements[0], "stroke-linejoin", currentStyle.strokeLinejoin);
|
||||
|
||||
var fill = getPaint(currentStyle.fillPaint, currentStyle.fillOpacity*100, "fill")
|
||||
var stroke = getPaint(currentStyle.strokePaint, currentStyle.strokeOpacity*100, "stroke")
|
||||
|
||||
svgCanvas.setPaint("fill", fill)
|
||||
svgCanvas.setPaint("stroke", stroke)
|
||||
|
||||
addToHistory(new ChangeElementCommand(target, changes));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1402,10 +1402,10 @@
|
|||
cur_shape = svgCanvas.addSvgElementFromJson({
|
||||
"element": "rect",
|
||||
"attr": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": res.w,
|
||||
"height": res.h,
|
||||
"x": -1,
|
||||
"y": -1,
|
||||
"width": res.w+2,
|
||||
"height": res.h+2,
|
||||
"stroke": "none",
|
||||
"id": "canvas_background",
|
||||
"opacity": 1,
|
||||
|
|
|
@ -6711,8 +6711,8 @@ this.setResolution = function(x, y) {
|
|||
if (background) {
|
||||
background.setAttribute("x", -1)
|
||||
background.setAttribute("y", -1)
|
||||
background.setAttribute("width", x+1)
|
||||
background.setAttribute("height", y+1)
|
||||
background.setAttribute("width", x+2)
|
||||
background.setAttribute("height", y+2)
|
||||
}
|
||||
call("changed", [svgcontent]);
|
||||
}
|
||||
|
@ -7025,7 +7025,6 @@ this.setPaint = function(type, paint) {
|
|||
// make a copy
|
||||
var p = new $.jGraduate.Paint(paint);
|
||||
this.setPaintOpacity(type, p.alpha/100, true);
|
||||
|
||||
// now set the current paint object
|
||||
cur_properties[type + '_paint'] = p;
|
||||
switch ( p.type ) {
|
||||
|
@ -7037,7 +7036,7 @@ this.setPaint = function(type, paint) {
|
|||
else {
|
||||
this.setColor(type, "none");
|
||||
var selector = (type == "fill") ? "#fill_color rect" : "#stroke_color rect"
|
||||
document.querySelector(selector).setAttribute('fill', 'transparent');
|
||||
document.querySelector(selector).setAttribute('fill', 'none');
|
||||
}
|
||||
break;
|
||||
case "linearGradient":
|
||||
|
|
|
@ -335,13 +335,13 @@ this.setUiStrings=function(g){$.extend(Cb,g.notification)};this.setConfig=functi
|
|||
g}else{k=d.createElementNS(c,"title");k.textContent=g;$(h).prepend(k);v.addSubCommand(new Na(k))}else{v.addSubCommand(new Sa(k[0],k.nextSibling,h));k.remove()}Ia(v)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(g){for(var h=l.childNodes,k=false,v="",s=new Oa("Change Image Title"),E=0;E<h.length;E++)if(h[E].nodeName=="title"){k=h[E];v=k.textContent;break}if(!k){k=d.createElementNS(c,"title");l.insertBefore(k,l.firstChild)}if(g.length)k.textContent=g;else k.parentNode.removeChild(k);
|
||||
s.addSubCommand(new Wa(k,{"#text":v}));Ia(s)};this.getEditorNS=function(g){g&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(g,h){var k=Vb(),v=k.w;k=k.h;var s;if(g=="fit"){var E=getStrokedBBox();if(E){s=new Oa("Fit Canvas to Content");var z=Hb();Fb(z);var t=[],C=[];$.each(z,function(){t.push(E.x*-1);C.push(E.y*-1)});z=b.moveSelectedElements(t,C,true);s.addSubCommand(z);$a();g=Math.round(E.width);h=Math.round(E.height)}else return false}if(g!=
|
||||
v||h!=k){z=e.suspendRedraw(1E3);s||(s=new Oa("Change Image Dimensions"));g=ra("width",g);h=ra("height",h);l.setAttribute("width",g);l.setAttribute("height",h);this.contentW=g;this.contentH=h;s.addSubCommand(new Wa(l,{width:v,height:k}));l.setAttribute("viewBox",[0,0,g/p,h/p].join(" "));s.addSubCommand(new Wa(l,{viewBox:["0 0",v,k].join(" ")}));Ia(s);e.unsuspendRedraw(z);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",
|
||||
g+1);background.setAttribute("height",h+1)}K("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,s=function(E){if(!E)return false;var z=Math.min(Math.round(h/E.width*100*v)/100,Math.round(k/E.height*100*v)/100);b.setZoom(z);return{zoom:z,bbox:E}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:p*g.factor);return{zoom:p,bbox:g}}return s(g)}switch(g){case "selection":if(!J[0])return;g=$.map(J,function(E){if(E)return E});
|
||||
g+2);background.setAttribute("height",h+2)}K("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,s=function(E){if(!E)return false;var z=Math.min(Math.round(h/E.width*100*v)/100,Math.round(k/E.height*100*v)/100);b.setZoom(z);return{zoom:z,bbox:E}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:p*g.factor);return{zoom:p,bbox:g}}return s(g)}switch(g){case "selection":if(!J[0])return;g=$.map(J,function(E){if(E)return E});
|
||||
g=getStrokedBBox(g);break;case "canvas":g=Vb();v=0.95;g={width:g.w,height:g.h,x:0,y:0};break;case "content":g=getStrokedBBox();break;case "layer":g=getStrokedBBox(Hb(w().getCurrentLayer()));break;default:return}return s(g)};this.setZoom=function(g){var h=Vb();l.setAttribute("viewBox","0 0 "+h.w/g+" "+h.h/g);p=g;$.each(J,function(k,v){v&&Qa.requestSelector(v).resize()});Ua.zoomChange();sb("zoomChanged",g)};this.getMode=function(){return Ma};this.setMode=function(g){Ua.clear(true);gb.clear();$("#workarea").attr("class",
|
||||
g);ib=J[0]&&J[0].nodeName=="text"?fb:M;Ma=g};this.getColor=function(g){return ib[g]};this.setColor=function(g,h,k){M[g]=h;ib[g+"_paint"]={type:"solidColor"};for(var v=[],s=J.length;s--;){var E=J[s];if(E)if(E.tagName=="g")svgedit.utilities.walkTree(E,function(z){z.nodeName!="g"&&v.push(z)});else if(g=="fill")E.tagName!="polyline"&&E.tagName!="line"&&v.push(E);else v.push(E)}if(v.length>0)if(k)Wb(g,h,v);else{db(g,h,v);K("changed",v)}};var vb=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},kc=this.setGradient=function(g){if(!(!ib[g+"_paint"]||ib[g+"_paint"].type=="solidColor")){var h=b[g+"Grad"],k=jc(h),v=vb();if(k)h=k;else{h=v.appendChild(d.importNode(h,true));h.id=na()}b.setColor(g,"url(#"+h.id+")");if(g=="canvas")(g=document.getElementById("canvas_background"))&&g.setAttribute("fill","url(#"+h.id+")")}},jc=function(g){var h=vb();h=$(h).find("linearGradient, radialGradient");
|
||||
for(var k=h.length,v=["r","cx","cy","fx","fy"];k--;){var s=h[k];if(g.tagName=="linearGradient"){if(g.getAttribute("x1")!=s.getAttribute("x1")||g.getAttribute("y1")!=s.getAttribute("y1")||g.getAttribute("x2")!=s.getAttribute("x2")||g.getAttribute("y2")!=s.getAttribute("y2"))continue}else{var E=$(g).attr(v),z=$(s).attr(v),t=false;$.each(v,function(G,P){if(E[P]!=z[P])t=true});if(t)continue}var C=g.getElementsByTagNameNS(c,"stop"),F=s.getElementsByTagNameNS(c,"stop");if(C.length==F.length){for(var B=
|
||||
C.length;B--;){var D=C[B],H=F[B];if(D.getAttribute("offset")!=H.getAttribute("offset")||D.getAttribute("stop-opacity")!=H.getAttribute("stop-opacity")||D.getAttribute("stop-color")!=H.getAttribute("stop-color"))break}if(B==-1)return s}}return null};this.setPaint=function(g,h){var k=new $.jGraduate.Paint(h);this.setPaintOpacity(g,k.alpha/100,true);ib[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","transparent")}break;case "linearGradient":case "radialGradient":b[g+"Grad"]=k[k.type];kc(g)}};this.getStrokeWidth=function(){return ib.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Ma)>=0)b.setStrokeWidth(1);else{ib.stroke_width=g;for(var h=[],k=J.length;k--;){var v=J[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(s){s.nodeName!="g"&&h.push(s)}):h.push(v)}if(h.length>
|
||||
"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];kc(g)}};this.getStrokeWidth=function(){return ib.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Ma)>=0)b.setStrokeWidth(1);else{ib.stroke_width=g;for(var h=[],k=J.length;k--;){var v=J[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(s){s.nodeName!="g"&&h.push(s)}):h.push(v)}if(h.length>
|
||||
0){db("stroke-width",g,h);K("changed",J)}}};this.setStrokeAttr=function(g,h){M[g.replace("-","_")]=h;for(var k=[],v=J.length;v--;){var s=J[v];if(s)s.tagName=="g"?svgedit.utilities.walkTree(s,function(E){E.nodeName!="g"&&k.push(E)}):k.push(s)}if(k.length>0){db(g,h,k);K("changed",J)}};this.getStyle=function(){return M};this.getOpacity=function(){return M.opacity};this.setOpacity=function(g){M.opacity=g;db("opacity",g)};this.getFillOpacity=function(){return M.fill_opacity};this.getStrokeOpacity=function(){return M.stroke_opacity};
|
||||
this.setPaintOpacity=function(g,h,k){M[g+"_opacity"]=h;k?Wb(g+"-opacity",h):db(g+"-opacity",h)};this.getBlur=function(g){var h=0;if(g)if(g.getAttribute("filter"))if(g=la(g.id+"_blur"))h=g.firstChild.getAttribute("stdDeviation");return h};(function(){function g(){var s=b.undoMgr.finishUndoableChange();h.addSubCommand(s);Ia(h);k=h=null}var h=null,k=null,v=false;b.setBlurNoUndo=function(s){if(k)if(s===0){Wb("filter","");v=true}else{var E=J[0];v&&Wb("filter","url(#"+E.id+"_blur)");if(svgedit.browser.isWebkit()){E.removeAttribute("filter");
|
||||
E.setAttribute("filter","url(#"+E.id+"_blur)")}Wb("stdDeviation",s,[k.firstChild]);b.setBlurOffsets(k,s)}else b.setBlur(s)};b.setBlurOffsets=function(s,E){if(E>3)oa(s,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){s.removeAttribute("x");s.removeAttribute("y");s.removeAttribute("width");s.removeAttribute("height")}};b.setBlur=function(s,E){if(h)g();else{var z=J[0],t=z.id;k=la(t+"_blur");s-=0;var C=new Oa;if(k){if(s===0)k=null}else{var F=da({element:"feGaussianBlur",
|
||||
|
@ -406,7 +406,7 @@ q/2,y:A.y*q+A.height*q/2});f.getMode()=="zoom"&&A.width&&oa();B()}}};a("#cur_con
|
|||
a(this).mouseup(Ca);Ba.key&&a(document).bind("keydown",Ba.key[0]+" shift+"+Ba.key[0],Ca)});if(va)ja.attr("data-curopt",I[va].sel);else ja.attr("data-curopt")||ja.attr("data-curopt",I[0].sel);var ya,Da=a(X).position();a(A).css({left:Da.left+34,top:Da.top+77});ja.mousedown(function(Ca){a("#tools_shapelib").is(":visible")&&xa(X,false);if(ja.hasClass("disabled"))return false;var Ba=a(A),tb=Da.left+34,Ta=Ba.width()*-1,ia=Ba.data("shown_popop")?200:0;ya=setTimeout(function(){ja.data("isLibrary")?Ba.css("left",
|
||||
tb).show():Ba.css("left",Ta).show().animate({left:tb},150);Ba.data("shown_popop",true)},ia);Ca.preventDefault()}).mouseup(function(){clearTimeout(ya);var Ca=a(this).attr("data-curopt");if(ja.data("isLibrary")&&a(X.replace("_show","")).is(":visible"))xa(X,true);else xa(X)&&Ca in Ia&&Ia[Ca]()})});Kb()},Ga=function(q,A){return a("<div>",{"class":"tools_flyout",id:q}).appendTo("#svg_editor").append(A)},Cb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show"),A=q.offset();q=q.outerWidth();
|
||||
a(this).css({left:(A.left+q)*S,top:A.top})})},Kb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show");if(!q.data("isLibrary")){var A=[];a(this).children().each(function(){A.push(this.title)});q[0].title=A.join(" / ")}})},nb,ab=function(q,A,I){var R=null;if(q.indexOf("url(#")===0){q=(q=f.getRefElem(q))?q.cloneNode(true):a("#"+I+"_color defs *")[0];R={alpha:A};R[q.tagName]=q}else R=q.indexOf("#")===0?{alpha:A,solidColor:q.substr(1)}:{alpha:A,solidColor:"none"};return new a.jGraduate.Paint(R)},
|
||||
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:0,y:0,width:Ya.w,height:Ya.h,stroke:"none",id:"canvas_background",opacity:1,fill:q||a.pref("bkgd_color"),style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
|
||||
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ya.w+2,height:Ya.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:q||a.pref("bkgd_color"),style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
|
||||
f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")?document.getElementById("canvas_background").getAttribute("fill"):La();if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));var Ea=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(A){A?a("#url_notice").hide():a("#url_notice").show();
|
||||
ea=q});a("#image_url").show();a("#change_image_url").hide()}},qb=function(q){var A=Math.min(Math.max(12+q.value.length*6,50),300);a(q).width(A)},Ja=function(){var q=Z;if(q!=null&&!q.parentNode)q=null;var A=f.getCurrentDrawing().getCurrentLayerName(),I=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,X=I=="pathedit",ja=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&&!Aa&&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(!X&&I!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=
|
||||
|
|
|
@ -49,6 +49,35 @@ svgEditor.addExtension("eyedropper", function(S) {
|
|||
|
||||
}
|
||||
|
||||
var getPaint = function(color, opac, type) {
|
||||
// update the editor's fill paint
|
||||
var opts = null;
|
||||
if (color.indexOf("url(#") === 0) {
|
||||
var refElem = svgCanvas.getRefElem(color);
|
||||
if(refElem) {
|
||||
refElem = refElem.cloneNode(true);
|
||||
} else {
|
||||
refElem = $("#" + type + "_color defs *")[0];
|
||||
}
|
||||
|
||||
opts = { alpha: opac };
|
||||
opts[refElem.tagName] = refElem;
|
||||
}
|
||||
else if (color.indexOf("#") === 0) {
|
||||
opts = {
|
||||
alpha: opac,
|
||||
solidColor: color.substr(1)
|
||||
};
|
||||
}
|
||||
else {
|
||||
opts = {
|
||||
alpha: opac,
|
||||
solidColor: 'none'
|
||||
};
|
||||
}
|
||||
return new $.jGraduate.Paint(opts);
|
||||
};
|
||||
|
||||
return {
|
||||
name: "eyedropper",
|
||||
svgicons: "extensions/eyedropper-icon.xml",
|
||||
|
@ -101,6 +130,12 @@ svgEditor.addExtension("eyedropper", function(S) {
|
|||
if (currentStyle.strokeLinecap) change(opts.selectedElements[0], "stroke-linecap", currentStyle.strokeLinecap);
|
||||
if (currentStyle.strokeLinejoin) change(opts.selectedElements[0], "stroke-linejoin", currentStyle.strokeLinejoin);
|
||||
|
||||
var fill = getPaint(currentStyle.fillPaint, currentStyle.fillOpacity*100, "fill")
|
||||
var stroke = getPaint(currentStyle.strokePaint, currentStyle.strokeOpacity*100, "stroke")
|
||||
|
||||
svgCanvas.setPaint("fill", fill)
|
||||
svgCanvas.setPaint("stroke", stroke)
|
||||
|
||||
addToHistory(new ChangeElementCommand(target, changes));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1402,10 +1402,10 @@
|
|||
cur_shape = svgCanvas.addSvgElementFromJson({
|
||||
"element": "rect",
|
||||
"attr": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": res.w,
|
||||
"height": res.h,
|
||||
"x": -1,
|
||||
"y": -1,
|
||||
"width": res.w+2,
|
||||
"height": res.h+2,
|
||||
"stroke": "none",
|
||||
"id": "canvas_background",
|
||||
"opacity": 1,
|
||||
|
|
|
@ -6711,8 +6711,8 @@ this.setResolution = function(x, y) {
|
|||
if (background) {
|
||||
background.setAttribute("x", -1)
|
||||
background.setAttribute("y", -1)
|
||||
background.setAttribute("width", x+1)
|
||||
background.setAttribute("height", y+1)
|
||||
background.setAttribute("width", x+2)
|
||||
background.setAttribute("height", y+2)
|
||||
}
|
||||
call("changed", [svgcontent]);
|
||||
}
|
||||
|
@ -7025,7 +7025,6 @@ this.setPaint = function(type, paint) {
|
|||
// make a copy
|
||||
var p = new $.jGraduate.Paint(paint);
|
||||
this.setPaintOpacity(type, p.alpha/100, true);
|
||||
|
||||
// now set the current paint object
|
||||
cur_properties[type + '_paint'] = p;
|
||||
switch ( p.type ) {
|
||||
|
@ -7037,7 +7036,7 @@ this.setPaint = function(type, paint) {
|
|||
else {
|
||||
this.setColor(type, "none");
|
||||
var selector = (type == "fill") ? "#fill_color rect" : "#stroke_color rect"
|
||||
document.querySelector(selector).setAttribute('fill', 'transparent');
|
||||
document.querySelector(selector).setAttribute('fill', 'none');
|
||||
}
|
||||
break;
|
||||
case "linearGradient":
|
||||
|
|
|
@ -335,13 +335,13 @@ this.setUiStrings=function(g){$.extend(Cb,g.notification)};this.setConfig=functi
|
|||
g}else{k=d.createElementNS(c,"title");k.textContent=g;$(h).prepend(k);v.addSubCommand(new Na(k))}else{v.addSubCommand(new Sa(k[0],k.nextSibling,h));k.remove()}Ia(v)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(g){for(var h=l.childNodes,k=false,v="",s=new Oa("Change Image Title"),E=0;E<h.length;E++)if(h[E].nodeName=="title"){k=h[E];v=k.textContent;break}if(!k){k=d.createElementNS(c,"title");l.insertBefore(k,l.firstChild)}if(g.length)k.textContent=g;else k.parentNode.removeChild(k);
|
||||
s.addSubCommand(new Wa(k,{"#text":v}));Ia(s)};this.getEditorNS=function(g){g&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(g,h){var k=Vb(),v=k.w;k=k.h;var s;if(g=="fit"){var E=getStrokedBBox();if(E){s=new Oa("Fit Canvas to Content");var z=Hb();Fb(z);var t=[],C=[];$.each(z,function(){t.push(E.x*-1);C.push(E.y*-1)});z=b.moveSelectedElements(t,C,true);s.addSubCommand(z);$a();g=Math.round(E.width);h=Math.round(E.height)}else return false}if(g!=
|
||||
v||h!=k){z=e.suspendRedraw(1E3);s||(s=new Oa("Change Image Dimensions"));g=ra("width",g);h=ra("height",h);l.setAttribute("width",g);l.setAttribute("height",h);this.contentW=g;this.contentH=h;s.addSubCommand(new Wa(l,{width:v,height:k}));l.setAttribute("viewBox",[0,0,g/p,h/p].join(" "));s.addSubCommand(new Wa(l,{viewBox:["0 0",v,k].join(" ")}));Ia(s);e.unsuspendRedraw(z);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",
|
||||
g+1);background.setAttribute("height",h+1)}K("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,s=function(E){if(!E)return false;var z=Math.min(Math.round(h/E.width*100*v)/100,Math.round(k/E.height*100*v)/100);b.setZoom(z);return{zoom:z,bbox:E}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:p*g.factor);return{zoom:p,bbox:g}}return s(g)}switch(g){case "selection":if(!J[0])return;g=$.map(J,function(E){if(E)return E});
|
||||
g+2);background.setAttribute("height",h+2)}K("changed",[l])}return true};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(g,h,k){var v=0.85,s=function(E){if(!E)return false;var z=Math.min(Math.round(h/E.width*100*v)/100,Math.round(k/E.height*100*v)/100);b.setZoom(z);return{zoom:z,bbox:E}};if(typeof g=="object"){g=g;if(g.width==0||g.height==0){b.setZoom(g.zoom?g.zoom:p*g.factor);return{zoom:p,bbox:g}}return s(g)}switch(g){case "selection":if(!J[0])return;g=$.map(J,function(E){if(E)return E});
|
||||
g=getStrokedBBox(g);break;case "canvas":g=Vb();v=0.95;g={width:g.w,height:g.h,x:0,y:0};break;case "content":g=getStrokedBBox();break;case "layer":g=getStrokedBBox(Hb(w().getCurrentLayer()));break;default:return}return s(g)};this.setZoom=function(g){var h=Vb();l.setAttribute("viewBox","0 0 "+h.w/g+" "+h.h/g);p=g;$.each(J,function(k,v){v&&Qa.requestSelector(v).resize()});Ua.zoomChange();sb("zoomChanged",g)};this.getMode=function(){return Ma};this.setMode=function(g){Ua.clear(true);gb.clear();$("#workarea").attr("class",
|
||||
g);ib=J[0]&&J[0].nodeName=="text"?fb:M;Ma=g};this.getColor=function(g){return ib[g]};this.setColor=function(g,h,k){M[g]=h;ib[g+"_paint"]={type:"solidColor"};for(var v=[],s=J.length;s--;){var E=J[s];if(E)if(E.tagName=="g")svgedit.utilities.walkTree(E,function(z){z.nodeName!="g"&&v.push(z)});else if(g=="fill")E.tagName!="polyline"&&E.tagName!="line"&&v.push(E);else v.push(E)}if(v.length>0)if(k)Wb(g,h,v);else{db(g,h,v);K("changed",v)}};var vb=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},kc=this.setGradient=function(g){if(!(!ib[g+"_paint"]||ib[g+"_paint"].type=="solidColor")){var h=b[g+"Grad"],k=jc(h),v=vb();if(k)h=k;else{h=v.appendChild(d.importNode(h,true));h.id=na()}b.setColor(g,"url(#"+h.id+")");if(g=="canvas")(g=document.getElementById("canvas_background"))&&g.setAttribute("fill","url(#"+h.id+")")}},jc=function(g){var h=vb();h=$(h).find("linearGradient, radialGradient");
|
||||
for(var k=h.length,v=["r","cx","cy","fx","fy"];k--;){var s=h[k];if(g.tagName=="linearGradient"){if(g.getAttribute("x1")!=s.getAttribute("x1")||g.getAttribute("y1")!=s.getAttribute("y1")||g.getAttribute("x2")!=s.getAttribute("x2")||g.getAttribute("y2")!=s.getAttribute("y2"))continue}else{var E=$(g).attr(v),z=$(s).attr(v),t=false;$.each(v,function(G,P){if(E[P]!=z[P])t=true});if(t)continue}var C=g.getElementsByTagNameNS(c,"stop"),F=s.getElementsByTagNameNS(c,"stop");if(C.length==F.length){for(var B=
|
||||
C.length;B--;){var D=C[B],H=F[B];if(D.getAttribute("offset")!=H.getAttribute("offset")||D.getAttribute("stop-opacity")!=H.getAttribute("stop-opacity")||D.getAttribute("stop-color")!=H.getAttribute("stop-color"))break}if(B==-1)return s}}return null};this.setPaint=function(g,h){var k=new $.jGraduate.Paint(h);this.setPaintOpacity(g,k.alpha/100,true);ib[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","transparent")}break;case "linearGradient":case "radialGradient":b[g+"Grad"]=k[k.type];kc(g)}};this.getStrokeWidth=function(){return ib.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Ma)>=0)b.setStrokeWidth(1);else{ib.stroke_width=g;for(var h=[],k=J.length;k--;){var v=J[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(s){s.nodeName!="g"&&h.push(s)}):h.push(v)}if(h.length>
|
||||
"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];kc(g)}};this.getStrokeWidth=function(){return ib.stroke_width};this.setStrokeWidth=function(g){if(g==0&&["line","path"].indexOf(Ma)>=0)b.setStrokeWidth(1);else{ib.stroke_width=g;for(var h=[],k=J.length;k--;){var v=J[k];if(v)v.tagName=="g"?svgedit.utilities.walkTree(v,function(s){s.nodeName!="g"&&h.push(s)}):h.push(v)}if(h.length>
|
||||
0){db("stroke-width",g,h);K("changed",J)}}};this.setStrokeAttr=function(g,h){M[g.replace("-","_")]=h;for(var k=[],v=J.length;v--;){var s=J[v];if(s)s.tagName=="g"?svgedit.utilities.walkTree(s,function(E){E.nodeName!="g"&&k.push(E)}):k.push(s)}if(k.length>0){db(g,h,k);K("changed",J)}};this.getStyle=function(){return M};this.getOpacity=function(){return M.opacity};this.setOpacity=function(g){M.opacity=g;db("opacity",g)};this.getFillOpacity=function(){return M.fill_opacity};this.getStrokeOpacity=function(){return M.stroke_opacity};
|
||||
this.setPaintOpacity=function(g,h,k){M[g+"_opacity"]=h;k?Wb(g+"-opacity",h):db(g+"-opacity",h)};this.getBlur=function(g){var h=0;if(g)if(g.getAttribute("filter"))if(g=la(g.id+"_blur"))h=g.firstChild.getAttribute("stdDeviation");return h};(function(){function g(){var s=b.undoMgr.finishUndoableChange();h.addSubCommand(s);Ia(h);k=h=null}var h=null,k=null,v=false;b.setBlurNoUndo=function(s){if(k)if(s===0){Wb("filter","");v=true}else{var E=J[0];v&&Wb("filter","url(#"+E.id+"_blur)");if(svgedit.browser.isWebkit()){E.removeAttribute("filter");
|
||||
E.setAttribute("filter","url(#"+E.id+"_blur)")}Wb("stdDeviation",s,[k.firstChild]);b.setBlurOffsets(k,s)}else b.setBlur(s)};b.setBlurOffsets=function(s,E){if(E>3)oa(s,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){s.removeAttribute("x");s.removeAttribute("y");s.removeAttribute("width");s.removeAttribute("height")}};b.setBlur=function(s,E){if(h)g();else{var z=J[0],t=z.id;k=la(t+"_blur");s-=0;var C=new Oa;if(k){if(s===0)k=null}else{var F=da({element:"feGaussianBlur",
|
||||
|
@ -406,7 +406,7 @@ q/2,y:A.y*q+A.height*q/2});f.getMode()=="zoom"&&A.width&&oa();B()}}};a("#cur_con
|
|||
a(this).mouseup(Ca);Ba.key&&a(document).bind("keydown",Ba.key[0]+" shift+"+Ba.key[0],Ca)});if(va)ja.attr("data-curopt",I[va].sel);else ja.attr("data-curopt")||ja.attr("data-curopt",I[0].sel);var ya,Da=a(X).position();a(A).css({left:Da.left+34,top:Da.top+77});ja.mousedown(function(Ca){a("#tools_shapelib").is(":visible")&&xa(X,false);if(ja.hasClass("disabled"))return false;var Ba=a(A),tb=Da.left+34,Ta=Ba.width()*-1,ia=Ba.data("shown_popop")?200:0;ya=setTimeout(function(){ja.data("isLibrary")?Ba.css("left",
|
||||
tb).show():Ba.css("left",Ta).show().animate({left:tb},150);Ba.data("shown_popop",true)},ia);Ca.preventDefault()}).mouseup(function(){clearTimeout(ya);var Ca=a(this).attr("data-curopt");if(ja.data("isLibrary")&&a(X.replace("_show","")).is(":visible"))xa(X,true);else xa(X)&&Ca in Ia&&Ia[Ca]()})});Kb()},Ga=function(q,A){return a("<div>",{"class":"tools_flyout",id:q}).appendTo("#svg_editor").append(A)},Cb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show"),A=q.offset();q=q.outerWidth();
|
||||
a(this).css({left:(A.left+q)*S,top:A.top})})},Kb=function(){a(".tools_flyout").each(function(){var q=a("#"+this.id+"_show");if(!q.data("isLibrary")){var A=[];a(this).children().each(function(){A.push(this.title)});q[0].title=A.join(" / ")}})},nb,ab=function(q,A,I){var R=null;if(q.indexOf("url(#")===0){q=(q=f.getRefElem(q))?q.cloneNode(true):a("#"+I+"_color defs *")[0];R={alpha:A};R[q.tagName]=q}else R=q.indexOf("#")===0?{alpha:A,solidColor:q.substr(1)}:{alpha:A,solidColor:"none"};return new a.jGraduate.Paint(R)},
|
||||
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:0,y:0,width:Ya.w,height:Ya.h,stroke:"none",id:"canvas_background",opacity:1,fill:q||a.pref("bkgd_color"),style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
|
||||
Ya=f.getResolution();if(d.baseUnit!=="px"){Ya.w=svgedit.units.convertUnit(Ya.w)+d.baseUnit;Ya.h=svgedit.units.convertUnit(Ya.h)+d.baseUnit}a(".canvas_width").val(Ya.w);a(".canvas_height").val(Ya.h);a("#docprops_button").on("click",function(){H()});var La=function(q){f.createLayer("background");cur_shape=f.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ya.w+2,height:Ya.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:q||a.pref("bkgd_color"),style:"pointer-events:none"}});f.setCurrentLayer("Layer 1");
|
||||
f.setCurrentLayerPosition("1")};document.getElementById("canvas_background")?document.getElementById("canvas_background").getAttribute("fill"):La();if(a.pref("bkgd_color"))p(a.pref("bkgd_color"),a.pref("bkgd_url"));else a.pref("bkgd_url")&&p(o.bkgd_color,a.pref("bkgd_url"));var Ea=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(A){A?a("#url_notice").hide():a("#url_notice").show();
|
||||
ea=q});a("#image_url").show();a("#change_image_url").hide()}},qb=function(q){var A=Math.min(Math.max(12+q.value.length*6,50),300);a(q).width(A)},Ja=function(){var q=Z;if(q!=null&&!q.parentNode)q=null;var A=f.getCurrentDrawing().getCurrentLayerName(),I=f.getMode(),R=d.baseUnit!=="px"?d.baseUnit:null,X=I=="pathedit",ja=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&&!Aa&&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(!X&&I!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");if(["line","circle","ellipse"].indexOf(va)>=
|
||||
|
|
Loading…
Reference in New Issue