typo 3.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (742) hide show
  1. data/.DS_Store +0 -0
  2. data/CHANGELOG +718 -0
  3. data/MAINTAINERS +30 -0
  4. data/MIT-LICENSE +21 -0
  5. data/README +92 -0
  6. data/Rakefile +10 -0
  7. data/app/apis/blogger_service.rb +94 -0
  8. data/app/apis/meta_weblog_service.rb +197 -0
  9. data/app/apis/movable_type_service.rb +150 -0
  10. data/app/apis/typo_web_service.rb +26 -0
  11. data/app/controllers/accounts_controller.rb +52 -0
  12. data/app/controllers/admin/base_controller.rb +21 -0
  13. data/app/controllers/admin/blacklist_controller.rb +50 -0
  14. data/app/controllers/admin/cache_controller.rb +31 -0
  15. data/app/controllers/admin/categories_controller.rb +64 -0
  16. data/app/controllers/admin/comments_controller.rb +57 -0
  17. data/app/controllers/admin/content_controller.rb +147 -0
  18. data/app/controllers/admin/general_controller.rb +42 -0
  19. data/app/controllers/admin/pages_controller.rb +50 -0
  20. data/app/controllers/admin/resources_controller.rb +98 -0
  21. data/app/controllers/admin/sidebar_controller.rb +74 -0
  22. data/app/controllers/admin/textfilters_controller.rb +104 -0
  23. data/app/controllers/admin/themes_controller.rb +20 -0
  24. data/app/controllers/admin/trackbacks_controller.rb +54 -0
  25. data/app/controllers/admin/users_controller.rb +41 -0
  26. data/app/controllers/application.rb +66 -0
  27. data/app/controllers/articles_controller.rb +218 -0
  28. data/app/controllers/backend_controller.rb +11 -0
  29. data/app/controllers/content_controller.rb +98 -0
  30. data/app/controllers/live_controller.rb +10 -0
  31. data/app/controllers/redirect_controller.rb +16 -0
  32. data/app/controllers/sidebar_controller.rb +50 -0
  33. data/app/controllers/textfilter_controller.rb +22 -0
  34. data/app/controllers/theme_controller.rb +52 -0
  35. data/app/controllers/xml_controller.rb +111 -0
  36. data/app/helpers/accounts_helper.rb +2 -0
  37. data/app/helpers/admin/base_helper.rb +124 -0
  38. data/app/helpers/admin/blacklist_helper.rb +2 -0
  39. data/app/helpers/admin/cache_helper.rb +2 -0
  40. data/app/helpers/admin/comments_helper.rb +2 -0
  41. data/app/helpers/admin/content_helper.rb +2 -0
  42. data/app/helpers/admin/general_helper.rb +2 -0
  43. data/app/helpers/admin/pages_helper.rb +2 -0
  44. data/app/helpers/admin/resources_helper.rb +2 -0
  45. data/app/helpers/admin/sidebar_helper.rb +2 -0
  46. data/app/helpers/admin/textfilters_helper.rb +2 -0
  47. data/app/helpers/admin/themes_helper.rb +2 -0
  48. data/app/helpers/admin/trackbacks_helper.rb +2 -0
  49. data/app/helpers/admin/users_helper.rb +2 -0
  50. data/app/helpers/application_helper.rb +92 -0
  51. data/app/helpers/articles_helper.rb +163 -0
  52. data/app/helpers/backend_helper.rb +2 -0
  53. data/app/helpers/content_helper.rb +3 -0
  54. data/app/helpers/mail_helper.rb +6 -0
  55. data/app/helpers/redirect_helper.rb +2 -0
  56. data/app/helpers/sidebar_helper.rb +22 -0
  57. data/app/helpers/sidebars/plugin_helper.rb +2 -0
  58. data/app/helpers/text_filter_plugin_helper.rb +2 -0
  59. data/app/helpers/textfilter_helper.rb +2 -0
  60. data/app/helpers/theme_helper.rb +23 -0
  61. data/app/helpers/xml_helper.rb +21 -0
  62. data/app/models/aggregations/audioscrobbler.rb +54 -0
  63. data/app/models/aggregations/backpack.rb +57 -0
  64. data/app/models/aggregations/delicious.rb +57 -0
  65. data/app/models/aggregations/flickr.rb +89 -0
  66. data/app/models/aggregations/fortythree.rb +62 -0
  67. data/app/models/aggregations/magnolia.rb +81 -0
  68. data/app/models/aggregations/tada.rb +75 -0
  69. data/app/models/aggregations/technorati.rb +51 -0
  70. data/app/models/aggregations/upcoming.rb +74 -0
  71. data/app/models/article.rb +211 -0
  72. data/app/models/blacklist_pattern.rb +22 -0
  73. data/app/models/blog.rb +162 -0
  74. data/app/models/blog_sweeper.rb +23 -0
  75. data/app/models/category.rb +62 -0
  76. data/app/models/comment.rb +76 -0
  77. data/app/models/config_manager.rb +80 -0
  78. data/app/models/content.rb +222 -0
  79. data/app/models/content_observer.rb +5 -0
  80. data/app/models/content_state/base.rb +51 -0
  81. data/app/models/content_state/draft.rb +40 -0
  82. data/app/models/content_state/factory.rb +16 -0
  83. data/app/models/content_state/just_published.rb +47 -0
  84. data/app/models/content_state/new.rb +45 -0
  85. data/app/models/content_state/publication_pending.rb +43 -0
  86. data/app/models/content_state/published.rb +35 -0
  87. data/app/models/email_notifier.rb +9 -0
  88. data/app/models/notification_mailer.rb +34 -0
  89. data/app/models/page.rb +20 -0
  90. data/app/models/page_cache.rb +29 -0
  91. data/app/models/ping.rb +129 -0
  92. data/app/models/redirect.rb +3 -0
  93. data/app/models/resource.rb +76 -0
  94. data/app/models/sidebar.rb +32 -0
  95. data/app/models/simple_cache.rb +37 -0
  96. data/app/models/tag.rb +63 -0
  97. data/app/models/text_filter.rb +111 -0
  98. data/app/models/theme.rb +44 -0
  99. data/app/models/trackback.rb +51 -0
  100. data/app/models/trigger.rb +31 -0
  101. data/app/models/user.rb +113 -0
  102. data/app/models/web_notifier.rb +7 -0
  103. data/app/views/accounts/login.rhtml +24 -0
  104. data/app/views/accounts/logout.rhtml +12 -0
  105. data/app/views/accounts/signup.rhtml +26 -0
  106. data/app/views/accounts/welcome.rhtml +13 -0
  107. data/app/views/admin/base/_recent_comments.rhtml +10 -0
  108. data/app/views/admin/base/_recent_trackbacks.rhtml +10 -0
  109. data/app/views/admin/blacklist/_blacklist_patterns.rhtml +16 -0
  110. data/app/views/admin/blacklist/_form.rhtml +15 -0
  111. data/app/views/admin/blacklist/_quick_post.rhtml +16 -0
  112. data/app/views/admin/blacklist/destroy.rhtml +10 -0
  113. data/app/views/admin/blacklist/edit.rhtml +14 -0
  114. data/app/views/admin/blacklist/list.rhtml +13 -0
  115. data/app/views/admin/cache/list.rhtml +8 -0
  116. data/app/views/admin/categories/_categories.rhtml +14 -0
  117. data/app/views/admin/categories/_form.rhtml +7 -0
  118. data/app/views/admin/categories/_quick_post.rhtml +11 -0
  119. data/app/views/admin/categories/destroy.rhtml +10 -0
  120. data/app/views/admin/categories/edit.rhtml +13 -0
  121. data/app/views/admin/categories/list.rhtml +15 -0
  122. data/app/views/admin/categories/reorder.rhtml +9 -0
  123. data/app/views/admin/categories/show.rhtml +18 -0
  124. data/app/views/admin/comments/_form.rhtml +19 -0
  125. data/app/views/admin/comments/comments.rhtml +4 -0
  126. data/app/views/admin/comments/destroy.rhtml +11 -0
  127. data/app/views/admin/comments/edit.rhtml +18 -0
  128. data/app/views/admin/comments/list.rhtml +31 -0
  129. data/app/views/admin/comments/new.rhtml +15 -0
  130. data/app/views/admin/comments/show.rhtml +10 -0
  131. data/app/views/admin/content/_articles.rhtml +20 -0
  132. data/app/views/admin/content/_attachment.rhtml +17 -0
  133. data/app/views/admin/content/_form.rhtml +51 -0
  134. data/app/views/admin/content/_pages.rhtml +3 -0
  135. data/app/views/admin/content/_quick_post.rhtml +20 -0
  136. data/app/views/admin/content/_show_categories.rhtml +9 -0
  137. data/app/views/admin/content/_show_resources.rhtml +9 -0
  138. data/app/views/admin/content/destroy.rhtml +11 -0
  139. data/app/views/admin/content/edit.rhtml +28 -0
  140. data/app/views/admin/content/list.rhtml +20 -0
  141. data/app/views/admin/content/new.rhtml +27 -0
  142. data/app/views/admin/content/preview.rhtml +3 -0
  143. data/app/views/admin/content/show.rhtml +25 -0
  144. data/app/views/admin/general/index.rhtml +216 -0
  145. data/app/views/admin/general/update_database.rhtml +44 -0
  146. data/app/views/admin/pages/_form.rhtml +19 -0
  147. data/app/views/admin/pages/_pages.rhtml +18 -0
  148. data/app/views/admin/pages/_quick_post.rhtml +21 -0
  149. data/app/views/admin/pages/destroy.rhtml +11 -0
  150. data/app/views/admin/pages/edit.rhtml +28 -0
  151. data/app/views/admin/pages/list.rhtml +13 -0
  152. data/app/views/admin/pages/new.rhtml +24 -0
  153. data/app/views/admin/pages/preview.rhtml +1 -0
  154. data/app/views/admin/pages/show.rhtml +14 -0
  155. data/app/views/admin/resources/_itunes_category_add.rhtml +11 -0
  156. data/app/views/admin/resources/_itunes_category_edit.rhtml +32 -0
  157. data/app/views/admin/resources/_metadata_add.rhtml +22 -0
  158. data/app/views/admin/resources/_metadata_edit.rhtml +22 -0
  159. data/app/views/admin/resources/_mime_edit.rhtml +8 -0
  160. data/app/views/admin/resources/_pages.rhtml +3 -0
  161. data/app/views/admin/resources/_resources.rhtml +40 -0
  162. data/app/views/admin/resources/destroy.rhtml +11 -0
  163. data/app/views/admin/resources/list.rhtml +9 -0
  164. data/app/views/admin/resources/new.rhtml +12 -0
  165. data/app/views/admin/sidebar/_active.rhtml +14 -0
  166. data/app/views/admin/sidebar/_actives.rhtml +9 -0
  167. data/app/views/admin/sidebar/_available.rhtml +5 -0
  168. data/app/views/admin/sidebar/_availables.rhtml +5 -0
  169. data/app/views/admin/sidebar/_publish.rhtml +2 -0
  170. data/app/views/admin/sidebar/_target.rhtml +1 -0
  171. data/app/views/admin/sidebar/index.rhtml +34 -0
  172. data/app/views/admin/sidebar/publish.rjs +6 -0
  173. data/app/views/admin/sidebar/remove.rjs +5 -0
  174. data/app/views/admin/sidebar/set_active.rjs +10 -0
  175. data/app/views/admin/textfilters/_form.rhtml +45 -0
  176. data/app/views/admin/textfilters/_macros.rhtml +16 -0
  177. data/app/views/admin/textfilters/_textfilters.rhtml +20 -0
  178. data/app/views/admin/textfilters/destroy.rhtml +10 -0
  179. data/app/views/admin/textfilters/edit.rhtml +17 -0
  180. data/app/views/admin/textfilters/list.rhtml +15 -0
  181. data/app/views/admin/textfilters/macro_help.rhtml +3 -0
  182. data/app/views/admin/textfilters/new.rhtml +15 -0
  183. data/app/views/admin/textfilters/preview.rhtml +3 -0
  184. data/app/views/admin/textfilters/show.rhtml +34 -0
  185. data/app/views/admin/textfilters/show_help.rhtml +8 -0
  186. data/app/views/admin/themes/index.rhtml +12 -0
  187. data/app/views/admin/trackbacks/_form.rhtml +19 -0
  188. data/app/views/admin/trackbacks/destroy.rhtml +6 -0
  189. data/app/views/admin/trackbacks/edit.rhtml +14 -0
  190. data/app/views/admin/trackbacks/list.rhtml +31 -0
  191. data/app/views/admin/trackbacks/new.rhtml +15 -0
  192. data/app/views/admin/trackbacks/show.rhtml +14 -0
  193. data/app/views/admin/users/_form.rhtml +48 -0
  194. data/app/views/admin/users/_user.rhtml +9 -0
  195. data/app/views/admin/users/destroy.rhtml +14 -0
  196. data/app/views/admin/users/edit.rhtml +14 -0
  197. data/app/views/admin/users/list.rhtml +9 -0
  198. data/app/views/admin/users/new.rhtml +15 -0
  199. data/app/views/admin/users/show.rhtml +18 -0
  200. data/app/views/articles/_article.rhtml +4 -0
  201. data/app/views/articles/_comment.rhtml +7 -0
  202. data/app/views/articles/_comment_box.rhtml +43 -0
  203. data/app/views/articles/_comment_error.rhtml +1 -0
  204. data/app/views/articles/_trackback.rhtml +7 -0
  205. data/app/views/articles/archives.rhtml +22 -0
  206. data/app/views/articles/comment_preview.rhtml +3 -0
  207. data/app/views/articles/error.rhtml +3 -0
  208. data/app/views/articles/groupings.rhtml +14 -0
  209. data/app/views/articles/index.rhtml +11 -0
  210. data/app/views/articles/read.rhtml +70 -0
  211. data/app/views/articles/trackback.rxml +5 -0
  212. data/app/views/articles/view_page.rhtml +3 -0
  213. data/app/views/layouts/accounts.rhtml +22 -0
  214. data/app/views/layouts/administration.rhtml +75 -0
  215. data/app/views/layouts/sidebar.rhtml +40 -0
  216. data/app/views/live/search.rhtml +10 -0
  217. data/app/views/notification_mailer/_mail_footer.rhtml +7 -0
  218. data/app/views/notification_mailer/_mail_header.rhtml +1 -0
  219. data/app/views/notification_mailer/article.rhtml +6 -0
  220. data/app/views/notification_mailer/comment.rhtml +11 -0
  221. data/app/views/notification_mailer/trackback.rhtml +3 -0
  222. data/app/views/settings/done.rhtml +2 -0
  223. data/app/views/settings/install.rhtml +12 -0
  224. data/app/views/shared/_search.rhtml +10 -0
  225. data/app/views/sidebar/_row.rhtml +1 -0
  226. data/app/views/sidebar/_sidebar.rhtml +5 -0
  227. data/app/views/sidebar/display_plugins.rhtml +5 -0
  228. data/app/views/sidebar/show.rhtml +1 -0
  229. data/app/views/theme/static_view_test.rhtml +1 -0
  230. data/app/views/xml/_atom10_item_article.rxml +39 -0
  231. data/app/views/xml/_atom10_item_comment.rxml +13 -0
  232. data/app/views/xml/_atom10_item_trackback.rxml +16 -0
  233. data/app/views/xml/_itunes_item_resource.rxml +30 -0
  234. data/app/views/xml/_rss20_item_article.rxml +35 -0
  235. data/app/views/xml/_rss20_item_comment.rxml +7 -0
  236. data/app/views/xml/_rss20_item_trackback.rxml +7 -0
  237. data/app/views/xml/atom10_feed.rxml +18 -0
  238. data/app/views/xml/itunes_feed.rxml +29 -0
  239. data/app/views/xml/rsd.rxml +19 -0
  240. data/app/views/xml/rss20_feed.rxml +18 -0
  241. data/bin/typo +12 -0
  242. data/cache/META/DATA/ACTION_PARAM/localhost.3000/articles/index/.cache +540 -0
  243. data/cache/META/DATA/ACTION_PARAM/localhost.3000/articles/permalink/day=09&month=09&title=i-need-a-new-keyboard-and-mouse&year=2005.cache +414 -0
  244. data/cache/META/META/ACTION_PARAM/localhost.3000/articles/index/.cache +3 -0
  245. data/cache/META/META/ACTION_PARAM/localhost.3000/articles/permalink/day=09&month=09&title=i-need-a-new-keyboard-and-mouse&year=2005.cache +3 -0
  246. data/components/plugins/sidebars/aimpresence/content.rhtml +4 -0
  247. data/components/plugins/sidebars/aimpresence_controller.rb +10 -0
  248. data/components/plugins/sidebars/amazon/content.rhtml +4 -0
  249. data/components/plugins/sidebars/amazon_controller.rb +17 -0
  250. data/components/plugins/sidebars/archives/content.rhtml +11 -0
  251. data/components/plugins/sidebars/archives_controller.rb +24 -0
  252. data/components/plugins/sidebars/audioscrobbler/content.rhtml +10 -0
  253. data/components/plugins/sidebars/audioscrobbler_controller.rb +10 -0
  254. data/components/plugins/sidebars/backpack/content.rhtml +12 -0
  255. data/components/plugins/sidebars/backpack_controller.rb +17 -0
  256. data/components/plugins/sidebars/category/content.rhtml +10 -0
  257. data/components/plugins/sidebars/category_controller.rb +13 -0
  258. data/components/plugins/sidebars/delicious/content.rhtml +20 -0
  259. data/components/plugins/sidebars/delicious_controller.rb +29 -0
  260. data/components/plugins/sidebars/flickr/content.rhtml +15 -0
  261. data/components/plugins/sidebars/flickr_controller.rb +16 -0
  262. data/components/plugins/sidebars/fortythree/content.rhtml +8 -0
  263. data/components/plugins/sidebars/fortythree_controller.rb +12 -0
  264. data/components/plugins/sidebars/fortythreeplaces/content.rhtml +8 -0
  265. data/components/plugins/sidebars/fortythreeplaces_controller.rb +12 -0
  266. data/components/plugins/sidebars/magnolia/content.rhtml +12 -0
  267. data/components/plugins/sidebars/magnolia_controller.rb +17 -0
  268. data/components/plugins/sidebars/recent_comments/content.rhtml +12 -0
  269. data/components/plugins/sidebars/recent_comments_controller.rb +23 -0
  270. data/components/plugins/sidebars/static/content.rhtml +2 -0
  271. data/components/plugins/sidebars/static_controller.rb +23 -0
  272. data/components/plugins/sidebars/tada/content.rhtml +12 -0
  273. data/components/plugins/sidebars/tada_controller.rb +12 -0
  274. data/components/plugins/sidebars/tag/content.rhtml +8 -0
  275. data/components/plugins/sidebars/tag_controller.rb +18 -0
  276. data/components/plugins/sidebars/technorati/content.rhtml +8 -0
  277. data/components/plugins/sidebars/technorati_controller.rb +12 -0
  278. data/components/plugins/sidebars/upcoming/content.rhtml +8 -0
  279. data/components/plugins/sidebars/upcoming_controller.rb +11 -0
  280. data/components/plugins/sidebars/xbox/content.rhtml +2 -0
  281. data/components/plugins/sidebars/xbox_controller.rb +6 -0
  282. data/components/plugins/sidebars/xml/content.rhtml +12 -0
  283. data/components/plugins/sidebars/xml_controller.rb +11 -0
  284. data/components/plugins/textfilters/amazon_controller.rb +39 -0
  285. data/components/plugins/textfilters/code_controller.rb +59 -0
  286. data/components/plugins/textfilters/flickr_controller.rb +75 -0
  287. data/components/plugins/textfilters/htmlfilter_controller.rb +8 -0
  288. data/components/plugins/textfilters/lightbox_controller.rb +122 -0
  289. data/components/plugins/textfilters/macropost_controller.rb +14 -0
  290. data/components/plugins/textfilters/macropre_controller.rb +14 -0
  291. data/components/plugins/textfilters/markdown_controller.rb +32 -0
  292. data/components/plugins/textfilters/none_controller.rb +8 -0
  293. data/components/plugins/textfilters/smartypants_controller.rb +8 -0
  294. data/components/plugins/textfilters/sparkline_controller.rb +87 -0
  295. data/components/plugins/textfilters/textile_controller.rb +8 -0
  296. data/components/sidebars/README +36 -0
  297. data/config/boot.rb +44 -0
  298. data/config/database.yml +17 -0
  299. data/config/database.yml-pgsql +17 -0
  300. data/config/database.yml.example +18 -0
  301. data/config/environment.rb +145 -0
  302. data/config/environments/development.rb +17 -0
  303. data/config/environments/production.rb +19 -0
  304. data/config/environments/test.rb +26 -0
  305. data/config/iTunes.yml +72 -0
  306. data/config/lighttpd.conf +46 -0
  307. data/config/mail.yml +8 -0
  308. data/config/mail.yml.example +8 -0
  309. data/config/routes.rb +92 -0
  310. data/db/DB +0 -0
  311. data/db/DB.test +0 -0
  312. data/db/converters/README +14 -0
  313. data/db/converters/feed.rb +68 -0
  314. data/db/converters/mt-import.rb +72 -0
  315. data/db/converters/mt3.rb +172 -0
  316. data/db/converters/rss.rb +67 -0
  317. data/db/converters/s9y.rb +182 -0
  318. data/db/converters/textpattern.rb +137 -0
  319. data/db/converters/wordpress.rb +187 -0
  320. data/db/development_structure.sql +691 -0
  321. data/db/migrate/001_initial_schema.rb +127 -0
  322. data/db/migrate/002_add_user_email.rb +17 -0
  323. data/db/migrate/003_add_article_user_id.rb +20 -0
  324. data/db/migrate/004_add_sidebars.rb +31 -0
  325. data/db/migrate/005_add_cache_table.rb +20 -0
  326. data/db/migrate/006_add_pages.rb +17 -0
  327. data/db/migrate/007_add_permalink.rb +36 -0
  328. data/db/migrate/008_add_page_title.rb +9 -0
  329. data/db/migrate/009_add_article_guid.rb +10 -0
  330. data/db/migrate/010_add_tags.rb +19 -0
  331. data/db/migrate/011_add_article_id.rb +17 -0
  332. data/db/migrate/012_enlarge_settings.rb +11 -0
  333. data/db/migrate/013_add_textfilters.rb +33 -0
  334. data/db/migrate/014_move_text_filter_to_text_filter_id.rb +43 -0
  335. data/db/migrate/015_convert_mysql_to_innodb.rb +19 -0
  336. data/db/migrate/016_fix_is_primary_postgres.rb +19 -0
  337. data/db/migrate/017_add_comment_user_id.rb +23 -0
  338. data/db/migrate/018_add_guids.rb +13 -0
  339. data/db/migrate/019_add_whiteboards_to_content.rb +15 -0
  340. data/db/migrate/020_superclass_articles.rb +167 -0
  341. data/db/migrate/021_superclass_comments.rb +94 -0
  342. data/db/migrate/022_superclass_trackbacks.rb +71 -0
  343. data/db/migrate/023_superclass_pages.rb +64 -0
  344. data/db/migrate/024_cleanup_contents.rb +54 -0
  345. data/db/migrate/025_add_itunes_metadata.rb +29 -0
  346. data/db/migrate/026_add_redirect_table.rb +13 -0
  347. data/db/migrate/027_set_comment_published_flag.rb +19 -0
  348. data/db/migrate/028_rename_redirect_to.rb +12 -0
  349. data/db/migrate/029_add_user_notification.rb +29 -0
  350. data/db/migrate/030_index_sessions.rb +9 -0
  351. data/db/migrate/031_add_notifications_table.rb +14 -0
  352. data/db/migrate/032_add_jabber_notification.rb +11 -0
  353. data/db/migrate/033_add_count_caching.rb +34 -0
  354. data/db/migrate/034_boolify_published.rb +36 -0
  355. data/db/migrate/035_boolify_content_allow_foo.rb +36 -0
  356. data/db/migrate/036_add_tag_display_name.rb +53 -0
  357. data/db/migrate/037_enlarge_ip_field.rb +9 -0
  358. data/db/migrate/038_add_blog_object.rb +52 -0
  359. data/db/migrate/039_serialize_blog_attributes.rb +160 -0
  360. data/db/migrate/040_attach_content_to_blog.rb +28 -0
  361. data/db/migrate/041_fixup_default_sidebars.rb +18 -0
  362. data/db/migrate/042_remove_sidebar_staged_config.rb +22 -0
  363. data/db/migrate/043_create_triggers.rb +14 -0
  364. data/db/migrate/044_add_published_at_to_content.rb +18 -0
  365. data/db/migrate/045_fix_contents_published_default.rb +9 -0
  366. data/db/migrate/046_fixup_forthcoming_publications.rb +40 -0
  367. data/db/schema.mysql-v3.sql +218 -0
  368. data/db/schema.mysql.sql +218 -0
  369. data/db/schema.postgresql.sql +218 -0
  370. data/db/schema.rb +169 -0
  371. data/db/schema.sqlite.sql +218 -0
  372. data/db/schema.sqlserver.sql +232 -0
  373. data/db/schema_version +1 -0
  374. data/db/scripts/fix_permalinks.rb +5 -0
  375. data/db/updates/update.168.to.200.mysql.sql +33 -0
  376. data/db/updates/update.168.to.200.psql.sql +30 -0
  377. data/doc/Installer.txt +55 -0
  378. data/doc/README_FOR_APP +2 -0
  379. data/installer/rails-installer.rb +488 -0
  380. data/installer/rails_installer_defaults.yml +4 -0
  381. data/installer/typo-installer.rb +35 -0
  382. data/lib/backpack_api.rb +202 -0
  383. data/lib/bare_migration.rb +142 -0
  384. data/lib/email_notify.rb +32 -0
  385. data/lib/format.rb +19 -0
  386. data/lib/generators/sidebar/sidebar_generator.rb +13 -0
  387. data/lib/generators/sidebar/templates/components/plugins/sidebars/controller_template.rb +20 -0
  388. data/lib/generators/sidebar/templates/components/plugins/sidebars/views/content_template.rhtml +4 -0
  389. data/lib/jabber_notify.rb +32 -0
  390. data/lib/login_system.rb +85 -0
  391. data/lib/migrator.rb +28 -0
  392. data/lib/rails_patch/active_record.rb +36 -0
  393. data/lib/rails_patch/components.rb +14 -0
  394. data/lib/sidebars/component_plugin.rb +5 -0
  395. data/lib/sidebars/plugin.rb +241 -0
  396. data/lib/spam_protection.rb +126 -0
  397. data/lib/tasks/release.rake +171 -0
  398. data/lib/tasks/schemas.rake +6 -0
  399. data/lib/tasks/sweep_cache.rake +6 -0
  400. data/lib/text_filter_plugin.rb +97 -0
  401. data/lib/transforms.rb +26 -0
  402. data/lib/typo_guid.rb +10 -0
  403. data/lib/typo_plugins.rb +19 -0
  404. data/lib/typo_version.rb +1 -0
  405. data/lib/xmlrpc_fix.rb +13 -0
  406. data/public/.htaccess +34 -0
  407. data/public/404.html +8 -0
  408. data/public/500.html +8 -0
  409. data/public/dispatch.cgi +10 -0
  410. data/public/dispatch.fcgi +24 -0
  411. data/public/dispatch.rb +10 -0
  412. data/public/favicon.ico +0 -0
  413. data/public/images/admin/dot-vertical.gif +0 -0
  414. data/public/images/admin/h-tile.gif +0 -0
  415. data/public/images/admin/hdr-tile.gif +0 -0
  416. data/public/images/admin/toggle.gif +0 -0
  417. data/public/images/bg.jpg +0 -0
  418. data/public/images/bgcolor.jpg +0 -0
  419. data/public/images/body_bg.png +0 -0
  420. data/public/images/branding_bg.png +0 -0
  421. data/public/images/branding_logo.png +0 -0
  422. data/public/images/checked.gif +0 -0
  423. data/public/images/content_bg.png +0 -0
  424. data/public/images/delete.png +0 -0
  425. data/public/images/footer.jpg +0 -0
  426. data/public/images/footer.png +0 -0
  427. data/public/images/global_bg.png +0 -0
  428. data/public/images/global_logo.png +0 -0
  429. data/public/images/go.png +0 -0
  430. data/public/images/header.jpg +0 -0
  431. data/public/images/loading.gif +0 -0
  432. data/public/images/not-checked copy.gif +0 -0
  433. data/public/images/not-checked.gif +0 -0
  434. data/public/images/overlay.png +0 -0
  435. data/public/images/powered.gif +0 -0
  436. data/public/images/section_bg.png +0 -0
  437. data/public/images/sections_bg.png +0 -0
  438. data/public/images/sections_hilite.png +0 -0
  439. data/public/images/sections_hover.png +0 -0
  440. data/public/images/spinner-blue.gif +0 -0
  441. data/public/images/spinner.gif +0 -0
  442. data/public/images/spot-header.gif +0 -0
  443. data/public/images/spot-title.gif +0 -0
  444. data/public/images/x-ed.gif +0 -0
  445. data/public/javascripts/application.js +2 -0
  446. data/public/javascripts/controls.js +815 -0
  447. data/public/javascripts/cookies.js +60 -0
  448. data/public/javascripts/dragdrop.js +724 -0
  449. data/public/javascripts/effects.js +953 -0
  450. data/public/javascripts/lightbox.js +348 -0
  451. data/public/javascripts/prototype.js +1985 -0
  452. data/public/javascripts/scriptaculous.js +47 -0
  453. data/public/javascripts/slider.js +258 -0
  454. data/public/javascripts/typo.js +85 -0
  455. data/public/robots.txt +2 -0
  456. data/public/stylesheets/administration.css +585 -0
  457. data/public/stylesheets/lightbox.css +22 -0
  458. data/public/stylesheets/rss.css +54 -0
  459. data/public/stylesheets/user-styles.css +0 -0
  460. data/script/about +3 -0
  461. data/script/benchmarker +19 -0
  462. data/script/breakpointer +3 -0
  463. data/script/console +3 -0
  464. data/script/destroy +3 -0
  465. data/script/generate +3 -0
  466. data/script/lighttpd +2 -0
  467. data/script/logreport +79 -0
  468. data/script/migrate +31 -0
  469. data/script/performance/benchmarker +3 -0
  470. data/script/performance/profiler +3 -0
  471. data/script/plugin +3 -0
  472. data/script/process/reaper +3 -0
  473. data/script/process/spawner +3 -0
  474. data/script/process/spinner +3 -0
  475. data/script/profiler +34 -0
  476. data/script/runner +3 -0
  477. data/script/server +3 -0
  478. data/script/spacecheck +40 -0
  479. data/test/fixtures/articles_categories.yml +31 -0
  480. data/test/fixtures/articles_tags.yml +19 -0
  481. data/test/fixtures/blacklist_patterns.yml +10 -0
  482. data/test/fixtures/blogs.yml +74 -0
  483. data/test/fixtures/categories.yml +35 -0
  484. data/test/fixtures/contents.yml +297 -0
  485. data/test/fixtures/notification_mailer/article +3 -0
  486. data/test/fixtures/notification_mailer/comment +3 -0
  487. data/test/fixtures/notification_mailer/trackback +3 -0
  488. data/test/fixtures/notifications.yml +0 -0
  489. data/test/fixtures/page_caches.yml +7 -0
  490. data/test/fixtures/redirects.yml +13 -0
  491. data/test/fixtures/resources.yml +24 -0
  492. data/test/fixtures/sidebars.yml +5 -0
  493. data/test/fixtures/tags.yml +13 -0
  494. data/test/fixtures/text_filters.yml +42 -0
  495. data/test/fixtures/triggers.yml +1 -0
  496. data/test/fixtures/users.yml +56 -0
  497. data/test/functional/accounts_controller_test.rb +82 -0
  498. data/test/functional/admin/article_preview_test.rb +67 -0
  499. data/test/functional/admin/blacklist_controller_test.rb +63 -0
  500. data/test/functional/admin/categories_controller_test.rb +112 -0
  501. data/test/functional/admin/comments_controller_test.rb +78 -0
  502. data/test/functional/admin/content_controller_test.rb +234 -0
  503. data/test/functional/admin/general_controller_test.rb +26 -0
  504. data/test/functional/admin/pages_controller_test.rb +103 -0
  505. data/test/functional/admin/resources_controller_test.rb +49 -0
  506. data/test/functional/admin/textfilters_controller_test.rb +29 -0
  507. data/test/functional/admin/themes_controller_test.rb +34 -0
  508. data/test/functional/admin/trackbacks_controller_test.rb +76 -0
  509. data/test/functional/admin/users_controller_test.rb +72 -0
  510. data/test/functional/articles_controller_test.rb +525 -0
  511. data/test/functional/backend_controller_test.rb +273 -0
  512. data/test/functional/redirect_controller_test.rb +40 -0
  513. data/test/functional/textfilter_controller_test.rb +275 -0
  514. data/test/functional/theme_controller_test.rb +45 -0
  515. data/test/functional/xml_controller_test.rb +353 -0
  516. data/test/mocks/test/dns_mock.rb +13 -0
  517. data/test/mocks/test/flickr_mock.rb +30 -0
  518. data/test/mocks/test/http_mock.rb +38 -0
  519. data/test/mocks/test/theme_mock.rb +5 -0
  520. data/test/mocks/test/xmlrpc_mock.rb +27 -0
  521. data/test/mocks/themes/123-numbers-in-path/about.markdown +0 -0
  522. data/test/mocks/themes/CamelCaseDirectory/about.markdown +0 -0
  523. data/test/mocks/themes/azure/about.markdown +5 -0
  524. data/test/mocks/themes/azure/layouts/default.rhtml +50 -0
  525. data/test/mocks/themes/azure/preview.png +0 -0
  526. data/test/mocks/themes/azure/views/theme/static_view_test.rhtml +1 -0
  527. data/test/mocks/themes/i-have-special-chars/about.markdown +0 -0
  528. data/test/test_helper.rb +95 -0
  529. data/test/unit/article_test.rb +245 -0
  530. data/test/unit/assumptions_tests.rb +54 -0
  531. data/test/unit/audioscrobbler_test.rb +132 -0
  532. data/test/unit/blacklist_pattern_test.rb +14 -0
  533. data/test/unit/blog_test.rb +83 -0
  534. data/test/unit/category_test.rb +37 -0
  535. data/test/unit/comment_test.rb +117 -0
  536. data/test/unit/configuration_test.rb +21 -0
  537. data/test/unit/content_state/factory_test.rb +84 -0
  538. data/test/unit/delicious_test.rb +96 -0
  539. data/test/unit/flickr_test.rb +134 -0
  540. data/test/unit/fortythree_test.rb +66 -0
  541. data/test/unit/magnolia_test.rb +87 -0
  542. data/test/unit/metafragment_test.rb +63 -0
  543. data/test/unit/notification_mailer_test.rb +55 -0
  544. data/test/unit/observer_test.rb +40 -0
  545. data/test/unit/page_cache_test.rb +34 -0
  546. data/test/unit/page_test.rb +25 -0
  547. data/test/unit/ping_test.rb +111 -0
  548. data/test/unit/redirect_test.rb +19 -0
  549. data/test/unit/resource_test.rb +71 -0
  550. data/test/unit/sidebar_test.rb +14 -0
  551. data/test/unit/tag_test.rb +66 -0
  552. data/test/unit/text_filter_test.rb +126 -0
  553. data/test/unit/theme_test.rb +44 -0
  554. data/test/unit/trackback_test.rb +45 -0
  555. data/test/unit/trigger_test.rb +40 -0
  556. data/test/unit/user_test.rb +111 -0
  557. data/themes/azure/about.markdown +5 -0
  558. data/themes/azure/images/bg-tile.gif +0 -0
  559. data/themes/azure/images/bracket.gif +0 -0
  560. data/themes/azure/images/bullet.gif +0 -0
  561. data/themes/azure/images/hdr.gif +0 -0
  562. data/themes/azure/images/q-close.gif +0 -0
  563. data/themes/azure/images/q-open.gif +0 -0
  564. data/themes/azure/images/sbar-tile.gif +0 -0
  565. data/themes/azure/images/spinner.gif +0 -0
  566. data/themes/azure/images/xlink.gif +0 -0
  567. data/themes/azure/layouts/default.rhtml +50 -0
  568. data/themes/azure/preview.png +0 -0
  569. data/themes/azure/stylesheets/azure.css +436 -0
  570. data/themes/azure/stylesheets/print.css +30 -0
  571. data/themes/azure/views/theme/static_view_test.rhtml +1 -0
  572. data/vendor/akismet/Akismet.rb +140 -0
  573. data/vendor/bluecloth/CHANGES +366 -0
  574. data/vendor/bluecloth/LICENSE +340 -0
  575. data/vendor/bluecloth/README +99 -0
  576. data/vendor/bluecloth/bin/bluecloth +83 -0
  577. data/vendor/bluecloth/install.rb +150 -0
  578. data/vendor/bluecloth/lib/bluecloth.rb +1144 -0
  579. data/vendor/bluecloth/test.rb +117 -0
  580. data/vendor/bluecloth/tests/00_Class.tests.rb +71 -0
  581. data/vendor/bluecloth/tests/05_Markdown.tests.rb +1527 -0
  582. data/vendor/bluecloth/tests/10_Bug.tests.rb +57 -0
  583. data/vendor/bluecloth/tests/15_Contrib.tests.rb +132 -0
  584. data/vendor/bluecloth/tests/bctestcase.rb +274 -0
  585. data/vendor/bluecloth/tests/data/antsugar.txt +34 -0
  586. data/vendor/bluecloth/tests/data/ml-announce.txt +17 -0
  587. data/vendor/bluecloth/tests/data/re-overflow.txt +67 -0
  588. data/vendor/bluecloth/tests/data/re-overflow2.txt +281 -0
  589. data/vendor/bluecloth/utils.rb +553 -0
  590. data/vendor/flickr/Rakefile +36 -0
  591. data/vendor/flickr/flickr.rb +490 -0
  592. data/vendor/flickr/index.html +129 -0
  593. data/vendor/flickr/test_flickr.rb +173 -0
  594. data/vendor/jabber4r/CHANGES +8 -0
  595. data/vendor/jabber4r/LICENSE.txt +12 -0
  596. data/vendor/jabber4r/README +180 -0
  597. data/vendor/jabber4r/Rakefile.rb +143 -0
  598. data/vendor/jabber4r/lib/jabber4r/jabber4r.rb +22 -0
  599. data/vendor/jabber4r/lib/jabber4r/jid.rb +93 -0
  600. data/vendor/jabber4r/lib/jabber4r/protocol.rb +1384 -0
  601. data/vendor/jabber4r/lib/jabber4r/rexml_1.8_patch.rb +16 -0
  602. data/vendor/jabber4r/lib/jabber4r/roster.rb +322 -0
  603. data/vendor/jabber4r/lib/jabber4r/session.rb +615 -0
  604. data/vendor/jabber4r/lib/jabber4r/vcard.rb +42 -0
  605. data/vendor/plugins/expiring_action_cache/init.rb +2 -0
  606. data/vendor/plugins/expiring_action_cache/lib/actionparamcache.rb +113 -0
  607. data/vendor/plugins/expiring_action_cache/lib/metafragment.rb +46 -0
  608. data/vendor/plugins/upload_progress/CHANGELOG +3 -0
  609. data/vendor/plugins/upload_progress/MIT-LICENSE +20 -0
  610. data/vendor/plugins/upload_progress/README +45 -0
  611. data/vendor/plugins/upload_progress/Rakefile +23 -0
  612. data/vendor/plugins/upload_progress/init.rb +7 -0
  613. data/vendor/plugins/upload_progress/lib/multipart_progress.rb +169 -0
  614. data/vendor/plugins/upload_progress/lib/progress.rb +145 -0
  615. data/vendor/plugins/upload_progress/lib/upload_progress.rb +303 -0
  616. data/vendor/plugins/upload_progress/lib/upload_progress_helper.rb +424 -0
  617. data/vendor/plugins/upload_progress/public/stylesheets/upload_progress.css +21 -0
  618. data/vendor/plugins/upload_progress/test/multipart_progress_testx.rb +364 -0
  619. data/vendor/plugins/upload_progress/test/upload_progress_helper_testx.rb +134 -0
  620. data/vendor/plugins/upload_progress/test/upload_progress_testx.rb +88 -0
  621. data/vendor/redcloth/RedCloth.gemspec +52 -0
  622. data/vendor/redcloth/bin/redcloth +3 -0
  623. data/vendor/redcloth/doc/CHANGELOG +160 -0
  624. data/vendor/redcloth/doc/COPYING +25 -0
  625. data/vendor/redcloth/doc/README +106 -0
  626. data/vendor/redcloth/doc/REFERENCE +216 -0
  627. data/vendor/redcloth/doc/make.rb +359 -0
  628. data/vendor/redcloth/install.rb +1032 -0
  629. data/vendor/redcloth/lib/redcloth.rb +1130 -0
  630. data/vendor/redcloth/run-tests.rb +28 -0
  631. data/vendor/redcloth/setup.rb +1376 -0
  632. data/vendor/redcloth/tests/code.yml +105 -0
  633. data/vendor/redcloth/tests/hard_breaks.yml +26 -0
  634. data/vendor/redcloth/tests/images.yml +171 -0
  635. data/vendor/redcloth/tests/instiki.yml +39 -0
  636. data/vendor/redcloth/tests/links.yml +155 -0
  637. data/vendor/redcloth/tests/lists.yml +77 -0
  638. data/vendor/redcloth/tests/markdown.yml +218 -0
  639. data/vendor/redcloth/tests/poignant.yml +64 -0
  640. data/vendor/redcloth/tests/table.yml +198 -0
  641. data/vendor/redcloth/tests/textism.yml +406 -0
  642. data/vendor/ruby-mp3info/lib/mp3info.rb +720 -0
  643. data/vendor/rubypants/README +114 -0
  644. data/vendor/rubypants/Rakefile +55 -0
  645. data/vendor/rubypants/html/classes/RubyPants.html +924 -0
  646. data/vendor/rubypants/html/created.rid +1 -0
  647. data/vendor/rubypants/html/files/README.html +248 -0
  648. data/vendor/rubypants/html/files/rubypants_rb.html +125 -0
  649. data/vendor/rubypants/html/fr_class_index.html +27 -0
  650. data/vendor/rubypants/html/fr_file_index.html +28 -0
  651. data/vendor/rubypants/html/fr_method_index.html +38 -0
  652. data/vendor/rubypants/html/index.html +24 -0
  653. data/vendor/rubypants/html/rdoc-style.css +172 -0
  654. data/vendor/rubypants/install.rb +9 -0
  655. data/vendor/rubypants/rubypants.rb +490 -0
  656. data/vendor/rubypants/test_rubypants.rb +162 -0
  657. data/vendor/sparklines/README.txt +47 -0
  658. data/vendor/sparklines/USAGE +14 -0
  659. data/vendor/sparklines/lib/sparklines.rb +435 -0
  660. data/vendor/sparklines/samples/sparklinestest.rb +26 -0
  661. data/vendor/sparklines/sparklines_generator.rb +9 -0
  662. data/vendor/sparklines/templates/sparklines_controller.rb +30 -0
  663. data/vendor/sparklines/templates/sparklines_helper.rb +30 -0
  664. data/vendor/syntax/LICENSE +27 -0
  665. data/vendor/syntax/NEWS +16 -0
  666. data/vendor/syntax/README +38 -0
  667. data/vendor/syntax/Rakefile +194 -0
  668. data/vendor/syntax/api/classes/Syntax.html +173 -0
  669. data/vendor/syntax/api/classes/Syntax/Convertors.html +91 -0
  670. data/vendor/syntax/api/classes/Syntax/Convertors/Abstract.html +159 -0
  671. data/vendor/syntax/api/classes/Syntax/Convertors/HTML.html +149 -0
  672. data/vendor/syntax/api/classes/Syntax/Default.html +123 -0
  673. data/vendor/syntax/api/classes/Syntax/Ruby.html +319 -0
  674. data/vendor/syntax/api/classes/Syntax/Token.html +151 -0
  675. data/vendor/syntax/api/classes/Syntax/Tokenizer.html +324 -0
  676. data/vendor/syntax/api/classes/Syntax/Version.html +109 -0
  677. data/vendor/syntax/api/classes/Syntax/XML.html +205 -0
  678. data/vendor/syntax/api/classes/Syntax/YAML.html +189 -0
  679. data/vendor/syntax/api/created.rid +1 -0
  680. data/vendor/syntax/api/files/README.html +155 -0
  681. data/vendor/syntax/api/files/lib/syntax/common_rb.html +96 -0
  682. data/vendor/syntax/api/files/lib/syntax/convertors/abstract_rb.html +96 -0
  683. data/vendor/syntax/api/files/lib/syntax/convertors/html_rb.html +96 -0
  684. data/vendor/syntax/api/files/lib/syntax/lang/ruby_rb.html +96 -0
  685. data/vendor/syntax/api/files/lib/syntax/lang/xml_rb.html +96 -0
  686. data/vendor/syntax/api/files/lib/syntax/lang/yaml_rb.html +96 -0
  687. data/vendor/syntax/api/files/lib/syntax/version_rb.html +92 -0
  688. data/vendor/syntax/api/files/lib/syntax_rb.html +96 -0
  689. data/vendor/syntax/api/fr_class_index.html +56 -0
  690. data/vendor/syntax/api/fr_file_index.html +54 -0
  691. data/vendor/syntax/api/fr_method_index.html +65 -0
  692. data/vendor/syntax/api/index.html +26 -0
  693. data/vendor/syntax/api/rdoc-style.css +175 -0
  694. data/vendor/syntax/doc/manual-html/chapter-1.html +198 -0
  695. data/vendor/syntax/doc/manual-html/chapter-2.html +262 -0
  696. data/vendor/syntax/doc/manual-html/chapter-3.html +266 -0
  697. data/vendor/syntax/doc/manual-html/chapter-4.html +267 -0
  698. data/vendor/syntax/doc/manual-html/index.html +152 -0
  699. data/vendor/syntax/doc/manual-html/stylesheets/manual.css +270 -0
  700. data/vendor/syntax/doc/manual-html/stylesheets/ruby.css +17 -0
  701. data/vendor/syntax/doc/manual/chapter.erb +38 -0
  702. data/vendor/syntax/doc/manual/example.erb +18 -0
  703. data/vendor/syntax/doc/manual/index.erb +29 -0
  704. data/vendor/syntax/doc/manual/manual.rb +311 -0
  705. data/vendor/syntax/doc/manual/manual.yml +43 -0
  706. data/vendor/syntax/doc/manual/page.erb +87 -0
  707. data/vendor/syntax/doc/manual/parts/0000.txt +5 -0
  708. data/vendor/syntax/doc/manual/parts/0001.txt +16 -0
  709. data/vendor/syntax/doc/manual/parts/0002.txt +24 -0
  710. data/vendor/syntax/doc/manual/parts/0003.txt +6 -0
  711. data/vendor/syntax/doc/manual/parts/0004.txt +32 -0
  712. data/vendor/syntax/doc/manual/parts/0005.txt +18 -0
  713. data/vendor/syntax/doc/manual/parts/0006.txt +62 -0
  714. data/vendor/syntax/doc/manual/parts/0007.txt +3 -0
  715. data/vendor/syntax/doc/manual/parts/0008.txt +5 -0
  716. data/vendor/syntax/doc/manual/parts/0009.txt +29 -0
  717. data/vendor/syntax/doc/manual/parts/0010.txt +21 -0
  718. data/vendor/syntax/doc/manual/stylesheets/manual.css +270 -0
  719. data/vendor/syntax/doc/manual/stylesheets/ruby.css +17 -0
  720. data/vendor/syntax/doc/manual/tutorial.erb +30 -0
  721. data/vendor/syntax/lib/syntax.rb +38 -0
  722. data/vendor/syntax/lib/syntax/common.rb +163 -0
  723. data/vendor/syntax/lib/syntax/convertors/abstract.rb +27 -0
  724. data/vendor/syntax/lib/syntax/convertors/html.rb +51 -0
  725. data/vendor/syntax/lib/syntax/lang/ruby.rb +317 -0
  726. data/vendor/syntax/lib/syntax/lang/xml.rb +108 -0
  727. data/vendor/syntax/lib/syntax/lang/yaml.rb +105 -0
  728. data/vendor/syntax/lib/syntax/version.rb +9 -0
  729. data/vendor/syntax/setup.rb +1331 -0
  730. data/vendor/syntax/syntax.gemspec +24 -0
  731. data/vendor/syntax/test/ALL-TESTS.rb +5 -0
  732. data/vendor/syntax/test/syntax/tc_ruby.rb +871 -0
  733. data/vendor/syntax/test/syntax/tc_xml.rb +202 -0
  734. data/vendor/syntax/test/syntax/tc_yaml.rb +228 -0
  735. data/vendor/syntax/test/syntax/tokenizer_testcase.rb +40 -0
  736. data/vendor/syntax/test/tc_syntax.rb +22 -0
  737. data/vendor/uuidtools/CHANGELOG +4 -0
  738. data/vendor/uuidtools/README +13 -0
  739. data/vendor/uuidtools/install.rb +30 -0
  740. data/vendor/uuidtools/lib/uuidtools.rb +555 -0
  741. data/vendor/uuidtools/rakefile +112 -0
  742. metadata +1022 -0
