active_scaffold 3.2.17 → 3.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGELOG +5 -1
  2. metadata +17 -261
  3. data/app/assets/images/active_scaffold/add.png +0 -0
  4. data/app/assets/images/active_scaffold/arrow_down.png +0 -0
  5. data/app/assets/images/active_scaffold/arrow_up.png +0 -0
  6. data/app/assets/images/active_scaffold/close.png +0 -0
  7. data/app/assets/images/active_scaffold/close_touch.png +0 -0
  8. data/app/assets/images/active_scaffold/config.png +0 -0
  9. data/app/assets/images/active_scaffold/cross.png +0 -0
  10. data/app/assets/images/active_scaffold/gears.png +0 -0
  11. data/app/assets/images/active_scaffold/indicator-small.gif +0 -0
  12. data/app/assets/images/active_scaffold/indicator.gif +0 -0
  13. data/app/assets/images/active_scaffold/magnifier.png +0 -0
  14. data/app/assets/javascripts/active_scaffold.js.erb +0 -19
  15. data/app/assets/javascripts/jquery/active_scaffold.js +0 -1113
  16. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +0 -24
  17. data/app/assets/javascripts/jquery/draggable_lists.js +0 -27
  18. data/app/assets/javascripts/jquery/jquery.editinplace.js +0 -743
  19. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +0 -7
  20. data/app/assets/javascripts/prototype/active_scaffold.js +0 -1107
  21. data/app/assets/javascripts/prototype/dhtml_history.js +0 -870
  22. data/app/assets/javascripts/prototype/form_enhancements.js +0 -117
  23. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  24. data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -7
  25. data/app/assets/stylesheets/active_scaffold-ie.css.scss +0 -54
  26. data/app/assets/stylesheets/active_scaffold.css.scss +0 -14
  27. data/app/assets/stylesheets/active_scaffold_colors.css.scss +0 -395
  28. data/app/assets/stylesheets/active_scaffold_extensions.css.erb +0 -2
  29. data/app/assets/stylesheets/active_scaffold_images.css.scss +0 -40
  30. data/app/assets/stylesheets/active_scaffold_layout.css +0 -936
  31. data/app/assets/stylesheets/blue-theme.css +0 -74
  32. data/config/locales/de.yml +0 -125
  33. data/config/locales/en.yml +0 -127
  34. data/config/locales/es.yml +0 -128
  35. data/config/locales/fr.yml +0 -131
  36. data/config/locales/hu.yml +0 -126
  37. data/config/locales/ja.yml +0 -126
  38. data/config/locales/ru.yml +0 -135
  39. data/frontends/default/views/_action_group.html.erb +0 -24
  40. data/frontends/default/views/_add_existing_form.html.erb +0 -30
  41. data/frontends/default/views/_base_form.html.erb +0 -53
  42. data/frontends/default/views/_create_form.html.erb +0 -8
  43. data/frontends/default/views/_create_form_on_list.html.erb +0 -6
  44. data/frontends/default/views/_field_search.html.erb +0 -32
  45. data/frontends/default/views/_form.html.erb +0 -28
  46. data/frontends/default/views/_form_association.html.erb +0 -17
  47. data/frontends/default/views/_form_association_footer.html.erb +0 -47
  48. data/frontends/default/views/_form_attribute.html.erb +0 -23
  49. data/frontends/default/views/_form_hidden_attribute.html.erb +0 -7
  50. data/frontends/default/views/_form_messages.html.erb +0 -5
  51. data/frontends/default/views/_horizontal_subform.html.erb +0 -22
  52. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  53. data/frontends/default/views/_horizontal_subform_header.html.erb +0 -11
  54. data/frontends/default/views/_horizontal_subform_record.html.erb +0 -43
  55. data/frontends/default/views/_human_conditions.html.erb +0 -1
  56. data/frontends/default/views/_list.html.erb +0 -18
  57. data/frontends/default/views/_list_actions.html.erb +0 -15
  58. data/frontends/default/views/_list_calculations.html.erb +0 -16
  59. data/frontends/default/views/_list_column_headings.html.erb +0 -12
  60. data/frontends/default/views/_list_header.html.erb +0 -10
  61. data/frontends/default/views/_list_inline_adapter.html.erb +0 -21
  62. data/frontends/default/views/_list_messages.html.erb +0 -28
  63. data/frontends/default/views/_list_pagination.html.erb +0 -11
  64. data/frontends/default/views/_list_pagination_links.html.erb +0 -9
  65. data/frontends/default/views/_list_record.html.erb +0 -13
  66. data/frontends/default/views/_list_record_columns.html.erb +0 -8
  67. data/frontends/default/views/_list_with_header.html.erb +0 -36
  68. data/frontends/default/views/_messages.html.erb +0 -10
  69. data/frontends/default/views/_refresh_list.js.erb +0 -1
  70. data/frontends/default/views/_render_field.js.erb +0 -20
  71. data/frontends/default/views/_row.html.erb +0 -1
  72. data/frontends/default/views/_search.html.erb +0 -34
  73. data/frontends/default/views/_search_attribute.html.erb +0 -10
  74. data/frontends/default/views/_show.html.erb +0 -8
  75. data/frontends/default/views/_show_columns.html.erb +0 -15
  76. data/frontends/default/views/_update_actions.html.erb +0 -9
  77. data/frontends/default/views/_update_calculations.js.erb +0 -4
  78. data/frontends/default/views/_update_form.html.erb +0 -6
  79. data/frontends/default/views/_update_messages.js.erb +0 -2
  80. data/frontends/default/views/_vertical_subform.html.erb +0 -12
  81. data/frontends/default/views/_vertical_subform_record.html.erb +0 -43
  82. data/frontends/default/views/action_confirmation.html.erb +0 -13
  83. data/frontends/default/views/add_existing.js.erb +0 -14
  84. data/frontends/default/views/add_existing_form.html.erb +0 -5
  85. data/frontends/default/views/create.html.erb +0 -5
  86. data/frontends/default/views/delete.html.erb +0 -13
  87. data/frontends/default/views/destroy.js.erb +0 -26
  88. data/frontends/default/views/edit_associated.js.erb +0 -12
  89. data/frontends/default/views/field_search.html.erb +0 -5
  90. data/frontends/default/views/form_messages.js.erb +0 -1
  91. data/frontends/default/views/list.html.erb +0 -1
  92. data/frontends/default/views/on_action_update.js.erb +0 -22
  93. data/frontends/default/views/on_create.js.erb +0 -38
  94. data/frontends/default/views/on_mark.js.erb +0 -6
  95. data/frontends/default/views/on_update.js.erb +0 -29
  96. data/frontends/default/views/refresh_list.js.erb +0 -2
  97. data/frontends/default/views/render_field.js.erb +0 -1
  98. data/frontends/default/views/row.js.erb +0 -2
  99. data/frontends/default/views/search.html.erb +0 -5
  100. data/frontends/default/views/show.html.erb +0 -5
  101. data/frontends/default/views/update.html.erb +0 -8
  102. data/frontends/default/views/update_column.js.erb +0 -15
  103. data/frontends/default/views/update_row.js.erb +0 -1
  104. data/lib/active_scaffold.rb +0 -373
  105. data/lib/active_scaffold/actions/common_search.rb +0 -22
  106. data/lib/active_scaffold/actions/core.rb +0 -203
  107. data/lib/active_scaffold/actions/create.rb +0 -139
  108. data/lib/active_scaffold/actions/delete.rb +0 -74
  109. data/lib/active_scaffold/actions/field_search.rb +0 -78
  110. data/lib/active_scaffold/actions/list.rb +0 -208
  111. data/lib/active_scaffold/actions/mark.rb +0 -89
  112. data/lib/active_scaffold/actions/nested.rb +0 -244
  113. data/lib/active_scaffold/actions/search.rb +0 -48
  114. data/lib/active_scaffold/actions/show.rb +0 -61
  115. data/lib/active_scaffold/actions/subform.rb +0 -23
  116. data/lib/active_scaffold/actions/update.rb +0 -156
  117. data/lib/active_scaffold/active_record_permissions.rb +0 -135
  118. data/lib/active_scaffold/attribute_params.rb +0 -200
  119. data/lib/active_scaffold/bridges.rb +0 -61
  120. data/lib/active_scaffold/bridges/ancestry.rb +0 -5
  121. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +0 -39
  122. data/lib/active_scaffold/bridges/bitfields.rb +0 -6
  123. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +0 -37
  124. data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -24
  125. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -66
  126. data/lib/active_scaffold/bridges/cancan.rb +0 -15
  127. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +0 -127
  128. data/lib/active_scaffold/bridges/carrierwave.rb +0 -12
  129. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +0 -31
  130. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +0 -10
  131. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +0 -45
  132. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +0 -17
  133. data/lib/active_scaffold/bridges/country_helper.rb +0 -9
  134. data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +0 -358
  135. data/lib/active_scaffold/bridges/date_picker.rb +0 -23
  136. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -63
  137. data/lib/active_scaffold/bridges/date_picker/helper.rb +0 -180
  138. data/lib/active_scaffold/bridges/dragonfly.rb +0 -9
  139. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +0 -34
  140. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +0 -10
  141. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +0 -27
  142. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +0 -16
  143. data/lib/active_scaffold/bridges/file_column.rb +0 -11
  144. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +0 -46
  145. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +0 -57
  146. data/lib/active_scaffold/bridges/file_column/form_ui.rb +0 -34
  147. data/lib/active_scaffold/bridges/file_column/list_ui.rb +0 -26
  148. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +0 -43
  149. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +0 -9
  150. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -15
  151. data/lib/active_scaffold/bridges/paperclip.rb +0 -12
  152. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +0 -27
  153. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +0 -16
  154. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +0 -36
  155. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +0 -24
  156. data/lib/active_scaffold/bridges/record_select.rb +0 -11
  157. data/lib/active_scaffold/bridges/record_select/helpers.rb +0 -92
  158. data/lib/active_scaffold/bridges/semantic_attributes.rb +0 -5
  159. data/lib/active_scaffold/bridges/semantic_attributes/column.rb +0 -20
  160. data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -209
  161. data/lib/active_scaffold/bridges/tiny_mce.rb +0 -17
  162. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +0 -46
  163. data/lib/active_scaffold/config/base.rb +0 -75
  164. data/lib/active_scaffold/config/core.rb +0 -236
  165. data/lib/active_scaffold/config/create.rb +0 -32
  166. data/lib/active_scaffold/config/delete.rb +0 -32
  167. data/lib/active_scaffold/config/field_search.rb +0 -79
  168. data/lib/active_scaffold/config/form.rb +0 -64
  169. data/lib/active_scaffold/config/list.rb +0 -247
  170. data/lib/active_scaffold/config/mark.rb +0 -30
  171. data/lib/active_scaffold/config/nested.rb +0 -42
  172. data/lib/active_scaffold/config/search.rb +0 -73
  173. data/lib/active_scaffold/config/show.rb +0 -31
  174. data/lib/active_scaffold/config/subform.rb +0 -35
  175. data/lib/active_scaffold/config/update.rb +0 -33
  176. data/lib/active_scaffold/configurable.rb +0 -29
  177. data/lib/active_scaffold/constraints.rb +0 -171
  178. data/lib/active_scaffold/data_structures/action_columns.rb +0 -142
  179. data/lib/active_scaffold/data_structures/action_link.rb +0 -185
  180. data/lib/active_scaffold/data_structures/action_links.rb +0 -191
  181. data/lib/active_scaffold/data_structures/actions.rb +0 -45
  182. data/lib/active_scaffold/data_structures/bridge.rb +0 -22
  183. data/lib/active_scaffold/data_structures/column.rb +0 -401
  184. data/lib/active_scaffold/data_structures/columns.rb +0 -75
  185. data/lib/active_scaffold/data_structures/error_message.rb +0 -24
  186. data/lib/active_scaffold/data_structures/nested_info.rb +0 -171
  187. data/lib/active_scaffold/data_structures/set.rb +0 -61
  188. data/lib/active_scaffold/data_structures/sorting.rb +0 -167
  189. data/lib/active_scaffold/engine.rb +0 -4
  190. data/lib/active_scaffold/extensions/action_controller_rendering.rb +0 -20
  191. data/lib/active_scaffold/extensions/action_controller_rescueing.rb +0 -7
  192. data/lib/active_scaffold/extensions/action_view_rendering.rb +0 -115
  193. data/lib/active_scaffold/extensions/active_record_offset.rb +0 -12
  194. data/lib/active_scaffold/extensions/array.rb +0 -7
  195. data/lib/active_scaffold/extensions/cache_association.rb +0 -16
  196. data/lib/active_scaffold/extensions/localize.rb +0 -10
  197. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +0 -12
  198. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +0 -7
  199. data/lib/active_scaffold/extensions/paginator_extensions.rb +0 -26
  200. data/lib/active_scaffold/extensions/reverse_associations.rb +0 -64
  201. data/lib/active_scaffold/extensions/routing_mapper.rb +0 -48
  202. data/lib/active_scaffold/extensions/to_label.rb +0 -8
  203. data/lib/active_scaffold/extensions/unsaved_associated.rb +0 -61
  204. data/lib/active_scaffold/extensions/unsaved_record.rb +0 -20
  205. data/lib/active_scaffold/extensions/usa_state.rb +0 -46
  206. data/lib/active_scaffold/finder.rb +0 -399
  207. data/lib/active_scaffold/helpers/association_helpers.rb +0 -42
  208. data/lib/active_scaffold/helpers/controller_helpers.rb +0 -94
  209. data/lib/active_scaffold/helpers/form_column_helpers.rb +0 -322
  210. data/lib/active_scaffold/helpers/human_condition_helpers.rb +0 -64
  211. data/lib/active_scaffold/helpers/id_helpers.rb +0 -131
  212. data/lib/active_scaffold/helpers/list_column_helpers.rb +0 -374
  213. data/lib/active_scaffold/helpers/pagination_helpers.rb +0 -62
  214. data/lib/active_scaffold/helpers/search_column_helpers.rb +0 -257
  215. data/lib/active_scaffold/helpers/show_column_helpers.rb +0 -44
  216. data/lib/active_scaffold/helpers/view_helpers.rb +0 -398
  217. data/lib/active_scaffold/marked_model.rb +0 -38
  218. data/lib/active_scaffold/paginator.rb +0 -136
  219. data/lib/active_scaffold/responds_to_parent.rb +0 -70
  220. data/lib/active_scaffold/tableless.rb +0 -83
  221. data/lib/active_scaffold/version.rb +0 -9
  222. data/lib/active_scaffold_env.rb +0 -13
  223. data/lib/generators/active_scaffold/USAGE +0 -29
  224. data/lib/generators/active_scaffold/active_scaffold_generator.rb +0 -21
  225. data/lib/generators/active_scaffold_controller/USAGE +0 -19
  226. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +0 -29
  227. data/lib/generators/active_scaffold_controller/templates/controller.rb +0 -4
  228. data/lib/generators/active_scaffold_controller/templates/helper.rb +0 -2
  229. data/public/blank.html +0 -33
  230. data/shoulda_macros/macros.rb +0 -136
  231. data/vendor/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  232. data/vendor/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  233. data/vendor/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
  234. data/vendor/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  235. data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  236. data/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  237. data/vendor/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  238. data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  239. data/vendor/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  240. data/vendor/assets/images/ui-icons_222222_256x240.png +0 -0
  241. data/vendor/assets/images/ui-icons_228ef1_256x240.png +0 -0
  242. data/vendor/assets/images/ui-icons_ef8c08_256x240.png +0 -0
  243. data/vendor/assets/images/ui-icons_ffd27a_256x240.png +0 -0
  244. data/vendor/assets/images/ui-icons_ffffff_256x240.png +0 -0
  245. data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +0 -1276
  246. data/vendor/assets/stylesheets/jquery-ui.css +0 -568
