batch.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function ($, Drupal) {
  8. Drupal.behaviors.batch = {
  9. attach: function attach(context, settings) {
  10. var batch = settings.batch;
  11. var $progress = $('[data-drupal-progress]').once('batch');
  12. var progressBar = void 0;
  13. function updateCallback(progress, status, pb) {
  14. if (progress === '100') {
  15. pb.stopMonitoring();
  16. window.location = batch.uri + '&op=finished';
  17. }
  18. }
  19. function errorCallback(pb) {
  20. $progress.prepend($('<p class="error"></p>').html(batch.errorMessage));
  21. $('#wait').hide();
  22. }
  23. if ($progress.length) {
  24. progressBar = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback);
  25. progressBar.setProgress(-1, batch.initMessage);
  26. progressBar.startMonitoring(batch.uri + '&op=do', 10);
  27. $progress.empty();
  28. $progress.append(progressBar.element);
  29. }
  30. }
  31. };
  32. })(jQuery, Drupal);