sproutcore 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. data/History.txt +19 -0
  2. data/Manifest.txt +103 -26
  3. data/app_generators/sproutcore/templates/README +1 -1
  4. data/bin/sc-build +1 -1
  5. data/bin/sc-gen +0 -0
  6. data/bin/sc-ide +278 -0
  7. data/bin/sc-init +38 -0
  8. data/bin/sc-install +96 -0
  9. data/bin/sc-remove +94 -0
  10. data/bin/sc-server +4 -0
  11. data/bin/sc-update +94 -0
  12. data/bin/sproutcore +3 -14
  13. data/clients/sc_docs/controllers/docs.js +1 -1
  14. data/clients/sc_docs/models/doc.js +6 -0
  15. data/clients/sc_docs/views/doc_frame.js +1 -1
  16. data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
  17. data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
  18. data/frameworks/sproutcore/HISTORY +34 -2
  19. data/frameworks/sproutcore/controllers/array.js +1 -1
  20. data/frameworks/sproutcore/controllers/controller.js +1 -1
  21. data/frameworks/sproutcore/controllers/object.js +9 -6
  22. data/frameworks/sproutcore/core.js +19 -4
  23. data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
  24. data/frameworks/sproutcore/english.lproj/core.css +1 -0
  25. data/frameworks/sproutcore/english.lproj/menu.css +1 -0
  26. data/frameworks/sproutcore/foundation/application.js +3 -3
  27. data/frameworks/sproutcore/foundation/benchmark.js +1 -1
  28. data/frameworks/sproutcore/foundation/node_descriptor.js +13 -1
  29. data/frameworks/sproutcore/foundation/page.js +3 -2
  30. data/frameworks/sproutcore/foundation/path_module.js +33 -16
  31. data/frameworks/sproutcore/foundation/run_loop.js +1 -1
  32. data/frameworks/sproutcore/foundation/server.js +68 -18
  33. data/frameworks/sproutcore/foundation/string.js +1 -1
  34. data/frameworks/sproutcore/globals/window.js +62 -15
  35. data/frameworks/sproutcore/lib/core_views.rb +1 -0
  36. data/frameworks/sproutcore/lib/index.rhtml +4 -3
  37. data/frameworks/sproutcore/lib/menu_views.rb +2 -2
  38. data/frameworks/sproutcore/models/collection.js +122 -107
  39. data/frameworks/sproutcore/models/record.js +2 -2
  40. data/frameworks/sproutcore/panes/manager.js +1 -1
  41. data/frameworks/sproutcore/panes/overlay.js +3 -3
  42. data/frameworks/sproutcore/tests/controllers/object.rhtml +26 -0
  43. data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +2 -2
  44. data/frameworks/sproutcore/views/button/disclosure.js +1 -1
  45. data/frameworks/sproutcore/views/collection/collection.js +19 -15
  46. data/frameworks/sproutcore/views/collection/source_list.js +1 -1
  47. data/frameworks/sproutcore/views/collection/table.js +2 -2
  48. data/frameworks/sproutcore/views/error_explanation.js +1 -1
  49. data/frameworks/sproutcore/views/field/checkbox_field.js +1 -1
  50. data/frameworks/sproutcore/views/field/field.js +1 -1
  51. data/frameworks/sproutcore/views/field/radio_field.js +1 -1
  52. data/frameworks/sproutcore/views/field/select_field.js +1 -1
  53. data/frameworks/sproutcore/views/form.js +1 -1
  54. data/frameworks/sproutcore/views/image.js +1 -1
  55. data/frameworks/sproutcore/views/menu_item.js +1 -1
  56. data/frameworks/sproutcore/views/popup_button.js +1 -1
  57. data/frameworks/sproutcore/views/popup_menu.js +1 -1
  58. data/frameworks/sproutcore/views/progress.js +4 -2
  59. data/frameworks/sproutcore/views/radio_group.js +1 -1
  60. data/frameworks/sproutcore/views/scroll.js +1 -1
  61. data/frameworks/sproutcore/views/source_list_group.js +1 -1
  62. data/frameworks/sproutcore/views/split.js +1 -1
  63. data/frameworks/sproutcore/views/tab.js +3 -1
  64. data/frameworks/sproutcore/views/view.js +19 -3
  65. data/jsdoc/README.txt +89 -57
  66. data/jsdoc/app/frame/Chain.js +102 -0
  67. data/jsdoc/app/frame/Dumper.js +144 -0
  68. data/jsdoc/app/frame/Hash.js +47 -0
  69. data/jsdoc/app/frame/Link.js +142 -0
  70. data/jsdoc/app/frame/Namespace.js +10 -0
  71. data/jsdoc/app/frame/Opt.js +134 -0
  72. data/jsdoc/app/frame/Reflection.js +26 -0
  73. data/jsdoc/app/frame/String.js +93 -0
  74. data/jsdoc/app/frame/Testrun.js +129 -0
  75. data/jsdoc/app/frame.js +33 -0
  76. data/jsdoc/app/handlers/FOODOC.js +26 -0
  77. data/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  78. data/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  79. data/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  80. data/jsdoc/app/handlers/XMLDOC.js +26 -0
  81. data/jsdoc/app/lib/JSDOC/DocComment.js +200 -0
  82. data/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  83. data/jsdoc/app/lib/JSDOC/JsDoc.js +180 -0
  84. data/jsdoc/app/lib/JSDOC/JsPlate.js +100 -0
  85. data/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  86. data/jsdoc/app/lib/JSDOC/Parser.js +109 -0
  87. data/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  88. data/jsdoc/app/lib/JSDOC/Symbol.js +600 -0
  89. data/jsdoc/app/lib/JSDOC/SymbolSet.js +220 -0
  90. data/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  91. data/jsdoc/app/lib/JSDOC/Token.js +18 -0
  92. data/jsdoc/app/lib/JSDOC/TokenReader.js +323 -0
  93. data/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  94. data/jsdoc/app/lib/JSDOC/Util.js +32 -0
  95. data/jsdoc/app/lib/JSDOC/Walker.js +416 -0
  96. data/jsdoc/app/lib/JSDOC.js +97 -0
  97. data/jsdoc/app/main.js +74 -0
  98. data/jsdoc/app/plugins/commentSrcJson.js +19 -0
  99. data/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  100. data/jsdoc/app/plugins/functionCall.js +10 -0
  101. data/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  102. data/jsdoc/app/plugins/sproutcoreTags.js +26 -0
  103. data/jsdoc/app/plugins/symbolLink.js +9 -0
  104. data/jsdoc/app/plugins/tagParamConfig.js +31 -0
  105. data/jsdoc/app/plugins/tagSynonyms.js +43 -0
  106. data/jsdoc/app/run.js +339 -137
  107. data/jsdoc/changes.txt +47 -0
  108. data/jsdoc/conf/sample.conf +31 -0
  109. data/jsdoc/java/build.xml +36 -0
  110. data/jsdoc/java/build_1.4.xml +36 -0
  111. data/jsdoc/java/classes/js.jar +0 -0
  112. data/jsdoc/java/src/JsDebugRun.java +21 -0
  113. data/jsdoc/java/src/JsRun.java +21 -0
  114. data/jsdoc/jsdebug.jar +0 -0
  115. data/jsdoc/jsrun.jar +0 -0
  116. data/jsdoc/t/TestDoc.js +144 -0
  117. data/jsdoc/t/runner.js +13 -0
  118. data/jsdoc/templates/sproutcore/allclasses.tmpl +17 -0
  119. data/jsdoc/templates/sproutcore/allfiles.tmpl +56 -0
  120. data/jsdoc/templates/sproutcore/class.tmpl +408 -326
  121. data/jsdoc/templates/sproutcore/index.tmpl +30 -31
  122. data/jsdoc/templates/sproutcore/publish.js +173 -81
  123. data/jsdoc/templates/sproutcore/static/default.css +191 -0
  124. data/jsdoc/templates/sproutcore/static/header.html +2 -0
  125. data/jsdoc/templates/sproutcore/static/index.html +19 -0
  126. data/jsdoc/templates/sproutcore/symbol.tmpl +35 -0
  127. data/jsdoc/test/addon.js +24 -0
  128. data/jsdoc/test/anon_inner.js +14 -0
  129. data/jsdoc/test/augments.js +31 -0
  130. data/jsdoc/test/augments2.js +26 -0
  131. data/jsdoc/test/borrows.js +41 -0
  132. data/jsdoc/test/borrows2.js +23 -0
  133. data/jsdoc/test/config.js +22 -0
  134. data/jsdoc/test/constructs.js +18 -0
  135. data/jsdoc/test/encoding.js +10 -0
  136. data/jsdoc/test/encoding_other.js +12 -0
  137. data/jsdoc/test/functions_anon.js +39 -0
  138. data/jsdoc/test/functions_nested.js +33 -0
  139. data/jsdoc/test/global.js +13 -0
  140. data/jsdoc/test/globals.js +25 -0
  141. data/jsdoc/test/ignore.js +10 -0
  142. data/jsdoc/test/inner.js +16 -0
  143. data/jsdoc/test/jsdoc_test.js +477 -0
  144. data/jsdoc/test/lend.js +33 -0
  145. data/jsdoc/test/memberof.js +20 -0
  146. data/jsdoc/test/memberof_constructor.js +15 -0
  147. data/jsdoc/test/name.js +19 -0
  148. data/jsdoc/test/namespace_nested.js +23 -0
  149. data/jsdoc/test/nocode.js +13 -0
  150. data/jsdoc/test/oblit_anon.js +20 -0
  151. data/jsdoc/test/overview.js +20 -0
  152. data/jsdoc/test/param_inline.js +37 -0
  153. data/jsdoc/test/params_optional.js +8 -0
  154. data/jsdoc/test/prototype.js +17 -0
  155. data/jsdoc/test/prototype_nested.js +9 -0
  156. data/jsdoc/test/prototype_oblit.js +13 -0
  157. data/jsdoc/test/prototype_oblit_constructor.js +24 -0
  158. data/jsdoc/test/public.js +10 -0
  159. data/jsdoc/test/shared.js +42 -0
  160. data/jsdoc/test/shared2.js +2 -0
  161. data/jsdoc/test/shortcuts.js +22 -0
  162. data/jsdoc/test/static_this.js +13 -0
  163. data/jsdoc/test/synonyms.js +23 -0
  164. data/jsdoc/test/tosource.js +23 -0
  165. data/jsdoc/test/variable_redefine.js +14 -0
  166. data/jsdoc/test.js +304 -0
  167. data/lib/sproutcore/build_tools/resource_builder.rb +6 -1
  168. data/lib/sproutcore/bundle_installer.rb +268 -0
  169. data/lib/sproutcore/jsdoc.rb +7 -6
  170. data/lib/sproutcore/library.rb +38 -0
  171. data/lib/sproutcore/merb/bundle_controller.rb +8 -4
  172. data/lib/sproutcore/version.rb +1 -1
  173. data/lib/sproutcore.rb +1 -1
  174. data/script/destroy +0 -0
  175. data/script/generate +0 -0
  176. data/script/txt2html +0 -0
  177. metadata +117 -29
  178. data/clients/view_builder/core.js +0 -19
  179. data/clients/view_builder/english.lproj/body.css +0 -149
  180. data/clients/view_builder/english.lproj/body.rhtml +0 -18
  181. data/clients/view_builder/english.lproj/strings.js +0 -14
  182. data/clients/view_builder/main.js +0 -37
  183. data/jsdoc/app/DocFile.js +0 -137
  184. data/jsdoc/app/DocTag.js +0 -110
  185. data/jsdoc/app/Doclet.js +0 -63
  186. data/jsdoc/app/Dumper.js +0 -143
  187. data/jsdoc/app/JsDoc.js +0 -103
  188. data/jsdoc/app/JsHilite.js +0 -45
  189. data/jsdoc/app/JsIO.js +0 -163
  190. data/jsdoc/app/JsParse.js +0 -385
  191. data/jsdoc/app/JsPlate.js +0 -130
  192. data/jsdoc/app/JsTestrun.js +0 -129
  193. data/jsdoc/app/JsToke.js +0 -564
  194. data/jsdoc/app/Symbol.js +0 -298
  195. data/jsdoc/app/Transformer.js +0 -14
  196. data/jsdoc/app/Util.js +0 -97
  197. data/jsdoc/app/js.jar +0 -0
  198. data/jsdoc/plugins/min.js +0 -316
  199. data/jsdoc/plugins/strip.js +0 -20
  200. data/jsdoc/templates/sproutcore/default.css +0 -191
  201. data/jsdoc/templates/sproutcore/index.html +0 -13
  202. data/jsdoc/templates/sproutcore/prototype.js +0 -4186
  203. data/jsdoc/templates/sproutcore/splash.html +0 -7
