cleaned quote inconsistencies
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2397 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -21,11 +21,11 @@ if (!svgedit.path) {
|
|||||||
svgedit.path = {};
|
svgedit.path = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
var svgns = "http://www.w3.org/2000/svg";
|
var svgns = 'http://www.w3.org/2000/svg';
|
||||||
|
|
||||||
var uiStrings = {
|
var uiStrings = {
|
||||||
"pathNodeTooltip": "Drag node to move it. Double-click node to change segment type",
|
'pathNodeTooltip': 'Drag node to move it. Double-click node to change segment type',
|
||||||
"pathCtrlPtTooltip": "Drag control point to adjust curve properties"
|
'pathCtrlPtTooltip': 'Drag control point to adjust curve properties'
|
||||||
};
|
};
|
||||||
|
|
||||||
var segData = {
|
var segData = {
|
||||||
@@ -140,16 +140,16 @@ svgedit.path.addPointGrip = function(index, x, y) {
|
|||||||
// create the container of all the point grips
|
// create the container of all the point grips
|
||||||
var pointGripContainer = svgedit.path.getGripContainer();
|
var pointGripContainer = svgedit.path.getGripContainer();
|
||||||
|
|
||||||
var pointGrip = svgedit.utilities.getElem("pathpointgrip_"+index);
|
var pointGrip = svgedit.utilities.getElem('pathpointgrip_'+index);
|
||||||
// create it
|
// create it
|
||||||
if (!pointGrip) {
|
if (!pointGrip) {
|
||||||
pointGrip = document.createElementNS(svgns, "circle");
|
pointGrip = document.createElementNS(svgns, 'circle');
|
||||||
svgedit.utilities.assignAttributes(pointGrip, {
|
svgedit.utilities.assignAttributes(pointGrip, {
|
||||||
'id': "pathpointgrip_" + index,
|
'id': 'pathpointgrip_' + index,
|
||||||
'display': "none",
|
'display': 'none',
|
||||||
'r': 4,
|
'r': 4,
|
||||||
'fill': "#0FF",
|
'fill': '#0FF',
|
||||||
'stroke': "#00F",
|
'stroke': '#00F',
|
||||||
'stroke-width': 2,
|
'stroke-width': 2,
|
||||||
'cursor': 'move',
|
'cursor': 'move',
|
||||||
'style': 'pointer-events:all',
|
'style': 'pointer-events:all',
|
||||||
@@ -167,33 +167,33 @@ svgedit.path.addPointGrip = function(index, x, y) {
|
|||||||
svgedit.utilities.assignAttributes(pointGrip, {
|
svgedit.utilities.assignAttributes(pointGrip, {
|
||||||
'cx': x,
|
'cx': x,
|
||||||
'cy': y,
|
'cy': y,
|
||||||
'display': "inline"
|
'display': 'inline'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return pointGrip;
|
return pointGrip;
|
||||||
};
|
};
|
||||||
|
|
||||||
svgedit.path.getGripContainer = function() {
|
svgedit.path.getGripContainer = function() {
|
||||||
var c = svgedit.utilities.getElem("pathpointgrip_container");
|
var c = svgedit.utilities.getElem('pathpointgrip_container');
|
||||||
if (!c) {
|
if (!c) {
|
||||||
var parent = svgedit.utilities.getElem("selectorParentGroup");
|
var parent = svgedit.utilities.getElem('selectorParentGroup');
|
||||||
c = parent.appendChild(document.createElementNS(svgns, "g"));
|
c = parent.appendChild(document.createElementNS(svgns, 'g'));
|
||||||
c.id = "pathpointgrip_container";
|
c.id = 'pathpointgrip_container';
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
};
|
};
|
||||||
|
|
||||||
svgedit.path.addCtrlGrip = function(id) {
|
svgedit.path.addCtrlGrip = function(id) {
|
||||||
var pointGrip = svgedit.utilities.getElem("ctrlpointgrip_"+id);
|
var pointGrip = svgedit.utilities.getElem('ctrlpointgrip_'+id);
|
||||||
if (pointGrip) return pointGrip;
|
if (pointGrip) return pointGrip;
|
||||||
|
|
||||||
pointGrip = document.createElementNS(svgns, "circle");
|
pointGrip = document.createElementNS(svgns, 'circle');
|
||||||
svgedit.utilities.assignAttributes(pointGrip, {
|
svgedit.utilities.assignAttributes(pointGrip, {
|
||||||
'id': "ctrlpointgrip_" + id,
|
'id': 'ctrlpointgrip_' + id,
|
||||||
'display': "none",
|
'display': 'none',
|
||||||
'r': 4,
|
'r': 4,
|
||||||
'fill': "#0FF",
|
'fill': '#0FF',
|
||||||
'stroke': "#55F",
|
'stroke': '#55F',
|
||||||
'stroke-width': 1,
|
'stroke-width': 1,
|
||||||
'cursor': 'move',
|
'cursor': 'move',
|
||||||
'style': 'pointer-events:all',
|
'style': 'pointer-events:all',
|
||||||
@@ -204,15 +204,15 @@ svgedit.path.addCtrlGrip = function(id) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
svgedit.path.getCtrlLine = function(id) {
|
svgedit.path.getCtrlLine = function(id) {
|
||||||
var ctrlLine = svgedit.utilities.getElem("ctrlLine_"+id);
|
var ctrlLine = svgedit.utilities.getElem('ctrlLine_'+id);
|
||||||
if (ctrlLine) return ctrlLine;
|
if (ctrlLine) return ctrlLine;
|
||||||
|
|
||||||
ctrlLine = document.createElementNS(svgns, "line");
|
ctrlLine = document.createElementNS(svgns, 'line');
|
||||||
svgedit.utilities.assignAttributes(ctrlLine, {
|
svgedit.utilities.assignAttributes(ctrlLine, {
|
||||||
'id': "ctrlLine_"+id,
|
'id': 'ctrlLine_'+id,
|
||||||
'stroke': "#555",
|
'stroke': '#555',
|
||||||
'stroke-width': 1,
|
'stroke-width': 1,
|
||||||
"style": "pointer-events:none"
|
'style': 'pointer-events:none'
|
||||||
});
|
});
|
||||||
svgedit.path.getGripContainer().appendChild(ctrlLine);
|
svgedit.path.getGripContainer().appendChild(ctrlLine);
|
||||||
return ctrlLine;
|
return ctrlLine;
|
||||||
@@ -227,7 +227,7 @@ svgedit.path.getPointGrip = function(seg, update) {
|
|||||||
svgedit.utilities.assignAttributes(pointGrip, {
|
svgedit.utilities.assignAttributes(pointGrip, {
|
||||||
'cx': pt.x,
|
'cx': pt.x,
|
||||||
'cy': pt.y,
|
'cy': pt.y,
|
||||||
'display': "inline"
|
'display': 'inline'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ svgedit.path.getPointGrip = function(seg, update) {
|
|||||||
svgedit.path.getControlPoints = function(seg) {
|
svgedit.path.getControlPoints = function(seg) {
|
||||||
var item = seg.item;
|
var item = seg.item;
|
||||||
var index = seg.index;
|
var index = seg.index;
|
||||||
if (!("x1" in item) || !("x2" in item)) return null;
|
if (!('x1' in item) || !('x2' in item)) return null;
|
||||||
var cpt = {};
|
var cpt = {};
|
||||||
var pointGripContainer = svgedit.path.getGripContainer();
|
var pointGripContainer = svgedit.path.getGripContainer();
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ svgedit.path.getControlPoints = function(seg) {
|
|||||||
'y1': pt.y,
|
'y1': pt.y,
|
||||||
'x2': gpt.x,
|
'x2': gpt.x,
|
||||||
'y2': gpt.y,
|
'y2': gpt.y,
|
||||||
'display': "inline"
|
'display': 'inline'
|
||||||
});
|
});
|
||||||
|
|
||||||
cpt['c' + i + '_line'] = ctrlLine;
|
cpt['c' + i + '_line'] = ctrlLine;
|
||||||
@@ -270,7 +270,7 @@ svgedit.path.getControlPoints = function(seg) {
|
|||||||
svgedit.utilities.assignAttributes(pointGrip, {
|
svgedit.utilities.assignAttributes(pointGrip, {
|
||||||
'cx': pt.x,
|
'cx': pt.x,
|
||||||
'cy': pt.y,
|
'cy': pt.y,
|
||||||
'display': "inline"
|
'display': 'inline'
|
||||||
});
|
});
|
||||||
cpt['c' + i] = pointGrip;
|
cpt['c' + i] = pointGrip;
|
||||||
}
|
}
|
||||||
@@ -306,16 +306,16 @@ svgedit.path.replacePathSeg = function(type, index, pts, elem) {
|
|||||||
|
|
||||||
svgedit.path.getSegSelector = function(seg, update) {
|
svgedit.path.getSegSelector = function(seg, update) {
|
||||||
var index = seg.index;
|
var index = seg.index;
|
||||||
var segLine = svgedit.utilities.getElem("segline_" + index);
|
var segLine = svgedit.utilities.getElem('segline_' + index);
|
||||||
if (!segLine) {
|
if (!segLine) {
|
||||||
var pointGripContainer = svgedit.path.getGripContainer();
|
var pointGripContainer = svgedit.path.getGripContainer();
|
||||||
// create segline
|
// create segline
|
||||||
segLine = document.createElementNS(svgns, "path");
|
segLine = document.createElementNS(svgns, 'path');
|
||||||
svgedit.utilities.assignAttributes(segLine, {
|
svgedit.utilities.assignAttributes(segLine, {
|
||||||
'id': "segline_" + index,
|
'id': 'segline_' + index,
|
||||||
'display': 'none',
|
'display': 'none',
|
||||||
'fill': "none",
|
'fill': 'none',
|
||||||
'stroke': "#0FF",
|
'stroke': '#0FF',
|
||||||
'stroke-width': 2,
|
'stroke-width': 2,
|
||||||
'style':'pointer-events:none',
|
'style':'pointer-events:none',
|
||||||
'd': 'M0,0 0,0'
|
'd': 'M0,0 0,0'
|
||||||
@@ -326,7 +326,7 @@ svgedit.path.getSegSelector = function(seg, update) {
|
|||||||
if (update) {
|
if (update) {
|
||||||
var prev = seg.prev;
|
var prev = seg.prev;
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
segLine.setAttribute("display", "none");
|
segLine.setAttribute('display', 'none');
|
||||||
return segLine;
|
return segLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +410,7 @@ svgedit.path.Segment = function(index, item) {
|
|||||||
|
|
||||||
svgedit.path.Segment.prototype.showCtrlPts = function(y) {
|
svgedit.path.Segment.prototype.showCtrlPts = function(y) {
|
||||||
for (var i in this.ctrlpts) {
|
for (var i in this.ctrlpts) {
|
||||||
this.ctrlpts[i].setAttribute("display", y ? "inline" : "none");
|
this.ctrlpts[i].setAttribute('display', y ? 'inline' : 'none');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -421,8 +421,8 @@ svgedit.path.Segment.prototype.selectCtrls = function(y) {
|
|||||||
|
|
||||||
svgedit.path.Segment.prototype.show = function(y) {
|
svgedit.path.Segment.prototype.show = function(y) {
|
||||||
if (this.ptgrip) {
|
if (this.ptgrip) {
|
||||||
this.ptgrip.setAttribute("display", y ? "inline" : "none");
|
this.ptgrip.setAttribute('display', y ? 'inline' : 'none');
|
||||||
this.segsel.setAttribute("display", y ? "inline" : "none");
|
this.segsel.setAttribute('display', y ? 'inline' : 'none');
|
||||||
// Show/hide all control points if available
|
// Show/hide all control points if available
|
||||||
this.showCtrlPts(y);
|
this.showCtrlPts(y);
|
||||||
}
|
}
|
||||||
@@ -430,8 +430,8 @@ svgedit.path.Segment.prototype.show = function(y) {
|
|||||||
|
|
||||||
svgedit.path.Segment.prototype.select = function(y) {
|
svgedit.path.Segment.prototype.select = function(y) {
|
||||||
if (this.ptgrip) {
|
if (this.ptgrip) {
|
||||||
this.ptgrip.setAttribute("stroke", y ? "#0FF" : "#00F");
|
this.ptgrip.setAttribute('stroke', y ? '#0FF' : '#00F');
|
||||||
this.segsel.setAttribute("display", y ? "inline" : "none");
|
this.segsel.setAttribute('display', y ? 'inline' : 'none');
|
||||||
if (this.ctrlpts) {
|
if (this.ctrlpts) {
|
||||||
this.selectCtrls(y);
|
this.selectCtrls(y);
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ svgedit.path.Segment.prototype.update = function(full) {
|
|||||||
}
|
}
|
||||||
svgedit.path.getControlPoints(this);
|
svgedit.path.getControlPoints(this);
|
||||||
}
|
}
|
||||||
// this.segsel.setAttribute("display", y?"inline":"none");
|
// this.segsel.setAttribute('display', y?'inline':'none');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -485,12 +485,12 @@ svgedit.path.Segment.prototype.move = function(dx, dy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.mate) {
|
if (this.mate) {
|
||||||
// The last point of a closed subpath has a "mate",
|
// The last point of a closed subpath has a 'mate',
|
||||||
// which is the "M" segment of the subpath
|
// which is the 'M' segment of the subpath
|
||||||
var item = this.mate.item;
|
var item = this.mate.item;
|
||||||
var pts = [item.x += dx, item.y += dy];
|
var pts = [item.x += dx, item.y += dy];
|
||||||
svgedit.path.replacePathSeg(this.mate.type, this.mate.index, pts);
|
svgedit.path.replacePathSeg(this.mate.type, this.mate.index, pts);
|
||||||
// Has no grip, so does not need "updating"?
|
// Has no grip, so does not need 'updating'?
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update(true);
|
this.update(true);
|
||||||
@@ -546,8 +546,8 @@ svgedit.path.Segment.prototype.setType = function(new_type, pts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
svgedit.path.Path = function(elem) {
|
svgedit.path.Path = function(elem) {
|
||||||
if (!elem || elem.tagName !== "path") {
|
if (!elem || elem.tagName !== 'path') {
|
||||||
throw "svgedit.path.Path constructed without a <path> element";
|
throw 'svgedit.path.Path constructed without a <path> element';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
@@ -561,7 +561,7 @@ svgedit.path.Path = function(elem) {
|
|||||||
// Reset path data
|
// Reset path data
|
||||||
svgedit.path.Path.prototype.init = function() {
|
svgedit.path.Path.prototype.init = function() {
|
||||||
// Hide all grips, etc
|
// Hide all grips, etc
|
||||||
$(svgedit.path.getGripContainer()).find("*").attr("display", "none");
|
$(svgedit.path.getGripContainer()).find('*').attr('display', 'none');
|
||||||
var segList = this.elem.pathSegList;
|
var segList = this.elem.pathSegList;
|
||||||
var len = segList.numberOfItems;
|
var len = segList.numberOfItems;
|
||||||
this.segs = [];
|
this.segs = [];
|
||||||
@@ -788,7 +788,7 @@ svgedit.path.Path.prototype.setSegType = function(new_type) {
|
|||||||
if (!prev) continue;
|
if (!prev) continue;
|
||||||
|
|
||||||
if (!new_type) { // double-click, so just toggle
|
if (!new_type) { // double-click, so just toggle
|
||||||
text = "Toggle Path Segment Type";
|
text = 'Toggle Path Segment Type';
|
||||||
|
|
||||||
// Toggle segment to curve/straight line
|
// Toggle segment to curve/straight line
|
||||||
var old_type = cur.type;
|
var old_type = cur.type;
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ if (!svgedit.sanitize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Namespace constants
|
// Namespace constants
|
||||||
var svgns = "http://www.w3.org/2000/svg",
|
var svgns = 'http://www.w3.org/2000/svg',
|
||||||
xlinkns = "http://www.w3.org/1999/xlink",
|
xlinkns = 'http://www.w3.org/1999/xlink',
|
||||||
xmlns = "http://www.w3.org/XML/1998/namespace",
|
xmlns = 'http://www.w3.org/XML/1998/namespace',
|
||||||
xmlnsns = "http://www.w3.org/2000/xmlns/", // see http://www.w3.org/TR/REC-xml-names/#xmlReserved
|
xmlnsns = 'http://www.w3.org/2000/xmlns/', // see http://www.w3.org/TR/REC-xml-names/#xmlReserved
|
||||||
htmlns = "http://www.w3.org/1999/xhtml",
|
htmlns = 'http://www.w3.org/1999/xhtml',
|
||||||
mathns = "http://www.w3.org/1998/Math/MathML",
|
mathns = 'http://www.w3.org/1998/Math/MathML',
|
||||||
se_ns = "http://svg-edit.googlecode.com";
|
se_ns = 'http://svg-edit.googlecode.com';
|
||||||
|
|
||||||
// map namespace URIs to prefixes
|
// map namespace URIs to prefixes
|
||||||
var nsMap_ = {};
|
var nsMap_ = {};
|
||||||
@@ -142,7 +142,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||||||
// Cleanup text nodes
|
// Cleanup text nodes
|
||||||
if (node.nodeType == 3) { // 3 == TEXT_NODE
|
if (node.nodeType == 3) { // 3 == TEXT_NODE
|
||||||
// Trim whitespace
|
// Trim whitespace
|
||||||
node.nodeValue = node.nodeValue.replace(/^\s+|\s+$/g, "");
|
node.nodeValue = node.nodeValue.replace(/^\s+|\s+$/g, '');
|
||||||
// Remove if empty
|
// Remove if empty
|
||||||
if(node.nodeValue.length == 0) node.parentNode.removeChild(node);
|
if(node.nodeValue.length == 0) node.parentNode.removeChild(node);
|
||||||
}
|
}
|
||||||
@@ -192,20 +192,20 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||||||
// Add spaces before negative signs where necessary
|
// Add spaces before negative signs where necessary
|
||||||
if(svgedit.browser.isGecko()) {
|
if(svgedit.browser.isGecko()) {
|
||||||
switch ( attrName ) {
|
switch ( attrName ) {
|
||||||
case "transform":
|
case 'transform':
|
||||||
case "gradientTransform":
|
case 'gradientTransform':
|
||||||
case "patternTransform":
|
case 'patternTransform':
|
||||||
var val = attr.nodeValue.replace(/(\d)-/g, "$1 -");
|
var val = attr.nodeValue.replace(/(\d)-/g, '$1 -');
|
||||||
node.setAttribute(attrName, val);
|
node.setAttribute(attrName, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the style attribute, rewrite it in terms of XML presentational attributes
|
// For the style attribute, rewrite it in terms of XML presentational attributes
|
||||||
if (attrName == "style") {
|
if (attrName == 'style') {
|
||||||
var props = attr.nodeValue.split(";"),
|
var props = attr.nodeValue.split(';'),
|
||||||
p = props.length;
|
p = props.length;
|
||||||
while(p--) {
|
while(p--) {
|
||||||
var nv = props[p].split(":");
|
var nv = props[p].split(':');
|
||||||
var styleAttrName = $.trim(nv[0]);
|
var styleAttrName = $.trim(nv[0]);
|
||||||
var styleAttrVal = $.trim(nv[1]);
|
var styleAttrVal = $.trim(nv[1]);
|
||||||
// Now check that this attribute is supported
|
// Now check that this attribute is supported
|
||||||
@@ -225,31 +225,31 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||||||
// (but not for links)
|
// (but not for links)
|
||||||
var href = svgedit.utilities.getHref(node);
|
var href = svgedit.utilities.getHref(node);
|
||||||
if(href &&
|
if(href &&
|
||||||
["filter", "linearGradient", "pattern",
|
['filter', 'linearGradient', 'pattern',
|
||||||
"radialGradient", "textPath", "use"].indexOf(node.nodeName) >= 0)
|
'radialGradient', 'textPath', 'use'].indexOf(node.nodeName) >= 0)
|
||||||
{
|
{
|
||||||
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
||||||
if (href[0] != "#") {
|
if (href[0] != '#') {
|
||||||
// remove the attribute (but keep the element)
|
// remove the attribute (but keep the element)
|
||||||
svgedit.utilities.setHref(node, "");
|
svgedit.utilities.setHref(node, '');
|
||||||
node.removeAttributeNS(xlinkns, "href");
|
node.removeAttributeNS(xlinkns, 'href');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safari crashes on a <use> without a xlink:href, so we just remove the node here
|
// Safari crashes on a <use> without a xlink:href, so we just remove the node here
|
||||||
if (node.nodeName == "use" && !svgedit.utilities.getHref(node)) {
|
if (node.nodeName == 'use' && !svgedit.utilities.getHref(node)) {
|
||||||
parent.removeChild(node);
|
parent.removeChild(node);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if the element has attributes pointing to a non-local reference,
|
// if the element has attributes pointing to a non-local reference,
|
||||||
// need to remove the attribute
|
// need to remove the attribute
|
||||||
$.each(["clip-path", "fill", "filter", "marker-end", "marker-mid", "marker-start", "mask", "stroke"], function(i, attr) {
|
$.each(['clip-path', 'fill', 'filter', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'stroke'], function(i, attr) {
|
||||||
var val = node.getAttribute(attr);
|
var val = node.getAttribute(attr);
|
||||||
if (val) {
|
if (val) {
|
||||||
val = svgedit.utilities.getUrlFromAttr(val);
|
val = svgedit.utilities.getUrlFromAttr(val);
|
||||||
// simply check for first character being a '#'
|
// simply check for first character being a '#'
|
||||||
if (val && val[0] !== "#") {
|
if (val && val[0] !== '#') {
|
||||||
node.setAttribute(attr, "");
|
node.setAttribute(attr, '');
|
||||||
node.removeAttribute(attr);
|
node.removeAttribute(attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,17 +23,17 @@ var svgroot = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|||||||
// Helper function.
|
// Helper function.
|
||||||
function transformToString(xform) {
|
function transformToString(xform) {
|
||||||
var m = xform.matrix,
|
var m = xform.matrix,
|
||||||
text = "";
|
text = '';
|
||||||
switch(xform.type) {
|
switch(xform.type) {
|
||||||
case 1: // MATRIX
|
case 1: // MATRIX
|
||||||
text = "matrix(" + [m.a, m.b, m.c, m.d, m.e, m.f].join(",") + ")";
|
text = 'matrix(' + [m.a, m.b, m.c, m.d, m.e, m.f].join(',') + ')';
|
||||||
break;
|
break;
|
||||||
case 2: // TRANSLATE
|
case 2: // TRANSLATE
|
||||||
text = "translate(" + m.e + "," + m.f + ")";
|
text = 'translate(' + m.e + ',' + m.f + ')';
|
||||||
break;
|
break;
|
||||||
case 3: // SCALE
|
case 3: // SCALE
|
||||||
if (m.a == m.d) text = "scale(" + m.a + ")";
|
if (m.a == m.d) text = 'scale(' + m.a + ')';
|
||||||
else text = "scale(" + m.a + "," + m.d + ")";
|
else text = 'scale(' + m.a + ',' + m.d + ')';
|
||||||
break;
|
break;
|
||||||
case 4: // ROTATE
|
case 4: // ROTATE
|
||||||
var cx = 0, cy = 0;
|
var cx = 0, cy = 0;
|
||||||
@@ -43,7 +43,7 @@ function transformToString(xform) {
|
|||||||
cy = ( K * m.f + m.b*m.e ) / ( K*K + m.b*m.b );
|
cy = ( K * m.f + m.b*m.e ) / ( K*K + m.b*m.b );
|
||||||
cx = ( m.e - m.b * cy ) / K;
|
cx = ( m.e - m.b * cy ) / K;
|
||||||
}
|
}
|
||||||
text = "rotate(" + xform.angle + " " + cx + "," + cy + ")";
|
text = 'rotate(' + xform.angle + ' ' + cx + ',' + cy + ')';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
@@ -80,18 +80,18 @@ svgedit.transformlist.SVGTransformList = function(elem) {
|
|||||||
this._xforms = [];
|
this._xforms = [];
|
||||||
// TODO: how do we capture the undo-ability in the changed transform list?
|
// TODO: how do we capture the undo-ability in the changed transform list?
|
||||||
this._update = function() {
|
this._update = function() {
|
||||||
var tstr = "";
|
var tstr = '';
|
||||||
var concatMatrix = svgroot.createSVGMatrix();
|
var concatMatrix = svgroot.createSVGMatrix();
|
||||||
for (var i = 0; i < this.numberOfItems; ++i) {
|
for (var i = 0; i < this.numberOfItems; ++i) {
|
||||||
var xform = this._list.getItem(i);
|
var xform = this._list.getItem(i);
|
||||||
tstr += transformToString(xform) + " ";
|
tstr += transformToString(xform) + ' ';
|
||||||
}
|
}
|
||||||
this._elem.setAttribute("transform", tstr);
|
this._elem.setAttribute('transform', tstr);
|
||||||
};
|
};
|
||||||
this._list = this;
|
this._list = this;
|
||||||
this._init = function() {
|
this._init = function() {
|
||||||
// Transform attribute parser
|
// Transform attribute parser
|
||||||
var str = this._elem.getAttribute("transform");
|
var str = this._elem.getAttribute('transform');
|
||||||
if (!str) return;
|
if (!str) return;
|
||||||
|
|
||||||
// TODO: Add skew support in future
|
// TODO: Add skew support in future
|
||||||
@@ -105,7 +105,7 @@ svgedit.transformlist.SVGTransformList = function(elem) {
|
|||||||
var bits = x.split(/\s*\(/);
|
var bits = x.split(/\s*\(/);
|
||||||
var name = bits[0];
|
var name = bits[0];
|
||||||
var val_bits = bits[1].match(/\s*(.*?)\s*\)/);
|
var val_bits = bits[1].match(/\s*(.*?)\s*\)/);
|
||||||
val_bits[1] = val_bits[1].replace(/(\d)-/g, "$1 -");
|
val_bits[1] = val_bits[1].replace(/(\d)-/g, '$1 -');
|
||||||
var val_arr = val_bits[1].split(/[, ]+/);
|
var val_arr = val_bits[1].split(/[, ]+/);
|
||||||
var letters = 'abcdef'.split('');
|
var letters = 'abcdef'.split('');
|
||||||
var mtx = svgroot.createSVGMatrix();
|
var mtx = svgroot.createSVGMatrix();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ if (!svgedit.utilities) {
|
|||||||
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||||
var SVGNS = 'http://www.w3.org/2000/svg';
|
var SVGNS = 'http://www.w3.org/2000/svg';
|
||||||
var XLINKNS = 'http://www.w3.org/1999/xlink';
|
var XLINKNS = 'http://www.w3.org/1999/xlink';
|
||||||
var XMLNS = "http://www.w3.org/XML/1998/namespace";
|
var XMLNS = 'http://www.w3.org/XML/1998/namespace';
|
||||||
|
|
||||||
// Much faster than running getBBox() every time
|
// Much faster than running getBBox() every time
|
||||||
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';
|
var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use';
|
||||||
@@ -48,7 +48,7 @@ svgedit.utilities.init = function(editorContext) {
|
|||||||
// Function: svgedit.utilities.toXml
|
// Function: svgedit.utilities.toXml
|
||||||
// Converts characters in a string to XML-friendly entities.
|
// Converts characters in a string to XML-friendly entities.
|
||||||
//
|
//
|
||||||
// Example: "&" becomes "&"
|
// Example: '&' becomes '&'
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// str - The string to be converted
|
// str - The string to be converted
|
||||||
@@ -61,7 +61,7 @@ svgedit.utilities.toXml = function(str) {
|
|||||||
|
|
||||||
// Function: svgedit.utilities.fromXml
|
// Function: svgedit.utilities.fromXml
|
||||||
// Converts XML entities in a string to single characters.
|
// Converts XML entities in a string to single characters.
|
||||||
// Example: "&" becomes "&"
|
// Example: '&' becomes '&'
|
||||||
//
|
//
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// str - The string to be converted
|
// str - The string to be converted
|
||||||
@@ -120,13 +120,13 @@ svgedit.utilities.encode64 = function(input) {
|
|||||||
// Converts a string from base64
|
// Converts a string from base64
|
||||||
svgedit.utilities.decode64 = function(input) {
|
svgedit.utilities.decode64 = function(input) {
|
||||||
if(window.atob) return window.atob(input);
|
if(window.atob) return window.atob(input);
|
||||||
var output = "";
|
var output = '';
|
||||||
var chr1, chr2, chr3 = "";
|
var chr1, chr2, chr3 = '';
|
||||||
var enc1, enc2, enc3, enc4 = "";
|
var enc1, enc2, enc3, enc4 = '';
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
||||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||||
|
|
||||||
do {
|
do {
|
||||||
enc1 = KEYSTR.indexOf(input.charAt(i++));
|
enc1 = KEYSTR.indexOf(input.charAt(i++));
|
||||||
@@ -147,8 +147,8 @@ svgedit.utilities.decode64 = function(input) {
|
|||||||
output = output + String.fromCharCode(chr3);
|
output = output + String.fromCharCode(chr3);
|
||||||
}
|
}
|
||||||
|
|
||||||
chr1 = chr2 = chr3 = "";
|
chr1 = chr2 = chr3 = '';
|
||||||
enc1 = enc2 = enc3 = enc4 = "";
|
enc1 = enc2 = enc3 = enc4 = '';
|
||||||
|
|
||||||
} while (i < input.length);
|
} while (i < input.length);
|
||||||
return unescape(output);
|
return unescape(output);
|
||||||
@@ -157,7 +157,7 @@ svgedit.utilities.decode64 = function(input) {
|
|||||||
// Currently not being used, so commented out for now
|
// Currently not being used, so commented out for now
|
||||||
// based on http://phpjs.org/functions/utf8_encode:577
|
// based on http://phpjs.org/functions/utf8_encode:577
|
||||||
// codedread:does not seem to work with webkit-based browsers on OSX
|
// codedread:does not seem to work with webkit-based browsers on OSX
|
||||||
// "encodeUTF8": function(input) {
|
// 'encodeUTF8': function(input) {
|
||||||
// //return unescape(encodeURIComponent(input)); //may or may not work
|
// //return unescape(encodeURIComponent(input)); //may or may not work
|
||||||
// var output = '';
|
// var output = '';
|
||||||
// for (var n = 0; n < input.length; n++){
|
// for (var n = 0; n < input.length; n++){
|
||||||
@@ -187,7 +187,7 @@ svgedit.utilities.convertToXMLReferences = function(input) {
|
|||||||
if (c < 128) {
|
if (c < 128) {
|
||||||
output += input[n];
|
output += input[n];
|
||||||
} else if(c > 127) {
|
} else if(c > 127) {
|
||||||
output += ("&#" + c + ";");
|
output += ('&#' + c + ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
@@ -203,16 +203,16 @@ svgedit.utilities.text2xml = function(sXML) {
|
|||||||
|
|
||||||
var out;
|
var out;
|
||||||
try{
|
try{
|
||||||
var dXML = (window.DOMParser)?new DOMParser():new ActiveXObject("Microsoft.XMLDOM");
|
var dXML = (window.DOMParser)?new DOMParser():new ActiveXObject('Microsoft.XMLDOM');
|
||||||
dXML.async = false;
|
dXML.async = false;
|
||||||
} catch(e){
|
} catch(e){
|
||||||
throw new Error("XML Parser could not be instantiated");
|
throw new Error('XML Parser could not be instantiated');
|
||||||
};
|
};
|
||||||
try{
|
try{
|
||||||
if(dXML.loadXML) out = (dXML.loadXML(sXML))?dXML:false;
|
if(dXML.loadXML) out = (dXML.loadXML(sXML))?dXML:false;
|
||||||
else out = dXML.parseFromString(sXML, "text/xml");
|
else out = dXML.parseFromString(sXML, 'text/xml');
|
||||||
}
|
}
|
||||||
catch(e){ throw new Error("Error parsing XML string"); };
|
catch(e){ throw new Error('Error parsing XML string'); };
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -298,13 +298,13 @@ svgedit.utilities.getUrlFromAttr = function(attrVal) {
|
|||||||
// Function: svgedit.utilities.getHref
|
// Function: svgedit.utilities.getHref
|
||||||
// Returns the given element's xlink:href value
|
// Returns the given element's xlink:href value
|
||||||
svgedit.utilities.getHref = function(elem) {
|
svgedit.utilities.getHref = function(elem) {
|
||||||
return elem.getAttributeNS(XLINKNS, "href");
|
return elem.getAttributeNS(XLINKNS, 'href');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function: svgedit.utilities.setHref
|
// Function: svgedit.utilities.setHref
|
||||||
// Sets the given element's xlink:href value
|
// Sets the given element's xlink:href value
|
||||||
svgedit.utilities.setHref = function(elem, val) {
|
svgedit.utilities.setHref = function(elem, val) {
|
||||||
elem.setAttributeNS(XLINKNS, "xlink:href", val);
|
elem.setAttributeNS(XLINKNS, 'xlink:href', val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function: findDefs
|
// Function: findDefs
|
||||||
@@ -313,12 +313,12 @@ svgedit.utilities.setHref = function(elem, val) {
|
|||||||
// The document's <defs> element, create it first if necessary
|
// The document's <defs> element, create it first if necessary
|
||||||
svgedit.utilities.findDefs = function() {
|
svgedit.utilities.findDefs = function() {
|
||||||
var svgElement = editorContext_.getSVGContent();
|
var svgElement = editorContext_.getSVGContent();
|
||||||
var defs = svgElement.getElementsByTagNameNS(SVGNS, "defs");
|
var defs = svgElement.getElementsByTagNameNS(SVGNS, 'defs');
|
||||||
if (defs.length > 0) {
|
if (defs.length > 0) {
|
||||||
defs = defs[0];
|
defs = defs[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
defs = svgElement.ownerDocument.createElementNS(SVGNS, "defs");
|
defs = svgElement.ownerDocument.createElementNS(SVGNS, 'defs');
|
||||||
if (svgElement.firstChild) {
|
if (svgElement.firstChild) {
|
||||||
// first child is a comment, so call nextSibling
|
// first child is a comment, so call nextSibling
|
||||||
svgElement.insertBefore(defs, svgElement.firstChild.nextSibling);
|
svgElement.insertBefore(defs, svgElement.firstChild.nextSibling);
|
||||||
@@ -498,7 +498,7 @@ svgedit.utilities.getBBox = function(elem) {
|
|||||||
ret = groupBBFix(selected, true);
|
ret = groupBBFix(selected, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(elname === 'use' || ( elname === "foreignObject" && svgedit.browser.isWebkit() ) ) {
|
if(elname === 'use' || ( elname === 'foreignObject' && svgedit.browser.isWebkit() ) ) {
|
||||||
if(!ret) ret = selected.getBBox();
|
if(!ret) ret = selected.getBBox();
|
||||||
// This is resolved in later versions of webkit, perhaps we should
|
// This is resolved in later versions of webkit, perhaps we should
|
||||||
// have a featured detection for correct 'use' behavior?
|
// have a featured detection for correct 'use' behavior?
|
||||||
@@ -515,7 +515,7 @@ svgedit.utilities.getBBox = function(elem) {
|
|||||||
try { ret = selected.getBBox();}
|
try { ret = selected.getBBox();}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
// Check if element is child of a foreignObject
|
// Check if element is child of a foreignObject
|
||||||
var fo = $(selected).closest("foreignObject");
|
var fo = $(selected).closest('foreignObject');
|
||||||
if(fo.length) {
|
if(fo.length) {
|
||||||
try {
|
try {
|
||||||
ret = fo[0].getBBox();
|
ret = fo[0].getBBox();
|
||||||
@@ -586,7 +586,7 @@ if (svgedit.browser.supportsSelectors()) {
|
|||||||
return domdoc_.evaluate(
|
return domdoc_.evaluate(
|
||||||
'svg:svg[@id="svgroot"]//svg:*[@id="'+id+'"]',
|
'svg:svg[@id="svgroot"]//svg:*[@id="'+id+'"]',
|
||||||
domcontainer_,
|
domcontainer_,
|
||||||
function() { return "http://www.w3.org/2000/svg"; },
|
function() { return 'http://www.w3.org/2000/svg'; },
|
||||||
9,
|
9,
|
||||||
null).singleNodeValue;
|
null).singleNodeValue;
|
||||||
};
|
};
|
||||||
@@ -612,8 +612,8 @@ svgedit.utilities.assignAttributes = function(node, attrs, suspendLength, unitCh
|
|||||||
if (!svgedit.browser.isOpera()) svgroot_.suspendRedraw(suspendLength);
|
if (!svgedit.browser.isOpera()) svgroot_.suspendRedraw(suspendLength);
|
||||||
|
|
||||||
for (var i in attrs) {
|
for (var i in attrs) {
|
||||||
var ns = (i.substr(0,4) === "xml:" ? XMLNS :
|
var ns = (i.substr(0,4) === 'xml:' ? XMLNS :
|
||||||
i.substr(0,6) === "xlink:" ? XLINKNS : null);
|
i.substr(0,6) === 'xlink:' ? XLINKNS : null);
|
||||||
|
|
||||||
if(ns) {
|
if(ns) {
|
||||||
node.setAttributeNS(ns, i, attrs[i]);
|
node.setAttributeNS(ns, i, attrs[i]);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ var typeMap_ = {};
|
|||||||
/**
|
/**
|
||||||
* ElementContainer interface
|
* ElementContainer interface
|
||||||
*
|
*
|
||||||
* function getBaseUnit() - returns a string of the base unit type of the container ("em")
|
* function getBaseUnit() - returns a string of the base unit type of the container ('em')
|
||||||
* function getElement() - returns an element in the container given an id
|
* function getElement() - returns an element in the container given an id
|
||||||
* function getHeight() - returns the container's height
|
* function getHeight() - returns the container's height
|
||||||
* function getWidth() - returns the container's width
|
* function getWidth() - returns the container's width
|
||||||
@@ -171,14 +171,14 @@ svgedit.units.setUnitAttr = function(elem, attr, val) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var attrsToConvert = {
|
var attrsToConvert = {
|
||||||
"line": ['x1', 'x2', 'y1', 'y2'],
|
'line': ['x1', 'x2', 'y1', 'y2'],
|
||||||
"circle": ['cx', 'cy', 'r'],
|
'circle': ['cx', 'cy', 'r'],
|
||||||
"ellipse": ['cx', 'cy', 'rx', 'ry'],
|
'ellipse': ['cx', 'cy', 'rx', 'ry'],
|
||||||
"foreignObject": ['x', 'y', 'width', 'height'],
|
'foreignObject': ['x', 'y', 'width', 'height'],
|
||||||
"rect": ['x', 'y', 'width', 'height'],
|
'rect': ['x', 'y', 'width', 'height'],
|
||||||
"image": ['x', 'y', 'width', 'height'],
|
'image': ['x', 'y', 'width', 'height'],
|
||||||
"use": ['x', 'y', 'width', 'height'],
|
'use': ['x', 'y', 'width', 'height'],
|
||||||
"text": ['x', 'y']
|
'text': ['x', 'y']
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.units.convertAttrs
|
// Function: svgedit.units.convertAttrs
|
||||||
@@ -259,7 +259,7 @@ svgedit.units.isValidUnit = function(attr, val, selectedElement) {
|
|||||||
if (re.test(val)) valid = true;
|
if (re.test(val)) valid = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (attr == "id") {
|
} else if (attr == 'id') {
|
||||||
// if we're trying to change the id, make sure it's not already present in the doc
|
// if we're trying to change the id, make sure it's not already present in the doc
|
||||||
// and the id value is valid.
|
// and the id value is valid.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user