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() {
// Correct decimals on clone attributes (Opera < 10.5/win/non-en)
var rect = document.createElementNS(svgns, 'rect');
rect.setAttribute('x',.1);
rect.setAttribute('x', 0.1);
var crect = rect.cloneNode(false);
var retValue = (crect.getAttribute('x').indexOf(',') == -1);
if(!retValue) {

View File

@ -142,10 +142,9 @@ svgedit.draw.Drawing.prototype.getElem_ = function(id) {
if(this.svgElem_.querySelector) {
// querySelector lookup
return this.svgElem_.querySelector('#'+id);
} else {
}
// jQuery lookup: twice as slow as xpath in FF
return $(this.svgElem_).find('[id=' + id + ']')[0];
}
};
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['y' + num] += dy;
var pts = [item.x,item.y,
item.x1,item.y1, item.x2,item.y2];
var pts = [item.x, item.y, item.x1, item.y1, item.x2, item.y2];
svgedit.path.replacePathSeg(this.type, this.index, pts);
this.update(true);

View File

@ -34,7 +34,6 @@ if (window.opera) {
}
(function() {
// This fixes $(...).attr() to work as expected with SVG elements.
// 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
// 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) {
var len = this.length;
if (!len) return proxied.apply(this, arguments);
@ -58,7 +58,8 @@ if (window.opera) {
elem.setAttribute(key, value);
} else if ($.isArray(key)) {
// Getting attributes from array
var j = key.length, obj = {};
var j = key.length,
obj = {};
while (j--) {
var aname = key[j];
@ -424,8 +425,7 @@ svgedit.utilities.snapToGrid = function(value){
if (unit !== "px") {
stepSize *= svgedit.units.getTypeMap()[unit];
}
value = Math.round(value/stepSize)*stepSize;
return value;
return Math.round(value/stepSize)*stepSize;
};
var snapToGrid = svgedit.utilities.snapToGrid;
@ -544,8 +544,7 @@ canvas.clipBoard = [];
// Should this return an array by default, so extension results aren't overwritten?
var runExtensions = this.runExtensions = function(action, vars, returnArray) {
var result = false;
if (returnArray) result = [];
var result = returnArray ? [] : false;
$.each(extensions, function(name, opts) {
if (action in opts) {
if (returnArray) {
@ -567,7 +566,6 @@ var runExtensions = this.runExtensions = function(action, vars, returnArray) {
this.addExtension = function(name, ext_func) {
if (!(name in extensions)) {
// Provide private vars/funcs here. Is there a better way to do this?
if ($.isFunction(ext_func)) {
var ext = ext_func($.extend(canvas.getPrivateMethods(), {
svgroot: svgroot,
@ -664,8 +662,8 @@ getStrokedBBox = this.getStrokedBBox = function(elems) {
// in Issue 339 comment #2).
var bb = svgedit.utilities.getBBox(elem);
var angle = svgedit.utilities.getRotationAngle(elem);
if ((angle && angle % 90) ||
svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) {
// 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;
if (elName === "g" || elName === "text" || elName == "tspan" || elName === "use") {
// 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
// we apply the changes directly to the DOM
switch (elName)
{
switch (elName) {
case "foreignObject":
case "rect":
case "image":
@ -1782,7 +1778,6 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
}
clipPaths_done = [];
start_transform = old_start_transform;
}
}
@ -2251,8 +2246,7 @@ var removeFromSelection = this.removeFromSelection = function(elemsToRemove) {
if (elemsToRemove.indexOf(elem) == -1) {
newSelectedItems[j] = elem;
j++;
}
else { // remove the item and its selector
} else { // remove the item and its selector
selectorManager.releaseSelector(elem);
}
}
@ -2600,7 +2594,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
case "fhellipse":
case "fhrect":
case "fhpath":
start.x=real_x; start.y=real_y;
start.x = real_x;
start.y = real_y;
started = true;
d_attr = real_x + "," + real_y + " ";
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();
switch (current_mode)
{
switch (current_mode) {
case "select":
// we temporarily use a translate on the element(s) being dragged
// this transform is removed upon mousing up and the element is
@ -2807,7 +2801,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
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) {
var len = selectedElements.length;
@ -2997,7 +2995,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
var x2 = x;
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, "y2", y2);
@ -3117,7 +3119,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
var y1 = start_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') {
@ -4250,7 +4253,11 @@ var pathActions = canvas.pathActions = function() {
var last = drawn_path.pathSegList.getItem(num -1);
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
var s_seg = stretchy.pathSegList.getItem(1);
@ -4845,7 +4852,8 @@ var pathActions = canvas.pathActions = function() {
// TODO: Find right way to select point now
// path.selectPt(sel_pt);
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)");
},
@ -5295,8 +5303,7 @@ this.svgToString = function(elem, indent) {
indent++;
var bOneLine = false;
for (var i=0; i<childs.length; i++)
{
for (var i=0; i<childs.length; i++) {
var child = childs.item(i);
switch(child.nodeType) {
case 1: // element node

View File

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