From e557f346e9f501ee264435fb4d8860bbf734d649 Mon Sep 17 00:00:00 2001
From: Jeff Schiller
Date: Thu, 13 Jan 2011 06:57:26 +0000
Subject: [PATCH] Add unused document JS module and test. Change svgcanvas to
always increment object ids for every call to getNextId().
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1908 eee81c28-f429-11dd-99c0-75d572ba1ddd
---
Makefile | 1 +
editor/document.js | 104 +++++++++++++++++++++++++
editor/svg-editor.html | 1 +
editor/svgcanvas.js | 35 ++++-----
test/all_tests.html | 1 +
test/document_test.html | 168 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 290 insertions(+), 20 deletions(-)
create mode 100644 editor/document.js
create mode 100644 test/document_test.html
diff --git a/Makefile b/Makefile
index ade3ed2a..08b7ec19 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ build/$(PACKAGE):
--js sanitize.js \
--js history.js \
--js select.js \
+ --js document.js \
--js svgcanvas.js \
--js svg-editor.js \
--js locale/locale.js \
diff --git a/editor/document.js b/editor/document.js
new file mode 100644
index 00000000..ce6d779a
--- /dev/null
+++ b/editor/document.js
@@ -0,0 +1,104 @@
+/**
+ * Package: svgedit.document
+ *
+ * Licensed under the Apache License, Version 2
+ *
+ * Copyright(c) 2010 Jeff Schiller
+ */
+
+/*
+ TODOs:
+
+ Phase 1:
+ - migrate svgcanvas to using a Document object for its calls to getNextId() and getId()
+ - migrate usages of randomizeIds() to proxy into the Document
+
+ Phase 2:
+ - migrate uniquifyElems into this module
+ - migrate as many usages of svgcontent in svgcanvas to using a Document instance as possible
+
+ */
+// Dependencies:
+// 1) jQuery
+
+(function() {
+if (!window.svgedit) {
+ window.svgedit = {};
+}
+
+if (!svgedit.document) {
+ svgedit.document = {};
+}
+
+var svg_ns = "http://www.w3.org/2000/svg";
+var se_ns = "http://svg-edit.googlecode.com";
+
+/**
+ * This class encapsulates the concept of a SVG-edit document.
+ *
+ * @param svgElem {SVGSVGElement} The SVG DOM Element that this JS object
+ * encapsulates. If the svgElem has a se:nonce attribute on it, then
+ * IDs will use the nonce as they are generated.
+ * @param opt_idPrefix {String} The ID prefix to use. Defaults to "svg_"
+ * if not specified.
+ */
+svgedit.document.Document = function(svgElem, opt_idPrefix) {
+ if (!svgElem || !svgElem.tagName || !svgElem.namespaceURI ||
+ svgElem.tagName != 'svg' || svgElem.namespaceURI != svg_ns) {
+ throw "Error: svgedit.document.Document instance initialized without a
+
+
+
+
+
+
+
+