active_scaffold 3.0.12 → 3.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/README +21 -11
  2. data/frontends/default/images/close_touch.png +0 -0
  3. data/frontends/default/javascripts/jquery/active_scaffold.js +187 -99
  4. data/frontends/default/javascripts/prototype/active_scaffold.js +105 -33
  5. data/frontends/default/javascripts/prototype/dhtml_history.js +80 -77
  6. data/frontends/default/stylesheets/stylesheet.css +121 -2
  7. data/frontends/default/views/_action_group.html.erb +6 -2
  8. data/frontends/default/views/_base_form.html.erb +11 -5
  9. data/frontends/default/views/_base_form.html.erb~ +42 -0
  10. data/frontends/default/views/_field_search.html.erb +1 -1
  11. data/frontends/default/views/_form.html.erb +9 -7
  12. data/frontends/default/views/_form_association.html.erb +8 -3
  13. data/frontends/default/views/_form_association_footer.html.erb +10 -3
  14. data/frontends/default/views/_form_attribute.html.erb +8 -3
  15. data/frontends/default/views/_horizontal_subform.html.erb +12 -2
  16. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  17. data/frontends/default/views/_horizontal_subform_record.html.erb +5 -4
  18. data/frontends/default/views/_list_messages.html.erb +1 -1
  19. data/frontends/default/views/_list_with_header.html.erb +1 -1
  20. data/frontends/default/views/_render_field.js.rjs +4 -6
  21. data/frontends/default/views/_vertical_subform.html.erb +1 -1
  22. data/frontends/default/views/_vertical_subform_record.html.erb +2 -2
  23. data/frontends/default/views/on_action_update.js.rjs +3 -1
  24. data/frontends/default/views/on_mark_all.js.rjs +12 -0
  25. data/frontends/default/views/on_update.js.rjs +1 -1
  26. data/frontends/default/views/render_field.js.rjs +1 -0
  27. data/frontends/default/views/update_column.js.rjs +1 -1
  28. data/lib/active_scaffold.rb +60 -21
  29. data/lib/active_scaffold/actions/common_search.rb +2 -2
  30. data/lib/active_scaffold/actions/core.rb +30 -9
  31. data/lib/active_scaffold/actions/create.rb +14 -10
  32. data/lib/active_scaffold/actions/field_search.rb +6 -6
  33. data/lib/active_scaffold/actions/list.rb +22 -12
  34. data/lib/active_scaffold/actions/mark.rb +34 -9
  35. data/lib/active_scaffold/actions/nested.rb +12 -16
  36. data/lib/active_scaffold/actions/show.rb +2 -2
  37. data/lib/active_scaffold/actions/subform.rb +15 -8
  38. data/lib/active_scaffold/actions/update.rb +14 -4
  39. data/lib/active_scaffold/attribute_params.rb +15 -10
  40. data/lib/active_scaffold/bridges/bridge.rb +21 -12
  41. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +3 -3
  42. data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
  43. data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
  44. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +1 -1
  45. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +3 -8
  46. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +1 -15
  47. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +23 -13
  48. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +1 -1
  49. data/lib/active_scaffold/bridges/country_helper/bridge.rb +9 -0
  50. data/lib/active_scaffold/bridges/country_helper/lib/country_helper_bridge.rb +358 -0
  51. data/lib/active_scaffold/bridges/date_picker/bridge.rb +5 -3
  52. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +9 -0
  53. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +9 -0
  54. data/lib/active_scaffold/bridges/dragonfly/bridge.rb~ +12 -0
  55. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +36 -0
  56. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb~ +36 -0
  57. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +12 -0
  58. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb~ +12 -0
  59. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb +27 -0
  60. data/lib/active_scaffold/bridges/dragonfly/lib/form_ui.rb~ +27 -0
  61. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb +16 -0
  62. data/lib/active_scaffold/bridges/dragonfly/lib/list_ui.rb~ +16 -0
  63. data/lib/active_scaffold/bridges/paperclip/bridge.rb +1 -1
  64. data/lib/active_scaffold/bridges/record_select/bridge.rb +5 -0
  65. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb +87 -0
  66. data/lib/active_scaffold/bridges/record_select/lib/record_select_bridge.rb~ +84 -0
  67. data/lib/active_scaffold/bridges/shared/date_bridge.rb +56 -34
  68. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +19 -3
  69. data/lib/active_scaffold/config/base.rb +4 -4
  70. data/lib/active_scaffold/config/core.rb +4 -0
  71. data/lib/active_scaffold/config/create.rb +1 -1
  72. data/lib/active_scaffold/config/field_search.rb +7 -7
  73. data/lib/active_scaffold/config/form.rb +8 -2
  74. data/lib/active_scaffold/config/list.rb +22 -8
  75. data/lib/active_scaffold/config/mark.rb +18 -5
  76. data/lib/active_scaffold/config/nested.rb +3 -3
  77. data/lib/active_scaffold/config/search.rb +1 -1
  78. data/lib/active_scaffold/config/show.rb +1 -1
  79. data/lib/active_scaffold/data_structures/action_columns.rb +10 -6
  80. data/lib/active_scaffold/data_structures/action_link.rb +14 -10
  81. data/lib/active_scaffold/data_structures/action_links.rb +2 -2
  82. data/lib/active_scaffold/data_structures/column.rb +25 -11
  83. data/lib/active_scaffold/data_structures/nested_info.rb +21 -21
  84. data/lib/active_scaffold/data_structures/set.rb +2 -3
  85. data/lib/active_scaffold/data_structures/sorting.rb +8 -8
  86. data/lib/{extensions → active_scaffold/extensions}/action_controller_rendering.rb +3 -1
  87. data/lib/{extensions → active_scaffold/extensions}/action_view_rendering.rb +31 -33
  88. data/lib/{extensions → active_scaffold/extensions}/action_view_resolver.rb +0 -0
  89. data/lib/{extensions → active_scaffold/extensions}/active_association_reflection.rb +0 -0
  90. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  91. data/lib/{extensions → active_scaffold/extensions}/array.rb +0 -0
  92. data/lib/{extensions → active_scaffold/extensions}/localize.rb +1 -1
  93. data/lib/{extensions → active_scaffold/extensions}/name_option_for_datetime.rb +1 -1
  94. data/lib/{extensions → active_scaffold/extensions}/nil_id_in_url_params.rb +0 -0
  95. data/lib/{extensions → active_scaffold/extensions}/paginator_extensions.rb +2 -2
  96. data/lib/{extensions → active_scaffold/extensions}/reverse_associations.rb +1 -1
  97. data/lib/{extensions → active_scaffold/extensions}/routing_mapper.rb +2 -2
  98. data/lib/{extensions → active_scaffold/extensions}/to_label.rb +0 -0
  99. data/lib/{extensions → active_scaffold/extensions}/unsaved_associated.rb +0 -0
  100. data/lib/{extensions → active_scaffold/extensions}/unsaved_record.rb +0 -0
  101. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  102. data/lib/active_scaffold/finder.rb +30 -19
  103. data/lib/active_scaffold/helpers/controller_helpers.rb +3 -5
  104. data/lib/active_scaffold/helpers/form_column_helpers.rb +19 -45
  105. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  106. data/lib/active_scaffold/helpers/id_helpers.rb +2 -2
  107. data/lib/active_scaffold/helpers/list_column_helpers.rb +28 -17
  108. data/lib/active_scaffold/helpers/search_column_helpers.rb +51 -40
  109. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +215 -0
  110. data/lib/active_scaffold/helpers/show_column_helpers.rb +8 -4
  111. data/lib/active_scaffold/helpers/view_helpers.rb +50 -27
  112. data/lib/active_scaffold/locale/de.yml +111 -0
  113. data/lib/active_scaffold/locale/en.yml +115 -0
  114. data/lib/active_scaffold/locale/es.yml +32 -32
  115. data/lib/active_scaffold/locale/fr.yml +118 -0
  116. data/lib/active_scaffold/marked_model.rb +6 -6
  117. data/lib/active_scaffold/version.rb +1 -1
  118. data/lib/active_scaffold_assets.rb +1 -3
  119. data/lib/active_scaffold_env.rb +1 -2
  120. data/lib/generators/active_scaffold/active_scaffold_generator.rb +5 -5
  121. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +3 -2
  122. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  123. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +17 -19
  124. data/shoulda_macros/macros.rb +4 -4
  125. data/test/misc/finder_test.rb +2 -2
  126. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +4 -1
  127. metadata +144 -126
  128. data/.autotest +0 -27
  129. data/.document +0 -5
  130. data/Gemfile +0 -13
  131. data/Gemfile.lock +0 -20
  132. data/Rakefile +0 -53
  133. data/active_scaffold.gemspec +0 -385
  134. data/init.rb +0 -2
  135. data/lib/active_scaffold/helpers/country_helpers.rb +0 -358
  136. data/lib/active_scaffold/locale/de.rb +0 -120
  137. data/lib/active_scaffold/locale/en.rb +0 -119
  138. data/lib/active_scaffold/locale/fr.rb +0 -116
  139. data/lib/extensions/active_record_offset.rb +0 -12
  140. data/lib/extensions/usa_state.rb +0 -50
  141. data/test/mock_app/.gitignore +0 -2
  142. data/uninstall.rb +0 -13
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
  ** For all documentation see the project website: http://github.com/vhochstein/active_scaffold/wiki **
