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