From bda52632a5aa033d44151c224a39236b223c6b0e Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sun, 26 Apr 2009 19:18:46 +0000 Subject: #444402 by kkaefer and RobLoach: Enforce coding standards on all core JavaScript. --- misc/progress.js | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'misc/progress.js') diff --git a/misc/progress.js b/misc/progress.js index b0fad15733d6..265c538f7209 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('
'+ - '
'+ - '
 
'); + this.element = $('
').attr('id', id); + this.element.html('
' + + '
' + + '
 
'); }; /** * 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 = $('
').html(string); $(this.element).before(error).hide(); if (this.errorCallback) { -- cgit v1.2.3