3
3
  ******************************************************************************************************
4
4
 
5
- ActiveScaffold 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)
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
6
 
7
7
  Uses DhtmlHistory by Brad Neuberg (bkn3@columbia.edu)
8
8
  http://codinginparadise.org
@@ -18,30 +18,32 @@ http://code.google.com/p/recordselect/
18
18
 
19
19
  == Version Information
20
20
 
21
- Please note the following list of Active Scaffold branches and Rails versions. Master will not work with Rails < 2.2
21
+ Please note the following list of Active Scaffold branches and Rails versions. Master will not work with Rails < 3.1
22
22
 
23
- Active Scaffold master currently supports rails-2.3.5, but incompatible changes can be introduced, if you want an stable version, use rails-2.3
24
- Rails 2.3.*: Active Scaffold rails-2.3
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
25
26
  Rails 2.2.*: Active Scaffold rails-2.2
26
27
  Rails 2.1.*: Active Scaffold rails-2.1
27
28
  Rails < 2.1: Active Scaffold 1-1-stable (no guarantees)
28
29
 
29
- Since Rails 2.3, render_component plugin is needed for nested and embbeded scaffolds. It works with rails-2.3 branch from ewildgoose repository:
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:
30
31
  script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3
31
32
 
32
- == Rails 3.0 compatible fork of activesaffold by Volker Hochstein:
33
-
34
33
  Since Rails 3.0 render_component is not used for nesting, but is optional for embedded scaffolds.
