Skip to content
Browse files

Merge branch 'master' of git@github.com:joshuaclayton/fuzzy-monster

Conflicts:
	app/views/forums/_recordset.html.erb
  • Loading branch information...
2 parents 98ea668 + b4be1cb commit a1a10b501fce7ae4d87bb8b236d23384c7929c13 Joshua Clayton committed Apr 21, 2009
Showing with 2,748 additions and 9,572 deletions.
  1. +10 −0 app/controllers/forums_controller.rb
  2. +9 −1 app/models/forum.rb
  3. +35 −14 app/models/post.rb
  4. +32 −15 app/models/topic.rb
  5. +8 −2 app/presenters/forum_presenter.rb
  6. +13 −2 app/presenters/forums_presenter.rb
  7. +3 −1 app/views/forums/_recordset.html.erb
  8. +2 −13 app/views/forums/index.html.erb
  9. +1 −1 app/views/layouts/application.html.erb
  10. +2 −2 config/boot.rb
  11. +3 −2 config/environment.rb
  12. +5 −0 config/locales/en.yml
  13. +1 −1 config/routes.rb
  14. +72 −72 public/javascripts/controls.js
  15. +165 −164 public/javascripts/dragdrop.js
  16. +173 −165 public/javascripts/effects.js
  17. +218 −119 public/javascripts/prototype.js
  18. +4 −1 public/stylesheets/my-screen.css
  19. +38 −0 spec/factories/factory.rb
  20. +10 −6 spec/models/post_spec.rb
  21. +30 −17 spec/spec_helpers/generate.rb
  22. +5 −0 vendor/rails/actionmailer/CHANGELOG
  23. +1 −1 vendor/rails/actionmailer/Rakefile
  24. +14 −9 vendor/rails/actionmailer/lib/action_mailer/base.rb
  25. +1 −1 vendor/rails/actionmailer/lib/action_mailer/version.rb
  26. +6 −2 vendor/rails/actionmailer/test/abstract_unit.rb
  27. +26 −0 vendor/rails/actionmailer/test/mail_service_test.rb
  28. +36 −0 vendor/rails/actionpack/CHANGELOG
  29. +1 −1 vendor/rails/actionpack/Rakefile
  30. +60 −20 vendor/rails/actionpack/lib/action_controller/base.rb
  31. +4 −1 vendor/rails/actionpack/lib/action_controller/dispatcher.rb
  32. +19 −3 vendor/rails/actionpack/lib/action_controller/mime_type.rb
  33. +2 −1 vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb
  34. +2 −1 vendor/rails/actionpack/lib/action_controller/request.rb
  35. +1 −1 vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb
  36. +81 −37 vendor/rails/actionpack/lib/action_controller/resources.rb
  37. +23 −30 vendor/rails/actionpack/lib/action_controller/routing/builder.rb
  38. +15 −7 vendor/rails/actionpack/lib/action_controller/routing/optimisations.rb
  39. +2 −8 vendor/rails/actionpack/lib/action_controller/routing/recognition_optimisation.rb
  40. +1 −1 vendor/rails/actionpack/lib/action_controller/routing/route.rb
  41. +1 −0 vendor/rails/actionpack/lib/action_controller/routing/route_set.rb
  42. +4 −0 vendor/rails/actionpack/lib/action_controller/routing/routing_ext.rb
  43. +25 −3 vendor/rails/actionpack/lib/action_controller/routing/segments.rb
  44. +2 −1 vendor/rails/actionpack/lib/action_controller/test_process.rb
  45. +1 −1 vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
  46. +1 −1 vendor/rails/actionpack/lib/action_pack/version.rb
  47. +1 −1 vendor/rails/actionpack/lib/action_view.rb
  48. +14 −3 vendor/rails/actionpack/lib/action_view/base.rb
  49. +35 −29 vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb
  50. +9 −4 vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb
  51. +3 −3 vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb
  52. +10 −4 vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb
  53. +0 −3 vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb
  54. +0 −963 vendor/rails/actionpack/lib/action_view/helpers/javascripts/controls.js
  55. +0 −972 vendor/rails/actionpack/lib/action_view/helpers/javascripts/dragdrop.js
  56. +0 −1,120 vendor/rails/actionpack/lib/action_view/helpers/javascripts/effects.js
  57. +0 −4,221 vendor/rails/actionpack/lib/action_view/helpers/javascripts/prototype.js
  58. +7 −5 vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb
  59. +7 −7 vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb
  60. +4 −5 vendor/rails/actionpack/lib/action_view/helpers/translation_helper.rb
  61. +14 −3 vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb
  62. +1 −1 vendor/rails/actionpack/lib/action_view/locale/{en-US.yml → en.yml}
  63. +1 −1 vendor/rails/actionpack/lib/action_view/partials.rb
  64. +12 −4 vendor/rails/actionpack/lib/action_view/renderable.rb
  65. +7 −5 vendor/rails/actionpack/test/controller/caching_test.rb
  66. +2 −1 vendor/rails/actionpack/test/controller/cgi_test.rb
  67. +4 −0 vendor/rails/actionpack/test/controller/html-scanner/sanitizer_test.rb
  68. +46 −0 vendor/rails/actionpack/test/controller/logging_test.rb
  69. +6 −6 vendor/rails/actionpack/test/controller/mime_type_test.rb
  70. +17 −0 vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb
  71. +10 −0 vendor/rails/actionpack/test/controller/redirect_test.rb
  72. +65 −12 vendor/rails/actionpack/test/controller/render_test.rb
  73. +66 −52 vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb
  74. +4 −10 vendor/rails/actionpack/test/controller/request_test.rb
  75. +266 −0 vendor/rails/actionpack/test/controller/resources_test.rb
  76. +9 −3 vendor/rails/actionpack/test/controller/routing_test.rb
  77. +1 −0 vendor/rails/actionpack/test/controller/session/cookie_store_test.rb
  78. +2 −2 vendor/rails/actionpack/test/controller/test_test.rb
  79. +2 −0 vendor/rails/actionpack/test/fixtures/layouts/_column.html.erb
  80. +1 −1 vendor/rails/actionpack/test/fixtures/test/_customer.erb
  81. +1 −0 vendor/rails/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb
  82. +3 −0 vendor/rails/actionpack/test/fixtures/test/nested_layout.erb
  83. +1 −0 vendor/rails/actionpack/test/fixtures/test/template.erb
  84. +12 −12 vendor/rails/actionpack/test/template/active_record_helper_i18n_test.rb
  85. +19 −1 vendor/rails/actionpack/test/template/asset_tag_helper_test.rb
  86. +2 −1 vendor/rails/actionpack/test/template/atom_feed_helper_test.rb
  87. +20 −8 vendor/rails/actionpack/test/template/compiled_templates_test.rb
  88. +11 −11 vendor/rails/actionpack/test/template/date_helper_i18n_test.rb
  89. +40 −0 vendor/rails/actionpack/test/template/date_helper_test.rb
  90. +36 −2 vendor/rails/actionpack/test/template/form_tag_helper_test.rb
  91. +15 −15 vendor/rails/actionpack/test/template/number_helper_i18n_test.rb
  92. +38 −6 vendor/rails/actionpack/test/template/render_test.rb
  93. +4 −0 vendor/rails/actionpack/test/template/tag_helper_test.rb
  94. +1 −0 vendor/rails/actionpack/test/template/text_helper_test.rb
  95. +3 −3 vendor/rails/actionpack/test/template/translation_helper_test.rb
  96. +23 −0 vendor/rails/actionpack/test/template/url_helper_test.rb
  97. +5 −1 vendor/rails/activerecord/CHANGELOG
  98. +1 −1 vendor/rails/activerecord/Rakefile
  99. +1 −1 vendor/rails/activerecord/lib/active_record.rb
  100. +1 −1 vendor/rails/activerecord/lib/active_record/association_preload.rb
  101. +20 −9 vendor/rails/activerecord/lib/active_record/associations.rb
  102. +3 −4 vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb
  103. +1 −1 vendor/rails/activerecord/lib/active_record/attribute_methods.rb
  104. +18 −10 vendor/rails/activerecord/lib/active_record/base.rb
  105. +1 −1 vendor/rails/activerecord/lib/active_record/calculations.rb
  106. +14 −8 vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  107. +14 −28 vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  108. +2 −3 vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  109. +79 −68 vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  110. +1 −1 vendor/rails/activerecord/lib/active_record/locale/{en-US.yml → en.yml}
  111. +12 −6 vendor/rails/activerecord/lib/active_record/schema_dumper.rb
  112. +2 −4 vendor/rails/activerecord/lib/active_record/test_case.rb
  113. +1 −1 vendor/rails/activerecord/lib/active_record/version.rb
  114. +0 −95 vendor/rails/activerecord/test/cases/adapter_test_sqlserver.rb
  115. +1 −1 vendor/rails/activerecord/test/cases/associations/eager_test.rb
  116. +23 −0 vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  117. +39 −1 vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb
  118. +7 −4 vendor/rails/activerecord/test/cases/attribute_methods_test.rb
  119. +11 −8 vendor/rails/activerecord/test/cases/base_test.rb
  120. +1 −5 vendor/rails/activerecord/test/cases/binary_test.rb
  121. +5 −0 vendor/rails/activerecord/test/cases/calculations_test.rb
  122. +1 −1 vendor/rails/activerecord/test/cases/defaults_test.rb
  123. +11 −0 vendor/rails/activerecord/test/cases/finder_test.rb
  124. +6 −6 vendor/rails/activerecord/test/cases/i18n_test.rb
  125. +2 −2 vendor/rails/activerecord/test/cases/inheritance_test.rb
  126. +2 −2 vendor/rails/activerecord/test/cases/locking_test.rb
  127. +3 −7 vendor/rails/activerecord/test/cases/migration_test.rb
  128. +20 −4 vendor/rails/activerecord/test/cases/pooled_connections_test.rb
  129. +0 −23 vendor/rails/activerecord/test/cases/table_name_test_sqlserver.rb
  130. +48 −48 vendor/rails/activerecord/test/cases/validations_i18n_test.rb
  131. +0 −726 vendor/rails/activerecord/test/debug.log
  132. BIN vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3
  133. BIN vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3
  134. +5 −0 vendor/rails/activerecord/test/fixtures/organizations.yml
  135. +2 −0 vendor/rails/activerecord/test/models/member.rb
  136. +4 −0 vendor/rails/activerecord/test/models/member_detail.rb
  137. +4 −0 vendor/rails/activerecord/test/models/organization.rb
  138. +10 −0 vendor/rails/activerecord/test/schema/schema.rb
  139. +0 −5 vendor/rails/activerecord/test/schema/sqlserver_specific_schema.rb
  140. +5 −0 vendor/rails/activeresource/CHANGELOG
  141. +1 −1 vendor/rails/activeresource/Rakefile
  142. +1 −1 vendor/rails/activeresource/lib/active_resource/custom_methods.rb
  143. +1 −1 vendor/rails/activeresource/lib/active_resource/version.rb
  144. +2 −0 vendor/rails/activeresource/test/base/custom_methods_test.rb
  145. +12 −2 vendor/rails/activesupport/CHANGELOG
  146. +1 −1 vendor/rails/activesupport/lib/active_support.rb
  147. +103 −1 vendor/rails/activesupport/lib/active_support/cache.rb
  148. +1 −0 vendor/rails/activesupport/lib/active_support/cache/file_store.rb
  149. +33 −9 vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb
  150. +14 −0 vendor/rails/activesupport/lib/active_support/cache/memory_store.rb
  151. +1 −0 vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb
  152. +3 −23 vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb
  153. +1 −1 vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb
  154. +4 −0 vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb
  155. +1 −1 vendor/rails/activesupport/lib/active_support/core_ext/rexml.rb
  156. +2 −0 vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
  157. +17 −3 vendor/rails/activesupport/lib/active_support/dependencies.rb
  158. +2 −2 vendor/rails/activesupport/lib/active_support/deprecation.rb
  159. +1 −2 vendor/rails/activesupport/lib/active_support/inflector.rb
  160. +1 −1 vendor/rails/activesupport/lib/active_support/locale/{en-US.yml → en.yml}
  161. +4 −4 vendor/rails/activesupport/lib/active_support/rescuable.rb
  162. +1 −1 vendor/rails/activesupport/lib/active_support/string_inquirer.rb
  163. +1 −1 vendor/rails/activesupport/lib/active_support/testing/performance.rb
  164. +4 −3 vendor/rails/activesupport/lib/active_support/values/time_zone.rb
  165. +4 −4 vendor/rails/activesupport/lib/active_support/vendor.rb
  166. +14 −7 vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
  167. +20 −16 vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
  168. +3 −3 ...tivesupport/lib/active_support/vendor/{memcache-client-1.5.0 → memcache-client-1.5.1}/memcache.rb
  169. +0 −170 ...esupport/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb
  170. 0 vendor/rails/activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb
  171. 0 ...s/activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb
  172. 0 ...ivesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb
  173. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb
  174. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb
  175. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb
  176. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb
  177. 0 ...b/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb
  178. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb
  179. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb
  180. 0 ...pport/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb
  181. +86 −0 ...esupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb
  182. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb
  183. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb
  184. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb
  185. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb
  186. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb
  187. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb
  188. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb
  189. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb
  190. 0 ...support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb
  191. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb
  192. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb
  193. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb
  194. 0 ...b/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb
  195. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb
  196. 0 ...b/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb
  197. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb
  198. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb
  199. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb
  200. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb
  201. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb
  202. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb
  203. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb
  204. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb
  205. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb
  206. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb
  207. 0 ...support/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb
  208. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb
  209. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb
  210. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Colombo.rb
  211. 0 ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb
  212. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb
  213. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb
  214. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb
  215. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb
  216. 0 ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kabul.rb
  217. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kamchatka.rb
  218. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Karachi.rb
  219. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Katmandu.rb
  220. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kolkata.rb
  221. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Krasnoyarsk.rb
  222. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuala_Lumpur.rb
  223. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuwait.rb
  224. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Magadan.rb
  225. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Muscat.rb
  226. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Novosibirsk.rb
  227. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Rangoon.rb
  228. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Riyadh.rb
  229. 0 ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Seoul.rb
  230. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Shanghai.rb
  231. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Singapore.rb
  232. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Taipei.rb
  233. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tashkent.rb
  234. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tbilisi.rb
  235. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tehran.rb
  236. 0 ...upport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tokyo.rb
  237. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Ulaanbaatar.rb
  238. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Urumqi.rb
  239. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Vladivostok.rb
  240. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yakutsk.rb
  241. 0 ...ib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yekaterinburg.rb
  242. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yerevan.rb
  243. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Azores.rb
  244. 0 ...b/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Cape_Verde.rb
  245. 0 ...ctive_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/South_Georgia.rb
  246. 0 ...ib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Adelaide.rb
  247. 0 ...ib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Brisbane.rb
  248. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Darwin.rb
  249. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Hobart.rb
  250. 0 ...b/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Melbourne.rb
  251. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Perth.rb
  252. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Sydney.rb
  253. 0 ...vesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Etc/UTC.rb
  254. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Amsterdam.rb
  255. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Athens.rb
  256. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Belgrade.rb
  257. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Berlin.rb
  258. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bratislava.rb
  259. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Brussels.rb
  260. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bucharest.rb
  261. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Budapest.rb
  262. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Copenhagen.rb
  263. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Dublin.rb
  264. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Helsinki.rb
  265. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Istanbul.rb
  266. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Kiev.rb
  267. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Lisbon.rb
  268. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Ljubljana.rb
  269. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/London.rb
  270. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Madrid.rb
  271. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Minsk.rb
  272. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Moscow.rb
  273. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Paris.rb
  274. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Prague.rb
  275. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Riga.rb
  276. 0 ...pport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Rome.rb
  277. 0 ...t/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sarajevo.rb
  278. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Skopje.rb
  279. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sofia.rb
  280. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Stockholm.rb
  281. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Tallinn.rb
  282. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vienna.rb
  283. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vilnius.rb
  284. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Warsaw.rb
  285. 0 ...ort/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Zagreb.rb
  286. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Auckland.rb
  287. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Fiji.rb
  288. 0 ...port/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Guam.rb
  289. 0 .../lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Honolulu.rb
  290. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Majuro.rb
  291. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Midway.rb
  292. 0 ...rt/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Noumea.rb
  293. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Pago_Pago.rb
  294. 0 .../active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Port_Moresby.rb
  295. 0 ...lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Tongatapu.rb
  296. 0 ...s/activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/info_timezone.rb
  297. 0 ...activesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone.rb
  298. 0 ...esupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone_info.rb
  299. 0 ...ctivesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/offset_rationals.rb
  300. 0 ...tivesupport/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/ruby_core_support.rb
