Add fully qualified function calls, shuffle a couple tiny functions into svgutils.js, add an empty coords.js module for later
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2390 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
1
Makefile
1
Makefile
@@ -16,6 +16,7 @@ JS_FILES=\
|
|||||||
svgutils.js \
|
svgutils.js \
|
||||||
sanitize.js \
|
sanitize.js \
|
||||||
history.js \
|
history.js \
|
||||||
|
coords.js \
|
||||||
select.js \
|
select.js \
|
||||||
draw.js \
|
draw.js \
|
||||||
path.js \
|
path.js \
|
||||||
|
|||||||
27
editor/coords.js
Normal file
27
editor/coords.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Coords.
|
||||||
|
*
|
||||||
|
* Licensed under the MIT License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Dependencies:
|
||||||
|
// 1) svgtransformlist.js
|
||||||
|
// 2) math.js
|
||||||
|
// 3) svgutils.js
|
||||||
|
// 4) jquery.js
|
||||||
|
// 5) history.js
|
||||||
|
|
||||||
|
var svgedit = svgedit || {};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
if (!svgedit.coords) {
|
||||||
|
svgedit.coords = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Move remapElement() into here.
|
||||||
|
// TODO: Move updateClipPath() into here.
|
||||||
|
// TODO: Move recalculateDimensions() into here.
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
<script type="text/javascript" src="svgutils.js"></script>
|
<script type="text/javascript" src="svgutils.js"></script>
|
||||||
<script type="text/javascript" src="sanitize.js"></script>
|
<script type="text/javascript" src="sanitize.js"></script>
|
||||||
<script type="text/javascript" src="history.js"></script>
|
<script type="text/javascript" src="history.js"></script>
|
||||||
|
<script type="text/javascript" src="coords.js"></script>
|
||||||
<script type="text/javascript" src="select.js"></script>
|
<script type="text/javascript" src="select.js"></script>
|
||||||
<script type="text/javascript" src="draw.js"></script>
|
<script type="text/javascript" src="draw.js"></script>
|
||||||
<script type="text/javascript" src="path.js"></script>
|
<script type="text/javascript" src="path.js"></script>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -308,20 +308,23 @@ svgedit.utilities.setHref = function(elem, val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function: findDefs
|
// Function: findDefs
|
||||||
// Parameters:
|
|
||||||
// svgElement - The <svg> element.
|
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// The document's <defs> element, create it first if necessary
|
// The document's <defs> element, create it first if necessary
|
||||||
svgedit.utilities.findDefs = function(svgElement) {
|
svgedit.utilities.findDefs = function() {
|
||||||
var svgElement = editorContext_.getSVGContent().documentElement;
|
var svgElement = editorContext_.getSVGContent().documentElement;
|
||||||
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 {
|
||||||
// first child is a comment, so call nextSibling
|
defs = svgElement.ownerDocument.createElementNS(SVGNS, "defs");
|
||||||
defs = svgElement.insertBefore( svgElement.ownerDocument.createElementNS(SVGNS, "defs" ), svgElement.firstChild.nextSibling);
|
if (svgElement.firstChild) {
|
||||||
|
// first child is a comment, so call nextSibling
|
||||||
|
svgElement.insertBefore(defs, svgElement.firstChild.nextSibling);
|
||||||
|
} else {
|
||||||
|
svgElement.appendChild(defs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return defs;
|
return defs;
|
||||||
};
|
};
|
||||||
@@ -558,6 +561,15 @@ svgedit.utilities.getRotationAngle = function(elem, to_rad) {
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Function getRefElem
|
||||||
|
// Get the reference element associated with the given attribute value
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// attrVal - The attribute value as a string
|
||||||
|
svgedit.utilities.getRefElem = this.getRefElem = function(attrVal) {
|
||||||
|
return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(attrVal).substr(1));
|
||||||
|
};
|
||||||
|
|
||||||
// Function: getElem
|
// Function: getElem
|
||||||
// Get a DOM element by ID within the SVG root element.
|
// Get a DOM element by ID within the SVG root element.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<iframe src='units_test.html' width='100%' height='70' scrolling='no'></iframe>
|
<iframe src='units_test.html' width='100%' height='70' scrolling='no'></iframe>
|
||||||
<iframe src='path_test.html' width='100%' height='70' scrolling='no'></iframe>
|
<iframe src='path_test.html' width='100%' height='70' scrolling='no'></iframe>
|
||||||
<iframe src='sanitize_test.html' width='100%' height='70' scrolling='no'></iframe>
|
<iframe src='sanitize_test.html' width='100%' height='70' scrolling='no'></iframe>
|
||||||
|
<iframe src='coords_test.html' width='100%' height='70' scrolling='no'></iframe>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
|
|||||||
38
test/coords_test.html
Normal file
38
test/coords_test.html
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel='stylesheet' href='qunit/qunit.css' type='text/css'/>
|
||||||
|
<script type='text/javascript' src='../editor/jquery.js'></script>
|
||||||
|
<script type='text/javascript' src='../editor/browser.js'></script>
|
||||||
|
<script type='text/javascript' src='../editor/svgutils.js'></script>
|
||||||
|
<script type='text/javascript' src='../editor/sanitize.js'></script>
|
||||||
|
<script type='text/javascript' src='qunit/qunit.js'></script>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
$(function() {
|
||||||
|
// log function
|
||||||
|
QUnit.log = function(result, message) {
|
||||||
|
if (window.console && window.console.log) {
|
||||||
|
window.console.log(result +' :: '+ message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var svgns = 'http://www.w3.org/2000/svg';
|
||||||
|
var svg = document.createElementNS(svgns, 'svg');
|
||||||
|
|
||||||
|
// TODO: Since recalculateDimensions() and surrounding code is
|
||||||
|
// probably the largest, most complicated and strange piece of
|
||||||
|
// code in SVG-edit, we need to write a whole lot of unit tests
|
||||||
|
// for it here.
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 id='qunit-header'>Unit Tests for svgedit.coords</h1>
|
||||||
|
<h2 id='qunit-banner'></h2>
|
||||||
|
<h2 id='qunit-userAgent'></h2>
|
||||||
|
<ol id='qunit-tests'>
|
||||||
|
</ol>
|
||||||
|
<div id='anchor' style='visibility:hidden'>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user