cleanup
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@50 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
d346bd02ee
commit
47603917c9
2
CHANGES
2
CHANGES
|
@ -7,6 +7,8 @@
|
|||
* fix flyouts when using color picker
|
||||
* change license from GPLv2 to Apache License v2.0
|
||||
* replaced Farbtastic with jPicker, because of the license issues
|
||||
* removed dependency on svgcanvas.svg, now created in JavaScript
|
||||
* added Select tool
|
||||
|
||||
2.0 - June 03, 2009
|
||||
------------------
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
|
||||
#tools {
|
||||
background: #E8E8E8;
|
||||
height: 534px;
|
||||
height: 580px;
|
||||
border: 1px solid #808080;
|
||||
padding: 4px;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,17 @@ var palette = ["#000000","#202020","#404040","#606060","#808080","#a0a0a0","#c0c
|
|||
|
||||
$(document).ready(function(){
|
||||
var svgCanvas = new SvgCanvas(document.getElementById("svgcanvas"));
|
||||
|
||||
|
||||
var selectedChanged = function(window,elem) {
|
||||
if (elem != null) {
|
||||
|
||||
|
||||
// update fill color
|
||||
var fillColor = elem.getAttribute("fill");
|
||||
if (fillColor == null || fillColor == "" || fillColor == "none") {
|
||||
fillColor = 'url(\'images/none.png\')';
|
||||
}
|
||||
$('#fill_color').css('background', fillColor);
|
||||
|
||||
|
||||
// update stroke color
|
||||
var strokeColor = elem.getAttribute("stroke");
|
||||
if (strokeColor == null || strokeColor == "" || strokeColor == "none") {
|
||||
|
@ -20,7 +20,7 @@ $(document).ready(function(){
|
|||
}
|
||||
$('#stroke_color').css('background', strokeColor);
|
||||
|
||||
// update fill opacity
|
||||
// update fill opacity
|
||||
var fillOpacity = elem.getAttribute("fill-opacity");
|
||||
if (fillOpacity == null || fillColor == "") {
|
||||
fillOpacity = 1.0;
|
||||
|
@ -28,14 +28,22 @@ $(document).ready(function(){
|
|||
fillOpacity = (fillOpacity*100)+" %";
|
||||
$('#fill_opacity').val(fillOpacity);
|
||||
|
||||
// update stroke opacity
|
||||
// update stroke opacity
|
||||
var strokeOpacity = elem.getAttribute("stroke-opacity");
|
||||
if (strokeOpacity == null || strokeOpacity == "") {
|
||||
strokeOpacity = 1.0;
|
||||
}
|
||||
strokeOpacity = (strokeOpacity*100)+" %";
|
||||
$('#stroke_opacity').val(strokeOpacity);
|
||||
|
||||
|
||||
// update group opacity
|
||||
var opacity = elem.getAttribute("opacity");
|
||||
if (opacity == null || opacity == "") {
|
||||
opacity = 1.0;
|
||||
}
|
||||
opacity = (opacity*100)+" %";
|
||||
$('#group_opacity').val(opacity);
|
||||
|
||||
var strokeWidth = elem.getAttribute("stroke-width");
|
||||
if (strokeWidth == null || strokeWidth == "") {
|
||||
strokeWidth = 1;
|
||||
|
@ -49,7 +57,7 @@ $(document).ready(function(){
|
|||
$('#stroke_dasharray').val(strokeDashArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// bind the selected event to our function that handles updates to the UI
|
||||
svgCanvas.bind("selected", selectedChanged);
|
||||
|
||||
|
@ -105,7 +113,7 @@ $(document).ready(function(){
|
|||
}
|
||||
svgCanvas.setStrokeColor(color);
|
||||
});
|
||||
|
||||
|
||||
// This is a common function used when a tool has been clicked (chosen)
|
||||
// It does several common things:
|
||||
// - hides any flyout menus
|
||||
|
|
|
@ -9,9 +9,9 @@ function SvgCanvas(c)
|
|||
|
||||
var svgdoc = c.ownerDocument;
|
||||
var svgroot = svgdoc.createElementNS(svgns, "svg");
|
||||
svgroot.setAttribute("width",640);
|
||||
svgroot.setAttribute("height",480);
|
||||
svgroot.setAttributeNS(null,"id","svgroot");
|
||||
svgroot.setAttribute("width", 640);
|
||||
svgroot.setAttribute("height", 480);
|
||||
svgroot.setAttributeNS(null, "id", "svgroot");
|
||||
container.appendChild(svgroot);
|
||||
|
||||
var d_attr = null;
|
||||
|
@ -84,17 +84,10 @@ function SvgCanvas(c)
|
|||
var attr;
|
||||
var i;
|
||||
var childs = elem.childNodes;
|
||||
// don't include scripts in output svg
|
||||
if (elem.nodeName == "script") return "";
|
||||
for (i=0; i<indent; i++) out += " ";
|
||||
out += "<" + elem.nodeName;
|
||||
for (i=attrs.length-1; i>=0; i--) {
|
||||
attr = attrs.item(i);
|
||||
// don't include events in output svg
|
||||
if (attr.nodeName == "onload" ||
|
||||
attr.nodeName == "onmousedown" ||
|
||||
attr.nodeName == "onmousemove" ||
|
||||
attr.nodeName == "onmouseup") continue;
|
||||
out += " " + attr.nodeName + "=\"" + attr.nodeValue+ "\"";
|
||||
}
|
||||
if (elem.hasChildNodes()) {
|
||||
|
@ -307,7 +300,7 @@ function SvgCanvas(c)
|
|||
shape.setAttributeNS(null, "x", start_x < x ? start_x : start_x - size);
|
||||
shape.setAttributeNS(null, "y", start_y < y ? start_y : start_y - size);
|
||||
break;
|
||||
case "select":
|
||||
// case "select":
|
||||
case "rect":
|
||||
shape.setAttributeNS(null, "x", Math.min(start_x,x));
|
||||
shape.setAttributeNS(null, "y", Math.min(start_y,y));
|
||||
|
@ -349,6 +342,7 @@ function SvgCanvas(c)
|
|||
var keep = false;
|
||||
switch (current_mode)
|
||||
{
|
||||
/*
|
||||
case "select":
|
||||
if (element.getAttribute('width') == 0 &&
|
||||
element.getAttribute('height') == 0) {
|
||||
|
@ -359,24 +353,25 @@ function SvgCanvas(c)
|
|||
// should scan elements which are in rect(x,y,width,height) and select them
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case "path":
|
||||
keep = true;
|
||||
break;
|
||||
case "line":
|
||||
keep = (element.getAttribute('x1') != element.getAttribute('x2') ||
|
||||
element.getAttribute('y1') == element.getAttribute('y2'));
|
||||
element.getAttribute('y1') == element.getAttribute('y2'));
|
||||
break;
|
||||
case "square":
|
||||
case "rect":
|
||||
keep = (element.getAttribute('width') != 0 ||
|
||||
element.getAttribute('height') != 0);
|
||||
element.getAttribute('height') != 0);
|
||||
break;
|
||||
case "circle":
|
||||
keep = (element.getAttribute('r') != 0);
|
||||
break;
|
||||
case "ellipse":
|
||||
keep = (element.getAttribute('rx') != 0 ||
|
||||
element.getAttribute('ry') != 0);
|
||||
element.getAttribute('ry') != 0);
|
||||
break;
|
||||
case "fhellipse":
|
||||
if ((freehand_max_x - freehand_min_x) > 0 &&
|
||||
|
@ -439,7 +434,7 @@ function SvgCanvas(c)
|
|||
|
||||
this.save = function() {
|
||||
// remove the selected outline before serializing
|
||||
this.selectElement(null);
|
||||
this.selectNone();
|
||||
var str = "<?xml version=\"1.0\" standalone=\"no\"?>\n"
|
||||
str += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
||||
str += svgToString(svgroot, 0);
|
||||
|
@ -450,7 +445,7 @@ function SvgCanvas(c)
|
|||
var nodes = svgroot.childNodes;
|
||||
var len = svgroot.childNodes.length;
|
||||
var i = 0;
|
||||
this.setSelected(null);
|
||||
this.selectNone();
|
||||
for(var rep = 0; rep < len; rep++){
|
||||
if (nodes[i].nodeType == 1) { // element node
|
||||
nodes[i].parentNode.removeChild(nodes[i]);
|
||||
|
@ -522,6 +517,10 @@ function SvgCanvas(c)
|
|||
|
||||
this.setOpacity = function(val) {
|
||||
current_opacity = val;
|
||||
if (selected != null) {
|
||||
selected.setAttribute("opacity", val);
|
||||
call("changed", selected);
|
||||
}
|
||||
}
|
||||
|
||||
this.getFillOpacity = function() {
|
||||
|
@ -559,7 +558,7 @@ function SvgCanvas(c)
|
|||
this.saveHandler = function(svg) {
|
||||
alert(svg);
|
||||
}
|
||||
|
||||
|
||||
this.selectNone = function() {
|
||||
selectElement(null);
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xml:space="preserve" id="svg_image" onload="svgCanvasInit(evt)" width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<script xlink:href="svgcanvas.js" type="text/ecmascript"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 392 B |
Loading…
Reference in New Issue