/[drupal]/drupal/misc/batch.js
ViewVC logotype

Contents of /drupal/misc/batch.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download) (as text)
Mon Aug 31 05:51:07 2009 UTC (2 months, 3 weeks ago) by dries
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, DRUPAL-7-0-UNSTABLE-9, HEAD
Changes since 1.9: +2 -6 lines
File MIME type: text/javascript
- Patch #444344 by kkaefer, sun, Rob Loach: this change introduces a jQuery .once() method which streamlines the way behavior functions work. Previously, we had to manually ensure that an element is only initialized once. Usually, this happens by adding classes and selecting only those elements which do not have that class. However, this process can be separated out into a jQuery ‘filtering’ function which does all the grunt work.
1 // $Id: batch.js,v 1.9 2009/04/27 20:19:35 webchick Exp $
2 (function ($) {
3
4 /**
5 * Attaches the batch behavior to progress bars.
6 */
7 Drupal.behaviors.batch = {
8 attach: function (context, settings) {
9 $('#progress', context).once('batch', function () {
10 var holder = $(this);
11
12 // Success: redirect to the summary.
13 var updateCallback = function (progress, status, pb) {
14 if (progress == 100) {
15 pb.stopMonitoring();
16 window.location = settings.batch.uri + '&op=finished';
17 }
18 };
19
20 var errorCallback = function (pb) {
21 holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage));
22 $('#wait').hide();
23 };
24
25 var progress = new Drupal.progressBar('updateprogress', updateCallback, 'POST', errorCallback);
26 progress.setProgress(-1, settings.batch.initMessage);
27 holder.append(progress.element);
28 progress.startMonitoring(settings.batch.uri + '&op=do', 10);
29 });
30 }
31 };
32
33 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2