sproutcore 1.6.0.rc.1-x86-mingw32 → 1.6.0.rc.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. data/CHANGELOG +31 -6
  2. data/{History.txt → History.rdoc} +0 -0
  3. data/{README.txt → README.rdoc} +3 -2
  4. data/Rakefile +15 -15
  5. data/{Todo.txt → Todo.rdoc} +0 -0
  6. data/VERSION.yml +1 -1
  7. data/lib/buildtasks/manifest.rake +11 -4
  8. data/lib/buildtasks/target.rake +20 -23
  9. data/lib/frameworks/sproutcore/CHANGELOG.md +36 -0
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +2 -42
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/bind.js +2 -1
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js +3 -1
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/checkbox_support.js +5 -5
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +29 -12
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +4 -4
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/template_helpers/text_field_support.js +9 -0
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js +110 -0
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +63 -26
  19. data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +25 -5
  20. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +3 -3
  21. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/nested_records/nested_record_array.js +26 -3
  22. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/core_methods.js +74 -53
  23. data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +6 -7
  24. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +6 -3
  25. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/alert/ui.js +25 -1
  26. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +1 -3
  27. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/tab/ui.js +20 -1
  28. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +1 -1
  29. data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +46 -49
  30. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +23 -0
  31. data/lib/frameworks/sproutcore/frameworks/foundation/views/container.js +14 -2
  32. data/lib/frameworks/sproutcore/frameworks/jquery/jquery-buffered.js +2 -76
  33. data/lib/frameworks/sproutcore/frameworks/jquery/jquery.js +3348 -1591
  34. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +25 -5
  35. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +0 -3
  36. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/objectForPropertyPath.js +10 -5
  37. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/requiredObjectForPropertyPath.js +29 -0
  38. data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue.js +98 -0
  39. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
  40. data/lib/frameworks/sproutcore/themes/ace/resources/split/split.css +1 -1
  41. data/lib/gen/language/Buildfile +1 -1
  42. data/lib/sproutcore.rb +1 -14
  43. data/lib/sproutcore/buildfile/string_ext.rb +0 -4
  44. data/lib/sproutcore/helpers/cssmin.rb +44 -59
  45. data/lib/sproutcore/helpers/text_helper.rb +11 -13
  46. data/lib/sproutcore/models/manifest.rb +4 -4
  47. data/lib/sproutcore/models/target.rb +11 -110
  48. data/lib/sproutcore/rack.rb +0 -1
  49. data/lib/sproutcore/rack/dev.rb +0 -1
  50. data/lib/sproutcore/rack/proxy.rb +9 -8
  51. data/lib/sproutcore/rack/service.rb +1 -1
  52. data/lib/sproutcore/render_engines/haml.rb +2 -5
  53. data/lib/sproutcore/tools/build.rb +2 -0
  54. data/lib/sproutcore/tools/docs.rb +7 -36
  55. data/lib/sproutcore/tools/manifest.rb +1 -1
  56. data/spec/buildtasks/target_spec.rb +9 -0
  57. data/spec/fixtures/real_world/frameworks/sproutcore/Buildfile +1 -1
  58. data/sproutcore.gemspec +3 -4
  59. data/vendor/chance/lib/chance/instance.rb +5 -8
  60. metadata +41 -207
  61. data/lib/doc_templates/jsdoc/allclasses.tmpl +0 -17
  62. data/lib/doc_templates/jsdoc/allfiles.tmpl +0 -56
  63. data/lib/doc_templates/jsdoc/class.tmpl +0 -487
  64. data/lib/doc_templates/jsdoc/index.tmpl +0 -38
  65. data/lib/doc_templates/jsdoc/publish.js +0 -170
  66. data/lib/doc_templates/jsdoc/static/default.css +0 -162
  67. data/lib/doc_templates/jsdoc/static/header.html +0 -2
  68. data/lib/doc_templates/jsdoc/static/index.html +0 -19
  69. data/lib/doc_templates/jsdoc/symbol.tmpl +0 -35
  70. data/lib/doc_templates/sproutcore/allclasses.tmpl +0 -0
  71. data/lib/doc_templates/sproutcore/allfiles.tmpl +0 -56
  72. data/lib/doc_templates/sproutcore/class.tmpl +0 -674
  73. data/lib/doc_templates/sproutcore/classes-json.tmpl +0 -55
  74. data/lib/doc_templates/sproutcore/index.tmpl +0 -62
  75. data/lib/doc_templates/sproutcore/publish.js +0 -346
  76. data/lib/doc_templates/sproutcore/static/default.css +0 -258
  77. data/lib/doc_templates/sproutcore/static/header.html +0 -2
  78. data/lib/doc_templates/sproutcore/static/index.html +0 -19
  79. data/lib/doc_templates/sproutcore/symbol.tmpl +0 -35
  80. data/lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js +0 -55
  81. data/lib/sproutcore/rack/docs.rb +0 -24
  82. data/spec/fixtures/real_world/frameworks/sproutcore/apps/docs/PLACEHOLDER +0 -0
  83. data/vendor/jsdoc/README.txt +0 -151
  84. data/vendor/jsdoc/app/frame.js +0 -33
  85. data/vendor/jsdoc/app/frame/Chain.js +0 -102
  86. data/vendor/jsdoc/app/frame/Dumper.js +0 -144
  87. data/vendor/jsdoc/app/frame/Hash.js +0 -47
  88. data/vendor/jsdoc/app/frame/Link.js +0 -142
  89. data/vendor/jsdoc/app/frame/Namespace.js +0 -10
  90. data/vendor/jsdoc/app/frame/Opt.js +0 -134
  91. data/vendor/jsdoc/app/frame/Reflection.js +0 -26
  92. data/vendor/jsdoc/app/frame/String.js +0 -93
  93. data/vendor/jsdoc/app/frame/Testrun.js +0 -129
  94. data/vendor/jsdoc/app/handlers/FOODOC.js +0 -26
  95. data/vendor/jsdoc/app/handlers/XMLDOC.js +0 -26
  96. data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +0 -159
  97. data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +0 -16
  98. data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +0 -292
  99. data/vendor/jsdoc/app/lib/JSDOC.js +0 -98
  100. data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +0 -200
  101. data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +0 -294
  102. data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +0 -162
  103. data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +0 -100
  104. data/vendor/jsdoc/app/lib/JSDOC/Lang.js +0 -144
  105. data/vendor/jsdoc/app/lib/JSDOC/Parser.js +0 -109
  106. data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +0 -33
  107. data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +0 -681
  108. data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +0 -226
  109. data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +0 -41
  110. data/vendor/jsdoc/app/lib/JSDOC/Token.js +0 -18
  111. data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +0 -332
  112. data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +0 -133
  113. data/vendor/jsdoc/app/lib/JSDOC/Util.js +0 -32
  114. data/vendor/jsdoc/app/lib/JSDOC/Walker.js +0 -453
  115. data/vendor/jsdoc/app/main.js +0 -74
  116. data/vendor/jsdoc/app/plugins/commentSrcJson.js +0 -19
  117. data/vendor/jsdoc/app/plugins/frameworkPrototype.js +0 -16
  118. data/vendor/jsdoc/app/plugins/functionCall.js +0 -10
  119. data/vendor/jsdoc/app/plugins/publishSrcHilite.js +0 -62
  120. data/vendor/jsdoc/app/plugins/sproutcoreTags.js +0 -26
  121. data/vendor/jsdoc/app/plugins/symbolLink.js +0 -9
  122. data/vendor/jsdoc/app/plugins/tagParamConfig.js +0 -31
  123. data/vendor/jsdoc/app/plugins/tagSynonyms.js +0 -43
  124. data/vendor/jsdoc/app/run.js +0 -346
  125. data/vendor/jsdoc/app/t/TestDoc.js +0 -144
  126. data/vendor/jsdoc/app/t/runner.js +0 -13
  127. data/vendor/jsdoc/app/test.js +0 -304
  128. data/vendor/jsdoc/app/test/addon.js +0 -24
  129. data/vendor/jsdoc/app/test/anon_inner.js +0 -14
  130. data/vendor/jsdoc/app/test/augments.js +0 -31
  131. data/vendor/jsdoc/app/test/augments2.js +0 -26
  132. data/vendor/jsdoc/app/test/borrows.js +0 -41
  133. data/vendor/jsdoc/app/test/borrows2.js +0 -23
  134. data/vendor/jsdoc/app/test/config.js +0 -22
  135. data/vendor/jsdoc/app/test/constructs.js +0 -18
  136. data/vendor/jsdoc/app/test/encoding.js +0 -10
  137. data/vendor/jsdoc/app/test/encoding_other.js +0 -12
  138. data/vendor/jsdoc/app/test/functions_anon.js +0 -39
  139. data/vendor/jsdoc/app/test/functions_nested.js +0 -33
  140. data/vendor/jsdoc/app/test/global.js +0 -13
  141. data/vendor/jsdoc/app/test/globals.js +0 -25
  142. data/vendor/jsdoc/app/test/ignore.js +0 -10
  143. data/vendor/jsdoc/app/test/inner.js +0 -16
  144. data/vendor/jsdoc/app/test/jsdoc_test.js +0 -477
  145. data/vendor/jsdoc/app/test/lend.js +0 -33
  146. data/vendor/jsdoc/app/test/memberof.js +0 -20
  147. data/vendor/jsdoc/app/test/memberof_constructor.js +0 -15
  148. data/vendor/jsdoc/app/test/name.js +0 -19
  149. data/vendor/jsdoc/app/test/namespace_nested.js +0 -23
  150. data/vendor/jsdoc/app/test/nocode.js +0 -13
  151. data/vendor/jsdoc/app/test/oblit_anon.js +0 -20
  152. data/vendor/jsdoc/app/test/overview.js +0 -20
  153. data/vendor/jsdoc/app/test/param_inline.js +0 -37
  154. data/vendor/jsdoc/app/test/params_optional.js +0 -8
  155. data/vendor/jsdoc/app/test/prototype.js +0 -17
  156. data/vendor/jsdoc/app/test/prototype_nested.js +0 -9
  157. data/vendor/jsdoc/app/test/prototype_oblit.js +0 -13
  158. data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +0 -24
  159. data/vendor/jsdoc/app/test/public.js +0 -10
  160. data/vendor/jsdoc/app/test/shared.js +0 -42
  161. data/vendor/jsdoc/app/test/shared2.js +0 -2
  162. data/vendor/jsdoc/app/test/shortcuts.js +0 -22
  163. data/vendor/jsdoc/app/test/static_this.js +0 -13
  164. data/vendor/jsdoc/app/test/synonyms.js +0 -23
  165. data/vendor/jsdoc/app/test/tosource.js +0 -23
  166. data/vendor/jsdoc/app/test/variable_redefine.js +0 -14
  167. data/vendor/jsdoc/changes.txt +0 -47
  168. data/vendor/jsdoc/conf/sample.conf +0 -31
  169. data/vendor/jsdoc/java/build.xml +0 -36
  170. data/vendor/jsdoc/java/build_1.4.xml +0 -36
  171. data/vendor/jsdoc/java/classes/js.jar +0 -0
  172. data/vendor/jsdoc/java/src/JsDebugRun.java +0 -21
  173. data/vendor/jsdoc/java/src/JsRun.java +0 -21
  174. data/vendor/jsdoc/jsdebug.jar +0 -0
  175. data/vendor/jsdoc/jsrun.jar +0 -0
  176. data/vendor/jsdoc/t/TestDoc.js +0 -144
  177. data/vendor/jsdoc/t/runner.js +0 -13
  178. data/vendor/jsdoc/test.js +0 -304
  179. data/vendor/jsdoc/test/addon.js +0 -24
  180. data/vendor/jsdoc/test/anon_inner.js +0 -14
  181. data/vendor/jsdoc/test/augments.js +0 -31
  182. data/vendor/jsdoc/test/augments2.js +0 -26
  183. data/vendor/jsdoc/test/borrows.js +0 -41
  184. data/vendor/jsdoc/test/borrows2.js +0 -23
  185. data/vendor/jsdoc/test/config.js +0 -22
  186. data/vendor/jsdoc/test/constructs.js +0 -18
  187. data/vendor/jsdoc/test/encoding.js +0 -10
  188. data/vendor/jsdoc/test/encoding_other.js +0 -12
  189. data/vendor/jsdoc/test/functions_anon.js +0 -39
  190. data/vendor/jsdoc/test/functions_nested.js +0 -33
  191. data/vendor/jsdoc/test/global.js +0 -13
  192. data/vendor/jsdoc/test/globals.js +0 -25
  193. data/vendor/jsdoc/test/ignore.js +0 -10
  194. data/vendor/jsdoc/test/inner.js +0 -16
  195. data/vendor/jsdoc/test/jsdoc_test.js +0 -477
  196. data/vendor/jsdoc/test/lend.js +0 -33
  197. data/vendor/jsdoc/test/memberof.js +0 -20
  198. data/vendor/jsdoc/test/memberof_constructor.js +0 -15
  199. data/vendor/jsdoc/test/name.js +0 -19
  200. data/vendor/jsdoc/test/namespace_nested.js +0 -23
  201. data/vendor/jsdoc/test/nocode.js +0 -13
  202. data/vendor/jsdoc/test/oblit_anon.js +0 -20
  203. data/vendor/jsdoc/test/overview.js +0 -20
  204. data/vendor/jsdoc/test/param_inline.js +0 -37
  205. data/vendor/jsdoc/test/params_optional.js +0 -8
  206. data/vendor/jsdoc/test/prototype.js +0 -17
  207. data/vendor/jsdoc/test/prototype_nested.js +0 -9
  208. data/vendor/jsdoc/test/prototype_oblit.js +0 -13
  209. data/vendor/jsdoc/test/prototype_oblit_constructor.js +0 -24
  210. data/vendor/jsdoc/test/public.js +0 -10
  211. data/vendor/jsdoc/test/shared.js +0 -42
  212. data/vendor/jsdoc/test/shared2.js +0 -2
  213. data/vendor/jsdoc/test/shortcuts.js +0 -22
  214. data/vendor/jsdoc/test/static_this.js +0 -13
  215. data/vendor/jsdoc/test/synonyms.js +0 -23
  216. data/vendor/jsdoc/test/tosource.js +0 -23
  217. data/vendor/jsdoc/test/variable_redefine.js +0 -14