@@ -1,24 +0,0 @@
1
- <%= ActiveScaffold::Bridges[:date_picker].localization %>
2
-
3
- jQuery(document).ready(function() {
4
- jQuery('input.date_picker').live('focus', function(event) {
5
- var date_picker = jQuery(this);
6
- if (typeof(date_picker.datepicker) == 'function') {
7
- if (!date_picker.hasClass('hasDatepicker')) {
8
- date_picker.datepicker();
9
- date_picker.trigger('focus');
10
- }
11
- }
12
- return true;
13
- });
14
- jQuery('input.datetime_picker').live('focus', function(event) {
15
- var date_picker = jQuery(this);
16
- if (typeof(date_picker.datetimepicker) == 'function') {
17
- if (!date_picker.hasClass('hasDatepicker')) {
18
- date_picker.datetimepicker();
19
- date_picker.trigger('focus');
20
- }
21
- }
22
- return true;
23
- });
24
- });
@@ -1,27 +0,0 @@
1
- jQuery.fn.draggable_lists = function() {
2
- this.addClass('draggable-list');
3
- var list_selected = jQuery(this.get(0).cloneNode(false)).addClass('selected');
4
- list_selected.attr('id', list_selected.attr('id') + '_selected').insertAfter(this);
5
- this.find('input:checkbox').each(function(index, item) {
6
- var li = jQuery(item).closest('li').addClass('draggable-item');
7
- li.children('label').removeAttr('for');
8
- if (jQuery(item).is(':checked')) li.appendTo(list_selected);
9
- li.draggable({appendTo: 'body', helper: 'clone'});
10
- });
11
- jQuery([this, list_selected]).droppable({
12
- hoverClass: 'hover',
13
- accept: function(draggable) {
14
- var parent_id = draggable.parent().attr('id'), id = jQuery(this).attr('id'),
15
- requested_id = jQuery(this).hasClass('selected') ? id.replace('_selected', '') : id + '_selected';
16
- return parent_id == requested_id;
17
- },
18
- drop: function(event, ui) {
19
- jQuery(this).append(ui.draggable);
20
- var input = jQuery('input:checkbox', ui.draggable);
21
- if (jQuery(this).hasClass('selected')) input.attr('checked', 'checked');
22
- else input.removeAttr('checked');
23
- ui.draggable.css({left: '0px', top: '0px'});
24
- }
25
- });
26
- return this;
27
- };
@@ -1,743 +0,0 @@
1
- /*
2
-
3
- A jQuery edit in place plugin
4
-
5
- Version 2.2.0
6
-
7
- Authors:
8
- Dave Hauenstein
9
- Martin Häcker <spamfaenger [at] gmx [dot] de>
10
-
11
- Project home:
12
- http://code.google.com/p/jquery-in-place-editor/
13
-
14
- Patches with tests welcomed! For guidance see the tests </spec/unit/>. To submit, attach them to the bug tracker.
15
-
16
- License:
17
- This source file is subject to the BSD license bundled with this package.
18
- Available online: {@link http://www.opensource.org/licenses/bsd-license.php}
19
- If you did not receive a copy of the license, and are unable to obtain it,
20
- learn to use a search engine.
21
-
22
- Rev: 161
23
- */
24
-
25
- (function($){
26
-
27
- $.fn.editInPlace = function(options) {
28
-
29
- var settings = $.extend({}, $.fn.editInPlace.defaults, options);
30
- assertMandatorySettingsArePresent(settings);
31
- preloadImage(settings.saving_image);
32
-
33
- return this.each(function() {
34
- var dom = $(this);
35
- // This won't work with live queries as there is no specific element to attach this
36
- // one way to deal with this could be to store a reference to self and then compare that in click?
37
- if (dom.data('editInPlace'))
38
- return; // already an editor here
39
- dom.data('editInPlace', true);
40
-
41
- new InlineEditor(settings, dom).init();
42
- });
43
- };
44
-
45
- /// Switch these through the dictionary argument to $(aSelector).editInPlace(overideOptions)
46
- /// Required Options: Either url or callback, so the editor knows what to do with the edited values.
47
- $.fn.editInPlace.defaults = {
48
- url: "", // string: POST URL to send edited content
49
- ajax_data_type: "html", // string: dataType (html|script) for ajax call to save updated value
50
- bg_over: "#ffc", // string: background color of hover of unactivated editor
51
- bg_out: "transparent", // string: background color on restore from hover
52
- hover_class: "", // string: class added to root element during hover. Will override bg_over and bg_out
53
- show_buttons: false, // boolean: will show the buttons: cancel or save; will automatically cancel out the onBlur functionality
54
- save_button: '<button class="inplace_save">Save</button>', // string: image button tag to use as “Save” button
55
- cancel_button: '<button class="inplace_cancel">Cancel</button>', // string: image button tag to use as “Cancel” button
56
- params: "", // string: example: first_name=dave&last_name=hauenstein extra paramters sent via the post request to the server
57
- field_type: "text", // string: "text", "textarea", or "select", or "remote", or "clone"; The type of form field that will appear on instantiation
58
- default_text: "(Click here to add text)", // string: text to show up if the element that has this functionality is empty
59
- use_html: false, // boolean, set to true if the editor should use jQuery.fn.html() to extract the value to show from the dom node (keep in mind that IE will uppercase all tags, so use with caution)
60
- textarea_rows: 10, // integer: set rows attribute of textarea, if field_type is set to textarea. Use CSS if possible though
61
- textarea_cols: 25, // integer: set cols attribute of textarea, if field_type is set to textarea. Use CSS if possible though
62
- select_text: "Choose new value", // string: default text to show up in select box
63
- select_options: "", // string or array: Used if field_type is set to 'select'. Can be comma delimited list of options 'textandValue,text:value', Array of options ['textAndValue', 'text:value'] or array of arrays ['textAndValue', ['text', 'value']]. The last form is especially usefull if your labels or values contain colons)
64
- text_size: null, // integer: set cols attribute of text input, if field_type is set to text. Use CSS if possible though
65
- editor_url: null, // for field_type: remote url to get html_code for edit_control
66
- loading_text: 'Loading...', // shown if inplace editor is loaded from server
67
- // Specifying callback_skip_dom_reset will disable all saving_* options
68
- saving_text: undefined, // string: text to be used when server is saving information. Example "Saving..."
69
- saving_image: "", // string: uses saving text specify an image location instead of text while server is saving
70
- saving_animation_color: 'transparent', // hex color string, will be the color the pulsing animation during the save pulses to. Note: Only works if jquery-ui is loaded
71
- clone_selector: null, // if field_type clone a selector to clone editor from
72
- clone_id_suffix: null, // if field_type clone a suffix to create unique ids
73
-
74
- value_required: false, // boolean: if set to true, the element will not be saved unless a value is entered
75
- element_id: "element_id", // string: name of parameter holding the id or the editable
76
- update_value: "update_value", // string: name of parameter holding the updated/edited value
77
- original_value: 'original_value', // string: name of parameter holding the updated/edited value
78
- original_html: "original_html", // string: name of parameter holding original_html value of the editable /* DEPRECATED in 2.2.0 */ use original_value instead.
79
- save_if_nothing_changed: false, // boolean: submit to function or server even if the user did not change anything
80
- on_blur: "save", // string: "save" or null; what to do on blur; will be overridden if show_buttons is true
81
- cancel: "", // string: if not empty, a jquery selector for elements that will not cause the editor to open even though they are clicked. E.g. if you have extra buttons inside editable fields
82
-
83
- // All callbacks will have this set to the DOM node of the editor that triggered the callback
84
-
85
- callback: null, // function: function to be called when editing is complete; cancels ajax submission to the url param. Prototype: function(idOfEditor, enteredText, orinalHTMLContent, settingsParams, callbacks). The function needs to return the value that should be shown in the dom. Returning undefined means cancel and will restore the dom and trigger an error. callbacks is a dictionary with two functions didStartSaving and didEndSaving() that you can use to tell the inline editor that it should start and stop any saving animations it has configured. /* DEPRECATED in 2.1.0 */ Parameter idOfEditor, use $(this).attr('id') instead
86
- callback_skip_dom_reset: false, // boolean: set this to true if the callback should handle replacing the editor with the new value to show
87
- success: null, // function: this function gets called if server responds with a success. Prototype: function(newEditorContentString)
88
- error: null, // function: this function gets called if server responds with an error. Prototype: function(request)
89
- error_sink: function(idOfEditor, errorString) { alert(errorString); }, // function: gets id of the editor and the error. Make sure the editor has an id, or it will just be undefined. If set to null, no error will be reported. /* DEPRECATED in 2.1.0 */ Parameter idOfEditor, use $(this).attr('id') instead
90
- preinit: null, // function: this function gets called after a click on an editable element but before the editor opens. If you return false, the inline editor will not open. Prototype: function(currentDomNode). DEPRECATED in 2.2.0 use delegate shouldOpenEditInPlace call instead
91
- postclose: null, // function: this function gets called after the inline editor has closed and all values are updated. Prototype: function(currentDomNode). DEPRECATED in 2.2.0 use delegate didCloseEditInPlace call instead
92
- delegate: null // object: if it has methods with the name of the callbacks documented below in delegateExample these will be called. This means that you just need to impelment the callbacks you are interested in.
93
- };
94
-
95
- // Lifecycle events that the delegate can implement
96
- // this will always be fixed to the delegate
97
- var delegateExample = {
98
- // called while opening the editor.
99
- // return false to prevent editor from opening
100
- shouldOpenEditInPlace: function(aDOMNode, aSettingsDict, triggeringEvent) {},
101
- // return content to show in inplace editor
102
- willOpenEditInPlace: function(aDOMNode, aSettingsDict) {},
103
- didOpenEditInPlace: function(aDOMNode, aSettingsDict) {},
104
-
105
- // called while closing the editor
106
- // return false to prevent the editor from closing
107
- shouldCloseEditInPlace: function(aDOMNode, aSettingsDict, triggeringEvent) {},
108
- // return value will be shown during saving
109
- willCloseEditInPlace: function(aDOMNode, aSettingsDict) {},
110
- didCloseEditInPlace: function(aDOMNode, aSettingsDict) {},
111
-
112
- missingCommaErrorPreventer:''
113
- };
114
-
115
-
116
- function InlineEditor(settings, dom) {
117
- this.settings = settings;
118
- this.dom = dom;
119
- this.originalValue = null;
120
- this.didInsertDefaultText = false;
121
- this.shouldDelayReinit = false;
122
- };
123
-
124
- $.extend(InlineEditor.prototype, {
125
-
126
- init: function() {
127
- this.setDefaultTextIfNeccessary();
128
- this.connectOpeningEvents();
129
- },
130
-
131
- reinit: function() {
132
- if (this.shouldDelayReinit)
133
- return;
134
-
135
- this.triggerCallback(this.settings.postclose, /* DEPRECATED in 2.1.0 */ this.dom);
136
- this.triggerDelegateCall('didCloseEditInPlace');
137
-
138
- this.markEditorAsInactive();
139
- this.connectOpeningEvents();
140
- },
141
-
142
- setDefaultTextIfNeccessary: function() {
143
- if('' !== this.dom.html())
144
- return;
145
-
146
- this.dom.html(this.settings.default_text);
147
- this.didInsertDefaultText = true;
148
- },
149
-
150
- connectOpeningEvents: function() {
151
- var that = this;
152
- this.dom
153
- .bind('mouseenter.editInPlace', function(){ that.addHoverEffect(); })
154
- .bind('mouseleave.editInPlace', function(){ that.removeHoverEffect(); })
155
- .bind('click.editInPlace', function(anEvent){ that.openEditor(anEvent); });
156
- },
157
-
158
- disconnectOpeningEvents: function() {
159
- // prevent re-opening the editor when it is already open
160
- this.dom.unbind('.editInPlace');
161
- },
162
-
163
- addHoverEffect: function() {
164
- if (this.settings.hover_class)
165
- this.dom.addClass(this.settings.hover_class);
166
- else
167
- this.dom.css("background-color", this.settings.bg_over);
168
- },
169
-
170
- removeHoverEffect: function() {
171
- if (this.settings.hover_class)
172
- this.dom.removeClass(this.settings.hover_class);
173
- else
174
- this.dom.css("background-color", this.settings.bg_out);
175
- },
176
-
177
- openEditor: function(anEvent) {
178
- if ( ! this.shouldOpenEditor(anEvent))
179
- return;
180
-
181
- this.disconnectOpeningEvents();
182
- this.removeHoverEffect();
183
- this.removeInsertedDefaultTextIfNeccessary();
184
- this.saveOriginalValue();
185
- this.markEditorAsActive();
186
- this.replaceContentWithEditor();
187
- this.setInitialValue();
188
- this.workAroundMissingBlurBug();
189
- this.connectClosingEventsToEditor();
190
- this.triggerDelegateCall('didOpenEditInPlace');
191
- },
192
-
193
- shouldOpenEditor: function(anEvent) {
194
- if (this.isClickedObjectCancelled(anEvent.target))
195
- return false;
196
-
197
- if (false === this.triggerCallback(this.settings.preinit, /* DEPRECATED in 2.1.0 */ this.dom))
198
- return false;
199
-
200
- if (false === this.triggerDelegateCall('shouldOpenEditInPlace', true, anEvent))
201
- return false;
202
-
203
- return true;
204
- },
205
-
206
- removeInsertedDefaultTextIfNeccessary: function() {
207
- if ( ! this.didInsertDefaultText
208
- || this.dom.html() !== this.settings.default_text)
209
- return;
210
-
211
- this.dom.html('');
212
- this.didInsertDefaultText = false;
213
- },
214
-
215
- isClickedObjectCancelled: function(eventTarget) {
216
- if ( ! this.settings.cancel)
217
- return false;
218
-
219
- var eventTargetAndParents = $(eventTarget).parents().andSelf();
220
- var elementsMatchingCancelSelector = eventTargetAndParents.filter(this.settings.cancel);
221
- return 0 !== elementsMatchingCancelSelector.length;
222
- },
223
-
224
- saveOriginalValue: function() {
225
- if (this.settings.use_html)
226
- this.originalValue = this.dom.html();
227
- else
228
- this.originalValue = trim(this.dom.text());
229
- },
230
-
231
- restoreOriginalValue: function() {
232
- this.setClosedEditorContent(this.originalValue);
233
- },
234
-
235
- setClosedEditorContent: function(aValue) {
236
- if (this.settings.use_html)
237
- this.dom.html(aValue);
238
- else
239
- this.dom.text(aValue);
240
- },
241
-
242
- workAroundMissingBlurBug: function() {
243
- // Strangely, all browser will forget to send a blur event to an input element
244
- // when another one is created and selected programmatically. (at least under some circumstances).
245
- // This means that if another inline editor is opened, existing inline editors will _not_ close
246
- // if they are configured to submit when blurred.
247
-
248
- // Using parents() instead document as base to workaround the fact that in the unittests
249
- // the editor is not a child of window.document but of a document fragment
250
- var ourInput = this.dom.find(':input');
251
- this.dom.parents(':last').find('.editInPlace-active :input').not(ourInput).blur();
252
- },
253
-
254
- replaceContentWithEditor: function() {
255
- var buttons_html = (this.settings.show_buttons) ? this.settings.save_button + ' ' + this.settings.cancel_button : '';
256
- var editorElement = this.createEditorElement(); // needs to happen before anything is replaced
257
- /* insert the new in place form after the element they click, then empty out the original element */
258
- this.dom.html('<form class="inplace_form" style="display: inline; margin: 0; padding: 0;"></form>')
259
- .find('form')
260
- .append(editorElement)
261
- .append(buttons_html);
262
- },
263
-
264
- createEditorElement: function() {
265
- if (-1 === $.inArray(this.settings.field_type, ['text', 'textarea', 'select', 'remote', 'clone']))
266
- throw "Unknown field_type <fnord>, supported are 'text', 'textarea', 'select' and 'remote'";
267
-
268
- var editor = null;
269
- if ("select" === this.settings.field_type)
270
- editor = this.createSelectEditor();
271
- else if ("text" === this.settings.field_type)
272
- editor = $('<input type="text" ' + this.inputNameAndClass()
273
- + ' size="' + this.settings.text_size + '" />');
274
- else if ("textarea" === this.settings.field_type)
275
- editor = $('<textarea ' + this.inputNameAndClass()
276
- + ' rows="' + this.settings.textarea_rows + '" '
277
- + ' cols="' + this.settings.textarea_cols + '" />');
278
- else if ("remote" === this.settings.field_type)
279
- editor = this.createRemoteGeneratedEditor();
280
- else if ("clone" === this.settings.field_type) {
281
- editor = this.cloneEditor();
282
- return editor;
283
- }
284
- return editor;
285
- },
286
-
287
- setInitialValue: function() {
288
- if (this.settings.field_type == 'remote') return; // remote generated editor doesn't need initial value
289
- var initialValue = this.triggerDelegateCall('willOpenEditInPlace', this.originalValue);
290
- var editor = this.dom.find(':input');
291
- editor.val(initialValue);
292
-
293
- // Workaround for select fields which don't contain the original value.
294
- // Somehow the browsers don't like to select the instructional choice (disabled) in that case
295
- if (editor.val() !== initialValue)
296
- editor.val(''); // selects instructional choice
297
- },
298
-
299
- createRemoteGeneratedEditor: function () {
300
- this.dom.html(this.settings.loading_text);
301
- return $($.ajax({
302
- url: this.settings.editor_url,
303
- async: false
304
- }).responseText);
305
- },
306
-
307
- cloneEditor: function() {
308
- var patternNodes = this.getPatternNodes(this.settings.clone_selector);
309
- if (patternNodes.editNode == null) {
310
- alert('did not find any matching node for ' + this.settings.clone_selector);
311
- return;
312
- }
313
-
314
- var editorNode = patternNodes.editNode.clone();
315
- var clonedNodes = null;
316
- if (editorNode.attr('id')) editorNode.attr('id', editorNode.attr('id') + this.settings.clone_id_suffix);
317
- editorNode.attr('name', 'inplace_value');
318
- editorNode.addClass('editor_field');
319
- this.setValue(editorNode, this.originalValue);
320
- clonedNodes = editorNode;
321
-
322
- if (patternNodes.additionalNodes) {
323
- patternNodes.additionalNodes.each(function (index, node) {
324
- var patternNode = $(node).clone();
325
- if (patternNode.attr('id')) {
326
- patternNode.attr('id', patternNode.attr('id') + this.settings.clone_id_suffix);
327
- }
328
- clonedNodes = clonedNodes.after(patternNode);
329
- });
330
- }
331
- return clonedNodes;
332
- },
333
-
334
- getPatternNodes: function(clone_selector) {
335
- var nodes = {editNode: null, additionalNodes: null};
336
- var selectedNodes = $(clone_selector);
337
- var firstNode = selectedNodes.first();
338
-
339
- if (typeof(firstNode) !== 'undefined') {
340
- // AS inplace_edit_control_container -> we have to select all child nodes
341
- // Workaround for ie which does not support css > selector
342
- if (firstNode.hasClass('as_inplace_pattern')) {
343
- selectedNodes = firstNode.children();
344
- }
345
- nodes.editNode = selectedNodes.first();
346
- nodes.additionalNodes = selectedNodes.slice(1);
347
- }
348
- return nodes;
349
- },
350
-
351
- setValue: function(editField, textValue) {
352
- var function_name = 'setValueFor' + editField.get(0).nodeName.toLowerCase();
353
- if (typeof(this[function_name]) == 'function') {
354
- this[function_name](editField, textValue);
355
- } else {
356
- editField.val(textValue);
357
- }
358
- },
359
-
360
- setValueForselect: function(editField, textValue) {
361
- var option_value = editField.children("option:contains('" + textValue + "')").val();
362
-
363
- if (typeof(option_value) !== 'undefined') {
364
- editField.val(option_value);
365
- }
366
- },
367
-
368
- inputNameAndClass: function() {
369
- return ' name="inplace_value" class="inplace_field" ';
370
- },
371
-
372
- createSelectEditor: function() {
373
- var editor = $('<select' + this.inputNameAndClass() + '>'
374
- + '<option disabled="true" value="">' + this.settings.select_text + '</option>'
375
- + '</select>');
376
-
377
- var optionsArray = this.settings.select_options;
378
- if ( ! $.isArray(optionsArray))
379
- optionsArray = optionsArray.split(',');
380
-
381
- for (var i=0; i<optionsArray.length; i++) {
382
- var currentTextAndValue = optionsArray[i];
383
- if ( ! $.isArray(currentTextAndValue))
384
- currentTextAndValue = currentTextAndValue.split(':');
385
-
386
- var value = trim(currentTextAndValue[1] || currentTextAndValue[0]);
387
- var text = trim(currentTextAndValue[0]);
388
-
389
- var option = $('<option>').val(value).text(text);
390
- editor.append(option);
391
- }
392
-
393
- return editor;
394
- },
395
-
396
- connectClosingEventsToEditor: function() {
397
- var that = this;
398
- function cancelEditorAction(anEvent) {
399
- that.handleCancelEditor(anEvent);
400
- return false; // stop event bubbling
401
- }
402
- function saveEditorAction(anEvent) {
403
- that.handleSaveEditor(anEvent);
404
- return false; // stop event bubbling
405
- }
406
-
407
- var form = this.dom.find("form");
408
-
409
- form.find(".inplace_field").focus().select();
410
- form.find(".inplace_cancel").click(cancelEditorAction);
411
- form.find(".inplace_save").click(saveEditorAction);
412
-
413
- if ( ! this.settings.show_buttons) {
414
- // TODO: Firefox has a bug where blur is not reliably called when focus is lost
415
- // (for example by another editor appearing)
416
- if ("save" === this.settings.on_blur)
417
- form.find(".inplace_field").blur(saveEditorAction);
418
- else
419
- form.find(".inplace_field").blur(cancelEditorAction);
420
-
421
- // workaround for msie & firefox bug where it won't submit on enter if no button is shown
422
- if ($.browser.mozilla || $.browser.msie)
423
- this.bindSubmitOnEnterInInput();
424
- }
425
-
426
- form.keyup(function(anEvent) {
427
- // allow canceling with escape
428
- var escape = 27;
429
- if (escape === anEvent.which)
430
- return cancelEditorAction();
431
- });
432
-
433
- // workaround for webkit nightlies where they won't submit at all on enter
434
- // REFACT: find a way to just target the nightlies
435
- if ($.browser.safari)
436
- this.bindSubmitOnEnterInInput();
437
-
438
-
439
- form.submit(saveEditorAction);
440
- },
441
-
442
- bindSubmitOnEnterInInput: function() {
443
- if ('textarea' === this.settings.field_type)
444
- return; // can't enter newlines otherwise
445
-
446
- var that = this;
447
- this.dom.find(':input').keyup(function(event) {
448
- var enter = 13;
449
- if (enter === event.which)
450
- return that.dom.find('form').submit();
451
- });
452
-
453
- },
454
-
455
- handleCancelEditor: function(anEvent) {
456
- // REFACT: remove duplication between save and cancel
457
- if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
458
- return;
459
-
460
- var editor = this.dom.find(':input');
461
-
462
- var enteredText = editor.val();
463
- enteredText = this.triggerDelegateCall('willCloseEditInPlace', enteredText);
464
-
465
- this.restoreOriginalValue();
466
- this.reinit();
467
- },
468
-
469
- handleSaveEditor: function(anEvent) {
470
- if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
471
- return;
472
-
473
- var editor = this.dom.find(':input:not(:button)').not('input:checkbox:not(:checked)').not('input:radio:not(:checked)');
474
- var enteredText = '';
475
- if (editor.length > 1) {
476
- enteredText = jQuery.map(editor, function(item, index) {
477
- return $(item).val();
478
- });
479
- } else {
480
- enteredText = editor.val();
481
- }
482
- enteredText = this.triggerDelegateCall('willCloseEditInPlace', enteredText);
483
-
484
- if (this.isDisabledDefaultSelectChoice()
485
- || this.isUnchangedInput(enteredText)) {
486
- this.handleCancelEditor(anEvent);
487
- return;
488
- }
489
-
490
- if (this.didForgetRequiredText(enteredText)) {
491
- this.handleCancelEditor(anEvent);
492
- this.reportError("Error: You must enter a value to save this field");
493
- return;
494
- }
495
-
496
- this.showSaving(enteredText);
497
-
498
- if (this.settings.callback)
499
- this.handleSubmitToCallback(enteredText);
500
- else
501
- this.handleSubmitToServer(enteredText);
502
- },
503
-
504
- didForgetRequiredText: function(enteredText) {
505
- return this.settings.value_required
506
- && ("" === enteredText
507
- || undefined === enteredText
508
- || null === enteredText);
509
- },
510
-
511
- isDisabledDefaultSelectChoice: function() {
512
- return this.dom.find('option').eq(0).is(':selected:disabled');
513
- },
514
-
515
- isUnchangedInput: function(enteredText) {
516
- return ! this.settings.save_if_nothing_changed
517
- && this.originalValue === enteredText;
518
- },
519
-
520
- showSaving: function(enteredText) {
521
- if (this.settings.callback && this.settings.callback_skip_dom_reset)
522
- return;
523
-
524
- var savingMessage = enteredText;
525
- if (hasContent(this.settings.saving_text))
526
- savingMessage = this.settings.saving_text;
527
- if(hasContent(this.settings.saving_image))
528
- // REFACT: alt should be the configured saving message
529
- savingMessage = $('<img />').attr('src', this.settings.saving_image).attr('alt', savingMessage);
530
- this.dom.html(savingMessage);
531
- },
532
-
533
- handleSubmitToCallback: function(enteredText) {
534
- // REFACT: consider to encode enteredText and originalHTML before giving it to the callback
535
- this.enableOrDisableAnimationCallbacks(true, false);
536
- var newHTML = this.triggerCallback(this.settings.callback, /* DEPRECATED in 2.1.0 */ this.id(), enteredText, this.originalValue,
537
- this.settings.params, this.savingAnimationCallbacks());
538
-
539
- if (this.settings.callback_skip_dom_reset)
540
- ; // do nothing
541
- else if (undefined === newHTML) {
542
- // failure; put original back
543
- this.reportError("Error: Failed to save value: " + enteredText);
544
- this.restoreOriginalValue();
545
- }
546
- else
547
- // REFACT: use setClosedEditorContent
548
- this.dom.html(newHTML);
549
-
550
- if (this.didCallNoCallbacks()) {
551
- this.enableOrDisableAnimationCallbacks(false, false);
552
- this.reinit();
553
- }
554
- },
555
-
556
- handleSubmitToServer: function(enteredText) {
557
- var data = '';
558
- if (typeof(enteredText) === 'string') {
559
- data += this.settings.update_value + '=' + encodeURIComponent(enteredText) + '&';
560
- } else {
561
- for(var i = 0;i < enteredText.length; i++) {
562
- data += this.settings.update_value + '[]=' + encodeURIComponent(enteredText[i]) + '&';
563
- }
564
- }
565
-
566
- data += this.settings.element_id + '=' + this.dom.attr("id")
567
- + ((this.settings.params) ? '&' + this.settings.params : '')
568
- + '&' + this.settings.original_html + '=' + encodeURIComponent(this.originalValue) /* DEPRECATED in 2.2.0 */
569
- + '&' + this.settings.original_value + '=' + encodeURIComponent(this.originalValue);
570
-
571
- this.enableOrDisableAnimationCallbacks(true, false);
572
- this.didStartSaving();
573
- var that = this;
574
- $.ajax({
575
- url: that.settings.url,
576
- type: "POST",
577
- data: data,
578
- dataType: that.settings.ajax_data_type,
579
- complete: function(request){
580
- that.didEndSaving();
581
- },
582
- success: function(data){
583
- if (that.settings.ajax_data_type == 'html') {
584
- var new_text = data || that.settings.default_text;
585
-
586
- /* put the newly updated info into the original element */
587
- // FIXME: should be affected by the preferences switch
588
- that.dom.html(new_text);
589
- // REFACT: remove dom parameter, already in this, not documented, should be easy to remove
590
- // REFACT: callback should be able to override what gets put into the DOM
591
- }
592
- that.triggerCallback(that.settings.success,data);
593
- },
594
- error: function(request) {
595
- that.dom.html(that.originalHTML); // REFACT: what about a restorePreEditingContent()
596
- if (that.settings.error)
597
- // REFACT: remove dom parameter, already in this, not documented, can remove without deprecation
598
- // REFACT: callback should be able to override what gets entered into the DOM
599
- that.triggerCallback(that.settings.error, request);
600
- else
601
- that.reportError("Failed to save value: " + request.responseText || 'Unspecified Error');
602
- }
603
- });
604
- },
605
-
606
- // Utilities .........................................................
607
-
608
- triggerCallback: function(aCallback /*, arguments */) {
609
- if ( ! aCallback)
610
- return; // callback wasn't specified after all
611
-
612
- var callbackArguments = Array.prototype.slice.call(arguments, 1);
613
- return aCallback.apply(this.dom[0], callbackArguments);
614
- },
615
-
616
- /// defaultReturnValue is only used if the delegate returns undefined
617
- triggerDelegateCall: function(aDelegateMethodName, defaultReturnValue, optionalEvent) {
618
- // REFACT: consider to trigger equivalent callbacks automatically via a mapping table?
619
- if ( ! this.settings.delegate
620
- || ! $.isFunction(this.settings.delegate[aDelegateMethodName]))
621
- return defaultReturnValue;
622
-
623
- var delegateReturnValue = this.settings.delegate[aDelegateMethodName](this.dom, this.settings, optionalEvent);
624
- return (undefined === delegateReturnValue)
625
- ? defaultReturnValue
626
- : delegateReturnValue;
627
- },
628
-
629
- reportError: function(anErrorString) {
630
- this.triggerCallback(this.settings.error_sink, /* DEPRECATED in 2.1.0 */ this.id(), anErrorString);
631
- },
632
-
633
- // REFACT: this method should go, callbacks should get the dom node itself as an argument
634
- id: function() {
635
- return this.dom.attr('id');
636
- },
637
-
638
- markEditorAsActive: function() {
639
- this.dom.addClass('editInPlace-active');
640
- },
641
-
642
- markEditorAsInactive: function() {
643
- this.dom.removeClass('editInPlace-active');
644
- },
645
-
646
- // REFACT: consider rename, doesn't deal with animation directly
647
- savingAnimationCallbacks: function() {
648
- var that = this;
649
- return {
650
- didStartSaving: function() { that.didStartSaving(); },
651
- didEndSaving: function() { that.didEndSaving(); }
652
- };
653
- },
654
-
655
- enableOrDisableAnimationCallbacks: function(shouldEnableStart, shouldEnableEnd) {
656
- this.didStartSaving.enabled = shouldEnableStart;
657
- this.didEndSaving.enabled = shouldEnableEnd;
658
- },
659
-
660
- didCallNoCallbacks: function() {
661
- return this.didStartSaving.enabled && ! this.didEndSaving.enabled;
662
- },
663
-
664
- assertCanCall: function(methodName) {
665
- if ( ! this[methodName].enabled)
666
- throw new Error('Cannot call ' + methodName + ' now. See documentation for details.');
667
- },
668
-
669
- didStartSaving: function() {
670
- this.assertCanCall('didStartSaving');
671
- this.shouldDelayReinit = true;
672
- this.enableOrDisableAnimationCallbacks(false, true);
673
-
674
- this.startSavingAnimation();
675
- },
676
-
677
- didEndSaving: function() {
678
- this.assertCanCall('didEndSaving');
679
- this.shouldDelayReinit = false;
680
- this.enableOrDisableAnimationCallbacks(false, false);
681
- this.reinit();
682
-
683
- this.stopSavingAnimation();
684
- },
685
-
686
- startSavingAnimation: function() {
687
- var that = this;
688
- this.dom
689
- .animate({ backgroundColor: this.settings.saving_animation_color }, 400)
690
- .animate({ backgroundColor: 'transparent'}, 400, 'swing', function(){
691
- // In the tests animations are turned off - i.e they happen instantaneously.
692
- // Hence we need to prevent this from becomming an unbounded recursion.
693
- setTimeout(function(){ that.startSavingAnimation(); }, 10);
694
- });
695
- },
696
-
697
- stopSavingAnimation: function() {
698
- this.dom
699
- .stop(true)
700
- .css({backgroundColor: ''});
701
- },
702
-
703
- missingCommaErrorPreventer:''
704
- });
705
-
706
-
707
-
708
- // Private helpers .......................................................
709
-
710
- function assertMandatorySettingsArePresent(options) {
711
- // one of these needs to be non falsy
712
- if (options.url || options.callback)
713
- return;
714
-
715
- throw new Error("Need to set either url: or callback: option for the inline editor to work.");
716
- }
717
-
718
- /* preload the loading icon if it is configured */
719
- function preloadImage(anImageURL) {
720
- if ('' === anImageURL)
721
- return;
722
-
723
- var loading_image = new Image();
724
- loading_image.src = anImageURL;
725
- }
726
-
727
- function trim(aString) {
728
- return aString
729
- .replace(/^\s+/, '')
730
- .replace(/\s+$/, '');
731
- }
732
-
733
- function hasContent(something) {
734
- if (undefined === something || null === something)
735
- return false;
736
-
737
- if (0 === something.length)
738
- return false;
739
-
740
- return true;
741
- }
742
-
743
- })(jQuery);