diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-05-04 09:41:37 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-05-04 09:41:37 +0000 |
commit | c740ac7fd58b5f4597bde987ae9263f3d05febd8 (patch) | |
tree | 0eb9221dd27cfa6d308e99babc41b1f9fd474c7b /misc | |
parent | 304400293a997a76290f04c7d1d65680fef2c7d8 (diff) | |
download | brdo-c740ac7fd58b5f4597bde987ae9263f3d05febd8.tar.gz brdo-c740ac7fd58b5f4597bde987ae9263f3d05febd8.tar.bz2 |
#127539: progressive operation support, refactoring update.php code to a generic batch API to support runnning operations in multiple HTTP requests
- update.php is already on the batch API
- node access rebuilding is in the works
- automatic locale importing is in the works
Thanks to Yves Chedemois (yched) for the good code quality, very wide awareness of issues related to batches,
and the fantastic turnaround times. Hats off.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/batch.js | 31 | ||||
-rw-r--r-- | misc/drupal.js | 3 | ||||
-rw-r--r-- | misc/progress.js | 6 |
3 files changed, 37 insertions, 3 deletions
diff --git a/misc/batch.js b/misc/batch.js new file mode 100644 index 000000000..43117e243 --- /dev/null +++ b/misc/batch.js @@ -0,0 +1,31 @@ +if (Drupal.jsEnabled) { + $(document).ready(function() { + $('#progress').each(function () { + var holder = this; + var uri = Drupal.settings.batch.uri; + var initMessage = Drupal.settings.batch.initMessage; + var errorMessage = Drupal.settings.batch.errorMessage; + + // Success: redirect to the summary. + var updateCallback = function (progress, status, pb) { + if (progress == 100) { + pb.stopMonitoring(); + window.location = uri+'&op=finished'; + } + } + + var errorCallback = function (pb) { + var div = document.createElement('p'); + div.className = 'error'; + $(div).html(errorMessage); + $(holder).prepend(div); + $('#wait').hide(); + } + + var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback); + progress.setProgress(-1, initMessage); + $(holder).append(progress.element); + progress.startMonitoring(uri+'&op=do', 10); + }); + }); +} diff --git a/misc/drupal.js b/misc/drupal.js index 04176089d..c4fa5d8ab 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -222,5 +222,8 @@ Drupal.getSelection = function (element) { // Global Killswitch on the <html> element if (Drupal.jsEnabled) { + // Global Killswitch on the <html> element document.documentElement.className = 'js'; + // 'js enabled' cookie + document.cookie = 'has_js=1'; } diff --git a/misc/progress.js b/misc/progress.js index 3db804f2f..cf5c12017 100644 --- a/misc/progress.js +++ b/misc/progress.js @@ -20,9 +20,9 @@ Drupal.progressBar = function (id, updateCallback, method, errorCallback) { this.element = document.createElement('div'); this.element.id = id; this.element.className = 'progress'; - $(this.element).html('<div class="percentage"></div>'+ - '<div class="message"> </div>'+ - '<div class="bar"><div class="filled"></div></div>'); + $(this.element).html('<div class="bar"><div class="filled"></div></div>'+ + '<div class="percentage"></div>'+ + '<div class="message"> </div>'); } /** |