X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmisc%2Fprogress.js;fp=web%2Fcore%2Fmisc%2Fprogress.js;h=82280aac4edd32d3ea4d51b48493425a79326270;hp=a6694892b27023ea3abe56fe53c573c70c23d27a;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5
diff --git a/web/core/misc/progress.js b/web/core/misc/progress.js
index a6694892b..82280aac4 100644
--- a/web/core/misc/progress.js
+++ b/web/core/misc/progress.js
@@ -1,78 +1,26 @@
/**
- * @file
- * Progress bar.
- */
+* DO NOT EDIT THIS FILE.
+* See the following change record for more information,
+* https://www.drupal.org/node/2815083
+* @preserve
+**/
(function ($, Drupal) {
-
- 'use strict';
-
- /**
- * Theme function for the progress bar.
- *
- * @param {string} id
- * The id for the progress bar.
- *
- * @return {string}
- * The HTML for the progress bar.
- */
Drupal.theme.progressBar = function (id) {
- return '
' +
- '
' +
- '
' +
- '
' +
- '
' +
- '
';
+ return '' + '
' + '
' + '
' + '
' + '
';
};
- /**
- * A progressbar object. Initialized with the given id. Must be inserted into
- * the DOM afterwards through progressBar.element.
- *
- * Method is the function which will perform the HTTP request to get the
- * progress bar state. Either "GET" or "POST".
- *
- * @example
- * pb = new Drupal.ProgressBar('myProgressBar');
- * some_element.appendChild(pb.element);
- *
- * @constructor
- *
- * @param {string} id
- * The id for the progressbar.
- * @param {function} updateCallback
- * Callback to run on update.
- * @param {string} method
- * HTTP method to use.
- * @param {function} errorCallback
- * Callback to call on error.
- */
Drupal.ProgressBar = function (id, updateCallback, method, errorCallback) {
this.id = id;
this.method = method || 'GET';
this.updateCallback = updateCallback;
this.errorCallback = errorCallback;
- // The WAI-ARIA setting aria-live="polite" will announce changes after
- // users
- // have completed their current activity and not interrupt the screen
- // reader.
this.element = $(Drupal.theme('progressBar', id));
};
- $.extend(Drupal.ProgressBar.prototype, /** @lends Drupal.ProgressBar# */{
-
- /**
- * Set the percentage and status message for the progressbar.
- *
- * @param {number} percentage
- * The progress percentage.
- * @param {string} message
- * The message to show the user.
- * @param {string} label
- * The text for the progressbar label.
- */
- setProgress: function (percentage, message, label) {
+ $.extend(Drupal.ProgressBar.prototype, {
+ setProgress: function setProgress(percentage, message, label) {
if (percentage >= 0 && percentage <= 100) {
$(this.element).find('div.progress__bar').css('width', percentage + '%');
$(this.element).find('div.progress__percentage').html(percentage + '%');
@@ -83,46 +31,27 @@
this.updateCallback(percentage, message, this);
}
},
-
- /**
- * Start monitoring progress via Ajax.
- *
- * @param {string} uri
- * The URI to use for monitoring.
- * @param {number} delay
- * The delay for calling the monitoring URI.
- */
- startMonitoring: function (uri, delay) {
+ startMonitoring: function startMonitoring(uri, delay) {
this.delay = delay;
this.uri = uri;
this.sendPing();
},
-
- /**
- * Stop monitoring progress via Ajax.
- */
- stopMonitoring: function () {
+ stopMonitoring: function stopMonitoring() {
clearTimeout(this.timer);
- // This allows monitoring to be stopped from within the callback.
+
this.uri = null;
},
-
- /**
- * Request progress data from server.
- */
- sendPing: function () {
+ sendPing: function sendPing() {
if (this.timer) {
clearTimeout(this.timer);
}
if (this.uri) {
var pb = this;
- // When doing a post request, you need non-null data. Otherwise a
- // HTTP 411 or HTTP 406 (with Apache mod_security) error may result.
+
var uri = this.uri;
if (uri.indexOf('?') === -1) {
uri += '?';
- }
- else {
+ } else {
uri += '&';
}
uri += '_format=json';
@@ -131,32 +60,26 @@
url: uri,
data: '',
dataType: 'json',
- success: function (progress) {
- // Display errors.
+ success: function success(progress) {
if (progress.status === 0) {
pb.displayError(progress.data);
return;
}
- // Update display.
+
pb.setProgress(progress.percentage, progress.message, progress.label);
- // Schedule next timer.
- pb.timer = setTimeout(function () { pb.sendPing(); }, pb.delay);
+
+ pb.timer = setTimeout(function () {
+ pb.sendPing();
+ }, pb.delay);
},
- error: function (xmlhttp) {
+ error: function error(xmlhttp) {
var e = new Drupal.AjaxError(xmlhttp, pb.uri);
pb.displayError('' + e.message + '
');
}
});
}
},
-
- /**
- * Display errors on the page.
- *
- * @param {string} string
- * The error message to show the user.
- */
- displayError: function (string) {
+ displayError: function displayError(string) {
var error = $('').html(string);
$(this.element).before(error).hide();
@@ -165,5 +88,4 @@
}
}
});
-
-})(jQuery, Drupal);
+})(jQuery, Drupal);
\ No newline at end of file