From c740ac7fd58b5f4597bde987ae9263f3d05febd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Fri, 4 May 2007 09:41:37 +0000 Subject: #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. --- misc/batch.js | 31 +++++++++++++++++++++++++++++++ misc/drupal.js | 3 +++ misc/progress.js | 6 +++--- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 misc/batch.js (limited to 'misc') 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 element if (Drupal.jsEnabled) { + // Global Killswitch on the 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('
'+ - '
 
'+ - '
'); + $(this.element).html('
'+ + '
'+ + '
 
'); } /** -- cgit v1.2.3