From 05904be7c1bf49e274209b24ef80881b1e095892 Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Wed, 15 Aug 2012 14:30:12 -0500 Subject: [PATCH] additional fix for background color --- editor/svg-editor.js | 13 +++++++------ editor/svgedit.compiled.js | 10 +++++----- method-draw/svg-editor.js | 13 +++++++------ method-draw/svgedit.compiled.js | 10 +++++----- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 68889d7..2594d6a 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -2873,11 +2873,7 @@ } this.rect.setAttribute('fill', fillAttr); this.rect.setAttribute('opacity', opac); - - if(apply) { - svgCanvas.setColor(this.type, fillAttr, true); - svgCanvas.setPaintOpacity(this.type, opac, true); - } + if (this.type == "canvas") { //recache background in case it changed var background = document.getElementById("canvas_background"); @@ -2887,11 +2883,16 @@ background.setAttribute("y", -1); background.setAttribute("width", res.w+2); background.setAttribute("height", res.h+2); - //background.setAttribute('fill', fillAttr) + if (fillAttr.indexOf("url") == -1) background.setAttribute('fill', fillAttr) } else createBackground(fillAttr) } + if(apply) { + svgCanvas.setColor(this.type, fillAttr, true); + svgCanvas.setPaintOpacity(this.type, opac, true); + } + } this.update = function(apply) { diff --git a/editor/svgedit.compiled.js b/editor/svgedit.compiled.js index 82eb133..af2153c 100644 --- a/editor/svgedit.compiled.js +++ b/editor/svgedit.compiled.js @@ -458,11 +458,11 @@ var Db=a.noop;a(window).resize(function(){G()});(function(){K.scroll(function(){ "fill",o=k[0].id=="canvas_color";if(o)n="canvas";var w=b.paintBox[n].paint;k=n=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";o=o?{right:175,top:50}:{left:50,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).removeAttr("style").css(o).jGraduate({paint:w,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(E){w=new a.jGraduate.Paint(E);b.paintBox[n].setPaint(w); g.setPaint(n,w);a("#color_picker").hide()},function(){a("#color_picker").hide()})};c=function(k,n){var o=document.getElementById("canvas_background"),w={color:"fff",opacity:1};if(n=="stroke")w=curConfig.initStroke;if(n=="fill")w=curConfig.initFill;if(n=="canvas"&&o)if(o=o.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))w={color:("0"+parseInt(o[1],10).toString(16)).slice(-2)+("0"+parseInt(o[2],10).toString(16)).slice(-2)+("0"+parseInt(o[3],10).toString(16)).slice(-2),opacity:1};o=(new DOMParser).parseFromString('\t\t\t\t\t',"text/xml").documentElement;o=a(k)[0].appendChild(document.importNode(o,true));n==="canvas"?o.setAttribute("width",60.5):o.setAttribute("width","100%");this.rect=o.firstChild;this.defs=o.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:w.color});this.type=n;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,Y=E.alpha/100;switch(O){case "solidColor":J= -E[O]=="none"||E[O]=="one"?"none":"#"+E[O];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(E[O]);J="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",J);this.rect.setAttribute("opacity",Y);if(H){g.setColor(this.type,J,true);g.setPaintOpacity(this.type,Y,true)}if(this.type=="canvas")if(O=document.getElementById("canvas_background")){ya=g.getResolution();O.setAttribute("x",-1);O.setAttribute("y",-1);O.setAttribute("width", -ya.w+2);O.setAttribute("height",ya.h+2)}else Ja(J)};this.update=function(E){if(X){var H=this.type;switch(X.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var J=null,O=X.getElementsByTagName("*"),Y=0,da=O.length;Y\t\t\t\t\t',"text/xml").documentElement;o=a(k)[0].appendChild(document.importNode(o,true));n==="canvas"?o.setAttribute("width",60.5):o.setAttribute("width","100%");this.rect=o.firstChild;this.defs=o.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:w.color});this.type=n;this.setPaint=function(E,H){this.paint=E;var J="none",O=E.type,Y=E.alpha/100;switch(O){case "solidColor":J= -E[O]=="none"||E[O]=="one"?"none":"#"+E[O];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(E[O]);J="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",J);this.rect.setAttribute("opacity",Y);if(H){g.setColor(this.type,J,true);g.setPaintOpacity(this.type,Y,true)}if(this.type=="canvas")if(O=document.getElementById("canvas_background")){ya=g.getResolution();O.setAttribute("x",-1);O.setAttribute("y",-1);O.setAttribute("width", -ya.w+2);O.setAttribute("height",ya.h+2)}else Ja(J)};this.update=function(E){if(X){var H=this.type;switch(X.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var J=null,O=X.getElementsByTagName("*"),Y=0,da=O.length;Y