bhf 0.8.0 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +1 -1
  4. data/VERSION +1 -1
  5. data/app/assets/images/bhf/pictos.png +0 -0
  6. data/app/assets/images/bhf/pictos_2x.png +0 -0
  7. data/app/assets/javascripts/bhf/application.js +153 -116
  8. data/app/assets/javascripts/bhf/classes/ArrayFields.js +1 -1
  9. data/app/assets/javascripts/bhf/classes/MultipleFields.js +2 -2
  10. data/app/assets/javascripts/bhf/classes/PlatformHelper.js +6 -11
  11. data/app/assets/javascripts/bhf/classes/{AjaxEdit.js → QuickEdit.js} +9 -9
  12. data/app/assets/javascripts/bhf/classes/{AjaxEditStack.js → QuickEditStack.js} +4 -20
  13. data/app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js +1 -0
  14. data/app/assets/javascripts/bhf/mootools_ujs.js +11 -11
  15. data/app/assets/stylesheets/bhf/application.css.sass +86 -48
  16. data/app/controllers/bhf/application_controller.rb +8 -4
  17. data/app/controllers/bhf/embed_entries_controller.rb +2 -6
  18. data/app/controllers/bhf/entries_controller.rb +13 -16
  19. data/app/controllers/bhf/pages_controller.rb +14 -13
  20. data/app/helpers/bhf/application_helper.rb +6 -6
  21. data/app/helpers/bhf/entries_helper.rb +4 -2
  22. data/app/helpers/bhf/pages_helper.rb +0 -4
  23. data/app/views/bhf/entries/_form.haml +7 -4
  24. data/app/views/bhf/entries/show.haml +3 -4
  25. data/app/views/bhf/form/belongs_to/_radio.haml +28 -0
  26. data/app/views/bhf/form/belongs_to/_select.haml +21 -0
  27. data/app/views/bhf/form/belongs_to/_static.haml +1 -0
  28. data/app/views/bhf/{entries/form → form}/column/_array.haml +0 -0
  29. data/app/views/bhf/{entries/form → form}/column/_boolean.haml +0 -0
  30. data/app/views/bhf/{entries/form → form}/column/_date.haml +0 -0
  31. data/app/views/bhf/{entries/form → form}/column/_hash.haml +0 -0
  32. data/app/views/bhf/{entries/form → form}/column/_mappin.haml +0 -0
  33. data/app/views/bhf/{entries/form → form}/column/_markdown.haml +0 -0
  34. data/app/views/bhf/{entries/form → form}/column/_multiple_fields.haml +0 -0
  35. data/app/views/bhf/{entries/form → form}/column/_number.haml +0 -0
  36. data/app/views/bhf/{entries/form → form}/column/_paperclip.haml +0 -0
  37. data/app/views/bhf/{entries/form → form}/column/_password.haml +0 -0
  38. data/app/views/bhf/{entries/form → form}/column/_static.haml +0 -0
  39. data/app/views/bhf/{entries/form → form}/column/_string.haml +0 -0
  40. data/app/views/bhf/{entries/form → form}/column/_text.haml +0 -0
  41. data/app/views/bhf/{entries/form → form}/column/_wysiwyg.haml +0 -0
  42. data/app/views/bhf/form/embeds_many/_static.haml +26 -0
  43. data/app/views/bhf/form/embeds_one/_static.haml +2 -0
  44. data/app/views/bhf/form/has_and_belongs_to_many/_check_box.haml +22 -0
  45. data/app/views/bhf/form/has_and_belongs_to_many/_static.haml +1 -0
  46. data/app/views/bhf/form/has_many/_static.haml +26 -0
  47. data/app/views/bhf/form/has_one/_static.haml +2 -0
  48. data/app/views/bhf/helper/_definition_item.haml +1 -1
  49. data/app/views/bhf/helper/_frontend_edit.haml +1 -1
  50. data/app/views/bhf/pages/_platform.haml +39 -16
  51. data/app/views/bhf/{pages/macro → table}/belongs_to/_default.haml +1 -1
  52. data/app/views/bhf/table/column/_array.haml +1 -0
  53. data/app/views/bhf/table/column/_boolean.haml +1 -0
  54. data/app/views/bhf/table/column/_date.haml +1 -0
  55. data/app/views/bhf/table/column/_extern_link.haml +2 -0
  56. data/app/views/bhf/table/column/_file.haml +1 -0
  57. data/app/views/bhf/table/column/_hash.haml +1 -0
  58. data/app/views/bhf/table/column/_image.haml +1 -0
  59. data/app/views/bhf/table/column/_number.haml +1 -0
  60. data/app/views/bhf/table/column/_paperclip.haml +5 -0
  61. data/app/views/bhf/table/column/_primary_key.haml +1 -0
  62. data/app/views/bhf/table/column/_string.haml +1 -0
  63. data/app/views/bhf/table/column/_text.haml +1 -0
  64. data/app/views/bhf/table/embeds_many/_default.haml +1 -0
  65. data/app/views/bhf/table/embeds_one/_default.haml +1 -0
  66. data/app/views/bhf/table/has_and_belongs_to_many/_default.haml +1 -0
  67. data/app/views/bhf/table/has_many/_default.haml +2 -0
  68. data/app/views/bhf/{pages/macro → table}/has_one/_default.haml +1 -1
  69. data/bhf.gemspec +60 -59
  70. data/config/locales/de.yml +8 -8
  71. data/config/locales/en.yml +7 -7
  72. data/lib/bhf.rb +26 -21
  73. data/lib/bhf/action_view/form_builder.rb +36 -0
  74. data/lib/bhf/action_view/form_options.rb +30 -0
  75. data/lib/bhf/active_record/base.rb +58 -0
  76. data/lib/bhf/mongoid/document.rb +135 -137
  77. data/lib/bhf/platform/attribute/abstract.rb +52 -0
  78. data/lib/bhf/platform/attribute/column.rb +78 -0
  79. data/lib/bhf/platform/attribute/reflection.rb +68 -0
  80. data/lib/bhf/platform/base.rb +333 -0
  81. data/lib/bhf/{pagination.rb → platform/pagination.rb} +1 -1
  82. data/lib/bhf/{settings.rb → settings/base.rb} +14 -11
  83. data/lib/bhf/settings/platform.rb +20 -0
  84. data/lib/bhf/settings/yaml_parser.rb +84 -0
  85. data/lib/rails/generators/bhf/templates/initializer.rb +1 -1
  86. metadata +58 -57
  87. data/app/views/bhf/entries/form/belongs_to/_account_scope.haml +0 -2
  88. data/app/views/bhf/entries/form/belongs_to/_radio.haml +0 -8
  89. data/app/views/bhf/entries/form/belongs_to/_select.haml +0 -7
  90. data/app/views/bhf/entries/form/belongs_to/_static.haml +0 -1
  91. data/app/views/bhf/entries/form/embeds_many/_static.haml +0 -12
  92. data/app/views/bhf/entries/form/embeds_one/_static.haml +0 -12
  93. data/app/views/bhf/entries/form/has_and_belongs_to_many/_account_scope.haml +0 -2
  94. data/app/views/bhf/entries/form/has_and_belongs_to_many/_check_box.haml +0 -5
  95. data/app/views/bhf/entries/form/has_and_belongs_to_many/_static.haml +0 -1
  96. data/app/views/bhf/entries/form/has_many/_static.haml +0 -12
  97. data/app/views/bhf/entries/form/has_one/_account_scope.haml +0 -2
  98. data/app/views/bhf/entries/form/has_one/_static.haml +0 -9
  99. data/app/views/bhf/pages/macro/column/_array.haml +0 -1
  100. data/app/views/bhf/pages/macro/column/_boolean.haml +0 -1
  101. data/app/views/bhf/pages/macro/column/_date.haml +0 -1
  102. data/app/views/bhf/pages/macro/column/_extern_link.haml +0 -2
  103. data/app/views/bhf/pages/macro/column/_file.haml +0 -1
  104. data/app/views/bhf/pages/macro/column/_hash.haml +0 -1
  105. data/app/views/bhf/pages/macro/column/_image.haml +0 -2
  106. data/app/views/bhf/pages/macro/column/_number.haml +0 -1
  107. data/app/views/bhf/pages/macro/column/_paperclip.haml +0 -6
  108. data/app/views/bhf/pages/macro/column/_primary_key.haml +0 -1
  109. data/app/views/bhf/pages/macro/column/_string.haml +0 -1
  110. data/app/views/bhf/pages/macro/column/_text.haml +0 -1
  111. data/app/views/bhf/pages/macro/embeds_many/_default.haml +0 -1
  112. data/app/views/bhf/pages/macro/embeds_one/_default.haml +0 -1
  113. data/app/views/bhf/pages/macro/has_and_belongs_to_many/_default.haml +0 -1
  114. data/app/views/bhf/pages/macro/has_many/_default.haml +0 -2
  115. data/lib/bhf/active_record/active_record.rb +0 -59
  116. data/lib/bhf/data.rb +0 -169
  117. data/lib/bhf/form.rb +0 -36
  118. data/lib/bhf/platform.rb +0 -308
  119. data/lib/bhf/settings_parser.rb +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1366b2ceb6e65bcd2a739f3521e555bf9f6a036d
