Commit e6cfbba9 authored by webchick's avatar webchick

Issue #1574490 by frega, nod_: Clean-up: batch.js.

parent be8126ff
(function ($) {
(function ($, Drupal) {
"use strict";
......@@ -7,31 +7,33 @@
*/
Drupal.behaviors.batch = {
attach: function (context, settings) {
$(context).find('#progress').once('batch', function () {
var holder = $(this);
// Remove HTML from no-js progress bar. The JS progress bar is created
// later on.
holder.empty();
var batch = settings.batch;
var $progress = $('#progress').once('batch');
var progressBar;
// Success: redirect to the summary.
var updateCallback = function (progress, status, pb) {
if (progress === '100') {
pb.stopMonitoring();
window.location = settings.batch.uri + '&op=finished';
}
};
// Success: redirect to the summary.
function updateCallback(progress, status, pb) {
if (progress === '100') {
pb.stopMonitoring();
window.location = batch.uri + '&op=finished';
}
}
var errorCallback = function (pb) {
holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage));
$('#wait').hide();
};
function errorCallback(pb) {
$progress.prepend($('<p class="error"></p>').html(batch.errorMessage));
$('#wait').hide();
}
var progress = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback);
progress.setProgress(-1, settings.batch.initMessage);
holder.append(progress.element);
progress.startMonitoring(settings.batch.uri + '&op=do', 10);
});
if ($progress.length) {
progressBar = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback);
progressBar.setProgress(-1, batch.initMessage);
progressBar.startMonitoring(batch.uri + '&op=do', 10);
// Remove HTML from no-js progress bar.
$progress.empty();
// Append the JS progressbar element.
$progress.append(progressBar.element);
}
}
};
})(jQuery);
})(jQuery, Drupal);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment