equal
deleted
inserted
replaced
|
1 (function ($) { |
|
2 |
|
3 /** |
|
4 * Attaches the batch behavior to progress bars. |
|
5 */ |
|
6 Drupal.behaviors.batch = { |
|
7 attach: function (context, settings) { |
|
8 $('#progress', context).once('batch', function () { |
|
9 var holder = $(this); |
|
10 |
|
11 // Success: redirect to the summary. |
|
12 var updateCallback = function (progress, status, pb) { |
|
13 if (progress == 100) { |
|
14 pb.stopMonitoring(); |
|
15 window.location = settings.batch.uri + '&op=finished'; |
|
16 } |
|
17 }; |
|
18 |
|
19 var errorCallback = function (pb) { |
|
20 holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage)); |
|
21 $('#wait').hide(); |
|
22 }; |
|
23 |
|
24 var progress = new Drupal.progressBar('updateprogress', updateCallback, 'POST', errorCallback); |
|
25 progress.setProgress(-1, settings.batch.initMessage); |
|
26 holder.append(progress.element); |
|
27 progress.startMonitoring(settings.batch.uri + '&op=do', 10); |
|
28 }); |
|
29 } |
|
30 }; |
|
31 |
|
32 })(jQuery); |