Change all tab indentations to 2sp indentation. Addresses issue #37
This commit is contained in:
@@ -16,20 +16,20 @@
|
||||
'use strict';
|
||||
|
||||
if (!svgedit.browser) {
|
||||
svgedit.browser = {};
|
||||
svgedit.browser = {};
|
||||
}
|
||||
|
||||
// alias
|
||||
var NS = svgedit.NS;
|
||||
|
||||
var supportsSvg_ = (function () {
|
||||
return !!document.createElementNS && !!document.createElementNS(NS.SVG, 'svg').createSVGRect;
|
||||
return !!document.createElementNS && !!document.createElementNS(NS.SVG, 'svg').createSVGRect;
|
||||
}());
|
||||
|
||||
svgedit.browser.supportsSvg = function () { return supportsSvg_; };
|
||||
if (!svgedit.browser.supportsSvg()) {
|
||||
window.location = 'browser-not-supported.html';
|
||||
return;
|
||||
window.location = 'browser-not-supported.html';
|
||||
return;
|
||||
}
|
||||
|
||||
var userAgent = navigator.userAgent;
|
||||
@@ -46,120 +46,120 @@ var isMac_ = userAgent.indexOf('Macintosh') >= 0;
|
||||
var isTouch_ = 'ontouchstart' in window;
|
||||
|
||||
var supportsSelectors_ = (function () {
|
||||
return !!svg.querySelector;
|
||||
return !!svg.querySelector;
|
||||
}());
|
||||
|
||||
var supportsXpath_ = (function () {
|
||||
return !!document.evaluate;
|
||||
return !!document.evaluate;
|
||||
}());
|
||||
|
||||
// segList functions (for FF1.5 and 2.0)
|
||||
var supportsPathReplaceItem_ = (function () {
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 10,10');
|
||||
var seglist = path.pathSegList;
|
||||
var seg = path.createSVGPathSegLinetoAbs(5, 5);
|
||||
try {
|
||||
seglist.replaceItem(seg, 1);
|
||||
return true;
|
||||
} catch (err) {}
|
||||
return false;
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 10,10');
|
||||
var seglist = path.pathSegList;
|
||||
var seg = path.createSVGPathSegLinetoAbs(5, 5);
|
||||
try {
|
||||
seglist.replaceItem(seg, 1);
|
||||
return true;
|
||||
} catch (err) {}
|
||||
return false;
|
||||
}());
|
||||
|
||||
var supportsPathInsertItemBefore_ = (function () {
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 10,10');
|
||||
var seglist = path.pathSegList;
|
||||
var seg = path.createSVGPathSegLinetoAbs(5, 5);
|
||||
try {
|
||||
seglist.insertItemBefore(seg, 1);
|
||||
return true;
|
||||
} catch (err) {}
|
||||
return false;
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 10,10');
|
||||
var seglist = path.pathSegList;
|
||||
var seg = path.createSVGPathSegLinetoAbs(5, 5);
|
||||
try {
|
||||
seglist.insertItemBefore(seg, 1);
|
||||
return true;
|
||||
} catch (err) {}
|
||||
return false;
|
||||
}());
|
||||
|
||||
// text character positioning (for IE9)
|
||||
var supportsGoodTextCharPos_ = (function () {
|
||||
var svgroot = document.createElementNS(NS.SVG, 'svg');
|
||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||
document.documentElement.appendChild(svgroot);
|
||||
svgcontent.setAttribute('x', 5);
|
||||
svgroot.appendChild(svgcontent);
|
||||
var text = document.createElementNS(NS.SVG, 'text');
|
||||
text.textContent = 'a';
|
||||
svgcontent.appendChild(text);
|
||||
var pos = text.getStartPositionOfChar(0).x;
|
||||
document.documentElement.removeChild(svgroot);
|
||||
return (pos === 0);
|
||||
var svgroot = document.createElementNS(NS.SVG, 'svg');
|
||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||
document.documentElement.appendChild(svgroot);
|
||||
svgcontent.setAttribute('x', 5);
|
||||
svgroot.appendChild(svgcontent);
|
||||
var text = document.createElementNS(NS.SVG, 'text');
|
||||
text.textContent = 'a';
|
||||
svgcontent.appendChild(text);
|
||||
var pos = text.getStartPositionOfChar(0).x;
|
||||
document.documentElement.removeChild(svgroot);
|
||||
return (pos === 0);
|
||||
}());
|
||||
|
||||
var supportsPathBBox_ = (function () {
|
||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||
document.documentElement.appendChild(svgcontent);
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 C0,0 10,10 10,0');
|
||||
svgcontent.appendChild(path);
|
||||
var bbox = path.getBBox();
|
||||
document.documentElement.removeChild(svgcontent);
|
||||
return (bbox.height > 4 && bbox.height < 5);
|
||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||
document.documentElement.appendChild(svgcontent);
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 C0,0 10,10 10,0');
|
||||
svgcontent.appendChild(path);
|
||||
var bbox = path.getBBox();
|
||||
document.documentElement.removeChild(svgcontent);
|
||||
return (bbox.height > 4 && bbox.height < 5);
|
||||
}());
|
||||
|
||||
// Support for correct bbox sizing on groups with horizontal/vertical lines
|
||||
var supportsHVLineContainerBBox_ = (function () {
|
||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||
document.documentElement.appendChild(svgcontent);
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 10,0');
|
||||
var path2 = document.createElementNS(NS.SVG, 'path');
|
||||
path2.setAttribute('d', 'M5,0 15,0');
|
||||
var g = document.createElementNS(NS.SVG, 'g');
|
||||
g.appendChild(path);
|
||||
g.appendChild(path2);
|
||||
svgcontent.appendChild(g);
|
||||
var bbox = g.getBBox();
|
||||
document.documentElement.removeChild(svgcontent);
|
||||
// Webkit gives 0, FF gives 10, Opera (correctly) gives 15
|
||||
return (bbox.width === 15);
|
||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||
document.documentElement.appendChild(svgcontent);
|
||||
var path = document.createElementNS(NS.SVG, 'path');
|
||||
path.setAttribute('d', 'M0,0 10,0');
|
||||
var path2 = document.createElementNS(NS.SVG, 'path');
|
||||
path2.setAttribute('d', 'M5,0 15,0');
|
||||
var g = document.createElementNS(NS.SVG, 'g');
|
||||
g.appendChild(path);
|
||||
g.appendChild(path2);
|
||||
svgcontent.appendChild(g);
|
||||
var bbox = g.getBBox();
|
||||
document.documentElement.removeChild(svgcontent);
|
||||
// Webkit gives 0, FF gives 10, Opera (correctly) gives 15
|
||||
return (bbox.width === 15);
|
||||
}());
|
||||
|
||||
var supportsEditableText_ = (function () {
|
||||
// TODO: Find better way to check support for this
|
||||
return isOpera_;
|
||||
// TODO: Find better way to check support for this
|
||||
return isOpera_;
|
||||
}());
|
||||
|
||||
var supportsGoodDecimals_ = (function () {
|
||||
// Correct decimals on clone attributes (Opera < 10.5/win/non-en)
|
||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||
rect.setAttribute('x', 0.1);
|
||||
var crect = rect.cloneNode(false);
|
||||
var retValue = (crect.getAttribute('x').indexOf(',') === -1);
|
||||
if (!retValue) {
|
||||
$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\n' +
|
||||
'Please upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.');
|
||||
}
|
||||
return retValue;
|
||||
// Correct decimals on clone attributes (Opera < 10.5/win/non-en)
|
||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||
rect.setAttribute('x', 0.1);
|
||||
var crect = rect.cloneNode(false);
|
||||
var retValue = (crect.getAttribute('x').indexOf(',') === -1);
|
||||
if (!retValue) {
|
||||
$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\n' +
|
||||
'Please upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.');
|
||||
}
|
||||
return retValue;
|
||||
}());
|
||||
|
||||
var supportsNonScalingStroke_ = (function () {
|
||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||
rect.setAttribute('style', 'vector-effect:non-scaling-stroke');
|
||||
return rect.style.vectorEffect === 'non-scaling-stroke';
|
||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||
rect.setAttribute('style', 'vector-effect:non-scaling-stroke');
|
||||
return rect.style.vectorEffect === 'non-scaling-stroke';
|
||||
}());
|
||||
|
||||
var supportsNativeSVGTransformLists_ = (function () {
|
||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||
var rxform = rect.transform.baseVal;
|
||||
var t1 = svg.createSVGTransform();
|
||||
rxform.appendItem(t1);
|
||||
var r1 = rxform.getItem(0);
|
||||
return r1 instanceof SVGTransform && t1 instanceof SVGTransform &&
|
||||
r1.type === t1.type && r1.angle === t1.angle &&
|
||||
r1.matrix.a === t1.matrix.a &&
|
||||
r1.matrix.b === t1.matrix.b &&
|
||||
r1.matrix.c === t1.matrix.c &&
|
||||
r1.matrix.d === t1.matrix.d &&
|
||||
r1.matrix.e === t1.matrix.e &&
|
||||
r1.matrix.f === t1.matrix.f;
|
||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||
var rxform = rect.transform.baseVal;
|
||||
var t1 = svg.createSVGTransform();
|
||||
rxform.appendItem(t1);
|
||||
var r1 = rxform.getItem(0);
|
||||
return r1 instanceof SVGTransform && t1 instanceof SVGTransform &&
|
||||
r1.type === t1.type && r1.angle === t1.angle &&
|
||||
r1.matrix.a === t1.matrix.a &&
|
||||
r1.matrix.b === t1.matrix.b &&
|
||||
r1.matrix.c === t1.matrix.c &&
|
||||
r1.matrix.d === t1.matrix.d &&
|
||||
r1.matrix.e === t1.matrix.e &&
|
||||
r1.matrix.f === t1.matrix.f;
|
||||
}());
|
||||
|
||||
// Public API
|
||||
|
||||
Reference in New Issue
Block a user