additional fix for background color

master
Mark MacKay 2012-08-15 14:30:12 -05:00
parent 9c496dcbd6
commit 05904be7c1
4 changed files with 24 additions and 22 deletions

View File

@ -2874,10 +2874,6 @@
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) {

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
w.color+'" opacity="'+w.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"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<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H==="fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,
O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(xa(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);c=b.paintBox.fill.rect.cloneNode(false);
c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);v.img_save=
"ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",
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(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);J.indexOf("url")==
-1&&O.setAttribute("fill",J)}else Ja(J);if(H){g.setColor(this.type,J,true);g.setPaintOpacity(this.type,Y,true)}};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<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H===
"fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(xa(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*
100);c=b.paintBox.fill.rect.cloneNode(false);c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);
v.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",
function(){e(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");e(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");e(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||
a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a(window).bind("load resize",function(){K.css("line-height",K.height()+"px")});var m=function(){var k=a("#canvas_width"),n=a("#canvas_height"),o=k.val(),w=n.val();if(o!="fit"&&!svgedit.units.isValidUnit("width",o)){a.alert(uiStrings.notification.invalidAttrValGiven);
k.parent().addClass("error");return false}k.parent().removeClass("error");if(w!="fit"&&!svgedit.units.isValidUnit("height",w)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");if(!g.setResolution(o,w)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();k.val(o.w);n.val(o.h);return false}G()};a("#resolution").change(function(){var k=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value==

View File

@ -2874,10 +2874,6 @@
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) {

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
w.color+'" opacity="'+w.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"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<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H==="fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,
O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(xa(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);c=b.paintBox.fill.rect.cloneNode(false);
c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);v.img_save=
"ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",
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(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);J.indexOf("url")==
-1&&O.setAttribute("fill",J)}else Ja(J);if(H){g.setColor(this.type,J,true);g.setPaintOpacity(this.type,Y,true)}};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<da;Y++){var V=O[Y].getAttribute(H);if(Y===0)J=V;else if(J!==V){J=null;break}}if(J===null){O=null;return}O=J;J=1;break;default:J=parseFloat(X.getAttribute(H+"-opacity"));if(isNaN(J))J=1;O=H===
"fill"?"black":"none";O=X.getAttribute(H)||O}if(E){g.setColor(H,O,true);g.setPaintOpacity(H,J,true)}J*=100;this.setPaint(xa(O,J,H))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var E=new a.jGraduate.Paint({copy:this.paint});g.setPaint(n,E)}}};b.paintBox.fill=new c("#fill_color","fill");b.paintBox.stroke=new c("#stroke_color","stroke");b.paintBox.canvas=new c("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*
100);c=b.paintBox.fill.rect.cloneNode(false);c.setAttribute("style","vector-effect:non-scaling-stroke");var h=c.style.vectorEffect==="non-scaling-stroke";c.removeAttribute("style");c=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");typeof c.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(c).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);
v.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))e(a("#fill_color"));else{a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))e(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",
function(){e(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");e(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");a("#tool_stroke").removeClass("active");e(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||
a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});a(window).bind("load resize",function(){K.css("line-height",K.height()+"px")});var m=function(){var k=a("#canvas_width"),n=a("#canvas_height"),o=k.val(),w=n.val();if(o!="fit"&&!svgedit.units.isValidUnit("width",o)){a.alert(uiStrings.notification.invalidAttrValGiven);
k.parent().addClass("error");return false}k.parent().removeClass("error");if(w!="fit"&&!svgedit.units.isValidUnit("height",w)){a.alert(uiStrings.notification.invalidAttrValGiven);n.parent().addClass("error");return false}n.parent().removeClass("error");if(!g.setResolution(o,w)){a.alert(uiStrings.notification.noContentToFitTo);o=g.getResolution();k.val(o.w);n.val(o.h);return false}G()};a("#resolution").change(function(){var k=a("#canvas_width")[0],n=a("#canvas_height")[0];if(this.selectedIndex)if(this.value==