active_scaffold_clarity 3.0.24.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. data/CHANGELOG +179 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +73 -0
  4. data/frontends/default/images/add.gif +0 -0
  5. data/frontends/default/images/arrow_down.gif +0 -0
  6. data/frontends/default/images/arrow_up.gif +0 -0
  7. data/frontends/default/images/close.gif +0 -0
  8. data/frontends/default/images/close_touch.png +0 -0
  9. data/frontends/default/images/config.png +0 -0
  10. data/frontends/default/images/cross.png +0 -0
  11. data/frontends/default/images/gears.png +0 -0
  12. data/frontends/default/images/indicator-small.gif +0 -0
  13. data/frontends/default/images/indicator.gif +0 -0
  14. data/frontends/default/images/magnifier.png +0 -0
  15. data/frontends/default/javascripts/jquery/active_scaffold.js +1049 -0
  16. data/frontends/default/javascripts/jquery/jquery.editinplace.js +743 -0
  17. data/frontends/default/javascripts/prototype/active_scaffold.js +1031 -0
  18. data/frontends/default/javascripts/prototype/dhtml_history.js +870 -0
  19. data/frontends/default/javascripts/prototype/form_enhancements.js +117 -0
  20. data/frontends/default/javascripts/prototype/rico_corner.js +370 -0
  21. data/frontends/default/stylesheets/stylesheet-ie.css +35 -0
  22. data/frontends/default/stylesheets/stylesheet.css +1093 -0
  23. data/frontends/default/views/_action_group.html.erb +24 -0
  24. data/frontends/default/views/_add_existing_form.html.erb +30 -0
  25. data/frontends/default/views/_base_form.html.erb +51 -0
  26. data/frontends/default/views/_create_form.html.erb +8 -0
  27. data/frontends/default/views/_create_form_on_list.html.erb +6 -0
  28. data/frontends/default/views/_field_search.html.erb +32 -0
  29. data/frontends/default/views/_form.html.erb +26 -0
  30. data/frontends/default/views/_form_association.html.erb +19 -0
  31. data/frontends/default/views/_form_association_footer.html.erb +47 -0
  32. data/frontends/default/views/_form_attribute.html.erb +20 -0
  33. data/frontends/default/views/_form_hidden_attribute.html.erb +2 -0
  34. data/frontends/default/views/_form_messages.html.erb +5 -0
  35. data/frontends/default/views/_horizontal_subform.html.erb +29 -0
  36. data/frontends/default/views/_horizontal_subform_header.html.erb +11 -0
  37. data/frontends/default/views/_horizontal_subform_record.html.erb +38 -0
  38. data/frontends/default/views/_human_conditions.html.erb +1 -0
  39. data/frontends/default/views/_list.html.erb +18 -0
  40. data/frontends/default/views/_list_actions.html.erb +15 -0
  41. data/frontends/default/views/_list_calculations.html.erb +16 -0
  42. data/frontends/default/views/_list_column_headings.html.erb +12 -0
  43. data/frontends/default/views/_list_header.html.erb +10 -0
  44. data/frontends/default/views/_list_inline_adapter.html.erb +10 -0
  45. data/frontends/default/views/_list_messages.html.erb +32 -0
  46. data/frontends/default/views/_list_pagination.html.erb +11 -0
  47. data/frontends/default/views/_list_pagination_links.html.erb +9 -0
  48. data/frontends/default/views/_list_record.html.erb +14 -0
  49. data/frontends/default/views/_list_record_columns.html.erb +8 -0
  50. data/frontends/default/views/_list_with_header.html.erb +32 -0
  51. data/frontends/default/views/_messages.html.erb +10 -0
  52. data/frontends/default/views/_render_field.js.rjs +14 -0
  53. data/frontends/default/views/_row.html.erb +12 -0
  54. data/frontends/default/views/_search.html.erb +34 -0
  55. data/frontends/default/views/_search_attribute.html.erb +10 -0
  56. data/frontends/default/views/_show.html.erb +8 -0
  57. data/frontends/default/views/_show_columns.html.erb +15 -0
  58. data/frontends/default/views/_update_actions.html.erb +9 -0
  59. data/frontends/default/views/_update_form.html.erb +6 -0
  60. data/frontends/default/views/_vertical_subform.html.erb +12 -0
  61. data/frontends/default/views/_vertical_subform_record.html.erb +38 -0
  62. data/frontends/default/views/action_confirmation.html.erb +13 -0
  63. data/frontends/default/views/add_existing.js.rjs +17 -0
  64. data/frontends/default/views/add_existing_form.html.erb +5 -0
  65. data/frontends/default/views/create.html.erb +5 -0
  66. data/frontends/default/views/delete.html.erb +13 -0
  67. data/frontends/default/views/destroy.js.rjs +23 -0
  68. data/frontends/default/views/edit_associated.js.rjs +11 -0
  69. data/frontends/default/views/field_search.html.erb +5 -0
  70. data/frontends/default/views/form_messages.js.rjs +1 -0
  71. data/frontends/default/views/list.html.erb +1 -0
  72. data/frontends/default/views/list.js.rjs +1 -0
  73. data/frontends/default/views/on_action_update.js.rjs +10 -0
  74. data/frontends/default/views/on_create.js.rjs +41 -0
  75. data/frontends/default/views/on_mark_all.js.rjs +12 -0
  76. data/frontends/default/views/on_update.js.rjs +28 -0
  77. data/frontends/default/views/render_field.js.rjs +1 -0
  78. data/frontends/default/views/search.html.erb +5 -0
  79. data/frontends/default/views/show.html.erb +5 -0
  80. data/frontends/default/views/update.html.erb +8 -0
  81. data/frontends/default/views/update_column.js.rjs +13 -0
  82. data/frontends/default/views/update_row.js.rjs +1 -0
  83. data/lib/active_scaffold.rb +386 -0
  84. data/lib/active_scaffold/actions/common_search.rb +22 -0
  85. data/lib/active_scaffold/actions/core.rb +191 -0
  86. data/lib/active_scaffold/actions/create.rb +149 -0
  87. data/lib/active_scaffold/actions/delete.rb +75 -0
  88. data/lib/active_scaffold/actions/field_search.rb +82 -0
  89. data/lib/active_scaffold/actions/list.rb +194 -0
  90. data/lib/active_scaffold/actions/mark.rb +75 -0
  91. data/lib/active_scaffold/actions/nested.rb +254 -0
  92. data/lib/active_scaffold/actions/search.rb +47 -0
  93. data/lib/active_scaffold/actions/show.rb +61 -0
  94. data/lib/active_scaffold/actions/subform.rb +27 -0
  95. data/lib/active_scaffold/actions/update.rb +151 -0
  96. data/lib/active_scaffold/active_record_permissions.rb +134 -0
  97. data/lib/active_scaffold/attribute_params.rb +212 -0
  98. data/lib/active_scaffold/bridges/ancestry/bridge.rb +5 -0
  99. data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +39 -0
  100. data/lib/active_scaffold/bridges/bridge.rb +59 -0
  101. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +16 -0
  102. data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +83 -0
  103. data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
  104. data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
  105. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +9 -0
  106. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +33 -0
  107. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +12 -0
  108. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +45 -0
  109. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +17 -0
  110. data/lib/active_scaffold/bridges/country_helper/bridge.rb +9 -0
  111. data/lib/active_scaffold/bridges/country_helper/lib/country_helper_bridge.rb +358 -0
  112. data/lib/active_scaffold/bridges/date_picker/bridge.rb +24 -0
  113. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +234 -0
  114. data/lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js +22 -0
  115. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +9 -0
  116. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +36 -0
  117. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +12 -0
  118. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb +27 -0
  119. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb +16 -0
  120. data/lib/active_scaffold/bridges/file_column/bridge.rb +11 -0
  121. data/lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb +46 -0
  122. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +59 -0
  123. data/lib/active_scaffold/bridges/file_column/lib/form_ui.rb +37 -0
  124. data/lib/active_scaffold/bridges/file_column/lib/list_ui.rb +26 -0
  125. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
  126. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
  127. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
  128. data/lib/active_scaffold/bridges/paperclip/bridge.rb +12 -0
  129. data/lib/active_scaffold/bridges/paperclip/lib/form_ui.rb +27 -0
  130. data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +16 -0
  131. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +38 -0
  132. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +26 -0
  133. data/lib/active_scaffold/bridges/record_select/bridge.rb +5 -0
  134. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb +92 -0
  135. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +5 -0
  136. data/lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
  137. data/lib/active_scaffold/bridges/shared/date_bridge.rb +209 -0
  138. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +5 -0
  139. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +61 -0
  140. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +8 -0
  141. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +21 -0
  142. data/lib/active_scaffold/config/base.rb +62 -0
  143. data/lib/active_scaffold/config/core.rb +220 -0
  144. data/lib/active_scaffold/config/create.rb +51 -0
  145. data/lib/active_scaffold/config/delete.rb +34 -0
  146. data/lib/active_scaffold/config/field_search.rb +75 -0
  147. data/lib/active_scaffold/config/form.rb +53 -0
  148. data/lib/active_scaffold/config/list.rb +188 -0
  149. data/lib/active_scaffold/config/mark.rb +35 -0
  150. data/lib/active_scaffold/config/nested.rb +45 -0
  151. data/lib/active_scaffold/config/search.rb +69 -0
  152. data/lib/active_scaffold/config/show.rb +35 -0
  153. data/lib/active_scaffold/config/subform.rb +35 -0
  154. data/lib/active_scaffold/config/update.rb +46 -0
  155. data/lib/active_scaffold/configurable.rb +29 -0
  156. data/lib/active_scaffold/constraints.rb +184 -0
  157. data/lib/active_scaffold/data_structures/action_columns.rb +137 -0
  158. data/lib/active_scaffold/data_structures/action_link.rb +175 -0
  159. data/lib/active_scaffold/data_structures/action_links.rb +185 -0
  160. data/lib/active_scaffold/data_structures/actions.rb +45 -0
  161. data/lib/active_scaffold/data_structures/column.rb +366 -0
  162. data/lib/active_scaffold/data_structures/columns.rb +75 -0
  163. data/lib/active_scaffold/data_structures/error_message.rb +24 -0
  164. data/lib/active_scaffold/data_structures/nested_info.rb +123 -0
  165. data/lib/active_scaffold/data_structures/set.rb +62 -0
  166. data/lib/active_scaffold/data_structures/sorting.rb +168 -0
  167. data/lib/active_scaffold/extensions/action_controller_rendering.rb +22 -0
  168. data/lib/active_scaffold/extensions/action_view_rendering.rb +111 -0
  169. data/lib/active_scaffold/extensions/action_view_resolver.rb +7 -0
  170. data/lib/active_scaffold/extensions/active_association_reflection.rb +13 -0
  171. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  172. data/lib/active_scaffold/extensions/array.rb +7 -0
  173. data/lib/active_scaffold/extensions/localize.rb +10 -0
  174. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +12 -0
  175. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +7 -0
  176. data/lib/active_scaffold/extensions/paginator_extensions.rb +26 -0
  177. data/lib/active_scaffold/extensions/reverse_associations.rb +62 -0
  178. data/lib/active_scaffold/extensions/routing_mapper.rb +34 -0
  179. data/lib/active_scaffold/extensions/to_label.rb +8 -0
  180. data/lib/active_scaffold/extensions/unsaved_associated.rb +61 -0
  181. data/lib/active_scaffold/extensions/unsaved_record.rb +20 -0
  182. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  183. data/lib/active_scaffold/finder.rb +345 -0
  184. data/lib/active_scaffold/helpers/association_helpers.rb +42 -0
  185. data/lib/active_scaffold/helpers/controller_helpers.rb +87 -0
  186. data/lib/active_scaffold/helpers/form_column_helpers.rb +321 -0
  187. data/lib/active_scaffold/helpers/human_condition_helpers.rb +59 -0
  188. data/lib/active_scaffold/helpers/id_helpers.rb +127 -0
  189. data/lib/active_scaffold/helpers/list_column_helpers.rb +375 -0
  190. data/lib/active_scaffold/helpers/pagination_helpers.rb +55 -0
  191. data/lib/active_scaffold/helpers/search_column_helpers.rb +254 -0
  192. data/lib/active_scaffold/helpers/show_column_helpers.rb +50 -0
  193. data/lib/active_scaffold/helpers/view_helpers.rb +379 -0
  194. data/lib/active_scaffold/locale/de.yml +111 -0
  195. data/lib/active_scaffold/locale/en.yml +115 -0
  196. data/lib/active_scaffold/locale/es.yml +115 -0
  197. data/lib/active_scaffold/locale/fr.yml +118 -0
  198. data/lib/active_scaffold/locale/hu.yml +63 -0
  199. data/lib/active_scaffold/locale/ja.yml +64 -0
  200. data/lib/active_scaffold/locale/ru.yml +119 -0
  201. data/lib/active_scaffold/marked_model.rb +38 -0
  202. data/lib/active_scaffold/paginator.rb +136 -0
  203. data/lib/active_scaffold/responds_to_parent.rb +70 -0
  204. data/lib/active_scaffold/version.rb +10 -0
  205. data/lib/active_scaffold_assets.rb +45 -0
  206. data/lib/active_scaffold_env.rb +13 -0
  207. data/lib/generators/active_scaffold/USAGE +29 -0
  208. data/lib/generators/active_scaffold/active_scaffold_generator.rb +20 -0
  209. data/lib/generators/active_scaffold_controller/USAGE +19 -0
  210. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +29 -0
  211. data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
  212. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  213. data/lib/generators/active_scaffold_setup/USAGE +10 -0
  214. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +59 -0
  215. data/public/blank.html +33 -0
  216. data/shoulda_macros/macros.rb +136 -0
  217. data/test/bridges/bridge_test.rb +47 -0
  218. data/test/config/base_test.rb +15 -0
  219. data/test/config/create_test.rb +55 -0
  220. data/test/config/list_test.rb +74 -0
  221. data/test/config/show_test.rb +43 -0
  222. data/test/config/update_test.rb +17 -0
  223. data/test/const_mocker.rb +36 -0
  224. data/test/data_structures/action_columns_test.rb +113 -0
  225. data/test/data_structures/action_link_test.rb +78 -0
  226. data/test/data_structures/action_links_test.rb +78 -0
  227. data/test/data_structures/actions_test.rb +25 -0
  228. data/test/data_structures/association_column_test.rb +42 -0
  229. data/test/data_structures/column_test.rb +185 -0
  230. data/test/data_structures/columns_test.rb +69 -0
  231. data/test/data_structures/error_message_test.rb +28 -0
  232. data/test/data_structures/set_test.rb +86 -0
  233. data/test/data_structures/sorting_test.rb +126 -0
  234. data/test/data_structures/standard_column_test.rb +24 -0
  235. data/test/data_structures/virtual_column_test.rb +23 -0
  236. data/test/extensions/active_record_test.rb +45 -0
  237. data/test/extensions/array_test.rb +12 -0
  238. data/test/helpers/form_column_helpers_test.rb +31 -0
  239. data/test/helpers/list_column_helpers_test.rb +31 -0
  240. data/test/helpers/pagination_helpers_test.rb +55 -0
  241. data/test/misc/active_record_permissions_test.rb +154 -0
  242. data/test/misc/attribute_params_test.rb +110 -0
  243. data/test/misc/configurable_test.rb +96 -0
  244. data/test/misc/constraints_test.rb +193 -0
  245. data/test/misc/finder_test.rb +93 -0
  246. data/test/misc/lang_test.rb +12 -0
  247. data/test/mock_app/app/controllers/application_controller.rb +10 -0
  248. data/test/mock_app/app/helpers/application_helper.rb +3 -0
  249. data/test/mock_app/config/boot.rb +110 -0
  250. data/test/mock_app/config/database.yml +16 -0
  251. data/test/mock_app/config/environment.rb +43 -0
  252. data/test/mock_app/config/environments/development.rb +17 -0
  253. data/test/mock_app/config/environments/production.rb +28 -0
  254. data/test/mock_app/config/environments/test.rb +28 -0
  255. data/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
  256. data/test/mock_app/config/initializers/inflections.rb +10 -0
  257. data/test/mock_app/config/initializers/mime_types.rb +5 -0
  258. data/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
  259. data/test/mock_app/config/initializers/session_store.rb +15 -0
  260. data/test/mock_app/config/locales/en.yml +5 -0
  261. data/test/mock_app/config/routes.rb +43 -0
  262. data/test/mock_app/db/test.sqlite3 +1 -0
  263. data/test/mock_app/public/blank.html +33 -0
  264. data/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
  265. data/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
  266. data/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
  267. data/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
  268. data/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
  269. data/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
  270. data/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
  271. data/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
  272. data/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
  273. data/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
  274. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
  275. data/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
  276. data/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
  277. data/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
  278. data/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
  279. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
  280. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +842 -0
  281. data/test/model_stub.rb +55 -0
  282. data/test/run_all.rb +8 -0
  283. data/test/test_helper.rb +39 -0
  284. metadata +470 -0