35
34
  Since Rails 3.0, https://github.com/rails/verification.git is also needed.
36
35
 
37
36
  If you want to install as plugins under vendor/plugins, install these versions:
38
37
  rails plugin install git://github.com/vhochstein/render_component.git
39
38
  rails plugin install git://github.com/rails/verification.git
40
- rails plugin install git://github.com/vhochstein/active_scaffold.git
39
+ rails plugin install git://github.com/activescaffold/active_scaffold.git -r 'rails-3.0'
41
40
 
42
41
  If you want to use the gem, add to your Gemfile:
43
42
  gem "active_scaffold"
44
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
+
45
47
  == Pick your own javascript framework
46
48
 
47
49
  The Rails 3.0 version uses unobtrusive Javascript, so you are free to pick your javascript framework.
@@ -50,14 +52,22 @@ Out of the box Prototype or JQuery are supported:
50
52
  Prototype 1.7 (default js framework)
51
53
  rails.js in git://github.com/vhochstein/prototype-ujs.git
52
54
 
53
- JQuery 1.4.1
54
- rails.js in git://github.com/vhochstein/jquery-ujs.git
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
55
60
 
56
61
  To configure the javascript framework when installed under vendor/plugins/
57
- uncomment last line in ...plugins/active_scaffold/environment.rb in order to use jquery instead of prototype
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.
58
64
 
