active_scaffold_san 3.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. data/.autotest +27 -0
  2. data/.document +5 -0
  3. data/CHANGELOG +179 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +20 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README +69 -0
  8. data/Rakefile +53 -0
  9. data/active_scaffold_vho.gemspec +388 -0
  10. data/frontends/default/images/add.gif +0 -0
  11. data/frontends/default/images/arrow_down.gif +0 -0
  12. data/frontends/default/images/arrow_up.gif +0 -0
  13. data/frontends/default/images/close.gif +0 -0
  14. data/frontends/default/images/config.png +0 -0
  15. data/frontends/default/images/cross.png +0 -0
  16. data/frontends/default/images/gears.png +0 -0
  17. data/frontends/default/images/indicator-small.gif +0 -0
  18. data/frontends/default/images/indicator.gif +0 -0
  19. data/frontends/default/images/magnifier.png +0 -0
  20. data/frontends/default/javascripts/jquery/active_scaffold.js +1004 -0
  21. data/frontends/default/javascripts/jquery/jquery.editinplace.js +743 -0
  22. data/frontends/default/javascripts/prototype/active_scaffold.js +1003 -0
  23. data/frontends/default/javascripts/prototype/dhtml_history.js +867 -0
  24. data/frontends/default/javascripts/prototype/form_enhancements.js +117 -0
  25. data/frontends/default/javascripts/prototype/rico_corner.js +370 -0
  26. data/frontends/default/stylesheets/stylesheet-ie.css +35 -0
  27. data/frontends/default/stylesheets/stylesheet.css +973 -0
  28. data/frontends/default/views/_action_group.html.erb +20 -0
  29. data/frontends/default/views/_add_existing_form.html.erb +30 -0
  30. data/frontends/default/views/_base_form.html.erb +51 -0
  31. data/frontends/default/views/_create_form.html.erb +8 -0
  32. data/frontends/default/views/_create_form_on_list.html.erb +6 -0
  33. data/frontends/default/views/_field_search.html.erb +32 -0
  34. data/frontends/default/views/_form.html.erb +24 -0
  35. data/frontends/default/views/_form_association.html.erb +19 -0
  36. data/frontends/default/views/_form_association_footer.html.erb +40 -0
  37. data/frontends/default/views/_form_attribute.html.erb +15 -0
  38. data/frontends/default/views/_form_hidden_attribute.html.erb +2 -0
  39. data/frontends/default/views/_form_messages.html.erb +5 -0
  40. data/frontends/default/views/_horizontal_subform.html.erb +29 -0
  41. data/frontends/default/views/_horizontal_subform_header.html.erb +10 -0
  42. data/frontends/default/views/_horizontal_subform_record.html.erb +37 -0
  43. data/frontends/default/views/_human_conditions.html.erb +1 -0
  44. data/frontends/default/views/_list.html.erb +18 -0
  45. data/frontends/default/views/_list_actions.html.erb +15 -0
  46. data/frontends/default/views/_list_calculations.html.erb +16 -0
  47. data/frontends/default/views/_list_column_headings.html.erb +12 -0
  48. data/frontends/default/views/_list_header.html.erb +10 -0
  49. data/frontends/default/views/_list_inline_adapter.html.erb +10 -0
  50. data/frontends/default/views/_list_messages.html.erb +32 -0
  51. data/frontends/default/views/_list_pagination.html.erb +11 -0
  52. data/frontends/default/views/_list_pagination_links.html.erb +9 -0
  53. data/frontends/default/views/_list_record.html.erb +14 -0
  54. data/frontends/default/views/_list_record_columns.html.erb +8 -0
  55. data/frontends/default/views/_list_with_header.html.erb +32 -0
  56. data/frontends/default/views/_messages.html.erb +10 -0
  57. data/frontends/default/views/_render_field.js.rjs +10 -0
  58. data/frontends/default/views/_row.html.erb +12 -0
  59. data/frontends/default/views/_search.html.erb +34 -0
  60. data/frontends/default/views/_search_attribute.html.erb +10 -0
  61. data/frontends/default/views/_show.html.erb +8 -0
  62. data/frontends/default/views/_show_columns.html.erb +15 -0
  63. data/frontends/default/views/_update_actions.html.erb +9 -0
  64. data/frontends/default/views/_update_form.html.erb +6 -0
  65. data/frontends/default/views/_vertical_subform.html.erb +12 -0
  66. data/frontends/default/views/_vertical_subform_record.html.erb +38 -0
  67. data/frontends/default/views/action_confirmation.html.erb +13 -0
  68. data/frontends/default/views/add_existing.js.rjs +17 -0
  69. data/frontends/default/views/add_existing_form.html.erb +5 -0
  70. data/frontends/default/views/create.html.erb +5 -0
  71. data/frontends/default/views/delete.html.erb +13 -0
  72. data/frontends/default/views/destroy.js.rjs +23 -0
  73. data/frontends/default/views/edit_associated.js.rjs +11 -0
  74. data/frontends/default/views/field_search.html.erb +5 -0
  75. data/frontends/default/views/form_messages.js.rjs +1 -0
  76. data/frontends/default/views/list.html.erb +1 -0
  77. data/frontends/default/views/list.js.rjs +1 -0
  78. data/frontends/default/views/on_action_update.js.rjs +8 -0
  79. data/frontends/default/views/on_create.js.rjs +41 -0
  80. data/frontends/default/views/on_mark_all.js.rjs +4 -0
  81. data/frontends/default/views/on_update.js.rjs +28 -0
  82. data/frontends/default/views/search.html.erb +5 -0
  83. data/frontends/default/views/show.html.erb +5 -0
  84. data/frontends/default/views/update.html.erb +8 -0
  85. data/frontends/default/views/update_column.js.rjs +13 -0
  86. data/frontends/default/views/update_row.js.rjs +1 -0
  87. data/init.rb +8 -0
  88. data/lib/active_scaffold.rb +360 -0
  89. data/lib/active_scaffold/actions/common_search.rb +22 -0
  90. data/lib/active_scaffold/actions/core.rb +180 -0
  91. data/lib/active_scaffold/actions/create.rb +149 -0
  92. data/lib/active_scaffold/actions/delete.rb +75 -0
  93. data/lib/active_scaffold/actions/field_search.rb +82 -0
  94. data/lib/active_scaffold/actions/list.rb +184 -0
  95. data/lib/active_scaffold/actions/mark.rb +63 -0
  96. data/lib/active_scaffold/actions/nested.rb +250 -0
  97. data/lib/active_scaffold/actions/search.rb +47 -0
  98. data/lib/active_scaffold/actions/show.rb +61 -0
  99. data/lib/active_scaffold/actions/subform.rb +27 -0
  100. data/lib/active_scaffold/actions/update.rb +151 -0
  101. data/lib/active_scaffold/active_record_permissions.rb +134 -0
  102. data/lib/active_scaffold/attribute_params.rb +211 -0
  103. data/lib/active_scaffold/bridges/ancestry/bridge.rb +5 -0
  104. data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +39 -0
  105. data/lib/active_scaffold/bridges/bridge.rb +59 -0
  106. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +16 -0
  107. data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +83 -0
  108. data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
  109. data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
  110. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +9 -0
  111. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +33 -0
  112. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +12 -0
  113. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +45 -0
  114. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +17 -0
  115. data/lib/active_scaffold/bridges/date_picker/bridge.rb +24 -0
  116. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +225 -0
  117. data/lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js +22 -0
  118. data/lib/active_scaffold/bridges/file_column/bridge.rb +11 -0
  119. data/lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb +46 -0
  120. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +59 -0
  121. data/lib/active_scaffold/bridges/file_column/lib/form_ui.rb +37 -0
  122. data/lib/active_scaffold/bridges/file_column/lib/list_ui.rb +26 -0
  123. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
  124. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
  125. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
  126. data/lib/active_scaffold/bridges/paperclip/bridge.rb +12 -0
  127. data/lib/active_scaffold/bridges/paperclip/lib/form_ui.rb +27 -0
  128. data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +16 -0
  129. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +38 -0
  130. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +26 -0
  131. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +5 -0
  132. data/lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
  133. data/lib/active_scaffold/bridges/shared/date_bridge.rb +209 -0
  134. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +5 -0
  135. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +61 -0
  136. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +8 -0
  137. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +21 -0
  138. data/lib/active_scaffold/config/base.rb +62 -0
  139. data/lib/active_scaffold/config/core.rb +220 -0
  140. data/lib/active_scaffold/config/create.rb +51 -0
  141. data/lib/active_scaffold/config/delete.rb +34 -0
  142. data/lib/active_scaffold/config/field_search.rb +75 -0
  143. data/lib/active_scaffold/config/form.rb +47 -0
  144. data/lib/active_scaffold/config/list.rb +174 -0
  145. data/lib/active_scaffold/config/mark.rb +22 -0
  146. data/lib/active_scaffold/config/nested.rb +44 -0
  147. data/lib/active_scaffold/config/search.rb +69 -0
  148. data/lib/active_scaffold/config/show.rb +35 -0
  149. data/lib/active_scaffold/config/subform.rb +35 -0
  150. data/lib/active_scaffold/config/update.rb +46 -0
  151. data/lib/active_scaffold/configurable.rb +29 -0
  152. data/lib/active_scaffold/constraints.rb +184 -0
  153. data/lib/active_scaffold/data_structures/action_columns.rb +137 -0
  154. data/lib/active_scaffold/data_structures/action_link.rb +175 -0
  155. data/lib/active_scaffold/data_structures/action_links.rb +185 -0
  156. data/lib/active_scaffold/data_structures/actions.rb +45 -0
  157. data/lib/active_scaffold/data_structures/column.rb +355 -0
  158. data/lib/active_scaffold/data_structures/columns.rb +75 -0
  159. data/lib/active_scaffold/data_structures/error_message.rb +24 -0
  160. data/lib/active_scaffold/data_structures/nested_info.rb +123 -0
  161. data/lib/active_scaffold/data_structures/set.rb +62 -0
  162. data/lib/active_scaffold/data_structures/sorting.rb +168 -0
  163. data/lib/active_scaffold/extensions/action_controller_rendering.rb +20 -0
  164. data/lib/active_scaffold/extensions/action_view_rendering.rb +123 -0
  165. data/lib/active_scaffold/extensions/action_view_resolver.rb +7 -0
  166. data/lib/active_scaffold/extensions/active_association_reflection.rb +13 -0
  167. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  168. data/lib/active_scaffold/extensions/array.rb +7 -0
  169. data/lib/active_scaffold/extensions/localize.rb +10 -0
  170. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +12 -0
  171. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +7 -0
  172. data/lib/active_scaffold/extensions/paginator_extensions.rb +26 -0
  173. data/lib/active_scaffold/extensions/reverse_associations.rb +62 -0
  174. data/lib/active_scaffold/extensions/routing_mapper.rb +34 -0
  175. data/lib/active_scaffold/extensions/to_label.rb +8 -0
  176. data/lib/active_scaffold/extensions/unsaved_associated.rb +61 -0
  177. data/lib/active_scaffold/extensions/unsaved_record.rb +20 -0
  178. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  179. data/lib/active_scaffold/finder.rb +343 -0
  180. data/lib/active_scaffold/helpers/association_helpers.rb +40 -0
  181. data/lib/active_scaffold/helpers/controller_helpers.rb +87 -0
  182. data/lib/active_scaffold/helpers/country_helpers.rb +352 -0
  183. data/lib/active_scaffold/helpers/form_column_helpers.rb +350 -0
  184. data/lib/active_scaffold/helpers/human_condition_helpers.rb +59 -0
  185. data/lib/active_scaffold/helpers/id_helpers.rb +127 -0
  186. data/lib/active_scaffold/helpers/list_column_helpers.rb +361 -0
  187. data/lib/active_scaffold/helpers/pagination_helpers.rb +55 -0
  188. data/lib/active_scaffold/helpers/search_column_helpers.rb +249 -0
  189. data/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
  190. data/lib/active_scaffold/helpers/view_helpers.rb +360 -0
  191. data/lib/active_scaffold/locale/de.rb +120 -0
  192. data/lib/active_scaffold/locale/en.rb +119 -0
  193. data/lib/active_scaffold/locale/es.yml +115 -0
  194. data/lib/active_scaffold/locale/fr.rb +122 -0
  195. data/lib/active_scaffold/locale/hu.yml +63 -0
  196. data/lib/active_scaffold/locale/ja.yml +64 -0
  197. data/lib/active_scaffold/locale/ru.yml +119 -0
  198. data/lib/active_scaffold/marked_model.rb +38 -0
  199. data/lib/active_scaffold/paginator.rb +136 -0
  200. data/lib/active_scaffold/responds_to_parent.rb +70 -0
  201. data/lib/active_scaffold/version.rb +9 -0
  202. data/lib/active_scaffold_assets.rb +45 -0
  203. data/lib/active_scaffold_env.rb +14 -0
  204. data/lib/active_scaffold_vho.rb +2 -0
  205. data/lib/generators/active_scaffold/USAGE +29 -0
  206. data/lib/generators/active_scaffold/active_scaffold_generator.rb +20 -0
  207. data/lib/generators/active_scaffold_controller/USAGE +19 -0
  208. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +29 -0
  209. data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
  210. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  211. data/lib/generators/active_scaffold_setup/USAGE +10 -0
  212. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +61 -0
  213. data/public/blank.html +33 -0
  214. data/shoulda_macros/macros.rb +136 -0
  215. data/test/bridges/bridge_test.rb +47 -0
  216. data/test/config/base_test.rb +15 -0
  217. data/test/config/create_test.rb +55 -0
  218. data/test/config/list_test.rb +74 -0
  219. data/test/config/show_test.rb +43 -0
  220. data/test/config/update_test.rb +17 -0
  221. data/test/const_mocker.rb +36 -0
  222. data/test/data_structures/action_columns_test.rb +113 -0
  223. data/test/data_structures/action_link_test.rb +78 -0
  224. data/test/data_structures/action_links_test.rb +78 -0
  225. data/test/data_structures/actions_test.rb +25 -0
  226. data/test/data_structures/association_column_test.rb +42 -0
  227. data/test/data_structures/column_test.rb +185 -0
  228. data/test/data_structures/columns_test.rb +69 -0
  229. data/test/data_structures/error_message_test.rb +28 -0
  230. data/test/data_structures/set_test.rb +86 -0
  231. data/test/data_structures/sorting_test.rb +126 -0
  232. data/test/data_structures/standard_column_test.rb +24 -0
  233. data/test/data_structures/virtual_column_test.rb +23 -0
  234. data/test/extensions/active_record_test.rb +45 -0
  235. data/test/extensions/array_test.rb +12 -0
  236. data/test/helpers/form_column_helpers_test.rb +31 -0
  237. data/test/helpers/list_column_helpers_test.rb +31 -0
  238. data/test/helpers/pagination_helpers_test.rb +55 -0
  239. data/test/misc/active_record_permissions_test.rb +154 -0
  240. data/test/misc/attribute_params_test.rb +110 -0
  241. data/test/misc/configurable_test.rb +96 -0
  242. data/test/misc/constraints_test.rb +193 -0
  243. data/test/misc/finder_test.rb +93 -0
  244. data/test/misc/lang_test.rb +12 -0
  245. data/test/mock_app/.gitignore +2 -0
  246. data/test/mock_app/app/controllers/application_controller.rb +10 -0
  247. data/test/mock_app/app/helpers/application_helper.rb +3 -0
  248. data/test/mock_app/config/boot.rb +110 -0
  249. data/test/mock_app/config/database.yml +16 -0
  250. data/test/mock_app/config/environment.rb +43 -0
  251. data/test/mock_app/config/environments/development.rb +17 -0
  252. data/test/mock_app/config/environments/production.rb +28 -0
  253. data/test/mock_app/config/environments/test.rb +28 -0
  254. data/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
  255. data/test/mock_app/config/initializers/inflections.rb +10 -0
  256. data/test/mock_app/config/initializers/mime_types.rb +5 -0
  257. data/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
  258. data/test/mock_app/config/initializers/session_store.rb +15 -0
  259. data/test/mock_app/config/locales/en.yml +5 -0
  260. data/test/mock_app/config/routes.rb +43 -0
  261. data/test/mock_app/db/test.sqlite3 +1 -0
  262. data/test/mock_app/public/blank.html +33 -0
  263. data/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
  264. data/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
  265. data/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
  266. data/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
  267. data/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
  268. data/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
  269. data/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
  270. data/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
  271. data/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
  272. data/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
  273. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
  274. data/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
  275. data/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
  276. data/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
  277. data/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
  278. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
  279. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +842 -0
  280. data/test/model_stub.rb +55 -0
  281. data/test/run_all.rb +8 -0
  282. data/test/test_helper.rb +39 -0
  283. data/uninstall.rb +13 -0
  284. metadata +497 -0
