diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 9b89250..65b1ce4 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1780,7 +1780,7 @@ function drupal_common_theme() { 'variables' => array('url' => NULL, 'title' => NULL), ), 'progress_bar' => array( - 'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL), + 'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL, 'animate' => TRUE), ), 'indentation' => array( 'variables' => array('size' => 1), @@ -1863,3 +1863,14 @@ function drupal_common_theme() { ), ); } + +/** + * Implements hook_preprocess_HOOK(). + * + * Allow ajax version of progress to be animated. + * + * @see progress.js + */ +function template_preprocess_progress_bar(&$variables) { + $variables['#attached']['drupalSettings']['progressBarAnimate'] = $variables['animate']; +} diff --git a/core/misc/progress.js b/core/misc/progress.js index a669489..8f232d1 100644 --- a/core/misc/progress.js +++ b/core/misc/progress.js @@ -58,6 +58,11 @@ // have completed their current activity and not interrupt the screen // reader. this.element = $(Drupal.theme('progressBar', id)); + + // Implement optional animation of progress bar. + if (drupalSettings.progressBarAnimate) { + $(this.element).find('progress__bar').addClass('progress__bar--animate'); + } }; $.extend(Drupal.ProgressBar.prototype, /** @lends Drupal.ProgressBar# */{ diff --git a/core/modules/system/templates/progress-bar.html.twig b/core/modules/system/templates/progress-bar.html.twig index 885a80f..93852df 100644 --- a/core/modules/system/templates/progress-bar.html.twig +++ b/core/modules/system/templates/progress-bar.html.twig @@ -9,6 +9,10 @@ * - label: The label of the working task. * - percent: The percentage of the progress. * - message: A string containing information to be displayed. + * - animate: If set, enable the progress bar animation. + * + * @see template_preprocess_progress_bar() + * @see progress.js * * @ingroup themeable */ @@ -17,7 +21,7 @@ {% if label %}