@@ -0,0 +1,102 @@
1
+ /**@constructor*/
2
+ function ChainNode(object, link) {
3
+ this.value = object;
4
+ this.link = link; // describes this node's relationship to the previous node
5
+ }
6
+
7
+ /**@constructor*/
8
+ function Chain(valueLinks) {
9
+ this.nodes = [];
10
+ this.cursor = -1;
11
+
12
+ if (valueLinks && valueLinks.length > 0) {
13
+ this.push(valueLinks[0], "//");
14
+ for (var i = 1, l = valueLinks.length; i < l; i+=2) {
15
+ this.push(valueLinks[i+1], valueLinks[i]);
16
+ }
17
+ }
18
+ }
19
+
20
+ Chain.prototype.push = function(o, link) {
21
+ if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link));
22
+ else this.nodes.push(new ChainNode(o));
23
+ }
24
+
25
+ Chain.prototype.unshift = function(o, link) {
26
+ if (this.nodes.length > 0 && link) this.nodes[0].link = link;
27
+ this.nodes.unshift(new ChainNode(o));
28
+ this.cursor++;
29
+ }
30
+
31
+ Chain.prototype.get = function() {
32
+ if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null;
33
+ return this.nodes[this.cursor];
34
+ }
35
+
36
+ Chain.prototype.first = function() {
37
+ this.cursor = 0;
38
+ return this.get();
39
+ }
40
+
41
+ Chain.prototype.last = function() {
42
+ this.cursor = this.nodes.length-1;
43
+ return this.get();
44
+ }
45
+
46
+ Chain.prototype.next = function() {
47
+ this.cursor++;
48
+ return this.get();
49
+ }
50
+
51
+ Chain.prototype.prev = function() {
52
+ this.cursor--;
53
+ return this.get();
54
+ }
55
+
56
+ Chain.prototype.toString = function() {
57
+ var string = "";
58
+ for (var i = 0, l = this.nodes.length; i < l; i++) {
59
+ if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> ";
60
+ string += this.nodes[i].value.toString();
61
+ }
62
+ return string;
63
+ }
64
+
65
+ Chain.prototype.joinLeft = function() {
66
+ var result = "";
67
+ for (var i = 0, l = this.cursor; i < l; i++) {
68
+ if (result && this.nodes[i].link) result += this.nodes[i].link;
69
+ result += this.nodes[i].value.toString();
70
+ }
71
+ return result;
72
+ }
73
+
74
+
75
+ /* USAGE:
76
+
77
+ var path = "one/two/three.four/five-six";
78
+ var pathChain = new Chain(path.split(/([\/.-])/));
79
+ print(pathChain);
80
+
81
+ var lineage = new Chain();
82
+ lineage.push("Port");
83
+ lineage.push("Les", "son");
84
+ lineage.push("Dawn", "daughter");
85
+ lineage.unshift("Purdie", "son");
86
+
87
+ print(lineage);
88
+
89
+ // walk left
90
+ for (var node = lineage.last(); node !== null; node = lineage.prev()) {
91
+ print("< "+node.value);
92
+ }
93
+
94
+ // walk right
95
+ var node = lineage.first()
96
+ while (node !== null) {
97
+ print(node.value);
98
+ node = lineage.next();
99
+ if (node && node.link) print("had a "+node.link+" named");
100
+ }
101
+
102
+ */
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @class
3
+ <pre>
4
+ This is a lightly modified version of Kevin Jones' JavaScript
5
+ library Data.Dump. To download the original visit:
6
+ <a href="http://openjsan.org/doc/k/ke/kevinj/Data/Dump/">http://openjsan.org/doc/k/ke/kevinj/Data/Dump/</a>
7
+
8
+ AUTHORS
9
+
10
+ The Data.Dump JavaScript module is written by Kevin Jones
11
+ (kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
12
+ based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
13
+
14
+ COPYRIGHT
15
+
16
+ Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
17
+ Copyright 1996-1998 Gurusamy Sarathy.
18
+
19
+ This program is free software; you can redistribute it and/or modify
20
+ it under the terms of the Perl Artistic License
21
+
22
+ See http://www.perl.com/perl/misc/Artistic.html
23
+ </pre>
24
+ * @static
25
+ */
26
+ Dumper = {
27
+ /** @param [...] The objects to dump. */
28
+ dump: function () {
29
+ if (arguments.length > 1)
30
+ return this._dump(arguments);
31
+ else if (arguments.length == 1)
32
+ return this._dump(arguments[0]);
33
+ else
34
+ return "()";
35
+ },
36
+
37
+ _dump: function (obj) {
38
+ if (typeof obj == 'undefined') return 'undefined';
39
+ var out;
40
+ if (obj.serialize) { return obj.serialize(); }
41
+ var type = this._typeof(obj);
42
+ if (obj.circularReference) obj.circularReference++;
43
+ switch (type) {
44
+ case 'circular':
45
+ out = "{ //circularReference\n}";
46
+ break;
47
+ case 'object':
48
+ var pairs = new Array;
49
+
50
+ for (var prop in obj) {
51
+ if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties
52
+ pairs.push(prop + ': ' + this._dump(obj[prop]));
53
+ }
54
+ }
55
+
56
+ out = '{' + this._format_list(pairs) + '}';
57
+ break;
58
+
59
+ case 'string':
60
+ for (var prop in Dumper.ESC) {
61
+ if (Dumper.ESC.hasOwnProperty(prop)) {
62
+ obj = obj.replace(prop, Dumper.ESC[prop]);
63
+ }
64
+ }
65
+
66
+ // Escape UTF-8 Strings
67
+ if (obj.match(/^[\x00-\x7f]*$/)) {
68
+ out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"';
69
+ }
70
+ else {
71
+ out = "unescape('"+escape(obj)+"')";
72
+ }
73
+ break;
74
+
75
+ case 'array':
76
+ var elems = new Array;
77
+
78
+ for (var i=0; i<obj.length; i++) {
79
+ elems.push( this._dump(obj[i]) );
80
+ }
81
+
82
+ out = '[' + this._format_list(elems) + ']';
83
+ break;
84
+
85
+ case 'date':
86
+ // firefox returns GMT strings from toUTCString()...
87
+ var utc_string = obj.toUTCString().replace(/GMT/,'UTC');
88
+ out = 'new Date("' + utc_string + '")';
89
+ break;
90
+
91
+ case 'element':
92
+ // DOM element
93
+ out = this._dump_dom(obj);
94
+ break;
95
+
96
+ default:
97
+ out = obj;
98
+ }
99
+
100
+ out = String(out).replace(/\n/g, '\n ');
101
+ out = out.replace(/\n (.*)$/,"\n$1");
102
+
103
+ return out;
104
+ },
105
+
106
+ _format_list: function (list) {
107
+ if (!list.length) return '';
108
+ var nl = list.toString().length > 60 ? '\n' : ' ';
109
+ return nl + list.join(',' + nl) + nl;
110
+ },
111
+
112
+ _typeof: function (obj) {
113
+ if (obj && obj.circularReference && obj.circularReference > 1) return 'circular';
114
+ if (Array.prototype.isPrototypeOf(obj)) return 'array';
115
+ if (Date.prototype.isPrototypeOf(obj)) return 'date';
116
+ if (typeof obj.nodeType != 'undefined') return 'element';
117
+ return typeof(obj);
118
+ },
119
+
120
+ _dump_dom: function (obj) {
121
+ return '"' + Dumper.nodeTypes[obj.nodeType] + '"';
122
+ }
123
+ };
124
+
125
+ Dumper.ESC = {
126
+ "\t": "\\t",
127
+ "\n": "\\n",
128
+ "\f": "\\f"
129
+ };
130
+
131
+ Dumper.nodeTypes = {
132
+ 1: "ELEMENT_NODE",
133
+ 2: "ATTRIBUTE_NODE",
134
+ 3: "TEXT_NODE",
135
+ 4: "CDATA_SECTION_NODE",
136
+ 5: "ENTITY_REFERENCE_NODE",
137
+ 6: "ENTITY_NODE",
138
+ 7: "PROCESSING_INSTRUCTION_NODE",
139
+ 8: "COMMENT_NODE",
140
+ 9: "DOCUMENT_NODE",
141
+ 10: "DOCUMENT_TYPE_NODE",
142
+ 11: "DOCUMENT_FRAGMENT_NODE",
143
+ 12: "NOTATION_NODE"
144
+ };
@@ -0,0 +1,47 @@
1
+ /**@constructor*/
2
+ function Hash() {
3
+ this.reset();
4
+ }
5
+
6
+ Hash.prototype.reset = function() {
7
+ this.elements = {};
8
+ }
9
+
10
+ Hash.prototype.put = function() {
11
+ for (var i = 0, l = arguments.length; i < l; i++) {
12
+ this.elements[arguments[i]] = arguments[++i];
13
+ }
14
+ }
15
+
16
+ Hash.prototype.has = function(key) {
17
+ return this.elements.hasOwnProperty(key);
18
+ }
19
+
20
+ Hash.prototype.get = function(key) {
21
+ return (this.has(key)) ? this.elements[key] : undefined;
22
+ }
23
+
24
+ Hash.prototype.drop = function(key) {
25
+ if (this.has(key)) {
26
+ delete this.elements[key];
27
+ }
28
+ }
29
+
30
+ Hash.prototype.rename = function(oldKey, newKey) {
31
+ if (oldKey != newKey && this.has(oldKey)) {
32
+ this.elements[newKey] = this.elements[oldKey];
33
+ delete this.elements[oldKey];
34
+ }
35
+ }
36
+
37
+ Hash.prototype.keys = function() {
38
+ var keys = [];
39
+ for (var key in this.elements) if (this.has(key)) keys.push(key);
40
+ return keys;
41
+ }
42
+
43
+ Hash.prototype.values = function() {
44
+ var values = [];
45
+ for (var key in this.elements) if (this.has(key)) values.push(this.get(key));
46
+ return values;
47
+ }
@@ -0,0 +1,142 @@
1
+ /** Handle the creation of HTML links to documented symbols.
2
+ @constructor
3
+ */
4
+ function Link() {
5
+ this.alias = "";
6
+ this.src = "";
7
+ this.file = "";
8
+ this.text = "";
9
+ this.innerName = "";
10
+ this.classLink = false;
11
+ this.targetName = "";
12
+
13
+ this.target = function(targetName) {
14
+ if (defined(targetName)) this.targetName = targetName;
15
+ return this;
16
+ }
17
+ this.inner = function(inner) {
18
+ if (defined(inner)) this.innerName = inner;
19
+ return this;
20
+ }
21
+ this.withText = function(text) {
22
+ if (defined(text)) this.text = text;
23
+ return this;
24
+ }
25
+ this.toSrc = function(filename) {
26
+ if (defined(filename)) this.src = filename;
27
+ return this;
28
+ }
29
+ this.toSymbol = function(alias) {
30
+ if (defined(alias)) this.alias = new String(alias);
31
+ return this;
32
+ }
33
+ this.toClass = function(alias) {
34
+ this.classLink = true;
35
+ return this.toSymbol(alias);
36
+ }
37
+ this.toFile = function(file) {
38
+ if (defined(file)) this.file = file;
39
+ return this;
40
+ }
41
+
42
+ this.toString = function() {
43
+ var linkString;
44
+ var thisLink = this;
45
+
46
+ if (this.alias) {
47
+ linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
48
+ function(match, prematch, symbolName, postmatch) {
49
+ var symbolNames = symbolName.split("|");
50
+ var links = [];
51
+ for (var i = 0, l = symbolNames.length; i < l; i++) {
52
+ thisLink.alias = symbolNames[i];
53
+ links.push(thisLink._makeSymbolLink(symbolNames[i]));
54
+ }
55
+ return prematch+links.join("|")+postmatch;
56
+ }
57
+ );
58
+ }
59
+ else if (this.src) {
60
+ linkString = thisLink._makeSrcLink(this.src);
61
+ }
62
+ else if (this.file) {
63
+ linkString = thisLink._makeFileLink(this.file);
64
+ }
65
+
66
+ return linkString;
67
+ }
68
+ }
69
+
70
+ /** prefixed for hashes */
71
+ Link.hashPrefix = "";
72
+
73
+ /** Appended to the front of relative link paths. */
74
+ Link.base = "";
75
+
76
+ Link.symbolNameToLinkName = function(symbol) {
77
+ var linker = "";
78
+ if (symbol.isStatic) linker = ".";
79
+ else if (symbol.isInner) linker = "-";
80
+
81
+ return Link.hashPrefix+linker+symbol.name;
82
+ }
83
+
84
+ /** Create a link to a snother symbol. */
85
+ Link.prototype._makeSymbolLink = function(alias) {
86
+ var linkBase = Link.base+publish.conf.symbolsDir;
87
+ var linkTo = Link.symbolSet.getSymbol(alias);
88
+ var linkPath;
89
+ var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
90
+
91
+ // is it an internal link?
92
+ if (alias.charAt(0) == "#") var linkPath = alias;
93
+
94
+ // if there is no symbol by that name just return the name unaltered
95
+ else if (!linkTo) return this.text || alias;
96
+
97
+ // it's a symbol in another file
98
+ else {
99
+
100
+ if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
101
+ linkPath = escape(linkTo.memberOf) || "_global_";
102
+ linkPath += publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo);
103
+ }
104
+ else {
105
+ linkPath = escape(linkTo.alias);
106
+ linkPath += publish.conf.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
107
+ }
108
+ linkPath = linkBase + linkPath
109
+ }
110
+
111
+ var linkText = this.text || alias;
112
+
113
+ var link = {linkPath: linkPath, linkText: linkText};
114
+
115
+ if (typeof JSDOC.PluginManager != "undefined") {
116
+ JSDOC.PluginManager.run("onSymbolLink", link);
117
+ }
118
+
119
+ return "<a href=\""+link.linkPath+"\""+target+">"+link.linkText+"</a>";
120
+ }
121
+
122
+ /** Create a link to a source file. */
123
+ Link.prototype._makeSrcLink = function(srcFilePath) {
124
+ var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
125
+
126
+ // transform filepath into a filename
127
+ var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "_");
128
+ var outFilePath = Link.base + publish.conf.srcDir + srcFile + publish.conf.ext;
129
+
130
+ if (!this.text) this.text = FilePath.fileName(srcFilePath);
131
+ return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
132
+ }
133
+
134
+ /** Create a link to a source file. */
135
+ Link.prototype._makeFileLink = function(filePath) {
136
+ var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
137
+
138
+ var outFilePath = Link.base + filePath;
139
+
140
+ if (!this.text) this.text = filePath;
141
+ return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
142
+ }
@@ -0,0 +1,10 @@
1
+ _global_ = this;
2
+
3
+ function Namespace(name, f) {
4
+ var n = name.split(".");
5
+ for (var o = _global_, i = 0, l = n.length; i < l; i++) {
6
+ o = o[n[i]] = o[n[i]] || {};
7
+ }
8
+
9
+ if (f) f();
10
+ }
@@ -0,0 +1,134 @@
1
+ /** @namespace */
2
+ Opt = {
3
+ /**
4
+ * Get commandline option values.
5
+ * @param {Array} args Commandline arguments. Like ["-a=xml", "-b", "--class=new", "--debug"]
6
+ * @param {object} optNames Map short names to long names. Like {a:"accept", b:"backtrace", c:"class", d:"debug"}.
7
+ * @return {object} Short names and values. Like {a:"xml", b:true, c:"new", d:true}
8
+ */
9
+ get: function(args, optNames) {
10
+ var opt = {"_": []}; // the unnamed option allows multiple values
11
+ for (var i = 0; i < args.length; i++) {
12
+ var arg = new String(args[i]);
13
+ var name;
14
+ var value;
15
+ if (arg.charAt(0) == "-") {
16
+ if (arg.charAt(1) == "-") { // it's a longname like --foo
17
+ arg = arg.substring(2);
18
+ var m = arg.split("=");
19
+ name = m.shift();
20
+ value = m.shift();
21
+ if (typeof value == "undefined") value = true;
22
+
23
+ for (var n in optNames) { // convert it to a shortname
24
+ if (name == optNames[n]) {
25
+ name = n;
26
+ }
27
+ }
28
+ }
29
+ else { // it's a shortname like -f
30
+ arg = arg.substring(1);
31
+ var m = arg.split("=");
32
+ name = m.shift();
33
+ value = m.shift();
34
+ if (typeof value == "undefined") value = true;
35
+
36
+ for (var n in optNames) { // find the matching key
37
+ if (name == n || name+'[]' == n) {
38
+ name = n;
39
+ break;
40
+ }
41
+ }
42
+ }
43
+ if (name.match(/(.+)\[\]$/)) { // it's an array type like n[]
44
+ name = RegExp.$1;
45
+ if (!opt[name]) opt[name] = [];
46
+ }
47
+
48
+ if (opt[name] && opt[name].push) {
49
+ opt[name].push(value);
50
+ }
51
+ else {
52
+ opt[name] = value;
53
+ }
54
+ }
55
+ else { // not associated with any optname
56
+ opt._.push(args[i]);
57
+ }
58
+ }
59
+ return opt;
60
+ }
61
+ }
62
+
63
+ /*t:
64
+ plan(11, "Testing Opt.");
65
+
66
+ is(
67
+ typeof Opt,
68
+ "object",
69
+ "Opt is an object."
70
+ );
71
+
72
+ is(
73
+ typeof Opt.get,
74
+ "function",
75
+ "Opt.get is a function."
76
+ );
77
+
78
+ var optNames = {a:"accept", b:"backtrace", c:"class", d:"debug", "e[]":"exceptions"};
79
+ var t_options = Opt.get(["-a=xml", "-b", "--class=new", "--debug", "-e=one", "-e=two", "foo", "bar"], optNames);
80
+
81
+ is(
82
+ t_options.a,
83
+ "xml",
84
+ "an option defined with a short name can be accessed by its short name."
85
+ );
86
+
87
+ is(
88
+ t_options.b,
89
+ true,
90
+ "an option defined with a short name and no value are true."
91
+ );
92
+
93
+ is(
94
+ t_options.c,
95
+ "new",
96
+ "an option defined with a long name can be accessed by its short name."
97
+ );
98
+
99
+ is(
100
+ t_options.d,
101
+ true,
102
+ "an option defined with a long name and no value are true."
103
+ );
104
+
105
+ is(
106
+ typeof t_options.e,
107
+ "object",
108
+ "an option that can accept multiple values is defined."
109
+ );
110
+
111
+ is(
112
+ t_options.e.length,
113
+ 2,
114
+ "an option that can accept multiple values can have more than one value."
115
+ );
116
+
117
+ is(
118
+ t_options.e[1],
119
+ "two",
120
+ "an option that can accept multiple values can be accessed as an array."
121
+ );
122
+
123
+ is(
124
+ typeof t_options._,
125
+ "object",
126
+ "the property '_' is defined for unnamed options."
127
+ );
128
+
129
+ is(
130
+ t_options._[0],
131
+ "foo",
132
+ "the property '_' can be accessed as an array."
133
+ );
134
+ */
@@ -0,0 +1,26 @@
1
+ /**@constructor*/
2
+ function Reflection(obj) {
3
+ this.obj = obj;
4
+ }
5
+
6
+ Reflection.prototype.getConstructorName = function() {
7
+ if (this.obj.constructor.name) return this.obj.constructor.name;
8
+ var src = this.obj.constructor.toSource();
9
+ var name = src.substring(name.indexOf("function")+8, src.indexOf('(')).replace(/ /g,'');
10
+ return name;
11
+ }
12
+
13
+ Reflection.prototype.getMethod = function(name) {
14
+ for (var p in this.obj) {
15
+ if (p == name && typeof(this.obj[p]) == "function") return this.obj[p];
16
+ }
17
+ return null;
18
+ }
19
+
20
+ Reflection.prototype.getParameterNames = function() {
21
+ var src = this.obj.toSource();
22
+ src = src.substring(
23
+ src.indexOf("(", 8)+1, src.indexOf(")")
24
+ );
25
+ return src.split(/, ?/);
26
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ @name String
3
+ @class Additions to the core string object.
4
+ */
5
+
6
+ /** @author Steven Levithan, released as public domain. */
7
+ String.prototype.trim = function() {
8
+ var str = this.replace(/^\s+/, '');
9
+ for (var i = str.length - 1; i >= 0; i--) {
10
+ if (/\S/.test(str.charAt(i))) {
11
+ str = str.substring(0, i + 1);
12
+ break;
13
+ }
14
+ }
15
+ return str;
16
+ }
17
+ /*t:
18
+ plan(6, "Testing String.prototype.trim.");
19
+
20
+ var s = " a bc ".trim();
21
+ is(s, "a bc", "multiple spaces front and back are trimmed.");
22
+
23
+ s = "a bc\n\n".trim();
24
+ is(s, "a bc", "newlines only in back are trimmed.");
25
+
26
+ s = "\ta bc".trim();
27
+ is(s, "a bc", "tabs only in front are trimmed.");
28
+
29
+ s = "\n \t".trim();
30
+ is(s, "", "an all-space string is trimmed to empty.");
31
+
32
+ s = "a b\nc".trim();
33
+ is(s, "a b\nc", "a string with no spaces in front or back is trimmed to itself.");
34
+
35
+ s = "".trim();
36
+ is(s, "", "an empty string is trimmed to empty.");
37
+
38
+ */
39
+
40
+ String.prototype.balance = function(open, close) {
41
+ var i = 0;
42
+ while (this.charAt(i) != open) {
43
+ if (i == this.length) return [-1, -1];
44
+ i++;
45
+ }
46
+
47
+ var j = i+1;
48
+ var balance = 1;
49
+ while (j < this.length) {
50
+ if (this.charAt(j) == open) balance++;
51
+ if (this.charAt(j) == close) balance--;
52
+ if (balance == 0) break;
53
+ j++;
54
+ if (j == this.length) return [-1, -1];
55
+ }
56
+
57
+ return [i, j];
58
+ }
59
+ /*t:
60
+ plan(16, "Testing String.prototype.balance.");
61
+
62
+ var s = "{abc}".balance("{","}");
63
+ is(s[0], 0, "opener in first is found.");
64
+ is(s[1], 4, "closer in last is found.");
65
+
66
+ s = "ab{c}de".balance("{","}");
67
+ is(s[0], 2, "opener in middle is found.");
68
+ is(s[1], 4, "closer in middle is found.");
69
+
70
+ s = "a{b{c}de}f".balance("{","}");
71
+ is(s[0], 1, "nested opener is found.");
72
+ is(s[1], 8, "nested closer is found.");
73
+
74
+ s = "{}".balance("{","}");
75
+ is(s[0], 0, "opener with no content is found.");
76
+ is(s[1], 1, "closer with no content is found.");
77
+
78
+ s = "".balance("{","}");
79
+ is(s[0], -1, "empty string opener is -1.");
80
+ is(s[1], -1, "empty string closer is -1.");
81
+
82
+ s = "{abc".balance("{","}");
83
+ is(s[0], -1, "opener with no closer returns -1.");
84
+ is(s[1], -1, "no closer returns -1.");
85
+
86
+ s = "abc".balance("{","}");
87
+ is(s[0], -1, "no opener or closer returns -1 for opener.");
88
+ is(s[1], -1, "no opener or closer returns -1 for closer.");
89
+
90
+ s = "a<bc}de".balance("<","}");
91
+ is(s[0], 1, "unmatching opener is found.");
92
+ is(s[1], 4, "unmatching closer is found.");
93
+ */