'));
// Disable the button.
submitButton.addClass('button-disabled');
// Add the spinner.
submitButton.parent().append('
');
// Start the process.
batch.process_step(1, data);
}
})
.on('submit', '.pum-batch-form.pum-upgrade-form[data-upgrade_id]', function (event) {
var $form = $(this),
data = {
upgrade_id: $form.data('upgrade_id'),
nonce: $form.data('nonce'),
form: $form.serializeAssoc(),
test: $form.pumSerializeObject()
};
event.preventDefault();
// Process presubmit actions like showing progress data and validating info.
if (batch_upgrades.form.beforeSubmit($form)) {
// Start the process.
batch_upgrades.process_step($form.data('step') || 1, data);
}
});
}(jQuery));
// Initiate when ready.
jQuery(function ($) {
$.extend({
arrayMerge: function () {
var a = {};
var n = 0;
var argv = $.arrayMerge.arguments;
for (var i = 0; i < argv.length; i++) {
if (Array.isArray(argv[i])) {
for (var j = 0; j < argv[i].length; j++) {
a[n++] = argv[i][j];
}
a = $.makeArray(a);
} else {
for (var k in argv[i]) {
if (argv[i].hasOwnProperty(k)) {
if (isNaN(k)) {
var v = argv[i][k];
if (typeof v === 'object' && a[k]) {
v = $.arrayMerge(a[k], v);
}
a[k] = v;
} else {
a[n++] = argv[i][k];
}
}
}
}
}
return a;
},
count: function (arr) {
return Array.isArray(arr) ? arr.length : typeof arr === 'object' ? Object.keys(arr).length : false;
}
});
$.fn.extend({
serializeAssoc: function () {
var o = {
aa: {},
add: function (name, value) {
var tmp = name.match(/^(.*)\[([^\]]*)]$/),
v = {};
if (tmp) {
if (tmp[2])
v[tmp[2]] = value;
else
v[$.count(v)] = value;
this.add(tmp[1], v);
} else if (typeof value === 'object') {
if (typeof this.aa[name] !== 'object') {
this.aa[name] = {};
}
this.aa[name] = $.arrayMerge(this.aa[name], value);
} else {
this.aa[name] = value;
}
}
};
var a = $(this).serializeArray();
for (var i = 0; i < a.length; i++) {
o.add(a[i].name, a[i].value);
}
return o.aa;
}
});
});