diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-10-29 10:01:28 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-10-29 10:01:28 +0000 |
commit | 5371104a2d10889c532bb5d345fa6d71c0a897d1 (patch) | |
tree | bbef382cea55823195e0cb7469074b743913bc74 /misc/batch.js | |
parent | 068febde425f4521d61f863ffaca76da65916449 (diff) | |
download | brdo-5371104a2d10889c532bb5d345fa6d71c0a897d1.tar.gz brdo-5371104a2d10889c532bb5d345fa6d71c0a897d1.tar.bz2 |
- Patch #316225 by sun et al: allow behaviors to detach from AHAH/AJAX.
Diffstat (limited to 'misc/batch.js')
-rw-r--r-- | misc/batch.js | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/misc/batch.js b/misc/batch.js index 5a5587ad8..4d1a4d551 100644 --- a/misc/batch.js +++ b/misc/batch.js @@ -3,36 +3,38 @@ /** * 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; +Drupal.behaviors.batch = { + attach: 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'; - } - }; + // 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 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); - }); + var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback); + progress.setProgress(-1, initMessage); + $(holder).append(progress.element); + progress.startMonitoring(uri+'&op=do', 10); + }); + } }; |