bhf 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/app/assets/images/bhf/pictos.png +0 -0
- data/app/assets/images/bhf/pictos_2x.png +0 -0
- data/app/assets/javascripts/bhf/application.js +153 -116
- data/app/assets/javascripts/bhf/classes/ArrayFields.js +1 -1
- data/app/assets/javascripts/bhf/classes/MultipleFields.js +2 -2
- data/app/assets/javascripts/bhf/classes/PlatformHelper.js +6 -11
- data/app/assets/javascripts/bhf/classes/{AjaxEdit.js → QuickEdit.js} +9 -9
- data/app/assets/javascripts/bhf/classes/{AjaxEditStack.js → QuickEditStack.js} +4 -20
- data/app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js +1 -0
- data/app/assets/javascripts/bhf/mootools_ujs.js +11 -11
- data/app/assets/stylesheets/bhf/application.css.sass +86 -48
- data/app/controllers/bhf/application_controller.rb +8 -4
- data/app/controllers/bhf/embed_entries_controller.rb +2 -6
- data/app/controllers/bhf/entries_controller.rb +13 -16
- data/app/controllers/bhf/pages_controller.rb +14 -13
- data/app/helpers/bhf/application_helper.rb +6 -6
- data/app/helpers/bhf/entries_helper.rb +4 -2
- data/app/helpers/bhf/pages_helper.rb +0 -4
- data/app/views/bhf/entries/_form.haml +7 -4
- data/app/views/bhf/entries/show.haml +3 -4
- data/app/views/bhf/form/belongs_to/_radio.haml +28 -0
- data/app/views/bhf/form/belongs_to/_select.haml +21 -0
- data/app/views/bhf/form/belongs_to/_static.haml +1 -0
- data/app/views/bhf/{entries/form → form}/column/_array.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_boolean.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_date.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_hash.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_mappin.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_markdown.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_multiple_fields.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_number.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_paperclip.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_password.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_static.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_string.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_text.haml +0 -0
- data/app/views/bhf/{entries/form → form}/column/_wysiwyg.haml +0 -0
- data/app/views/bhf/form/embeds_many/_static.haml +26 -0
- data/app/views/bhf/form/embeds_one/_static.haml +2 -0
- data/app/views/bhf/form/has_and_belongs_to_many/_check_box.haml +22 -0
- data/app/views/bhf/form/has_and_belongs_to_many/_static.haml +1 -0
- data/app/views/bhf/form/has_many/_static.haml +26 -0
- data/app/views/bhf/form/has_one/_static.haml +2 -0
- data/app/views/bhf/helper/_definition_item.haml +1 -1
- data/app/views/bhf/helper/_frontend_edit.haml +1 -1
- data/app/views/bhf/pages/_platform.haml +39 -16
- data/app/views/bhf/{pages/macro → table}/belongs_to/_default.haml +1 -1
- data/app/views/bhf/table/column/_array.haml +1 -0
- data/app/views/bhf/table/column/_boolean.haml +1 -0
- data/app/views/bhf/table/column/_date.haml +1 -0
- data/app/views/bhf/table/column/_extern_link.haml +2 -0
- data/app/views/bhf/table/column/_file.haml +1 -0
- data/app/views/bhf/table/column/_hash.haml +1 -0
- data/app/views/bhf/table/column/_image.haml +1 -0
- data/app/views/bhf/table/column/_number.haml +1 -0
- data/app/views/bhf/table/column/_paperclip.haml +5 -0
- data/app/views/bhf/table/column/_primary_key.haml +1 -0
- data/app/views/bhf/table/column/_string.haml +1 -0
- data/app/views/bhf/table/column/_text.haml +1 -0
- data/app/views/bhf/table/embeds_many/_default.haml +1 -0
- data/app/views/bhf/table/embeds_one/_default.haml +1 -0
- data/app/views/bhf/table/has_and_belongs_to_many/_default.haml +1 -0
- data/app/views/bhf/table/has_many/_default.haml +2 -0
- data/app/views/bhf/{pages/macro → table}/has_one/_default.haml +1 -1
- data/bhf.gemspec +60 -59
- data/config/locales/de.yml +8 -8
- data/config/locales/en.yml +7 -7
- data/lib/bhf.rb +26 -21
- data/lib/bhf/action_view/form_builder.rb +36 -0
- data/lib/bhf/action_view/form_options.rb +30 -0
- data/lib/bhf/active_record/base.rb +58 -0
- data/lib/bhf/mongoid/document.rb +135 -137
- data/lib/bhf/platform/attribute/abstract.rb +52 -0
- data/lib/bhf/platform/attribute/column.rb +78 -0
- data/lib/bhf/platform/attribute/reflection.rb +68 -0
- data/lib/bhf/platform/base.rb +333 -0
- data/lib/bhf/{pagination.rb → platform/pagination.rb} +1 -1
- data/lib/bhf/{settings.rb → settings/base.rb} +14 -11
- data/lib/bhf/settings/platform.rb +20 -0
- data/lib/bhf/settings/yaml_parser.rb +84 -0
- data/lib/rails/generators/bhf/templates/initializer.rb +1 -1
- metadata +58 -57
- data/app/views/bhf/entries/form/belongs_to/_account_scope.haml +0 -2
- data/app/views/bhf/entries/form/belongs_to/_radio.haml +0 -8
- data/app/views/bhf/entries/form/belongs_to/_select.haml +0 -7
- data/app/views/bhf/entries/form/belongs_to/_static.haml +0 -1
- data/app/views/bhf/entries/form/embeds_many/_static.haml +0 -12
- data/app/views/bhf/entries/form/embeds_one/_static.haml +0 -12
- data/app/views/bhf/entries/form/has_and_belongs_to_many/_account_scope.haml +0 -2
- data/app/views/bhf/entries/form/has_and_belongs_to_many/_check_box.haml +0 -5
- data/app/views/bhf/entries/form/has_and_belongs_to_many/_static.haml +0 -1
- data/app/views/bhf/entries/form/has_many/_static.haml +0 -12
- data/app/views/bhf/entries/form/has_one/_account_scope.haml +0 -2
- data/app/views/bhf/entries/form/has_one/_static.haml +0 -9
- data/app/views/bhf/pages/macro/column/_array.haml +0 -1
- data/app/views/bhf/pages/macro/column/_boolean.haml +0 -1
- data/app/views/bhf/pages/macro/column/_date.haml +0 -1
- data/app/views/bhf/pages/macro/column/_extern_link.haml +0 -2
- data/app/views/bhf/pages/macro/column/_file.haml +0 -1
- data/app/views/bhf/pages/macro/column/_hash.haml +0 -1
- data/app/views/bhf/pages/macro/column/_image.haml +0 -2
- data/app/views/bhf/pages/macro/column/_number.haml +0 -1
- data/app/views/bhf/pages/macro/column/_paperclip.haml +0 -6
- data/app/views/bhf/pages/macro/column/_primary_key.haml +0 -1
- data/app/views/bhf/pages/macro/column/_string.haml +0 -1
- data/app/views/bhf/pages/macro/column/_text.haml +0 -1
- data/app/views/bhf/pages/macro/embeds_many/_default.haml +0 -1
- data/app/views/bhf/pages/macro/embeds_one/_default.haml +0 -1
- data/app/views/bhf/pages/macro/has_and_belongs_to_many/_default.haml +0 -1
- data/app/views/bhf/pages/macro/has_many/_default.haml +0 -2
- data/lib/bhf/active_record/active_record.rb +0 -59
- data/lib/bhf/data.rb +0 -169
- data/lib/bhf/form.rb +0 -36
- data/lib/bhf/platform.rb +0 -308
- data/lib/bhf/settings_parser.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cc6b87836fe806140e022b27025867fbdffa363
|
4
|
+
data.tar.gz: ac24ced7f99b1cd4ddd2307f22e56021c9d248df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3569c76fb5640ab31921d2443ab04deab1b9b5764c5e3336f47f9b38f569744c020a627804c5504291b537591907cc3540e3dc54dd9fa018901d052d52e67428
|
7
|
+
data.tar.gz: e6bbc281d695181e7d4d6afc7ec7cfb86f52434bbc5cc211bd50f67284c8521ccbc51364b1feedbc10ad211e0bd2fa7a23cc17e820fa96560768e84efa0ed038
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
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('
|
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
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
85
|
+
|
86
|
+
if (json) {
|
87
|
+
var parsedTemplate = entryTemplate.innerHTML.replace(new RegExp('%7Bobject_id%7D', 'g'), '{object_id}').substitute(json)
|
40
88
|
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
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
|
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(
|
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
|
-
|
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.
|
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(
|
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
|
-
|
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(
|
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(
|
232
|
+
editStack.addEditBrick(quickEditOptions, nextTr.getElement('a'), nextTr);
|
151
233
|
}
|
152
234
|
}
|
153
235
|
}
|
154
|
-
},
|
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
|
-
|
242
|
+
triggerPlatformPagination(link.get('href'), link.getParent('.platform'));
|
179
243
|
},
|
180
244
|
onQuickEditStart: function(link){
|
181
245
|
editStack.removeAllStacks();
|
182
|
-
editStack.addEditBrick(
|
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
|
-
|
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.
|
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(
|
277
|
+
editStack.addEditBrick(quickEditOptions, holder.getElement('a'));
|
224
278
|
}
|
225
|
-
},
|
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(
|
284
|
+
editStack.addEditBrick(quickEditOptions, this);
|
232
285
|
});
|
233
286
|
}
|
234
287
|
else if (mainScope.hasClass('quick_edit_holder')) {
|
235
|
-
|
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
|
-
},
|
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(
|
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 >
|
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('.
|
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:
|
325
|
+
url: sortableElems.get('data-sort-url')
|
289
326
|
}).send({data: {order: this.serialize()}});
|
290
327
|
}
|
291
328
|
});
|