[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/misc/ -> batch.js (source)

   1  
   2  /**
   3   * Attaches the batch behavior to progress bars.
   4   */
   5  Drupal.behaviors.batch = function (context) {
   6    // This behavior attaches by ID, so is only valid once on a page.
   7    if ($('#progress.batch-processed').size()) {
   8      return;
   9    }
  10    $('#progress', context).addClass('batch-processed').each(function () {
  11      var holder = this;
  12      var uri = Drupal.settings.batch.uri;
  13      var initMessage = Drupal.settings.batch.initMessage;
  14      var errorMessage = Drupal.settings.batch.errorMessage;
  15  
  16      // Success: redirect to the summary.
  17      var updateCallback = function (progress, status, pb) {
  18        if (progress == 100) {
  19          pb.stopMonitoring();
  20          window.location = uri+'&op=finished';
  21        }
  22      };
  23  
  24      var errorCallback = function (pb) {
  25        var div = document.createElement('p');
  26        div.className = 'error';
  27        $(div).html(errorMessage);
  28        $(holder).prepend(div);
  29        $('#wait').hide();
  30      };
  31  
  32      var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback);
  33      progress.setProgress(-1, initMessage);
  34      $(holder).append(progress.element);
  35      progress.startMonitoring(uri+'&op=do', 10);
  36    });
  37  };


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7