59
65
  To configure the javascript framework when installed as a gem:
60
66
  Add a config/initializers/active_scaffold.rb containing:
61
67
  ActiveScaffold.js_framework = :jquery # :prototype is the default
62
68
 
69
+ == Rails 3.1 compatible branch:
70
+ under construction
71
+
72
+
63
73
  Released under the MIT license (included)
@@ -34,7 +34,14 @@ $(document).ready(function() {
34
34
  } else {
35
35
  // hack: jquery requires if you request for javascript that javascript
36
36
  // is coming back, however rails has a different mantra
37
- if (action_link.position) event.data_type = 'rails';
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
+
38
45
  if (action_link.loading_indicator) action_link.loading_indicator.css('visibility','visible');
39
46
  action_link.disable();
40
47
  }
@@ -50,7 +57,7 @@ $(document).ready(function() {
50
57
  } else {
51
58
  action_link.enable();
52
59
  }
53
- return true;
60
+ $(this).trigger('as:action_success', action_link);
54
61
  }
55
62
  return true;
56
63
  });
@@ -128,65 +135,7 @@ $(document).ready(function() {
128
135
  return true;
129
136
  });
130
137
  $('span.in_place_editor_field').live('click', function(event) {
131
- var span = $(this);
132
- span.data(); // jquery 1.4.2 workaround
133
- if (typeof(span.data('editInPlace')) === 'undefined') {
134
- var options = {show_buttons: true,
135
- hover_class: 'hover',
136
- element_id: 'editor_id',
137
- ajax_data_type: "script",
138
- update_value: 'value'},
139
- csrf_param = $('meta[name=csrf-param]').first(),
140
- csrf_token = $('meta[name=csrf-token]').first(),
141
- my_parent = span.parent(),
142
- column_heading = null;
143
-
144
- if (my_parent.is('td')) {
145
- var column_no = my_parent.prevAll('td').length;
146
- column_heading = my_parent.closest('.active-scaffold').find('th:eq(' + column_no + ')');
147
- } else if (my_parent.is('th')) {
148
- column_heading = my_parent;
149
- }
150
-
151
- var render_url = column_heading.attr('data-ie_render_url'),
152
- mode = column_heading.attr('data-ie_mode'),
153
- record_id = span.attr('data-ie_id');
154
-
155
- ActiveScaffold.read_inplace_edit_heading_attributes(column_heading, options);
156
-
157
- if (span.attr('data-ie_url')) {
158
- options.url = span.attr('data-ie_url').replace(/__id__/, record_id);
159
- } else {
160
- options.url = column_heading.attr('data-ie_url').replace(/__id__/, record_id);
161
- }
162
-
163
- if (csrf_param) options['params'] = csrf_param.attr('content') + '=' + csrf_token.attr('content');
164
-
165
- if (span.closest('div.active-scaffold').attr('data-eid')) {
166
- if (options['params'].length > 0) {
167
- options['params'] += ";";
168
- }
169
- options['params'] += ("eid=" + span.closest('div.active-scaffold').attr('data-eid'));
170
- }
171
-
172
- if (mode === 'clone') {
173
- options.clone_id_suffix = record_id;
174
- options.clone_selector = '#' + column_heading.attr('id') + ' .as_inplace_pattern';
175
- options.field_type = 'clone';
176
- }
177
-
178
- if (render_url) {
179
- var plural = false;
180
- if (column_heading.attr('data-ie_plural')) plural = true;
181
- options.field_type = 'remote';
182
- options.editor_url = render_url.replace(/__id__/, record_id)
183
- }
184
- if (mode === 'inline_checkbox') {
185
- ActiveScaffold.process_checkbox_inplace_edit(span.find('input:checkbox'), options);
186
- } else {
187
- ActiveScaffold.create_inplace_editor(span, options);
188
- }
189
- }
138
+ ActiveScaffold.in_place_editor_field_clicked($(this));
190
139
  });