@@ -1,159 +0,0 @@
1
- LOG.inform("XMLDOC.DomReader loaded");
2
-
3
- XMLDOC.DomReader = function(root) {
4
-
5
- this.dom = root;
6
-
7
- /**
8
- * The current node the reader is on
9
- */
10
- this.node = root;
11
-
12
- /**
13
- * Get the current node the reader is on
14
- * @type XMLDOC.Parser.node
15
- */
16
- XMLDOC.DomReader.prototype.getNode = function() {
17
- return this.node;
18
- };
19
-
20
- /**
21
- * Set the node the reader should be positioned on.
22
- * @param node {XMLDOC.Parser.node}
23
- */
24
- XMLDOC.DomReader.prototype.setNode = function(node) {
25
- this.node = node;
26
- };
27
-
28
- /**
29
- * A helper method to make sure the current node will
30
- * never return null, unless null is passed as the root.
31
- * @param step {String} An expression to evaluate - should return a node or null
32
- */
33
- XMLDOC.DomReader.prototype.navigate = function(step) {
34
- var n;
35
- if ((n = step) != null)
36
- {
37
- this.node = n;
38
- return this.node;
39
- }
40
- return null;
41
- };
42
-
43
- /**
44
- * Get the root node of the current node's document.
45
- */
46
- XMLDOC.DomReader.prototype.root = function() {
47
- this.navigate(this.dom);
48
- };
49
-
50
- /**
51
- * Get the parent of the current node.
52
- */
53
- XMLDOC.DomReader.prototype.parent = function() {
54
- return this.navigate(this.node.parentNode());
55
- };
56
-
57
- /**
58
- * Get the first child of the current node.
59
- */
60
- XMLDOC.DomReader.prototype.firstChild = function() {
61
- return this.navigate(this.node.firstChild());
62
- };
63
-
64
- /**
65
- * Get the last child of the current node.
66
- */
67
- XMLDOC.DomReader.prototype.lastChild = function() {
68
- return this.navigate(this.node.lastChild());
69
- };
70
-
71
- /**
72
- * Get the next sibling of the current node.
73
- */
74
- XMLDOC.DomReader.prototype.nextSibling = function() {
75
- return this.navigate(this.node.nextSibling());
76
- };
77
-
78
- /**
79
- * Get the previous sibling of the current node.
80
- */
81
- XMLDOC.DomReader.prototype.prevSibling = function() {
82
- return this.navigate(this.node.prevSibling());
83
- };
84
-
85
- //===============================================================================================
86
- // Support methods
87
-
88
- /**
89
- * Walk the tree starting with the current node, calling the plug-in for
90
- * each node visited. Each time the plug-in is called, the DomReader
91
- * is passed as the only parameter. Use the {@link XMLDOC.DomReader#getNode} method
92
- * to access the current node. <i>This method uses a depth first traversal pattern.</i>
93
- *
94
- * @param srcFile {String} The source file being evaluated
95
- */
96
- XMLDOC.DomReader.prototype.getSymbols = function(srcFile)
97
- {
98
- XMLDOC.DomReader.symbols = [];
99
- XMLDOC.DomReader.currentFile = srcFile;
100
- JSDOC.Symbol.srcFile = (srcFile || "");
101
-
102
- if (defined(JSDOC.PluginManager)) {
103
- JSDOC.PluginManager.run("onDomGetSymbols", this);
104
- }
105
-
106
- return XMLDOC.DomReader.symbols;
107
- };
108
-
109
- /**
110
- * Find the node with the given name using a depth first traversal.
111
- * Does not modify the DomReader's current node.
112
- *
113
- * @param name {String} The name of the node to find
114
- * @return the node that was found, or null if not found
115
- */
116
- XMLDOC.DomReader.prototype.findNode = function(name)
117
- {
118
- var findNode = null;
119
-
120
- // Start at the current node and move into the subtree,
121
- // looking for the node with the given name
122
- function deeper(node, find)
123
- {
124
- var look = null;
125
-
126
- if (node) {
127
- if (node.name == find)
128
- {
129
- return node;
130
- }
131
-
132
- if (node.firstChild())
133
- {
134
- look = deeper(node.firstChild(), find);
135
- }
136
-
137
- if (!look && node.nextSibling())
138
- {
139
- look = deeper(node.nextSibling(), find);
140
- }
141
- }
142
-
143
- return look;
144
- }
145
-
146
- return deeper(this.getNode().firstChild(), name);
147
- };
148
-
149
- /**
150
- * Find the next node with the given name using a depth first traversal.
151
- *
152
- * @param name {String} The name of the node to find
153
- */
154
- XMLDOC.DomReader.prototype.findPreviousNode = function(name)
155
- {
156
- };
157
-
158
- };
159
-
@@ -1,16 +0,0 @@
1
- LOG.inform("XMLDOC.symbolize loaded");
2
-
3
- /**
4
- * Convert the source file to a set of symbols
5
- */
6
- XMLDOC.symbolize = function(srcFile, src) {
7
-
8
- LOG.inform("Symbolizing file '" + srcFile + "'");
9
-
10
- // XML files already have a defined structure, so we don't need to
11
- // do anything but parse them. The DOM reader can create a symbol
12
- // table from the parsed XML.
13
- var dr = new XMLDOC.DomReader(XMLDOC.Parser.parse(src));
14
- return dr.getSymbols(srcFile);
15
-
16
- };
@@ -1,292 +0,0 @@
1
- LOG.inform("XMLDOC.Parser loaded");
2
-
3
- /**
4
- * XML Parser object. Returns an {@link #XMLDOC.Parser.node} which is
5
- * the root element of the parsed document.
6
- * <p/>
7
- * By default, this parser will only handle well formed XML. To
8
- * allow the parser to handle HTML, set the <tt>XMLDOC.Parser.strictMode</tt>
9
- * variable to <tt>false</tt> before calling <tt>XMLDOC.Parser.parse()</tt>.
10
- * <p/>
11
- * <i>Note: If you pass poorly formed XML, it will cause the parser to throw
12
- * an exception.</i>
13
- *
14
- * @author Brett Fattori (bfattori@fry.com)
15
- * @author $Author: micmath $
16
- * @version $Revision: 497 $
17
- */
18
- XMLDOC.Parser = {};
19
-
20
- /**
21
- * Strict mode setting. Setting this to false allows HTML-style source to
22
- * be parsed. Normally, well formed XML has defined end tags, or empty tags
23
- * are properly formed. Default: <tt>true</tt>
24
- * @type Boolean
25
- */
26
- XMLDOC.Parser.strictMode = true;
27
-
28
- /**
29
- * A node in an XML Document. Node types are ROOT, ELEMENT, COMMENT, PI, and TEXT.
30
- * @param parent {XMLDOC.Parser.node} The parent node
31
- * @param name {String} The node name
32
- * @param type {String} One of the types
33
- */
34
- XMLDOC.Parser.node = function(parent, name, type)
35
- {
36
- this.name = name;
37
- this.type = type || "ELEMENT";
38
- this.parent = parent;
39
- this.charData = "";
40
- this.attrs = {};
41
- this.nodes = [];
42
- this.cPtr = 0;
43
-
44
- XMLDOC.Parser.node.prototype.getAttributeNames = function() {
45
- var a = [];
46
- for (var o in this.attrs)
47
- {
48
- a.push(o);
49
- }
50
-
51
- return a;
52
- };
53
-
54
- XMLDOC.Parser.node.prototype.getAttribute = function(attr) {
55
- return this.attrs[attr];
56
- };
57
-
58
- XMLDOC.Parser.node.prototype.setAttribute = function(attr, val) {
59
- this.attrs[attr] = val;
60
- };
61
-
62
- XMLDOC.Parser.node.prototype.getChild = function(idx) {
63
- return this.nodes[idx];
64
- };
65
-
66
- XMLDOC.Parser.node.prototype.parentNode = function() {
67
- return this.parent;
68
- };
69
-
70
- XMLDOC.Parser.node.prototype.firstChild = function() {
71
- return this.nodes[0];
72
- };
73
-
74
- XMLDOC.Parser.node.prototype.lastChild = function() {
75
- return this.nodes[this.nodes.length - 1];
76
- };
77
-
78
- XMLDOC.Parser.node.prototype.nextSibling = function() {
79
- var p = this.parent;
80
- if (p && (p.nodes.indexOf(this) + 1 != p.nodes.length))
81
- {
82
- return p.getChild(p.nodes.indexOf(this) + 1);
83
- }
84
- return null;
85
- };
86
-
87
- XMLDOC.Parser.node.prototype.prevSibling = function() {
88
- var p = this.parent;
89
- if (p && (p.nodes.indexOf(this) - 1 >= 0))
90
- {
91
- return p.getChild(p.nodes.indexOf(this) - 1);
92
- }
93
- return null;
94
- };
95
- };
96
-
97
- /**
98
- * Parse an XML Document from the specified source. The XML should be
99
- * well formed, unless strict mode is disabled, then the parser will
100
- * handle HTML-style XML documents.
101
- * @param src {String} The source to parse
102
- */
103
- XMLDOC.Parser.parse = function(src)
104
- {
105
- var A = [];
106
-
107
- // Normailize whitespace
108
- A = src.split("\r\n");
109
- src = A.join("\n");
110
- A = src.split("\r");
111
- src = A.join("\n");
112
-
113
- // Remove XML and DOCTYPE specifier
114
- src.replace(/<\?XML .*\?>/i, "");
115
- src.replace(/<!DOCTYPE .*\>/i, "");
116
-
117
- // The document is the root node and cannot be modified or removed
118
- var doc = new XMLDOC.Parser.node(null, "ROOT", "DOCUMENT");
119
-
120
- // Let's break it down
121
- XMLDOC.Parser.eat(doc, src);
122
-
123
- return doc;
124
- };
125
-
126
- /**
127
- * The XML fragment processing routine. This method is private and should not be called
128
- * directly.
129
- * @param parentNode {XMLDOC.Parser.node} The node which is the parent of this fragment
130
- * @param src {String} The source within the fragment to process
131
- * @private
132
- */
133
- XMLDOC.Parser.eat = function(parentNode, src)
134
- {
135
- // A simple tag def
136
- var reTag = new RegExp("<(!|)(\\?|--|)((.|\\s)*?)\\2>","g");
137
-
138
- // Special tag types
139
- var reCommentTag = /<!--((.|\s)*?)-->/;
140
- var rePITag = /<\?((.|\s)*?)\?>/;
141
-
142
- // A start tag (with potential empty marker)
143
- var reStartTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*)\4)*(\/)?>/;
144
-
145
- // An empty HTML style tag (not proper XML, but we'll accept it so we can process HTML)
146
- var reHTMLEmptyTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*)\4)*>/;
147
-
148
- // Fully enclosing tag with nested tags
149
- var reEnclosingTag = /<(.*?)( +([\w_\-]*)=(\"|')(.*?)\4)*>((.|\s)*?)<\/\1>/;
150
-
151
- // Breaks down attributes
152
- var reAttributes = new RegExp(" +([\\w_\\-]*)=(\"|')(.*?)\\2","g");
153
-
154
- // Find us a tag
155
- var tag;
156
- while ((tag = reTag.exec(src)) != null)
157
- {
158
- if (tag.index > 0)
159
- {
160
- // The next tag has some text before it
161
- var text = src.substring(0, tag.index).replace(/^[ \t\n]+((.|\n)*?)[ \t\n]+$/, "$1");
162
-
163
- if (text.length > 0 && (text != "\n"))
164
- {
165
- var txtnode = new XMLDOC.Parser.node(parentNode, "", "TEXT");
166
- txtnode.charData = text;
167
-
168
- // Append the new text node
169
- parentNode.nodes.push(txtnode);
170
- }
171
-
172
- // Reset the lastIndex of reTag
173
- reTag.lastIndex -= src.substring(0, tag.index).length;
174
-
175
- // Eat the text
176
- src = src.substring(tag.index);
177
- }
178
-
179
- if (reCommentTag.test(tag[0]))
180
- {
181
- // Is this a comment?
182
- var comment = new XMLDOC.Parser.node(parentNode, "", "COMMENT");
183
- comment.charData = reCommentTag.exec(tag[0])[1];
184
-
185
- // Append the comment
186
- parentNode.nodes.push(comment);
187
-
188
- // Move the lastIndex of reTag
189
- reTag.lastIndex -= tag[0].length;
190
-
191
- // Eat the tag
192
- src = src.replace(reCommentTag, "");
193
- }
194
- else if (rePITag.test(tag[0]))
195
- {
196
- // Is this a processing instruction?
197
- var pi = new XMLDOC.Parser.node(parentNode, "", "PI");
198
- pi.charData = rePITag.exec(tag[0])[1];
199
-
200
- // Append the processing instruction
201
- parentNode.nodes.push(pi);
202
-
203
- // Move the lastIndex of reTag
204
- reTag.lastIndex -= tag[0].length;
205
-
206
- // Eat the tag
207
- src = src.replace(rePITag, "");
208
- }
209
- else if (reStartTag.test(tag[0]))
210
- {
211
- // Break it down
212
- var e = reStartTag.exec(tag[0]);
213
- var elem = new XMLDOC.Parser.node(parentNode, e[1], "ELEMENT");
214
-
215
- // Get attributes from the tag
216
- var a;
217
- while ((a = reAttributes.exec(e[2])) != null )
218
- {
219
- elem.attrs[a[1]] = a[3];
220
- }
221
-
222
- // Is this an empty XML-style tag?
223
- if (e[6] == "/")
224
- {
225
- // Append the empty element
226
- parentNode.nodes.push(elem);
227
-
228
- // Move the lastIndex of reTag (include the start tag length)
229
- reTag.lastIndex -= e[0].length;
230
-
231
- // Eat the tag
232
- src = src.replace(reStartTag, "");
233
- }
234
- else
235
- {
236
- // Check for malformed XML tags
237
- var htmlParsed = false;
238
- var htmlStartTag = reHTMLEmptyTag.exec(src);
239
-
240
- // See if there isn't an end tag within this block
241
- var reHTMLEndTag = new RegExp("</" + htmlStartTag[1] + ">");
242
- var htmlEndTag = reHTMLEndTag.exec(src);
243
-
244
- if (XMLDOC.Parser.strictMode && htmlEndTag == null)
245
- {
246
- // Poorly formed XML fails in strict mode
247
- var err = new Error("Malformed XML passed to XMLDOC.Parser... Error contains malformed 'src'");
248
- err.src = src;
249
- throw err;
250
- }
251
- else if (htmlEndTag == null)
252
- {
253
- // This is an HTML-style empty tag, store the element for it in non-strict mode
254
- parentNode.nodes.push(elem);
255
-
256
- // Eat the tag
257
- src = src.replace(reHTMLEmptyTag, "");
258
- htmlParsed = true;
259
- }
260
-
261
- // If we didn't parse HTML-style, it must be an enclosing tag
262
- if (!htmlParsed)
263
- {
264
- var enc = reEnclosingTag.exec(src);
265
-
266
- // Go deeper into the document
267
- XMLDOC.Parser.eat(elem, enc[6]);
268
-
269
- // Append the new element node
270
- parentNode.nodes.push(elem);
271
-
272
- // Eat the tag
273
- src = src.replace(reEnclosingTag, "");
274
- }
275
- }
276
-
277
- // Reset the lastIndex of reTag
278
- reTag.lastIndex = 0;
279
- }
280
- }
281
-
282
- // No tag was found... append the text if there is any
283
- src = src.replace(/^[ \t\n]+((.|\n)*?)[ \t\n]+$/, "$1");
284
- if (src.length > 0 && (src != "\n"))
285
- {
286
- var txtNode = new XMLDOC.Parser.node(parentNode, "", "TEXT");
287
- txtNode.charData = src;
288
-
289
- // Append the new text node
290
- parentNode.nodes.push(txtNode);
291
- }
292
- };