@@ -0,0 +1,348 @@
1
+ /*
2
+ Lightbox JS: Fullsize Image Overlays
3
+ by Lokesh Dhakar - http://www.huddletogether.com
4
+
5
+ For more information on this script, visit:
6
+ http://huddletogether.com/projects/lightbox/
7
+
8
+ Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
9
+ (basically, do anything you want, just leave my name and link)
10
+
11
+ Table of Contents
12
+ -----------------
13
+ Configuration
14
+
15
+ Functions
16
+ - getPageScroll()
17
+ - getPageSize()
18
+ - pause()
19
+ - showLightbox()
20
+ - hideLightbox()
21
+ - initLightbox()
22
+ - addLoadEvent()
23
+
24
+ Function Calls
25
+ - addLoadEvent(initLightbox)
26
+
27
+ */
28
+
29
+
30
+
31
+ //
32
+ // Configuration
33
+ //
34
+
35
+ // If you would like to use a loading image, point to it in the next line, otherwise leave as-is.
36
+ var loadingImage = '/images/loading.gif';
37
+
38
+
39
+
40
+
41
+
42
+ //
43
+ // getPageScroll()
44
+ // Returns array with x,y page scroll values.
45
+ // Core code from - quirksmode.org
46
+ //
47
+ function getPageScroll(){
48
+
49
+ var yScroll;
50
+
51
+ if (self.pageYOffset) {
52
+ yScroll = self.pageYOffset;
53
+ } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
54
+ yScroll = document.documentElement.scrollTop;
55
+ } else if (document.body) {// all other Explorers
56
+ yScroll = document.body.scrollTop;
57
+ }
58
+
59
+ arrayPageScroll = new Array('',yScroll)
60
+ return arrayPageScroll;
61
+ }
62
+
63
+
64
+
65
+ //
66
+ // getPageSize()
67
+ // Returns array with page width, height and window width, height
68
+ // Core code from - quirksmode.org
69
+ // Edit for Firefox by pHaez
70
+ //
71
+ function getPageSize(){
72
+
73
+ var xScroll, yScroll;
74
+
75
+ if (window.innerHeight && window.scrollMaxY) {
76
+ xScroll = document.body.scrollWidth;
77
+ yScroll = window.innerHeight + window.scrollMaxY;
78
+ } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
79
+ xScroll = document.body.scrollWidth;
80
+ yScroll = document.body.scrollHeight;
81
+ } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
82
+ xScroll = document.body.offsetWidth;
83
+ yScroll = document.body.offsetHeight;
84
+ }
85
+
86
+ var windowWidth, windowHeight;
87
+ if (self.innerHeight) { // all except Explorer
88
+ windowWidth = self.innerWidth;
89
+ windowHeight = self.innerHeight;
90
+ } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
91
+ windowWidth = document.documentElement.clientWidth;
92
+ windowHeight = document.documentElement.clientHeight;
93
+ } else if (document.body) { // other Explorers
94
+ windowWidth = document.body.clientWidth;
95
+ windowHeight = document.body.clientHeight;
96
+ }
97
+
98
+ // for small pages with total height less then height of the viewport
99
+ if(yScroll < windowHeight){
100
+ pageHeight = windowHeight;
101
+ } else {
102
+ pageHeight = yScroll;
103
+ }
104
+
105
+ // for small pages with total width less then width of the viewport
106
+ if(xScroll < windowWidth){
107
+ pageWidth = windowWidth;
108
+ } else {
109
+ pageWidth = xScroll;
110
+ }
111
+
112
+
113
+ arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
114
+ return arrayPageSize;
115
+ }
116
+
117
+ //
118
+ // pause(numberMillis)
119
+ // Pauses code execution for specified time. Uses busy code, not good.
120
+ // Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
121
+ //
122
+ function pause(numberMillis) {
123
+ var now = new Date();
124
+ var exitTime = now.getTime() + numberMillis;
125
+ while (true) {
126
+ now = new Date();
127
+ if (now.getTime() > exitTime)
128
+ return;
129
+ }
130
+ }
131
+
132
+
133
+
134
+
135
+
136
+ //
137
+ // showLightbox()
138
+ // Preloads images. Pleaces new image in lightbox then centers and displays.
139
+ //
140
+ function showLightbox(objLink)
141
+ {
142
+ // prep objects
143
+ var objOverlay = document.getElementById('overlay');
144
+ var objLightbox = document.getElementById('lightbox');
145
+ var objCaption = document.getElementById('lightboxCaption');
146
+ var objImage = document.getElementById('lightboxImage');
147
+ var objLoadingImage = document.getElementById('loadingImage');
148
+
149
+ var arrayPageSize = getPageSize();
150
+ var arrayPageScroll = getPageScroll();
151
+
152
+ // center loadingImage if it exists
153
+ if (objLoadingImage) {
154
+ objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
155
+ objLoadingImage.style.left = (((arrayPageSize[0] - 40 - objLoadingImage.width) / 2) + 'px');
156
+ }
157
+
158
+ // set height of Overlay to take up whole page and show
159
+ objOverlay.style.height = (arrayPageSize[1] + 'px');
160
+ objOverlay.style.display = 'block';
161
+
162
+ // preload image
163
+ imgPreload = new Image();
164
+
165
+ imgPreload.onload=function(){
166
+ objImage.src = objLink.href;
167
+
168
+ // center lightbox and make sure that the top and left values are not negative
169
+ // and the image placed outside the viewport
170
+ var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
171
+ var lightboxLeft = ((arrayPageSize[0] - 40 - imgPreload.width) / 2);
172
+
173
+ objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
174
+ objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
175
+
176
+
177
+
178
+ if(objLink.getAttribute('title')){
179
+ objCaption.style.display = 'block';
180
+ objCaption.style.width = imgPreload.width + 'px';
181
+ objCaption.innerHTML = objLink.getAttribute('title');
182
+ } else {
183
+ objCaption.style.display = 'none';
184
+ }
185
+
186
+ // A small pause between the image loading and displaying is required with IE,
187
+ // this prevents the previous image displaying for a short burst causing flicker.
188
+ if (navigator.appVersion.indexOf("MSIE")!=-1){
189
+ pause(250);
190
+ }
191
+
192
+ objLightbox.style.display = 'block';
193
+
194
+ return false;
195
+ }
196
+
197
+ imgPreload.src = objLink.href;
198
+
199
+ }
200
+
201
+
202
+
203
+
204
+
205
+ //
206
+ // hideLightbox()
207
+ //
208
+ function hideLightbox()
209
+ {
210
+ // get objects
211
+ objOverlay = document.getElementById('overlay');
212
+ objLightbox = document.getElementById('lightbox');
213
+
214
+ // hide lightbox and overlay
215
+ objOverlay.style.display = 'none';
216
+ objLightbox.style.display = 'none';
217
+ }
218
+
219
+
220
+
221
+
222
+ //
223
+ // initLightbox()
224
+ // Function runs on window load, going through link tags looking for rel="lightbox".
225
+ // These links receive onclick events that enable the lightbox display for their targets.
226
+ // The function also inserts html markup at the top of the page which will be used as a
227
+ // container for the overlay pattern and the inline image.
228
+ //
229
+ function initLightbox()
230
+ {
231
+ if (!document.getElementsByTagName){ return; }
232
+ var anchors = document.getElementsByTagName("a");
233
+
234
+ // loop through all anchor tags
235
+ for (var i=0; i<anchors.length; i++){
236
+ var anchor = anchors[i];
237
+
238
+ if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")){
239
+ anchor.onclick = function () {showLightbox(this); return false;}
240
+ }
241
+ }
242
+
243
+ // the rest of this code inserts html at the top of the page that looks like this:
244
+ //
245
+ // <div id="overlay">
246
+ // <a href="#" onclick="hideLightbox(); return false;"><img id="loadingImage" /></a>
247
+ // </div>
248
+ // <div id="lightbox">
249
+ // <a href="#" onclick="hideLightbox(); return false;" title="Click anywhere to close image"><img /></a>
250
+ // <div id="lightboxCaption"></div>
251
+ // </div>
252
+
253
+ var objBody = document.getElementsByTagName("body").item(0);
254
+
255
+ // create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
256
+ var objOverlay = document.createElement("div");
257
+ objOverlay.setAttribute('id','overlay');
258
+ objOverlay.style.display = 'none';
259
+ objOverlay.style.position = 'absolute';
260
+ objOverlay.style.top = '0';
261
+ objOverlay.style.left = '0';
262
+ objOverlay.style.zIndex = '90';
263
+ objOverlay.style.width = '100%';
264
+ objBody.insertBefore(objOverlay, objBody.firstChild);
265
+
266
+ var arrayPageSize = getPageSize();
267
+ var arrayPageScroll = getPageScroll();
268
+
269
+ // preload and create loader image
270
+ var imgPreloader = new Image();
271
+
272
+ // if loader image found, create link to hide lightbox and create loadingimage
273
+ imgPreloader.onload=function(){
274
+
275
+ var objLoadingImageLink = document.createElement("a");
276
+ objLoadingImageLink.setAttribute('href','#');
277
+ objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
278
+ objOverlay.appendChild(objLoadingImageLink);
279
+
280
+ var objLoadingImage = document.createElement("img");
281
+ objLoadingImage.src = loadingImage;
282
+ objLoadingImage.setAttribute('id','loadingImage');
283
+ objLoadingImage.style.position = 'absolute';
284
+ objLoadingImage.style.zIndex = '150';
285
+ objLoadingImageLink.appendChild(objLoadingImage);
286
+
287
+ imgPreloader.onload=function(){}; // clear onLoad, as IE will flip out w/animated gifs
288
+
289
+ return false;
290
+ }
291
+
292
+ imgPreloader.src = loadingImage;
293
+
294
+ // create lightbox div, same note about styles as above
295
+ var objLightbox = document.createElement("div");
296
+ objLightbox.setAttribute('id','lightbox');
297
+ objLightbox.style.display = 'none';
298
+ objLightbox.style.position = 'absolute';
299
+ objLightbox.style.zIndex = '100';
300
+ objBody.insertBefore(objLightbox, objOverlay.nextSibling);
301
+
302
+ // create link
303
+ var objLink = document.createElement("a");
304
+ objLink.setAttribute('href','#');
305
+ objLink.setAttribute('title','Click to close');
306
+ objLink.onclick = function () {hideLightbox(); return false;}
307
+ objLightbox.appendChild(objLink);
308
+
309
+ // create image
310
+ var objImage = document.createElement("img");
311
+ objImage.setAttribute('id','lightboxImage');
312
+ objLink.appendChild(objImage);
313
+
314
+ // create caption
315
+ var objCaption = document.createElement("div");
316
+ objCaption.setAttribute('id','lightboxCaption');
317
+ objCaption.style.display = 'none';
318
+ objLightbox.appendChild(objCaption);
319
+
320
+ }
321
+
322
+
323
+
324
+
325
+ //
326
+ // addLoadEvent()
327
+ // Adds event to window.onload without overwriting currently assigned onload functions.
328
+ // Function found at Simon Willison's weblog - http://simon.incutio.com/
329
+ //
330
+ function addLoadEvent(func)
331
+ {
332
+ var oldonload = window.onload;
333
+ if (typeof window.onload != 'function'){
334
+ window.onload = func;
335
+ } else {
336
+ window.onload = function(){
337
+ oldonload();
338
+ func();
339
+ }
340
+ }
341
+
342
+ }
343
+
344
+
345
+
346
+
347
+ //addLoadEvent(initLightbox); // run initLightbox onLoad
348
+ register_onload(initLightbox);
@@ -0,0 +1,1985 @@
1
+ /* Prototype JavaScript framework, version 1.5.0_pre1
2
+ * (c) 2005 Sam Stephenson <sam@conio.net>
3
+ *
4
+ * Prototype is freely distributable under the terms of an MIT-style license.
5
+ * For details, see the Prototype web site: http://prototype.conio.net/
6
+ *
7
+ /*--------------------------------------------------------------------------*/
8
+
9
+ var Prototype = {
10
+ Version: '1.5.0_pre1',
11
+ ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
12
+
13
+ emptyFunction: function() {},
14
+ K: function(x) {return x}
15
+ }
16
+
17
+ var Class = {
18
+ create: function() {
19
+ return function() {
20
+ this.initialize.apply(this, arguments);
21
+ }
22
+ }
23
+ }
24
+
25
+ var Abstract = new Object();
26
+
27
+ Object.extend = function(destination, source) {
28
+ for (property in source) {
29
+ destination[property] = source[property];
30
+ }
31
+ return destination;
32
+ }
33
+
34
+ Object.inspect = function(object) {
35
+ try {
36
+ if (object == undefined) return 'undefined';
37
+ if (object == null) return 'null';
38
+ return object.inspect ? object.inspect() : object.toString();
39
+ } catch (e) {
40
+ if (e instanceof RangeError) return '...';
41
+ throw e;
42
+ }
43
+ }
44
+
45
+ Function.prototype.bind = function() {
46
+ var __method = this, args = $A(arguments), object = args.shift();
47
+ return function() {
48
+ return __method.apply(object, args.concat($A(arguments)));
49
+ }
50
+ }
51
+
52
+ Function.prototype.bindAsEventListener = function(object) {
53
+ var __method = this;
54
+ return function(event) {
55
+ return __method.call(object, event || window.event);
56
+ }
57
+ }
58
+
59
+ Object.extend(Number.prototype, {
60
+ toColorPart: function() {
61
+ var digits = this.toString(16);
62
+ if (this < 16) return '0' + digits;
63
+ return digits;
64
+ },
65
+
66
+ succ: function() {
67
+ return this + 1;
68
+ },
69
+
70
+ times: function(iterator) {
71
+ $R(0, this, true).each(iterator);
72
+ return this;
73
+ }
74
+ });
75
+
76
+ var Try = {
77
+ these: function() {
78
+ var returnValue;
79
+
80
+ for (var i = 0; i < arguments.length; i++) {
81
+ var lambda = arguments[i];
82
+ try {
83
+ returnValue = lambda();
84
+ break;
85
+ } catch (e) {}
86
+ }
87
+
88
+ return returnValue;
89
+ }
90
+ }
91
+
92
+ /*--------------------------------------------------------------------------*/
93
+
94
+ var PeriodicalExecuter = Class.create();
95
+ PeriodicalExecuter.prototype = {
96
+ initialize: function(callback, frequency) {
97
+ this.callback = callback;
98
+ this.frequency = frequency;
99
+ this.currentlyExecuting = false;
100
+
101
+ this.registerCallback();
102
+ },
103
+
104
+ registerCallback: function() {
105
+ setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
106
+ },
107
+
108
+ onTimerEvent: function() {
109
+ if (!this.currentlyExecuting) {
110
+ try {
111
+ this.currentlyExecuting = true;
112
+ this.callback();
113
+ } finally {
114
+ this.currentlyExecuting = false;
115
+ }
116
+ }
117
+ }
118
+ }
119
+ Object.extend(String.prototype, {
120
+ gsub: function(pattern, replacement) {
121
+ var result = '', source = this, match;
122
+ replacement = arguments.callee.prepareReplacement(replacement);
123
+
124
+ while (source.length > 0) {
125
+ if (match = source.match(pattern)) {
126
+ result += source.slice(0, match.index);
127
+ result += (replacement(match) || '').toString();
128
+ source = source.slice(match.index + match[0].length);
129
+ } else {
130
+ result += source, source = '';
131
+ }
132
+ }
133
+ return result;
134
+ },
135
+
136
+ sub: function(pattern, replacement, count) {
137
+ replacement = this.gsub.prepareReplacement(replacement);
138
+ count = count === undefined ? 1 : count;
139
+
140
+ return this.gsub(pattern, function(match) {
141
+ if (--count < 0) return match[0];
142
+ return replacement(match);
143
+ });
144
+ },
145
+
146
+ scan: function(pattern, iterator) {
147
+ this.gsub(pattern, iterator);
148
+ return this;
149
+ },
150
+
151
+ truncate: function(length, truncation) {
152
+ length = length || 30;
153
+ truncation = truncation === undefined ? '...' : truncation;
154
+ return this.length > length ?
155
+ this.slice(0, length - truncation.length) + truncation : this;
156
+ },
157
+
158
+ strip: function() {
159
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
160
+ },
161
+
162
+ stripTags: function() {
163
+ return this.replace(/<\/?[^>]+>/gi, '');
164
+ },
165
+
166
+ stripScripts: function() {
167
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
168
+ },
169
+
170
+ extractScripts: function() {
171
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
172
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
173
+ return (this.match(matchAll) || []).map(function(scriptTag) {
174
+ return (scriptTag.match(matchOne) || ['', ''])[1];
175
+ });
176
+ },
177
+
178
+ evalScripts: function() {
179
+ return this.extractScripts().map(eval);
180
+ },
181
+
182
+ escapeHTML: function() {
183
+ var div = document.createElement('div');
184
+ var text = document.createTextNode(this);
185
+ div.appendChild(text);
186
+ return div.innerHTML;
187
+ },
188
+
189
+ unescapeHTML: function() {
190
+ var div = document.createElement('div');
191
+ div.innerHTML = this.stripTags();
192
+ return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
193
+ },
194
+
195
+ toQueryParams: function() {
196
+ var pairs = this.match(/^\??(.*)$/)[1].split('&');
197
+ return pairs.inject({}, function(params, pairString) {
198
+ var pair = pairString.split('=');
199
+ params[pair[0]] = pair[1];
200
+ return params;
201
+ });
202
+ },
203
+
204
+ toArray: function() {
205
+ return this.split('');
206
+ },
207
+
208
+ camelize: function() {
209
+ var oStringList = this.split('-');
210
+ if (oStringList.length == 1) return oStringList[0];
211
+
212
+ var camelizedString = this.indexOf('-') == 0
213
+ ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
214
+ : oStringList[0];
215
+
216
+ for (var i = 1, len = oStringList.length; i < len; i++) {
217
+ var s = oStringList[i];
218
+ camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
219
+ }
220
+
221
+ return camelizedString;
222
+ },
223
+
224
+ inspect: function() {
225
+ return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'";
226
+ }
227
+ });
228
+
229
+ String.prototype.gsub.prepareReplacement = function(replacement) {
230
+ if (typeof replacement == 'function') return replacement;
231
+ var template = new Template(replacement);
232
+ return function(match) { return template.evaluate(match) };
233
+ }
234
+
235
+ String.prototype.parseQuery = String.prototype.toQueryParams;
236
+
237
+ var Template = Class.create();
238
+ Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
239
+ Template.prototype = {
240
+ initialize: function(template, pattern) {
241
+ this.template = template.toString();
242
+ this.pattern = pattern || Template.Pattern;
243
+ },
244
+
245
+ evaluate: function(object) {
246
+ return this.template.gsub(this.pattern, function(match) {
247
+ var before = match[1];
248
+ if (before == '\\') return match[2];
249
+ return before + (object[match[3]] || '').toString();
250
+ });
251
+ }
252
+ }
253
+
254
+ var $break = new Object();
255
+ var $continue = new Object();
256
+
257
+ var Enumerable = {
258
+ each: function(iterator) {
259
+ var index = 0;
260
+ try {
261
+ this._each(function(value) {
262
+ try {
263
+ iterator(value, index++);
264
+ } catch (e) {
265
+ if (e != $continue) throw e;
266
+ }
267
+ });
268
+ } catch (e) {
269
+ if (e != $break) throw e;
270
+ }
271
+ },
272
+
273
+ all: function(iterator) {
274
+ var result = true;
275
+ this.each(function(value, index) {
276
+ result = result && !!(iterator || Prototype.K)(value, index);
277
+ if (!result) throw $break;
278
+ });
279
+ return result;
280
+ },
281
+
282
+ any: function(iterator) {
283
+ var result = true;
284
+ this.each(function(value, index) {
285
+ if (result = !!(iterator || Prototype.K)(value, index))
286
+ throw $break;
287
+ });
288
+ return result;
289
+ },
290
+
291
+ collect: function(iterator) {
292
+ var results = [];
293
+ this.each(function(value, index) {
294
+ results.push(iterator(value, index));
295
+ });
296
+ return results;
297
+ },
298
+
299
+ detect: function (iterator) {
300
+ var result;
301
+ this.each(function(value, index) {
302
+ if (iterator(value, index)) {
303
+ result = value;
304
+ throw $break;
305
+ }
306
+ });
307
+ return result;
308
+ },
309
+
310
+ findAll: function(iterator) {
311
+ var results = [];
312
+ this.each(function(value, index) {
313
+ if (iterator(value, index))
314
+ results.push(value);
315
+ });
316
+ return results;
317
+ },
318
+
319
+ grep: function(pattern, iterator) {
320
+ var results = [];
321
+ this.each(function(value, index) {
322
+ var stringValue = value.toString();
323
+ if (stringValue.match(pattern))
324
+ results.push((iterator || Prototype.K)(value, index));
325
+ })
326
+ return results;
327
+ },
328
+
329
+ include: function(object) {
330
+ var found = false;
331
+ this.each(function(value) {
332
+ if (value == object) {
333
+ found = true;
334
+ throw $break;
335
+ }
336
+ });
337
+ return found;
338
+ },
339
+
340
+ inject: function(memo, iterator) {
341
+ this.each(function(value, index) {
342
+ memo = iterator(memo, value, index);
343
+ });
344
+ return memo;
345
+ },
346
+
347
+ invoke: function(method) {
348
+ var args = $A(arguments).slice(1);
349
+ return this.collect(function(value) {
350
+ return value[method].apply(value, args);
351
+ });
352
+ },
353
+
354
+ max: function(iterator) {
355
+ var result;
356
+ this.each(function(value, index) {
357
+ value = (iterator || Prototype.K)(value, index);
358
+ if (value >= (result || value))
359
+ result = value;
360
+ });
361
+ return result;
362
+ },
363
+
364
+ min: function(iterator) {
365
+ var result;
366
+ this.each(function(value, index) {
367
+ value = (iterator || Prototype.K)(value, index);
368
+ if (value <= (result || value))
369
+ result = value;
370
+ });
371
+ return result;
372
+ },
373
+
374
+ partition: function(iterator) {
375
+ var trues = [], falses = [];
376
+ this.each(function(value, index) {
377
+ ((iterator || Prototype.K)(value, index) ?
378
+ trues : falses).push(value);
379
+ });
380
+ return [trues, falses];
381
+ },
382
+
383
+ pluck: function(property) {
384
+ var results = [];
385
+ this.each(function(value, index) {
386
+ results.push(value[property]);
387
+ });
388
+ return results;
389
+ },
390
+
391
+ reject: function(iterator) {
392
+ var results = [];
393
+ this.each(function(value, index) {
394
+ if (!iterator(value, index))
395
+ results.push(value);
396
+ });
397
+ return results;
398
+ },
399
+
400
+ sortBy: function(iterator) {
401
+ return this.collect(function(value, index) {
402
+ return {value: value, criteria: iterator(value, index)};
403
+ }).sort(function(left, right) {
404
+ var a = left.criteria, b = right.criteria;
405
+ return a < b ? -1 : a > b ? 1 : 0;
406
+ }).pluck('value');
407
+ },
408
+
409
+ toArray: function() {
410
+ return this.collect(Prototype.K);
411
+ },
412
+
413
+ zip: function() {
414
+ var iterator = Prototype.K, args = $A(arguments);
415
+ if (typeof args.last() == 'function')
416
+ iterator = args.pop();
417
+
418
+ var collections = [this].concat(args).map($A);
419
+ return this.map(function(value, index) {
420
+ return iterator(collections.pluck(index));
421
+ });
422
+ },
423
+
424
+ inspect: function() {
425
+ return '#<Enumerable:' + this.toArray().inspect() + '>';
426
+ }
427
+ }
428
+
429
+ Object.extend(Enumerable, {
430
+ map: Enumerable.collect,
431
+ find: Enumerable.detect,
432
+ select: Enumerable.findAll,
433
+ member: Enumerable.include,
434
+ entries: Enumerable.toArray
435
+ });
436
+ var $A = Array.from = function(iterable) {
437
+ if (!iterable) return [];
438
+ if (iterable.toArray) {
439
+ return iterable.toArray();
440
+ } else {
441
+ var results = [];
442
+ for (var i = 0; i < iterable.length; i++)
443
+ results.push(iterable[i]);
444
+ return results;
445
+ }
446
+ }
447
+
448
+ Object.extend(Array.prototype, Enumerable);
449
+
450
+ Array.prototype._reverse = Array.prototype.reverse;
451
+
452
+ Object.extend(Array.prototype, {
453
+ _each: function(iterator) {
454
+ for (var i = 0; i < this.length; i++)
455
+ iterator(this[i]);
456
+ },
457
+
458
+ clear: function() {
459
+ this.length = 0;
460
+ return this;
461
+ },
462
+
463
+ first: function() {
464
+ return this[0];
465
+ },
466
+
467
+ last: function() {
468
+ return this[this.length - 1];
469
+ },
470
+
471
+ compact: function() {
472
+ return this.select(function(value) {
473
+ return value != undefined || value != null;
474
+ });
475
+ },
476
+
477
+ flatten: function() {
478
+ return this.inject([], function(array, value) {
479
+ return array.concat(value.constructor == Array ?
480
+ value.flatten() : [value]);
481
+ });
482
+ },
483
+
484
+ without: function() {
485
+ var values = $A(arguments);
486
+ return this.select(function(value) {
487
+ return !values.include(value);
488
+ });
489
+ },
490
+
491
+ indexOf: function(object) {
492
+ for (var i = 0; i < this.length; i++)
493
+ if (this[i] == object) return i;
494
+ return -1;
495
+ },
496
+
497
+ reverse: function(inline) {
498
+ return (inline !== false ? this : this.toArray())._reverse();
499
+ },
500
+
501
+ shift: function() {
502
+ var result = this[0];
503
+ for (var i = 0; i < this.length - 1; i++)
504
+ this[i] = this[i + 1];
505
+ this.length--;
506
+ return result;
507
+ },
508
+
509
+ inspect: function() {
510
+ return '[' + this.map(Object.inspect).join(', ') + ']';
511
+ }
512
+ });
513
+ var Hash = {
514
+ _each: function(iterator) {
515
+ for (key in this) {
516
+ var value = this[key];
517
+ if (typeof value == 'function') continue;
518
+
519
+ var pair = [key, value];
520
+ pair.key = key;
521
+ pair.value = value;
522
+ iterator(pair);
523
+ }
524
+ },
525
+
526
+ keys: function() {
527
+ return this.pluck('key');
528
+ },
529
+
530
+ values: function() {
531
+ return this.pluck('value');
532
+ },
533
+
534
+ merge: function(hash) {
535
+ return $H(hash).inject($H(this), function(mergedHash, pair) {
536
+ mergedHash[pair.key] = pair.value;
537
+ return mergedHash;
538
+ });
539
+ },
540
+
541
+ toQueryString: function() {
542
+ return this.map(function(pair) {
543
+ return pair.map(encodeURIComponent).join('=');
544
+ }).join('&');
545
+ },
546
+
547
+ inspect: function() {
548
+ return '#<Hash:{' + this.map(function(pair) {
549
+ return pair.map(Object.inspect).join(': ');
550
+ }).join(', ') + '}>';
551
+ }
552
+ }
553
+
554
+ function $H(object) {
555
+ var hash = Object.extend({}, object || {});
556
+ Object.extend(hash, Enumerable);
557
+ Object.extend(hash, Hash);
558
+ return hash;
559
+ }
560
+ ObjectRange = Class.create();
561
+ Object.extend(ObjectRange.prototype, Enumerable);
562
+ Object.extend(ObjectRange.prototype, {
563
+ initialize: function(start, end, exclusive) {
564
+ this.start = start;
565
+ this.end = end;
566
+ this.exclusive = exclusive;
567
+ },
568
+
569
+ _each: function(iterator) {
570
+ var value = this.start;
571
+ do {
572
+ iterator(value);
573
+ value = value.succ();
574
+ } while (this.include(value));
575
+ },
576
+
577
+ include: function(value) {
578
+ if (value < this.start)
579
+ return false;
580
+ if (this.exclusive)
581
+ return value < this.end;
582
+ return value <= this.end;
583
+ }
584
+ });
585
+
586
+ var $R = function(start, end, exclusive) {
587
+ return new ObjectRange(start, end, exclusive);
588
+ }
589
+
590
+ var Ajax = {
591
+ getTransport: function() {
592
+ return Try.these(
593
+ function() {return new ActiveXObject('Msxml2.XMLHTTP')},
594
+ function() {return new ActiveXObject('Microsoft.XMLHTTP')},
595
+ function() {return new XMLHttpRequest()}
596
+ ) || false;
597
+ },
598
+
599
+ activeRequestCount: 0
600
+ }
601
+
602
+ Ajax.Responders = {
603
+ responders: [],
604
+
605
+ _each: function(iterator) {
606
+ this.responders._each(iterator);
607
+ },
608
+
609
+ register: function(responderToAdd) {
610
+ if (!this.include(responderToAdd))
611
+ this.responders.push(responderToAdd);
612
+ },
613
+
614
+ unregister: function(responderToRemove) {
615
+ this.responders = this.responders.without(responderToRemove);
616
+ },
617
+
618
+ dispatch: function(callback, request, transport, json) {
619
+ this.each(function(responder) {
620
+ if (responder[callback] && typeof responder[callback] == 'function') {
621
+ try {
622
+ responder[callback].apply(responder, [request, transport, json]);
623
+ } catch (e) {}
624
+ }
625
+ });
626
+ }
627
+ };
628
+
629
+ Object.extend(Ajax.Responders, Enumerable);
630
+
631
+ Ajax.Responders.register({
632
+ onCreate: function() {
633
+ Ajax.activeRequestCount++;
634
+ },
635
+
636
+ onComplete: function() {
637
+ Ajax.activeRequestCount--;
638
+ }
639
+ });
640
+
641
+ Ajax.Base = function() {};
642
+ Ajax.Base.prototype = {
643
+ setOptions: function(options) {
644
+ this.options = {
645
+ method: 'post',
646
+ asynchronous: true,
647
+ parameters: ''
648
+ }
649
+ Object.extend(this.options, options || {});
650
+ },
651
+
652
+ responseIsSuccess: function() {
653
+ return this.transport.status == undefined
654
+ || this.transport.status == 0
655
+ || (this.transport.status >= 200 && this.transport.status < 300);
656
+ },
657
+
658
+ responseIsFailure: function() {
659
+ return !this.responseIsSuccess();
660
+ }
661
+ }
662
+
663
+ Ajax.Request = Class.create();
664
+ Ajax.Request.Events =
665
+ ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
666
+
667
+ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
668
+ initialize: function(url, options) {
669
+ this.transport = Ajax.getTransport();
670
+ this.setOptions(options);
671
+ this.request(url);
672
+ },
673
+
674
+ request: function(url) {
675
+ var parameters = this.options.parameters || '';
676
+ if (parameters.length > 0) parameters += '&_=';
677
+
678
+ try {
679
+ this.url = url;
680
+ if (this.options.method == 'get' && parameters.length > 0)
681
+ this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
682
+
683
+ Ajax.Responders.dispatch('onCreate', this, this.transport);
684
+
685
+ this.transport.open(this.options.method, this.url,
686
+ this.options.asynchronous);
687
+
688
+ if (this.options.asynchronous) {
689
+ this.transport.onreadystatechange = this.onStateChange.bind(this);
690
+ setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
691
+ }
692
+
693
+ this.setRequestHeaders();
694
+
695
+ var body = this.options.postBody ? this.options.postBody : parameters;
696
+ this.transport.send(this.options.method == 'post' ? body : null);
697
+
698
+ } catch (e) {
699
+ this.dispatchException(e);
700
+ }
701
+ },
702
+
703
+ setRequestHeaders: function() {
704
+ var requestHeaders =
705
+ ['X-Requested-With', 'XMLHttpRequest',
706
+ 'X-Prototype-Version', Prototype.Version,
707
+ 'Accept', 'text/javascript, text/html, application/xml, text/xml, */*'];
708
+
709
+ if (this.options.method == 'post') {
710
+ requestHeaders.push('Content-type',
711
+ 'application/x-www-form-urlencoded');
712
+
713
+ /* Force "Connection: close" for Mozilla browsers to work around
714
+ * a bug where XMLHttpReqeuest sends an incorrect Content-length
715
+ * header. See Mozilla Bugzilla #246651.
716
+ */
717
+ if (this.transport.overrideMimeType)
718
+ requestHeaders.push('Connection', 'close');
719
+ }
720
+
721
+ if (this.options.requestHeaders)
722
+ requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
723
+
724
+ for (var i = 0; i < requestHeaders.length; i += 2)
725
+ this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
726
+ },
727
+
728
+ onStateChange: function() {
729
+ var readyState = this.transport.readyState;
730
+ if (readyState != 1)
731
+ this.respondToReadyState(this.transport.readyState);
732
+ },
733
+
734
+ header: function(name) {
735
+ try {
736
+ return this.transport.getResponseHeader(name);
737
+ } catch (e) {}
738
+ },
739
+
740
+ evalJSON: function() {
741
+ try {
742
+ return eval(this.header('X-JSON'));
743
+ } catch (e) {}
744
+ },
745
+
746
+ evalResponse: function() {
747
+ try {
748
+ return eval(this.transport.responseText);
749
+ } catch (e) {
750
+ this.dispatchException(e);
751
+ }
752
+ },
753
+
754
+ respondToReadyState: function(readyState) {
755
+ var event = Ajax.Request.Events[readyState];
756
+ var transport = this.transport, json = this.evalJSON();
757
+
758
+ if (event == 'Complete') {
759
+ try {
760
+ (this.options['on' + this.transport.status]
761
+ || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
762
+ || Prototype.emptyFunction)(transport, json);
763
+ } catch (e) {
764
+ this.dispatchException(e);
765
+ }
766
+
767
+ if ((this.header('Content-type') || '').match(/^text\/javascript/i))
768
+ this.evalResponse();
769
+ }
770
+
771
+ try {
772
+ (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
773
+ Ajax.Responders.dispatch('on' + event, this, transport, json);
774
+ } catch (e) {
775
+ this.dispatchException(e);
776
+ }
777
+
778
+ /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
779
+ if (event == 'Complete')
780
+ this.transport.onreadystatechange = Prototype.emptyFunction;
781
+ },
782
+
783
+ dispatchException: function(exception) {
784
+ (this.options.onException || Prototype.emptyFunction)(this, exception);
785
+ Ajax.Responders.dispatch('onException', this, exception);
786
+ }
787
+ });
788
+
789
+ Ajax.Updater = Class.create();
790
+
791
+ Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
792
+ initialize: function(container, url, options) {
793
+ this.containers = {
794
+ success: container.success ? $(container.success) : $(container),
795
+ failure: container.failure ? $(container.failure) :
796
+ (container.success ? null : $(container))
797
+ }
798
+
799
+ this.transport = Ajax.getTransport();
800
+ this.setOptions(options);
801
+
802
+ var onComplete = this.options.onComplete || Prototype.emptyFunction;
803
+ this.options.onComplete = (function(transport, object) {
804
+ this.updateContent();
805
+ onComplete(transport, object);
806
+ }).bind(this);
807
+
808
+ this.request(url);
809
+ },
810
+
811
+ updateContent: function() {
812
+ var receiver = this.responseIsSuccess() ?
813
+ this.containers.success : this.containers.failure;
814
+ var response = this.transport.responseText;
815
+
816
+ if (!this.options.evalScripts)
817
+ response = response.stripScripts();
818
+
819
+ if (receiver) {
820
+ if (this.options.insertion) {
821
+ new this.options.insertion(receiver, response);
822
+ } else {
823
+ Element.update(receiver, response);
824
+ }
825
+ }
826
+
827
+ if (this.responseIsSuccess()) {
828
+ if (this.onComplete)
829
+ setTimeout(this.onComplete.bind(this), 10);
830
+ }
831
+ }
832
+ });
833
+
834
+ Ajax.PeriodicalUpdater = Class.create();
835
+ Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
836
+ initialize: function(container, url, options) {
837
+ this.setOptions(options);
838
+ this.onComplete = this.options.onComplete;
839
+
840
+ this.frequency = (this.options.frequency || 2);
841
+ this.decay = (this.options.decay || 1);
842
+
843
+ this.updater = {};
844
+ this.container = container;
845
+ this.url = url;
846
+
847
+ this.start();
848
+ },
849
+
850
+ start: function() {
851
+ this.options.onComplete = this.updateComplete.bind(this);
852
+ this.onTimerEvent();
853
+ },
854
+
855
+ stop: function() {
856
+ this.updater.onComplete = undefined;
857
+ clearTimeout(this.timer);
858
+ (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
859
+ },
860
+
861
+ updateComplete: function(request) {
862
+ if (this.options.decay) {
863
+ this.decay = (request.responseText == this.lastText ?
864
+ this.decay * this.options.decay : 1);
865
+
866
+ this.lastText = request.responseText;
867
+ }
868
+ this.timer = setTimeout(this.onTimerEvent.bind(this),
869
+ this.decay * this.frequency * 1000);
870
+ },
871
+
872
+ onTimerEvent: function() {
873
+ this.updater = new Ajax.Updater(this.container, this.url, this.options);
874
+ }
875
+ });
876
+ function $() {
877
+ var results = [], element;
878
+ for (var i = 0; i < arguments.length; i++) {
879
+ element = arguments[i];
880
+ if (typeof element == 'string')
881
+ element = document.getElementById(element);
882
+ results.push(Element.extend(element));
883
+ }
884
+ return results.length < 2 ? results[0] : results;
885
+ }
886
+
887
+ document.getElementsByClassName = function(className, parentElement) {
888
+ var children = ($(parentElement) || document.body).getElementsByTagName('*');
889
+ return $A(children).inject([], function(elements, child) {
890
+ if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
891
+ elements.push(Element.extend(child));
892
+ return elements;
893
+ });
894
+ }
895
+
896
+ /*--------------------------------------------------------------------------*/
897
+
898
+ if (!window.Element)
899
+ var Element = new Object();
900
+
901
+ Element.extend = function(element) {
902
+ if (!element) return;
903
+
904
+ if (!element._extended && element.tagName && element != window) {
905
+ var methods = Element.Methods;
906
+ for (property in methods) {
907
+ var value = methods[property];
908
+ if (typeof value == 'function')
909
+ element[property] = value.bind(null, element);
910
+ }
911
+ }
912
+
913
+ element._extended = true;
914
+ return element;
915
+ }
916
+
917
+ Element.Methods = {
918
+ visible: function(element) {
919
+ return $(element).style.display != 'none';
920
+ },
921
+
922
+ toggle: function() {
923
+ for (var i = 0; i < arguments.length; i++) {
924
+ var element = $(arguments[i]);
925
+ Element[Element.visible(element) ? 'hide' : 'show'](element);
926
+ }
927
+ },
928
+
929
+ hide: function() {
930
+ for (var i = 0; i < arguments.length; i++) {
931
+ var element = $(arguments[i]);
932
+ element.style.display = 'none';
933
+ }
934
+ },
935
+
936
+ show: function() {
937
+ for (var i = 0; i < arguments.length; i++) {
938
+ var element = $(arguments[i]);
939
+ element.style.display = '';
940
+ }
941
+ },
942
+
943
+ remove: function(element) {
944
+ element = $(element);
945
+ element.parentNode.removeChild(element);
946
+ },
947
+
948
+ update: function(element, html) {
949
+ $(element).innerHTML = html.stripScripts();
950
+ setTimeout(function() {html.evalScripts()}, 10);
951
+ },
952
+
953
+ replace: function(element, html) {
954
+ element = $(element);
955
+ if (element.outerHTML) {
956
+ element.outerHTML = html.stripScripts();
957
+ } else {
958
+ var range = element.ownerDocument.createRange();
959
+ range.selectNodeContents(element);
960
+ element.parentNode.replaceChild(
961
+ range.createContextualFragment(html.stripScripts()), element);
962
+ }
963
+ setTimeout(function() {html.evalScripts()}, 10);
964
+ },
965
+
966
+ getHeight: function(element) {
967
+ element = $(element);
968
+ return element.offsetHeight;
969
+ },
970
+
971
+ classNames: function(element) {
972
+ return new Element.ClassNames(element);
973
+ },
974
+
975
+ hasClassName: function(element, className) {
976
+ if (!(element = $(element))) return;
977
+ return Element.classNames(element).include(className);
978
+ },
979
+
980
+ addClassName: function(element, className) {
981
+ if (!(element = $(element))) return;
982
+ return Element.classNames(element).add(className);
983
+ },
984
+
985
+ removeClassName: function(element, className) {
986
+ if (!(element = $(element))) return;
987
+ return Element.classNames(element).remove(className);
988
+ },
989
+
990
+ // removes whitespace-only text node children
991
+ cleanWhitespace: function(element) {
992
+ element = $(element);
993
+ for (var i = 0; i < element.childNodes.length; i++) {
994
+ var node = element.childNodes[i];
995
+ if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
996
+ Element.remove(node);
997
+ }
998
+ },
999
+
1000
+ empty: function(element) {
1001
+ return $(element).innerHTML.match(/^\s*$/);
1002
+ },
1003
+
1004
+ childOf: function(element, ancestor) {
1005
+ element = $(element), ancestor = $(ancestor);
1006
+ while (element = element.parentNode)
1007
+ if (element == ancestor) return true;
1008
+ return false;
1009
+ },
1010
+
1011
+ scrollTo: function(element) {
1012
+ element = $(element);
1013
+ var x = element.x ? element.x : element.offsetLeft,
1014
+ y = element.y ? element.y : element.offsetTop;
1015
+ window.scrollTo(x, y);
1016
+ },
1017
+
1018
+ getStyle: function(element, style) {
1019
+ element = $(element);
1020
+ var value = element.style[style.camelize()];
1021
+ if (!value) {
1022
+ if (document.defaultView && document.defaultView.getComputedStyle) {
1023
+ var css = document.defaultView.getComputedStyle(element, null);
1024
+ value = css ? css.getPropertyValue(style) : null;
1025
+ } else if (element.currentStyle) {
1026
+ value = element.currentStyle[style.camelize()];
1027
+ }
1028
+ }
1029
+
1030
+ if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
1031
+ if (Element.getStyle(element, 'position') == 'static') value = 'auto';
1032
+
1033
+ return value == 'auto' ? null : value;
1034
+ },
1035
+
1036
+ setStyle: function(element, style) {
1037
+ element = $(element);
1038
+ for (name in style)
1039
+ element.style[name.camelize()] = style[name];
1040
+ },
1041
+
1042
+ getDimensions: function(element) {
1043
+ element = $(element);
1044
+ if (Element.getStyle(element, 'display') != 'none')
1045
+ return {width: element.offsetWidth, height: element.offsetHeight};
1046
+
1047
+ // All *Width and *Height properties give 0 on elements with display none,
1048
+ // so enable the element temporarily
1049
+ var els = element.style;
1050
+ var originalVisibility = els.visibility;
1051
+ var originalPosition = els.position;
1052
+ els.visibility = 'hidden';
1053
+ els.position = 'absolute';
1054
+ els.display = '';
1055
+ var originalWidth = element.clientWidth;
1056
+ var originalHeight = element.clientHeight;
1057
+ els.display = 'none';
1058
+ els.position = originalPosition;
1059
+ els.visibility = originalVisibility;
1060
+ return {width: originalWidth, height: originalHeight};
1061
+ },
1062
+
1063
+ makePositioned: function(element) {
1064
+ element = $(element);
1065
+ var pos = Element.getStyle(element, 'position');
1066
+ if (pos == 'static' || !pos) {
1067
+ element._madePositioned = true;
1068
+ element.style.position = 'relative';
1069
+ // Opera returns the offset relative to the positioning context, when an
1070
+ // element is position relative but top and left have not been defined
1071
+ if (window.opera) {
1072
+ element.style.top = 0;
1073
+ element.style.left = 0;
1074
+ }
1075
+ }
1076
+ },
1077
+
1078
+ undoPositioned: function(element) {
1079
+ element = $(element);
1080
+ if (element._madePositioned) {
1081
+ element._madePositioned = undefined;
1082
+ element.style.position =
1083
+ element.style.top =
1084
+ element.style.left =
1085
+ element.style.bottom =
1086
+ element.style.right = '';
1087
+ }
1088
+ },
1089
+
1090
+ makeClipping: function(element) {
1091
+ element = $(element);
1092
+ if (element._overflow) return;
1093
+ element._overflow = element.style.overflow;
1094
+ if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
1095
+ element.style.overflow = 'hidden';
1096
+ },
1097
+
1098
+ undoClipping: function(element) {
1099
+ element = $(element);
1100
+ if (element._overflow) return;
1101
+ element.style.overflow = element._overflow;
1102
+ element._overflow = undefined;
1103
+ }
1104
+ }
1105
+
1106
+ Object.extend(Element, Element.Methods);
1107
+
1108
+ var Toggle = new Object();
1109
+ Toggle.display = Element.toggle;
1110
+
1111
+ /*--------------------------------------------------------------------------*/
1112
+
1113
+ Abstract.Insertion = function(adjacency) {
1114
+ this.adjacency = adjacency;
1115
+ }
1116
+
1117
+ Abstract.Insertion.prototype = {
1118
+ initialize: function(element, content) {
1119
+ this.element = $(element);
1120
+ this.content = content.stripScripts();
1121
+
1122
+ if (this.adjacency && this.element.insertAdjacentHTML) {
1123
+ try {
1124
+ this.element.insertAdjacentHTML(this.adjacency, this.content);
1125
+ } catch (e) {
1126
+ if (this.element.tagName.toLowerCase() == 'tbody') {
1127
+ this.insertContent(this.contentFromAnonymousTable());
1128
+ } else {
1129
+ throw e;
1130
+ }
1131
+ }
1132
+ } else {
1133
+ this.range = this.element.ownerDocument.createRange();
1134
+ if (this.initializeRange) this.initializeRange();
1135
+ this.insertContent([this.range.createContextualFragment(this.content)]);
1136
+ }
1137
+
1138
+ setTimeout(function() {content.evalScripts()}, 10);
1139
+ },
1140
+
1141
+ contentFromAnonymousTable: function() {
1142
+ var div = document.createElement('div');
1143
+ div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
1144
+ return $A(div.childNodes[0].childNodes[0].childNodes);
1145
+ }
1146
+ }
1147
+
1148
+ var Insertion = new Object();
1149
+
1150
+ Insertion.Before = Class.create();
1151
+ Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
1152
+ initializeRange: function() {
1153
+ this.range.setStartBefore(this.element);
1154
+ },
1155
+
1156
+ insertContent: function(fragments) {
1157
+ fragments.each((function(fragment) {
1158
+ this.element.parentNode.insertBefore(fragment, this.element);
1159
+ }).bind(this));
1160
+ }
1161
+ });
1162
+
1163
+ Insertion.Top = Class.create();
1164
+ Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
1165
+ initializeRange: function() {
1166
+ this.range.selectNodeContents(this.element);
1167
+ this.range.collapse(true);
1168
+ },
1169
+
1170
+ insertContent: function(fragments) {
1171
+ fragments.reverse(false).each((function(fragment) {
1172
+ this.element.insertBefore(fragment, this.element.firstChild);
1173
+ }).bind(this));
1174
+ }
1175
+ });
1176
+
1177
+ Insertion.Bottom = Class.create();
1178
+ Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
1179
+ initializeRange: function() {
1180
+ this.range.selectNodeContents(this.element);
1181
+ this.range.collapse(this.element);
1182
+ },
1183
+
1184
+ insertContent: function(fragments) {
1185
+ fragments.each((function(fragment) {
1186
+ this.element.appendChild(fragment);
1187
+ }).bind(this));
1188
+ }
1189
+ });
1190
+
1191
+ Insertion.After = Class.create();
1192
+ Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
1193
+ initializeRange: function() {
1194
+ this.range.setStartAfter(this.element);
1195
+ },
1196
+
1197
+ insertContent: function(fragments) {
1198
+ fragments.each((function(fragment) {
1199
+ this.element.parentNode.insertBefore(fragment,
1200
+ this.element.nextSibling);
1201
+ }).bind(this));
1202
+ }
1203
+ });
1204
+
1205
+ /*--------------------------------------------------------------------------*/
1206
+
1207
+ Element.ClassNames = Class.create();
1208
+ Element.ClassNames.prototype = {
1209
+ initialize: function(element) {
1210
+ this.element = $(element);
1211
+ },
1212
+
1213
+ _each: function(iterator) {
1214
+ this.element.className.split(/\s+/).select(function(name) {
1215
+ return name.length > 0;
1216
+ })._each(iterator);
1217
+ },
1218
+
1219
+ set: function(className) {
1220
+ this.element.className = className;
1221
+ },
1222
+
1223
+ add: function(classNameToAdd) {
1224
+ if (this.include(classNameToAdd)) return;
1225
+ this.set(this.toArray().concat(classNameToAdd).join(' '));
1226
+ },
1227
+
1228
+ remove: function(classNameToRemove) {
1229
+ if (!this.include(classNameToRemove)) return;
1230
+ this.set(this.select(function(className) {
1231
+ return className != classNameToRemove;
1232
+ }).join(' '));
1233
+ },
1234
+
1235
+ toString: function() {
1236
+ return this.toArray().join(' ');
1237
+ }
1238
+ }
1239
+
1240
+ Object.extend(Element.ClassNames.prototype, Enumerable);
1241
+ var Selector = Class.create();
1242
+ Selector.prototype = {
1243
+ initialize: function(expression) {
1244
+ this.params = {classNames: []};
1245
+ this.expression = expression.toString().strip();
1246
+ this.parseExpression();
1247
+ this.compileMatcher();
1248
+ },
1249
+
1250
+ parseExpression: function() {
1251
+ function abort(message) { throw 'Parse error in selector: ' + message; }
1252
+
1253
+ if (this.expression == '') abort('empty expression');
1254
+
1255
+ var params = this.params, expr = this.expression, match, modifier, clause, rest;
1256
+ while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
1257
+ params.attributes = params.attributes || [];
1258
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
1259
+ expr = match[1];
1260
+ }
1261
+
1262
+ if (expr == '*') return this.params.wildcard = true;
1263
+
1264
+ while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
1265
+ modifier = match[1], clause = match[2], rest = match[3];
1266
+ switch (modifier) {
1267
+ case '#': params.id = clause; break;
1268
+ case '.': params.classNames.push(clause); break;
1269
+ case '':
1270
+ case undefined: params.tagName = clause.toUpperCase(); break;
1271
+ default: abort(expr.inspect());
1272
+ }
1273
+ expr = rest;
1274
+ }
1275
+
1276
+ if (expr.length > 0) abort(expr.inspect());
1277
+ },
1278
+
1279
+ buildMatchExpression: function() {
1280
+ var params = this.params, conditions = [], clause;
1281
+
1282
+ if (params.wildcard)
1283
+ conditions.push('true');
1284
+ if (clause = params.id)
1285
+ conditions.push('element.id == ' + clause.inspect());
1286
+ if (clause = params.tagName)
1287
+ conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
1288
+ if ((clause = params.classNames).length > 0)
1289
+ for (var i = 0; i < clause.length; i++)
1290
+ conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')');
1291
+ if (clause = params.attributes) {
1292
+ clause.each(function(attribute) {
1293
+ var value = 'element.getAttribute(' + attribute.name.inspect() + ')';
1294
+ var splitValueBy = function(delimiter) {
1295
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
1296
+ }
1297
+
1298
+ switch (attribute.operator) {
1299
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
1300
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
1301
+ case '|=': conditions.push(
1302
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
1303
+ ); break;
1304
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
1305
+ case '':
1306
+ case undefined: conditions.push(value + ' != null'); break;
1307
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
1308
+ }
1309
+ });
1310
+ }
1311
+
1312
+ return conditions.join(' && ');
1313
+ },
1314
+
1315
+ compileMatcher: function() {
1316
+ this.match = new Function('element', 'if (!element.tagName) return false; \
1317
+ return ' + this.buildMatchExpression());
1318
+ },
1319
+
1320
+ findElements: function(scope) {
1321
+ var element;
1322
+
1323
+ if (element = $(this.params.id))
1324
+ if (this.match(element))
1325
+ if (!scope || Element.childOf(element, scope))
1326
+ return [element];
1327
+
1328
+ scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
1329
+
1330
+ var results = [];
1331
+ for (var i = 0; i < scope.length; i++)
1332
+ if (this.match(element = scope[i]))
1333
+ results.push(Element.extend(element));
1334
+
1335
+ return results;
1336
+ },
1337
+
1338
+ toString: function() {
1339
+ return this.expression;
1340
+ }
1341
+ }
1342
+
1343
+ function $$() {
1344
+ return $A(arguments).map(function(expression) {
1345
+ return expression.strip().split(/\s+/).inject([null], function(results, expr) {
1346
+ var selector = new Selector(expr);
1347
+ return results.map(selector.findElements.bind(selector)).flatten();
1348
+ });
1349
+ }).flatten();
1350
+ }
1351
+ var Field = {
1352
+ clear: function() {
1353
+ for (var i = 0; i < arguments.length; i++)
1354
+ $(arguments[i]).value = '';
1355
+ },
1356
+
1357
+ focus: function(element) {
1358
+ $(element).focus();
1359
+ },
1360
+
1361
+ present: function() {
1362
+ for (var i = 0; i < arguments.length; i++)
1363
+ if ($(arguments[i]).value == '') return false;
1364
+ return true;
1365
+ },
1366
+
1367
+ select: function(element) {
1368
+ $(element).select();
1369
+ },
1370
+
1371
+ activate: function(element) {
1372
+ element = $(element);
1373
+ element.focus();
1374
+ if (element.select)
1375
+ element.select();
1376
+ }
1377
+ }
1378
+
1379
+ /*--------------------------------------------------------------------------*/
1380
+
1381
+ var Form = {
1382
+ serialize: function(form) {
1383
+ var elements = Form.getElements($(form));
1384
+ var queryComponents = new Array();
1385
+
1386
+ for (var i = 0; i < elements.length; i++) {
1387
+ var queryComponent = Form.Element.serialize(elements[i]);
1388
+ if (queryComponent)
1389
+ queryComponents.push(queryComponent);
1390
+ }
1391
+
1392
+ return queryComponents.join('&');
1393
+ },
1394
+
1395
+ getElements: function(form) {
1396
+ form = $(form);
1397
+ var elements = new Array();
1398
+
1399
+ for (tagName in Form.Element.Serializers) {
1400
+ var tagElements = form.getElementsByTagName(tagName);
1401
+ for (var j = 0; j < tagElements.length; j++)
1402
+ elements.push(tagElements[j]);
1403
+ }
1404
+ return elements;
1405
+ },
1406
+
1407
+ getInputs: function(form, typeName, name) {
1408
+ form = $(form);
1409
+ var inputs = form.getElementsByTagName('input');
1410
+
1411
+ if (!typeName && !name)
1412
+ return inputs;
1413
+
1414
+ var matchingInputs = new Array();
1415
+ for (var i = 0; i < inputs.length; i++) {
1416
+ var input = inputs[i];
1417
+ if ((typeName && input.type != typeName) ||
1418
+ (name && input.name != name))
1419
+ continue;
1420
+ matchingInputs.push(input);
1421
+ }
1422
+
1423
+ return matchingInputs;
1424
+ },
1425
+
1426
+ disable: function(form) {
1427
+ var elements = Form.getElements(form);
1428
+ for (var i = 0; i < elements.length; i++) {
1429
+ var element = elements[i];
1430
+ element.blur();
1431
+ element.disabled = 'true';
1432
+ }
1433
+ },
1434
+
1435
+ enable: function(form) {
1436
+ var elements = Form.getElements(form);
1437
+ for (var i = 0; i < elements.length; i++) {
1438
+ var element = elements[i];
1439
+ element.disabled = '';
1440
+ }
1441
+ },
1442
+
1443
+ findFirstElement: function(form) {
1444
+ return Form.getElements(form).find(function(element) {
1445
+ return element.type != 'hidden' && !element.disabled &&
1446
+ ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
1447
+ });
1448
+ },
1449
+
1450
+ focusFirstElement: function(form) {
1451
+ Field.activate(Form.findFirstElement(form));
1452
+ },
1453
+
1454
+ reset: function(form) {
1455
+ $(form).reset();
1456
+ }
1457
+ }
1458
+
1459
+ Form.Element = {
1460
+ serialize: function(element) {
1461
+ element = $(element);
1462
+ var method = element.tagName.toLowerCase();
1463
+ var parameter = Form.Element.Serializers[method](element);
1464
+
1465
+ if (parameter) {
1466
+ var key = encodeURIComponent(parameter[0]);
1467
+ if (key.length == 0) return;
1468
+
1469
+ if (parameter[1].constructor != Array)
1470
+ parameter[1] = [parameter[1]];
1471
+
1472
+ return parameter[1].map(function(value) {
1473
+ return key + '=' + encodeURIComponent(value);
1474
+ }).join('&');
1475
+ }
1476
+ },
1477
+
1478
+ getValue: function(element) {
1479
+ element = $(element);
1480
+ var method = element.tagName.toLowerCase();
1481
+ var parameter = Form.Element.Serializers[method](element);
1482
+
1483
+ if (parameter)
1484
+ return parameter[1];
1485
+ }
1486
+ }
1487
+
1488
+ Form.Element.Serializers = {
1489
+ input: function(element) {
1490
+ switch (element.type.toLowerCase()) {
1491
+ case 'submit':
1492
+ case 'hidden':
1493
+ case 'password':
1494
+ case 'text':
1495
+ return Form.Element.Serializers.textarea(element);
1496
+ case 'checkbox':
1497
+ case 'radio':
1498
+ return Form.Element.Serializers.inputSelector(element);
1499
+ }
1500
+ return false;
1501
+ },
1502
+
1503
+ inputSelector: function(element) {
1504
+ if (element.checked)
1505
+ return [element.name, element.value];
1506
+ },
1507
+
1508
+ textarea: function(element) {
1509
+ return [element.name, element.value];
1510
+ },
1511
+
1512
+ select: function(element) {
1513
+ return Form.Element.Serializers[element.type == 'select-one' ?
1514
+ 'selectOne' : 'selectMany'](element);
1515
+ },
1516
+
1517
+ selectOne: function(element) {
1518
+ var value = '', opt, index = element.selectedIndex;
1519
+ if (index >= 0) {
1520
+ opt = element.options[index];
1521
+ value = opt.value;
1522
+ if (!value && !('value' in opt))
1523
+ value = opt.text;
1524
+ }
1525
+ return [element.name, value];
1526
+ },
1527
+
1528
+ selectMany: function(element) {
1529
+ var value = new Array();
1530
+ for (var i = 0; i < element.length; i++) {
1531
+ var opt = element.options[i];
1532
+ if (opt.selected) {
1533
+ var optValue = opt.value;
1534
+ if (!optValue && !('value' in opt))
1535
+ optValue = opt.text;
1536
+ value.push(optValue);
1537
+ }
1538
+ }
1539
+ return [element.name, value];
1540
+ }
1541
+ }
1542
+
1543
+ /*--------------------------------------------------------------------------*/
1544
+
1545
+ var $F = Form.Element.getValue;
1546
+
1547
+ /*--------------------------------------------------------------------------*/
1548
+
1549
+ Abstract.TimedObserver = function() {}
1550
+ Abstract.TimedObserver.prototype = {
1551
+ initialize: function(element, frequency, callback) {
1552
+ this.frequency = frequency;
1553
+ this.element = $(element);
1554
+ this.callback = callback;
1555
+
1556
+ this.lastValue = this.getValue();
1557
+ this.registerCallback();
1558
+ },
1559
+
1560
+ registerCallback: function() {
1561
+ setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
1562
+ },
1563
+
1564
+ onTimerEvent: function() {
1565
+ var value = this.getValue();
1566
+ if (this.lastValue != value) {
1567
+ this.callback(this.element, value);
1568
+ this.lastValue = value;
1569
+ }
1570
+ }
1571
+ }
1572
+
1573
+ Form.Element.Observer = Class.create();
1574
+ Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
1575
+ getValue: function() {
1576
+ return Form.Element.getValue(this.element);
1577
+ }
1578
+ });
1579
+
1580
+ Form.Observer = Class.create();
1581
+ Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
1582
+ getValue: function() {
1583
+ return Form.serialize(this.element);
1584
+ }
1585
+ });
1586
+
1587
+ /*--------------------------------------------------------------------------*/
1588
+
1589
+ Abstract.EventObserver = function() {}
1590
+ Abstract.EventObserver.prototype = {
1591
+ initialize: function(element, callback) {
1592
+ this.element = $(element);
1593
+ this.callback = callback;
1594
+
1595
+ this.lastValue = this.getValue();
1596
+ if (this.element.tagName.toLowerCase() == 'form')
1597
+ this.registerFormCallbacks();
1598
+ else
1599
+ this.registerCallback(this.element);
1600
+ },
1601
+
1602
+ onElementEvent: function() {
1603
+ var value = this.getValue();
1604
+ if (this.lastValue != value) {
1605
+ this.callback(this.element, value);
1606
+ this.lastValue = value;
1607
+ }
1608
+ },
1609
+
1610
+ registerFormCallbacks: function() {
1611
+ var elements = Form.getElements(this.element);
1612
+ for (var i = 0; i < elements.length; i++)
1613
+ this.registerCallback(elements[i]);
1614
+ },
1615
+
1616
+ registerCallback: function(element) {
1617
+ if (element.type) {
1618
+ switch (element.type.toLowerCase()) {
1619
+ case 'checkbox':
1620
+ case 'radio':
1621
+ Event.observe(element, 'click', this.onElementEvent.bind(this));
1622
+ break;
1623
+ case 'password':
1624
+ case 'text':
1625
+ case 'textarea':
1626
+ case 'select-one':
1627
+ case 'select-multiple':
1628
+ Event.observe(element, 'change', this.onElementEvent.bind(this));
1629
+ break;
1630
+ }
1631
+ }
1632
+ }
1633
+ }
1634
+
1635
+ Form.Element.EventObserver = Class.create();
1636
+ Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
1637
+ getValue: function() {
1638
+ return Form.Element.getValue(this.element);
1639
+ }
1640
+ });
1641
+
1642
+ Form.EventObserver = Class.create();
1643
+ Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
1644
+ getValue: function() {
1645
+ return Form.serialize(this.element);
1646
+ }
1647
+ });
1648
+ if (!window.Event) {
1649
+ var Event = new Object();
1650
+ }
1651
+
1652
+ Object.extend(Event, {
1653
+ KEY_BACKSPACE: 8,
1654
+ KEY_TAB: 9,
1655
+ KEY_RETURN: 13,
1656
+ KEY_ESC: 27,
1657
+ KEY_LEFT: 37,
1658
+ KEY_UP: 38,
1659
+ KEY_RIGHT: 39,
1660
+ KEY_DOWN: 40,
1661
+ KEY_DELETE: 46,
1662
+
1663
+ element: function(event) {
1664
+ return event.target || event.srcElement;
1665
+ },
1666
+
1667
+ isLeftClick: function(event) {
1668
+ return (((event.which) && (event.which == 1)) ||
1669
+ ((event.button) && (event.button == 1)));
1670
+ },
1671
+
1672
+ pointerX: function(event) {
1673
+ return event.pageX || (event.clientX +
1674
+ (document.documentElement.scrollLeft || document.body.scrollLeft));
1675
+ },
1676
+
1677
+ pointerY: function(event) {
1678
+ return event.pageY || (event.clientY +
1679
+ (document.documentElement.scrollTop || document.body.scrollTop));
1680
+ },
1681
+
1682
+ stop: function(event) {
1683
+ if (event.preventDefault) {
1684
+ event.preventDefault();
1685
+ event.stopPropagation();
1686
+ } else {
1687
+ event.returnValue = false;
1688
+ event.cancelBubble = true;
1689
+ }
1690
+ },
1691
+
1692
+ // find the first node with the given tagName, starting from the
1693
+ // node the event was triggered on; traverses the DOM upwards
1694
+ findElement: function(event, tagName) {
1695
+ var element = Event.element(event);
1696
+ while (element.parentNode && (!element.tagName ||
1697
+ (element.tagName.toUpperCase() != tagName.toUpperCase())))
1698
+ element = element.parentNode;
1699
+ return element;
1700
+ },
1701
+
1702
+ observers: false,
1703
+
1704
+ _observeAndCache: function(element, name, observer, useCapture) {
1705
+ if (!this.observers) this.observers = [];
1706
+ if (element.addEventListener) {
1707
+ this.observers.push([element, name, observer, useCapture]);
1708
+ element.addEventListener(name, observer, useCapture);
1709
+ } else if (element.attachEvent) {
1710
+ this.observers.push([element, name, observer, useCapture]);
1711
+ element.attachEvent('on' + name, observer);
1712
+ }
1713
+ },
1714
+
1715
+ unloadCache: function() {
1716
+ if (!Event.observers) return;
1717
+ for (var i = 0; i < Event.observers.length; i++) {
1718
+ Event.stopObserving.apply(this, Event.observers[i]);
1719
+ Event.observers[i][0] = null;
1720
+ }
1721
+ Event.observers = false;
1722
+ },
1723
+
1724
+ observe: function(element, name, observer, useCapture) {
1725
+ var element = $(element);
1726
+ useCapture = useCapture || false;
1727
+
1728
+ if (name == 'keypress' &&
1729
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
1730
+ || element.attachEvent))
1731
+ name = 'keydown';
1732
+
1733
+ this._observeAndCache(element, name, observer, useCapture);
1734
+ },
1735
+
1736
+ stopObserving: function(element, name, observer, useCapture) {
1737
+ var element = $(element);
1738
+ useCapture = useCapture || false;
1739
+
1740
+ if (name == 'keypress' &&
1741
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
1742
+ || element.detachEvent))
1743
+ name = 'keydown';
1744
+
1745
+ if (element.removeEventListener) {
1746
+ element.removeEventListener(name, observer, useCapture);
1747
+ } else if (element.detachEvent) {
1748
+ element.detachEvent('on' + name, observer);
1749
+ }
1750
+ }
1751
+ });
1752
+
1753
+ /* prevent memory leaks in IE */
1754
+ Event.observe(window, 'unload', Event.unloadCache, false);
1755
+ var Position = {
1756
+ // set to true if needed, warning: firefox performance problems
1757
+ // NOT neeeded for page scrolling, only if draggable contained in
1758
+ // scrollable elements
1759
+ includeScrollOffsets: false,
1760
+
1761
+ // must be called before calling withinIncludingScrolloffset, every time the
1762
+ // page is scrolled
1763
+ prepare: function() {
1764
+ this.deltaX = window.pageXOffset
1765
+ || document.documentElement.scrollLeft
1766
+ || document.body.scrollLeft
1767
+ || 0;
1768
+ this.deltaY = window.pageYOffset
1769
+ || document.documentElement.scrollTop
1770
+ || document.body.scrollTop
1771
+ || 0;
1772
+ },
1773
+
1774
+ realOffset: function(element) {
1775
+ var valueT = 0, valueL = 0;
1776
+ do {
1777
+ valueT += element.scrollTop || 0;
1778
+ valueL += element.scrollLeft || 0;
1779
+ element = element.parentNode;
1780
+ } while (element);
1781
+ return [valueL, valueT];
1782
+ },
1783
+
1784
+ cumulativeOffset: function(element) {
1785
+ var valueT = 0, valueL = 0;
1786
+ do {
1787
+ valueT += element.offsetTop || 0;
1788
+ valueL += element.offsetLeft || 0;
1789
+ element = element.offsetParent;
1790
+ } while (element);
1791
+ return [valueL, valueT];
1792
+ },
1793
+
1794
+ positionedOffset: function(element) {
1795
+ var valueT = 0, valueL = 0;
1796
+ do {
1797
+ valueT += element.offsetTop || 0;
1798
+ valueL += element.offsetLeft || 0;
1799
+ element = element.offsetParent;
1800
+ if (element) {
1801
+ p = Element.getStyle(element, 'position');
1802
+ if (p == 'relative' || p == 'absolute') break;
1803
+ }
1804
+ } while (element);
1805
+ return [valueL, valueT];
1806
+ },
1807
+
1808
+ offsetParent: function(element) {
1809
+ if (element.offsetParent) return element.offsetParent;
1810
+ if (element == document.body) return element;
1811
+
1812
+ while ((element = element.parentNode) && element != document.body)
1813
+ if (Element.getStyle(element, 'position') != 'static')
1814
+ return element;
1815
+
1816
+ return document.body;
1817
+ },
1818
+
1819
+ // caches x/y coordinate pair to use with overlap
1820
+ within: function(element, x, y) {
1821
+ if (this.includeScrollOffsets)
1822
+ return this.withinIncludingScrolloffsets(element, x, y);
1823
+ this.xcomp = x;
1824
+ this.ycomp = y;
1825
+ this.offset = this.cumulativeOffset(element);
1826
+
1827
+ return (y >= this.offset[1] &&
1828
+ y < this.offset[1] + element.offsetHeight &&
1829
+ x >= this.offset[0] &&
1830
+ x < this.offset[0] + element.offsetWidth);
1831
+ },
1832
+
1833
+ withinIncludingScrolloffsets: function(element, x, y) {
1834
+ var offsetcache = this.realOffset(element);
1835
+
1836
+ this.xcomp = x + offsetcache[0] - this.deltaX;
1837
+ this.ycomp = y + offsetcache[1] - this.deltaY;
1838
+ this.offset = this.cumulativeOffset(element);
1839
+
1840
+ return (this.ycomp >= this.offset[1] &&
1841
+ this.ycomp < this.offset[1] + element.offsetHeight &&
1842
+ this.xcomp >= this.offset[0] &&
1843
+ this.xcomp < this.offset[0] + element.offsetWidth);
1844
+ },
1845
+
1846
+ // within must be called directly before
1847
+ overlap: function(mode, element) {
1848
+ if (!mode) return 0;
1849
+ if (mode == 'vertical')
1850
+ return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
1851
+ element.offsetHeight;
1852
+ if (mode == 'horizontal')
1853
+ return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
1854
+ element.offsetWidth;
1855
+ },
1856
+
1857
+ clone: function(source, target) {
1858
+ source = $(source);
1859
+ target = $(target);
1860
+ target.style.position = 'absolute';
1861
+ var offsets = this.cumulativeOffset(source);
1862
+ target.style.top = offsets[1] + 'px';
1863
+ target.style.left = offsets[0] + 'px';
1864
+ target.style.width = source.offsetWidth + 'px';
1865
+ target.style.height = source.offsetHeight + 'px';
1866
+ },
1867
+
1868
+ page: function(forElement) {
1869
+ var valueT = 0, valueL = 0;
1870
+
1871
+ var element = forElement;
1872
+ do {
1873
+ valueT += element.offsetTop || 0;
1874
+ valueL += element.offsetLeft || 0;
1875
+
1876
+ // Safari fix
1877
+ if (element.offsetParent==document.body)
1878
+ if (Element.getStyle(element,'position')=='absolute') break;
1879
+
1880
+ } while (element = element.offsetParent);
1881
+
1882
+ element = forElement;
1883
+ do {
1884
+ valueT -= element.scrollTop || 0;
1885
+ valueL -= element.scrollLeft || 0;
1886
+ } while (element = element.parentNode);
1887
+
1888
+ return [valueL, valueT];
1889
+ },
1890
+
1891
+ clone: function(source, target) {
1892
+ var options = Object.extend({
1893
+ setLeft: true,
1894
+ setTop: true,
1895
+ setWidth: true,
1896
+ setHeight: true,
1897
+ offsetTop: 0,
1898
+ offsetLeft: 0
1899
+ }, arguments[2] || {})
1900
+
1901
+ // find page position of source
1902
+ source = $(source);
1903
+ var p = Position.page(source);
1904
+
1905
+ // find coordinate system to use
1906
+ target = $(target);
1907
+ var delta = [0, 0];
1908
+ var parent = null;
1909
+ // delta [0,0] will do fine with position: fixed elements,
1910
+ // position:absolute needs offsetParent deltas
1911
+ if (Element.getStyle(target,'position') == 'absolute') {
1912
+ parent = Position.offsetParent(target);
1913
+ delta = Position.page(parent);
1914
+ }
1915
+
1916
+ // correct by body offsets (fixes Safari)
1917
+ if (parent == document.body) {
1918
+ delta[0] -= document.body.offsetLeft;
1919
+ delta[1] -= document.body.offsetTop;
1920
+ }
1921
+
1922
+ // set position
1923
+ if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
1924
+ if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
1925
+ if(options.setWidth) target.style.width = source.offsetWidth + 'px';
1926
+ if(options.setHeight) target.style.height = source.offsetHeight + 'px';
1927
+ },
1928
+
1929
+ absolutize: function(element) {
1930
+ element = $(element);
1931
+ if (element.style.position == 'absolute') return;
1932
+ Position.prepare();
1933
+
1934
+ var offsets = Position.positionedOffset(element);
1935
+ var top = offsets[1];
1936
+ var left = offsets[0];
1937
+ var width = element.clientWidth;
1938
+ var height = element.clientHeight;
1939
+
1940
+ element._originalLeft = left - parseFloat(element.style.left || 0);
1941
+ element._originalTop = top - parseFloat(element.style.top || 0);
1942
+ element._originalWidth = element.style.width;
1943
+ element._originalHeight = element.style.height;
1944
+
1945
+ element.style.position = 'absolute';
1946
+ element.style.top = top + 'px';;
1947
+ element.style.left = left + 'px';;
1948
+ element.style.width = width + 'px';;
1949
+ element.style.height = height + 'px';;
1950
+ },
1951
+
1952
+ relativize: function(element) {
1953
+ element = $(element);
1954
+ if (element.style.position == 'relative') return;
1955
+ Position.prepare();
1956
+
1957
+ element.style.position = 'relative';
1958
+ var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
1959
+ var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
1960
+
1961
+ element.style.top = top + 'px';
1962
+ element.style.left = left + 'px';
1963
+ element.style.height = element._originalHeight;
1964
+ element.style.width = element._originalWidth;
1965
+ }
1966
+ }
1967
+
1968
+ // Safari returns margins on body which is incorrect if the child is absolutely
1969
+ // positioned. For performance reasons, redefine Position.cumulativeOffset for
1970
+ // KHTML/WebKit only.
1971
+ if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
1972
+ Position.cumulativeOffset = function(element) {
1973
+ var valueT = 0, valueL = 0;
1974
+ do {
1975
+ valueT += element.offsetTop || 0;
1976
+ valueL += element.offsetLeft || 0;
1977
+ if (element.offsetParent == document.body)
1978
+ if (Element.getStyle(element, 'position') == 'absolute') break;
1979
+
1980
+ element = element.offsetParent;
1981
+ } while (element);
1982
+
1983
+ return [valueL, valueT];
1984
+ }
1985
+ }