4
- data.tar.gz: 27dbc45a52a99f8836128b1560f939f65043fba8
3
+ metadata.gz: 4cc6b87836fe806140e022b27025867fbdffa363
4
+ data.tar.gz: ac24ced7f99b1cd4ddd2307f22e56021c9d248df
5
5
  SHA512:
6
- metadata.gz: 49b9b8d0b83fa398b7f1d2906e783170606f930fee4ce284d6b31366f6419563c6e9e171a4b41cc0744f335631058725353511135d25bbad4e587e43c7b6df76
7
- data.tar.gz: d59d1a6b9b2c019a352748b91f64b7a90273ff155c854ec4586f3e22a4566293c0dc54c5dedf94f100f9eb2cf9675d7000e3daf4588ed31f3f7bc55b8654a7e3
6
+ metadata.gz: 3569c76fb5640ab31921d2443ab04deab1b9b5764c5e3336f47f9b38f569744c020a627804c5504291b537591907cc3540e3dc54dd9fa018901d052d52e67428
7
+ data.tar.gz: e6bbc281d695181e7d4d6afc7ec7cfb86f52434bbc5cc211bd50f67284c8521ccbc51364b1feedbc10ad211e0bd2fa7a23cc17e820fa96560768e84efa0ed038
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '~> 4.1.1'
3
+ gem 'rails', '~> 4'
4
4
  gem 'turbolinks', '~> 2.1'