191
140
  $('a.as_paginate').live('ajax:before',function(event) {
192
141
  var as_paginate = $(this);
@@ -204,34 +153,15 @@ $(document).ready(function() {
204
153
  $(this).prevAll('img.loading-indicator').css('visibility','hidden');
205
154
  return true;
206
155
  });
207
- $('input[type=button].as_add_existing').live('ajax:before', function(event) {
156
+ $('input[type=button].as_add_existing, input[type=button].as_replace_existing').live('ajax:before', function(event) {
208
157
  var url = $(this).attr('href').replace('--ID--', $(this).prev().val());
209
158
  event.data_url = url;
210
159
  return true;
211
160
  });
212
161
  $('input.update_form, select.update_form').live('change', function(event) {
213
- var element = $(this);
214
- var as_form = element.closest('form.as_form');
215
- $.ajax({
216
- url: element.attr('data-update_url'),
217
- data: {value: element.val()},
218
- beforeSend: function(event) {
219
- element.nextAll('img.loading-indicator').css('visibility','visible');
220
- $('input[type=submit]', as_form).attr('disabled', 'disabled');
221
- $("input:enabled,select:enabled", as_form).attr('disabled', 'disabled');
222
- },
223
- complete: function(event) {
224
- element.nextAll('img.loading-indicator').css('visibility','hidden');
225
- $('input[type=submit]', as_form).attr('disabled', '');
226
- $("input:disabled,select:disabled", as_form).attr('disabled', '');
227
- },
228
- error: function (xhr, status, error) {
229
- var as_div = element.closest("div.active-scaffold");
230
- if (as_div) {
231
- ActiveScaffold.report_500_response(as_div)
232
- }
233
- }
234
- });
162
+ var element = $(this);
163
+ var value = element.is("input:checkbox") ? element.is(":checked") : element.val();
164
+ ActiveScaffold.update_column(element, element.attr('data-update_url'), element.attr('data-update_send_form'), element.attr('id'), value);
235
165
  return true;
236
166
  });
237
167
 
@@ -255,10 +185,27 @@ $(document).ready(function() {
255
185
  });
256
186
 
257
187
  $('a[data-popup]').live('click', function(e) {
258
- window.open($(this).attr('href'));
259
- e.preventDefault();
260
- });
261
-
188
+ window.open($(this).attr('href'));
189
+ e.preventDefault();
190
+ });
191
+
192
+ $('.hover_click').live("click", function(event) {
193
+ var element = $(this);
194
+ var ul_element = element.children('ul').first();
195
+ if (ul_element.is(':visible')) {
196
+ element.find('ul').hide();
197
+ } else {
198
+ ul_element.show();
199
+ }
200
+ return false;
201
+ });
202
+ $('.hover_click a.as_action').live('click', function(event) {
203
+ var element = $(this).closest('.hover_click');
204
+ if (element) {
205
+ element.find('ul').hide();
206
+ }
207
+ return true;
208
+ });
262
209
  });
263
210
 