Sorry, we could not display the entire diff because too many files (410) changed.
View
10 app/controllers/forums_controller.rb
@@ -5,6 +5,10 @@ class ForumsController < ApplicationController
ForumsPresenter.new(:current_user => current_user).can_be_created_by_current_user?
end
+ restrict_to :only => [:reorder] do
+ ForumsPresenter.new(:current_user => current_user).can_be_reordered_by_current_user?
+ end
+
restrict_to :only => [:edit, :update] do
object.can_be_edited_by_current_user?
end
@@ -13,9 +17,15 @@ class ForumsController < ApplicationController
object.can_be_deleted_by_current_user?
end
+ index.wants.js
index.wants.xml { render :xml => @forums }
show.wants.xml { render :xml => @forum }
+ def reorder
+ Forum.reorder params['forums-tbody']
+ index
+ end
+
private
def collection
View
10 app/models/forum.rb
@@ -1,14 +1,22 @@
class Forum < ActiveRecord::Base
acts_as_list
+
has_permalink :name, :slug
named_scope :ordered, {:order => "#{Forum.table_name}.position ASC"}
- has_many :topics, :order => "#{Topic.table_name}.sticky DESC, #{Topic.table_name}.last_updated_at DESC", :dependent => :delete_all
+ has_many :topics, :order => "#{Topic.table_name}.sticky DESC, #{Topic.table_name}.last_updated_at DESC", :dependent => :destroy
validates_presence_of :name
def to_param
self.slug
end
+
+ def self.reorder(array_of_ids)
+ array_of_ids.each_with_index do |id, index|
+ forum = self.find(id) rescue nil
+ forum.update_attribute(:position, index + 1) if forum
+ end
+ end
end
View
49 app/models/post.rb
@@ -1,21 +1,42 @@
+module Posts
+ module Callbacks
+ def self.included(base)
+ base.send :include, Posts::Callbacks::InstanceMethods
+ base.before_validation_on_create :set_forum_from_topic
+ end
+
+ module InstanceMethods
+ protected
+
+ def set_forum_from_topic
+ self.forum = self.topic.forum
+ end
+ end
+ end
+ module Validations
+ def self.included(base)
+ base.send :include, Posts::Validations::InstanceMethods
+ base.validate :topic_is_not_locked, :if => lambda {|post| post.topic && post.topic.posts_count > 0}
+ base.validates_presence_of :author_id, :forum_id, :topic_id, :body
+ end
+
+ module InstanceMethods
+ protected
+
+ def topic_is_not_locked
+ errors.add(:topic_id, "is locked") if self.topic.locked?
+ end
+ end
+ end
+end
+
class Post < ActiveRecord::Base
+ include Posts::Callbacks
+ include Posts::Validations
+
belongs_to :author, :class_name => "User", :foreign_key => :author_id, :counter_cache => true
belongs_to :forum, :counter_cache => true
belongs_to :topic, :counter_cache => true
- before_validation_on_create :set_forum_from_topic
- validate :topic_is_not_locked, :if => lambda {|post| post.topic && post.topic.posts_count > 0}
- validates_presence_of :author_id, :forum_id, :topic_id, :body
-
delegate :name, :to => :forum, :prefix => true
-
- protected
-
- def set_forum_from_topic
- self.forum = self.topic.forum
- end
-
- def topic_is_not_locked
- errors.add(:topic_id, "is locked") if self.topic.locked?
- end
end
View
47 app/models/topic.rb
@@ -1,8 +1,37 @@
+module Topics
+ module Callbacks
+ def self.included(base)
+ base.send :include, Topics::Callbacks::InstanceMethods
+ base.after_create :create_initial_post
+ end
+
+ module InstanceMethods
+ protected
+ def create_initial_post
+ self.posts.create(:author => self.creator, :body => self.body)
+ end
+ end
+ end
+ module Validations
+ def self.included(base)
+ base.validates_presence_of :title, :creator_id, :forum_id
+ base.validates_presence_of :body, :on => :create
+ end
+ end
+ module NamedScopes
+ def self.included(base)
+ base.named_scope :sticky, { :conditions => {:sticky => true} }
+ base.named_scope :not_sticky, { :conditions => {:sticky => false} }
+ end
+ end
+end
+
class Topic < ActiveRecord::Base
- has_permalink :title, :slug, :scope => :forum_id
+ include Topics::Callbacks
+ include Topics::Validations
+ include Topics::NamedScopes
- named_scope :sticky, { :conditions => {:sticky => true} }
- named_scope :not_sticky, { :conditions => {:sticky => false}}
+ has_permalink :title, :slug, :scope => :forum_id
belongs_to :forum, :counter_cache => true
belongs_to :creator, :class_name => "User", :foreign_key => :creator_id
@@ -12,13 +41,7 @@ class Topic < ActiveRecord::Base
belongs_to :last_post, :class_name => "Post", :foreign_key => :last_post_id
belongs_to :last_user, :class_name => "User", :foreign_key => :last_user_id
- validates_presence_of :title, :creator_id, :forum_id
- validates_presence_of :body, :on => :create
-
- after_create :create_initial_post
-
attr_accessible :title, :body, :forum, :creator, :sticky, :locked
-
attr_accessor :body
def view!
@@ -28,10 +51,4 @@ def view!
def to_param
self.slug
end
-
- protected
-
- def create_initial_post
- self.posts.create(:author => self.creator, :body => self.body)
- end
end
View
10 app/presenters/forum_presenter.rb
@@ -8,11 +8,11 @@ def initialize(options = {})
end
def can_be_edited_by_current_user?
- !!(@current_user && @current_user.has_privilege?(:admin))
+ is_current_user_admin?
end
def can_be_deleted_by_current_user?
- false
+ is_current_user_admin?
end
def can_topic_be_created_by_current_user?
@@ -22,4 +22,10 @@ def can_topic_be_created_by_current_user?
def method_missing(call, *args)
@forum.send call, *args
end
+
+ private
+
+ def is_current_user_admin?
+ !!(@current_user && @current_user.has_privilege?(:admin))
+ end
end
View
15 app/presenters/forums_presenter.rb
@@ -5,15 +5,26 @@ class ForumsPresenter
def initialize(options = {})
options.assert_valid_keys(:forums, :current_user)
- @forums = options[:forums] || Forum.ordered
@current_user = options[:current_user]
+ @forums = options[:forums] || Forum.ordered
+ @forums = @forums.map {|forum| ForumPresenter.new(:forum => forum, :current_user => @current_user) }
end
def can_be_created_by_current_user?
- !!(@current_user && @current_user.has_privilege?(:admin))
+ is_current_user_admin?
+ end
+
+ def can_be_reordered_by_current_user?
+ is_current_user_admin?
end
def each(&block)
@forums.each(&block)
end
+
+ private
+
+ def is_current_user_admin?
+ !!(@current_user && @current_user.has_privilege?(:admin))
+ end
end
View
4 app/views/forums/_recordset.html.erb
@@ -3,7 +3,9 @@
<% forums.each do |forum| %>
<% zebra_row :id => dom_id(forum), :class => ("grabbable" if forums.can_be_reordered_by_current_user?) do %>
<td>
- <span class="forum-title"><%= link_to forum.name, forum %></span><br/>
+ <span class="forum-title"><%= link_to forum.name, forum %></span>
+ <%= link_to "Delete", forum, :method => :delete, :confirm => "Are you sure?" if forum.can_be_deleted_by_current_user? %>
+ <br/>
<%= textilize forum.description %>
</td>
<td class="number"><%= forum.topics_count %></td>
View
15 app/views/forums/index.html.erb
@@ -1,18 +1,7 @@
<% sub_header do %>Forums<% end %>
<% content do %>
- <% recordset :headers => ["Forum", ["Topics", {:class => "number"}], ["Posts", {:class => "number"}]], :table => {:class => "forums"} do %>
- <tbody>
- <% @forums.each do |forum| %>
- <% zebra_row do %>
- <td>
- <span class="forum-title"><%= link_to forum.name, forum %></span><br/>
- <%= textilize forum.description %>
- </td>
- <td class="number"><%= forum.topics_count %></td>
- <td class="number"><%= forum.posts_count %></td>
- <% end %>
- <% end %>
- </tbody>
+ <% column :full, :id => "forums-recordset" do %>
+ <%= render :partial => "forums/recordset", :locals => {:forums => @forums} %>
<% end %>
<% end %>
<% extra_content do %>
View
2 app/views/layouts/application.html.erb
@@ -42,7 +42,7 @@
<% end %>
</div>
<div id="notification" style="display: none;"><%= image_tag("ajax-loader.gif") %> Waiting...</div>
- <%= javascript_include_tag "jquery", "jrails" %>
+ <%= javascript_include_tag "jquery", "jrails", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js" %>
<%= yield :footer %>
</body>
View
4 config/boot.rb
@@ -67,7 +67,7 @@ def load_rails_gem
class << self
def rubygems_version
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ Gem::RubyGemsVersion rescue nil
end
def gem_version
@@ -82,7 +82,7 @@ def gem_version
def load_rubygems
require 'rubygems'
- min_version = '1.1.1'
+ min_version = '1.3.1'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
View
5 config/environment.rb
@@ -4,11 +4,12 @@
config.frameworks -= [ :active_resource ]
config.action_controller.session = {
- :session_key => '_demo_session',
+ :session_key => '_fuzzy_monster_session',
:secret => '7d335e0169857cce16b2b0bb98acb77730263c9ab4c37add6960974d5a805b2443b5d20974202ca85e576b47447bf8d33b28cae1d0bc32cb8e3585f31bd72021'
}
- config.gem 'gravtastic'
+ config.gem "gravtastic"
+ config.gem "thoughtbot-factory_girl", :lib => "factory_girl"
config.load_paths += %W( #{RAILS_ROOT}/app/observers
#{RAILS_ROOT}/app/mailers
View
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
2 config/routes.rb
@@ -1,5 +1,5 @@
ActionController::Routing::Routes.draw do |map|
- map.resources :forums do |forums_map|
+ map.resources :forums, :collection => {:reorder => :put} do |forums_map|
forums_map.resources :topics do |topics_map|
topics_map.resources :posts
end
View
144 public/javascripts/controls.js
@@ -1,22 +1,22 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
+// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
// Rob Wills
-//
+//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
-// Autocompleter.Base handles all the autocompletion functionality
+// Autocompleter.Base handles all the autocompletion functionality
// that's independent of the data source for autocompletion. This
// includes drawing the autocompletion menu, observing keyboard
// and mouse events, and similar.
//
-// Specific autocompleters need to provide, at the very least,
+// Specific autocompleters need to provide, at the very least,
// a getUpdatedChoices function that will be invoked every time
-// the text inside the monitored textbox changes. This method
+// the text inside the monitored textbox changes. This method
// should get the text for which to provide autocompletion by
// invoking this.getToken(), NOT by directly accessing
// this.element.value. This is to allow incremental tokenized
@@ -30,23 +30,23 @@
// will incrementally autocomplete with a comma as the token.
// Additionally, ',' in the above example can be replaced with
// a token array, e.g. { tokens: [',', '\n'] } which
-// enables autocompletion on multiple tokens. This is most
-// useful when one of the tokens is \n (a newline), as it
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
// allows smart autocompletion after linebreaks.
if(typeof Effect == 'undefined')
throw("controls.js requires including script.aculo.us' effects.js library");
-var Autocompleter = { }
+var Autocompleter = { };
Autocompleter.Base = Class.create({
baseInitialize: function(element, update, options) {
- element = $(element)
- this.element = element;
- this.update = $(update);
- this.hasFocus = false;
- this.changed = false;
- this.active = false;
- this.index = 0;
+ element = $(element);
+ this.element = element;
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
this.entryCount = 0;
this.oldElementValue = this.element.value;
@@ -59,28 +59,28 @@ Autocompleter.Base = Class.create({
this.options.tokens = this.options.tokens || [];
this.options.frequency = this.options.frequency || 0.4;
this.options.minChars = this.options.minChars || 1;
- this.options.onShow = this.options.onShow ||
- function(element, update){
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
if(!update.style.position || update.style.position=='absolute') {
update.style.position = 'absolute';
Position.clone(element, update, {
- setHeight: false,
+ setHeight: false,
offsetTop: element.offsetHeight
});
}
Effect.Appear(update,{duration:0.15});
};
- this.options.onHide = this.options.onHide ||
+ this.options.onHide = this.options.onHide ||
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
- if(typeof(this.options.tokens) == 'string')
+ if(typeof(this.options.tokens) == 'string')
this.options.tokens = new Array(this.options.tokens);
// Force carriage returns as token delimiters anyway
if (!this.options.tokens.include('\n'))
this.options.tokens.push('\n');
this.observer = null;
-
+
this.element.setAttribute('autocomplete','off');
Element.hide(this.update);
@@ -91,18 +91,18 @@ Autocompleter.Base = Class.create({
show: function() {
if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
- if(!this.iefix &&
+ if(!this.iefix &&
(Prototype.Browser.IE) &&
(Element.getStyle(this.update, 'position')=='absolute')) {
- new Insertion.After(this.update,
+ new Insertion.After(this.update,
'<iframe id="' + this.update.id + '_iefix" '+
'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
this.iefix = $(this.update.id+'_iefix');
}
if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
},
-
+
fixIEOverlapping: function() {
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
this.iefix.style.zIndex = 1;
@@ -150,15 +150,15 @@ Autocompleter.Base = Class.create({
Event.stop(event);
return;
}
- else
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
(Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
this.changed = true;
this.hasFocus = true;
if(this.observer) clearTimeout(this.observer);
- this.observer =
+ this.observer =
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
},
@@ -170,35 +170,35 @@ Autocompleter.Base = Class.create({
onHover: function(event) {
var element = Event.findElement(event, 'LI');
- if(this.index != element.autocompleteIndex)
+ if(this.index != element.autocompleteIndex)
{
this.index = element.autocompleteIndex;
this.render();
}
Event.stop(event);
},
-
+
onClick: function(event) {
var element = Event.findElement(event, 'LI');
this.index = element.autocompleteIndex;
this.selectEntry();
this.hide();
},
-
+
onBlur: function(event) {
// needed to make click events working
setTimeout(this.hide.bind(this), 250);
this.hasFocus = false;
- this.active = false;
- },
-
+ this.active = false;
+ },
+
render: function() {
if(this.entryCount > 0) {
for (var i = 0; i < this.entryCount; i++)
- this.index==i ?
- Element.addClassName(this.getEntry(i),"selected") :
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
Element.removeClassName(this.getEntry(i),"selected");
- if(this.hasFocus) {
+ if(this.hasFocus) {
this.show();
this.active = true;
}
@@ -207,27 +207,27 @@ Autocompleter.Base = Class.create({
this.hide();
}
},
-
+
markPrevious: function() {
- if(this.index > 0) this.index--
+ if(this.index > 0) this.index--;
else this.index = this.entryCount-1;
this.getEntry(this.index).scrollIntoView(true);
},
-
+
markNext: function() {
- if(this.index < this.entryCount-1) this.index++
+ if(this.index < this.entryCount-1) this.index++;
else this.index = 0;
this.getEntry(this.index).scrollIntoView(false);
},
-
+
getEntry: function(index) {
return this.update.firstChild.childNodes[index];
},
-
+
getCurrentEntry: function() {
return this.getEntry(this.index);
},
-
+
selectEntry: function() {
this.active = false;
this.updateElement(this.getCurrentEntry());
@@ -244,7 +244,7 @@ Autocompleter.Base = Class.create({
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
} else
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
-
+
var bounds = this.getTokenBounds();
if (bounds[0] != -1) {
var newValue = this.element.value.substr(0, bounds[0]);
@@ -257,7 +257,7 @@ Autocompleter.Base = Class.create({
}
this.oldElementValue = this.element.value;
this.element.focus();
-
+
if (this.options.afterUpdateElement)
this.options.afterUpdateElement(this.element, selectedElement);
},
@@ -269,20 +269,20 @@ Autocompleter.Base = Class.create({
Element.cleanWhitespace(this.update.down());
if(this.update.firstChild && this.update.down().childNodes) {
- this.entryCount =
+ this.entryCount =
this.update.down().childNodes.length;
for (var i = 0; i < this.entryCount; i++) {
var entry = this.getEntry(i);
entry.autocompleteIndex = i;
this.addObservers(entry);
}
- } else {
+ } else {
this.entryCount = 0;
}
this.stopIndicator();
this.index = 0;
-
+
if(this.entryCount==1 && this.options.autoSelect) {
this.selectEntry();
this.hide();
@@ -298,7 +298,7 @@ Autocompleter.Base = Class.create({
},
onObserverEvent: function() {
- this.changed = false;
+ this.changed = false;
this.tokenBounds = null;
if(this.getToken().length>=this.options.minChars) {
this.getUpdatedChoices();
@@ -351,16 +351,16 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
getUpdatedChoices: function() {
this.startIndicator();
-
- var entry = encodeURIComponent(this.options.paramName) + '=' +
+
+ var entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
this.options.callback(this.element, entry) : entry;
- if(this.options.defaultParams)
+ if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
-
+
new Ajax.Request(this.url, this.options);
},
@@ -382,7 +382,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
// - choices - How many autocompletion choices to offer
//
// - partialSearch - If false, the autocompleter will match entered
-// text only at the beginning of strings in the
+// text only at the beginning of strings in the
// autocomplete array. Defaults to true, which will
// match text at the beginning of any *word* in the
// strings in the autocomplete array. If you want to
@@ -399,7 +399,7 @@ Ajax.Autocompleter = Class.create(Autocompleter.Base, {
// - ignoreCase - Whether to ignore case when autocompleting.
// Defaults to true.
//
-// It's possible to pass in a custom function as the 'selector'
+// It's possible to pass in a custom function as the 'selector'
// option, if you prefer to write your own autocompletion logic.
// In that case, the other options above will not apply unless
// you support them.
@@ -427,20 +427,20 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
var entry = instance.getToken();
var count = 0;
- for (var i = 0; i < instance.options.array.length &&
- ret.length < instance.options.choices ; i++) {
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
var elem = instance.options.array[i];
- var foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
elem.indexOf(entry);
while (foundPos != -1) {
- if (foundPos == 0 && elem.length != entry.length) {
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
elem.substr(entry.length) + "</li>");
break;
- } else if (entry.length >= instance.options.partialChars &&
+ } else if (entry.length >= instance.options.partialChars &&
instance.options.partialSearch && foundPos != -1) {
if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
@@ -450,14 +450,14 @@ Autocompleter.Local = Class.create(Autocompleter.Base, {
}
}
- foundPos = instance.options.ignoreCase ?
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
elem.indexOf(entry, foundPos + 1);
}
}
if (partial.length)
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
return "<ul>" + ret.join('') + "</ul>";
}
}, options || { });
@@ -474,7 +474,7 @@ Field.scrollFreeActivate = function(field) {
setTimeout(function() {
Field.activate(field);
}, 1);
-}
+};
Ajax.InPlaceEditor = Class.create({
initialize: function(element, url, options) {
@@ -604,7 +604,7 @@ Ajax.InPlaceEditor = Class.create({
this.triggerCallback('onEnterHover');
},
getText: function() {
- return this.element.innerHTML;
+ return this.element.innerHTML.unescapeHTML();
},
handleAJAXFailure: function(transport) {
this.triggerCallback('onFailure', transport);
@@ -780,7 +780,7 @@ Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
onSuccess: function(transport) {
var js = transport.responseText.strip();
if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
- throw 'Server returned an invalid collection representation.';
+ throw('Server returned an invalid collection representation.');
this._collection = eval(js);
this.checkForExternalText();
}.bind(this),
@@ -937,7 +937,7 @@ Ajax.InPlaceCollectionEditor.DefaultOptions = {
loadingCollectionText: 'Loading options...'
};
-// Delayed observer, like Form.Element.Observer,
+// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields
@@ -947,7 +947,7 @@ Form.Element.DelayedObserver = Class.create({
this.element = $(element);
this.callback = callback;
this.timer = null;
- this.lastValue = $F(this.element);
+ this.lastValue = $F(this.element);
Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
},
delayedListener: function(event) {
@@ -960,4 +960,4 @@ Form.Element.DelayedObserver = Class.create({
this.timer = null;
this.callback(this.element, $F(this.element));
}
-});
+});
View
329 public/javascripts/dragdrop.js
@@ -1,6 +1,6 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
-//
+// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@@ -32,42 +32,42 @@ var Droppables = {
options._containers.push($(containment));
}
}
-
+
if(options.accept) options.accept = [options.accept].flatten();
Element.makePositioned(element); // fix IE
options.element = element;
this.drops.push(options);
},
-
+
findDeepestChild: function(drops) {
deepest = drops[0];
-
+
for (i = 1; i < drops.length; ++i)
if (Element.isParent(drops[i].element, deepest.element))
deepest = drops[i];
-
+
return deepest;
},
isContained: function(element, drop) {
var containmentNode;
if(drop.tree) {
- containmentNode = element.treeNode;
+ containmentNode = element.treeNode;
} else {
containmentNode = element.parentNode;
}
return drop._containers.detect(function(c) { return containmentNode == c });
},
-
+
isAffected: function(point, element, drop) {
return (
(drop.element!=element) &&
((!drop._containers) ||
this.isContained(element, drop)) &&
((!drop.accept) ||
- (Element.classNames(element).detect(
+ (Element.classNames(element).detect(
function(v) { return drop.accept.include(v) } ) )) &&
Position.within(drop.element, point[0], point[1]) );
},
@@ -87,12 +87,12 @@ var Droppables = {
show: function(point, element) {
if(!this.drops.length) return;
var drop, affected = [];
-
+
this.drops.each( function(drop) {
if(Droppables.isAffected(point, element, drop))
affected.push(drop);
});
-
+
if(affected.length>0)
drop = Droppables.findDeepestChild(affected);
@@ -101,7 +101,7 @@ var Droppables = {
Position.within(drop.element, point[0], point[1]);
if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
-
+
if (drop != this.last_active) Droppables.activate(drop);
}
},
@@ -112,34 +112,34 @@ var Droppables = {
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
if (this.last_active.onDrop) {
- this.last_active.onDrop(element, this.last_active.element, event);
- return true;
+ this.last_active.onDrop(element, this.last_active.element, event);
+ return true;
}
},
reset: function() {
if(this.last_active)
this.deactivate(this.last_active);
}
-}
+};
var Draggables = {
drags: [],
observers: [],
-
+
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this);
-
+
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
}
this.drags.push(draggable);
},
-
+
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
@@ -148,77 +148,77 @@ var Draggables = {
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
-
+
activate: function(draggable) {
- if(draggable.options.delay) {
- this._timeout = setTimeout(function() {
- Draggables._timeout = null;
- window.focus();
- Draggables.activeDraggable = draggable;
- }.bind(this), draggable.options.delay);
+ if(draggable.options.delay) {
+ this._timeout = setTimeout(function() {
+ Draggables._timeout = null;
+ window.focus();
+ Draggables.activeDraggable = draggable;
+ }.bind(this), draggable.options.delay);
} else {
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable;
}
},
-
+
deactivate: function() {
this.activeDraggable = null;
},
-
+
updateDrag: function(event) {
if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
// Mozilla-based browsers fire successive mousemove events with
// the same coordinates, prevent needless redrawing (moz bug?)
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
this._lastPointer = pointer;
-
+
this.activeDraggable.updateDrag(event, pointer);
},
-
+
endDrag: function(event) {
- if(this._timeout) {
- clearTimeout(this._timeout);
- this._timeout = null;
+ if(this._timeout) {
+ clearTimeout(this._timeout);
+ this._timeout = null;
}
if(!this.activeDraggable) return;
this._lastPointer = null;
this.activeDraggable.endDrag(event);
this.activeDraggable = null;
},
-
+
keyPress: function(event) {
if(this.activeDraggable)
this.activeDraggable.keyPress(event);
},
-
+
addObserver: function(observer) {
this.observers.push(observer);
this._cacheObserverCallbacks();
},
-
+
removeObserver: function(element) { // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks();
},
-
+
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
if(this[eventName+'Count'] > 0)
this.observers.each( function(o) {
if(o[eventName]) o[eventName](eventName, draggable, event);
});
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
},
-
+
_cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select(
function(o) { return o[eventName]; }
).length;
});
}
-}
+};
/*--------------------------------------------------------------------------*/
@@ -234,12 +234,12 @@ var Draggable = Class.create({
},
endeffect: function(element) {
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
- new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
- afterFinish: function(){
- Draggable._dragging[element] = false
+ afterFinish: function(){
+ Draggable._dragging[element] = false
}
- });
+ });
},
zindex: 1000,
revert: false,
@@ -250,57 +250,57 @@ var Draggable = Class.create({
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
delay: 0
};
-
+
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
Object.extend(defaults, {
starteffect: function(element) {
element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
- new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
}
});
-
+
var options = Object.extend(defaults, arguments[1] || { });
this.element = $(element);
-
+
if(options.handle && Object.isString(options.handle))
this.handle = this.element.down('.'+options.handle, 0);
-
+
if(!this.handle) this.handle = $(options.handle);
if(!this.handle) this.handle = this.element;
-
+
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
options.scroll = $(options.scroll);
this._isScrollChild = Element.childOf(this.element, options.scroll);
}
- Element.makePositioned(this.element); // fix IE
+ Element.makePositioned(this.element); // fix IE
this.options = options;
- this.dragging = false;
+ this.dragging = false;
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown);
-
+
Draggables.register(this);
},
-
+
destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Draggables.unregister(this);
},
-
+
currentDelta: function() {
return([
parseInt(Element.getStyle(this.element,'left') || '0'),
parseInt(Element.getStyle(this.element,'top') || '0')]);
},
-
+
initDrag: function(event) {
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
Draggable._dragging[this.element]) return;
- if(Event.isLeftClick(event)) {
+ if(Event.isLeftClick(event)) {
// abort on form elements, fixes a Firefox issue
var src = Event.element(event);
if((tag_name = src.tagName.toUpperCase()) && (
@@ -309,34 +309,34 @@ var Draggable = Class.create({
tag_name=='OPTION' ||
tag_name=='BUTTON' ||
tag_name=='TEXTAREA')) return;
-
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos = Position.cumulativeOffset(this.element);
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
-
+
Draggables.activate(this);
Event.stop(event);
}
},
-
+
startDrag: function(event) {
this.dragging = true;
if(!this.delta)
this.delta = this.currentDelta();
-
+
if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex;
}
-
+
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
- this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
- if (!this.element._originallyAbsolute)
+ this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
+ if (!this._originallyAbsolute)
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
-
+
if(this.options.scroll) {
if (this.options.scroll == window) {
var where = this._getWindowScroll(this.options.scroll);
@@ -347,28 +347,28 @@ var Draggable = Class.create({
this.originalScrollTop = this.options.scroll.scrollTop;
}
}
-
+
Draggables.notify('onStart', this, event);
-
+
if(this.options.starteffect) this.options.starteffect(this.element);
},
-
+
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
-
+
if(!this.options.quiet){
Position.prepare();
Droppables.show(pointer, this.element);
}
-
+
Draggables.notify('onDrag', this, event);
-
+
this.draw(pointer);
if(this.options.change) this.options.change(this);
-
+
if(this.options.scroll) {
this.stopScrolling();
-
+
var p;
if (this.options.scroll == window) {
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
@@ -386,41 +386,41 @@ var Draggable = Class.create({
if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
this.startScrolling(speed);
}
-
+
// fix AppleWebKit rendering
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
-
+
Event.stop(event);
},
-
+
finishDrag: function(event, success) {
this.dragging = false;
-
+
if(this.options.quiet){
Position.prepare();
var pointer = [Event.pointerX(event), Event.pointerY(event)];
Droppables.show(pointer, this.element);
}
if(this.options.ghosting) {
- if (!this.element._originallyAbsolute)
+ if (!this._originallyAbsolute)
Position.relativize(this.element);
- delete this.element._originallyAbsolute;
+ delete this._originallyAbsolute;
Element.remove(this._clone);
this._clone = null;
}
- var dropped = false;
- if(success) {
- dropped = Droppables.fire(event, this.element);
- if (!dropped) dropped = false;
+ var dropped = false;
+ if(success) {
+ dropped = Droppables.fire(event, this.element);
+ if (!dropped) dropped = false;
}
if(dropped && this.options.onDropped) this.options.onDropped(this.element);
Draggables.notify('onEnd', this, event);
var revert = this.options.revert;
if(revert && Object.isFunction(revert)) revert = revert(this.element);
-
+
var d = this.currentDelta();
if(revert && this.options.reverteffect) {
if (dropped == 0 || revert != 'failure')
@@ -433,82 +433,82 @@ var Draggable = Class.create({
if(this.options.zindex)
this.element.style.zIndex = this.originalZ;
- if(this.options.endeffect)
+ if(this.options.endeffect)
this.options.endeffect(this.element);
-
+
Draggables.deactivate(this);
Droppables.reset();
},
-
+
keyPress: function(event) {
if(event.keyCode!=Event.KEY_ESC) return;
this.finishDrag(event, false);
Event.stop(event);
},
-
+
endDrag: function(event) {
if(!this.dragging) return;
this.stopScrolling();
this.finishDrag(event, true);
Event.stop(event);
},
-
+
draw: function(point) {
var pos = Position.cumulativeOffset(this.element);
if(this.options.ghosting) {
var r = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
}
-
+
var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1];
-
+
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
}
-
- var p = [0,1].map(function(i){
- return (point[i]-pos[i]-this.offset[i])
+
+ var p = [0,1].map(function(i){
+ return (point[i]-pos[i]-this.offset[i])
}.bind(this));
-
+
if(this.options.snap) {
if(Object.isFunction(this.options.snap)) {
p = this.options.snap(p[0],p[1],this);
} else {
if(Object.isArray(this.options.snap)) {
p = p.map( function(v, i) {
- return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this))
+ return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
} else {
p = p.map( function(v) {
- return (v/this.options.snap).round()*this.options.snap }.bind(this))
+ return (v/this.options.snap).round()*this.options.snap }.bind(this));
}
}}
-
+
var style = this.element.style;
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
style.left = p[0] + "px";
if((!this.options.constraint) || (this.options.constraint=='vertical'))
style.top = p[1] + "px";
-
+
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
},
-
+
stopScrolling: function() {
if(this.scrollInterval) {
clearInterval(this.scrollInterval);
this.scrollInterval = null;
Draggables._lastScrollPointer = null;
}
},
-
+
startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
},
-
+
scroll: function() {
var current = new Date();
var delta = current - this.lastScrolled;
@@ -524,7 +524,7 @@ var Draggable = Class.create({
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
}
-
+
Position.prepare();
Droppables.show(Draggables._lastPointer, this.element);
Draggables.notify('onDrag', this);
@@ -538,10 +538,10 @@ var Draggable = Class.create({
Draggables._lastScrollPointer[1] = 0;
this.draw(Draggables._lastScrollPointer);
}
-
+
if(this.options.change) this.options.change(this);
},
-
+
_getWindowScroll: function(w) {
var T, L, W, H;
with (w.document) {
@@ -560,7 +560,7 @@ var Draggable = Class.create({
H = documentElement.clientHeight;
} else {
W = body.offsetWidth;
- H = body.offsetHeight
+ H = body.offsetHeight;
}
}
return { top: T, left: L, width: W, height: H };
@@ -577,11 +577,11 @@ var SortableObserver = Class.create({
this.observer = observer;
this.lastValue = Sortable.serialize(this.element);
},
-
+
onStart: function() {
this.lastValue = Sortable.serialize(this.element);
},
-
+
onEnd: function() {
Sortable.unmark();
if(this.lastValue != Sortable.serialize(this.element))
@@ -591,11 +591,11 @@ var SortableObserver = Class.create({
var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
-
+
sortables: { },
-
+
_findRootElement: function(element) {
- while (element.tagName.toUpperCase() != "BODY") {
+ while (element.tagName.toUpperCase() != "BODY") {
if(element.id && Sortable.sortables[element.id]) return element;
element = element.parentNode;
}
@@ -606,22 +606,23 @@ var Sortable = {
if(!element) return;
return Sortable.sortables[element.id];
},
-
+
destroy: function(element){
- var s = Sortable.options(element);
-
+ element = $(element);
+ var s = Sortable.sortables[element.id];
+
if(s) {
Draggables.removeObserver(s.element);
s.droppables.each(function(d){ Droppables.remove(d) });
s.draggables.invoke('destroy');
-
+
delete Sortable.sortables[s.element.id];
}