diff options
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>'); } /** |