264
211
  /* Simple Inheritance
@@ -504,7 +451,7 @@ var ActiveScaffold = {
504
451
  var loading_indicator = $('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
505
452
  if (loading_indicator) loading_indicator.css('visibility','visible');
506
453
  $('input[type=submit]', as_form).attr('disabled', 'disabled');
507
- $("input:enabled,select:enabled", as_form).attr('disabled', 'disabled');
454
+ $("input:enabled,select:enabled,textarea:enabled", as_form).attr('disabled', 'disabled');
508
455
  },
509
456
 
510
457
  enable_form: function(as_form) {
@@ -513,7 +460,7 @@ var ActiveScaffold = {
513
460
  var loading_indicator = $('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
514
461
  if (loading_indicator) loading_indicator.css('visibility','hidden');
515
462
  $('input[type=submit]', as_form).attr('disabled', '');
516
- $("input:disabled,select:disabled", as_form).attr('disabled', '');
463
+ $("input:disabled,select:disabled,textarea:disabled", as_form).attr('disabled', '');
517
464
  },
518
465
 
519
466
  focus_first_element_of_form: function(form_element) {
@@ -562,6 +509,16 @@ var ActiveScaffold = {
562
509
  this.reload_if_empty(tbody, page_reload_url);
563
510
  },
564
511
 
512
+ delete_subform_record: function(record) {
513
+ if (typeof(record) == 'string') record = '#' + record;
514
+ record = $(record);
515
+ var errors = record.prev();
516
+ if (errors.hasClass('association-record-errors')) {
517
+ this.replace_html(errors, '');
518
+ }
519
+ this.remove(record);
520
+ },
521
+
565
522
  report_500_response: function(active_scaffold_id) {
566
523
  server_error = $(active_scaffold_id).find('td.messages-container p.server-error');
567
524
  if (!$(server_error).is(':visible')) {
@@ -616,7 +573,7 @@ var ActiveScaffold = {
616
573
  },
617
574
 
618
575
  highlight: function(element) {
619
- if (typeof(element) == 'string') element = '#' + element;
576
+ if (typeof(element) == 'string') element = $('#' + element);
620
577
  if (typeof(element.effect) == 'function') {
621
578
  element.effect("highlight", {}, 3000);
622
579
  }
@@ -644,7 +601,7 @@ var ActiveScaffold = {
644
601
  element.append(content);
645
602
  }
646
603
  } else {
647
- var current = $('#' + element.attr('id') + ' tr.association-record')
604
+ var current = $('#' + element.attr('id') + ' .association-record')
648
605
  if (current[0]) {
649
606
  this.replace(current[0], content);
650
607
  } else {
@@ -653,13 +610,21 @@ var ActiveScaffold = {
653
610
  }
654
611
  },
655
612
 
656
- render_form_field: function(element, content, options) {
657
- if (typeof(element) == 'string') element = '#' + element;
658
- var element = $(element);
659
- if (options.is_subform == false) {
660
- this.replace(element.closest('dl'), content);
661
- } else {
662
- this.replace_html(element, content);
613
+ render_form_field: function(source, content, options) {
614
+ if (typeof(source) == 'string') source = '#' + source;
615
+ var source = $(source);
616
+ var element = source.closest('.association-record');
617
+ if (element.length == 0) {
618
+ element = source.closest('ol.form');
619
+ }
620
+ element = element.find('.' + options.field_class + ":first");
621
+
622
+ if (element) {
623
+ if (options.is_subform == false) {
624
+ this.replace(element.closest('dl'), content);
625
+ } else {
626
+ this.replace_html(element, content);
627
+ }
663
628
  }
664
629
  },
665
630
 
@@ -685,6 +650,128 @@ var ActiveScaffold = {
685
650
  ActiveScaffold.report_500_response(active_scaffold_id)
686
651
  }
687
652
  });
653
+ },
654
+
655
+ // element is tbody id
656
+ mark_records: function(element, options) {
657
+ if (typeof(element) == 'string') element = '#' + element;
658
+ var element = $(element);
659
+ var mark_checkboxes = $('#' + element.attr('id') + ' > tr.record td.marked-column input[type="checkbox"]');
660
+ mark_checkboxes.each(function (index) {
661
+ var item = $(this);
662
+ if(options.checked === true) {
663
+ item.attr('checked', 'checked');
664
+ } else {
665
+ item.removeAttr('checked');
666
+ }
667
+ item.attr('value', ('' + !options.checked));
668
+ });
669
+ if(options.include_mark_all === true) {
670
+ var mark_all_checkbox = element.prev('thead').find('th.marked-column_heading span input[type="checkbox"]');
671
+ if(options.checked === true) {
672
+ mark_all_checkbox.attr('checked', 'checked');
673
+ } else {
674
+ mark_all_checkbox.removeAttr('checked');
675
+ }
676
+ mark_all_checkbox.attr('value', ('' + !options.checked));
677
+ }
678
+ },
679
+
680
+ in_place_editor_field_clicked: function(span) {
681
+ span.data(); // jquery 1.4.2 workaround
682
+ if (typeof(span.data('editInPlace')) === 'undefined') {
683
+ var options = {show_buttons: true,
684
+ hover_class: 'hover',
685
+ element_id: 'editor_id',
686
+ ajax_data_type: "script",
687
+ update_value: 'value'},
688
+ csrf_param = $('meta[name=csrf-param]').first(),
689
+ csrf_token = $('meta[name=csrf-token]').first(),
690
+ my_parent = span.parent(),
691
+ column_heading = null;
692
+
693
+ if(!(my_parent.is('td') || my_parent.is('th'))){
694
+ my_parent = span.parents('td').eq(0);
695
+ }
696
+
697
+ if (my_parent.is('td')) {
698
+ var column_no = my_parent.prevAll('td').length;
699
+ column_heading = my_parent.closest('.active-scaffold').find('th:eq(' + column_no + ')');
700
+ } else if (my_parent.is('th')) {
701
+ column_heading = my_parent;
702
+ }
703
+
704
+ var render_url = column_heading.attr('data-ie_render_url'),
705
+ mode = column_heading.attr('data-ie_mode'),
706
+ record_id = span.attr('data-ie_id');
707
+
708
+ ActiveScaffold.read_inplace_edit_heading_attributes(column_heading, options);
709
+
710
+ if (span.attr('data-ie_url')) {
711
+ options.url = span.attr('data-ie_url').replace(/__id__/, record_id);
712
+ } else {
713
+ options.url = column_heading.attr('data-ie_url').replace(/__id__/, record_id);
714
+ }
715
+
716
+ if (csrf_param) options['params'] = csrf_param.attr('content') + '=' + csrf_token.attr('content');
717
+
718
+ if (span.closest('div.active-scaffold').attr('data-eid')) {
719
+ if (options['params'].length > 0) {
720
+ options['params'] += "&";
721
+ }
722
+ options['params'] += ("eid=" + span.closest('div.active-scaffold').attr('data-eid'));
723
+ }
724
+
725
+ if (mode === 'clone') {
726
+ options.clone_id_suffix = record_id;
727
+ options.clone_selector = '#' + column_heading.attr('id') + ' .as_inplace_pattern';
728
+ options.field_type = 'clone';
729
+ }
730
+
731
+ if (render_url) {
732
+ var plural = false;
733
+ if (column_heading.attr('data-ie_plural')) plural = true;
734
+ options.field_type = 'remote';
735
+ options.editor_url = render_url.replace(/__id__/, record_id)
736
+ }
737
+ if (mode === 'inline_checkbox') {
738
+ ActiveScaffold.process_checkbox_inplace_edit(span.find('input:checkbox'), options);
739
+ } else {
740
+ ActiveScaffold.create_inplace_editor(span, options);
741
+ }
742
+ }
743
+ },
744
+
745
+ update_column: function(element, url, send_form, source_id, val) {
746
+ var as_form = element.closest('form.as_form');
747
+ var params = null;
748
+
749
+ if (send_form) {
750
+ params = as_form.serialize();
751
+ params += '&' + $.param({"source_id": source_id});
752
+ } else {
753
+ params = {value: val};
754
+ params.source_id = source_id;
755
+ }
756
+
757
+ $.ajax({
758
+ url: url,
759
+ data: params,
760
+ beforeSend: function(event) {
761
+ element.nextAll('img.loading-indicator').css('visibility','visible');
762
+ ActiveScaffold.disable_form(as_form);
763
+ },
764
+ complete: function(event) {
765
+ element.nextAll('img.loading-indicator').css('visibility','hidden');
766
+ ActiveScaffold.enable_form(as_form);
767
+ },
768
+ error: function (xhr, status, error) {
769
+ var as_div = element.closest("div.active-scaffold");
770
+ if (as_div) {
771
+ ActiveScaffold.report_500_response(as_div);
772
+ }
773
+ }
774
+ });
688
775
  }
689
776
  }
690
777
 
@@ -784,6 +871,7 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
784
871
  this.loading_indicator = loading_indicator;
785
872
  this.hide_target = false;
786
873
  this.position = this.tag.attr('data-position');
874
+ this.action = this.tag.attr('data-action');
787
875
 
788
876
  this.tag.data('action_link', this);
789
877
  return this;