Mercurial > hg > isophonics-drupal-site
annotate core/misc/batch.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * DO NOT EDIT THIS FILE. |
Chris@0 | 3 * See the following change record for more information, |
Chris@0 | 4 * https://www.drupal.org/node/2815083 |
Chris@0 | 5 * @preserve |
Chris@0 | 6 **/ |
Chris@0 | 7 |
Chris@0 | 8 (function ($, Drupal) { |
Chris@0 | 9 Drupal.behaviors.batch = { |
Chris@0 | 10 attach: function attach(context, settings) { |
Chris@0 | 11 var batch = settings.batch; |
Chris@0 | 12 var $progress = $('[data-drupal-progress]').once('batch'); |
Chris@0 | 13 var progressBar = void 0; |
Chris@0 | 14 |
Chris@0 | 15 function updateCallback(progress, status, pb) { |
Chris@0 | 16 if (progress === '100') { |
Chris@0 | 17 pb.stopMonitoring(); |
Chris@0 | 18 window.location = batch.uri + '&op=finished'; |
Chris@0 | 19 } |
Chris@0 | 20 } |
Chris@0 | 21 |
Chris@0 | 22 function errorCallback(pb) { |
Chris@0 | 23 $progress.prepend($('<p class="error"></p>').html(batch.errorMessage)); |
Chris@0 | 24 $('#wait').hide(); |
Chris@0 | 25 } |
Chris@0 | 26 |
Chris@0 | 27 if ($progress.length) { |
Chris@0 | 28 progressBar = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback); |
Chris@0 | 29 progressBar.setProgress(-1, batch.initMessage); |
Chris@0 | 30 progressBar.startMonitoring(batch.uri + '&op=do', 10); |
Chris@0 | 31 |
Chris@0 | 32 $progress.empty(); |
Chris@0 | 33 |
Chris@0 | 34 $progress.append(progressBar.element); |
Chris@0 | 35 } |
Chris@0 | 36 } |
Chris@0 | 37 }; |
Chris@0 | 38 })(jQuery, Drupal); |