cleaned inconsistencies with comma spacing

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2396 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Bruno Heridet 2013-02-15 16:51:48 +00:00
parent c446a7185f
commit 3d61d46f6b
11 changed files with 201 additions and 196 deletions

View File

@ -126,7 +126,7 @@ var supportsEditableText_ = (function() {
var supportsGoodDecimals_ = (function() { var supportsGoodDecimals_ = (function() {
// Correct decimals on clone attributes (Opera < 10.5/win/non-en) // Correct decimals on clone attributes (Opera < 10.5/win/non-en)
var rect = document.createElementNS(svgns, 'rect'); var rect = document.createElementNS(svgns, 'rect');
rect.setAttribute('x',.1); rect.setAttribute('x', 0.1);
var crect = rect.cloneNode(false); var crect = rect.cloneNode(false);
var retValue = (crect.getAttribute('x').indexOf(',') == -1); var retValue = (crect.getAttribute('x').indexOf(',') == -1);
if(!retValue) { if(!retValue) {

View File

@ -142,10 +142,9 @@ svgedit.draw.Drawing.prototype.getElem_ = function(id) {
if(this.svgElem_.querySelector) { if(this.svgElem_.querySelector) {
// querySelector lookup // querySelector lookup
return this.svgElem_.querySelector('#'+id); return this.svgElem_.querySelector('#'+id);
} else { }
// jQuery lookup: twice as slow as xpath in FF // jQuery lookup: twice as slow as xpath in FF
return $(this.svgElem_).find('[id=' + id + ']')[0]; return $(this.svgElem_).find('[id=' + id + ']')[0];
}
}; };
svgedit.draw.Drawing.prototype.getSvgElem = function() { svgedit.draw.Drawing.prototype.getSvgElem = function() {

View File

@ -530,8 +530,7 @@ svgedit.path.Segment.prototype.moveCtrl = function(num, dx, dy) {
item['x' + num] += dx; item['x' + num] += dx;
item['y' + num] += dy; item['y' + num] += dy;
var pts = [item.x,item.y, var pts = [item.x, item.y, item.x1, item.y1, item.x2, item.y2];
item.x1,item.y1, item.x2,item.y2];
svgedit.path.replacePathSeg(this.type, this.index, pts); svgedit.path.replacePathSeg(this.type, this.index, pts);
this.update(true); this.update(true);

View File

@ -34,7 +34,6 @@ if (window.opera) {
} }
(function() { (function() {
// This fixes $(...).attr() to work as expected with SVG elements. // This fixes $(...).attr() to work as expected with SVG elements.
// Does not currently use *AttributeNS() since we rarely need that. // Does not currently use *AttributeNS() since we rarely need that.
@ -45,7 +44,8 @@ if (window.opera) {
// - If an array is supplied as first parameter, multiple values are returned // - If an array is supplied as first parameter, multiple values are returned
// as an object with values for each given attributes // as an object with values for each given attributes
var proxied = jQuery.fn.attr, svgns = "http://www.w3.org/2000/svg"; var proxied = jQuery.fn.attr,
svgns = "http://www.w3.org/2000/svg";
jQuery.fn.attr = function(key, value) { jQuery.fn.attr = function(key, value) {
var len = this.length; var len = this.length;
if (!len) return proxied.apply(this, arguments); if (!len) return proxied.apply(this, arguments);
@ -58,7 +58,8 @@ if (window.opera) {
elem.setAttribute(key, value); elem.setAttribute(key, value);
} else if ($.isArray(key)) { } else if ($.isArray(key)) {
// Getting attributes from array // Getting attributes from array
var j = key.length, obj = {}; var j = key.length,
obj = {};
while (j--) { while (j--) {
var aname = key[j]; var aname = key[j];
@ -424,8 +425,7 @@ svgedit.utilities.snapToGrid = function(value){
if (unit !== "px") { if (unit !== "px") {
stepSize *= svgedit.units.getTypeMap()[unit]; stepSize *= svgedit.units.getTypeMap()[unit];
} }
value = Math.round(value/stepSize)*stepSize; return Math.round(value/stepSize)*stepSize;
return value;
}; };
var snapToGrid = svgedit.utilities.snapToGrid; var snapToGrid = svgedit.utilities.snapToGrid;
@ -544,8 +544,7 @@ canvas.clipBoard = [];
// Should this return an array by default, so extension results aren't overwritten? // Should this return an array by default, so extension results aren't overwritten?
var runExtensions = this.runExtensions = function(action, vars, returnArray) { var runExtensions = this.runExtensions = function(action, vars, returnArray) {
var result = false; var result = returnArray ? [] : false;
if (returnArray) result = [];
$.each(extensions, function(name, opts) { $.each(extensions, function(name, opts) {
if (action in opts) { if (action in opts) {
if (returnArray) { if (returnArray) {
@ -567,7 +566,6 @@ var runExtensions = this.runExtensions = function(action, vars, returnArray) {
this.addExtension = function(name, ext_func) { this.addExtension = function(name, ext_func) {
if (!(name in extensions)) { if (!(name in extensions)) {
// Provide private vars/funcs here. Is there a better way to do this? // Provide private vars/funcs here. Is there a better way to do this?
if ($.isFunction(ext_func)) { if ($.isFunction(ext_func)) {
var ext = ext_func($.extend(canvas.getPrivateMethods(), { var ext = ext_func($.extend(canvas.getPrivateMethods(), {
svgroot: svgroot, svgroot: svgroot,
@ -664,8 +662,8 @@ getStrokedBBox = this.getStrokedBBox = function(elems) {
// in Issue 339 comment #2). // in Issue 339 comment #2).
var bb = svgedit.utilities.getBBox(elem); var bb = svgedit.utilities.getBBox(elem);
var angle = svgedit.utilities.getRotationAngle(elem); var angle = svgedit.utilities.getRotationAngle(elem);
if ((angle && angle % 90) || if ((angle && angle % 90) ||
svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) { svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) {
// Accurate way to get BBox of rotated element in Firefox: // Accurate way to get BBox of rotated element in Firefox:
@ -1131,7 +1129,6 @@ var remapElement = this.remapElement = function(selected,changes,m) {
} }
} }
var elName = selected.tagName; var elName = selected.tagName;
if (elName === "g" || elName === "text" || elName == "tspan" || elName === "use") { if (elName === "g" || elName === "text" || elName == "tspan" || elName === "use") {
// if it was a translate, then just update x,y // if it was a translate, then just update x,y
@ -1170,8 +1167,7 @@ var remapElement = this.remapElement = function(selected,changes,m) {
// now we have a set of changes and an applied reduced transform list // now we have a set of changes and an applied reduced transform list
// we apply the changes directly to the DOM // we apply the changes directly to the DOM
switch (elName) switch (elName) {
{
case "foreignObject": case "foreignObject":
case "rect": case "rect":
case "image": case "image":
@ -1782,7 +1778,6 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
} }
clipPaths_done = []; clipPaths_done = [];
start_transform = old_start_transform; start_transform = old_start_transform;
} }
} }
@ -2251,8 +2246,7 @@ var removeFromSelection = this.removeFromSelection = function(elemsToRemove) {
if (elemsToRemove.indexOf(elem) == -1) { if (elemsToRemove.indexOf(elem) == -1) {
newSelectedItems[j] = elem; newSelectedItems[j] = elem;
j++; j++;
} } else { // remove the item and its selector
else { // remove the item and its selector
selectorManager.releaseSelector(elem); selectorManager.releaseSelector(elem);
} }
} }
@ -2600,7 +2594,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
case "fhellipse": case "fhellipse":
case "fhrect": case "fhrect":
case "fhpath": case "fhpath":
start.x=real_x; start.y=real_y; start.x = real_x;
start.y = real_y;
started = true; started = true;
d_attr = real_x + "," + real_y + " "; d_attr = real_x + "," + real_y + " ";
var stroke_w = cur_shape.stroke_width == 0 ? 1 : cur_shape.stroke_width; var stroke_w = cur_shape.stroke_width == 0 ? 1 : cur_shape.stroke_width;
@ -2792,8 +2787,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
evt.preventDefault(); evt.preventDefault();
switch (current_mode) switch (current_mode) {
{
case "select": case "select":
// we temporarily use a translate on the element(s) being dragged // we temporarily use a translate on the element(s) being dragged
// this transform is removed upon mousing up and the element is // this transform is removed upon mousing up and the element is
@ -2807,7 +2801,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
dy = snapToGrid(dy); dy = snapToGrid(dy);
} }
if (evt.shiftKey) { var xya = svgedit.math.snapToAngle(start_x,start_y,x,y); x=xya.x; y=xya.y; } if (evt.shiftKey) {
var xya = svgedit.math.snapToAngle(start_x, start_y, x, y);
x = xya.x;
y = xya.y;
}
if (dx != 0 || dy != 0) { if (dx != 0 || dy != 0) {
var len = selectedElements.length; var len = selectedElements.length;
@ -2997,7 +2995,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
var x2 = x; var x2 = x;
var y2 = y; var y2 = y;
if (evt.shiftKey) { var xya = svgedit.math.snapToAngle(start_x,start_y,x2,y2); x2=xya.x; y2=xya.y; } if (evt.shiftKey) {
var xya = svgedit.math.snapToAngle(start_x, start_y, x2, y2);
x2 = xya.x;
y2 = xya.y;
}
shape.setAttributeNS(null, "x2", x2); shape.setAttributeNS(null, "x2", x2);
shape.setAttributeNS(null, "y2", y2); shape.setAttributeNS(null, "y2", y2);
@ -3117,7 +3119,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
var y1 = start_y; var y1 = start_y;
} }
var xya = svgedit.math.snapToAngle(x1, y1, x, y); var xya = svgedit.math.snapToAngle(x1, y1, x, y);
x=xya.x; y=xya.y; x = xya.x;
y = xya.y;
} }
if (rubberBox && rubberBox.getAttribute('display') !== 'none') { if (rubberBox && rubberBox.getAttribute('display') !== 'none') {
@ -4250,7 +4253,11 @@ var pathActions = canvas.pathActions = function() {
var last = drawn_path.pathSegList.getItem(num -1); var last = drawn_path.pathSegList.getItem(num -1);
var lastx = last.x, lasty = last.y; var lastx = last.x, lasty = last.y;
if (evt.shiftKey) { var xya = svgedit.math.snapToAngle(lastx,lasty,x,y); x=xya.x; y=xya.y; } if (evt.shiftKey) {
var xya = svgedit.math.snapToAngle(lastx, lasty, x, y);
x = xya.x;
y = xya.y;
}
// Use the segment defined by stretchy // Use the segment defined by stretchy
var s_seg = stretchy.pathSegList.getItem(1); var s_seg = stretchy.pathSegList.getItem(1);
@ -4845,7 +4852,8 @@ var pathActions = canvas.pathActions = function() {
// TODO: Find right way to select point now // TODO: Find right way to select point now
// path.selectPt(sel_pt); // path.selectPt(sel_pt);
if (window.opera) { // Opera repaints incorrectly if (window.opera) { // Opera repaints incorrectly
var cp = $(svgedit.path.path.elem); cp.attr('d',cp.attr('d')); var cp = $(svgedit.path.path.elem);
cp.attr('d', cp.attr('d'));
} }
svgedit.path.path.endChanges("Delete path node(s)"); svgedit.path.path.endChanges("Delete path node(s)");
}, },
@ -5295,8 +5303,7 @@ this.svgToString = function(elem, indent) {
indent++; indent++;
var bOneLine = false; var bOneLine = false;
for (var i=0; i<childs.length; i++) for (var i=0; i<childs.length; i++) {
{
var child = childs.item(i); var child = childs.item(i);
switch(child.nodeType) { switch(child.nodeType) {
case 1: // element node case 1: // element node

View File

@ -68,9 +68,9 @@ svgedit.units.init = function(elementContainer) {
var svg = document.createElementNS(svgns, 'svg'); var svg = document.createElementNS(svgns, 'svg');
document.body.appendChild(svg); document.body.appendChild(svg);
var rect = document.createElementNS(svgns, 'rect'); var rect = document.createElementNS(svgns, 'rect');
rect.setAttribute('width',"1em"); rect.setAttribute('width', '1em');
rect.setAttribute('height',"1ex"); rect.setAttribute('height', '1ex');
rect.setAttribute('x',"1in"); rect.setAttribute('x', '1in');
svg.appendChild(rect); svg.appendChild(rect);
var bb = rect.getBBox(); var bb = rect.getBBox();
document.body.removeChild(svg); document.body.removeChild(svg);