3 * Extends methods from core/misc/progress.js.
6 (function ($, Drupal) {
11 * Theme function for the progress bar.
16 * The HTML for the progress bar.
18 Drupal.theme.progressBar = function (id) {
19 return '<div class="progress-wrapper" aria-live="polite">' +
20 '<div class="message"></div>'+
21 '<div id ="' + id + '" class="progress progress-striped active">' +
22 '<div class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">' +
23 '<span class="percentage"></span>' +
26 '<div class="progress-label"></div>' +
30 $.extend(Drupal.ProgressBar.prototype, /** @lends Drupal.ProgressBar */{
33 * Set the percentage and status message for the progressbar.
35 * @param {number} percentage
36 * @param {string} message
37 * @param {string} label
39 setProgress: function (percentage, message, label) {
40 if (percentage >= 0 && percentage <= 100) {
41 $(this.element).find('.progress-bar').css('width', percentage + '%').attr('aria-valuenow', percentage);
42 $(this.element).find('.percentage').html(percentage + '%');
45 // Remove the unnecessary whitespace at the end of the message.
46 message = message.replace(/<br\/> |\s*$/, '');
48 $('.message', this.element).html(message);
51 $('.progress-label', this.element).html(label);
53 if (this.updateCallback) {
54 this.updateCallback(percentage, message, this);
59 * Display errors on the page.
61 * @param {string} string
63 displayError: function (string) {
64 var error = $('<div class="alert alert-block alert-error"><a class="close" data-dismiss="alert" href="#">×</a><h4>' + Drupal.t('Error message') + '</h4></div>').append(string);
65 $(this.element).before(error).hide();
67 if (this.errorCallback) {
68 this.errorCallback(this);