@@ -0,0 +1,16 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
@@ -0,0 +1,43 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ #RAILS_GEM_VERSION = '2.3.3' unless defined? RAILS_GEM_VERSION
5
+
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Add additional load paths for your own custom dirs
15
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
16
+
17
+ # Specify gems that this application depends on and have them installed with rake gems:install
18
+ # config.gem "bj"
19
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
20
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
21
+ # config.gem "aws-s3", :lib => "aws/s3"
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+ config.plugin_paths += %W(#{RAILS_ROOT}/../../..)
27
+ config.plugins = [:active_scaffold]
28
+
29
+ # Skip frameworks you're not going to use. To use Rails without a database,
30
+ # you must remove the Active Record framework.
31
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
32
+
33
+ # Activate observers that should always be running
34
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
35
+
36
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
37
+ # Run "rake -D time" for a list of tasks for finding time zone names.
38
+ config.time_zone = 'UTC'
39
+
40
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
41
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
42
+ # config.i18n.default_locale = :de
43
+ end
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.action_controller.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+ config.action_view.cache_template_loading = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Enable serving of images, stylesheets, and javascripts from an asset server
22
+ # config.action_controller.asset_host = "http://assets.example.com"
23
+
24
+ # Disable delivery errors, bad email addresses will be ignored
25
+ # config.action_mailer.raise_delivery_errors = false
26
+
27
+ # Enable threaded mode
28
+ # config.threadsafe!
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+ config.action_view.cache_template_loading = true
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,19 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # These settings change the behavior of Rails 2 apps and will be defaults
4
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
5
+
6
+ if defined?(ActiveRecord)
7
+ # Include Active Record class name as root for JSON serialized output.
8
+ ActiveRecord::Base.include_root_in_json = true
9
+
10
+ # Store the full class name (including module namespace) in STI type column.
11
+ ActiveRecord::Base.store_full_sti_class = true
12
+ end
13
+
14
+ # Use ISO 8601 format for JSON serialized times and dates.
15
+ ActiveSupport.use_standard_json_time_format = true
16
+
17
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
18
+ # if you're including raw json in an HTML page.
19
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying cookie session data integrity.
4
+ # If you change this key, all old sessions will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ ActionController::Base.session = {
8
+ :key => '_mock_app_session',
9
+ :secret => 'ed0122432f6132fc5c99c928dc133a0863df7f24b0f2d53ce9dc2e9885a9b1f944d8ac6390333e2f1a72f902554bdaca75024fb23eb11a4548b0af4731439be2'
10
+ }
11
+
12
+ # Use the database for sessions instead of the cookie-based default,
13
+ # which shouldn't be used to store highly confidential information
14
+ # (create the session table with "rake db:sessions:create")
15
+ # ActionController::Base.session_store = :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,43 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ # map.root :controller => "welcome"
35
+
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing or commenting them out if you're using named routes and resources.
41
+ map.connect ':controller/:action/:id'
42
+ map.connect ':controller/:action/:id.:format'
43
+ end
@@ -0,0 +1 @@
1
+ S
@@ -0,0 +1,33 @@
1
+ <!--
2
+ Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
3
+ http://codinginparadise.org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the "Software"),
7
+ to deal in the Software without restriction, including without limitation
8
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
+ and/or sell copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
20
+ OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ -->
23
+
24
+ <html>
25
+ <script language="JavaScript">
26
+ function pageLoaded() {
27
+ window.parent.dhtmlHistory.iframeLoaded(window.location);
28
+ }
29
+ </script>
30
+ <body onload="pageLoaded()">
31
+ <h1>blank.html - Needed for Internet Explorer's hidden IFrame</h1>
32
+ </body>
33
+ </html>
@@ -0,0 +1,2 @@
1
+ Any changes made to files in sub-folders will be lost.
2
+ See http://activescaffold.com/tutorials/faq#custom-css.
@@ -0,0 +1,2 @@
1
+ Any changes made to files in sub-folders will be lost.
2
+ See http://activescaffold.com/tutorials/faq#custom-css.
@@ -0,0 +1,532 @@
1
+ if (typeof Prototype == 'undefined')
2
+ {
3
+ warning = "ActiveScaffold Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (e.g. <%= javascript_include_tag :defaults %>) *before* it includes active_scaffold.js (e.g. <%= active_scaffold_includes %>).";
4
+ alert(warning);
5
+ }
6
+ if (Prototype.Version.substring(0, 3) != '1.6')
7
+ {
8
+ warning = "ActiveScaffold Error: Prototype version 1.6.x is required. Please update prototype.js (rake rails:update:javascripts).";
9
+ alert(warning);
10
+ }
11
+ if (!Element.Methods.highlight) Element.addMethods({highlight: Prototype.emptyFunction});
12
+
13
+
14
+ /*
15
+ * Simple utility methods
16
+ */
17
+
18
+ var ActiveScaffold = {
19
+ records_for: function(tbody_id) {
20
+ var rows = [];
21
+ var child = $(tbody_id).down('.record');
22
+ while (child) {
23
+ rows.push(child);
24
+ child = child.next('.record');
25
+ }
26
+ return rows;
27
+ },
28
+ stripe: function(tbody_id) {
29
+ var even = false;
30
+ var rows = this.records_for(tbody_id);
31
+ for (var i = 0; i < rows.length; i++) {
32
+ var child = rows[i];
33
+ //Make sure to skip rows that are create or edit rows or messages
34
+ if (child.tagName != 'SCRIPT'
35
+ && !child.hasClassName("create")
36
+ && !child.hasClassName("update")
37
+ && !child.hasClassName("inline-adapter")
38
+ && !child.hasClassName("active-scaffold-calculations")) {
39
+
40
+ if (even) child.addClassName("even-record");
41
+ else child.removeClassName("even-record");
42
+
43
+ even = !even;
44
+ }
45
+ }
46
+ },
47
+ hide_empty_message: function(tbody, empty_message_id) {
48
+ if (this.records_for(tbody).length != 0) {
49
+ $(empty_message_id).hide();
50
+ }
51
+ },
52
+ reload_if_empty: function(tbody, url) {
53
+ if (this.records_for(tbody).length == 0) {
54
+ new Ajax.Request(url, {
55
+ method: 'get',
56
+ asynchronous: true,
57
+ evalScripts: true
58
+ });
59
+ }
60
+ },
61
+ removeSortClasses: function(scaffold_id) {
62
+ $$('#' + scaffold_id + ' td.sorted').each(function(element) {
63
+ element.removeClassName("sorted");
64
+ });
65
+ $$('#' + scaffold_id + ' th.sorted').each(function(element) {
66
+ element.removeClassName("sorted");
67
+ element.removeClassName("asc");
68
+ element.removeClassName("desc");
69
+ });
70
+ },
71
+ decrement_record_count: function(scaffold_id) {
72
+ // decrement the last record count, firsts record count are in nested lists
73
+ count = $$('#' + scaffold_id + ' span.active-scaffold-records').last();
74
+ if (count) count.update(parseInt(count.innerHTML, 10) - 1);
75
+ },
76
+ increment_record_count: function(scaffold_id) {
77
+ // increment the last record count, firsts record count are in nested lists
78
+ count = $$('#' + scaffold_id + ' span.active-scaffold-records').last();
79
+ if (count) count.update(parseInt(count.innerHTML, 10) + 1);
80
+ },
81
+ update_row: function(row, html) {
82
+ row = $(row);
83
+ Element.replace(row, html);
84
+ var new_row = $(row.id);
85
+ if (row.hasClassName('even-record')) new_row.addClassName('even-record');
86
+ new_row.highlight();
87
+ },
88
+
89
+ server_error_response: '',
90
+ report_500_response: function(active_scaffold_id) {
91
+ messages_container = $(active_scaffold_id).down('td.messages-container');
92
+ new Insertion.Top(messages_container, this.server_error_response);
93
+ }
94
+ }
95
+
96
+ /*
97
+ * DHTML history tie-in
98
+ */
99
+ function addActiveScaffoldPageToHistory(url, active_scaffold_id) {
100
+ if (typeof dhtmlHistory == 'undefined') return; // it may not be loaded
101
+
102
+ var array = url.split('?');
103
+ var qs = new Querystring(array[1]);
104
+ var sort = qs.get('sort')
105
+ var dir = qs.get('sort_direction')
106
+ var page = qs.get('page')
107
+ if (sort || dir || page) dhtmlHistory.add(active_scaffold_id+":"+page+":"+sort+":"+dir, url);
108
+ }
109
+
110
+ /*
111
+ * Add-ons/Patches to Prototype
112
+ */
113
+
114
+ /* patch to support replacing TR/TD/TBODY in Internet Explorer, courtesy of http://dev.rubyonrails.org/ticket/4273 */
115
+ Element.replace = function(element, html) {
116
+ element = $(element);
117
+ if (element.outerHTML) {
118
+ try {
119
+ element.outerHTML = html.stripScripts();
120
+ } catch (e) {
121
+ var tn = element.tagName;
122
+ if(tn=='TBODY' || tn=='TR' || tn=='TD')
123
+ {
124
+ var tempDiv = document.createElement("div");
125
+ tempDiv.innerHTML = '<table id="tempTable" style="display: none">' + html.stripScripts() + '</table>';
126
+ element.parentNode.replaceChild(tempDiv.getElementsByTagName(tn).item(0), element);
127
+ }
128
+ else throw e;
129
+ }
130
+ } else {
131
+ var range = element.ownerDocument.createRange();
132
+ /* patch to fix <form> replaces in Firefox. see http://dev.rubyonrails.org/ticket/8010 */
133
+ range.selectNodeContents(element.parentNode);
134
+ element.parentNode.replaceChild(range.createContextualFragment(html.stripScripts()), element);
135
+ }
136
+ setTimeout(function() {html.evalScripts()}, 10);
137
+ return element;
138
+ };
139
+
140
+ /*
141
+ * URL modification support. Incomplete functionality.
142
+ */
143
+ Object.extend(String.prototype, {
144
+ append_params: function(params) {
145
+ url = this;
146
+ if (url.indexOf('?') == -1) url += '?';
147
+ else if (url.lastIndexOf('&') != url.length) url += '&';
148
+
149
+ url += $H(params).collect(function(item) {
150
+ return item.key + '=' + item.value;
151
+ }).join('&');
152
+
153
+ return url;
154
+ }
155
+ });
156
+
157
+ /*
158
+ * Prototype's implementation was throwing an error instead of false
159
+ */
160
+ Element.Methods.Simulated = {
161
+ hasAttribute: function(element, attribute) {
162
+ var t = Element._attributeTranslations;
163
+ attribute = (t.names && t.names[attribute]) || attribute;
164
+ // Return false if we get an error here
165
+ try {
166
+ return $(element).getAttributeNode(attribute).specified;
167
+ } catch (e) {
168
+ return false;
169
+ }
170
+ }
171
+ };
172
+
173
+ /**
174
+ * A set of links. As a set, they can be controlled such that only one is "open" at a time, etc.
175
+ */
176
+ ActiveScaffold.Actions = new Object();
177
+ ActiveScaffold.Actions.Abstract = Class.create({
178
+ initialize: function(links, target, loading_indicator, options) {
179
+ this.target = $(target);
180
+ this.loading_indicator = $(loading_indicator);
181
+ this.options = options;
182
+ this.links = links.collect(function(link) {
183
+ return this.instantiate_link(link);
184
+ }.bind(this));
185
+ },
186
+
187
+ instantiate_link: function(link) {
188
+ throw 'unimplemented'
189
+ }
190
+ });
191
+
192
+ /**
193
+ * A DataStructures::ActionLink, represented in JavaScript.
194
+ * Concerned with AJAX-enabling a link and adapting the result for insertion into the table.
195
+ */
196
+ ActiveScaffold.ActionLink = new Object();
197
+ ActiveScaffold.ActionLink.Abstract = Class.create({
198
+ initialize: function(a, target, loading_indicator) {
199
+ this.tag = $(a);
200
+ this.url = this.tag.href;
201
+ this.method = 'get';
202
+ if(this.url.match('_method=delete')){
203
+ this.method = 'delete';
204
+ } else if(this.url.match('_method=post')){
205
+ this.method = 'post';
206
+ } else if(this.url.match('_method=put')){
207
+ this.method = 'put';
208
+ }
209
+ this.target = target;
210
+ this.loading_indicator = loading_indicator;
211
+ this.hide_target = false;
212
+ this.position = this.tag.getAttribute('position');
213
+ this.page_link = this.tag.getAttribute('page_link');
214
+
215
+ this.onclick = this.tag.onclick;
216
+ this.tag.onclick = null;
217
+ this.tag.observe('click', function(event) {
218
+ this.open();
219
+ Event.stop(event);
220
+ }.bind(this));
221
+
222
+ this.tag.action_link = this;
223
+ },
224
+
225
+ open: function() {
226
+ if (this.is_disabled()) return;
227
+
228
+ if (this.tag.hasAttribute( "dhtml_confirm")) {
229
+ if (this.onclick) this.onclick();
230
+ return;
231
+ } else {
232
+ if (this.onclick && !this.onclick()) return;//e.g. confirmation messages
233
+ this.open_action();
234
+ }
235
+ },
236
+
237
+ open_action: function() {
238
+ if (this.position) this.disable();
239
+
240
+ if (this.page_link) {
241
+ window.location = this.url;
242
+ } else {
243
+ if (this.loading_indicator) this.loading_indicator.style.visibility = 'visible';
244
+ new Ajax.Request(this.url, {
245
+ asynchronous: true,
246
+ evalScripts: true,
247
+ method: this.method,
248
+ onSuccess: function(request) {
249
+ if (this.position) {
250
+ this.insert(request.responseText);
251
+ if (this.hide_target) this.target.hide();
252
+ } else {
253
+ request.evalResponse();
254
+ }
255
+ }.bind(this),
256
+
257
+ onFailure: function(request) {
258
+ ActiveScaffold.report_500_response(this.scaffold_id());
259
+ if (this.position) this.enable()
260
+ }.bind(this),
261
+
262
+ onComplete: function(request) {
263
+ if (this.loading_indicator) this.loading_indicator.style.visibility = 'hidden';
264
+ }.bind(this)
265
+ });
266
+ }
267
+ },
268
+
269
+ insert: function(content) {
270
+ throw 'unimplemented'
271
+ },
272
+
273
+ close: function() {
274
+ this.enable();
275
+ this.adapter.remove();
276
+ if (this.hide_target) this.target.show();
277
+ },
278
+
279
+ close_handler: function(event) {
280
+ this.close();
281
+ if (event) Event.stop(event);
282
+ },
283
+
284
+ register_cancel_hooks: function() {
285
+ // anything in the insert with a class of cancel gets the closer method, and a reference to this object for good measure
286
+ var self = this;
287
+ this.adapter.select('.cancel').each(function(elem) {
288
+ elem.observe('click', this.close_handler.bind(this));
289
+ elem.link = self;
290
+ }.bind(this))
291
+ },
292
+
293
+ reload: function() {
294
+ this.close();
295
+ this.open();
296
+ },
297
+
298
+ get_new_adapter_id: function() {
299
+ var id = 'adapter_';
300
+ var i = 0;
301
+ while ($(id + i)) i++;
302
+ return id + i;
303
+ },
304
+
305
+ enable: function() {
306
+ return this.tag.removeClassName('disabled');
307
+ },
308
+
309
+ disable: function() {
310
+ return this.tag.addClassName('disabled');
311
+ },
312
+
313
+ is_disabled: function() {
314
+ return this.tag.hasClassName('disabled');
315
+ },
316
+
317
+ scaffold_id: function() {
318
+ return this.tag.up('div.active-scaffold').id;
319
+ }
320
+ });
321
+
322
+ /**
323
+ * Concrete classes for record actions
324
+ */
325
+ ActiveScaffold.Actions.Record = Class.create(ActiveScaffold.Actions.Abstract, {
326
+ instantiate_link: function(link) {
327
+ var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
328
+ l.refresh_url = this.options.refresh_url;
329
+ if (link.hasClassName('delete')) {
330
+ l.url = l.url.replace(/\/delete(\?.*)?$/, '$1');
331
+ l.url = l.url.replace(/\/delete\/(.*)/, '/destroy/$1');
332
+ }
333
+ if (l.position) l.url = l.url.append_params({adapter: '_list_inline_adapter'});
334
+ l.set = this;
335
+ return l;
336
+ }
337
+ });
338
+
339
+ ActiveScaffold.ActionLink.Record = Class.create(ActiveScaffold.ActionLink.Abstract, {
340
+ close_previous_adapter: function() {
341
+ this.set.links.each(function(item) {
342
+ if (item.url != this.url && item.is_disabled() && item.adapter) {
343
+ item.enable();
344
+ item.adapter.remove();
345
+ }
346
+ }.bind(this));
347
+ },
348
+
349
+ insert: function(content) {
350
+ this.close_previous_adapter();
351
+
352
+ if (this.position == 'replace') {
353
+ this.position = 'after';
354
+ this.hide_target = true;
355
+ }
356
+
357
+ if (this.position == 'after') {
358
+ new Insertion.After(this.target, content);
359
+ this.adapter = this.target.next();
360
+ }
361
+ else if (this.position == 'before') {
362
+ new Insertion.Before(this.target, content);
363
+ this.adapter = this.target.previous();
364
+ }
365
+ else {
366
+ return false;
367
+ }
368
+
369
+ this.adapter.down('a.inline-adapter-close').observe('click', this.close_handler.bind(this));
370
+ this.register_cancel_hooks();
371
+
372
+ this.adapter.down('td').down().highlight();
373
+ },
374
+
375
+ close: function($super, updatedRow) {
376
+ if (updatedRow) {
377
+ ActiveScaffold.update_row(this.target, updatedRow);
378
+ $super();
379
+ } else {
380
+ new Ajax.Request(this.refresh_url, {
381
+ asynchronous: true,
382
+ evalScripts: true,
383
+ method: this.method,
384
+ onSuccess: function(request) {
385
+ ActiveScaffold.update_row(this.target, request.responseText);
386
+ $super();
387
+ }.bind(this),
388
+
389
+ onFailure: function(request) {
390
+ ActiveScaffold.report_500_response(this.scaffold_id());
391
+ }
392
+ });
393
+ }
394
+ },
395
+
396
+ enable: function() {
397
+ this.set.links.each(function(item) {
398
+ if (item.url != this.url) return;
399
+ item.tag.removeClassName('disabled');
400
+ }.bind(this));
401
+ },
402
+
403
+ disable: function() {
404
+ this.set.links.each(function(item) {
405
+ if (item.url != this.url) return;
406
+ item.tag.addClassName('disabled');
407
+ }.bind(this));
408
+ }
409
+ });
410
+
411
+ /**
412
+ * Concrete classes for table actions
413
+ */
414
+ ActiveScaffold.Actions.Table = Class.create(ActiveScaffold.Actions.Abstract, {
415
+ instantiate_link: function(link) {
416
+ var l = new ActiveScaffold.ActionLink.Table(link, this.target, this.loading_indicator);
417
+ if (l.position) l.url = l.url.append_params({adapter: '_list_inline_adapter'});
418
+ return l;
419
+ }
420
+ });
421
+
422
+ ActiveScaffold.ActionLink.Table = Class.create(ActiveScaffold.ActionLink.Abstract, {
423
+ insert: function(content) {
424
+ if (this.position == 'top') {
425
+ new Insertion.Top(this.target, content);
426
+ this.adapter = this.target.immediateDescendants().first();
427
+ }
428
+ else {
429
+ throw 'Unknown position "' + this.position + '"'
430
+ }
431
+
432
+ this.adapter.down('a.inline-adapter-close').observe('click', this.close_handler.bind(this));
433
+ this.register_cancel_hooks();
434
+
435
+ this.adapter.down('td').down().highlight();
436
+ }
437
+ });
438
+
439
+ if (Ajax.InPlaceEditor) {
440
+ ActiveScaffold.InPlaceEditor = Class.create(Ajax.InPlaceEditor, {
441
+ setFieldFromAjax: function(url, options) {
442
+ var ipe = this;
443
+ $(ipe._controls.editor).remove();
444
+ new Ajax.Request(url, {
445
+ method: 'get',
446
+ onComplete: function(response) {
447
+ ipe._form.insert({top: response.responseText});
448
+ if (options.plural) {
449
+ ipe._form.getElements().each(function(el) {
450
+ if (el.type != "submit" && el.type != "image") {
451
+ el.name = ipe.options.paramName + '[]';
452
+ el.className = 'editor_field';
453
+ }
454
+ });
455
+ } else {
456
+ var fld = ipe._form.findFirstElement();
457
+ fld.name = ipe.options.paramName;
458
+ fld.className = 'editor_field';
459
+ if (ipe.options.submitOnBlur)
460
+ fld.onblur = ipe._boundSubmitHandler;
461
+ ipe._controls.editor = fld;
462
+ }
463
+ }
464
+ });
465
+ },
466
+
467
+ clonePatternField: function() {
468
+ var patternNodes = this.getPatternNodes(this.options.inplacePatternSelector);
469
+ if (patternNodes.editNode == null) {
470
+ alert('did not find any matching node for ' + this.options.editFieldSelector);
471
+ return;
472
+ }
473
+
474
+ var fld = patternNodes.editNode.cloneNode(true);
475
+ if (fld.id.length > 0) fld.id += this.options.nodeIdSuffix;
476
+ fld.name = this.options.paramName;
477
+ fld.className = 'editor_field';
478
+ this.setValue(fld, this._controls.editor.value);
479
+ if (this.options.submitOnBlur)
480
+ fld.onblur = this._boundSubmitHandler;
481
+ $(this._controls.editor).remove();
482
+ this._controls.editor = fld;
483
+ this._form.appendChild(this._controls.editor);
484
+
485
+ $A(patternNodes.additionalNodes).each(function(node) {
486
+ var patternNode = node.cloneNode(true);
487
+ if (patternNode.id.length > 0) {
488
+ patternNode.id = patternNode.id + this.options.nodeIdSuffix;
489
+ }
490
+ this._form.appendChild(patternNode);
491
+ }.bind(this));
492
+ },
493
+
494
+ getPatternNodes: function(inplacePatternSelector) {
495
+ var nodes = {editNode: null, additionalNodes: []};
496
+ var selectedNodes = $$(inplacePatternSelector);
497
+ var firstNode = selectedNodes.first();
498
+
499
+ if (typeof(firstNode) !== 'undefined') {
500
+ // AS inplace_edit_control_container -> we have to select all child nodes
501
+ // Workaround for ie which does not support css > selector
502
+ if (firstNode.className.indexOf('as_inplace_pattern') !== -1) {
503
+ selectedNodes = firstNode.childElements();
504
+ }
505
+ nodes.editNode = selectedNodes.first();
506
+ selectedNodes.shift();
507
+ nodes.additionalNodes = selectedNodes;
508
+ }
509
+ return nodes;
510
+ },
511
+
512
+ setValue: function(editField, textValue) {
513
+ var function_name = 'setValueFor' + editField.nodeName.toLowerCase();
514
+ if (typeof(this[function_name]) == 'function') {
515
+ this[function_name](editField, textValue);
516
+ } else {
517
+ editField.value = textValue;
518
+ }
519
+ },
520
+
521
+ setValueForselect: function(editField, textValue) {
522
+ var len = editField.options.length;
523
+ var i = 0;
524
+ while (i < len && editField.options[i].text != textValue) {
525
+ i++;
526
+ }
527
+ if (i < len) {
528
+ editField.value = editField.options[i].value
529
+ }
530
+ }
531
+ });
532
+ }