cleanup data_as_a_function code

This commit is contained in:
Adam Shaw
2013-07-29 23:13:28 -07:00
parent c93f64fc8b
commit 1c802475ea
+15 -5
View File
@@ -136,13 +136,22 @@ function EventManager(options, _sources) {
var success = source.success;
var error = source.error;
var complete = source.complete;
var custom_data;
// retrieve any outbound GET/POST $.ajax data from the options
var customData;
if ($.isFunction(source.data)) {
custom_data = source.data();
} else {
custom_data = source.data;
// supplied as a function that returns a key/value object
customData = source.data();
}
var data = $.extend({}, custom_data || {});
else {
// supplied as a straight key/value object
customData = source.data;
}
// use a copy of the custom data so we can modify the parameters
// and not affect the passed-in object.
var data = $.extend({}, customData || {});
var startParam = firstDefined(source.startParam, options.startParam);
var endParam = firstDefined(source.endParam, options.endParam);
if (startParam) {
@@ -151,6 +160,7 @@ function EventManager(options, _sources) {
if (endParam) {
data[endParam] = Math.round(+rangeEnd / 1000);
}
pushLoading();
$.ajax($.extend({}, ajaxDefaults, source, {
data: data,