diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-26 19:18:46 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-26 19:18:46 +0000 |
commit | bda52632a5aa033d44151c224a39236b223c6b0e (patch) | |
tree | da56b8095f58963707655312071d41de95adca84 /misc/progress.js | |
parent | a4dc8467bbe69ba984be31309f536af74dc64e73 (diff) | |
download | drupal-bda52632a5aa033d44151c224a39236b223c6b0e.tar.gz drupal-bda52632a5aa033d44151c224a39236b223c6b0e.zip |
#444402 by kkaefer and RobLoach: Enforce coding standards on all core JavaScript.
Diffstat (limited to 'misc/progress.js')
-rw-r--r-- | misc/progress.js | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/misc/progress.js b/misc/progress.js index b0fad15733d..265c538f720 100644 --- a/misc/progress.js +++ b/misc/progress.js @@ -11,28 +11,26 @@ * e.g. pb = new progressBar('myProgressBar'); * some_element.appendChild(pb.element); */ -Drupal.progressBar = function (id, updateCallback, method, errorCallback) { +Drupal.progressBar = function(id, updateCallback, method, errorCallback) { var pb = this; this.id = id; - this.method = method || "GET"; + this.method = method || 'GET'; this.updateCallback = updateCallback; this.errorCallback = errorCallback; - this.element = document.createElement('div'); - this.element.id = id; - this.element.className = 'progress'; - $(this.element).html('<div class="bar"><div class="filled"></div></div>'+ - '<div class="percentage"></div>'+ - '<div class="message"> </div>'); + this.element = $('<div class="progress"></div>').attr('id', id); + this.element.html('<div class="bar"><div class="filled"></div></div>' + + '<div class="percentage"></div>' + + '<div class="message"> </div>'); }; /** * Set the percentage and status message for the progressbar. */ -Drupal.progressBar.prototype.setProgress = function (percentage, message) { +Drupal.progressBar.prototype.setProgress = function(percentage, message) { if (percentage >= 0 && percentage <= 100) { - $('div.filled', this.element).css('width', percentage +'%'); - $('div.percentage', this.element).html(percentage +'%'); + $('div.filled', this.element).css('width', percentage + '%'); + $('div.percentage', this.element).html(percentage + '%'); } $('div.message', this.element).html(message); if (this.updateCallback) { @@ -43,7 +41,7 @@ Drupal.progressBar.prototype.setProgress = function (percentage, message) { /** * Start monitoring progress via Ajax. */ -Drupal.progressBar.prototype.startMonitoring = function (uri, delay) { +Drupal.progressBar.prototype.startMonitoring = function(uri, delay) { this.delay = delay; this.uri = uri; this.sendPing(); @@ -52,7 +50,7 @@ Drupal.progressBar.prototype.startMonitoring = function (uri, delay) { /** * Stop monitoring progress via Ajax. */ -Drupal.progressBar.prototype.stopMonitoring = function () { +Drupal.progressBar.prototype.stopMonitoring = function() { clearTimeout(this.timer); // This allows monitoring to be stopped from within the callback. this.uri = null; @@ -61,7 +59,7 @@ Drupal.progressBar.prototype.stopMonitoring = function () { /** * Request progress data from server. */ -Drupal.progressBar.prototype.sendPing = function () { +Drupal.progressBar.prototype.sendPing = function() { if (this.timer) { clearTimeout(this.timer); } @@ -74,7 +72,7 @@ Drupal.progressBar.prototype.sendPing = function () { url: this.uri, data: '', dataType: 'json', - success: function (progress) { + success: function(progress) { // Display errors. if (progress.status == 0) { pb.displayError(progress.data); @@ -85,7 +83,7 @@ Drupal.progressBar.prototype.sendPing = function () { // Schedule next timer. pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay); }, - error: function (xmlhttp) { + error: function(xmlhttp) { pb.displayError(Drupal.ahahError(xmlhttp, pb.uri)); } }); @@ -95,11 +93,8 @@ Drupal.progressBar.prototype.sendPing = function () { /** * Display errors on the page. */ -Drupal.progressBar.prototype.displayError = function (string) { - var error = document.createElement('div'); - error.className = 'error'; - error.innerHTML = string; - +Drupal.progressBar.prototype.displayError = function(string) { + var error = $('<div class="error"></div>').html(string); $(this.element).before(error).hide(); if (this.errorCallback) { |