/**
* @file
* Extends methods from core/misc/progress.js.
*/
(function ($, Drupal) {
'use strict';
/**
* Theme function for the progress bar.
*
* @param {string} id
*
* @return {string}
* The HTML for the progress bar.
*/
Drupal.theme.progressBar = function (id) {
return '
' +
''+
'
' +
'
' +
'' +
'
' +
'
' +
'' +
'
';
};
$.extend(Drupal.ProgressBar.prototype, /** @lends Drupal.ProgressBar */{
/**
* Set the percentage and status message for the progressbar.
*
* @param {number} percentage
* @param {string} message
* @param {string} label
*/
setProgress: function (percentage, message, label) {
if (percentage >= 0 && percentage <= 100) {
$(this.element).find('.progress-bar').css('width', percentage + '%').attr('aria-valuenow', percentage);
$(this.element).find('.percentage').html(percentage + '%');
}
if (message) {
// Remove the unnecessary whitespace at the end of the message.
message = message.replace(/ |\s*$/, '');
$('.message', this.element).html(message);
}
if (label) {
$('.progress-label', this.element).html(label);
}
if (this.updateCallback) {
this.updateCallback(percentage, message, this);
}
},
/**
* Display errors on the page.
*
* @param {string} string
*/
displayError: function (string) {
var error = $('