5
5
  gem 'kaminari', '~> 0.15'
6
6
  gem 'haml-rails', '~> 0.4'
data/Gemfile.lock CHANGED
@@ -162,7 +162,7 @@ DEPENDENCIES
162
162
  haml-rails (~> 0.4)
163
163
  jeweler (~> 2.0)
164
164
  kaminari (~> 0.15)
165
- rails (~> 4.1.1)
165
+ rails (~> 4)
166
166
  rdoc (~> 3.12)
167
167
  sass-rails (~> 4.0)
168
168
  shoulda (~> 3.5)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.2
Binary file
Binary file
@@ -4,6 +4,9 @@
4
4
  //= require ./mootools_ujs
5
5
  //= require_tree ./classes/
6
6
 
7
+ // Turbolinks bugs out on popState if you add own pushState events, so we cancel it
8
+ Turbolinks.pagesCached(0);
9
+
7
10
  var initHelper = function(callback){
8
11
  var scopedCallback = function(){
9
12
  callback(document.body);
@@ -11,8 +14,7 @@ var initHelper = function(callback){
11
14
  document.addEventListener('page:load', scopedCallback);
12
15
  window.addEvent('domready', scopedCallback);
13
16
  window.addEvent('platformUpdate', callback);
14
- window.addEvent('quickEditReady', callback);
15
- window.addEvent('newQuickEditLink', callback);
17
+ window.addEvent('quickEditFormInject', callback);
16
18
  };
17
19
 
18
20
  (function(){
@@ -25,44 +27,101 @@ var initHelper = function(callback){
25
27
  ajaxNote.loading();
26
28
  });
27
29
 
28
- var editStack = new AjaxEditStack();
29
-
30
- var insertNewLi = function(relation, json){
31
- var elems = [];
32
- if (json.can_edit) {
33
- elems.push(new Element('a.quick_edit', {text: json.to_bhf_s || '', href: json.edit_path}));
30
+ var editStack = new QuickEditStack({
31
+ permanentQuickEditEvents: {
32
+ startRequest: function(){
33
+ var linkElem = this.linkElem;
34
+ var rowElem = this.linkElem.getParent('tr');
35
+ if (rowElem) {
36
+ linkElem = rowElem;
37
+ }
38
+ linkElem.addClass('live_edit');
39
+ },
40
+ closed: function(){
41
+ var linkElem = this.linkElem;
42
+ var rowElem = this.linkElem.getParent('tr');
43
+ if (rowElem) {
44
+ linkElem = rowElem;
45
+ }
46
+ linkElem.addClass('animate');
47
+ setTimeout(function(){
48
+ linkElem.removeClass('live_edit');
49
+ });
50
+ setTimeout(function(){
51
+ linkElem.removeClass('animate');
52
+ }, 600);
53
+ }
34
54
  }
35
- else {
36
- elems.push(new Element('a', {text: json.to_bhf_s}));
55
+ });
56
+
57
+ var triggerPlatformPagination = function(href, platform, callback){
58
+ window.history.pushState({ turbolinks: true, url: href }, '', href);
59
+ ajaxNote.loading();
60
+ new Request.HTML({
61
+ method: 'get',
62
+ url: href,
63
+ onFailure: function(){
64
+ ajaxNote.failure();
65
+ },
66
+ onSuccess: function(a, b, html){
67
+ platform.innerHTML = html;
68
+ if (callback) {
69
+ callback.call();
70
+ }
71
+ window.fireEvent('platformUpdate', [platform.getParent()]);
72
+ }
73
+ }).send();
74
+ };
75
+
76
+ var updateElementsAfterQuickEditSuccess = function(eventNames, linkElem, json){
77
+ var parent = linkElem.getParent('.quick_edit_block');
78
+ var entryTemplate = parent.getElement('.quick_edit_template');
79
+ var newEntryInjectArea = parent.getElement('.quick_edit_inject');
80
+ var relation = parent.getElement('.relation');
81
+ var entry = linkElem.getParent('.quick_edit_entry');
82
+ if ( ! entry) {
83
+ entry = parent.getElement('.quick_edit_active');
37
84
  }
38
- if (json.can_delete) {
39
- elems.push(new Element('a.delete', {html: '×' || '', href: json.delete_path, 'data-confirm': json.delete_confirm, 'data-remote': 'true'}))
85
+
86
+ if (json) {
87
+ var parsedTemplate = entryTemplate.innerHTML.replace(new RegExp('%7Bobject_id%7D', 'g'), '{object_id}').substitute(json)
40
88
  }
41
- var newLi = new Element('li').adopt(elems);
42
- relation.adopt(newLi);
43
- window.fireEvent('newQuickEditLink', [newLi]);
44
- }
45
- var setupDefaultDeleteQuickEditEvents = function(scope, options){
46
- scope.addEvent('click:relay(.delete)', function(e){
47
- e.target.addEvents({
48
- 'ajax:success': function(html){
49
- var relation = e.target.getParent('.relation');
50
- if (relation.getElements('li').length < 2) {
51
- relation.getPrevious('.empty').removeClass('hide');
52
- if (relation.hasClass('has_one') || relation.hasClass('embeds_one')) {
53
- relation.getNext('.add_field').removeClass('hide');
54
- }
55
- }
56
- e.target.getParent('li').dispose();
57
- },
58
- 'ajax:failure': function(html){
59
- alert(Locale.get('Notifications.failure'));
89
+
90
+ if (eventNames.contains('successAndAdd')) {
91
+ if (newEntryInjectArea && entryTemplate) {
92
+ newEntryInjectArea.appendHTML(parsedTemplate);
93
+ if (newEntryInjectArea) {
94
+ newEntryInjectArea.fireEvent('quickEditEntryAdded');
60
95
  }
61
- });
62
- });
63
- }
96
+ }
97
+
98
+ if (relation) {
99
+ if (relation.getPrevious('.empty')) {
100
+ relation.getPrevious('.empty').addClass('hide');
101
+ }
102
+ if (relation.hasClass('has_one') || relation.hasClass('embeds_one')) {
103
+ relation.getNext('.js_add_field').addClass('hide');
104
+ }
105
+ }
106
+ }
107
+ if (eventNames.contains('successAndChange')) {
108
+ if (entry) {
109
+ entry.innerHTML = parsedTemplate;
110
+ }
111
+ }
112
+ if (eventNames.contains('successAndRemove')) {
113
+ if (entry) {
114
+ entry.dispose();
115
+ }
116
+ if (newEntryInjectArea) {
117
+ newEntryInjectArea.fireEvent('quickEditEntryRemoved');
118
+ }
119
+
120
+ }
121
+ };
64
122
 
65
123
  initHelper(function(mainScope){
124
+
66
125
  var areaSelect = mainScope.getElement('#area_select');
67
126
  if (areaSelect) {
68
127
  areaSelect.addEvent('change', function(){
@@ -71,18 +130,16 @@ var initHelper = function(callback){
71
130
  }
72
131
 
73
132
  var quickEditArray = [];
74
- var ajaxEditOptions;
133
+ var quickEditOptions;
75
134
 
76
135
  ajaxNote.setup();
77
136
 
78
- rails.applyEvents(mainScope);
79
-
80
137
  var jsForm = new FormHelper();
81
138
  mainScope.getElements('.js_bhf_form').each(function(form){
82
139
  jsForm.setup(form);
83
140
  });
84
141
 
85
- var sharedAjaxEditOptions = {
142
+ var sharedQuickEditOptions = {
86
143
  onFailure: function(){
87
144
  ajaxNote.failure();
88
145
  },
@@ -93,7 +150,8 @@ var initHelper = function(callback){
93
150
  scrollContent();
94
151
  ajaxNote.success();
95
152
  },
96
- onSave: function(form){
153
+ onSave: function(eventNames, linkElem, json){
154
+ updateElementsAfterQuickEditSuccess(eventNames, linkElem, json);
97
155
  ajaxNote.success();
98
156
  },
99
157
  onBeforeSubmit: function(){
@@ -106,39 +164,63 @@ var initHelper = function(callback){
106
164
 
107
165
  var platforms = mainScope.getElements('.platform');
108
166
  var mainForm = mainScope.getElementById('main_form');
167
+
168
+ mainScope.getElements('.quick_edit_select').addEvent('change', function(e){
169
+ var parent = this.getParent('.quick_edit_block');
170
+ var optionElem = this.options[this.selectedIndex];
171
+ var editElem = parent.getElement('.js_edit_field');
172
+ if (editElem) {
173
+ editElem.href = optionElem.get('data-edit');
174
+ }
175
+ var deleteElem = parent.getElement('.js_delete');
176
+ if (deleteElem) {
177
+ deleteElem.href = optionElem.get('data-delete');
178
+ }
179
+ this.getElements('.quick_edit_active').removeClass('quick_edit_active');
180
+ optionElem.addClass('quick_edit_active');
181
+ }).addEvent('quickEditEntryAdded', function(){
182
+ this.selectedIndex = this.options.length - 1;
183
+ this.fireEvent('change');
184
+ }).addEvent('quickEditEntryRemoved', function(){
185
+ this.selectedIndex = 0;
186
+ this.fireEvent('change');
187
+ }).fireEvent('change');
188
+
189
+ mainScope.addEvent('click:relay(.js_delete)', function(e){
190
+ e.target.addEvents({
191
+ 'ajax:success': function(html){
192
+ updateElementsAfterQuickEditSuccess(['successAndRemove'], e.target);
193
+ },
194
+ 'ajax:failure': function(html){
195
+ alert(Locale.get('Notifications.failure'));
196
+ }
197
+ });
198
+ });
199
+
109
200
 
110
201
  if (platforms.length) {
111
- ajaxEditOptions = Object.merge({
112
- onSuccessAndChange: function(json){
113
- var tr = this.wrapElement;
114
- tr.getElements('td').each(function(td){
115
- var name = td.get('data-column-name');
116
- if ( ! name) { return; }
117
- var a = td.getElement('a.quick_edit');
118
- (a ? a : td).innerHTML = json[name] || '';
119
- });
120
- },
202
+ quickEditOptions = Object.merge({
121
203
  onSuccessAndNext: function(json){
122
- var tr = this.wrapElement;
204
+ var tr = this.linkElem;
123
205
  var qe;
124
206
  var nextTr = tr.getNext('tr');
125
207
 
126
208
  if (nextTr) {
127
209
  editStack.removeAllStacks();
128
- editStack.addEditBrick(ajaxEditOptions, nextTr.getElement('a'), nextTr);
210
+ editStack.addEditBrick(quickEditOptions, nextTr.getElement('a'), nextTr);
129
211
  }
130
212
  else {
131
213
  var platform = tr.getParent('.platform');
132
214
  var loadMore = platform.getElement('.load_more');
133
215
  if (loadMore) {
134
216
  trIndex = tr.getParent('tbody').getElements('tr').indexOf(tr);
135
- updatePlatform(loadMore.get('href'), platform, function(){
217
+ triggerPlatformPagination(loadMore.get('href'), platform, function(){
136
218
  platform.getElements('tbody tr').each(function(newTr, index){
137
219
  if (trIndex === index) {
138
220
  nextTr = newTr.getNext('tr');
139
221
 
140
222
  editStack.removeAllStacks();
141
- editStack.addEditBrick(ajaxEditOptions, nextTr.getElement('a'), nextTr);
223
+ editStack.addEditBrick(quickEditOptions, nextTr.getElement('a'), nextTr);
142
224
  }
143
225
  });
144
226
  });
@@ -147,39 +229,21 @@ var initHelper = function(callback){
147
229
  nextTr = platform.getElements('tbody tr')[0];
148
230
 
149
231
  editStack.removeAllStacks();
150
- editStack.addEditBrick(ajaxEditOptions, nextTr.getElement('a'), nextTr);
232
+ editStack.addEditBrick(quickEditOptions, nextTr.getElement('a'), nextTr);
151
233
  }
152
234
  }
153
235
  }
154
- }, sharedAjaxEditOptions);
236
+ }, sharedQuickEditOptions);
155
237
 
156
-
157
- var updatePlatform = function(href, platform, callback){
158
- ajaxNote.loading();
159
- new Request.HTML({
160
- method: 'get',
161
- url: href,
162
- onFailure: function(){
163
- ajaxNote.failure();
164
- },
165
- onSuccess: function(a, b, html){
166
- platform.innerHTML = html;
167
- if (callback) {
168
- callback.call();
169
- }
170
- window.fireEvent('platformUpdate', [platform.getParent()]);
171
- }
172
- }).send();
173
- };
174
238
 
175
239
  platforms.each(function(p){
176
240
  new PlatformHelper(p, {
177
241
  onPaginationStart: function(link){
178
- updatePlatform(link.get('href'), link.getParent('.platform'));
242
+ triggerPlatformPagination(link.get('href'), link.getParent('.platform'));
179
243
  },
180
244
  onQuickEditStart: function(link){
181
245
  editStack.removeAllStacks();
182
- editStack.addEditBrick(ajaxEditOptions, link, link.getParent('tr'));
246
+ editStack.addEditBrick(quickEditOptions, link, link.getParent('tr'));
183
247
  },
184
248
  onSearch: function(){
185
249
  ajaxNote.loading();
@@ -187,95 +251,68 @@ var initHelper = function(callback){
187
251
  onSearchFailure: function(){
188
252
  ajaxNote.failure();
189
253
  },
190
- onSearchSuccess: function(){
254
+ onSearchSuccess: function(request){
191
255
  window.fireEvent('platformUpdate', [p.getParent()]);
256
+ // TODO: remove the mootools hack for request.url don't
257
+ window.history.pushState({ turbolinks: true, url: request.url }, '', request.url);
192
258
  }
193
259
  });
194
260
  });
195
261
  }
196
262
  else if (mainForm) {
197
- ajaxEditOptions = Object.merge({
198
- onSuccessAndAdd: function(json){
199
- var relation = this.wrapElement.getPrevious('.relation');
200
- relation.getPrevious('.empty').addClass('hide');
201
- if (relation.hasClass('has_one') || relation.hasClass('embeds_one')) {
202
- relation.getNext('.add_field').addClass('hide');
203
- }
204
- insertNewLi(relation, json);
205
- },
206
- onSuccessAndChange: function(json){
207
- this.wrapElement.set('text', json.to_bhf_s || '');
208
- },
263
+ quickEditOptions = Object.merge({
209
264
  onSuccessAndNext: function(json){
210
- var a = this.wrapElement;
265
+ var a = this.linkElem;
211
266
  var li = a.getParent('li');
212
267
  if ( ! li) {
213
268
  this.close();
214
269
  return;
215
270
  }
216
271
  var holder = li.getNext('li');
217
-
218
272
  if ( ! holder) {
219
273
  holder = li.getParent('ul');
220
274
  }
221
275
 
222
276
  editStack.removeAllStacks();
223
- editStack.addEditBrick(ajaxEditOptions, holder.getElement('a'));
277
+ editStack.addEditBrick(quickEditOptions, holder.getElement('a'));
224
278
  }
225
- }, sharedAjaxEditOptions);
279
+ }, sharedQuickEditOptions);
226
280
 
227
- setupDefaultDeleteQuickEditEvents(mainForm, ajaxEditOptions);
228
281
  mainForm.addEvent('click:relay(.quick_edit)', function(e){
229
282
  e.preventDefault();
230
283
  editStack.removeAllStacks();
231
- editStack.addEditBrick(ajaxEditOptions, this);
284
+ editStack.addEditBrick(quickEditOptions, this);
232
285
  });
233
286
  }
234
287
  else if (mainScope.hasClass('quick_edit_holder')) {
235
- ajaxEditOptions = Object.merge({
236
- onSuccessAndAdd: function(json){
237
- var relation = this.wrapElement.getPrevious('.relation');
238
- relation.getPrevious('.empty').addClass('hide');
239
- if (relation.hasClass('has_one') || relation.hasClass('embeds_one')) {
240
- relation.getNext('.add_field').addClass('hide');
241
- }
242
- insertNewLi(relation, json);
243
- },
244
- onSuccessAndChange: function(json){
245
- this.wrapElement.set('text', json.to_bhf_s || '');
246
- },
288
+ quickEditOptions = Object.merge({
247
289
  onClosed: function(){
248
290
  editStack.removeStack();
249
291
  },
250
292
  hideNext: true
251
- }, sharedAjaxEditOptions);
293
+ }, sharedQuickEditOptions);
252
294
 
253
- setupDefaultDeleteQuickEditEvents(mainScope, ajaxEditOptions);
254
295
  mainScope.addEvent('click:relay(.quick_edit)', function(e){
255
296
  e.preventDefault();
256
297
  editStack.addStack();
257
- editStack.addEditBrick(ajaxEditOptions, this);
298
+ editStack.addEditBrick(quickEditOptions, this);
258
299
  });
259
300
  }
260
301
 
261
302
 
262
- var windowHight = document.body.clientHeight;
263
- window.onresize = function(e){
264
- windowHight = document.body.clientHeight;
265
- };
266
303
  var scrollContent = function(){
267
304
  quickEditArray.each(function(quickEdit){
268
305
  var innerForm = quickEdit.holder.getElement('form');
269
306
  if ( ! innerForm) { return; }
270
307
  var scroll = document.body.scrollTop - 83;
271
- if (scroll + innerForm.getSize().y > windowHight) { return; }
308
+ if (scroll + innerForm.getSize().y > document.body.clientHeight) { return; }
272
309
  quickEdit.holder.setStyle('padding-top', scroll);
273
310
  });
274
311
  };
275
312
  // window.onscroll = scrollContent;
276
313
 
277
314
 
278
- mainScope.getElements('.sortable').each(function(sortableElems){
315
+ mainScope.getElements('.js_sortable').each(function(sortableElems){
279
316
  new Sortables(sortableElems, {
280
317
  handle: '.handle',
281
318
  onStart: function(element, clone){
@@ -285,7 +322,7 @@ var initHelper = function(callback){
285
322
  element.removeClass('dragged');
286
323
  new Request({
287
324
  method: 'put',
288
- url: this.element.getParent('tbody').get('data-sort-url')
325
+ url: sortableElems.get('data-sort-url')
289
326
  }).send({data: {order: this.serialize()}});
290
327
  }
291
328
  });