active_scaffold-sequel 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/active_scaffold.js.erb +12 -14
- data/app/assets/javascripts/jquery/active_scaffold.js +610 -348
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +37 -19
- data/app/assets/javascripts/jquery/draggable_lists.js +28 -27
- data/app/assets/javascripts/jquery/jquery.editinplace.js +145 -137
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +1 -1
- data/app/assets/stylesheets/{active_scaffold.css.scss → active_scaffold.scss} +0 -0
- data/app/assets/stylesheets/{active_scaffold_colors.css.scss → active_scaffold_colors.scss} +0 -0
- data/app/assets/stylesheets/{active_scaffold_images.css.scss → active_scaffold_images.scss} +0 -0
- data/frontends/default/views/_list.html.erb +1 -1
- data/frontends/default/views/_list_record.html.erb +2 -1
- data/frontends/default/views/_search.html.erb +1 -10
- data/frontends/default/views/add_existing.js.erb +0 -3
- data/lib/active_scaffold.rb +0 -12
- data/lib/active_scaffold/actions/list.rb +8 -3
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +3 -8
- data/lib/active_scaffold/bridges/date_picker.rb +2 -3
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +3 -7
- data/lib/active_scaffold/bridges/tiny_mce.rb +1 -5
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +1 -5
- data/lib/active_scaffold/extensions/action_view_rendering.rb +1 -6
- data/lib/active_scaffold/extensions/routing_mapper.rb +1 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/form_column_helpers.rb +3 -10
- data/lib/active_scaffold/version.rb +2 -2
- data/vendor/assets/javascripts/getprototypeof.js +12 -0
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +1882 -1276
- metadata +71 -65
- checksums.yaml +0 -7
- data/app/assets/javascripts/prototype/active_scaffold.js +0 -1103
- data/app/assets/javascripts/prototype/dhtml_history.js +0 -870
- data/app/assets/javascripts/prototype/form_enhancements.js +0 -117
- data/app/assets/javascripts/prototype/rico_corner.js +0 -370
- data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -7
- data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -24
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -67
@@ -1,24 +1,42 @@
|
|
1
|
+
<%# encoding: utf-8 %>
|
1
2
|
<%= ActiveScaffold::Bridges[:date_picker].localization %>
|
2
|
-
|
3
|
-
jQuery(
|
4
|
-
|
5
|
-
var
|
6
|
-
|
7
|
-
if
|
8
|
-
|
9
|
-
|
3
|
+
Object.getPrototypeOf(jQuery.datepicker)._attachDatepicker_without_inlineSettings = Object.getPrototypeOf(jQuery.datepicker)._attachDatepicker;
|
4
|
+
jQuery.extend(Object.getPrototypeOf(jQuery.datepicker), {
|
5
|
+
_attachDatepicker: function(target, settings) {
|
6
|
+
var inlineSettings = {}, $target = jQuery(target);
|
7
|
+
for (var attrName in this._defaults) {
|
8
|
+
if(this._defaults.hasOwnProperty(attrName)){
|
9
|
+
var attrValue = $target.data(attrName.toLowerCase());
|
10
|
+
if (attrValue) {
|
11
|
+
try {
|
12
|
+
inlineSettings[attrName] = eval(attrValue);
|
13
|
+
} catch (err) {
|
14
|
+
inlineSettings[attrName] = attrValue;
|
15
|
+
}
|
16
|
+
}
|
10
17
|
}
|
11
18
|
}
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
this._attachDatepicker_without_inlineSettings(target, jQuery.extend({}, settings || {}, inlineSettings));
|
20
|
+
}
|
21
|
+
});
|
22
|
+
jQuery(document).on("focus", "input.date_picker", function(){
|
23
|
+
var date_picker = jQuery(this);
|
24
|
+
if (typeof(date_picker.datepicker) == 'function') {
|
25
|
+
if (!date_picker.hasClass('hasDatepicker')) {
|
26
|
+
date_picker.datepicker();
|
27
|
+
date_picker.trigger('focus');
|
28
|
+
}
|
29
|
+
}
|
30
|
+
return true;
|
31
|
+
});
|
32
|
+
|
33
|
+
jQuery(document).on("focus", "input.datetime_picker", function(){
|
34
|
+
var date_picker = jQuery(this);
|
35
|
+
if (typeof(date_picker.datetimepicker) == 'function') {
|
36
|
+
if (!date_picker.hasClass('hasDatepicker')) {
|
37
|
+
date_picker.datetimepicker();
|
38
|
+
date_picker.trigger('focus');
|
21
39
|
}
|
22
|
-
|
23
|
-
|
40
|
+
}
|
41
|
+
return true;
|
24
42
|
});
|
@@ -1,27 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
};
|
1
|
+
(function() {
|
2
|
+
function enableDraggableLists(element) {
|
3
|
+
if (element.hasClass('draggable-list')) return;
|
4
|
+
element.addClass('draggable-list');
|
5
|
+
var list_selected = jQuery(element.get(0).cloneNode(false)).addClass('selected');
|
6
|
+
list_selected.attr('id', list_selected.attr('id') + '_selected').insertAfter(element);
|
7
|
+
element.find('input:checkbox').each(function(index, item) {
|
8
|
+
var li = jQuery(item).closest('li').addClass('draggable-item');
|
9
|
+
li.children('label').removeAttr('for');
|
10
|
+
if (jQuery(item).is(':checked')) li.appendTo(list_selected);
|
11
|
+
});
|
12
|
+
var options = {
|
13
|
+
hoverClass: 'hover',
|
14
|
+
containment: '',
|
15
|
+
receive: function(event, ui) {
|
16
|
+
var input = jQuery('input:checkbox', ui.item), selected = input.prop('checked');
|
17
|
+
input.prop('checked', jQuery(this).hasClass('selected'));
|
18
|
+
if (selected != input.prop('checked')) input.trigger('change');
|
19
|
+
}
|
20
|
+
};
|
21
|
+
jQuery(element).sortable(jQuery.extend(options, {connectWith: '#'+list_selected.attr('id')}));
|
22
|
+
jQuery(list_selected).sortable(jQuery.extend(options, {connectWith: '#'+element.attr('id')}));
|
23
|
+
return element;
|
24
|
+
};
|
25
|
+
jQuery.fn.draggableLists = function() {
|
26
|
+
this.each(function() { enableDraggableLists(jQuery(this)); });
|
27
|
+
};
|
28
|
+
})();
|
@@ -11,7 +11,7 @@ Authors:
|
|
11
11
|
Project home:
|
12
12
|
http://code.google.com/p/jquery-in-place-editor/
|
13
13
|
|
14
|
-
Patches with tests welcomed! For guidance see the tests
|
14
|
+
Patches with tests welcomed! For guidance see the tests </spec/unit/>. To submit, attach them to the bug tracker.
|
15
15
|
|
16
16
|
License:
|
17
17
|
This source file is subject to the BSD license bundled with this package.
|
@@ -19,6 +19,7 @@ Available online: {@link http://www.opensource.org/licenses/bsd-license.php}
|
|
19
19
|
If you did not receive a copy of the license, and are unable to obtain it,
|
20
20
|
learn to use a search engine.
|
21
21
|
|
22
|
+
Rev: 161
|
22
23
|
*/
|
23
24
|
|
24
25
|
(function($){
|
@@ -26,9 +27,7 @@ learn to use a search engine.
|
|
26
27
|
$.fn.editInPlace = function(options) {
|
27
28
|
|
28
29
|
var settings = $.extend({}, $.fn.editInPlace.defaults, options);
|
29
|
-
|
30
30
|
assertMandatorySettingsArePresent(settings);
|
31
|
-
|
32
31
|
preloadImage(settings.saving_image);
|
33
32
|
|
34
33
|
return this.each(function() {
|
@@ -47,44 +46,45 @@ $.fn.editInPlace = function(options) {
|
|
47
46
|
/// Required Options: Either url or callback, so the editor knows what to do with the edited values.
|
48
47
|
$.fn.editInPlace.defaults = {
|
49
48
|
url: "", // string: POST URL to send edited content
|
50
|
-
ajax_data_type:
|
49
|
+
ajax_data_type: "html", // string: dataType (html|script) for ajax call to save updated value
|
51
50
|
bg_over: "#ffc", // string: background color of hover of unactivated editor
|
52
51
|
bg_out: "transparent", // string: background color on restore from hover
|
53
|
-
hover_class: "",
|
52
|
+
hover_class: "", // string: class added to root element during hover. Will override bg_over and bg_out
|
54
53
|
show_buttons: false, // boolean: will show the buttons: cancel or save; will automatically cancel out the onBlur functionality
|
55
54
|
save_button: '<button class="inplace_save">Save</button>', // string: image button tag to use as “Save” button
|
56
55
|
cancel_button: '<button class="inplace_cancel">Cancel</button>', // string: image button tag to use as “Cancel” button
|
57
56
|
params: "", // string: example: first_name=dave&last_name=hauenstein extra paramters sent via the post request to the server
|
58
|
-
field_type: "text", // string: "text", "textarea", or "select", or "remote", or "clone";
|
57
|
+
field_type: "text", // string: "text", "textarea", or "select", or "remote", or "clone"; The type of form field that will appear on instantiation
|
59
58
|
default_text: "(Click here to add text)", // string: text to show up if the element that has this functionality is empty
|
60
|
-
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
|
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)
|
61
60
|
textarea_rows: 10, // integer: set rows attribute of textarea, if field_type is set to textarea. Use CSS if possible though
|
62
61
|
textarea_cols: 25, // integer: set cols attribute of textarea, if field_type is set to textarea. Use CSS if possible though
|
63
62
|
select_text: "Choose new value", // string: default text to show up in select box
|
64
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)
|
65
64
|
text_size: null, // integer: set cols attribute of text input, if field_type is set to text. Use CSS if possible though
|
66
|
-
editor_url:
|
67
|
-
loading_text:
|
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
|
68
67
|
// Specifying callback_skip_dom_reset will disable all saving_* options
|
69
68
|
saving_text: undefined, // string: text to be used when server is saving information. Example "Saving..."
|
70
69
|
saving_image: "", // string: uses saving text specify an image location instead of text while server is saving
|
71
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
|
72
|
-
clone_selector:
|
73
|
-
clone_id_suffix:
|
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
|
74
73
|
|
75
74
|
value_required: false, // boolean: if set to true, the element will not be saved unless a value is entered
|
76
75
|
element_id: "element_id", // string: name of parameter holding the id or the editable
|
77
76
|
update_value: "update_value", // string: name of parameter holding the updated/edited value
|
78
77
|
original_value: 'original_value', // string: name of parameter holding the updated/edited value
|
79
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.
|
80
|
-
save_if_nothing_changed: false,
|
79
|
+
save_if_nothing_changed: false, // boolean: submit to function or server even if the user did not change anything
|
81
80
|
on_blur: "save", // string: "save" or null; what to do on blur; will be overridden if show_buttons is true
|
82
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
|
83
82
|
|
84
83
|
// All callbacks will have this set to the DOM node of the editor that triggered the callback
|
85
84
|
|
86
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
|
87
|
-
callback_skip_dom_reset:
|
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
|
+
beforeSend: null, // function: this function gets called before sending new value to server. Prototype: function(request, requestSettings)
|
88
88
|
success: null, // function: this function gets called if server responds with a success. Prototype: function(newEditorContentString)
|
89
89
|
error: null, // function: this function gets called if server responds with an error. Prototype: function(request)
|
90
90
|
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
|
@@ -157,7 +157,7 @@ $.extend(InlineEditor.prototype, {
|
|
157
157
|
},
|
158
158
|
|
159
159
|
disconnectOpeningEvents: function() {
|
160
|
-
|
160
|
+
// prevent re-opening the editor when it is already open
|
161
161
|
this.dom.unbind('.editInPlace');
|
162
162
|
},
|
163
163
|
|
@@ -179,14 +179,15 @@ $.extend(InlineEditor.prototype, {
|
|
179
179
|
if ( ! this.shouldOpenEditor(anEvent))
|
180
180
|
return;
|
181
181
|
|
182
|
-
this.workAroundFirefoxBlurBug();
|
183
182
|
this.disconnectOpeningEvents();
|
184
183
|
this.removeHoverEffect();
|
185
184
|
this.removeInsertedDefaultTextIfNeccessary();
|
186
185
|
this.saveOriginalValue();
|
187
186
|
this.markEditorAsActive();
|
188
187
|
this.replaceContentWithEditor();
|
189
|
-
this.
|
188
|
+
this.setInitialValue();
|
189
|
+
this.workAroundMissingBlurBug();
|
190
|
+
this.connectClosingEventsToEditor();
|
190
191
|
this.triggerDelegateCall('didOpenEditInPlace');
|
191
192
|
},
|
192
193
|
|
@@ -239,20 +240,16 @@ $.extend(InlineEditor.prototype, {
|
|
239
240
|
this.dom.text(aValue);
|
240
241
|
},
|
241
242
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
//
|
247
|
-
|
248
|
-
// Firefox will forget to send a blur event to an input element when another one is
|
249
|
-
// created and selected programmatically. This means that if another inline editor is
|
250
|
-
// opened, existing inline editors will _not_ close if they are configured to submit when blurred.
|
251
|
-
// This is actually the first time I've written browser specific code for a browser different than IE! Wohoo!
|
243
|
+
workAroundMissingBlurBug: function() {
|
244
|
+
// Strangely, all browser will forget to send a blur event to an input element
|
245
|
+
// when another one is created and selected programmatically. (at least under some circumstances).
|
246
|
+
// This means that if another inline editor is opened, existing inline editors will _not_ close
|
247
|
+
// if they are configured to submit when blurred.
|
252
248
|
|
253
249
|
// Using parents() instead document as base to workaround the fact that in the unittests
|
254
250
|
// the editor is not a child of window.document but of a document fragment
|
255
|
-
this.dom.
|
251
|
+
var ourInput = this.dom.find(':input');
|
252
|
+
this.dom.parents(':last').find('.editInPlace-active :input').not(ourInput).blur();
|
256
253
|
},
|
257
254
|
|
258
255
|
replaceContentWithEditor: function() {
|
@@ -274,7 +271,7 @@ $.extend(InlineEditor.prototype, {
|
|
274
271
|
editor = this.createSelectEditor();
|
275
272
|
else if ("text" === this.settings.field_type)
|
276
273
|
editor = $('<input type="text" ' + this.inputNameAndClass()
|
277
|
-
+ ' size="' + this.settings.text_size
|
274
|
+
+ ' size="' + this.settings.text_size + '" />');
|
278
275
|
else if ("textarea" === this.settings.field_type)
|
279
276
|
editor = $('<textarea ' + this.inputNameAndClass()
|
280
277
|
+ ' rows="' + this.settings.textarea_rows + '" '
|
@@ -282,83 +279,93 @@ $.extend(InlineEditor.prototype, {
|
|
282
279
|
else if ("remote" === this.settings.field_type)
|
283
280
|
editor = this.createRemoteGeneratedEditor();
|
284
281
|
else if ("clone" === this.settings.field_type) {
|
285
|
-
|
286
|
-
|
282
|
+
editor = this.cloneEditor();
|
283
|
+
return editor;
|
287
284
|
}
|
288
|
-
editor.val(this.triggerDelegateCall('willOpenEditInPlace', this.originalValue));
|
289
285
|
return editor;
|
290
286
|
},
|
291
287
|
|
288
|
+
setInitialValue: function() {
|
289
|
+
if (this.settings.field_type == 'remote' || this.settings.field_type == 'clone') return; // remote and clone generated editor doesn't need initial value
|
290
|
+
var initialValue = this.triggerDelegateCall('willOpenEditInPlace', this.originalValue);
|
291
|
+
var editor = this.dom.find(':input');
|
292
|
+
editor.val(initialValue);
|
293
|
+
|
294
|
+
// Workaround for select fields which don't contain the original value.
|
295
|
+
// Somehow the browsers don't like to select the instructional choice (disabled) in that case
|
296
|
+
if (editor.val() !== initialValue)
|
297
|
+
editor.val(''); // selects instructional choice
|
298
|
+
},
|
299
|
+
|
292
300
|
createRemoteGeneratedEditor: function () {
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
301
|
+
this.dom.html(this.settings.loading_text);
|
302
|
+
return $($.ajax({
|
303
|
+
url: this.settings.editor_url,
|
304
|
+
async: false
|
305
|
+
}).responseText);
|
298
306
|
},
|
299
307
|
|
300
308
|
cloneEditor: function() {
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
},
|
344
|
-
|
345
|
-
setValue: function(editField, textValue) {
|
346
|
-
var function_name = 'setValueFor' + editField.get(0).nodeName.toLowerCase();
|
347
|
-
if (typeof(this[function_name]) == 'function') {
|
348
|
-
this[function_name](editField, textValue);
|
349
|
-
} else {
|
350
|
-
editField.val(textValue);
|
351
|
-
}
|
352
|
-
},
|
353
|
-
|
354
|
-
setValueForselect: function(editField, textValue) {
|
355
|
-
var option_value = editField.children("option:contains('" + textValue + "')").val();
|
356
|
-
|
357
|
-
if (typeof(option_value) !== 'undefined') {
|
358
|
-
editField.val(option_value);
|
359
|
-
}
|
360
|
-
},
|
309
|
+
var patternNodes = this.getPatternNodes(this.settings.clone_selector);
|
310
|
+
if (patternNodes.editNode == null) {
|
311
|
+
alert('did not find any matching node for ' + this.settings.clone_selector);
|
312
|
+
return;
|
313
|
+
}
|
314
|
+
|
315
|
+
var editorNode = patternNodes.editNode.clone();
|
316
|
+
var clonedNodes = null;
|
317
|
+
if (editorNode.data('id')) editorNode.attr('id', editorNode.data('id') + this.settings.clone_id_suffix);
|
318
|
+
editorNode.attr('name', 'inplace_value');
|
319
|
+
editorNode.addClass('editor_field');
|
320
|
+
this.setValue(editorNode, this.originalValue);
|
321
|
+
clonedNodes = editorNode;
|
322
|
+
|
323
|
+
if (patternNodes.additionalNodes) {
|
324
|
+
patternNodes.additionalNodes.each(function (index, node) {
|
325
|
+
var patternNode = $(node).clone();
|
326
|
+
if (patternNode.data('id')) {
|
327
|
+
patternNode.attr('id', patternNode.data('id') + this.settings.clone_id_suffix);
|
328
|
+
}
|
329
|
+
clonedNodes = clonedNodes.after(patternNode);
|
330
|
+
});
|
331
|
+
}
|
332
|
+
return clonedNodes;
|
333
|
+
},
|
334
|
+
|
335
|
+
getPatternNodes: function(clone_selector) {
|
336
|
+
var nodes = {editNode: null, additionalNodes: null};
|
337
|
+
var selectedNodes = $(clone_selector);
|
338
|
+
var firstNode = selectedNodes.first();
|
339
|
+
|
340
|
+
if (typeof(firstNode) !== 'undefined') {
|
341
|
+
// AS inplace_edit_control_container -> we have to select all child nodes
|
342
|
+
// Workaround for ie which does not support css > selector
|
343
|
+
if (firstNode.hasClass('as_inplace_pattern')) {
|
344
|
+
selectedNodes = firstNode.children();
|
345
|
+
}
|
346
|
+
nodes.editNode = selectedNodes.first();
|
347
|
+
nodes.additionalNodes = selectedNodes.slice(1);
|
348
|
+
}
|
349
|
+
return nodes;
|
350
|
+
},
|
361
351
|
|
352
|
+
setValue: function(editField, textValue) {
|
353
|
+
var function_name = 'setValueFor' + editField.get(0).nodeName.toLowerCase();
|
354
|
+
if (typeof(this[function_name]) == 'function') {
|
355
|
+
this[function_name](editField, textValue);
|
356
|
+
} else {
|
357
|
+
editField.val(textValue);
|
358
|
+
}
|
359
|
+
},
|
360
|
+
|
361
|
+
setValueForselect: function(editField, textValue) {
|
362
|
+
var option_value = editField.children("option:contains('" + textValue + "')").val();
|
363
|
+
|
364
|
+
if (typeof(option_value) !== 'undefined') {
|
365
|
+
editField.val(option_value);
|
366
|
+
}
|
367
|
+
},
|
368
|
+
|
362
369
|
inputNameAndClass: function() {
|
363
370
|
return ' name="inplace_value" class="inplace_field" ';
|
364
371
|
},
|
@@ -373,7 +380,6 @@ $.extend(InlineEditor.prototype, {
|
|
373
380
|
optionsArray = optionsArray.split(',');
|
374
381
|
|
375
382
|
for (var i=0; i<optionsArray.length; i++) {
|
376
|
-
|
377
383
|
var currentTextAndValue = optionsArray[i];
|
378
384
|
if ( ! $.isArray(currentTextAndValue))
|
379
385
|
currentTextAndValue = currentTextAndValue.split(':');
|
@@ -381,16 +387,14 @@ $.extend(InlineEditor.prototype, {
|
|
381
387
|
var value = trim(currentTextAndValue[1] || currentTextAndValue[0]);
|
382
388
|
var text = trim(currentTextAndValue[0]);
|
383
389
|
|
384
|
-
var
|
385
|
-
var option = $('<option ' + selected + ' ></option>').val(value).text(text);
|
390
|
+
var option = $('<option>').val(value).text(text);
|
386
391
|
editor.append(option);
|
387
392
|
}
|
393
|
+
|
388
394
|
return editor;
|
389
|
-
|
390
395
|
},
|
391
396
|
|
392
|
-
|
393
|
-
connectOpeningEventsToEditor: function() {
|
397
|
+
connectClosingEventsToEditor: function() {
|
394
398
|
var that = this;
|
395
399
|
function cancelEditorAction(anEvent) {
|
396
400
|
that.handleCancelEditor(anEvent);
|
@@ -415,9 +419,11 @@ $.extend(InlineEditor.prototype, {
|
|
415
419
|
else
|
416
420
|
form.find(".inplace_field").blur(cancelEditorAction);
|
417
421
|
|
418
|
-
// workaround for firefox bug where it won't submit on enter if no button is shown
|
419
|
-
|
422
|
+
// workaround for msie & firefox bug where it won't submit on enter if no button is shown
|
423
|
+
/* TODO find a way to restore it without $.browser if it doesn't work
|
424
|
+
if ($.browser.mozilla || $.browser.msie)
|
420
425
|
this.bindSubmitOnEnterInInput();
|
426
|
+
*/
|
421
427
|
}
|
422
428
|
|
423
429
|
form.keyup(function(anEvent) {
|
@@ -429,8 +435,10 @@ $.extend(InlineEditor.prototype, {
|
|
429
435
|
|
430
436
|
// workaround for webkit nightlies where they won't submit at all on enter
|
431
437
|
// REFACT: find a way to just target the nightlies
|
438
|
+
/* TODO find a way to restore it without $.browser if it doesn't work
|
432
439
|
if ($.browser.safari)
|
433
440
|
this.bindSubmitOnEnterInInput();
|
441
|
+
*/
|
434
442
|
|
435
443
|
|
436
444
|
form.submit(saveEditorAction);
|
@@ -446,7 +454,7 @@ $.extend(InlineEditor.prototype, {
|
|
446
454
|
if (enter === event.which)
|
447
455
|
return that.dom.find('form').submit();
|
448
456
|
});
|
449
|
-
|
457
|
+
|
450
458
|
},
|
451
459
|
|
452
460
|
handleCancelEditor: function(anEvent) {
|
@@ -460,9 +468,6 @@ $.extend(InlineEditor.prototype, {
|
|
460
468
|
enteredText = this.triggerDelegateCall('willCloseEditInPlace', enteredText);
|
461
469
|
|
462
470
|
this.restoreOriginalValue();
|
463
|
-
if (hasContent(enteredText)
|
464
|
-
&& ! this.isDisabledDefaultSelectChoice() && !editor.is('select'))
|
465
|
-
this.setClosedEditorContent(enteredText);
|
466
471
|
this.reinit();
|
467
472
|
},
|
468
473
|
|
@@ -470,15 +475,15 @@ $.extend(InlineEditor.prototype, {
|
|
470
475
|
if (false === this.triggerDelegateCall('shouldCloseEditInPlace', true, anEvent))
|
471
476
|
return;
|
472
477
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
478
|
+
var editor = this.dom.find('[name]:input:not(:button,[name=""])').not('input:checkbox:not(:checked)').not('input:radio:not(:checked)');
|
479
|
+
var enteredText = '';
|
480
|
+
if (editor.length > 1) {
|
481
|
+
enteredText = jQuery.map(editor, function(item, index) {
|
482
|
+
return $(item).val();
|
483
|
+
});
|
484
|
+
} else {
|
485
|
+
enteredText = editor.val();
|
486
|
+
}
|
482
487
|
enteredText = this.triggerDelegateCall('willCloseEditInPlace', enteredText);
|
483
488
|
|
484
489
|
if (this.isDisabledDefaultSelectChoice()
|
@@ -555,15 +560,15 @@ $.extend(InlineEditor.prototype, {
|
|
555
560
|
|
556
561
|
handleSubmitToServer: function(enteredText) {
|
557
562
|
var data = '';
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
563
|
+
if (typeof(enteredText) === 'string') {
|
564
|
+
data += this.settings.update_value + '=' + encodeURIComponent(enteredText) + '&';
|
565
|
+
} else {
|
566
|
+
for(var i = 0;i < enteredText.length; i++) {
|
567
|
+
data += this.settings.update_value + '[]=' + encodeURIComponent(enteredText[i]) + '&';
|
568
|
+
}
|
569
|
+
}
|
570
|
+
|
571
|
+
data += this.settings.element_id + '=' + this.dom.attr("id")
|
567
572
|
+ ((this.settings.params) ? '&' + this.settings.params : '')
|
568
573
|
+ '&' + this.settings.original_html + '=' + encodeURIComponent(this.originalValue) /* DEPRECATED in 2.2.0 */
|
569
574
|
+ '&' + this.settings.original_value + '=' + encodeURIComponent(this.originalValue);
|
@@ -576,19 +581,22 @@ $.extend(InlineEditor.prototype, {
|
|
576
581
|
type: "POST",
|
577
582
|
data: data,
|
578
583
|
dataType: that.settings.ajax_data_type,
|
584
|
+
beforeSend: function(request, settings) {
|
585
|
+
that.triggerCallback(that.settings.beforeSend, request, settings);
|
586
|
+
},
|
579
587
|
complete: function(request){
|
580
588
|
that.didEndSaving();
|
581
589
|
},
|
582
590
|
success: function(data){
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
591
|
+
if (that.settings.ajax_data_type == 'html') {
|
592
|
+
var new_text = data || that.settings.default_text;
|
593
|
+
|
594
|
+
/* put the newly updated info into the original element */
|
595
|
+
// FIXME: should be affected by the preferences switch
|
596
|
+
that.dom.html(new_text);
|
597
|
+
// REFACT: remove dom parameter, already in this, not documented, should be easy to remove
|
598
|
+
// REFACT: callback should be able to override what gets put into the DOM
|
599
|
+
}
|
592
600
|
that.triggerCallback(that.settings.success,data);
|
593
601
|
},
|
594
602
|
error: function(request) {
|
@@ -609,7 +617,7 @@ $.extend(InlineEditor.prototype, {
|
|
609
617
|
if ( ! aCallback)
|
610
618
|
return; // callback wasn't specified after all
|
611
619
|
|
612
|
-
var callbackArguments = Array.prototype.
|
620
|
+
var callbackArguments = Array.prototype.slice.call(arguments, 1);
|
613
621
|
return aCallback.apply(this.dom[0], callbackArguments);
|
614
622
|
},
|
615
623
|
|
@@ -620,7 +628,7 @@ $.extend(InlineEditor.prototype, {
|
|
620
628
|
|| ! $.isFunction(this.settings.delegate[aDelegateMethodName]))
|
621
629
|
return defaultReturnValue;
|
622
630
|
|
623
|
-
var delegateReturnValue =
|
631
|
+
var delegateReturnValue = this.settings.delegate[aDelegateMethodName](this.dom, this.settings, optionalEvent);
|
624
632
|
return (undefined === delegateReturnValue)
|
625
633
|
? defaultReturnValue
|
626
634
|
: delegateReturnValue;
|