@@ -0,0 +1,179 @@
1
+ = 3.0.5
2
+
3
+ - switch from explicit requires to autoloading
4
+ - get nested action links up and running
5
+
6
+ = 3.0.4
7
+
8
+ - Fix a typo that made 3.0.3 unusable.
9
+
10
+ = 3.0.3
11
+
12
+ - Fixing 'require' ordering
13
+ - Code for nested and subgrouped action links
14
+ - bugfixes for better html generation
15
+
16
+ = 3.0.2
17
+
18
+ - Two bug fixes and a deprecation silencing.
19
+
20
+ = 3.0.1
21
+
22
+ - Fixing the requiring of files.
23
+
24
+ = 3.0.0
25
+
26
+ - Packaging up vhochstein's fork for Rails 3.0 as a gem.
27
+
28
+ = 1.2RC1
29
+
30
+ == FEATURES
31
+
32
+ - Added view helpers (active_scaffold_javascripts, active_scaffold_stylesheets, active_scaffold_ie_stylesheets) to help with asset cacheing (Alexander Semyonov)
33
+ - Works with Rails 2.1 (2.0 / 1.2.x will continue to be supported by version 1.1)
34
+
35
+ == FIXES
36
+
37
+ - Javascript compatibility with FF3 / Safari 3.1 (Mike Dalessio)
38
+ see http://groups.google.com/group/activescaffold/browse_thread/thread/d37afa3f2ac687f2/b34ebf62d767bee3
39
+ - Avoid ruby deprecation warning in config/list.rb (Dustin Sallings)
40
+ - Fixes bug where template overrides are ignored when placed in Engines plugins (Mike Dalessio)
41
+ - Fixed in_place_editor to work with latest control.js
42
+ - Fixed infinite recursion bug when creating a new record with a new association
43
+ - Subform action name conflict fix
44
+ - Helpful warning message if record_select is not on a column with an association
45
+
46
+ = 1.1.1
47
+
48
+ == FIXES
49
+
50
+ * rendering for rails 1.2.x
51
+
52
+ = 1.1.0
53
+
54
+ == FEATURES
55
+
56
+ * `render :super' now accepts a :locals option
57
+ * parameter-based conditions now support arrays of values (e.g. users?name[]=bob&name[]=fred becomes "name IN ('bob', 'fred')")
58
+
59
+ == FIXES
60
+
61
+ * `render :super' now works from active_scaffold_overrides without endlessly looping
62
+ * `render :super' no longer assumes that the *immediate* caller was the override template file
63
+ * `render :super' works better with windows file names (e.g. c:/...)
64
+ * reload_if_empty() javascript now uses GET
65
+ * inplace_edit now uses POST instead of GET
66
+ * adding time and date fields to ignore list for determining whether subform row is empty. previously only datetime was ignored.
67
+ * closed a potential internet explorer security issue in dhtml_history.js library
68
+
69
+ = 1.1.0 RC1
70
+
71
+ == FEATURES
72
+
73
+ === LIST
74
+ * row class: new helper method (list_row_class) gets called for each record in the list and returns a CSS class.
75
+ * automatically link to the :show action of singular associations. this is similar to the nested scaffolds for plural associations.
76
+ * column.list_ui: good for when you want to render multiple columns the same way.
77
+ * * built-in list interface options:
78
+ * * * for inplace edits - checkbox
79
+ * Support :joins_for_collection in column_calculation
80
+ * inplace_edit option on list columns. currently works for text boxes and booleans
81
+
82
+ === CREATE/UPDATE
83
+ * file uploads - largely taken care of by file_column bridge.
84
+ * * automatically detects if FileColumn is installed. If so, uses it, and sets the form_ui for file columns to be file upload fields
85
+ * * sets multipart? on config.create and config.update if file_columns are used on the target model
86
+ * * Posts through iframe to give ajax-style file uploads
87
+ * * Image columns are recognized and previewed as such
88
+ * * Ability to delete a file
89
+ * form_ui
90
+ * * form interface options are now supported through helper method named active_scaffold_input_#{form_ui}. if you want a different form interface than activescaffold normally provides, you may configure the form_ui for that column to use one of these methods. you can easily define your own, too.
91
+ * * built-in form interface options:
92
+ * * * for associations - singular_association, plural_association, select, record_select
93
+ * * * others - select, checkbox, country, password, textarea, usa_state, virtual, boolean
94
+ * * subforms respect form_ui settings. but if form_ui is empty, it will be set to :select to disable subform nesting.
95
+ * boolean columns: when the database column allows nil, we now add a third option to the dropdown so you don't *have* to pick true or false.
96
+ * new :params option for a column lets you specify additional parameters to accept when the given column is on the form. this is for when a column needs to submit multiple values to work.
97
+ * improved support for associations in parameters. for simply selecting/deselecting associations, activescaffold will now recognize `:user => 5' or `:users => [1, 2, 5]'.
98
+ * Supply a unique id from active_scaffold_input_options for form fields.
99
+ * added after_update_save controller override method
100
+
101
+ === EMBEDDING
102
+ * `render :active_scaffold' now accepts a :conditions option, which is a weaker but more flexible variation of :constraints
103
+ * active_scaffold_includes now accepts a frontend name. this is necessary so you can include the proper assets even if active_scaffold isn't configured on the current controller (it's embedded).
104
+ * polymorphic constraints are now supported, assuming params[:parent_model].to_s is the proper content for the polymorphic _type field.
105
+ * Beefing up the constraint system so it can handle has_one/belongs_to. Specifically, it can now disassociate a previous relationship before setting a new one. For example, Bear has_one Den. If creating a new Den, constrained to a certain Bear, the constraints system will now disassociate any previous Den from the Bear before associating the new one.
106
+
107
+ === NESTING
108
+ * :through associations may now be nested
109
+ * nested#shallow_delete
110
+
111
+ === SEARCH
112
+ * fieldsearch module handles booleans better - provides third option so you don't *have* to search on a boolean column
113
+ * In field search lock_version is the only magic column. May want to search by :id or date fields.
114
+
115
+ === GENERAL
116
+ * use #human_name for the column label when possible.
117
+ * merge_conditions now supports hash conditions (and should forever support every conditions style that ActiveRecord supports)
118
+ * action links may now remove an action link with #clear_link
119
+ * action links have a new :controller option, so you don't have to sneak it into :params anymore
120
+ * dhtml history may now be disabled
121
+ * authorized_for? in ActiveRecordPermissions now calls respond_to? only as much as needed
122
+ * removing an assert_valid_keys? call in active_record_permissions#authorized_for?. it just wasn't worth the CPU time.
123
+ * render :super is now extension-agnostic. ex: `render :super` in list.html.erb will properly find list.rhtml as the "parent" template.
124
+ * Auto-bridge loading mechanism. Bridges integrated into core.
125
+ * inherited_view_paths: ability to specify other folders to look for if missing view occurs
126
+
127
+ == FIXES
128
+
129
+ === LIST
130
+ * the calculation row now updates on edit/create/destroy.
131
+ * list now returns to page 1 if the current page has no records.
132
+ * list will now try to reload the scaffold on a previous page if you delete the last entry on the current page.
133
+ * if there were no end-of-line record actions, then any column actions would not use ajax. this was because the loading indicator was missing, which messed up the action link javascript.
134
+ * theme == :default no longer attempts to use Rico.Corner
135
+ * column_empty? now treats any values equal to list.empty_field_text as empty, too.
136
+ * better :method handling for action links.
137
+ * the ' ' fix for ie6 was failing for value types that weren't nil and didn't respond to empty?
138
+ * if someone sets singular columns to link to the 'nested' action, the link will now render with the appropriate id parameter.
139
+ * do not propagate params[:search] through action links that link to other controllers. closes issue #447.
140
+ * reworked rendering of pagination links for IE
141
+
142
+ === CREATE/UPDATE
143
+ * constraints are now applied to a record during the #new action, in case any custom form rendering depends on the constrained column
144
+ * the default options_for_association_conditions now returns nil for :through associations
145
+ * will not update a record attribute if the value hasn't changed. this is a workaround for an activerecord bug with has_one associations.
146
+ * attributes_hash_is_empty? didn't handle multi-parameter attribute names like 'created_at(5i)', which resulted in extra records being created from subforms.
147
+ * Hide hidden column header labels - like lock_version - in sub-forms.
148
+ * configuring url_for to not escape ampersands for the add_new_url in association footers (the 'create another' button's url)
149
+ * attribute_params.rb#attributes_hash_is_empty now checks defaults by converting them to strings to match the parameter values.
150
+
151
+ === NESTING
152
+ * no longer trying to nest a polymorphic association (there's no consistent model to list)
153
+ * fixed :conditions generation for nested/embedded scaffolds - was causing a bind variable mismatch.
154
+
155
+ === SEARCH
156
+ * search/livesearch should no longer choke on virtual columns
157
+ * the search/live_search forms will now ignore params[:search] when generating the submit url
158
+
159
+ === GENERAL
160
+ * no longer blow up on data strings with unintentional % characters. as_() was sprintf'ing too frequently.
161
+ * link_to no longer blows up on controller symbols
162
+ * activescaffold no longer loses information on columns - `config.columns.add', `config.columns = [...]', and `config.columns.exclude' all now affect the *inheritability* of a column by the other modules (list, create, update, etc.), but all columns remain in config.columns. this also makes _id columns behave better.
163
+ * dhtml history no longer saves null:null:null history bookmark.
164
+ * if there aren't any columns to search on, then activescaffold no longer creates an empty WHERE clause
165
+ * render :update was failing in some cases because activescaffold wasn't expecting blocks to the render call.
166
+ * quoting the scaffold id for report_500_response()
167
+ * adding :update_column => :post to the RESTful routing. closes issue #448.
168
+
169
+ == MISC
170
+
171
+ * reorganized the helpers and extensions
172
+ * ui_type is now only an alias for form_ui
173
+ * improvements to exception messages
174
+ * when initializing in production mode, activescaffold now recovers gracefully if it can't copy asset files
175
+ * RESTful routing is now accomplished in a way that'll let other add-ons extend the meaning of :active_scaffold => true.
176
+ * fixes for edge rails compatibility
177
+ * small improvements for localization accessibility
178
+ * minor string renaming (will affect localization tables, though)
179
+ * closed a few XSS holes
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006 Richard White
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,73 @@
1
+ ******************************************************************************************************
2
+ ** For all documentation see the project website: http://github.com/vhochstein/active_scaffold/wiki **
3
+ ******************************************************************************************************
4
+
5
+ ActiveScaffold Gem/Plugin by Scott Rutherford (scott@caronsoftware.com), Richard White (rrwhite@gmail.com), Lance Ivy (lance@cainlevy.net), Ed Moss, Tim Harper and Sergio Cambra (sergio@entrecables.com)
6
+
7
+ Uses DhtmlHistory by Brad Neuberg (bkn3@columbia.edu)
8
+ http://codinginparadise.org
9
+
10
+ Uses Querystring by Adam Vandenberg
11
+ http://adamv.com/dev/javascript/querystring
12
+
13
+ Uses Paginator by Bruce Williams
14
+ http://paginator.rubyforge.org/
15
+
16
+ Supports RecordSelect by Lance Ivy
17
+ http://code.google.com/p/recordselect/
18
+
19
+ == Version Information
20
+
21
+ Please note the following list of Active Scaffold branches and Rails versions. Master will not work with Rails < 3.1
22
+
23
+ Active Scaffold master currently supports rails-3.1, but incompatible changes can be introduced, if you want an stable version, use rails-3.0
24
+ Rails 3.0.*: Active Scaffold rails-3.0
25
+ Rails 2.3.*: Active Scaffold rails-2.3 and v2.4
26
+ Rails 2.2.*: Active Scaffold rails-2.2
27
+ Rails 2.1.*: Active Scaffold rails-2.1
28
+ Rails < 2.1: Active Scaffold 1-1-stable (no guarantees)
29
+
30
+ Since Rails 2.3, render_component plugin is needed for nested and embedded scaffolds. It works with rails-2.3 branch from ewildgoose repository:
31
+ script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3
32
+
33
+ Since Rails 3.0 render_component is not used for nesting, but is optional for embedded scaffolds.
34
+ Since Rails 3.0, https://github.com/rails/verification.git is also needed.
35
+
36
+ If you want to install as plugins under vendor/plugins, install these versions:
37
+ rails plugin install git://github.com/vhochstein/render_component.git
38
+ rails plugin install git://github.com/rails/verification.git
39
+ rails plugin install git://github.com/activescaffold/active_scaffold.git -r 'rails-3.0'
40
+
41
+ If you want to use the gem, add to your Gemfile:
42
+ gem "active_scaffold"
43
+
44
+ In case you would like to use most recent commit:
45
+ gem 'active_scaffold', :git => 'git://github.com/activescaffold/active_scaffold.git', :branch => 'rails-3.0'
46
+
47
+ == Pick your own javascript framework
48
+
49
+ The Rails 3.0 version uses unobtrusive Javascript, so you are free to pick your javascript framework.
50
+ Out of the box Prototype or JQuery are supported:
51
+
52
+ Prototype 1.7 (default js framework)
53
+ rails.js in git://github.com/vhochstein/prototype-ujs.git
54
+
55
+ JQuery 1.4.1, 1.4.2
56
+ https://github.com/vhochstein/jquery-ujs/raw/jquery1_4_2/src/rails.js
57
+
58
+ JQuery > 1.4.2
59
+ https://github.com/vhochstein/jquery-ujs/raw/master/src/rails.js
60
+
61
+ To configure the javascript framework when installed under vendor/plugins/
62
+ uncomment last line in config/initializers/active_scaffold.rb in order to use jquery instead of prototype.
63
+ That file is created when you install ActiveScaffold as a plugin.
64
+
65
+ To configure the javascript framework when installed as a gem:
66
+ Add a config/initializers/active_scaffold.rb containing:
67
+ ActiveScaffold.js_framework = :jquery # :prototype is the default
68
+
69
+ == Rails 3.1 compatible branch:
70
+ under construction
71
+
72
+
73
+ Released under the MIT license (included)
@@ -0,0 +1,1049 @@
1
+ $(document).ready(function() {
2
+ $('form.as_form').live('ajax:loading', function(event) {
3
+ var as_form = $(this).closest("form");
4
+ if (as_form && as_form.attr('data-loading') == 'true') {
5
+ ActiveScaffold.disable_form(as_form);
6
+ }
7
+ return true;
8
+ });
9
+
10
+ $('form.as_form').live('ajax:complete', function(event) {
11
+ var as_form = $(this).closest("form");
12
+ if (as_form && as_form.attr('data-loading') == 'true') {
13
+ ActiveScaffold.enable_form(as_form);
14
+ }
15
+ });
16
+ $('form.as_form').live('ajax:failure', function(event) {
17
+ var as_div = $(this).closest("div.active-scaffold");
18
+ if (as_div) {
19
+ ActiveScaffold.report_500_response(as_div)
20
+ }
21
+ });
22
+ $('form.as_form.as_remote_upload').live('submit', function(event) {
23
+ var as_form = $(this).closest("form");
24
+ if (as_form && as_form.attr('data-loading') == 'true') {
25
+ setTimeout("ActiveScaffold.disable_form('" + as_form.attr('id') + "')", 10);
26
+ }
27
+ return true;
28
+ });
29
+ $('a.as_action').live('ajax:before', function(event) {
30
+ var action_link = ActiveScaffold.ActionLink.get($(this));
31
+ if (action_link) {
32
+ if (action_link.is_disabled()) {
33
+ return false;
34
+ } else {
35
+ // hack: jquery requires if you request for javascript that javascript
36
+ // is coming back, however rails has a different mantra
37
+ if (action_link.position) {
38
+ if (parseFloat($.fn.jquery) >= 1.5) {
39
+ event.data_type = 'text';
40
+ } else {
41
+ event.data_type = 'rails';
42
+ }
43
+ }
44
+
45
+ if (action_link.loading_indicator) action_link.loading_indicator.css('visibility','visible');
46
+ action_link.disable();
47
+ }
48
+ }
49
+ return true;
50
+ });
51
+ $('a.as_action').live('ajax:success', function(event, response) {
52
+ var action_link = ActiveScaffold.ActionLink.get($(this));
53
+ if (action_link) {
54
+ if (action_link.position) {
55
+ action_link.insert(response);
56
+ if (action_link.hide_target) action_link.target.hide();
57
+ } else {
58
+ action_link.enable();
59
+ }
60
+ $(this).trigger('as:action_success', action_link);
61
+ }
62
+ return true;
63
+ });
64
+ $('a.as_action').live('ajax:complete', function(event) {
65
+ var action_link = ActiveScaffold.ActionLink.get($(this));
66
+ if (action_link) {
67
+ if (action_link.loading_indicator) action_link.loading_indicator.css('visibility','hidden');
68
+ }
69
+ return true;
70
+ });
71
+ $('a.as_action').live('ajax:failure', function(event) {
72
+ var action_link = ActiveScaffold.ActionLink.get($(this));
73
+ if (action_link) {
74
+ ActiveScaffold.report_500_response(action_link.scaffold_id());
75
+ action_link.enable();
76
+ }
77
+ return true;
78
+ });
79
+ $('a.as_cancel').live('ajax:before', function(event) {
80
+ var as_cancel = $(this);
81
+ var action_link = ActiveScaffold.find_action_link(as_cancel);
82
+
83
+ if (action_link) {
84
+ var cancel_url = as_cancel.attr('href');
85
+ var refresh_data = as_cancel.attr('data-refresh');
86
+ if (refresh_data === 'true' && action_link.refresh_url) {
87
+ event.data_url = action_link.refresh_url;
88
+ if (action_link.position) event.data_type = 'html'
89
+ } else if (refresh_data === 'false' || typeof(cancel_url) == 'undefined' || cancel_url.length == 0) {
90
+ action_link.close();
91
+ return false;
92
+ }
93
+ }
94
+ return true;
95
+ });
96
+ $('a.as_cancel').live('ajax:success', function(event, response) {
97
+ var action_link = ActiveScaffold.find_action_link($(this));
98
+
99
+ if (action_link) {
100
+ if (action_link.position) {
101
+ action_link.close(response);
102
+ } else {
103
+ response.evalResponse();
104
+ }
105
+ }
106
+ return true;
107
+ });
108
+ $('a.as_cancel').live('ajax:failure', function(event) {
109
+ var action_link = ActiveScaffold.find_action_link($(this));
110
+ if (action_link) {
111
+ ActiveScaffold.report_500_response(action_link.scaffold_id());
112
+ }
113
+ return true;
114
+ });
115
+ $('a.as_sort').live('ajax:before', function(event) {
116
+ var as_sort = $(this);
117
+ var history_controller_id = as_sort.attr('data-page-history');
118
+ if (history_controller_id) addActiveScaffoldPageToHistory(as_sort.attr('href'), history_controller_id);
119
+ as_sort.closest('th').addClass('loading');
120
+ return true;
121
+ });
122
+ $('a.as_sort').live('ajax:failure', function(event) {
123
+ var as_scaffold = $(this).closest('.active-scaffold');
124
+ ActiveScaffold.report_500_response(as_scaffold);
125
+ return true;
126
+ });
127
+ $('span.in_place_editor_field').live('hover', function(event) {
128
+ $(this).data(); // jquery 1.4.2 workaround
129
+ if (event.type == 'mouseenter') {
130
+ if (typeof($(this).data('editInPlace')) === 'undefined') $(this).addClass("hover");
131
+ }
132
+ if (event.type == 'mouseleave') {
133
+ if (typeof($(this).data('editInPlace')) === 'undefined') $(this).removeClass("hover");
134
+ }
135
+ return true;
136
+ });
137
+ $('span.in_place_editor_field').live('click', function(event) {
138
+ ActiveScaffold.in_place_editor_field_clicked($(this));
139
+ });
140
+ $('a.as_paginate').live('ajax:before',function(event) {
141
+ var as_paginate = $(this);
142
+ var history_controller_id = as_paginate.attr('data-page-history');
143
+ if (history_controller_id) addActiveScaffoldPageToHistory(as_paginate.attr('href'), history_controller_id);
144
+ as_paginate.prevAll('img.loading-indicator').css('visibility','visible');
145
+ return true;
146
+ });
147
+ $('a.as_paginate').live('ajax:failure', function(event) {
148
+ var as_scaffold = $(this).closest('.active-scaffold');
149
+ ActiveScaffold.report_500_response(as_scaffold);
150
+ return true;
151
+ });
152
+ $('a.as_paginate').live('ajax:complete', function(event) {
153
+ $(this).prevAll('img.loading-indicator').css('visibility','hidden');
154
+ return true;
155
+ });
156
+ $('a.as_add_existing, a.as_replace_existing').live('ajax:before', function(event) {
157
+ var id = $(this).prev().val();
158
+ if (id) {
159
+ if (!$(this).data('href')) $(this).data('href', $(this).attr('href'));
160
+ $(this).attr('href', $(this).data('href').replace('--ID--', id));
161
+ return true;
162
+ } else return false;
163
+ });
164
+ $('input.update_form, select.update_form').live('change', function(event) {
165
+ var element = $(this);
166
+ var value = element.is("input:checkbox") ? element.is(":checked") : element.val();
167
+ ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), value);
168
+ return true;
169
+ });
170
+
171
+ $('select.as_search_range_option').live('change', function(event) {
172
+ ActiveScaffold[$(this).val() == 'BETWEEN' ? 'show' : 'hide']($(this).parent().find('.as_search_range_between'));
173
+ return true;
174
+ });
175
+
176
+ $('select.as_search_range_option').live('change', function(event) {
177
+ var element = $(this);
178
+ ActiveScaffold[!(element.val() == 'PAST' || element.val() == 'FUTURE' || element.val() == 'RANGE') ? 'show' : 'hide'](element.attr('id').replace(/_opt/, '_numeric'));
179
+ ActiveScaffold[(element.val() == 'PAST' || element.val() == 'FUTURE') ? 'show' : 'hide'](element.attr('id').replace(/_opt/, '_trend'));
180
+ ActiveScaffold[(element.val() == 'RANGE') ? 'show' : 'hide'](element.attr('id').replace(/_opt/, '_range'));
181
+ return true;
182
+ });
183
+
184
+ $('select.as_update_date_operator').live('change', function(event) {
185
+ ActiveScaffold[$(this).val() == 'REPLACE' ? 'show' : 'hide']($(this).next());
186
+ ActiveScaffold[$(this).val() == 'REPLACE' ? 'hide' : 'show']($(this).next().next());
187
+ return true;
188
+ });
189
+
190
+ $('a[data-popup]').live('click', function(e) {
191
+ window.open($(this).attr('href'));
192
+ e.preventDefault();
193
+ });
194
+
195
+ $('.hover_click').live("click", function(event) {
196
+ var element = $(this);
197
+ var ul_element = element.children('ul').first();
198
+ if (ul_element.is(':visible')) {
199
+ element.find('ul').hide();
200
+ } else {
201
+ ul_element.show();
202
+ }
203
+ return false;
204
+ });
205
+ $('.hover_click a.as_action').live('click', function(event) {
206
+ var element = $(this).closest('.hover_click');
207
+ if (element) {
208
+ element.find('ul').hide();
209
+ }
210
+ return true;
211
+ });
212
+ });
213
+
214
+ /* Simple Inheritance
215
+ http://ejohn.org/blog/simple-javascript-inheritance/
216
+ */
217
+ (function(){
218
+ var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
219
+
220
+ // The base Class implementation (does nothing)
221
+ this.Class = function(){};
222
+
223
+ // Create a new Class that inherits from this class
224
+ Class.extend = function(prop) {
225
+ var _super = this.prototype;
226
+
227
+ // Instantiate a base class (but only create the instance,
228
+ // don't run the init constructor)
229
+ initializing = true;
230
+ var prototype = new this();
231
+ initializing = false;
232
+
233
+ // Copy the properties over onto the new prototype
234
+ for (var name in prop) {
235
+ // Check if we're overwriting an existing function
236
+ prototype[name] = typeof prop[name] == "function" &&
237
+ typeof _super[name] == "function" && fnTest.test(prop[name]) ?
238
+ (function(name, fn){
239
+ return function() {
240
+ var tmp = this._super;
241
+
242
+ // Add a new ._super() method that is the same method
243
+ // but on the super-class
244
+ this._super = _super[name];
245
+
246
+ // The method only need to be bound temporarily, so we
247
+ // remove it when we're done executing
248
+ var ret = fn.apply(this, arguments);
249
+ this._super = tmp;
250
+
251
+ return ret;
252
+ };
253
+ })(name, prop[name]) :
254
+ prop[name];
255
+ }
256
+
257
+ // The dummy class constructor
258
+ function Class() {
259
+ // All construction is actually done in the init method
260
+ if ( !initializing && this.init )
261
+ this.init.apply(this, arguments);
262
+ }
263
+
264
+ // Populate our constructed prototype object
265
+ Class.prototype = prototype;
266
+
267
+ // Enforce the constructor to be what we expect
268
+ Class.constructor = Class;
269
+
270
+ // And make this class extendable
271
+ Class.extend = arguments.callee;
272
+
273
+ return Class;
274
+ };
275
+ })();
276
+
277
+ /*
278
+ jQuery delayed observer
279
+ (c) 2007 - Maxime Haineault (max@centdessin.com)
280
+
281
+ Special thanks to Stephen Goguen & Tane Piper.
282
+
283
+ Slight modifications by Elliot Winkler
284
+ */
285
+
286
+ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
287
+ (function() {
288
+ var delayedObserverStack = [];
289
+ var observed;
290
+
291
+ function delayedObserverCallback(stackPos) {
292
+ observed = delayedObserverStack[stackPos];
293
+ if (observed.timer) return;
294
+
295
+ observed.timer = setTimeout(function(){
296
+ observed.timer = null;
297
+ observed.callback(observed.obj.val(), observed.obj);
298
+ }, observed.delay * 1000);
299
+
300
+ observed.oldVal = observed.obj.val();
301
+ }
302
+
303
+ // going by
304
+ // <http://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f0306e3e25/Javascript-Char-Codes-Key-Codes.aspx>
305
+ // I think these codes only work when using keyup or keydown
306
+ function isNonPrintableKey(event) {
307
+ var code = event.keyCode;
308
+ return (
309
+ event.metaKey ||
310
+ (code >= 9 && code <= 16) || (code >= 27 && code <= 40) || (code >= 91 && code <= 93) || (code >= 112 && code <= 145)
311
+ );
312
+ }
313
+
314
+ jQuery.fn.extend({
315
+ delayedObserver:function(delay, callback){
316
+ $this = $(this);
317
+
318
+ delayedObserverStack.push({
319
+ obj: $this, timer: null, delay: delay,
320
+ oldVal: $this.val(), callback: callback
321
+ });
322
+
323
+ stackPos = delayedObserverStack.length-1;
324
+
325
+ $this.keyup(function(event) {
326
+ if (isNonPrintableKey(event)) return;
327
+ observed = delayedObserverStack[stackPos];
328
+ if (observed.obj.val() == observed.obj.oldVal) return;
329
+ else delayedObserverCallback(stackPos);
330
+ });
331
+ }
332
+ });
333
+ })();
334
+ };
335
+
336
+
337
+ /*
338
+ * Simple utility methods
339
+ */
340
+
341
+ var ActiveScaffold = {
342
+ records_for: function(tbody_id) {
343
+ if (typeof(tbody_id) == 'string') tbody_id = '#' + tbody_id;
344
+ return $(tbody_id).children('.record');
345
+ },
346
+ stripe: function(tbody_id) {
347
+ var even = false;
348
+ var rows = this.records_for(tbody_id);
349
+
350
+ rows.each(function (index, row_node) {
351
+ row = $(row_node);
352
+ if (row_node.tagName != 'SCRIPT'
353
+ && !row.hasClass("create")
354
+ && !row.hasClass("update")
355
+ && !row.hasClass("inline-adapter")
356
+ && !row.hasClass("active-scaffold-calculations")) {
357
+
358
+ if (even) row.addClass("even-record");
359
+ else row.removeClass("even-record");
360
+
361
+ even = !even;
362
+ }
363
+ });
364
+ },
365
+ hide_empty_message: function(tbody) {
366
+ if (this.records_for(tbody).length != 0) {
367
+ var empty_message_node = $(tbody).parent().find('tbody.messages p.empty-message')
368
+ if (empty_message_node) empty_message_node.hide();
369
+ }
370
+ },
371
+ reload_if_empty: function(tbody, url) {
372
+ if (this.records_for(tbody).length == 0) {
373
+ $.getScript(url);
374
+ }
375
+ },
376
+ removeSortClasses: function(scaffold) {
377
+ if (typeof(scaffold) == 'string') scaffold = '#' + scaffold;
378
+ scaffold = $(scaffold)
379
+ scaffold.find('td.sorted').each(function(element) {
380
+ element.removeClass("sorted");
381
+ });
382
+ scaffold.find('th.sorted').each(function(element) {
383
+ element.removeClass("sorted");
384
+ element.removeClass("asc");
385
+ element.removeClass("desc");
386
+ });
387
+ },
388
+ decrement_record_count: function(scaffold) {
389
+ // decrement the last record count, firsts record count are in nested lists
390
+ if (typeof(scaffold) == 'string') scaffold = '#' + scaffold;
391
+ scaffold = $(scaffold)
392
+ count = scaffold.find('span.active-scaffold-records').last();
393
+ if (count) count.html(parseInt(count.html(), 10) - 1);
394
+ },
395
+ increment_record_count: function(scaffold) {
396
+ // increment the last record count, firsts record count are in nested lists
397
+ if (typeof(scaffold) == 'string') scaffold = '#' + scaffold;
398
+ scaffold = $(scaffold)
399
+ count = scaffold.find('span.active-scaffold-records').last();
400
+ if (count) count.html(parseInt(count.html(), 10) + 1);
401
+ },
402
+ update_row: function(row, html) {
403
+ var even_row = false;
404
+ var replaced = null;
405
+ if (typeof(row) == 'string') row = '#' + row;
406
+ row = $(row);
407
+ if (row.hasClass('even-record')) even_row = true;
408
+
409
+ replaced = this.replace(row, html);
410
+ if (even_row === true) replaced.addClass('even-record');
411
+ ActiveScaffold.highlight(replaced);
412
+ },
413
+
414
+ replace: function(element, html) {
415
+ if (typeof(element) == 'string') element = '#' + element;
416
+ element = $(element);
417
+ element.replaceWith(html);
418
+ if (element.attr('id')) {
419
+ element = $('#' + element.attr('id'));
420
+ }
421
+ return element;
422
+ },
423
+
424
+ replace_html: function(element, html) {
425
+ if (typeof(element) == 'string') element = '#' + element;
426
+ element = $(element);
427
+ element.html(html);
428
+ return element;
429
+ },
430
+
431
+ remove: function(element) {
432
+ if (typeof(element) == 'string') element = '#' + element;
433
+ $(element).remove();
434
+ },
435
+
436
+ hide: function(element) {
437
+ if (typeof(element) == 'string') element = '#' + element;
438
+ $(element).hide();
439
+ },
440
+
441
+ show: function(element) {
442
+ if (typeof(element) == 'string') element = '#' + element;
443
+ $(element).show();
444
+ },
445
+
446
+ reset_form: function(element) {
447
+ if (typeof(element) == 'string') element = '#' + element;
448
+ $(element).get(0).reset();
449
+ },
450
+
451
+ disable_form: function(as_form) {
452
+ if (typeof(as_form) == 'string') as_form = '#' + as_form;
453
+ as_form = $(as_form)
454
+ var loading_indicator = $('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
455
+ if (loading_indicator) loading_indicator.css('visibility','visible');
456
+ $('input[type=submit]', as_form).attr('disabled', 'disabled');
457
+ $("input:enabled,select:enabled,textarea:enabled", as_form).attr('disabled', 'disabled');
458
+ },
459
+
460
+ enable_form: function(as_form) {
461
+ if (typeof(as_form) == 'string') as_form = '#' + as_form;
462
+ as_form = $(as_form)
463
+ var loading_indicator = $('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
464
+ if (loading_indicator) loading_indicator.css('visibility','hidden');
465
+ $('input[type=submit]', as_form).attr('disabled', '');
466
+ $("input:disabled,select:disabled,textarea:disabled", as_form).attr('disabled', '');
467
+ },
468
+
469
+ focus_first_element_of_form: function(form_element) {
470
+ if (typeof(form_element) == 'string') form_element = '#' + form_element;
471
+ $(form_element + ":first *:input[type!=hidden]:first").focus();
472
+ },
473
+
474
+ create_record_row: function(active_scaffold_id, html, options) {
475
+ if (typeof(active_scaffold_id) == 'string') active_scaffold_id = '#' + active_scaffold_id;
476
+ tbody = $(active_scaffold_id).find('tbody.records');
477
+
478
+ if (options.insert_at == 'top') {
479
+ tbody.prepend(html);
480
+ var new_row = tbody.children('tr.record:first-child');
481
+ } else if (options.insert_at == 'bottom') {
482
+ var rows = tbody.children('tr.record, tr.inline-adapter');
483
+ var new_row = null;
484
+ if (rows.length > 0) {
485
+ new_row = rows.last().after(html).next();
486
+ } else {
487
+ new_row = tbody.append(html).children().last();
488
+ }
489
+ }
490
+ this.stripe(tbody);
491
+ this.hide_empty_message(tbody);
492
+ this.increment_record_count(tbody.closest('div.active-scaffold'));
493
+ ActiveScaffold.highlight(new_row);
494
+ },
495
+
496
+ delete_record_row: function(row, page_reload_url) {
497
+ if (typeof(row) == 'string') row = '#' + row;
498
+ row = $(row);
499
+ var tbody = row.closest('tbody.records');
500
+
501
+ var current_action_node = row.find('td.actions a.disabled').first();
502
+ if (current_action_node) {
503
+ var action_link = ActiveScaffold.ActionLink.get(current_action_node);
504
+ if (action_link) {
505
+ action_link.close_previous_adapter();
506
+ }
507
+ }
508
+
509
+ row.remove();
510
+ this.stripe(tbody);
511
+ this.decrement_record_count(tbody.closest('div.active-scaffold'));
512
+ this.reload_if_empty(tbody, page_reload_url);
513
+ },
514
+
515
+ delete_subform_record: function(record) {
516
+ if (typeof(record) == 'string') record = '#' + record;
517
+ record = $(record);
518
+ var errors = record.prev();
519
+ if (errors.hasClass('association-record-errors')) {
520
+ this.replace_html(errors, '');
521
+ }
522
+ this.remove(record);
523
+ },
524
+
525
+ report_500_response: function(active_scaffold_id) {
526
+ server_error = $(active_scaffold_id).find('td.messages-container p.server-error');
527
+ if (!$(server_error).is(':visible')) {
528
+ server_error.show();
529
+ }
530
+ },
531
+
532
+ find_action_link: function(element) {
533
+ if (typeof(element) == 'string') element = '#' + element;
534
+ var as_adapter = $(element).closest('.as_adapter');
535
+ return ActiveScaffold.ActionLink.get(as_adapter);
536
+ },
537
+
538
+ scroll_to: function(element) {
539
+ if (typeof(element) == 'string') element = '#' + element;
540
+ var form_offset = $(element).offset(),
541
+ destination = form_offset.top;
542
+ $(document).scrollTop(destination);
543
+ },
544
+
545
+ process_checkbox_inplace_edit: function(checkbox, options) {
546
+ var checked = checkbox.is(':checked');
547
+ if (checked === true) options['params'] += '&value=1';
548
+ $.ajax({
549
+ url: options.url,
550
+ type: "POST",
551
+ data: options['params'],
552
+ dataType: options.ajax_data_type,
553
+ after: function(request){
554
+ checkbox.attr('disabled', 'disabled');
555
+ },
556
+ complete: function(request){
557
+ checkbox.attr('disabled', '');
558
+ }
559
+ });
560
+ },
561
+
562
+ read_inplace_edit_heading_attributes: function(column_heading, options) {
563
+ if (column_heading.attr('data-ie_cancel_text')) options.cancel_button = '<button class="inplace_cancel">' + column_heading.attr('data-ie_cancel_text') + "</button>";
564
+ if (column_heading.attr('data-ie_loading_text')) options.loading_text = column_heading.attr('data-ie_loading_text');
565
+ if (column_heading.attr('data-ie_saving_text')) options.saving_text = column_heading.attr('data-ie_saving_text');
566
+ if (column_heading.attr('data-ie_save_text')) options.save_button = '<button class="inplace_save">' + column_heading.attr('data-ie_save_text') + "</button>";
567
+ if (column_heading.attr('data-ie_rows')) options.textarea_rows = column_heading.attr('data-ie_rows');
568
+ if (column_heading.attr('data-ie_cols')) options.textarea_cols = column_heading.attr('data-ie_cols');
569
+ if (column_heading.attr('data-ie_size')) options.text_size = column_heading.attr('data-ie_size');
570
+ },
571
+
572
+ create_inplace_editor: function(span, options) {
573
+ span.removeClass('hover');
574
+ span.editInPlace(options);
575
+ span.trigger('click.editInPlace');
576
+ },
577
+
578
+ highlight: function(element) {
579
+ if (typeof(element) == 'string') element = $('#' + element);
580
+ if (typeof(element.effect) == 'function') {
581
+ element.effect("highlight", {}, 3000);
582
+ }
583
+ },
584
+
585
+ create_visibility_toggle: function(element, options) {
586
+ if (typeof(element) == 'string') element = '#' + element;
587
+ var toggable = $(element);
588
+ var toggler = toggable.prev();
589
+ var initial_label = (options.default_visible === true) ? options.hide_label : options.show_label;
590
+
591
+ toggler.append(' (<a class="visibility-toggle" href="#">' + initial_label + '</a>)');
592
+ toggler.children('a').click(function() {
593
+ toggable.toggle();
594
+ $(this).html((toggable.is(':hidden')) ? options.show_label : options.hide_label);
595
+ return false;
596
+ });
597
+ },
598
+
599
+ create_associated_record_form: function(element, content, options) {
600
+ if (typeof(element) == 'string') element = '#' + element;
601
+ var element = $(element);
602
+ if (options.singular == false) {
603
+ if (!(options.id && $('#' + options.id).size() > 0)) {
604
+ element.append(content);
605
+ }
606
+ } else {
607
+ var current = $('#' + element.attr('id') + ' .association-record')
608
+ if (current[0]) {
609
+ this.replace(current[0], content);
610
+ } else {
611
+ element.prepend(content);
612
+ }
613
+ }
614
+ },
615
+
616
+ render_form_field: function(source, content, options) {
617
+ if (typeof(source) == 'string') source = '#' + source;
618
+ var source = $(source);
619
+ var element = source.closest('.association-record');
620
+ if (element.length == 0) {
621
+ element = source.closest('ol.form');
622
+ }
623
+ element = element.find('.' + options.field_class + ":first");
624
+
625
+ if (element) {
626
+ if (options.is_subform == false) {
627
+ this.replace(element.closest('dl'), content);
628
+ } else {
629
+ this.replace_html(element, content);
630
+ }
631
+ }
632
+ },
633
+
634
+ sortable: function(element, controller, options, url_params) {
635
+ if (typeof(element) == 'string') element = '#' + element;
636
+ var element = $(element);
637
+ var sortable_options = {};
638
+ if (options.update === true) {
639
+ url_params.authenticity_token = $('meta[name=csrf-param]').attr('content');
640
+ sortable_options.update = function(event, ui) {
641
+ var url = controller + '/' + options.action + '?'
642
+ url += $(this).sortable('serialize',{key: encodeURIComponent($(this).attr('id') + '[]'), expression:/^[^_-](?:[A-Za-z0-9_-]*)-(.*)-row$/});
643
+ $.post(url.append_params(url_params));
644
+ }
645
+ }
646
+ element.sortable(sortable_options);
647
+ },
648
+
649
+ record_select_onselect: function(edit_associated_url, active_scaffold_id, id){
650
+ $.ajax({
651
+ url: edit_associated_url.split('--ID--').join(id),
652
+ error: function(xhr, textStatus, errorThrown){
653
+ ActiveScaffold.report_500_response(active_scaffold_id)
654
+ }
655
+ });
656
+ },
657
+
658
+ // element is tbody id
659
+ mark_records: function(element, options) {
660
+ if (typeof(element) == 'string') element = '#' + element;
661
+ var element = $(element);
662
+ var mark_checkboxes = $('#' + element.attr('id') + ' > tr.record td.marked-column input[type="checkbox"]');
663
+ mark_checkboxes.each(function (index) {
664
+ var item = $(this);
665
+ if(options.checked === true) {
666
+ item.attr('checked', 'checked');
667
+ } else {
668
+ item.removeAttr('checked');
669
+ }
670
+ item.attr('value', ('' + !options.checked));
671
+ });
672
+ if(options.include_mark_all === true) {
673
+ var mark_all_checkbox = element.prev('thead').find('th.marked-column_heading span input[type="checkbox"]');
674
+ if(options.checked === true) {
675
+ mark_all_checkbox.attr('checked', 'checked');
676
+ } else {
677
+ mark_all_checkbox.removeAttr('checked');
678
+ }
679
+ mark_all_checkbox.attr('value', ('' + !options.checked));
680
+ }
681
+ },
682
+
683
+ in_place_editor_field_clicked: function(span) {
684
+ span.data(); // jquery 1.4.2 workaround
685
+ if (typeof(span.data('editInPlace')) === 'undefined') {
686
+ var options = {show_buttons: true,
687
+ hover_class: 'hover',
688
+ element_id: 'editor_id',
689
+ ajax_data_type: "script",
690
+ update_value: 'value'},
691
+ csrf_param = $('meta[name=csrf-param]').first(),
692
+ csrf_token = $('meta[name=csrf-token]').first(),
693
+ my_parent = span.parent(),
694
+ column_heading = null;
695
+
696
+ if(!(my_parent.is('td') || my_parent.is('th'))){
697
+ my_parent = span.parents('td').eq(0);
698
+ }
699
+
700
+ if (my_parent.is('td')) {
701
+ var column_no = my_parent.prevAll('td').length;
702
+ column_heading = my_parent.closest('.active-scaffold').find('th:eq(' + column_no + ')');
703
+ } else if (my_parent.is('th')) {
704
+ column_heading = my_parent;
705
+ }
706
+
707
+ var render_url = column_heading.attr('data-ie_render_url'),
708
+ mode = column_heading.attr('data-ie_mode'),
709
+ record_id = span.attr('data-ie_id');
710
+
711
+ ActiveScaffold.read_inplace_edit_heading_attributes(column_heading, options);
712
+
713
+ if (span.attr('data-ie_url')) {
714
+ options.url = span.attr('data-ie_url').replace(/__id__/, record_id);
715
+ } else {
716
+ options.url = column_heading.attr('data-ie_url').replace(/__id__/, record_id);
717
+ }
718
+
719
+ if (csrf_param) options['params'] = csrf_param.attr('content') + '=' + csrf_token.attr('content');
720
+
721
+ if (span.closest('div.active-scaffold').attr('data-eid')) {
722
+ if (options['params'].length > 0) {
723
+ options['params'] += "&";
724
+ }
725
+ options['params'] += ("eid=" + span.closest('div.active-scaffold').attr('data-eid'));
726
+ }
727
+
728
+ if (mode === 'clone') {
729
+ options.clone_id_suffix = record_id;
730
+ options.clone_selector = '#' + column_heading.attr('id') + ' .as_inplace_pattern';
731
+ options.field_type = 'clone';
732
+ }
733
+
734
+ if (render_url) {
735
+ var plural = false;
736
+ if (column_heading.attr('data-ie_plural')) plural = true;
737
+ options.field_type = 'remote';
738
+ options.editor_url = render_url.replace(/__id__/, record_id)
739
+ }
740
+ if (mode === 'inline_checkbox') {
741
+ ActiveScaffold.process_checkbox_inplace_edit(span.find('input:checkbox'), options);
742
+ } else {
743
+ ActiveScaffold.create_inplace_editor(span, options);
744
+ }
745
+ }
746
+ },
747
+
748
+ update_column: function(element, url, send_form, source_id, val) {
749
+ var as_form = element.closest('form.as_form');
750
+ var params = null;
751
+
752
+ if (send_form) {
753
+ params = as_form.serialize();
754
+ params += '&' + $.param({"source_id": source_id});
755
+ } else {
756
+ params = {value: val};
757
+ params.source_id = source_id;
758
+ }
759
+
760
+ $.ajax({
761
+ url: url,
762
+ data: params,
763
+ beforeSend: function(event) {
764
+ element.nextAll('img.loading-indicator').css('visibility','visible');
765
+ ActiveScaffold.disable_form(as_form);
766
+ },
767
+ complete: function(event) {
768
+ element.nextAll('img.loading-indicator').css('visibility','hidden');
769
+ ActiveScaffold.enable_form(as_form);
770
+ },
771
+ error: function (xhr, status, error) {
772
+ var as_div = element.closest("div.active-scaffold");
773
+ if (as_div) {
774
+ ActiveScaffold.report_500_response(as_div);
775
+ }
776
+ }
777
+ });
778
+ }
779
+ }
780
+
781
+ /*
782
+ * DHTML history tie-in
783
+ */
784
+ function addActiveScaffoldPageToHistory(url, active_scaffold_id) {
785
+ if (typeof dhtmlHistory == 'undefined') return; // it may not be loaded
786
+
787
+ var array = url.split('?');
788
+ var qs = new Querystring(array[1]);
789
+ var sort = qs.get('sort')
790
+ var dir = qs.get('sort_direction')
791
+ var page = qs.get('page')
792
+ if (sort || dir || page) dhtmlHistory.add(active_scaffold_id+":"+page+":"+sort+":"+dir, url);
793
+ }
794
+
795
+ /*
796
+ * URL modification support. Incomplete functionality.
797
+ */
798
+ String.prototype.append_params = function(params) {
799
+ var url = this;
800
+ if (url.indexOf('?') == -1) url += '?';
801
+ else if (url.lastIndexOf('&') != url.length) url += '&';
802
+
803
+ for(var key in params) {
804
+ if (key) url += (key + '=' + params[key] + '&');
805
+ }
806
+
807
+ // the loop leaves a comma dangling at the end of string, chop it off
808
+ url = url.substring(0, url.length-1);
809
+ return url;
810
+ };
811
+
812
+
813
+ /**
814
+ * A set of links. As a set, they can be controlled such that only one is "open" at a time, etc.
815
+ */
816
+ ActiveScaffold.Actions = new Object();
817
+ ActiveScaffold.Actions.Abstract = Class.extend({
818
+ init: function(links, target, loading_indicator, options) {
819
+ this.target = $(target);
820
+ this.loading_indicator = $(loading_indicator);
821
+ this.options = options;
822
+ var _this = this;
823
+ this.links = $.map(links, function(link) {
824
+ var my_link = _this.instantiate_link(link);
825
+ return my_link;
826
+ });
827
+ },
828
+
829
+ instantiate_link: function(link) {
830
+ throw 'unimplemented'
831
+ }
832
+ });
833
+
834
+ /**
835
+ * A DataStructures::ActionLink, represented in JavaScript.
836
+ * Concerned with AJAX-enabling a link and adapting the result for insertion into the table.
837
+ */
838
+ ActiveScaffold.ActionLink = {
839
+ get: function(element) {
840
+ if (typeof(element) == 'string') element = '#' + element;
841
+ var element = $(element);
842
+ if (element.length > 0) {
843
+ element.data(); // jquery 1.4.2 workaround
844
+ if (typeof(element.data('action_link')) === 'undefined' && !element.hasClass('as_adapter')) {
845
+ var parent = element.closest('.actions');
846
+ if (parent.length === 0) {
847
+ // maybe an column action_link
848
+ parent = element.parent();
849
+ }
850
+ if (parent && parent.is('td')) {
851
+ // record action
852
+ parent = parent.closest('tr.record');
853
+ var target = parent.find('a.as_action');
854
+ var loading_indicator = parent.find('td.actions .loading-indicator');
855
+ new ActiveScaffold.Actions.Record(target, parent, loading_indicator);
856
+ } else if (parent && parent.is('div')) {
857
+ //table action
858
+ new ActiveScaffold.Actions.Table(parent.find('a.as_action'), parent.closest('div.active-scaffold').find('tbody.before-header'), parent.find('.loading-indicator'));
859
+ }
860
+ element = $(element);
861
+ }
862
+ return element.data('action_link');
863
+ } else {
864
+ return null;
865
+ }
866
+ }
867
+ };
868
+ ActiveScaffold.ActionLink.Abstract = Class.extend({
869
+ init: function(a, target, loading_indicator) {
870
+ this.tag = $(a);
871
+ this.url = this.tag.attr('href');
872
+ this.method = this.tag.attr('data-method') || 'get';
873
+ this.target = target;
874
+ this.loading_indicator = loading_indicator;
875
+ this.hide_target = false;
876
+ this.position = this.tag.attr('data-position');
877
+ this.action = this.tag.attr('data-action');
878
+
879
+ this.tag.data('action_link', this);
880
+ return this;
881
+ },
882
+
883
+ open: function(event) {
884
+ },
885
+
886
+ insert: function(content) {
887
+ throw 'unimplemented'
888
+ },
889
+
890
+ close: function() {
891
+ this.enable();
892
+ this.adapter.remove();
893
+ if (this.hide_target) this.target.show();
894
+ },
895
+
896
+ reload: function() {
897
+ this.close();
898
+ this.open();
899
+ },
900
+
901
+ get_new_adapter_id: function() {
902
+ var id = 'adapter_';
903
+ var i = 0;
904
+ while ($(id + i)) i++;
905
+ return id + i;
906
+ },
907
+
908
+ enable: function() {
909
+ return this.tag.removeClass('disabled');
910
+ },
911
+
912
+ disable: function() {
913
+ return this.tag.addClass('disabled');
914
+ },
915
+
916
+ is_disabled: function() {
917
+ return this.tag.hasClass('disabled');
918
+ },
919
+
920
+ scaffold_id: function() {
921
+ return '#' + this.tag.closest('div.active-scaffold').attr('id');
922
+ },
923
+
924
+ scaffold: function() {
925
+ return this.tag.closest('div.active-scaffold');
926
+ },
927
+
928
+ update_flash_messages: function(messages) {
929
+ message_node = $(this.scaffold_id().replace(/-active-scaffold/, '-messages'));
930
+ if (message_node) message_node.html(messages);
931
+ },
932
+ set_adapter: function(element) {
933
+ this.adapter = element;
934
+ this.adapter.addClass('as_adapter');
935
+ this.adapter.data('action_link', this);
936
+ }
937
+ });
938
+
939
+ /**
940
+ * Concrete classes for record actions
941
+ */
942
+ ActiveScaffold.Actions.Record = ActiveScaffold.Actions.Abstract.extend({
943
+ instantiate_link: function(link) {
944
+ var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
945
+ var refresh = this.target.attr('data-refresh');
946
+ if (refresh) l.refresh_url = refresh;
947
+
948
+ if (l.position) {
949
+ l.url = l.url.append_params({adapter: '_list_inline_adapter'});
950
+ l.tag.attr('href', l.url);
951
+ }
952
+ l.set = this;
953
+ return l;
954
+ }
955
+ });
956
+
957
+ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
958
+ close_previous_adapter: function() {
959
+ var _this = this;
960
+ $.each(this.set.links, function(index, item) {
961
+ if (item.url != _this.url && item.is_disabled() && item.adapter) {
962
+ item.enable();
963
+ item.adapter.remove();
964
+ }
965
+ });
966
+ },
967
+
968
+ insert: function(content) {
969
+ this.close_previous_adapter();
970
+
971
+ if (this.position == 'replace') {
972
+ this.position = 'after';
973
+ this.hide_target = true;
974
+ }
975
+
976
+ if (this.position == 'after') {
977
+ this.target.after(content);
978
+ this.set_adapter(this.target.next());
979
+ }
980
+ else if (this.position == 'before') {
981
+ this.target.before(content);
982
+ this.set_adapter(this.target.prev());
983
+ }
984
+ else {
985
+ return false;
986
+ }
987
+ ActiveScaffold.highlight(this.adapter.find('td'));
988
+ },
989
+
990
+ close: function(refreshed_content) {
991
+ if (refreshed_content) {
992
+ ActiveScaffold.update_row(this.target, refreshed_content);
993
+ }
994
+ this._super();
995
+ },
996
+
997
+ enable: function() {
998
+ var _this = this;
999
+ $.each(this.set.links, function(index, item) {
1000
+ if (item.url != _this.url) return;
1001
+ item.tag.removeClass('disabled');
1002
+ });
1003
+ },
1004
+
1005
+ disable: function() {
1006
+ var _this = this;
1007
+ $.each(this.set.links, function(index, item) {
1008
+ if (item.url != _this.url) return;
1009
+ item.tag.addClass('disabled');
1010
+ });
1011
+ },
1012
+
1013
+ set_opened: function() {
1014
+ if (this.position == 'after') {
1015
+ this.set_adapter(this.target.next());
1016
+ }
1017
+ else if (this.position == 'before') {
1018
+ this.set_adapter(this.target.prev());
1019
+ }
1020
+ this.disable();
1021
+ }
1022
+ });
1023
+
1024
+ /**
1025
+ * Concrete classes for table actions
1026
+ */
1027
+ ActiveScaffold.Actions.Table = ActiveScaffold.Actions.Abstract.extend({
1028
+ instantiate_link: function(link) {
1029
+ var l = new ActiveScaffold.ActionLink.Table(link, this.target, this.loading_indicator);
1030
+ if (l.position) {
1031
+ l.url = l.url.append_params({adapter: '_list_inline_adapter'});
1032
+ l.tag.attr('href', l.url);
1033
+ }
1034
+ return l;
1035
+ }
1036
+ });
1037
+
1038
+ ActiveScaffold.ActionLink.Table = ActiveScaffold.ActionLink.Abstract.extend({
1039
+ insert: function(content) {
1040
+ if (this.position == 'top') {
1041
+ this.target.prepend(content);
1042
+ this.set_adapter(this.target.children().first());
1043
+ }
1044
+ else {
1045
+ throw 'Unknown position "' + this.position + '"'
1046
+ }
1047
+ ActiveScaffold.highlight(this.adapter.find('td').first().children());
1048
+ }
1049
+ });