From 0abd1bb287372f6d38cf48e26cc60d0702898cd7 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 16 Apr 2015 15:48:54 +0200 Subject: [PATCH] Issue #2452381 by lanchez, googletorp, PieterJanPut: Use Drupal.theme for progress.js --- core/misc/progress.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/core/misc/progress.js b/core/misc/progress.js index 52127e6807c1..d2d7c29a7c43 100644 --- a/core/misc/progress.js +++ b/core/misc/progress.js @@ -1,7 +1,22 @@ -(function ($) { +(function ($, Drupal) { "use strict"; + /** + * Theme function for the progress bar. + * + * @return + * The HTML for the progress bar. + */ + Drupal.theme.progressBar = function (id) { + return '<div id="' + id + '" class="progress" aria-live="polite">' + + '<div class="progress__label"> </div>' + + '<div class="progress__track"><div class="progress__bar"></div></div>' + + '<div class="progress__percentage"></div>' + + '<div class="progress__description"> </div>' + + '</div>'; + }; + /** * A progressbar object. Initialized with the given id. Must be inserted into * the DOM afterwards through progressBar.element. @@ -20,11 +35,7 @@ // 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 = $('<div class="progress" aria-live="polite"></div>').attr('id', id); - this.element.html('<div class="progress__label"> </div>' + - '<div class="progress__track"><div class="progress__bar"></div></div>' + - '<div class="progress__percentage"></div>' + - '<div class="progress__description"> </div>'); + this.element = $(Drupal.theme(id)); }; $.extend(Drupal.ProgressBar.prototype, { @@ -109,4 +120,4 @@ } }); -})(jQuery); +})(jQuery, Drupal); -- GitLab