Skip to content
Snippets Groups Projects
Select Git revision
  • 60d83c8e5081cb4f45ae279f8e2013ffaebbb243
  • main default protected
2 results

javascript-practice.code-workspace

Blame
  • Forked from SOFT Core / SOFT 260 / JavaScript Practice
    Source project has a limited visibility.
    batch.js 995 B
    // $Id: batch.js,v 1.10 2009/08/31 05:51:07 dries Exp $
    (function ($) {
    
    /**
     * Attaches the batch behavior to progress bars.
     */
    Drupal.behaviors.batch = {
      attach: function (context, settings) {
        $('#progress', context).once('batch', function () {
          var holder = $(this);
    
          // Success: redirect to the summary.
          var updateCallback = function (progress, status, pb) {
            if (progress == 100) {
              pb.stopMonitoring();
              window.location = settings.batch.uri + '&op=finished';
            }
          };
    
          var errorCallback = function (pb) {
            holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage));
            $('#wait').hide();
          };
    
          var progress = new Drupal.progressBar('updateprogress', updateCallback, 'POST', errorCallback);
          progress.setProgress(-1, settings.batch.initMessage);
          holder.append(progress.element);
          progress.startMonitoring(settings.batch.uri + '&op=do', 10);
        });
      }
    };
    
    })(jQuery);