Initial code using Drupal 6.38
This commit is contained in:
commit
4824608a33
467 changed files with 90887 additions and 0 deletions
37
misc/batch.js
Normal file
37
misc/batch.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/**
|
||||
* Attaches the batch behavior to progress bars.
|
||||
*/
|
||||
Drupal.behaviors.batch = function (context) {
|
||||
// This behavior attaches by ID, so is only valid once on a page.
|
||||
if ($('#progress.batch-processed').size()) {
|
||||
return;
|
||||
}
|
||||
$('#progress', context).addClass('batch-processed').each(function () {
|
||||
var holder = this;
|
||||
var uri = Drupal.settings.batch.uri;
|
||||
var initMessage = Drupal.settings.batch.initMessage;
|
||||
var errorMessage = Drupal.settings.batch.errorMessage;
|
||||
|
||||
// Success: redirect to the summary.
|
||||
var updateCallback = function (progress, status, pb) {
|
||||
if (progress == 100) {
|
||||
pb.stopMonitoring();
|
||||
window.location = uri+'&op=finished';
|
||||
}
|
||||
};
|
||||
|
||||
var errorCallback = function (pb) {
|
||||
var div = document.createElement('p');
|
||||
div.className = 'error';
|
||||
$(div).html(errorMessage);
|
||||
$(holder).prepend(div);
|
||||
$('#wait').hide();
|
||||
};
|
||||
|
||||
var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
|
||||
progress.setProgress(-1, initMessage);
|
||||
$(holder).append(progress.element);
|
||||
progress.startMonitoring(uri+'&op=do', 10);
|
||||
});
|
||||
};
|
Reference in a new issue