spontaneous 0.1.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (556) hide show
  1. data/Gemfile +49 -0
  2. data/Gemfile.lock +146 -0
  3. data/LICENSE +0 -0
  4. data/README +0 -0
  5. data/Rakefile +284 -0
  6. data/Readme.markdown +7 -0
  7. data/application/css/add_alias_dialogue.scss +27 -0
  8. data/application/css/definitions.scss +249 -0
  9. data/application/css/developer.scss +9 -0
  10. data/application/css/editing.scss +649 -0
  11. data/application/css/login.scss +91 -0
  12. data/application/css/min/54ee0ed3c7fac7632bd5c020d69e9a2503e0c88c.css +1 -0
  13. data/application/css/min/c256adc144e2bdd0b0539356b04eb62db01e1dc3.css +1 -0
  14. data/application/css/popover.scss +335 -0
  15. data/application/css/schema_error.scss +90 -0
  16. data/application/css/spontaneous.scss +111 -0
  17. data/application/css/unsupported.scss +16 -0
  18. data/application/css/v2.scss +1606 -0
  19. data/application/css/variables.scss +80 -0
  20. data/application/js/add_alias_dialogue.js +59 -0
  21. data/application/js/add_home_dialogue.js +59 -0
  22. data/application/js/ajax.js +99 -0
  23. data/application/js/authentication.js +22 -0
  24. data/application/js/box.js +104 -0
  25. data/application/js/box_container.js +82 -0
  26. data/application/js/compatibility.js +132 -0
  27. data/application/js/conflicted_field_dialogue.js +92 -0
  28. data/application/js/content.js +224 -0
  29. data/application/js/content_area.js +44 -0
  30. data/application/js/dialogue.js +196 -0
  31. data/application/js/dom.js +71 -0
  32. data/application/js/edit_dialogue.js +137 -0
  33. data/application/js/edit_panel.js +232 -0
  34. data/application/js/editing.js +42 -0
  35. data/application/js/entry.js +13 -0
  36. data/application/js/extensions.js +104 -0
  37. data/application/js/field.js +4 -0
  38. data/application/js/field_preview.js +55 -0
  39. data/application/js/field_types/date_field.js +16 -0
  40. data/application/js/field_types/file_field.js +71 -0
  41. data/application/js/field_types/image_field.js +358 -0
  42. data/application/js/field_types/markdown_field.js +656 -0
  43. data/application/js/field_types/string_field.js +185 -0
  44. data/application/js/image.js +72 -0
  45. data/application/js/init.js +34 -0
  46. data/application/js/load.js +4 -0
  47. data/application/js/location.js +157 -0
  48. data/application/js/login.js +53 -0
  49. data/application/js/min/492a209de8ee955fa9c729a765377495001e11b1.js +17 -0
  50. data/application/js/min/80f684d77c940887a1d4a63e3a96102e993baa98.js +88 -0
  51. data/application/js/min/b8abf302a824c35385ff517b34111e1710ff3b37.js +2 -0
  52. data/application/js/min/c7140ec9475e5bf868b901e0621338d7d162358b.js +3 -0
  53. data/application/js/min/f07f2bd6630ee31e1c2288ec223383d8f0658ba6.js +2 -0
  54. data/application/js/page.js +43 -0
  55. data/application/js/page_browser.js +147 -0
  56. data/application/js/page_entry.js +47 -0
  57. data/application/js/popover.js +99 -0
  58. data/application/js/popover_view.js +56 -0
  59. data/application/js/preview.js +64 -0
  60. data/application/js/progress.js +358 -0
  61. data/application/js/properties.js +90 -0
  62. data/application/js/publish.js +187 -0
  63. data/application/js/require.js +129 -0
  64. data/application/js/sharded_upload.js +206 -0
  65. data/application/js/side_bar.js +30 -0
  66. data/application/js/spontaneous.js +6 -0
  67. data/application/js/state.js +64 -0
  68. data/application/js/status_bar.js +47 -0
  69. data/application/js/top_bar.js +368 -0
  70. data/application/js/types.js +98 -0
  71. data/application/js/upload.js +88 -0
  72. data/application/js/upload_manager.js +319 -0
  73. data/application/js/user.js +37 -0
  74. data/application/js/vendor/.DS_Store +0 -0
  75. data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +283 -0
  76. data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +30 -0
  77. data/application/js/vendor/JS.Class-2.1.5/README +30 -0
  78. data/application/js/vendor/JS.Class-2.1.5/min/command.js +1 -0
  79. data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +1 -0
  80. data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +1 -0
  81. data/application/js/vendor/JS.Class-2.1.5/min/core.js +1 -0
  82. data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +1 -0
  83. data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +1 -0
  84. data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +1 -0
  85. data/application/js/vendor/JS.Class-2.1.5/min/hash.js +1 -0
  86. data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +1 -0
  87. data/application/js/vendor/JS.Class-2.1.5/min/loader.js +1 -0
  88. data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +1 -0
  89. data/application/js/vendor/JS.Class-2.1.5/min/observable.js +1 -0
  90. data/application/js/vendor/JS.Class-2.1.5/min/package.js +1 -0
  91. data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +1 -0
  92. data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +1 -0
  93. data/application/js/vendor/JS.Class-2.1.5/min/set.js +1 -0
  94. data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +1 -0
  95. data/application/js/vendor/JS.Class-2.1.5/min/state.js +1 -0
  96. data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +16 -0
  97. data/application/js/vendor/JS.Class-2.1.5/src/command.js +93 -0
  98. data/application/js/vendor/JS.Class-2.1.5/src/comparable.js +37 -0
  99. data/application/js/vendor/JS.Class-2.1.5/src/constant_scope.js +48 -0
  100. data/application/js/vendor/JS.Class-2.1.5/src/core.js +1060 -0
  101. data/application/js/vendor/JS.Class-2.1.5/src/decorator.js +50 -0
  102. data/application/js/vendor/JS.Class-2.1.5/src/enumerable.js +505 -0
  103. data/application/js/vendor/JS.Class-2.1.5/src/forwardable.js +22 -0
  104. data/application/js/vendor/JS.Class-2.1.5/src/hash.js +334 -0
  105. data/application/js/vendor/JS.Class-2.1.5/src/linked_list.js +114 -0
  106. data/application/js/vendor/JS.Class-2.1.5/src/loader.js +553 -0
  107. data/application/js/vendor/JS.Class-2.1.5/src/method_chain.js +172 -0
  108. data/application/js/vendor/JS.Class-2.1.5/src/observable.js +55 -0
  109. data/application/js/vendor/JS.Class-2.1.5/src/package.js +472 -0
  110. data/application/js/vendor/JS.Class-2.1.5/src/proxy.js +58 -0
  111. data/application/js/vendor/JS.Class-2.1.5/src/ruby.js +44 -0
  112. data/application/js/vendor/JS.Class-2.1.5/src/set.js +332 -0
  113. data/application/js/vendor/JS.Class-2.1.5/src/stack_trace.js +151 -0
  114. data/application/js/vendor/JS.Class-2.1.5/src/state.js +95 -0
  115. data/application/js/vendor/JS.Class-2.1.5/src/stdlib.js +2612 -0
  116. data/application/js/vendor/crypto-2.3.0-crypto.js +160 -0
  117. data/application/js/vendor/crypto-2.3.0-sha1.js +91 -0
  118. data/application/js/vendor/diff_match_patch.js +2153 -0
  119. data/application/js/vendor/jquery-1.4.2.min.js +154 -0
  120. data/application/js/vendor/jquery-1.4.3.min.js +166 -0
  121. data/application/js/vendor/jquery-1.5.1.min.js +16 -0
  122. data/application/js/vendor/jquery-1.5.1rc1.min.js +24 -0
  123. data/application/js/vendor/jquery-1.6.2.min.js +18 -0
  124. data/application/js/vendor/jquery-ui-1.8.6.custom.min.js +265 -0
  125. data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +415 -0
  126. data/application/js/vendor/jquery-ui-1.8.custom.min.js +106 -0
  127. data/application/js/vendor/jquery.hotkeys-0.7.9.js +248 -0
  128. data/application/js/vendor/jquery.hotkeys-0.7.9.min.js +19 -0
  129. data/application/js/vendor/jsdiff.js +169 -0
  130. data/application/js/views/box_view.js +229 -0
  131. data/application/js/views/page_piece_view.js +45 -0
  132. data/application/js/views/page_view.js +238 -0
  133. data/application/js/views/piece_view.js +178 -0
  134. data/application/js/views.js +110 -0
  135. data/application/static/editing-0-noise.png +0 -0
  136. data/application/static/editing-1-noise.png +0 -0
  137. data/application/static/editing-texture-1.png +0 -0
  138. data/application/static/editing-texture.png +0 -0
  139. data/application/static/editing-toolbar-shadow-bottom.png +0 -0
  140. data/application/static/editing-toolbar-shadow-top.png +0 -0
  141. data/application/static/favicon.ico +0 -0
  142. data/application/static/inner-glow.png +0 -0
  143. data/application/static/item-buttons.png +0 -0
  144. data/application/static/location-arrow.png +0 -0
  145. data/application/static/logo-400px-transparent.png +0 -0
  146. data/application/static/missing.png +0 -0
  147. data/application/static/orange-down-arrow.png +0 -0
  148. data/application/static/page-browser-next.png +0 -0
  149. data/application/static/paper-texture-dark.png +0 -0
  150. data/application/static/px.gif +0 -0
  151. data/application/static/select-arrow-root.png +0 -0
  152. data/application/static/select-arrow.png +0 -0
  153. data/application/static/slot-down-arrow.png +0 -0
  154. data/application/static/splash.png +0 -0
  155. data/application/static/spontaneous.png +0 -0
  156. data/application/static/spot.png +0 -0
  157. data/application/static/spot.svg +40 -0
  158. data/application/static/texture.png +0 -0
  159. data/application/views/index.erubis +46 -0
  160. data/application/views/login.erubis +69 -0
  161. data/application/views/schema_modification_error.html.erb +61 -0
  162. data/application/views/unsupported.erubis +23 -0
  163. data/bin/limit-upload +5 -0
  164. data/bin/spot +10 -0
  165. data/bin/unlimit-upload +3 -0
  166. data/config/nginx.conf +60 -0
  167. data/db/migrations/20100610142136_init.rb +66 -0
  168. data/db/migrations/20101130104334_timestamps.rb +44 -0
  169. data/db/migrations/20101202113205_site_publishing_flags.rb +12 -0
  170. data/db/migrations/20101206124543_aliases.rb +16 -0
  171. data/db/migrations/20110201133550_visibility.rb +27 -0
  172. data/db/migrations/20110209152710_users_and_groups.rb +58 -0
  173. data/db/migrations/20110215133910_boxes.rb +25 -0
  174. data/db/migrations/20110521114145_remove_slots_and_entries.rb +21 -0
  175. data/db/migrations/20110604192145_rename_schema_id_columns.rb +22 -0
  176. data/db/migrations/20110805141925_rename_site_to_state.rb +11 -0
  177. data/lib/cutaneous/context_helper.rb +82 -0
  178. data/lib/cutaneous/first_pass_parser.rb +23 -0
  179. data/lib/cutaneous/first_pass_renderer.rb +18 -0
  180. data/lib/cutaneous/parser_core.rb +18 -0
  181. data/lib/cutaneous/preview_context.rb +31 -0
  182. data/lib/cutaneous/preview_renderer.rb +15 -0
  183. data/lib/cutaneous/publish_context.rb +9 -0
  184. data/lib/cutaneous/renderer.rb +122 -0
  185. data/lib/cutaneous/request_context.rb +8 -0
  186. data/lib/cutaneous/second_pass_parser.rb +23 -0
  187. data/lib/cutaneous/second_pass_renderer.rb +18 -0
  188. data/lib/cutaneous.rb +47 -0
  189. data/lib/sequel/plugins/content_table_inheritance.rb +196 -0
  190. data/lib/sequel/plugins/yajl_serialization.rb +154 -0
  191. data/lib/spontaneous/application/feature.rb +9 -0
  192. data/lib/spontaneous/application/plugin.rb +13 -0
  193. data/lib/spontaneous/application.rb +8 -0
  194. data/lib/spontaneous/box.rb +232 -0
  195. data/lib/spontaneous/box_style.rb +64 -0
  196. data/lib/spontaneous/change.rb +107 -0
  197. data/lib/spontaneous/cli/adapter.rb +13 -0
  198. data/lib/spontaneous/cli/base.rb +184 -0
  199. data/lib/spontaneous/cli/console.rb +0 -0
  200. data/lib/spontaneous/cli/media.rb +13 -0
  201. data/lib/spontaneous/cli/server.rb +50 -0
  202. data/lib/spontaneous/cli/site.rb +46 -0
  203. data/lib/spontaneous/cli/sync.rb +42 -0
  204. data/lib/spontaneous/cli/tasks.rb +9 -0
  205. data/lib/spontaneous/cli.rb +83 -0
  206. data/lib/spontaneous/collections/box_set.rb +56 -0
  207. data/lib/spontaneous/collections/change_set.rb +43 -0
  208. data/lib/spontaneous/collections/entry_set.rb +83 -0
  209. data/lib/spontaneous/collections/field_set.rb +53 -0
  210. data/lib/spontaneous/collections/prototype_set.rb +131 -0
  211. data/lib/spontaneous/collections/style_set.rb +13 -0
  212. data/lib/spontaneous/config.rb +156 -0
  213. data/lib/spontaneous/constants.rb +24 -0
  214. data/lib/spontaneous/content.rb +113 -0
  215. data/lib/spontaneous/content_query.rb +17 -0
  216. data/lib/spontaneous/errors.rb +48 -0
  217. data/lib/spontaneous/extensions/array.rb +18 -0
  218. data/lib/spontaneous/extensions/class.rb +17 -0
  219. data/lib/spontaneous/extensions/hash.rb +18 -0
  220. data/lib/spontaneous/extensions/json.rb +26 -0
  221. data/lib/spontaneous/extensions/kernel.rb +7 -0
  222. data/lib/spontaneous/extensions/object.rb +30 -0
  223. data/lib/spontaneous/extensions/object_space.rb +12 -0
  224. data/lib/spontaneous/extensions/string.rb +44 -0
  225. data/lib/spontaneous/facet.rb +47 -0
  226. data/lib/spontaneous/field_types/date_field.rb +12 -0
  227. data/lib/spontaneous/field_types/field.rb +252 -0
  228. data/lib/spontaneous/field_types/image_field.rb +329 -0
  229. data/lib/spontaneous/field_types/markdown_field.rb +37 -0
  230. data/lib/spontaneous/field_types/string_field.rb +14 -0
  231. data/lib/spontaneous/field_types.rb +40 -0
  232. data/lib/spontaneous/generators/page/inline.html.cut +1 -0
  233. data/lib/spontaneous/generators/page/page.html.cut.tt +4 -0
  234. data/lib/spontaneous/generators/page/page.rb.tt +9 -0
  235. data/lib/spontaneous/generators/page.rb +38 -0
  236. data/lib/spontaneous/generators/site/.gitignore +4 -0
  237. data/lib/spontaneous/generators/site/Gemfile.tt +31 -0
  238. data/lib/spontaneous/generators/site/Rakefile.tt +6 -0
  239. data/lib/spontaneous/generators/site/config/back.ru +7 -0
  240. data/lib/spontaneous/generators/site/config/boot.rb +19 -0
  241. data/lib/spontaneous/generators/site/config/database.yml.tt +21 -0
  242. data/lib/spontaneous/generators/site/config/deploy.rb.tt +0 -0
  243. data/lib/spontaneous/generators/site/config/environment.rb.tt +8 -0
  244. data/lib/spontaneous/generators/site/config/environments/development.rb.tt +15 -0
  245. data/lib/spontaneous/generators/site/config/environments/production.rb.tt +5 -0
  246. data/lib/spontaneous/generators/site/config/front.ru +8 -0
  247. data/lib/spontaneous/generators/site/config/user_levels.yml +22 -0
  248. data/lib/spontaneous/generators/site/lib/site.rb.tt +4 -0
  249. data/lib/spontaneous/generators/site/lib/tasks/site.rake.tt +8 -0
  250. data/lib/spontaneous/generators/site/public/css/site.css +0 -0
  251. data/lib/spontaneous/generators/site/public/favicon.ico +0 -0
  252. data/lib/spontaneous/generators/site/public/js/.empty_directory +0 -0
  253. data/lib/spontaneous/generators/site/public/js/site.js +0 -0
  254. data/lib/spontaneous/generators/site/public/robots.txt +0 -0
  255. data/lib/spontaneous/generators/site/schema/.map +1 -0
  256. data/lib/spontaneous/generators/site/schema/page.rb.tt +8 -0
  257. data/lib/spontaneous/generators/site/schema/piece.rb.tt +4 -0
  258. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +13 -0
  259. data/lib/spontaneous/generators/site.rb +77 -0
  260. data/lib/spontaneous/generators.rb +23 -0
  261. data/lib/spontaneous/image_size.rb +117 -0
  262. data/lib/spontaneous/json.rb +33 -0
  263. data/lib/spontaneous/layout.rb +15 -0
  264. data/lib/spontaneous/loader.rb +280 -0
  265. data/lib/spontaneous/logger.rb +369 -0
  266. data/lib/spontaneous/media.rb +84 -0
  267. data/lib/spontaneous/page.rb +92 -0
  268. data/lib/spontaneous/page_controller.rb +18 -0
  269. data/lib/spontaneous/page_piece.rb +77 -0
  270. data/lib/spontaneous/paths.rb +30 -0
  271. data/lib/spontaneous/permissions/access_group.rb +50 -0
  272. data/lib/spontaneous/permissions/access_key.rb +35 -0
  273. data/lib/spontaneous/permissions/user.rb +167 -0
  274. data/lib/spontaneous/permissions/user_level.rb +177 -0
  275. data/lib/spontaneous/permissions.rb +55 -0
  276. data/lib/spontaneous/piece.rb +30 -0
  277. data/lib/spontaneous/plugins/aliases.rb +128 -0
  278. data/lib/spontaneous/plugins/allowed_types.rb +173 -0
  279. data/lib/spontaneous/plugins/application/facets.rb +25 -0
  280. data/lib/spontaneous/plugins/application/paths.rb +137 -0
  281. data/lib/spontaneous/plugins/application/render.rb +29 -0
  282. data/lib/spontaneous/plugins/application/serialisation.rb +16 -0
  283. data/lib/spontaneous/plugins/application/state.rb +86 -0
  284. data/lib/spontaneous/plugins/boxes.rb +84 -0
  285. data/lib/spontaneous/plugins/controllers.rb +52 -0
  286. data/lib/spontaneous/plugins/entries.rb +193 -0
  287. data/lib/spontaneous/plugins/entry.rb +51 -0
  288. data/lib/spontaneous/plugins/fields.rb +103 -0
  289. data/lib/spontaneous/plugins/instance_code.rb +18 -0
  290. data/lib/spontaneous/plugins/layouts.rb +87 -0
  291. data/lib/spontaneous/plugins/media.rb +41 -0
  292. data/lib/spontaneous/plugins/page/formats.rb +67 -0
  293. data/lib/spontaneous/plugins/page/request.rb +89 -0
  294. data/lib/spontaneous/plugins/page_search.rb +64 -0
  295. data/lib/spontaneous/plugins/page_tree.rb +25 -0
  296. data/lib/spontaneous/plugins/paths.rb +125 -0
  297. data/lib/spontaneous/plugins/permissions.rb +63 -0
  298. data/lib/spontaneous/plugins/prototypes.rb +84 -0
  299. data/lib/spontaneous/plugins/publishing.rb +255 -0
  300. data/lib/spontaneous/plugins/render.rb +24 -0
  301. data/lib/spontaneous/plugins/schema_hierarchy.rb +76 -0
  302. data/lib/spontaneous/plugins/schema_id.rb +60 -0
  303. data/lib/spontaneous/plugins/schema_title.rb +33 -0
  304. data/lib/spontaneous/plugins/serialisation.rb +67 -0
  305. data/lib/spontaneous/plugins/site/instance.rb +22 -0
  306. data/lib/spontaneous/plugins/site/map.rb +19 -0
  307. data/lib/spontaneous/plugins/site/publishing.rb +74 -0
  308. data/lib/spontaneous/plugins/site/revisions.rb +28 -0
  309. data/lib/spontaneous/plugins/site/selectors.rb +41 -0
  310. data/lib/spontaneous/plugins/site_map.rb +34 -0
  311. data/lib/spontaneous/plugins/styles.rb +119 -0
  312. data/lib/spontaneous/plugins/supertype.rb +11 -0
  313. data/lib/spontaneous/plugins/visibility.rb +151 -0
  314. data/lib/spontaneous/plugins.rb +20 -0
  315. data/lib/spontaneous/prototypes/box_prototype.rb +168 -0
  316. data/lib/spontaneous/prototypes/field_prototype.rb +112 -0
  317. data/lib/spontaneous/prototypes/layout_prototype.rb +17 -0
  318. data/lib/spontaneous/prototypes/style_prototype.rb +42 -0
  319. data/lib/spontaneous/proxy_object.rb +12 -0
  320. data/lib/spontaneous/publishing/fire_and_forget.rb +57 -0
  321. data/lib/spontaneous/publishing/immediate.rb +197 -0
  322. data/lib/spontaneous/publishing/threaded.rb +25 -0
  323. data/lib/spontaneous/publishing.rb +10 -0
  324. data/lib/spontaneous/rack/around_back.rb +44 -0
  325. data/lib/spontaneous/rack/around_front.rb +29 -0
  326. data/lib/spontaneous/rack/around_preview.rb +26 -0
  327. data/lib/spontaneous/rack/assets.rb +98 -0
  328. data/lib/spontaneous/rack/back.rb +729 -0
  329. data/lib/spontaneous/rack/front.rb +41 -0
  330. data/lib/spontaneous/rack/http.rb +18 -0
  331. data/lib/spontaneous/rack/media.rb +29 -0
  332. data/lib/spontaneous/rack/public.rb +232 -0
  333. data/lib/spontaneous/rack/reloader.rb +42 -0
  334. data/lib/spontaneous/rack/static.rb +25 -0
  335. data/lib/spontaneous/rack.rb +55 -0
  336. data/lib/spontaneous/render/context.rb +100 -0
  337. data/lib/spontaneous/render/development_renderer.rb +14 -0
  338. data/lib/spontaneous/render/engine.rb +19 -0
  339. data/lib/spontaneous/render/format/html.rb +5 -0
  340. data/lib/spontaneous/render/format.rb +70 -0
  341. data/lib/spontaneous/render/preview_renderer.rb +18 -0
  342. data/lib/spontaneous/render/published_renderer.rb +54 -0
  343. data/lib/spontaneous/render/publishing_renderer.rb +13 -0
  344. data/lib/spontaneous/render/renderer.rb +46 -0
  345. data/lib/spontaneous/render.rb +173 -0
  346. data/lib/spontaneous/revision.rb +7 -0
  347. data/lib/spontaneous/schema/schema_modification.rb +260 -0
  348. data/lib/spontaneous/schema/uid.rb +221 -0
  349. data/lib/spontaneous/schema.rb +295 -0
  350. data/lib/spontaneous/server.rb +65 -0
  351. data/lib/spontaneous/site.rb +87 -0
  352. data/lib/spontaneous/state.rb +53 -0
  353. data/lib/spontaneous/style.rb +144 -0
  354. data/lib/spontaneous/tasks/database.rake +9 -0
  355. data/lib/spontaneous/tasks.rb +5 -0
  356. data/lib/spontaneous/version.rb +6 -0
  357. data/lib/spontaneous.rb +179 -0
  358. data/spontaneous.gemspec.tmpl +66 -0
  359. data/test/disabled/test_slots.rb +287 -0
  360. data/test/experimental/test_formats.rb +92 -0
  361. data/test/experimental/test_plugins.rb +64 -0
  362. data/test/fixtures/application/css/test.less +5 -0
  363. data/test/fixtures/application/js/test.js +1 -0
  364. data/test/fixtures/application/static/favicon.ico +1 -0
  365. data/test/fixtures/application/static/test.html +1 -0
  366. data/test/fixtures/application/views/index.erubis +1 -0
  367. data/test/fixtures/back/public/test.html +1 -0
  368. data/test/fixtures/back/templates/layouts/standard.html.cut +1 -0
  369. data/test/fixtures/config/config/environment.rb +4 -0
  370. data/test/fixtures/config/config/environments/development.rb +13 -0
  371. data/test/fixtures/config/config/environments/production.rb +22 -0
  372. data/test/fixtures/config/config/environments/staging.rb +2 -0
  373. data/test/fixtures/example_application/Gemfile +6 -0
  374. data/test/fixtures/example_application/Gemfile.lock +76 -0
  375. data/test/fixtures/example_application/Rakefile +6 -0
  376. data/test/fixtures/example_application/config/back.rb +15 -0
  377. data/test/fixtures/example_application/config/back.ru +8 -0
  378. data/test/fixtures/example_application/config/back.yml +8 -0
  379. data/test/fixtures/example_application/config/boot.rb +16 -0
  380. data/test/fixtures/example_application/config/database.yml +24 -0
  381. data/test/fixtures/example_application/config/environment.rb +4 -0
  382. data/test/fixtures/example_application/config/environments/development.rb +16 -0
  383. data/test/fixtures/example_application/config/environments/production.rb +21 -0
  384. data/test/fixtures/example_application/config/environments/staging.rb +1 -0
  385. data/test/fixtures/example_application/config/front.rb +8 -0
  386. data/test/fixtures/example_application/config/front.ru +8 -0
  387. data/test/fixtures/example_application/config/front.yml +8 -0
  388. data/test/fixtures/example_application/config/schema.yml +48 -0
  389. data/test/fixtures/example_application/config/unicorn.rb +1 -0
  390. data/test/fixtures/example_application/config/user_levels.yml +19 -0
  391. data/test/fixtures/example_application/public/css/test.css +0 -0
  392. data/test/fixtures/example_application/public/favicon.ico +1 -0
  393. data/test/fixtures/example_application/public/js/test.js +0 -0
  394. data/test/fixtures/example_application/public/test.html +1 -0
  395. data/test/fixtures/example_application/schema/client_project.rb +18 -0
  396. data/test/fixtures/example_application/schema/client_projects.rb +8 -0
  397. data/test/fixtures/example_application/schema/home_page.rb +22 -0
  398. data/test/fixtures/example_application/schema/info_page.rb +13 -0
  399. data/test/fixtures/example_application/schema/inline_image.rb +11 -0
  400. data/test/fixtures/example_application/schema/page.rb +4 -0
  401. data/test/fixtures/example_application/schema/piece.rb +3 -0
  402. data/test/fixtures/example_application/schema/project.rb +21 -0
  403. data/test/fixtures/example_application/schema/project_image.rb +18 -0
  404. data/test/fixtures/example_application/schema/projects_page.rb +12 -0
  405. data/test/fixtures/example_application/schema/text.rb +8 -0
  406. data/test/fixtures/example_application/templates/client_project/images.html.cut +1 -0
  407. data/test/fixtures/example_application/templates/client_project.html.cut +4 -0
  408. data/test/fixtures/example_application/templates/client_projects.html.cut +6 -0
  409. data/test/fixtures/example_application/templates/info_page/inline.html.cut +0 -0
  410. data/test/fixtures/example_application/templates/inline_image.html.cut +1 -0
  411. data/test/fixtures/example_application/templates/layouts/home.html.cut +15 -0
  412. data/test/fixtures/example_application/templates/layouts/info.html.cut +3 -0
  413. data/test/fixtures/example_application/templates/layouts/project.html.cut +13 -0
  414. data/test/fixtures/example_application/templates/layouts/projects.html.cut +11 -0
  415. data/test/fixtures/example_application/templates/layouts/standard.html.cut +0 -0
  416. data/test/fixtures/example_application/templates/project/inline.html.cut +5 -0
  417. data/test/fixtures/example_application/templates/project.html.cut +5 -0
  418. data/test/fixtures/example_application/templates/project_image.html.cut +1 -0
  419. data/test/fixtures/example_application/templates/text.html.cut +1 -0
  420. data/test/fixtures/images/rose.greyscale.jpg +0 -0
  421. data/test/fixtures/images/rose.jpg +0 -0
  422. data/test/fixtures/images/size.gif +0 -0
  423. data/test/fixtures/images/size.jpg +0 -0
  424. data/test/fixtures/images/size.png24 +0 -0
  425. data/test/fixtures/images/size.png8 +0 -0
  426. data/test/fixtures/layouts/layouts/custom1.html.cut +1 -0
  427. data/test/fixtures/layouts/layouts/custom1.pdf.cut +0 -0
  428. data/test/fixtures/layouts/layouts/custom1.xml.cut +0 -0
  429. data/test/fixtures/layouts/layouts/custom2.html.cut +1 -0
  430. data/test/fixtures/layouts/layouts/custom3.html.cut +0 -0
  431. data/test/fixtures/layouts/layouts/standard.html.cut +1 -0
  432. data/test/fixtures/media/101/003/rose.jpg +0 -0
  433. data/test/fixtures/permissions/config/user_levels.yml +9 -0
  434. data/test/fixtures/permissions/media/image.jpg +0 -0
  435. data/test/fixtures/plugins/schema_plugin/init.rb +1 -0
  436. data/test/fixtures/plugins/schema_plugin/schema/external.rb +5 -0
  437. data/test/fixtures/plugins/schema_plugin/templates/external.html.cut +1 -0
  438. data/test/fixtures/plugins/schema_plugin/templates/from_plugin.html.cut +0 -0
  439. data/test/fixtures/plugins/schema_plugin/templates/layouts/from_plugin.html.cut +0 -0
  440. data/test/fixtures/public/templates/layouts/default.html.cut +1 -0
  441. data/test/fixtures/public/templates/layouts/default.pdf.cut +1 -0
  442. data/test/fixtures/public/templates/layouts/default.rss.cut +1 -0
  443. data/test/fixtures/public/templates/layouts/dynamic.html.cut +1 -0
  444. data/test/fixtures/public/templates/layouts/standard.html.cut +0 -0
  445. data/test/fixtures/schema/before.yml +24 -0
  446. data/test/fixtures/schema/resolvable.yml +12 -0
  447. data/test/fixtures/schema/schema.yml +7 -0
  448. data/test/fixtures/serialisation/class_hash.yaml.erb +53 -0
  449. data/test/fixtures/serialisation/root_hash.yaml.erb +184 -0
  450. data/test/fixtures/sharding/rose.jpg +0 -0
  451. data/test/fixtures/sharding/xaa +0 -0
  452. data/test/fixtures/sharding/xab +0 -0
  453. data/test/fixtures/sharding/xac +0 -0
  454. data/test/fixtures/sharding/xad +0 -0
  455. data/test/fixtures/sharding/xae +0 -0
  456. data/test/fixtures/sharding/xaf +0 -0
  457. data/test/fixtures/sharding/xag +0 -0
  458. data/test/fixtures/styles/box_a/runny.html.cut +0 -0
  459. data/test/fixtures/styles/box_a.html.cut +1 -0
  460. data/test/fixtures/styles/named2.html.cut +1 -0
  461. data/test/fixtures/styles/orange/apple.html.cut +1 -0
  462. data/test/fixtures/styles/template_class/named1.html.cut +1 -0
  463. data/test/fixtures/styles/template_class/results.html.cut +1 -0
  464. data/test/fixtures/styles/template_class/walky.html.cut +0 -0
  465. data/test/fixtures/styles/template_class.epub.cut +0 -0
  466. data/test/fixtures/styles/template_class.html.cut +1 -0
  467. data/test/fixtures/styles/template_class.pdf.cut +0 -0
  468. data/test/fixtures/styles/template_sub_class1.html.cut +1 -0
  469. data/test/fixtures/templates/aliases/a/a_style.html.cut +0 -0
  470. data/test/fixtures/templates/aliases/a/page.html.cut +0 -0
  471. data/test/fixtures/templates/aliases/a_alias/a_alias_style.html.cut +0 -0
  472. data/test/fixtures/templates/aliases/layouts/b.html.cut +1 -0
  473. data/test/fixtures/templates/aliases/layouts/b_alias.html.cut +1 -0
  474. data/test/fixtures/templates/aliases/layouts/c_alias.html.cut +1 -0
  475. data/test/fixtures/templates/boxes/blank_content/things.html.cut +1 -0
  476. data/test/fixtures/templates/boxes/my_box_class/christy.html.cut +1 -0
  477. data/test/fixtures/templates/boxes/thangs.html.cut +1 -0
  478. data/test/fixtures/templates/boxes/with_template_box.html.cut +1 -0
  479. data/test/fixtures/templates/content/include.html.cut +1 -0
  480. data/test/fixtures/templates/content/include_dir.html.cut +1 -0
  481. data/test/fixtures/templates/content/included.epub.cut +1 -0
  482. data/test/fixtures/templates/content/included.html.cut +1 -0
  483. data/test/fixtures/templates/content/partial/included.html.cut +1 -0
  484. data/test/fixtures/templates/content/preprocess.html.cut +1 -0
  485. data/test/fixtures/templates/content/second.html.cut +1 -0
  486. data/test/fixtures/templates/content/template.epub.cut +1 -0
  487. data/test/fixtures/templates/content/template.html.cut +1 -0
  488. data/test/fixtures/templates/default_style_class.html.cut +1 -0
  489. data/test/fixtures/templates/direct.html.cut +1 -0
  490. data/test/fixtures/templates/extended/grandparent.html.cut +10 -0
  491. data/test/fixtures/templates/extended/main.html.cut +6 -0
  492. data/test/fixtures/templates/extended/parent.html.cut +10 -0
  493. data/test/fixtures/templates/layouts/entries.html.cut +7 -0
  494. data/test/fixtures/templates/layouts/page_style.html.cut +1 -0
  495. data/test/fixtures/templates/layouts/params.html.cut +1 -0
  496. data/test/fixtures/templates/layouts/preview_render.html.cut +2 -0
  497. data/test/fixtures/templates/layouts/standard_page.html.cut +1 -0
  498. data/test/fixtures/templates/layouts/subdir_style.html.cut +1 -0
  499. data/test/fixtures/templates/layouts/template_params.html.cut +1 -0
  500. data/test/fixtures/templates/page_class/inline_style.html.cut +1 -0
  501. data/test/fixtures/templates/preview_render/inline.html.cut +0 -0
  502. data/test/fixtures/templates/publishing/layouts/dynamic.html.cut +1 -0
  503. data/test/fixtures/templates/publishing/layouts/static.html.cut +1 -0
  504. data/test/fixtures/templates/template_class/anonymous_style.html.cut +4 -0
  505. data/test/fixtures/templates/template_class/another_template.html.cut +0 -0
  506. data/test/fixtures/templates/template_class/complex_template.html.cut +6 -0
  507. data/test/fixtures/templates/template_class/complex_template.pdf.cut +6 -0
  508. data/test/fixtures/templates/template_class/default_template_style.html.cut +4 -0
  509. data/test/fixtures/templates/template_class/images_with_template.html.cut +5 -0
  510. data/test/fixtures/templates/template_class/slots_template.html.cut +5 -0
  511. data/test/fixtures/templates/template_class/slots_template.pdf.cut +5 -0
  512. data/test/fixtures/templates/template_class/this_template.epub.cut +1 -0
  513. data/test/fixtures/templates/template_class/this_template.html.cut +1 -0
  514. data/test/fixtures/templates/template_class/this_template.pdf.cut +1 -0
  515. data/test/fixtures/templates/with_default_style_class.html.cut +1 -0
  516. data/test/functional/test_application.rb +176 -0
  517. data/test/functional/test_back.rb +902 -0
  518. data/test/functional/test_front.rb +571 -0
  519. data/test/javascript/test_dom.rb +94 -0
  520. data/test/javascript/test_markdown.rb +97 -0
  521. data/test/slow/test_publishing.rb +987 -0
  522. data/test/slow/test_visibility.rb +250 -0
  523. data/test/support/custom_matchers.rb +77 -0
  524. data/test/support/timing.rb +23 -0
  525. data/test/test_helper.rb +164 -0
  526. data/test/test_javascript.rb +34 -0
  527. data/test/ui/test_page_editing.rb +167 -0
  528. data/test/ui_helper.rb +114 -0
  529. data/test/unit/test_alias.rb +254 -0
  530. data/test/unit/test_authentication.rb +510 -0
  531. data/test/unit/test_boxes.rb +497 -0
  532. data/test/unit/test_config.rb +156 -0
  533. data/test/unit/test_content.rb +221 -0
  534. data/test/unit/test_content_inheritance.rb +103 -0
  535. data/test/unit/test_extensions.rb +14 -0
  536. data/test/unit/test_fields.rb +392 -0
  537. data/test/unit/test_generators.rb +97 -0
  538. data/test/unit/test_image_size.rb +25 -0
  539. data/test/unit/test_images.rb +265 -0
  540. data/test/unit/test_layouts.rb +111 -0
  541. data/test/unit/test_logger.rb +80 -0
  542. data/test/unit/test_media.rb +70 -0
  543. data/test/unit/test_page.rb +244 -0
  544. data/test/unit/test_permissions.rb +834 -0
  545. data/test/unit/test_piece.rb +80 -0
  546. data/test/unit/test_prototype_set.rb +192 -0
  547. data/test/unit/test_prototypes.rb +102 -0
  548. data/test/unit/test_render.rb +359 -0
  549. data/test/unit/test_schema.rb +1009 -0
  550. data/test/unit/test_serialisation.rb +215 -0
  551. data/test/unit/test_site.rb +145 -0
  552. data/test/unit/test_structure.rb +85 -0
  553. data/test/unit/test_styles.rb +417 -0
  554. data/test/unit/test_templates.rb +224 -0
  555. data/test/unit/test_type_hierarchy.rb +28 -0
  556. metadata +1017 -0
@@ -0,0 +1 @@
1
+ JS.Comparable=new JS.Module('Comparable',{extend:{ClassMethods:new JS.Module({compare:function(a,b){return a.compareTo(b)}}),included:function(a){a.extend(this.ClassMethods)}},lt:function(a){return this.compareTo(a)<0},lte:function(a){return this.compareTo(a)<1},gt:function(a){return this.compareTo(a)>0},gte:function(a){return this.compareTo(a)>-1},eq:function(a){return this.compareTo(a)===0},between:function(a,b){return this.gte(a)&&this.lte(b)}});
@@ -0,0 +1 @@
1
+ JS.ConstantScope=new JS.Module('ConstantScope',{extend:{included:function(a){a.__consts__=new JS.Module();a.extend(this.ClassMethods);a.include(a.__consts__);a.extend(a.__consts__);a.include(a.__mod__.__fns__);a.extend(a.__eigen__().__fns__)},ClassMethods:new JS.Module({extend:function(){var a=JS.ConstantScope.extract(arguments[0],this);this.__consts__.include(a);this.callSuper()},include:function(){var a=JS.ConstantScope.extract(arguments[0],this);this.__consts__.include(a);this.callSuper()}}),extract:function(a,e){if(!a)return null;if(JS.isType(a,JS.Module))return null;var d={},b,c;for(b in a){if(!/^[A-Z]/.test(b))continue;c=a[b];d[b]=c;delete a[b];if(JS.isType(c,JS.Module)){c.include(this);c.__consts__.include(e.__consts__)}}return d}}});
@@ -0,0 +1 @@
1
+ this.JS=this.JS||{};JS.extend=function(a,b){b=b||{};for(var c in b){if(a[c]===b[c])continue;a[c]=b[c]}return a};JS.extend(JS,{makeFunction:function(){return function(){return this.initialize?(this.initialize.apply(this,arguments)||this):this}},makeBridge:function(a){var b=function(){};b.prototype=a.prototype;return new b},bind:function(){var a=JS.array(arguments),b=a.shift(),c=a.shift()||null;return function(){return b.apply(c,a.concat(JS.array(arguments)))}},callsSuper:function(a){return a.SUPER===undefined?a.SUPER=/\bcallSuper\b/.test(a.toString()):a.SUPER},mask:function(a){var b=a.toString().replace(/callSuper/g,'super');a.toString=function(){return b};return a},array:function(a){if(!a)return[];if(a.toArray)return a.toArray();var b=a.length,c=[];while(b--)c[b]=a[b];return c},indexOf:function(a,b){for(var c=0,d=a.length;c<d;c++){if(a[c]===b)return c}return-1},isFn:function(a){return a instanceof Function},isType:function(a,b){if(!a||!b)return false;return(b instanceof Function&&a instanceof b)||(typeof b==='string'&&typeof a===b)||(a.isA&&a.isA(b))},ignore:function(a,b){return/^(include|extend)$/.test(a)&&typeof b==='object'}});JS.Module=JS.makeFunction();JS.extend(JS.Module.prototype,{END_WITHOUT_DOT:/([^\.])$/,initialize:function(a,b,c){this.__mod__=this;this.__inc__=[];this.__fns__={};this.__dep__=[];this.__mct__={};if(typeof a==='string'){this.__nom__=this.displayName=a}else{this.__nom__=this.displayName='';c=b;b=a}c=c||{};this.__res__=c._1||null;if(b)this.include(b,false);if(JS.Module.__chainq__)JS.Module.__chainq__.push(this)},setName:function(a){this.__nom__=this.displayName=a||'';for(var b in this.__mod__.__fns__)this.__name__(b);if(a&&this.__meta__)this.__meta__.setName(a+'.')},__name__:function(a){if(!this.__nom__)return;var b=this.__mod__.__fns__[a]||{};a=this.__nom__.replace(this.END_WITHOUT_DOT,'$1#')+a;if(JS.isFn(b.setName))return b.setName(a);if(JS.isFn(b))b.displayName=a},define:function(a,b,c,d){var f=(d||{})._0||this;this.__fns__[a]=b;this.__name__(a);if(JS.Module._0&&f&&JS.isFn(b))JS.Module._0(a,f);if(c!==false)this.resolve()},instanceMethod:function(a){var b=this.lookup(a).pop();return JS.isFn(b)?b:null},instanceMethods:function(a,b){var c=this.__mod__,b=b||[],d=c.ancestors(),f=d.length,e;for(e in c.__fns__){if(c.__fns__.hasOwnProperty(e)&&JS.isFn(c.__fns__[e])&&JS.indexOf(b,e)===-1)b.push(e)}if(a===false)return b;while(f--)d[f].instanceMethods(false,b);return b},include:function(a,b,c){b=(b!==false);if(!a)return b?this.resolve():this.uncache();c=c||{};if(a.__mod__)a=a.__mod__;var d=a.include,f=a.extend,e=c._4||this,g,h,i,j;if(a.__inc__&&a.__fns__){this.__inc__.push(a);a.__dep__.push(this);if(c._2)a.extended&&a.extended(c._2);else a.included&&a.included(e)}else{if(c._5){for(h in a){if(JS.ignore(h,a[h]))continue;this.define(h,a[h],false,{_0:e||c._2||this})}}else{if(typeof d==='object'||JS.isType(d,JS.Module)){g=[].concat(d);for(i=0,j=g.length;i<j;i++)e.include(g[i],b,c)}if(typeof f==='object'||JS.isType(f,JS.Module)){g=[].concat(f);for(i=0,j=g.length;i<j;i++)e.extend(g[i],false);e.extend()}c._5=true;return e.include(a,b,c)}}b?this.resolve():this.uncache()},includes:function(a){var b=this.__mod__,c=b.__inc__.length;if(Object===a||b===a||b.__res__===a.prototype)return true;while(c--){if(b.__inc__[c].includes(a))return true}return false},match:function(a){return a.isA&&a.isA(this)},ancestors:function(a){var b=this.__mod__,c=(a===undefined),d=(b.__res__||{}).klass,f=(d&&b.__res__===d.prototype)?d:b,e,g;if(c&&b.__anc__)return b.__anc__.slice();a=a||[];for(e=0,g=b.__inc__.length;e<g;e++)b.__inc__[e].ancestors(a);if(JS.indexOf(a,f)===-1)a.push(f);if(c)b.__anc__=a.slice();return a},lookup:function(a){var b=this.__mod__,c=b.__mct__;if(c[a])return c[a].slice();var d=b.ancestors(),f=[],e,g,h;for(e=0,g=d.length;e<g;e++){h=d[e].__mod__.__fns__[a];if(h)f.push(h)}c[a]=f.slice();return f},make:function(a,b){if(!JS.isFn(b)||!JS.callsSuper(b))return b;var c=this;return function(){return c.chain(this,a,arguments)}},chain:JS.mask(function(c,d,f){var e=this.lookup(d),g=e.length-1,h=c.callSuper,i=JS.array(f),j;c.callSuper=function(){var a=arguments.length;while(a--)i[a]=arguments[a];g-=1;var b=e[g].apply(c,i);g+=1;return b};j=e.pop().apply(c,i);h?c.callSuper=h:delete c.callSuper;return j}),resolve:function(a){var b=this.__mod__,a=a||b,c=a.__res__,d,f,e,g;if(a===b){b.uncache(false);d=b.__dep__.length;while(d--)b.__dep__[d].resolve()}if(!c)return;for(d=0,f=b.__inc__.length;d<f;d++)b.__inc__[d].resolve(a);for(e in b.__fns__){g=a.make(e,b.__fns__[e]);if(c[e]!==g)c[e]=g}},uncache:function(a){var b=this.__mod__,c=b.__dep__.length;b.__anc__=null;b.__mct__={};if(a===false)return;while(c--)b.__dep__[c].uncache()}});JS.Class=JS.makeFunction();JS.extend(JS.Class.prototype=JS.makeBridge(JS.Module),{initialize:function(a,b,c){if(typeof a==='string'){this.__nom__=this.displayName=a}else{this.__nom__=this.displayName='';c=b;b=a}var d=JS.extend(JS.makeFunction(),this);d.klass=d.constructor=this.klass;if(!JS.isFn(b)){c=b;b=Object}d.inherit(b);d.include(c,false);d.resolve();do{b.inherited&&b.inherited(d)}while(b=b.superclass);return d},inherit:function(a){this.superclass=a;if(this.__eigen__&&a.__eigen__)this.extend(a.__eigen__(),true);this.subclasses=[];(a.subclasses||[]).push(this);var b=this.prototype=JS.makeBridge(a);b.klass=b.constructor=this;this.__mod__=new JS.Module(this.__nom__,{},{_1:this.prototype});this.include(JS.Kernel,false);if(a!==Object)this.include(a.__mod__||new JS.Module(a.prototype,{_1:a.prototype}),false)},include:function(a,b,c){if(!a)return;var d=this.__mod__,c=c||{};c._4=this;return d.include(a,b,c)},define:function(a,b,c,d){var f=this.__mod__;d=d||{};d._0=this;f.define(a,b,c,d)}});JS.Module=new JS.Class('Module',JS.Module.prototype);JS.Class=new JS.Class('Class',JS.Module,JS.Class.prototype);JS.Module.klass=JS.Module.constructor=JS.Class.klass=JS.Class.constructor=JS.Class;JS.extend(JS.Module,{_3:[],__chainq__:[],methodAdded:function(a,b){this._3.push([a,b])},_0:function(a,b){var c=this._3,d=c.length;while(d--)c[d][0].call(c[d][1]||null,a,b)}});JS.Kernel=JS.extend(new JS.Module('Kernel',{__eigen__:function(){if(this.__meta__)return this.__meta__;var a=this.__nom__,b=this.klass.__nom__,c=a||(b?'#<'+b+'>':''),d=this.__meta__=new JS.Module(c?c+'.':'',{},{_1:this});d.include(this.klass.__mod__,false);return d},equals:function(a){return this===a},extend:function(a,b){return this.__eigen__().include(a,b,{_2:this})},hash:function(){return this.__hashcode__=this.__hashcode__||JS.Kernel.getHashCode()},isA:function(a){return this.__eigen__().includes(a)},method:function(a){var b=this,c=b.__mcache__=b.__mcache__||{};if((c[a]||{}).fn===b[a])return c[a].bd;return(c[a]={fn:b[a],bd:JS.bind(b[a],b)}).bd},methods:function(){return this.__eigen__().instanceMethods(true)},tap:function(a,b){a.call(b||null,this);return this}}),{__hashIndex__:0,getHashCode:function(){this.__hashIndex__+=1;return(Math.floor(new Date().getTime()/1000)+this.__hashIndex__).toString(16)}});JS.Module.include(JS.Kernel);JS.extend(JS.Module,JS.Kernel.__fns__);JS.Class.include(JS.Kernel);JS.extend(JS.Class,JS.Kernel.__fns__);JS.Interface=new JS.Class({initialize:function(d){this.test=function(a,b){var c=d.length;while(c--){if(!JS.isFn(a[d[c]]))return b?d[c]:false}return true}},extend:{ensure:function(){var a=JS.array(arguments),b=a.shift(),c,d;while(c=a.shift()){d=c.test(b,true);if(d!==true)throw new Error('object does not implement '+d+'()');}}}});JS.Singleton=new JS.Class({initialize:function(a,b,c){return new(new JS.Class(a,b,c))}});
@@ -0,0 +1 @@
1
+ JS.Decorator=new JS.Class('Decorator',{initialize:function(a,c){var b=new JS.Class(),f={},e,d;for(e in a.prototype){d=a.prototype[e];if(JS.isFn(d)&&d!==a)d=this.klass.delegate(e);f[e]=d}b.include(new JS.Module(f),false);b.include(this.klass.InstanceMethods,false);b.include(c,true);return b},extend:{delegate:function(a){return function(){return this.component[a].apply(this.component,arguments)}},InstanceMethods:new JS.Module({initialize:function(a){this.component=a;this.klass=this.constructor=a.klass;var c,b;for(c in a){if(this[c])continue;b=a[c];if(JS.isFn(b))b=JS.Decorator.delegate(c);this[c]=b}},extend:function(a){this.component.extend(a);var c,b;for(c in a){b=a[c];if(JS.isFn(b))b=JS.Decorator.delegate(c);this[c]=b}}})}});
@@ -0,0 +1 @@
1
+ JS.Enumerable=new JS.Module('Enumerable',{extend:{forEach:function(a,b){if(!a)return new JS.Enumerator(this,'forEach');for(var c=0,d=this.length;c<d;c++){if(this[c]!==undefined)a.call(b||null,this[c])}return this},isComparable:function(b){return b.all(function(a){return JS.isFn(a.compareTo)})},areEqual:function(a,b){return a.equals?a.equals(b):(a===b)},Collection:new JS.Class({initialize:function(b){this.length=0;var c=Array.prototype.push;JS.Enumerable.forEach.call(b,function(a){c.call(this,a)},this)}})},all:function(b,c){b=JS.Enumerable.toFn(b);var d=true;this.forEach(function(a){d=d&&(b?b.apply(c||null,arguments):a)});return!!d},any:function(b,c){b=JS.Enumerable.toFn(b);var d=false;this.forEach(function(a){d=d||(b?b.apply(c||null,arguments):a)});return!!d},count:function(a,b){if(JS.isFn(this.size))return this.size();var c=0,d=a;if(a&&!JS.isFn(a))a=function(x){return JS.Enumerable.areEqual(x,d)};this.forEach(function(){if(!a||a.apply(b||null,arguments))c+=1});return c},cycle:function(a,b,c){if(!b)return this.enumFor('cycle',a);b=JS.Enumerable.toFn(b);while(a--)this.forEach(b,c)},drop:function(c){var d=[];this.forEachWithIndex(function(a,b){if(b>=c)d.push(a)});return d},dropWhile:function(b,c){if(!b)return this.enumFor('dropWhile');b=JS.Enumerable.toFn(b);var d=[],e=true;this.forEach(function(a){if(e)e=e&&b.apply(c||null,arguments);if(!e)d.push(a)});return d},forEachCons:function(a,b,c){if(!b)return this.enumFor('forEachCons',a);b=JS.Enumerable.toFn(b);var d=this.toArray(),e=d.length,f=e-a,g;for(g=0;g<=f;g++)b.call(c||null,d.slice(g,g+a));return this},forEachSlice:function(a,b,c){if(!b)return this.enumFor('forEachSlice',a);b=JS.Enumerable.toFn(b);var d=this.toArray(),e=d.length,f=Math.ceil(e/a),g;for(g=0;g<f;g++)b.call(c||null,d.slice(g*a,(g+1)*a));return this},forEachWithIndex:function(c,d,e){if(JS.isFn(c)){e=d;d=c;c=0}c=c||0;if(!d)return this.enumFor('forEachWithIndex',c);d=JS.Enumerable.toFn(d);return this.forEach(function(a){var b=d.call(e||null,a,c);c+=1;return b})},forEachWithObject:function(b,c,d){if(!c)return this.enumFor('forEachWithObject',b);c=JS.Enumerable.toFn(c);this.forEach(function(){var a=[b].concat(JS.array(arguments));c.apply(d||null,a)});return b},find:function(b,c){if(!b)return this.enumFor('find');b=JS.Enumerable.toFn(b);var d={},e=d;this.forEach(function(a){if(d!==e)return;d=b.apply(c||null,arguments)?a:d});return d===e?null:d},findIndex:function(c,d){if(c===undefined)return this.enumFor('findIndex');var e=null,f=JS.isFn(c);this.forEachWithIndex(function(a,b){if(e!==null)return;if(JS.Enumerable.areEqual(c,a)||(f&&c.apply(d||null,arguments)))e=b});return e},first:function(a){var b=this.toArray();return(a===undefined)?b[0]:b.slice(0,a)},grep:function(c,d,e){d=JS.Enumerable.toFn(d);var f=[];this.forEach(function(a){var b=JS.isFn(c.match)?c.match(a):c(a);if(!b)return;if(d)a=d.apply(e||null,arguments);f.push(a)});return f},groupBy:function(c,d){if(!c)return this.enumFor('groupBy');c=JS.Enumerable.toFn(c);var e=new JS.Hash();this.forEach(function(a){var b=c.apply(d||null,arguments);if(!e.hasKey(b))e.store(b,[]);e.get(b).push(a)});return e},inject:function(c,d,e){var f=JS.array(arguments),g=0,h={};switch(f.length){case 1:c=h;d=f[0];break;case 2:if(JS.isFn(c)){c=h;d=f[0];e=f[1]}}d=JS.Enumerable.toFn(d);this.forEach(function(a){if(!g++&&c===h)return c=a;var b=[c].concat(JS.array(arguments));c=d.apply(e||null,b)});return c},map:function(a,b){if(!a)return this.enumFor('map');a=JS.Enumerable.toFn(a);var c=[];this.forEach(function(){c.push(a.apply(b||null,arguments))});return c},max:function(a,b){return this.minmax(a,b)[1]},maxBy:function(a,b){if(!a)return this.enumFor('maxBy');return this.minmaxBy(a,b)[1]},member:function(b){return this.any(function(a){return JS.Enumerable.areEqual(a,b)})},min:function(a,b){return this.minmax(a,b)[0]},minBy:function(a,b){if(!a)return this.enumFor('minBy');return this.minmaxBy(a,b)[0]},minmax:function(a,b){var c=this.sort(a,b);return[c[0],c[c.length-1]]},minmaxBy:function(a,b){if(!a)return this.enumFor('minmaxBy');var c=this.sortBy(a,b);return[c[0],c[c.length-1]]},none:function(a,b){return!this.any(a,b)},one:function(b,c){b=JS.Enumerable.toFn(b);var d=0;this.forEach(function(a){if(b?b.apply(c||null,arguments):a)d+=1});return d===1},partition:function(b,c){if(!b)return this.enumFor('partition');b=JS.Enumerable.toFn(b);var d=[],e=[];this.forEach(function(a){(b.apply(c||null,arguments)?d:e).push(a)});return[d,e]},reject:function(b,c){if(!b)return this.enumFor('reject');b=JS.Enumerable.toFn(b);var d=[];this.forEach(function(a){if(!b.apply(c||null,arguments))d.push(a)});return d},reverseForEach:function(a,b){if(!a)return this.enumFor('reverseForEach');a=JS.Enumerable.toFn(a);var c=this.toArray(),d=c.length;while(d--)a.call(b||null,c[d]);return this},select:function(b,c){if(!b)return this.enumFor('select');b=JS.Enumerable.toFn(b);var d=[];this.forEach(function(a){if(b.apply(c||null,arguments))d.push(a)});return d},sort:function(c,d){var e=JS.Enumerable.isComparable(this),f=this.toArray();c=c||(e?function(a,b){return a.compareTo(b)}:null);return c?f.sort(function(a,b){return c.call(d||null,a,b)}):f.sort()},sortBy:function(c,d){if(!c)return this.enumFor('sortBy');c=JS.Enumerable.toFn(c);var e=JS.Enumerable,f=new e.Collection(this.map(c,d)),g=e.isComparable(f);return new e.Collection(f.zip(this).sort(function(a,b){a=a[0];b=b[0];return g?a.compareTo(b):(a<b?-1:(a>b?1:0))})).map(function(a){return a[1]})},take:function(c){var d=[];this.forEachWithIndex(function(a,b){if(b<c)d.push(a)});return d},takeWhile:function(b,c){if(!b)return this.enumFor('takeWhile');b=JS.Enumerable.toFn(b);var d=[],e=true;this.forEach(function(a){if(e)e=e&&b.apply(c||null,arguments);if(e)d.push(a)});return d},toArray:function(){return this.drop(0)},zip:function(){var d=JS.Enumerable,e=[],f=0,g=arguments.length,h,i;if(JS.isFn(arguments[g-1])){h=arguments[g-1];i={}}if(JS.isFn(arguments[g-2])){h=arguments[g-2];i=arguments[g-1]}d.forEach.call(arguments,function(a){if(a===h||a===i)return;if(a.toArray)a=a.toArray();if(JS.isType(a,Array))e.push(a)});var j=this.map(function(b){var c=[b];d.forEach.call(e,function(a){c.push(a[f]===undefined?null:a[f])});return++f&&c});if(!h)return j;d.forEach.call(j,h,i)}});JS.Enumerable.include({forEach:JS.Enumerable.forEach,collect:JS.Enumerable.instanceMethod('map'),detect:JS.Enumerable.instanceMethod('find'),entries:JS.Enumerable.instanceMethod('toArray'),every:JS.Enumerable.instanceMethod('all'),findAll:JS.Enumerable.instanceMethod('select'),filter:JS.Enumerable.instanceMethod('select'),some:JS.Enumerable.instanceMethod('any'),extend:{toFn:function(a){if(!a)return a;if(a.toFunction)return a.toFunction();if(this.OPS[a])return this.OPS[a];if(JS.isType(a,'string')||JS.isType(a,String))return function(){var b=JS.array(arguments),c=b.shift(),d=c[a];return JS.isFn(d)?d.apply(c,b):d};return a},OPS:{'+':function(a,b){return a+b},'-':function(a,b){return a-b},'*':function(a,b){return a*b},'/':function(a,b){return a/b},'%':function(a,b){return a%b},'^':function(a,b){return a^b},'&':function(a,b){return a&b},'&&':function(a,b){return a&&b},'|':function(a,b){return a|b},'||':function(a,b){return a||b},'==':function(a,b){return a==b},'!=':function(a,b){return a!=b},'>':function(a,b){return a>b},'>=':function(a,b){return a>=b},'<':function(a,b){return a<b},'<=':function(a,b){return a<=b},'===':function(a,b){return a===b},'!==':function(a,b){return a!==b},'[]':function(a,b){return a[b]},'()':function(a,b){return a(b)}},Enumerator:new JS.Class({include:JS.Enumerable,extend:{DEFAULT_METHOD:'forEach'},initialize:function(a,b,c){this._0=a;this._1=b||this.klass.DEFAULT_METHOD;this._2=(c||[]).slice()},forEach:function(a,b){if(!a)return this;var c=this._2.slice();c.push(a);if(b)c.push(b);return this._0[this._1].apply(this._0,c)},cons:JS.Enumerable.instanceMethod('forEachCons'),reverse:JS.Enumerable.instanceMethod('reverseForEach'),slice:JS.Enumerable.instanceMethod('forEachSlice'),withIndex:JS.Enumerable.instanceMethod('forEachWithIndex'),withObject:JS.Enumerable.instanceMethod('forEachWithObject')})}},false);JS.Enumerable.Collection.include(JS.Enumerable,true);JS.Kernel.include({enumFor:function(a){var b=JS.array(arguments),a=b.shift();return new JS.Enumerable.Enumerator(this,a,b)}},false);JS.Kernel.define('toEnum',JS.Kernel.instanceMethod('enumFor'),true);
@@ -0,0 +1 @@
1
+ JS.Forwardable=new JS.Module('Forwardable',{defineDelegator:function(b,e,d,f){d=d||e;this.define(d,function(){var a=this[b],c=a[e];return JS.isFn(c)?c.apply(a,arguments):c},f!==false)},defineDelegators:function(){var a=JS.array(arguments),c=a.shift(),b=a.length;while(b--)this.defineDelegator(c,a[b],a[b],false);this.resolve()}});
@@ -0,0 +1 @@
1
+ JS.Hash=new JS.Class('Hash',{include:JS.Enumerable||{},extend:{Pair:new JS.Class({include:JS.Comparable||{},setKey:function(a){this[0]=this.key=a},hasKey:function(a){var b=this.key;return b.equals?b.equals(a):b===a},setValue:function(a){this[1]=this.value=a},hasValue:function(a){var b=this.value;return b.equals?b.equals(a):b===a},compareTo:function(a){return this.key.compareTo?this.key.compareTo(a.key):(this.key<a.key?-1:(this.key>a.key?1:0))},hash:function(){var a=JS.Hash.codeFor(this.key),b=JS.Hash.codeFor(this.value);return[a,b].sort().join('')}}),codeFor:function(a){if(typeof a!=='object')return String(a);return JS.isFn(a.hash)?a.hash():a.toString()}},initialize:function(a){this.clear();if(!JS.isType(a,Array))return this.setDefault(a);for(var b=0,c=a.length;b<c;b+=2)this.store(a[b],a[b+1])},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);var c,d,e;for(c in this._0){if(!this._0.hasOwnProperty(c))continue;d=this._0[c];e=d.length;while(e--)a.call(b||null,d[e])}return this},_3:function(a,b){var c=this.klass.codeFor(a),d=this._0[c];if(!d&&b)d=this._0[c]=[];return d},_4:function(a,b){var c=a.length,d=!!this._1;while(c--){if(d?(a[c].key===b):a[c].hasKey(b))return c}return-1},assoc:function(a,b){var c,d,e;c=this._3(a,b);if(!c)return null;d=this._4(c,a);if(d>-1)return c[d];if(!b)return null;this.size+=1;this.length+=1;e=new this.klass.Pair;e.setKey(a);c.push(e);return e},rassoc:function(a){var b=this.key(a);return b?this.assoc(b):null},clear:function(){this._0={};this.length=this.size=0},compareByIdentity:function(){this._1=true},comparesByIdentity:function(){return!!this._1},setDefault:function(a){this._2=a;return this},getDefault:function(a){return JS.isFn(this._2)?this._2(this,a):(this._2||null)},equals:function(c){if(!JS.isType(c,JS.Hash)||this.length!==c.length)return false;var d=true;this.forEach(function(a){if(!d)return;var b=c.assoc(a.key);if(b===null||!b.hasValue(a.value))d=false});return d},hash:function(){var b=[];this.forEach(function(a){b.push(a.hash())});return b.sort().join('')},fetch:function(a,b){var c=this.assoc(a);if(c)return c.value;if(b===undefined)throw new Error('key not found');if(JS.isFn(b))return b(a);return b},forEachKey:function(b,c){if(!b)return this.enumFor('forEachKey');b=JS.Enumerable.toFn(b);this.forEach(function(a){b.call(c||null,a.key)});return this},forEachPair:function(b,c){if(!b)return this.enumFor('forEachPair');b=JS.Enumerable.toFn(b);this.forEach(function(a){b.call(c||null,a.key,a.value)});return this},forEachValue:function(b,c){if(!b)return this.enumFor('forEachValue');b=JS.Enumerable.toFn(b);this.forEach(function(a){b.call(c||null,a.value)});return this},get:function(a){var b=this.assoc(a);return b?b.value:this.getDefault(a)},hasKey:function(a){return!!this.assoc(a)},hasValue:function(b){var c=false,d=!!this._1;this.forEach(function(a){if((b.equals&&!d)?b.equals(a.value):b===a.value)c=true});return c},invert:function(){var b=new this.klass;this.forEach(function(a){b.store(a.value,a.key)});return b},isEmpty:function(){for(var a in this._0){if(this._0.hasOwnProperty(a)&&this._0[a].length>0)return false}return true},key:function(b){var c=null;this.forEach(function(a){if(b.equals?b.equals(a.value):(b===a.value))c=a.key});return c},keys:function(){var b=[];this.forEach(function(a){b.push(a.key)});return b},merge:function(a,b,c){var d=new this.klass;d.update(this);d.update(a,b,c);return d},rehash:function(){var a=new this.klass;a._0=this._0;this.clear();this.update(a)},remove:function(a,b){if(b===undefined)b=null;var c,d,e;c=this._3(a);if(!c)return JS.isFn(b)?this.fetch(a,b):this.getDefault(a);d=this._4(c,a);if(d<0)return JS.isFn(b)?this.fetch(a,b):this.getDefault(a);e=c[d].value;c.splice(d,1);this.size-=1;this.length-=1;if(c.length===0)delete this._0[this.klass.codeFor(a)];return e},removeIf:function(b,c){if(!b)return this.enumFor('removeIf');b=JS.Enumerable.toFn(b);this.forEach(function(a){if(b.call(c||null,a))this.remove(a.key)},this);return this},replace:function(a){this.clear();this.update(a)},shift:function(){var a=this.keys();if(a.length===0)return this.getDefault();var b=this.assoc(a[0]);this.remove(b.key);return b},store:function(a,b){this.assoc(a,true).setValue(b);return b},update:function(d,e,f){var g=JS.isFn(e);d.forEach(function(a){var b=a.key,c=a.value;if(g&&this.hasKey(b))c=e.call(f||null,b,this.get(b),c);this.store(b,c)},this)},values:function(){var b=[];this.forEach(function(a){b.push(a.value)});return b},valuesAt:function(){var a=arguments.length,b=[];while(a--)b.push(this.get(arguments[a]));return b}});JS.Hash.include({includes:JS.Hash.instanceMethod('hasKey'),index:JS.Hash.instanceMethod('key'),put:JS.Hash.instanceMethod('store')},true);
@@ -0,0 +1 @@
1
+ JS.LinkedList=new JS.Class('LinkedList',{include:JS.Enumerable||{},initialize:function(a,b){this.length=0;this.first=this.last=null;if(!a)return;for(var c=0,d=a.length;c<d;c++)this.push(b?new this.klass.Node(a[c]):a[c])},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);var c=this.first,d,e,f;for(e=0,f=this.length;e<f;e++){d=c.next;a.call(b||null,c,e);if(c===this.last)break;c=d}return this},at:function(a){if(a<0||a>=this.length)return undefined;var b=this.first;while(a--)b=b.next;return b},pop:function(){return this.length?this.remove(this.last):undefined},shift:function(){return this.length?this.remove(this.first):undefined},insertAfter:function(){},push:function(){},remove:function(){},extend:{Node:new JS.Class({initialize:function(a){this.data=a;this.prev=this.next=this.list=null}})}});JS.LinkedList.Doubly=new JS.Class('LinkedList.Doubly',JS.LinkedList,{insertAt:function(a,b){if(a<0||a>=this.length)return;this.insertBefore(this.at(a),b)},unshift:function(a){this.length>0?this.insertBefore(this.first,a):this.push(a)},insertBefore:function(){}});JS.LinkedList.insertTemplate=function(c,d,e){return function(a,b){if(a.list!==this)return;b[c]=a;b[d]=a[d];a[d]=(a[d][c]=b);if(b[c]===this[e])this[e]=b;b.list=this;this.length++}};JS.LinkedList.Doubly.Circular=new JS.Class('LinkedList.Doubly.Circular',JS.LinkedList.Doubly,{insertAfter:JS.LinkedList.insertTemplate('prev','next','last'),insertBefore:JS.LinkedList.insertTemplate('next','prev','first'),push:function(a){if(this.length)return this.insertAfter(this.last,a);this.first=this.last=a.prev=a.next=a;a.list=this;this.length=1},remove:function(a){if(a.list!==this||this.length===0)return null;if(this.length>1){a.prev.next=a.next;a.next.prev=a.prev;if(a===this.first)this.first=a.next;if(a===this.last)this.last=a.prev}else{this.first=this.last=null}a.prev=a.next=a.list=null;this.length--;return a}});
@@ -0,0 +1 @@
1
+ JS=(typeof JS==='undefined')?{}:JS;JS.Package=function(a){var b=JS.Package.OrderedSet;JS.Package._5(this);this._0=a;this._2=new b();this._6=new b();this._b=new b();this._3={};this._7={}};(function(g){var m=g.OrderedSet=function(a,b){this._c=this.list=[];this._5={};if(!a)return;for(var c=0,d=a.length;c<d;c++)this.push(b?b(a[c]):a[c])};m.prototype.push=function(a){var b=(a.id!==undefined)?a.id:a,c=this._5;if(c.hasOwnProperty(b))return;c[b]=this._c.length;this._c.push(a)};g._4=this;if((this.document||{}).getElementsByTagName){var n=document.getElementsByTagName('script')[0];g._k=(n.readyState!==undefined)}var j=g.prototype;j.addDependency=function(a){this._6.push(a)};j.addSoftDependency=function(a){this._b.push(a)};j.addName=function(a){this._2.push(a);g.getFromCache(a).pkg=this};j.onload=function(a){this._d=a};j.on=function(a,b,c){if(this._7[a])return b.call(c);var d=this._3[a]=this._3[a]||[];d.push([b,c])};j.fire=function(a){if(this._7[a])return false;this._7[a]=true;var b=this._3[a];if(!b)return true;delete this._3[a];for(var c=0,d=b.length;c<d;c++)b[c][0].call(b[c][1]);return true};j.isLoaded=function(a){if(!a&&this._8!==undefined)return this._8;var b=this._2.list,c=b.length,d,f;while(c--){d=b[c];f=g.getObject(d);if(f!==undefined)continue;if(a)throw new Error('Expected package at '+this._0+' to define '+d);else return this._8=false}return this._8=true};j.load=function(){if(!this.fire('request'))return;var c=this._6.list.concat(this._b.list),d='load',f={};f[d]=this._6.list;g.when(f,function(){g.when({complete:c,load:[this]},function(){this.fire('complete')},this);var a=this,b=function(){if(a._d)a._d();a.isLoaded(true);a.fire('load')};if(this.isLoaded()){this.fire('download');return this.fire('load')}if(this._0===undefined)throw new Error('No load path found for '+this._2.list[0]);typeof this._0==='function'?this._0(b):g.Loader.loadFile(this._0,b);this.fire('download')},this)};j.toString=function(){return'Package:'+this._2.list.join(',')};g.when=function(b,c,d){var f=[],h,k,i;for(h in b){if(!b.hasOwnProperty(h))continue;k=new g.OrderedSet(b[h],function(a){return g.getByName(a)});i=k.list.length;while(i--)f.push([h,k.list[i]])}var l=i=f.length;if(l===0)return c&&c.call(d);while(i--){f[i][1].on(f[i][0],function(){l-=1;if(l===0&&c)c.call(d)});f[i][1].load()}};g._e=1;g._f={};g._g={};g._h=[];g._5=function(a){a.id=this._e;this._e+=1};g.getByPath=function(a){var b=a.toString();return this._f[b]=this._f[b]||new this(a)};g.getByName=function(a){if(typeof a!=='string')return a;var b=this.getFromCache(a);if(b.pkg)return b.pkg;var c=this._i(a);if(c)return c;var d=new this();d.addName(a);return d};g.autoload=function(a,b){this._h.push([a,b])};g._i=function(d){var f=this._h,h=f.length,k,i,l;for(k=0;k<h;k++){i=f[k];if(!i[0].test(d))continue;l=i[1].from+'/'+d.replace(/([a-z])([A-Z])/g,function(a,b,c){return b+'_'+c}).replace(/\./g,'/').toLowerCase()+'.js';pkg=new this(l);pkg.addName(d);if(l=i[1].require)pkg.addDependency(d.replace(i[0],l));return pkg}return null};g.getFromCache=function(a){return this._g[a]=this._g[a]||{}};g.getObject=function(a){var b=this.getFromCache(a);if(b.obj!==undefined)return b.obj;var c=this._4,d=a.split('.'),f;while(f=d.shift())c=c&&c[f];return this.getFromCache(a).obj=c}})(JS.Package);JS.Package.DomLoader={usable:function(){return!!JS.Package.getObject('window.document.getElementsByTagName')},__FILE__:function(){var a=document.getElementsByTagName('script');return a[a.length-1].src},loadFile:function(c,d){var f=this,h=document.createElement('script');h.type='text/javascript';h.src=c;h.onload=h.onreadystatechange=function(){var a=h.readyState,b=h.status;if(!a||a==='loaded'||a==='complete'||(a===4&&b===200)){d();h.onload=h.onreadystatechange=f._j;h=null}};if(window.console&&console.info)console.info('Loading '+c);document.getElementsByTagName('head')[0].appendChild(h)},_j:function(){}};JS.Package.CommonJSLoader={usable:function(){return typeof require==='function'&&typeof exports==='object'},setup:function(){var b=this;require=(function(a){return function(){b._1=arguments[0]+'.js';return a.apply(JS.Package._4,arguments)}})(require)},__FILE__:function(){return this._1},loadFile:function(a,b){var c=(typeof process==='object'),d=c?process.cwd():require('file').cwd(),f=a.replace(/\.[^\.]+$/g,''),h=c?require('path'):require('file');require(h.join(d,f));b()}};JS.Package.ServerLoader={usable:function(){return typeof JS.Package.getObject('load')==='function'&&typeof JS.Package.getObject('version')==='function'},setup:function(){var b=this;load=(function(a){return function(){b._1=arguments[0];return a.apply(JS.Package._4,arguments)}})(load)},__FILE__:function(){return this._1},loadFile:function(a,b){load(a);b()}};JS.Package.WshLoader={usable:function(){return!!JS.Package.getObject('ActiveXObject')&&!!JS.Package.getObject('WScript')},__FILE__:function(){return this._1},loadFile:function(a,b){this._1=a;var c=new ActiveXObject('Scripting.FileSystemObject'),d,f;try{d=c.OpenTextFile(a);f=function(){eval(d.ReadAll())};f();b()}finally{try{if(d)d.Close()}catch(e){}}}};(function(){var a=[JS.Package.DomLoader,JS.Package.CommonJSLoader,JS.Package.ServerLoader,JS.Package.WshLoader],b=a.length,c,d;for(c=0;c<b;c++){d=a[c];if(d.usable()){JS.Package.Loader=d;if(d.setup)d.setup();break}}})();JS.Package.DSL={__FILE__:function(){return JS.Package.Loader.__FILE__()},pkg:function(a,b){var c=b?JS.Package.getByPath(b):JS.Package.getByName(a);c.addName(a);return new JS.Package.Description(c)},file:function(a){var b=JS.Package.getByPath(a);return new JS.Package.Description(b)},load:function(a,b){JS.Package.Loader.loadFile(a,b)},autoload:function(a,b){JS.Package.autoload(a,b)}};JS.Package.Description=function(a){this._9=a};(function(f){f._a=function(a,b){var c=b.length,a=this._9[a],d;for(d=0;d<c;d++)a.call(this._9,b[d]);return this};f.provides=function(){return this._a('addName',arguments)};f.requires=function(){return this._a('addDependency',arguments)};f.uses=function(){return this._a('addSoftDependency',arguments)};f.setup=function(a){this._9.onload(a);return this}})(JS.Package.Description.prototype);JS.Package.DSL.loader=JS.Package.DSL.file;JS.Packages=function(a){a.call(JS.Package.DSL)};JS.require=function(){var a=[],b=0;while(typeof arguments[b]==='string'){a.push(arguments[b]);b+=1}JS.Package.when({complete:a},arguments[b],arguments[b+1])};JS.Packages(function(){with(this){var b=JS.Package._4.JSCLASS_PATH||__FILE__().replace(/[^\/]*$/g,'');if(!/\/$/.test(b))b=b+'/';var c=function(a){return file(b+a+'.js')};c('core').provides('JS.Module','JS.Class','JS.Kernel','JS.Singleton','JS.Interface');c('comparable').provides('JS.Comparable').requires('JS.Module');c('constant_scope').provides('JS.ConstantScope').requires('JS.Module');c('forwardable').provides('JS.Forwardable').requires('JS.Module');c('enumerable').provides('JS.Enumerable').requires('JS.Module','JS.Class');c('observable').provides('JS.Observable').requires('JS.Module');c('hash').provides('JS.Hash').requires('JS.Class','JS.Enumerable','JS.Comparable');c('set').provides('JS.Set','JS.HashSet','JS.SortedSet').requires('JS.Class','JS.Enumerable').uses('JS.Hash');c('linked_list').provides('JS.LinkedList','JS.LinkedList.Doubly','JS.LinkedList.Doubly.Circular').requires('JS.Class','JS.Enumerable');c('command').provides('JS.Command','JS.Command.Stack').requires('JS.Class','JS.Enumerable','JS.Observable');c('decorator').provides('JS.Decorator').requires('JS.Module','JS.Class');c('method_chain').provides('JS.MethodChain').requires('JS.Module','JS.Kernel');c('proxy').provides('JS.Proxy','JS.Proxy.Virtual').requires('JS.Module','JS.Class');c('ruby').provides('JS.Ruby').requires('JS.Class');c('stack_trace').provides('JS.StackTrace').requires('JS.Module','JS.Singleton');c('state').provides('JS.State').requires('JS.Module','JS.Class')}});
@@ -0,0 +1 @@
1
+ JS.MethodChain=function(c){var d=[],e=c||{};this.____=function(a,b){d.push({func:a,args:b})};this.fire=function(a){return JS.MethodChain.fire(d,a||e)}};JS.MethodChain.fire=function(a,b){var c,d,e,f;loop:for(e=0,f=a.length;e<f;e++){c=a[e];if(b instanceof JS.MethodChain){b.____(c.func,c.args);continue}switch(typeof c.func){case'string':d=b[c.func];break;case'function':d=c.func;break;case'object':b=c.func;continue loop;break}b=(typeof d==='function')?d.apply(b,c.args):d}return b};JS.MethodChain.prototype={_:function(){var a=arguments[0],b,c,d;switch(typeof a){case'object':case'function':b=[];for(c=1,d=arguments.length;c<d;c++)b.push(arguments[c]);this.____(a,b)}return this},toFunction:function(){var b=this;return function(a){return b.fire(a)}}};JS.MethodChain.reserved=(function(){var a=[],b;for(b in new JS.MethodChain)a.push(b);return new RegExp('^(?:'+a.join('|')+')$')})();JS.MethodChain.addMethod=function(a){if(this.reserved.test(a))return;var b=this.prototype[a]=function(){this.____(a,arguments);return this};b.displayName='MethodChain#'+a};JS.MethodChain.displayName='MethodChain';JS.MethodChain.addMethods=function(a){var b=[],c,d;for(c in a)Number(c)!==c&&b.push(c);if(a instanceof Array){d=a.length;while(d--)typeof a[d]==='string'&&b.push(a[d])}d=b.length;while(d--)this.addMethod(b[d]);a.__fns__&&this.addMethods(a.__fns__);a.prototype&&this.addMethods(a.prototype)};it=its=function(){return new JS.MethodChain};JS.Module.methodAdded(function(a){JS.MethodChain.addMethod(a)});JS.Kernel.include({wait:function(a){var b=new JS.MethodChain;typeof a==='number'&&setTimeout(b.fire.bind(b,this),a*1000);this.forEach&&typeof a==='function'&&this.forEach(function(){setTimeout(b.fire.bind(b,arguments[0]),a.apply(this,arguments)*1000)});return b},_:function(){var a=arguments[0],b=[],c,d;for(c=1,d=arguments.length;c<d;c++)b.push(arguments[c]);return(typeof a==='object'&&a)||(typeof a==='function'&&a.apply(this,b))||this}},true);(function(){var a=JS.Module.__chainq__,b=a.length;while(b--)JS.MethodChain.addMethods(a[b]);JS.Module.__chainq__=null})();JS.MethodChain.addMethods(["abbr","abs","accept","acceptCharset","accesskey","acos","action","addEventListener","adjacentNode","align","alignWithTop","alink","alt","anchor","appendChild","appendedNode","apply","archive","arguments","arity","asin","atan","atan2","attrNode","attributes","axis","background","bgcolor","big","blink","blur","bold","border","call","caller","ceil","cellpadding","cellspacing","char","charAt","charCodeAt","charoff","charset","checked","childNodes","cite","className","classid","clear","click","clientHeight","clientLeft","clientTop","clientWidth","cloneNode","code","codebase","codetype","color","cols","colspan","compact","concat","content","coords","cos","data","datetime","declare","deep","defer","dir","disabled","dispatchEvent","enctype","event","every","exec","exp","face","filter","firstChild","fixed","floor","focus","fontcolor","fontsize","forEach","frame","frameborder","fromCharCode","getAttribute","getAttributeNS","getAttributeNode","getAttributeNodeNS","getDate","getDay","getElementsByTagName","getElementsByTagNameNS","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getTime","getTimezoneOffset","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","getYear","global","handler","hasAttribute","hasAttributeNS","hasAttributes","hasChildNodes","hasOwnProperty","headers","height","href","hreflang","hspace","htmlFor","httpEquiv","id","ignoreCase","index","indexOf","innerHTML","input","insertBefore","insertedNode","isPrototypeOf","ismap","italics","join","label","lang","language","lastChild","lastIndex","lastIndexOf","length","link","listener","localName","log","longdesc","map","marginheight","marginwidth","match","max","maxlength","media","method","min","multiline","multiple","name","namespace","namespaceURI","nextSibling","node","nodeName","nodeType","nodeValue","nohref","noresize","normalize","noshade","now","nowrap","object","offsetHeight","offsetLeft","offsetParent","offsetTop","offsetWidth","onblur","onchange","onclick","ondblclick","onfocus","onkeydown","onkeypress","onkeyup","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onreset","onselect","onsubmit","onunload","ownerDocument","parentNode","parse","pop","pow","prefix","previousSibling","profile","prompt","propertyIsEnumerable","push","random","readonly","reduce","reduceRight","rel","removeAttribute","removeAttributeNS","removeAttributeNode","removeChild","removeEventListener","removedNode","replace","replaceChild","replacedNode","rev","reverse","round","rows","rowspan","rules","scheme","scope","scrollHeight","scrollIntoView","scrollLeft","scrollTop","scrollWidth","scrolling","search","selected","setAttribute","setAttributeNS","setAttributeNode","setAttributeNodeNS","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear","shape","shift","sin","size","slice","small","some","sort","source","span","splice","split","sqrt","src","standby","start","strike","style","sub","substr","substring","summary","sup","tabIndex","tabindex","tagName","tan","target","test","text","textContent","title","toArray","toFunction","toGMTString","toLocaleDateString","toLocaleFormat","toLocaleString","toLocaleTimeString","toLowerCase","toSource","toString","toUTCString","toUpperCase","type","unshift","unwatch","useCapture","usemap","valign","value","valueOf","valuetype","version","vlink","vspace","watch","width"]);
@@ -0,0 +1 @@
1
+ JS.Observable=new JS.Module('Observable',{extend:{DEFAULT_METHOD:'update'},addObserver:function(c,b){(this.__observers__=this.__observers__||[]).push({_0:c,_1:b||null})},removeObserver:function(c,b){this.__observers__=this.__observers__||[];b=b||null;var a=this.countObservers();while(a--){if(this.__observers__[a]._0===c&&this.__observers__[a]._1===b){this.__observers__.splice(a,1);return}}},removeObservers:function(){this.__observers__=[]},countObservers:function(){return(this.__observers__=this.__observers__||[]).length},notifyObservers:function(){if(!this.isChanged())return;var c=this.countObservers(),b,a,d;while(c--){b=this.__observers__[c];a=b._0;d=b._1;if(JS.isFn(a))a.apply(d||null,arguments);else a[d||JS.Observable.DEFAULT_METHOD].apply(a,arguments)}},setChanged:function(c){this.__changed__=!(c===false)},isChanged:function(){if(this.__changed__===undefined)this.__changed__=true;return!!this.__changed__}});JS.Observable.include({subscribe:JS.Observable.instanceMethod('addObserver'),unsubscribe:JS.Observable.instanceMethod('removeObserver')},true);
@@ -0,0 +1 @@
1
+ JS=(typeof JS==='undefined')?{}:JS;JS.Package=function(a){var b=JS.Package.OrderedSet;JS.Package._4(this);this._0=a;this._2=new b();this._5=new b();this._b=new b();this._3={};this._6={}};(function(g){var m=g.OrderedSet=function(a,b){this._c=this.list=[];this._4={};if(!a)return;for(var c=0,d=a.length;c<d;c++)this.push(b?b(a[c]):a[c])};m.prototype.push=function(a){var b=(a.id!==undefined)?a.id:a,c=this._4;if(c.hasOwnProperty(b))return;c[b]=this._c.length;this._c.push(a)};g._7=this;if((this.document||{}).getElementsByTagName){var n=document.getElementsByTagName('script')[0];g._k=(n.readyState!==undefined)}var j=g.prototype;j.addDependency=function(a){this._5.push(a)};j.addSoftDependency=function(a){this._b.push(a)};j.addName=function(a){this._2.push(a);g.getFromCache(a).pkg=this};j.onload=function(a){this._d=a};j.on=function(a,b,c){if(this._6[a])return b.call(c);var d=this._3[a]=this._3[a]||[];d.push([b,c])};j.fire=function(a){if(this._6[a])return false;this._6[a]=true;var b=this._3[a];if(!b)return true;delete this._3[a];for(var c=0,d=b.length;c<d;c++)b[c][0].call(b[c][1]);return true};j.isLoaded=function(a){if(!a&&this._8!==undefined)return this._8;var b=this._2.list,c=b.length,d,f;while(c--){d=b[c];f=g.getObject(d);if(f!==undefined)continue;if(a)throw new Error('Expected package at '+this._0+' to define '+d);else return this._8=false}return this._8=true};j.load=function(){if(!this.fire('request'))return;var c=this._5.list.concat(this._b.list),d='load',f={};f[d]=this._5.list;g.when(f,function(){g.when({complete:c,load:[this]},function(){this.fire('complete')},this);var a=this,b=function(){if(a._d)a._d();a.isLoaded(true);a.fire('load')};if(this.isLoaded()){this.fire('download');return this.fire('load')}if(this._0===undefined)throw new Error('No load path found for '+this._2.list[0]);typeof this._0==='function'?this._0(b):g.Loader.loadFile(this._0,b);this.fire('download')},this)};j.toString=function(){return'Package:'+this._2.list.join(',')};g.when=function(b,c,d){var f=[],h,k,i;for(h in b){if(!b.hasOwnProperty(h))continue;k=new g.OrderedSet(b[h],function(a){return g.getByName(a)});i=k.list.length;while(i--)f.push([h,k.list[i]])}var l=i=f.length;if(l===0)return c&&c.call(d);while(i--){f[i][1].on(f[i][0],function(){l-=1;if(l===0&&c)c.call(d)});f[i][1].load()}};g._e=1;g._f={};g._g={};g._h=[];g._4=function(a){a.id=this._e;this._e+=1};g.getByPath=function(a){var b=a.toString();return this._f[b]=this._f[b]||new this(a)};g.getByName=function(a){if(typeof a!=='string')return a;var b=this.getFromCache(a);if(b.pkg)return b.pkg;var c=this._i(a);if(c)return c;var d=new this();d.addName(a);return d};g.autoload=function(a,b){this._h.push([a,b])};g._i=function(d){var f=this._h,h=f.length,k,i,l;for(k=0;k<h;k++){i=f[k];if(!i[0].test(d))continue;l=i[1].from+'/'+d.replace(/([a-z])([A-Z])/g,function(a,b,c){return b+'_'+c}).replace(/\./g,'/').toLowerCase()+'.js';pkg=new this(l);pkg.addName(d);if(l=i[1].require)pkg.addDependency(d.replace(i[0],l));return pkg}return null};g.getFromCache=function(a){return this._g[a]=this._g[a]||{}};g.getObject=function(a){var b=this.getFromCache(a);if(b.obj!==undefined)return b.obj;var c=this._7,d=a.split('.'),f;while(f=d.shift())c=c&&c[f];return this.getFromCache(a).obj=c}})(JS.Package);JS.Package.DomLoader={usable:function(){return!!JS.Package.getObject('window.document.getElementsByTagName')},__FILE__:function(){var a=document.getElementsByTagName('script');return a[a.length-1].src},loadFile:function(c,d){var f=this,h=document.createElement('script');h.type='text/javascript';h.src=c;h.onload=h.onreadystatechange=function(){var a=h.readyState,b=h.status;if(!a||a==='loaded'||a==='complete'||(a===4&&b===200)){d();h.onload=h.onreadystatechange=f._j;h=null}};if(window.console&&console.info)console.info('Loading '+c);document.getElementsByTagName('head')[0].appendChild(h)},_j:function(){}};JS.Package.CommonJSLoader={usable:function(){return typeof require==='function'&&typeof exports==='object'},setup:function(){var b=this;require=(function(a){return function(){b._1=arguments[0]+'.js';return a.apply(JS.Package._7,arguments)}})(require)},__FILE__:function(){return this._1},loadFile:function(a,b){var c=(typeof process==='object'),d=c?process.cwd():require('file').cwd(),f=a.replace(/\.[^\.]+$/g,''),h=c?require('path'):require('file');require(h.join(d,f));b()}};JS.Package.ServerLoader={usable:function(){return typeof JS.Package.getObject('load')==='function'&&typeof JS.Package.getObject('version')==='function'},setup:function(){var b=this;load=(function(a){return function(){b._1=arguments[0];return a.apply(JS.Package._7,arguments)}})(load)},__FILE__:function(){return this._1},loadFile:function(a,b){load(a);b()}};JS.Package.WshLoader={usable:function(){return!!JS.Package.getObject('ActiveXObject')&&!!JS.Package.getObject('WScript')},__FILE__:function(){return this._1},loadFile:function(a,b){this._1=a;var c=new ActiveXObject('Scripting.FileSystemObject'),d,f;try{d=c.OpenTextFile(a);f=function(){eval(d.ReadAll())};f();b()}finally{try{if(d)d.Close()}catch(e){}}}};(function(){var a=[JS.Package.DomLoader,JS.Package.CommonJSLoader,JS.Package.ServerLoader,JS.Package.WshLoader],b=a.length,c,d;for(c=0;c<b;c++){d=a[c];if(d.usable()){JS.Package.Loader=d;if(d.setup)d.setup();break}}})();JS.Package.DSL={__FILE__:function(){return JS.Package.Loader.__FILE__()},pkg:function(a,b){var c=b?JS.Package.getByPath(b):JS.Package.getByName(a);c.addName(a);return new JS.Package.Description(c)},file:function(a){var b=JS.Package.getByPath(a);return new JS.Package.Description(b)},load:function(a,b){JS.Package.Loader.loadFile(a,b)},autoload:function(a,b){JS.Package.autoload(a,b)}};JS.Package.Description=function(a){this._9=a};(function(f){f._a=function(a,b){var c=b.length,a=this._9[a],d;for(d=0;d<c;d++)a.call(this._9,b[d]);return this};f.provides=function(){return this._a('addName',arguments)};f.requires=function(){return this._a('addDependency',arguments)};f.uses=function(){return this._a('addSoftDependency',arguments)};f.setup=function(a){this._9.onload(a);return this}})(JS.Package.Description.prototype);JS.Package.DSL.loader=JS.Package.DSL.file;JS.Packages=function(a){a.call(JS.Package.DSL)};JS.require=function(){var a=[],b=0;while(typeof arguments[b]==='string'){a.push(arguments[b]);b+=1}JS.Package.when({complete:a},arguments[b],arguments[b+1])};
@@ -0,0 +1 @@
1
+ if(JS.Proxy===undefined)JS.Proxy={};JS.Proxy.Virtual=new JS.Class('Proxy.Virtual',{initialize:function(a){var g=function(){},e=new JS.Class(),h={},f,d;g.prototype=a.prototype;for(f in a.prototype){d=a.prototype[f];if(JS.isFn(d)&&d!==a)d=this.klass.forward(f);h[f]=d}e.include({initialize:function(){var c=arguments,b=null;this.__getSubject__=function(){b=new g;a.apply(b,c);return(this.__getSubject__=function(){return b})()}},klass:a,constructor:a},false);e.include(new JS.Module(h),false);e.include(this.klass.InstanceMethods,true);return e},extend:{forward:function(b){return function(){var c=this.__getSubject__();return c[b].apply(c,arguments)}},InstanceMethods:new JS.Module({extend:function(c){this.__getSubject__().extend(c);var b,a;for(b in c){a=c[b];if(JS.isFn(a))a=JS.Proxy.Virtual.forward(b);this[b]=a}}})}});
@@ -0,0 +1 @@
1
+ JS.Ruby=function(d,b){b.call(new JS.Ruby.ClassBuilder(d))};JS.extend(JS.Ruby,{extendDSL:function(d,b){for(var a in b){if(d[a]||!JS.isFn(b[a]))continue;this.addMethod(d,b,a)}},addMethod:function(b,a,c){b[c]=function(){var d=a[c].apply(a,arguments);JS.Ruby.extendDSL(b,a);return d}},alias:function(c,e){return function(d,b){var a=c[b];if(a!==undefined)this.def(d,a);if(e)JS.Ruby.extendDSL(e,c)}},ClassBuilder:function(c){this.def=c.method('define');this.alias=JS.Ruby.alias(c.prototype);this.self={def:JS.bind(function(d,b){var a={};a[d]=b;c.extend(a);JS.Ruby.extendDSL(this,c)},this),alias:JS.Ruby.alias(c,this)};JS.Ruby.extendDSL(this,c)}});
@@ -0,0 +1 @@
1
+ JS.Set=new JS.Class('Set',{extend:{forEach:function(a,b,c){if(!a||!b)return;if(a.forEach)return a.forEach(b,c);for(var d=0,e=a.length;d<e;d++){if(a[d]!==undefined)b.call(c||null,a[d],d)}}},include:JS.Enumerable||{},initialize:function(a,b,c){this.clear();if(b)this.klass.forEach(a,function(item){this.add(b.call(c||null,item))},this);else this.merge(a)},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);this.klass.forEach(this._0,a,b);return this},add:function(a){if(this.contains(a))return false;this._0.push(a);this.length=this.size=this._0.length;return true},classify:function(c,d){if(!c)return this.enumFor('classify');c=JS.Enumerable.toFn(c);var e=new JS.Hash();this.forEach(function(a){var b=c.call(d||null,a);if(!e.hasKey(b))e.store(b,new this.klass);e.get(b).add(a)},this);return e},clear:function(){this._0=[];this.length=this.size=0},complement:function(b){var c=new this.klass;this.klass.forEach(b,function(a){if(!this.contains(a))c.add(a)},this);return c},contains:function(a){return this._1(a)!==-1},difference:function(b){b=JS.isType(b,JS.Set)?b:new JS.Set(b);var c=new this.klass;this.forEach(function(a){if(!b.contains(a))c.add(a)});return c},divide:function(a,b){if(!a)return this.enumFor('divide');a=JS.Enumerable.toFn(a);var c=this.classify(a,b),d=new this.klass;c.forEachValue(d.method('add'));return d},equals:function(b){if(this.length!==b.length||!JS.isType(b,JS.Set))return false;var c=true;this.forEach(function(a){if(!c)return;if(!b.contains(a))c=false});return c},hash:function(){var b=[];this.forEach(function(a){b.push(JS.Hash.codeFor(a))});return b.sort().join('')},flatten:function(b){var c=new this.klass;c._0=this._0;if(!b){b=this;b.clear()}c.forEach(function(a){if(JS.isType(a,JS.Set))a.flatten(b);else b.add(a)});return b},intersection:function(b){var c=new this.klass;this.klass.forEach(b,function(a){if(this.contains(a))c.add(a)},this);return c},isEmpty:function(){return this._0.length===0},isProperSubset:function(a){return this._0.length<a._0.length&&this.isSubset(a)},isProperSuperset:function(a){return this._0.length>a._0.length&&this.isSuperset(a)},isSubset:function(b){var c=true;this.forEach(function(a){if(!c)return;if(!b.contains(a))c=false});return c},isSuperset:function(a){return a.isSubset(this)},merge:function(b){this.klass.forEach(b,function(a){this.add(a)},this)},product:function(c){var d=new JS.Set;this.forEach(function(b){this.klass.forEach(c,function(a){d.add([b,a])})},this);return d},rebuild:function(){var a=this._0;this.clear();this.merge(a)},remove:function(a){var b=this._1(a);if(b===-1)return;this._0.splice(b,1);this.length=this.size=this._0.length},removeIf:function(a,b){if(!a)return this.enumFor('removeIf');a=JS.Enumerable.toFn(a);var c=this._0,d=c.length;while(d--){if(a.call(b||null,c[d]))this.remove(c[d])}return this},replace:function(a){this.clear();this.merge(a)},subtract:function(b){this.klass.forEach(b,function(a){this.remove(a)},this)},union:function(a){var b=new this.klass;b.merge(this);b.merge(a);return b},xor:function(b){var c=new JS.Set(b);this.forEach(function(a){c[c.contains(a)?'remove':'add'](a)});return c},_1:function(a){var b=this._0.length,c=JS.Enumerable.areEqual;while(b--){if(c(a,this._0[b]))return b}return-1}});JS.Set.include({n:JS.Set.instanceMethod('intersection'),u:JS.Set.instanceMethod('union'),x:JS.Set.instanceMethod('product')},false);JS.SortedSet=new JS.Class('SortedSet',JS.Set,{extend:{compare:function(a,b){return JS.isType(a,Object)?a.compareTo(b):(a<b?-1:(a>b?1:0))}},add:function(a){var b=this._1(a,true);if(b===null)return;this._0.splice(b,0,a);this.length=this.size=this._0.length},_1:function(a,b){var c=this._0,d=c.length,e=0,f=d,g=this.klass.compare,h=JS.Enumerable.areEqual,i;if(d===0)return b?0:-1;if(g(a,c[0])<1){f=0;e=0}if(g(a,c[d-1])>0){f=0;e=d}while(!h(a,c[e])&&f>0.5){f=f/2;e+=(g(a,c[e])>0?1:-1)*Math.round(f);if(e>0&&g(a,c[e-1])>0&&g(a,c[e])<1)f=0}while(c[e]&&!h(a,c[e])&&g(a,c[e])===0)e+=1;i=h(a,c[e]);return b?(i?null:e):(i?e:-1)}});JS.HashSet=new JS.Class('HashSet',JS.Set,{forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);this._0.forEachKey(a,b);return this},add:function(a){if(this.contains(a))return false;this._0.store(a,true);this.length=this.size=this._0.length;return true},clear:function(){this._0=new JS.Hash();this.size=this.length=0},contains:function(a){return this._0.hasKey(a)},rebuild:function(){this._0.rehash();this.length=this.size=this._0.length},remove:function(a){this._0.remove(a);this.length=this.size=this._0.length},removeIf:function(b,c){if(!b)return this.enumFor('removeIf');b=JS.Enumerable.toFn(b);this._0.removeIf(function(a){return b.call(c||null,a.key)});this.length=this.size=this._0.length;return this}});JS.Enumerable.include({toSet:function(a,b,c){a=a||JS.Set;return new a(this,b,c)}},true);
@@ -0,0 +1 @@
1
+ JS.StackTrace=new JS.Module('StackTrace',{extend:{included:function(h){var f=h.__mod__||h,b=this,d;f.extend({define:function(a,c){if(!JS.isFn(c))return this.callSuper();var g=b.wrap(c,f,a);return this.callSuper(a,g)}});for(d in f.__fns__)f.define(d,f.__fns__[d],false);f.resolve();if(!f.__nom__)setTimeout(function(){f.__nom__=b.nameOf(h)},1)},nameOf:function(a,c){var g=[],h,f,b,d;if(JS.isType(a,Array)){for(h=0,f=a.length;h<f;h++)g.push(this.nameOf(a[h]));return g}if(a.__nom__)return a.__nom__;b=[{name:null,o:c||this.root}];d=0;while(typeof b==='object'&&d<this.maxDepth){d+=1;b=this.descend(b,a)}if(typeof b=='string'){b=b.replace(/\.prototype\./g,'#');a.__nom__=b;if(a.__meta__)a.__meta__.__nom__=b+'.__meta__'}return a.__nom__},descend:function(a,c){var g=[],h=a.length,f=h,b,d,i;while(f--){d=a[f];if(h>1&&JS.indexOf(this.excluded,d.o)!==-1)continue;if(JS.isType(d.o,Array))continue;i=d.name?d.name+'.':'';for(b in d.o){if(c&&d.o[b]===c)return i+b;g.push({name:i+b,o:d.o[b]})}}return g},root:this,excluded:[],maxDepth:8,logLevel:'full',stack:new JS.Singleton({_0:[],indent:function(){var a='',c=this._0.length;while(c--)a+='| ';return a},push:function(a,c,g){if(JS.StackTrace.logLevel==='full')window.console&&console.log(this.indent()+a+'(',g,')');this._0.push({name:a,object:c,args:g})},pop:function(a){var c=this._0.pop().name;if(JS.StackTrace.logLevel==='full')window.console&&console.log(this.indent()+c+'() --> ',a);return c},top:function(){return this._0[this._0.length-1]||{}},backtrace:function(){var a=this._0.length,c;while(a--){c=this._0[a];window.console&&console.log(c.name,'in',c.object,'(',c.args,')')}}}),flush:function(){this.stack._0=[]},print:function(){this.stack.backtrace()},wrap:function(g,h,f){var b=JS.StackTrace;var d=function(){var a,c=b.nameOf(h)+'#'+f;b.stack.push(c,this,arguments);if(b.logLevel==='errors'){try{a=g.apply(this,arguments)}catch(e){if(e.logged)throw e;e.logged=true;window.console&&console.error(e,'thrown by',b.stack.top().name+'. Backtrace:');b.print();b.flush();throw e;}}else{a=g.apply(this,arguments)}b.stack.pop(a);return a};d.toString=function(){return g.toString()};return d}}});(function(){var a=JS.StackTrace,c;for(c in a.root){if(c!=='JS')a.excluded.push(a.root[c])}})();
@@ -0,0 +1 @@
1
+ JS.State=new JS.Module('State',{__getState__:function(a){return(typeof a==='object'&&a)||(typeof a==='string'&&((this.states||{})[a]||{}))||{}},setState:function(a){this.__state__=this.__getState__(a);JS.State.addMethods(this.__state__,this.klass)},inState:function(){var a=arguments.length;while(a--){if(this.__state__===this.__getState__(arguments[a]))return true}return false},extend:{stub:function(){return this},buildStubs:function(a,b,c){var d,e;for(d in c){b[d]={};for(e in c[d])a[e]=this.stub}},findStates:function(a,b){var c=a.length,d=[];while(c--){if(a[c].hasOwnProperty(b))d.push(a[c][b])}return d},buildCollection:function(a,b){var c={},d={},e=a.lookup('states'),h,g,j,i,k,f,l;this.buildStubs(c,d,b);for(f=0,l=e.length;f<l;f++)this.buildStubs(c,d,e[f]);for(h in d){g=new JS.Class(b[h]);k=this.findStates(e,h);f=k.length;while(f--)g.include(k[f].klass);j={};for(i in c){if(!g.prototype[i])j[i]=c[i]}g.include(j);d[h]=new g}if(a.__res__)this.addMethods(c,a.__res__.klass);return d},addMethods:function(a,b){if(!b)return;var c={},d=b.prototype,e;for(e in a){if(d[e])continue;d[e]=b.__mod__.__fns__[e]=this.wrapped(e)}},wrapped:function(b){return function(){var a=(this.__state__||{})[b];return a?a.apply(this,arguments):this}}}});JS.Module.include({define:(function(c){return function(a,b){if(a==='states'&&typeof b==='object')arguments[1]=JS.State.buildCollection(this,b);return c.apply(this,arguments)}})(JS.Module.prototype.define)},true);
@@ -0,0 +1,16 @@
1
+ JS.MethodChain=function(c){var d=[],e=c||{};this.____=function(a,b){d.push({func:a,args:b})};this.fire=function(a){return JS.MethodChain.fire(d,a||e)}};JS.MethodChain.fire=function(a,b){var c,d,e,f;loop:for(e=0,f=a.length;e<f;e++){c=a[e];if(b instanceof JS.MethodChain){b.____(c.func,c.args);continue}switch(typeof c.func){case'string':d=b[c.func];break;case'function':d=c.func;break;case'object':b=c.func;continue loop;break}b=(typeof d==='function')?d.apply(b,c.args):d}return b};JS.MethodChain.prototype={_:function(){var a=arguments[0],b,c,d;switch(typeof a){case'object':case'function':b=[];for(c=1,d=arguments.length;c<d;c++)b.push(arguments[c]);this.____(a,b)}return this},toFunction:function(){var b=this;return function(a){return b.fire(a)}}};JS.MethodChain.reserved=(function(){var a=[],b;for(b in new JS.MethodChain)a.push(b);return new RegExp('^(?:'+a.join('|')+')$')})();JS.MethodChain.addMethod=function(a){if(this.reserved.test(a))return;var b=this.prototype[a]=function(){this.____(a,arguments);return this};b.displayName='MethodChain#'+a};JS.MethodChain.displayName='MethodChain';JS.MethodChain.addMethods=function(a){var b=[],c,d;for(c in a)Number(c)!==c&&b.push(c);if(a instanceof Array){d=a.length;while(d--)typeof a[d]==='string'&&b.push(a[d])}d=b.length;while(d--)this.addMethod(b[d]);a.__fns__&&this.addMethods(a.__fns__);a.prototype&&this.addMethods(a.prototype)};it=its=function(){return new JS.MethodChain};JS.Module.methodAdded(function(a){JS.MethodChain.addMethod(a)});JS.Kernel.include({wait:function(a){var b=new JS.MethodChain;typeof a==='number'&&setTimeout(b.fire.bind(b,this),a*1000);this.forEach&&typeof a==='function'&&this.forEach(function(){setTimeout(b.fire.bind(b,arguments[0]),a.apply(this,arguments)*1000)});return b},_:function(){var a=arguments[0],b=[],c,d;for(c=1,d=arguments.length;c<d;c++)b.push(arguments[c]);return(typeof a==='object'&&a)||(typeof a==='function'&&a.apply(this,b))||this}},true);(function(){var a=JS.Module.__chainq__,b=a.length;while(b--)JS.MethodChain.addMethods(a[b]);JS.Module.__chainq__=null})();JS.MethodChain.addMethods(["abbr","abs","accept","acceptCharset","accesskey","acos","action","addEventListener","adjacentNode","align","alignWithTop","alink","alt","anchor","appendChild","appendedNode","apply","archive","arguments","arity","asin","atan","atan2","attrNode","attributes","axis","background","bgcolor","big","blink","blur","bold","border","call","caller","ceil","cellpadding","cellspacing","char","charAt","charCodeAt","charoff","charset","checked","childNodes","cite","className","classid","clear","click","clientHeight","clientLeft","clientTop","clientWidth","cloneNode","code","codebase","codetype","color","cols","colspan","compact","concat","content","coords","cos","data","datetime","declare","deep","defer","dir","disabled","dispatchEvent","enctype","event","every","exec","exp","face","filter","firstChild","fixed","floor","focus","fontcolor","fontsize","forEach","frame","frameborder","fromCharCode","getAttribute","getAttributeNS","getAttributeNode","getAttributeNodeNS","getDate","getDay","getElementsByTagName","getElementsByTagNameNS","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getTime","getTimezoneOffset","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","getYear","global","handler","hasAttribute","hasAttributeNS","hasAttributes","hasChildNodes","hasOwnProperty","headers","height","href","hreflang","hspace","htmlFor","httpEquiv","id","ignoreCase","index","indexOf","innerHTML","input","insertBefore","insertedNode","isPrototypeOf","ismap","italics","join","label","lang","language","lastChild","lastIndex","lastIndexOf","length","link","listener","localName","log","longdesc","map","marginheight","marginwidth","match","max","maxlength","media","method","min","multiline","multiple","name","namespace","namespaceURI","nextSibling","node","nodeName","nodeType","nodeValue","nohref","noresize","normalize","noshade","now","nowrap","object","offsetHeight","offsetLeft","offsetParent","offsetTop","offsetWidth","onblur","onchange","onclick","ondblclick","onfocus","onkeydown","onkeypress","onkeyup","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onreset","onselect","onsubmit","onunload","ownerDocument","parentNode","parse","pop","pow","prefix","previousSibling","profile","prompt","propertyIsEnumerable","push","random","readonly","reduce","reduceRight","rel","removeAttribute","removeAttributeNS","removeAttributeNode","removeChild","removeEventListener","removedNode","replace","replaceChild","replacedNode","rev","reverse","round","rows","rowspan","rules","scheme","scope","scrollHeight","scrollIntoView","scrollLeft","scrollTop","scrollWidth","scrolling","search","selected","setAttribute","setAttributeNS","setAttributeNode","setAttributeNodeNS","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear","shape","shift","sin","size","slice","small","some","sort","source","span","splice","split","sqrt","src","standby","start","strike","style","sub","substr","substring","summary","sup","tabIndex","tabindex","tagName","tan","target","test","text","textContent","title","toArray","toFunction","toGMTString","toLocaleDateString","toLocaleFormat","toLocaleString","toLocaleTimeString","toLowerCase","toSource","toString","toUTCString","toUpperCase","type","unshift","unwatch","useCapture","usemap","valign","value","valueOf","valuetype","version","vlink","vspace","watch","width"]);
2
+ JS=(typeof JS==='undefined')?{}:JS;JS.Package=function(a){var b=JS.Package.OrderedSet;JS.Package._4(this);this._0=a;this._2=new b();this._5=new b();this._b=new b();this._3={};this._6={}};(function(g){var m=g.OrderedSet=function(a,b){this._c=this.list=[];this._4={};if(!a)return;for(var c=0,d=a.length;c<d;c++)this.push(b?b(a[c]):a[c])};m.prototype.push=function(a){var b=(a.id!==undefined)?a.id:a,c=this._4;if(c.hasOwnProperty(b))return;c[b]=this._c.length;this._c.push(a)};g._7=this;if((this.document||{}).getElementsByTagName){var n=document.getElementsByTagName('script')[0];g._k=(n.readyState!==undefined)}var j=g.prototype;j.addDependency=function(a){this._5.push(a)};j.addSoftDependency=function(a){this._b.push(a)};j.addName=function(a){this._2.push(a);g.getFromCache(a).pkg=this};j.onload=function(a){this._d=a};j.on=function(a,b,c){if(this._6[a])return b.call(c);var d=this._3[a]=this._3[a]||[];d.push([b,c])};j.fire=function(a){if(this._6[a])return false;this._6[a]=true;var b=this._3[a];if(!b)return true;delete this._3[a];for(var c=0,d=b.length;c<d;c++)b[c][0].call(b[c][1]);return true};j.isLoaded=function(a){if(!a&&this._8!==undefined)return this._8;var b=this._2.list,c=b.length,d,f;while(c--){d=b[c];f=g.getObject(d);if(f!==undefined)continue;if(a)throw new Error('Expected package at '+this._0+' to define '+d);else return this._8=false}return this._8=true};j.load=function(){if(!this.fire('request'))return;var c=this._5.list.concat(this._b.list),d='load',f={};f[d]=this._5.list;g.when(f,function(){g.when({complete:c,load:[this]},function(){this.fire('complete')},this);var a=this,b=function(){if(a._d)a._d();a.isLoaded(true);a.fire('load')};if(this.isLoaded()){this.fire('download');return this.fire('load')}if(this._0===undefined)throw new Error('No load path found for '+this._2.list[0]);typeof this._0==='function'?this._0(b):g.Loader.loadFile(this._0,b);this.fire('download')},this)};j.toString=function(){return'Package:'+this._2.list.join(',')};g.when=function(b,c,d){var f=[],h,k,i;for(h in b){if(!b.hasOwnProperty(h))continue;k=new g.OrderedSet(b[h],function(a){return g.getByName(a)});i=k.list.length;while(i--)f.push([h,k.list[i]])}var l=i=f.length;if(l===0)return c&&c.call(d);while(i--){f[i][1].on(f[i][0],function(){l-=1;if(l===0&&c)c.call(d)});f[i][1].load()}};g._e=1;g._f={};g._g={};g._h=[];g._4=function(a){a.id=this._e;this._e+=1};g.getByPath=function(a){var b=a.toString();return this._f[b]=this._f[b]||new this(a)};g.getByName=function(a){if(typeof a!=='string')return a;var b=this.getFromCache(a);if(b.pkg)return b.pkg;var c=this._i(a);if(c)return c;var d=new this();d.addName(a);return d};g.autoload=function(a,b){this._h.push([a,b])};g._i=function(d){var f=this._h,h=f.length,k,i,l;for(k=0;k<h;k++){i=f[k];if(!i[0].test(d))continue;l=i[1].from+'/'+d.replace(/([a-z])([A-Z])/g,function(a,b,c){return b+'_'+c}).replace(/\./g,'/').toLowerCase()+'.js';pkg=new this(l);pkg.addName(d);if(l=i[1].require)pkg.addDependency(d.replace(i[0],l));return pkg}return null};g.getFromCache=function(a){return this._g[a]=this._g[a]||{}};g.getObject=function(a){var b=this.getFromCache(a);if(b.obj!==undefined)return b.obj;var c=this._7,d=a.split('.'),f;while(f=d.shift())c=c&&c[f];return this.getFromCache(a).obj=c}})(JS.Package);JS.Package.DomLoader={usable:function(){return!!JS.Package.getObject('window.document.getElementsByTagName')},__FILE__:function(){var a=document.getElementsByTagName('script');return a[a.length-1].src},loadFile:function(c,d){var f=this,h=document.createElement('script');h.type='text/javascript';h.src=c;h.onload=h.onreadystatechange=function(){var a=h.readyState,b=h.status;if(!a||a==='loaded'||a==='complete'||(a===4&&b===200)){d();h.onload=h.onreadystatechange=f._j;h=null}};if(window.console&&console.info)console.info('Loading '+c);document.getElementsByTagName('head')[0].appendChild(h)},_j:function(){}};JS.Package.CommonJSLoader={usable:function(){return typeof require==='function'&&typeof exports==='object'},setup:function(){var b=this;require=(function(a){return function(){b._1=arguments[0]+'.js';return a.apply(JS.Package._7,arguments)}})(require)},__FILE__:function(){return this._1},loadFile:function(a,b){var c=(typeof process==='object'),d=c?process.cwd():require('file').cwd(),f=a.replace(/\.[^\.]+$/g,''),h=c?require('path'):require('file');require(h.join(d,f));b()}};JS.Package.ServerLoader={usable:function(){return typeof JS.Package.getObject('load')==='function'&&typeof JS.Package.getObject('version')==='function'},setup:function(){var b=this;load=(function(a){return function(){b._1=arguments[0];return a.apply(JS.Package._7,arguments)}})(load)},__FILE__:function(){return this._1},loadFile:function(a,b){load(a);b()}};JS.Package.WshLoader={usable:function(){return!!JS.Package.getObject('ActiveXObject')&&!!JS.Package.getObject('WScript')},__FILE__:function(){return this._1},loadFile:function(a,b){this._1=a;var c=new ActiveXObject('Scripting.FileSystemObject'),d,f;try{d=c.OpenTextFile(a);f=function(){eval(d.ReadAll())};f();b()}finally{try{if(d)d.Close()}catch(e){}}}};(function(){var a=[JS.Package.DomLoader,JS.Package.CommonJSLoader,JS.Package.ServerLoader,JS.Package.WshLoader],b=a.length,c,d;for(c=0;c<b;c++){d=a[c];if(d.usable()){JS.Package.Loader=d;if(d.setup)d.setup();break}}})();JS.Package.DSL={__FILE__:function(){return JS.Package.Loader.__FILE__()},pkg:function(a,b){var c=b?JS.Package.getByPath(b):JS.Package.getByName(a);c.addName(a);return new JS.Package.Description(c)},file:function(a){var b=JS.Package.getByPath(a);return new JS.Package.Description(b)},load:function(a,b){JS.Package.Loader.loadFile(a,b)},autoload:function(a,b){JS.Package.autoload(a,b)}};JS.Package.Description=function(a){this._9=a};(function(f){f._a=function(a,b){var c=b.length,a=this._9[a],d;for(d=0;d<c;d++)a.call(this._9,b[d]);return this};f.provides=function(){return this._a('addName',arguments)};f.requires=function(){return this._a('addDependency',arguments)};f.uses=function(){return this._a('addSoftDependency',arguments)};f.setup=function(a){this._9.onload(a);return this}})(JS.Package.Description.prototype);JS.Package.DSL.loader=JS.Package.DSL.file;JS.Packages=function(a){a.call(JS.Package.DSL)};JS.require=function(){var a=[],b=0;while(typeof arguments[b]==='string'){a.push(arguments[b]);b+=1}JS.Package.when({complete:a},arguments[b],arguments[b+1])};
3
+ JS.Comparable=new JS.Module('Comparable',{extend:{ClassMethods:new JS.Module({compare:function(a,b){return a.compareTo(b)}}),included:function(a){a.extend(this.ClassMethods)}},lt:function(a){return this.compareTo(a)<0},lte:function(a){return this.compareTo(a)<1},gt:function(a){return this.compareTo(a)>0},gte:function(a){return this.compareTo(a)>-1},eq:function(a){return this.compareTo(a)===0},between:function(a,b){return this.gte(a)&&this.lte(b)}});
4
+ JS.Enumerable=new JS.Module('Enumerable',{extend:{forEach:function(a,b){if(!a)return new JS.Enumerator(this,'forEach');for(var c=0,d=this.length;c<d;c++){if(this[c]!==undefined)a.call(b||null,this[c])}return this},isComparable:function(b){return b.all(function(a){return JS.isFn(a.compareTo)})},areEqual:function(a,b){return a.equals?a.equals(b):(a===b)},Collection:new JS.Class({initialize:function(b){this.length=0;var c=Array.prototype.push;JS.Enumerable.forEach.call(b,function(a){c.call(this,a)},this)}})},all:function(b,c){b=JS.Enumerable.toFn(b);var d=true;this.forEach(function(a){d=d&&(b?b.apply(c||null,arguments):a)});return!!d},any:function(b,c){b=JS.Enumerable.toFn(b);var d=false;this.forEach(function(a){d=d||(b?b.apply(c||null,arguments):a)});return!!d},count:function(a,b){if(JS.isFn(this.size))return this.size();var c=0,d=a;if(a&&!JS.isFn(a))a=function(x){return JS.Enumerable.areEqual(x,d)};this.forEach(function(){if(!a||a.apply(b||null,arguments))c+=1});return c},cycle:function(a,b,c){if(!b)return this.enumFor('cycle',a);b=JS.Enumerable.toFn(b);while(a--)this.forEach(b,c)},drop:function(c){var d=[];this.forEachWithIndex(function(a,b){if(b>=c)d.push(a)});return d},dropWhile:function(b,c){if(!b)return this.enumFor('dropWhile');b=JS.Enumerable.toFn(b);var d=[],e=true;this.forEach(function(a){if(e)e=e&&b.apply(c||null,arguments);if(!e)d.push(a)});return d},forEachCons:function(a,b,c){if(!b)return this.enumFor('forEachCons',a);b=JS.Enumerable.toFn(b);var d=this.toArray(),e=d.length,f=e-a,g;for(g=0;g<=f;g++)b.call(c||null,d.slice(g,g+a));return this},forEachSlice:function(a,b,c){if(!b)return this.enumFor('forEachSlice',a);b=JS.Enumerable.toFn(b);var d=this.toArray(),e=d.length,f=Math.ceil(e/a),g;for(g=0;g<f;g++)b.call(c||null,d.slice(g*a,(g+1)*a));return this},forEachWithIndex:function(c,d,e){if(JS.isFn(c)){e=d;d=c;c=0}c=c||0;if(!d)return this.enumFor('forEachWithIndex',c);d=JS.Enumerable.toFn(d);return this.forEach(function(a){var b=d.call(e||null,a,c);c+=1;return b})},forEachWithObject:function(b,c,d){if(!c)return this.enumFor('forEachWithObject',b);c=JS.Enumerable.toFn(c);this.forEach(function(){var a=[b].concat(JS.array(arguments));c.apply(d||null,a)});return b},find:function(b,c){if(!b)return this.enumFor('find');b=JS.Enumerable.toFn(b);var d={},e=d;this.forEach(function(a){if(d!==e)return;d=b.apply(c||null,arguments)?a:d});return d===e?null:d},findIndex:function(c,d){if(c===undefined)return this.enumFor('findIndex');var e=null,f=JS.isFn(c);this.forEachWithIndex(function(a,b){if(e!==null)return;if(JS.Enumerable.areEqual(c,a)||(f&&c.apply(d||null,arguments)))e=b});return e},first:function(a){var b=this.toArray();return(a===undefined)?b[0]:b.slice(0,a)},grep:function(c,d,e){d=JS.Enumerable.toFn(d);var f=[];this.forEach(function(a){var b=JS.isFn(c.match)?c.match(a):c(a);if(!b)return;if(d)a=d.apply(e||null,arguments);f.push(a)});return f},groupBy:function(c,d){if(!c)return this.enumFor('groupBy');c=JS.Enumerable.toFn(c);var e=new JS.Hash();this.forEach(function(a){var b=c.apply(d||null,arguments);if(!e.hasKey(b))e.store(b,[]);e.get(b).push(a)});return e},inject:function(c,d,e){var f=JS.array(arguments),g=0,h={};switch(f.length){case 1:c=h;d=f[0];break;case 2:if(JS.isFn(c)){c=h;d=f[0];e=f[1]}}d=JS.Enumerable.toFn(d);this.forEach(function(a){if(!g++&&c===h)return c=a;var b=[c].concat(JS.array(arguments));c=d.apply(e||null,b)});return c},map:function(a,b){if(!a)return this.enumFor('map');a=JS.Enumerable.toFn(a);var c=[];this.forEach(function(){c.push(a.apply(b||null,arguments))});return c},max:function(a,b){return this.minmax(a,b)[1]},maxBy:function(a,b){if(!a)return this.enumFor('maxBy');return this.minmaxBy(a,b)[1]},member:function(b){return this.any(function(a){return JS.Enumerable.areEqual(a,b)})},min:function(a,b){return this.minmax(a,b)[0]},minBy:function(a,b){if(!a)return this.enumFor('minBy');return this.minmaxBy(a,b)[0]},minmax:function(a,b){var c=this.sort(a,b);return[c[0],c[c.length-1]]},minmaxBy:function(a,b){if(!a)return this.enumFor('minmaxBy');var c=this.sortBy(a,b);return[c[0],c[c.length-1]]},none:function(a,b){return!this.any(a,b)},one:function(b,c){b=JS.Enumerable.toFn(b);var d=0;this.forEach(function(a){if(b?b.apply(c||null,arguments):a)d+=1});return d===1},partition:function(b,c){if(!b)return this.enumFor('partition');b=JS.Enumerable.toFn(b);var d=[],e=[];this.forEach(function(a){(b.apply(c||null,arguments)?d:e).push(a)});return[d,e]},reject:function(b,c){if(!b)return this.enumFor('reject');b=JS.Enumerable.toFn(b);var d=[];this.forEach(function(a){if(!b.apply(c||null,arguments))d.push(a)});return d},reverseForEach:function(a,b){if(!a)return this.enumFor('reverseForEach');a=JS.Enumerable.toFn(a);var c=this.toArray(),d=c.length;while(d--)a.call(b||null,c[d]);return this},select:function(b,c){if(!b)return this.enumFor('select');b=JS.Enumerable.toFn(b);var d=[];this.forEach(function(a){if(b.apply(c||null,arguments))d.push(a)});return d},sort:function(c,d){var e=JS.Enumerable.isComparable(this),f=this.toArray();c=c||(e?function(a,b){return a.compareTo(b)}:null);return c?f.sort(function(a,b){return c.call(d||null,a,b)}):f.sort()},sortBy:function(c,d){if(!c)return this.enumFor('sortBy');c=JS.Enumerable.toFn(c);var e=JS.Enumerable,f=new e.Collection(this.map(c,d)),g=e.isComparable(f);return new e.Collection(f.zip(this).sort(function(a,b){a=a[0];b=b[0];return g?a.compareTo(b):(a<b?-1:(a>b?1:0))})).map(function(a){return a[1]})},take:function(c){var d=[];this.forEachWithIndex(function(a,b){if(b<c)d.push(a)});return d},takeWhile:function(b,c){if(!b)return this.enumFor('takeWhile');b=JS.Enumerable.toFn(b);var d=[],e=true;this.forEach(function(a){if(e)e=e&&b.apply(c||null,arguments);if(e)d.push(a)});return d},toArray:function(){return this.drop(0)},zip:function(){var d=JS.Enumerable,e=[],f=0,g=arguments.length,h,i;if(JS.isFn(arguments[g-1])){h=arguments[g-1];i={}}if(JS.isFn(arguments[g-2])){h=arguments[g-2];i=arguments[g-1]}d.forEach.call(arguments,function(a){if(a===h||a===i)return;if(a.toArray)a=a.toArray();if(JS.isType(a,Array))e.push(a)});var j=this.map(function(b){var c=[b];d.forEach.call(e,function(a){c.push(a[f]===undefined?null:a[f])});return++f&&c});if(!h)return j;d.forEach.call(j,h,i)}});JS.Enumerable.include({forEach:JS.Enumerable.forEach,collect:JS.Enumerable.instanceMethod('map'),detect:JS.Enumerable.instanceMethod('find'),entries:JS.Enumerable.instanceMethod('toArray'),every:JS.Enumerable.instanceMethod('all'),findAll:JS.Enumerable.instanceMethod('select'),filter:JS.Enumerable.instanceMethod('select'),some:JS.Enumerable.instanceMethod('any'),extend:{toFn:function(a){if(!a)return a;if(a.toFunction)return a.toFunction();if(this.OPS[a])return this.OPS[a];if(JS.isType(a,'string')||JS.isType(a,String))return function(){var b=JS.array(arguments),c=b.shift(),d=c[a];return JS.isFn(d)?d.apply(c,b):d};return a},OPS:{'+':function(a,b){return a+b},'-':function(a,b){return a-b},'*':function(a,b){return a*b},'/':function(a,b){return a/b},'%':function(a,b){return a%b},'^':function(a,b){return a^b},'&':function(a,b){return a&b},'&&':function(a,b){return a&&b},'|':function(a,b){return a|b},'||':function(a,b){return a||b},'==':function(a,b){return a==b},'!=':function(a,b){return a!=b},'>':function(a,b){return a>b},'>=':function(a,b){return a>=b},'<':function(a,b){return a<b},'<=':function(a,b){return a<=b},'===':function(a,b){return a===b},'!==':function(a,b){return a!==b},'[]':function(a,b){return a[b]},'()':function(a,b){return a(b)}},Enumerator:new JS.Class({include:JS.Enumerable,extend:{DEFAULT_METHOD:'forEach'},initialize:function(a,b,c){this._0=a;this._1=b||this.klass.DEFAULT_METHOD;this._2=(c||[]).slice()},forEach:function(a,b){if(!a)return this;var c=this._2.slice();c.push(a);if(b)c.push(b);return this._0[this._1].apply(this._0,c)},cons:JS.Enumerable.instanceMethod('forEachCons'),reverse:JS.Enumerable.instanceMethod('reverseForEach'),slice:JS.Enumerable.instanceMethod('forEachSlice'),withIndex:JS.Enumerable.instanceMethod('forEachWithIndex'),withObject:JS.Enumerable.instanceMethod('forEachWithObject')})}},false);JS.Enumerable.Collection.include(JS.Enumerable,true);JS.Kernel.include({enumFor:function(a){var b=JS.array(arguments),a=b.shift();return new JS.Enumerable.Enumerator(this,a,b)}},false);JS.Kernel.define('toEnum',JS.Kernel.instanceMethod('enumFor'),true);
5
+ JS.LinkedList=new JS.Class('LinkedList',{include:JS.Enumerable||{},initialize:function(a,b){this.length=0;this.first=this.last=null;if(!a)return;for(var c=0,d=a.length;c<d;c++)this.push(b?new this.klass.Node(a[c]):a[c])},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);var c=this.first,d,e,f;for(e=0,f=this.length;e<f;e++){d=c.next;a.call(b||null,c,e);if(c===this.last)break;c=d}return this},at:function(a){if(a<0||a>=this.length)return undefined;var b=this.first;while(a--)b=b.next;return b},pop:function(){return this.length?this.remove(this.last):undefined},shift:function(){return this.length?this.remove(this.first):undefined},insertAfter:function(){},push:function(){},remove:function(){},extend:{Node:new JS.Class({initialize:function(a){this.data=a;this.prev=this.next=this.list=null}})}});JS.LinkedList.Doubly=new JS.Class('LinkedList.Doubly',JS.LinkedList,{insertAt:function(a,b){if(a<0||a>=this.length)return;this.insertBefore(this.at(a),b)},unshift:function(a){this.length>0?this.insertBefore(this.first,a):this.push(a)},insertBefore:function(){}});JS.LinkedList.insertTemplate=function(c,d,e){return function(a,b){if(a.list!==this)return;b[c]=a;b[d]=a[d];a[d]=(a[d][c]=b);if(b[c]===this[e])this[e]=b;b.list=this;this.length++}};JS.LinkedList.Doubly.Circular=new JS.Class('LinkedList.Doubly.Circular',JS.LinkedList.Doubly,{insertAfter:JS.LinkedList.insertTemplate('prev','next','last'),insertBefore:JS.LinkedList.insertTemplate('next','prev','first'),push:function(a){if(this.length)return this.insertAfter(this.last,a);this.first=this.last=a.prev=a.next=a;a.list=this;this.length=1},remove:function(a){if(a.list!==this||this.length===0)return null;if(this.length>1){a.prev.next=a.next;a.next.prev=a.prev;if(a===this.first)this.first=a.next;if(a===this.last)this.last=a.prev}else{this.first=this.last=null}a.prev=a.next=a.list=null;this.length--;return a}});
6
+ JS.Hash=new JS.Class('Hash',{include:JS.Enumerable||{},extend:{Pair:new JS.Class({include:JS.Comparable||{},setKey:function(a){this[0]=this.key=a},hasKey:function(a){var b=this.key;return b.equals?b.equals(a):b===a},setValue:function(a){this[1]=this.value=a},hasValue:function(a){var b=this.value;return b.equals?b.equals(a):b===a},compareTo:function(a){return this.key.compareTo?this.key.compareTo(a.key):(this.key<a.key?-1:(this.key>a.key?1:0))},hash:function(){var a=JS.Hash.codeFor(this.key),b=JS.Hash.codeFor(this.value);return[a,b].sort().join('')}}),codeFor:function(a){if(typeof a!=='object')return String(a);return JS.isFn(a.hash)?a.hash():a.toString()}},initialize:function(a){this.clear();if(!JS.isType(a,Array))return this.setDefault(a);for(var b=0,c=a.length;b<c;b+=2)this.store(a[b],a[b+1])},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);var c,d,e;for(c in this._0){if(!this._0.hasOwnProperty(c))continue;d=this._0[c];e=d.length;while(e--)a.call(b||null,d[e])}return this},_3:function(a,b){var c=this.klass.codeFor(a),d=this._0[c];if(!d&&b)d=this._0[c]=[];return d},_4:function(a,b){var c=a.length,d=!!this._1;while(c--){if(d?(a[c].key===b):a[c].hasKey(b))return c}return-1},assoc:function(a,b){var c,d,e;c=this._3(a,b);if(!c)return null;d=this._4(c,a);if(d>-1)return c[d];if(!b)return null;this.size+=1;this.length+=1;e=new this.klass.Pair;e.setKey(a);c.push(e);return e},rassoc:function(a){var b=this.key(a);return b?this.assoc(b):null},clear:function(){this._0={};this.length=this.size=0},compareByIdentity:function(){this._1=true},comparesByIdentity:function(){return!!this._1},setDefault:function(a){this._2=a;return this},getDefault:function(a){return JS.isFn(this._2)?this._2(this,a):(this._2||null)},equals:function(c){if(!JS.isType(c,JS.Hash)||this.length!==c.length)return false;var d=true;this.forEach(function(a){if(!d)return;var b=c.assoc(a.key);if(b===null||!b.hasValue(a.value))d=false});return d},hash:function(){var b=[];this.forEach(function(a){b.push(a.hash())});return b.sort().join('')},fetch:function(a,b){var c=this.assoc(a);if(c)return c.value;if(b===undefined)throw new Error('key not found');if(JS.isFn(b))return b(a);return b},forEachKey:function(b,c){if(!b)return this.enumFor('forEachKey');b=JS.Enumerable.toFn(b);this.forEach(function(a){b.call(c||null,a.key)});return this},forEachPair:function(b,c){if(!b)return this.enumFor('forEachPair');b=JS.Enumerable.toFn(b);this.forEach(function(a){b.call(c||null,a.key,a.value)});return this},forEachValue:function(b,c){if(!b)return this.enumFor('forEachValue');b=JS.Enumerable.toFn(b);this.forEach(function(a){b.call(c||null,a.value)});return this},get:function(a){var b=this.assoc(a);return b?b.value:this.getDefault(a)},hasKey:function(a){return!!this.assoc(a)},hasValue:function(b){var c=false,d=!!this._1;this.forEach(function(a){if((b.equals&&!d)?b.equals(a.value):b===a.value)c=true});return c},invert:function(){var b=new this.klass;this.forEach(function(a){b.store(a.value,a.key)});return b},isEmpty:function(){for(var a in this._0){if(this._0.hasOwnProperty(a)&&this._0[a].length>0)return false}return true},key:function(b){var c=null;this.forEach(function(a){if(b.equals?b.equals(a.value):(b===a.value))c=a.key});return c},keys:function(){var b=[];this.forEach(function(a){b.push(a.key)});return b},merge:function(a,b,c){var d=new this.klass;d.update(this);d.update(a,b,c);return d},rehash:function(){var a=new this.klass;a._0=this._0;this.clear();this.update(a)},remove:function(a,b){if(b===undefined)b=null;var c,d,e;c=this._3(a);if(!c)return JS.isFn(b)?this.fetch(a,b):this.getDefault(a);d=this._4(c,a);if(d<0)return JS.isFn(b)?this.fetch(a,b):this.getDefault(a);e=c[d].value;c.splice(d,1);this.size-=1;this.length-=1;if(c.length===0)delete this._0[this.klass.codeFor(a)];return e},removeIf:function(b,c){if(!b)return this.enumFor('removeIf');b=JS.Enumerable.toFn(b);this.forEach(function(a){if(b.call(c||null,a))this.remove(a.key)},this);return this},replace:function(a){this.clear();this.update(a)},shift:function(){var a=this.keys();if(a.length===0)return this.getDefault();var b=this.assoc(a[0]);this.remove(b.key);return b},store:function(a,b){this.assoc(a,true).setValue(b);return b},update:function(d,e,f){var g=JS.isFn(e);d.forEach(function(a){var b=a.key,c=a.value;if(g&&this.hasKey(b))c=e.call(f||null,b,this.get(b),c);this.store(b,c)},this)},values:function(){var b=[];this.forEach(function(a){b.push(a.value)});return b},valuesAt:function(){var a=arguments.length,b=[];while(a--)b.push(this.get(arguments[a]));return b}});JS.Hash.include({includes:JS.Hash.instanceMethod('hasKey'),index:JS.Hash.instanceMethod('key'),put:JS.Hash.instanceMethod('store')},true);
7
+ JS.Set=new JS.Class('Set',{extend:{forEach:function(a,b,c){if(!a||!b)return;if(a.forEach)return a.forEach(b,c);for(var d=0,e=a.length;d<e;d++){if(a[d]!==undefined)b.call(c||null,a[d],d)}}},include:JS.Enumerable||{},initialize:function(a,b,c){this.clear();if(b)this.klass.forEach(a,function(item){this.add(b.call(c||null,item))},this);else this.merge(a)},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);this.klass.forEach(this._0,a,b);return this},add:function(a){if(this.contains(a))return false;this._0.push(a);this.length=this.size=this._0.length;return true},classify:function(c,d){if(!c)return this.enumFor('classify');c=JS.Enumerable.toFn(c);var e=new JS.Hash();this.forEach(function(a){var b=c.call(d||null,a);if(!e.hasKey(b))e.store(b,new this.klass);e.get(b).add(a)},this);return e},clear:function(){this._0=[];this.length=this.size=0},complement:function(b){var c=new this.klass;this.klass.forEach(b,function(a){if(!this.contains(a))c.add(a)},this);return c},contains:function(a){return this._1(a)!==-1},difference:function(b){b=JS.isType(b,JS.Set)?b:new JS.Set(b);var c=new this.klass;this.forEach(function(a){if(!b.contains(a))c.add(a)});return c},divide:function(a,b){if(!a)return this.enumFor('divide');a=JS.Enumerable.toFn(a);var c=this.classify(a,b),d=new this.klass;c.forEachValue(d.method('add'));return d},equals:function(b){if(this.length!==b.length||!JS.isType(b,JS.Set))return false;var c=true;this.forEach(function(a){if(!c)return;if(!b.contains(a))c=false});return c},hash:function(){var b=[];this.forEach(function(a){b.push(JS.Hash.codeFor(a))});return b.sort().join('')},flatten:function(b){var c=new this.klass;c._0=this._0;if(!b){b=this;b.clear()}c.forEach(function(a){if(JS.isType(a,JS.Set))a.flatten(b);else b.add(a)});return b},intersection:function(b){var c=new this.klass;this.klass.forEach(b,function(a){if(this.contains(a))c.add(a)},this);return c},isEmpty:function(){return this._0.length===0},isProperSubset:function(a){return this._0.length<a._0.length&&this.isSubset(a)},isProperSuperset:function(a){return this._0.length>a._0.length&&this.isSuperset(a)},isSubset:function(b){var c=true;this.forEach(function(a){if(!c)return;if(!b.contains(a))c=false});return c},isSuperset:function(a){return a.isSubset(this)},merge:function(b){this.klass.forEach(b,function(a){this.add(a)},this)},product:function(c){var d=new JS.Set;this.forEach(function(b){this.klass.forEach(c,function(a){d.add([b,a])})},this);return d},rebuild:function(){var a=this._0;this.clear();this.merge(a)},remove:function(a){var b=this._1(a);if(b===-1)return;this._0.splice(b,1);this.length=this.size=this._0.length},removeIf:function(a,b){if(!a)return this.enumFor('removeIf');a=JS.Enumerable.toFn(a);var c=this._0,d=c.length;while(d--){if(a.call(b||null,c[d]))this.remove(c[d])}return this},replace:function(a){this.clear();this.merge(a)},subtract:function(b){this.klass.forEach(b,function(a){this.remove(a)},this)},union:function(a){var b=new this.klass;b.merge(this);b.merge(a);return b},xor:function(b){var c=new JS.Set(b);this.forEach(function(a){c[c.contains(a)?'remove':'add'](a)});return c},_1:function(a){var b=this._0.length,c=JS.Enumerable.areEqual;while(b--){if(c(a,this._0[b]))return b}return-1}});JS.Set.include({n:JS.Set.instanceMethod('intersection'),u:JS.Set.instanceMethod('union'),x:JS.Set.instanceMethod('product')},false);JS.SortedSet=new JS.Class('SortedSet',JS.Set,{extend:{compare:function(a,b){return JS.isType(a,Object)?a.compareTo(b):(a<b?-1:(a>b?1:0))}},add:function(a){var b=this._1(a,true);if(b===null)return;this._0.splice(b,0,a);this.length=this.size=this._0.length},_1:function(a,b){var c=this._0,d=c.length,e=0,f=d,g=this.klass.compare,h=JS.Enumerable.areEqual,i;if(d===0)return b?0:-1;if(g(a,c[0])<1){f=0;e=0}if(g(a,c[d-1])>0){f=0;e=d}while(!h(a,c[e])&&f>0.5){f=f/2;e+=(g(a,c[e])>0?1:-1)*Math.round(f);if(e>0&&g(a,c[e-1])>0&&g(a,c[e])<1)f=0}while(c[e]&&!h(a,c[e])&&g(a,c[e])===0)e+=1;i=h(a,c[e]);return b?(i?null:e):(i?e:-1)}});JS.HashSet=new JS.Class('HashSet',JS.Set,{forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);this._0.forEachKey(a,b);return this},add:function(a){if(this.contains(a))return false;this._0.store(a,true);this.length=this.size=this._0.length;return true},clear:function(){this._0=new JS.Hash();this.size=this.length=0},contains:function(a){return this._0.hasKey(a)},rebuild:function(){this._0.rehash();this.length=this.size=this._0.length},remove:function(a){this._0.remove(a);this.length=this.size=this._0.length},removeIf:function(b,c){if(!b)return this.enumFor('removeIf');b=JS.Enumerable.toFn(b);this._0.removeIf(function(a){return b.call(c||null,a.key)});this.length=this.size=this._0.length;return this}});JS.Enumerable.include({toSet:function(a,b,c){a=a||JS.Set;return new a(this,b,c)}},true);
8
+ JS.Observable=new JS.Module('Observable',{extend:{DEFAULT_METHOD:'update'},addObserver:function(c,b){(this.__observers__=this.__observers__||[]).push({_0:c,_1:b||null})},removeObserver:function(c,b){this.__observers__=this.__observers__||[];b=b||null;var a=this.countObservers();while(a--){if(this.__observers__[a]._0===c&&this.__observers__[a]._1===b){this.__observers__.splice(a,1);return}}},removeObservers:function(){this.__observers__=[]},countObservers:function(){return(this.__observers__=this.__observers__||[]).length},notifyObservers:function(){if(!this.isChanged())return;var c=this.countObservers(),b,a,d;while(c--){b=this.__observers__[c];a=b._0;d=b._1;if(JS.isFn(a))a.apply(d||null,arguments);else a[d||JS.Observable.DEFAULT_METHOD].apply(a,arguments)}},setChanged:function(c){this.__changed__=!(c===false)},isChanged:function(){if(this.__changed__===undefined)this.__changed__=true;return!!this.__changed__}});JS.Observable.include({subscribe:JS.Observable.instanceMethod('addObserver'),unsubscribe:JS.Observable.instanceMethod('removeObserver')},true);
9
+ JS.Forwardable=new JS.Module('Forwardable',{defineDelegator:function(b,e,d,f){d=d||e;this.define(d,function(){var a=this[b],c=a[e];return JS.isFn(c)?c.apply(a,arguments):c},f!==false)},defineDelegators:function(){var a=JS.array(arguments),c=a.shift(),b=a.length;while(b--)this.defineDelegator(c,a[b],a[b],false);this.resolve()}});
10
+ JS.ConstantScope=new JS.Module('ConstantScope',{extend:{included:function(a){a.__consts__=new JS.Module();a.extend(this.ClassMethods);a.include(a.__consts__);a.extend(a.__consts__);a.include(a.__mod__.__fns__);a.extend(a.__eigen__().__fns__)},ClassMethods:new JS.Module({extend:function(){var a=JS.ConstantScope.extract(arguments[0],this);this.__consts__.include(a);this.callSuper()},include:function(){var a=JS.ConstantScope.extract(arguments[0],this);this.__consts__.include(a);this.callSuper()}}),extract:function(a,e){if(!a)return null;if(JS.isType(a,JS.Module))return null;var d={},b,c;for(b in a){if(!/^[A-Z]/.test(b))continue;c=a[b];d[b]=c;delete a[b];if(JS.isType(c,JS.Module)){c.include(this);c.__consts__.include(e.__consts__)}}return d}}});
11
+ JS.Decorator=new JS.Class('Decorator',{initialize:function(a,c){var b=new JS.Class(),f={},e,d;for(e in a.prototype){d=a.prototype[e];if(JS.isFn(d)&&d!==a)d=this.klass.delegate(e);f[e]=d}b.include(new JS.Module(f),false);b.include(this.klass.InstanceMethods,false);b.include(c,true);return b},extend:{delegate:function(a){return function(){return this.component[a].apply(this.component,arguments)}},InstanceMethods:new JS.Module({initialize:function(a){this.component=a;this.klass=this.constructor=a.klass;var c,b;for(c in a){if(this[c])continue;b=a[c];if(JS.isFn(b))b=JS.Decorator.delegate(c);this[c]=b}},extend:function(a){this.component.extend(a);var c,b;for(c in a){b=a[c];if(JS.isFn(b))b=JS.Decorator.delegate(c);this[c]=b}}})}});
12
+ if(JS.Proxy===undefined)JS.Proxy={};JS.Proxy.Virtual=new JS.Class('Proxy.Virtual',{initialize:function(a){var g=function(){},e=new JS.Class(),h={},f,d;g.prototype=a.prototype;for(f in a.prototype){d=a.prototype[f];if(JS.isFn(d)&&d!==a)d=this.klass.forward(f);h[f]=d}e.include({initialize:function(){var c=arguments,b=null;this.__getSubject__=function(){b=new g;a.apply(b,c);return(this.__getSubject__=function(){return b})()}},klass:a,constructor:a},false);e.include(new JS.Module(h),false);e.include(this.klass.InstanceMethods,true);return e},extend:{forward:function(b){return function(){var c=this.__getSubject__();return c[b].apply(c,arguments)}},InstanceMethods:new JS.Module({extend:function(c){this.__getSubject__().extend(c);var b,a;for(b in c){a=c[b];if(JS.isFn(a))a=JS.Proxy.Virtual.forward(b);this[b]=a}}})}});
13
+ JS.Command=new JS.Class('Command',{initialize:function(a){if(JS.isFn(a))a={execute:a};this._2=a;this._0=this._2.stack||null},execute:function(a){if(this._0)this._0._3();var b=this._2.execute;if(b)b.apply(this);if(this._0&&a!==false)this._0.push(this)},undo:function(){var exec=this._2.undo;if(exec)exec.apply(this)},extend:{Stack:new JS.Class({include:[JS.Observable||{},JS.Enumerable||{}],initialize:function(a){a=a||{};this._1=a.redo||null;this.clear()},forEach:function(a,b){if(!a)return this.enumFor('forEach');a=JS.Enumerable.toFn(a);for(var c=0,d=this._0.length;c<d;c++){if(this._0[c]!==undefined)a.call(b||null,this._0[c],c)}return this},clear:function(){this._0=[];this.length=this.pointer=0},_3:function(){if(this.pointer===0&&this._1&&this._1.execute)this._1.execute()},push:function(a){this._0.splice(this.pointer,this.length);this._0.push(a);this.length=this.pointer=this._0.length;if(this.notifyObservers)this.notifyObservers(this)},stepTo:function(a){if(a<0||a>this.length)return;var b,c;switch(true){case a>this.pointer:for(b=this.pointer,c=a;b<c;b++)this._0[b].execute(false);break;case a<this.pointer:if(this._1&&this._1.execute){this._1.execute();for(b=0,c=a;b<c;b++)this._0[b].execute(false)}else{for(b=0,c=this.pointer-a;b<c;b++)this._0[this.pointer-b-1].undo()}break}this.pointer=a;if(this.notifyObservers)this.notifyObservers(this)},undo:function(){this.stepTo(this.pointer-1)},redo:function(){this.stepTo(this.pointer+1)}})}});
14
+ JS.State=new JS.Module('State',{__getState__:function(a){return(typeof a==='object'&&a)||(typeof a==='string'&&((this.states||{})[a]||{}))||{}},setState:function(a){this.__state__=this.__getState__(a);JS.State.addMethods(this.__state__,this.klass)},inState:function(){var a=arguments.length;while(a--){if(this.__state__===this.__getState__(arguments[a]))return true}return false},extend:{stub:function(){return this},buildStubs:function(a,b,c){var d,e;for(d in c){b[d]={};for(e in c[d])a[e]=this.stub}},findStates:function(a,b){var c=a.length,d=[];while(c--){if(a[c].hasOwnProperty(b))d.push(a[c][b])}return d},buildCollection:function(a,b){var c={},d={},e=a.lookup('states'),h,g,j,i,k,f,l;this.buildStubs(c,d,b);for(f=0,l=e.length;f<l;f++)this.buildStubs(c,d,e[f]);for(h in d){g=new JS.Class(b[h]);k=this.findStates(e,h);f=k.length;while(f--)g.include(k[f].klass);j={};for(i in c){if(!g.prototype[i])j[i]=c[i]}g.include(j);d[h]=new g}if(a.__res__)this.addMethods(c,a.__res__.klass);return d},addMethods:function(a,b){if(!b)return;var c={},d=b.prototype,e;for(e in a){if(d[e])continue;d[e]=b.__mod__.__fns__[e]=this.wrapped(e)}},wrapped:function(b){return function(){var a=(this.__state__||{})[b];return a?a.apply(this,arguments):this}}}});JS.Module.include({define:(function(c){return function(a,b){if(a==='states'&&typeof b==='object')arguments[1]=JS.State.buildCollection(this,b);return c.apply(this,arguments)}})(JS.Module.prototype.define)},true);
15
+ JS.StackTrace=new JS.Module('StackTrace',{extend:{included:function(h){var f=h.__mod__||h,b=this,d;f.extend({define:function(a,c){if(!JS.isFn(c))return this.callSuper();var g=b.wrap(c,f,a);return this.callSuper(a,g)}});for(d in f.__fns__)f.define(d,f.__fns__[d],false);f.resolve();if(!f.__nom__)setTimeout(function(){f.__nom__=b.nameOf(h)},1)},nameOf:function(a,c){var g=[],h,f,b,d;if(JS.isType(a,Array)){for(h=0,f=a.length;h<f;h++)g.push(this.nameOf(a[h]));return g}if(a.__nom__)return a.__nom__;b=[{name:null,o:c||this.root}];d=0;while(typeof b==='object'&&d<this.maxDepth){d+=1;b=this.descend(b,a)}if(typeof b=='string'){b=b.replace(/\.prototype\./g,'#');a.__nom__=b;if(a.__meta__)a.__meta__.__nom__=b+'.__meta__'}return a.__nom__},descend:function(a,c){var g=[],h=a.length,f=h,b,d,i;while(f--){d=a[f];if(h>1&&JS.indexOf(this.excluded,d.o)!==-1)continue;if(JS.isType(d.o,Array))continue;i=d.name?d.name+'.':'';for(b in d.o){if(c&&d.o[b]===c)return i+b;g.push({name:i+b,o:d.o[b]})}}return g},root:this,excluded:[],maxDepth:8,logLevel:'full',stack:new JS.Singleton({_0:[],indent:function(){var a='',c=this._0.length;while(c--)a+='| ';return a},push:function(a,c,g){if(JS.StackTrace.logLevel==='full')window.console&&console.log(this.indent()+a+'(',g,')');this._0.push({name:a,object:c,args:g})},pop:function(a){var c=this._0.pop().name;if(JS.StackTrace.logLevel==='full')window.console&&console.log(this.indent()+c+'() --> ',a);return c},top:function(){return this._0[this._0.length-1]||{}},backtrace:function(){var a=this._0.length,c;while(a--){c=this._0[a];window.console&&console.log(c.name,'in',c.object,'(',c.args,')')}}}),flush:function(){this.stack._0=[]},print:function(){this.stack.backtrace()},wrap:function(g,h,f){var b=JS.StackTrace;var d=function(){var a,c=b.nameOf(h)+'#'+f;b.stack.push(c,this,arguments);if(b.logLevel==='errors'){try{a=g.apply(this,arguments)}catch(e){if(e.logged)throw e;e.logged=true;window.console&&console.error(e,'thrown by',b.stack.top().name+'. Backtrace:');b.print();b.flush();throw e;}}else{a=g.apply(this,arguments)}b.stack.pop(a);return a};d.toString=function(){return g.toString()};return d}}});(function(){var a=JS.StackTrace,c;for(c in a.root){if(c!=='JS')a.excluded.push(a.root[c])}})();
16
+ JS.Ruby=function(d,b){b.call(new JS.Ruby.ClassBuilder(d))};JS.extend(JS.Ruby,{extendDSL:function(d,b){for(var a in b){if(d[a]||!JS.isFn(b[a]))continue;this.addMethod(d,b,a)}},addMethod:function(b,a,c){b[c]=function(){var d=a[c].apply(a,arguments);JS.Ruby.extendDSL(b,a);return d}},alias:function(c,e){return function(d,b){var a=c[b];if(a!==undefined)this.def(d,a);if(e)JS.Ruby.extendDSL(e,c)}},ClassBuilder:function(c){this.def=c.method('define');this.alias=JS.Ruby.alias(c.prototype);this.self={def:JS.bind(function(d,b){var a={};a[d]=b;c.extend(a);JS.Ruby.extendDSL(this,c)},this),alias:JS.Ruby.alias(c,this)};JS.Ruby.extendDSL(this,c)}});
@@ -0,0 +1,93 @@
1
+ JS.Command = new JS.Class('Command', {
2
+ initialize: function(functions) {
3
+ if (JS.isFn(functions))
4
+ functions = {execute: functions};
5
+ this._functions = functions;
6
+ this._stack = this._functions.stack || null;
7
+ },
8
+
9
+ execute: function(push) {
10
+ if (this._stack) this._stack._restart();
11
+ var exec = this._functions.execute;
12
+ if (exec) exec.apply(this);
13
+ if (this._stack && push !== false) this._stack.push(this);
14
+ },
15
+
16
+ undo: function() {
17
+ var exec = this._functions.undo;
18
+ if (exec) exec.apply(this);
19
+ },
20
+
21
+ extend: {
22
+ Stack: new JS.Class({
23
+ include: [JS.Observable || {}, JS.Enumerable || {}],
24
+
25
+ initialize: function(options) {
26
+ options = options || {};
27
+ this._redo = options.redo || null;
28
+ this.clear();
29
+ },
30
+
31
+ forEach: function(block, context) {
32
+ if (!block) return this.enumFor('forEach');
33
+ block = JS.Enumerable.toFn(block);
34
+
35
+ for (var i = 0, n = this._stack.length; i < n; i++) {
36
+ if (this._stack[i] !== undefined)
37
+ block.call(context || null, this._stack[i], i);
38
+ }
39
+ return this;
40
+ },
41
+
42
+ clear: function() {
43
+ this._stack = [];
44
+ this.length = this.pointer = 0;
45
+ },
46
+
47
+ _restart: function() {
48
+ if (this.pointer === 0 && this._redo && this._redo.execute)
49
+ this._redo.execute();
50
+ },
51
+
52
+ push: function(command) {
53
+ this._stack.splice(this.pointer, this.length);
54
+ this._stack.push(command);
55
+ this.length = this.pointer = this._stack.length;
56
+ if (this.notifyObservers) this.notifyObservers(this);
57
+ },
58
+
59
+ stepTo: function(position) {
60
+ if (position < 0 || position > this.length) return;
61
+ var i, n;
62
+
63
+ switch (true) {
64
+ case position > this.pointer :
65
+ for (i = this.pointer, n = position; i < n; i++)
66
+ this._stack[i].execute(false);
67
+ break;
68
+
69
+ case position < this.pointer :
70
+ if (this._redo && this._redo.execute) {
71
+ this._redo.execute();
72
+ for (i = 0, n = position; i < n; i++)
73
+ this._stack[i].execute(false);
74
+ } else {
75
+ for (i = 0, n = this.pointer - position; i < n; i++)
76
+ this._stack[this.pointer - i - 1].undo();
77
+ }
78
+ break;
79
+ }
80
+ this.pointer = position;
81
+ if (this.notifyObservers) this.notifyObservers(this);
82
+ },
83
+
84
+ undo: function() {
85
+ this.stepTo(this.pointer - 1);
86
+ },
87
+
88
+ redo: function() {
89
+ this.stepTo(this.pointer + 1);
90
+ }
91
+ })
92
+ }
93
+ });
@@ -0,0 +1,37 @@
1
+ JS.Comparable = new JS.Module('Comparable', {
2
+ extend: {
3
+ ClassMethods: new JS.Module({
4
+ compare: function(one, another) {
5
+ return one.compareTo(another);
6
+ }
7
+ }),
8
+
9
+ included: function(base) {
10
+ base.extend(this.ClassMethods);
11
+ }
12
+ },
13
+
14
+ lt: function(other) {
15
+ return this.compareTo(other) < 0;
16
+ },
17
+
18
+ lte: function(other) {
19
+ return this.compareTo(other) < 1;
20
+ },
21
+
22
+ gt: function(other) {
23
+ return this.compareTo(other) > 0;
24
+ },
25
+
26
+ gte: function(other) {
27
+ return this.compareTo(other) > -1;
28
+ },
29
+
30
+ eq: function(other) {
31
+ return this.compareTo(other) === 0;
32
+ },
33
+
34
+ between: function(a, b) {
35
+ return this.gte(a) && this.lte(b);
36
+ }
37
+ });
@@ -0,0 +1,48 @@
1
+ JS.ConstantScope = new JS.Module('ConstantScope', {
2
+ extend: {
3
+ included: function(base) {
4
+ base.__consts__ = new JS.Module();
5
+ base.extend(this.ClassMethods);
6
+
7
+ base.include(base.__consts__);
8
+ base.extend(base.__consts__);
9
+
10
+ base.include(base.__mod__.__fns__);
11
+ base.extend(base.__eigen__().__fns__);
12
+ },
13
+
14
+ ClassMethods: new JS.Module({
15
+ extend: function() {
16
+ var constants = JS.ConstantScope.extract(arguments[0], this);
17
+ this.__consts__.include(constants);
18
+ this.callSuper();
19
+ },
20
+
21
+ include: function() {
22
+ var constants = JS.ConstantScope.extract(arguments[0], this);
23
+ this.__consts__.include(constants);
24
+ this.callSuper();
25
+ }
26
+ }),
27
+
28
+ extract: function(inclusions, base) {
29
+ if (!inclusions) return null;
30
+ if (JS.isType(inclusions, JS.Module)) return null;
31
+ var constants = {}, key, object;
32
+ for (key in inclusions) {
33
+
34
+ if (!/^[A-Z]/.test(key)) continue;
35
+
36
+ object = inclusions[key];
37
+ constants[key] = object;
38
+ delete inclusions[key];
39
+
40
+ if (JS.isType(object, JS.Module)) {
41
+ object.include(this);
42
+ object.__consts__.include(base.__consts__);
43
+ }
44
+ }
45
+ return constants;
46
+ }
47
+ }
48
+ });