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 %}
{{ label }}
{% endif %} -
+
{{ percent }}%
{{ message }}
diff --git a/core/themes/classy/css/components/progress.css b/core/themes/classy/css/components/progress.css index 1fb80a6..0a51cf4 100644 --- a/core/themes/classy/css/components/progress.css +++ b/core/themes/classy/css/components/progress.css @@ -44,22 +44,26 @@ padding: 0 1px; height: 16px; border-radius: 10em; - -webkit-animation: animate-stripes 3s linear infinite; - -moz-animation: animate-stripes 3s linear infinite; - -webkit-transition: width 0.5s ease-out; - transition: width 0.5s ease-out; } [dir="rtl"] .progress__bar { margin-left: 0; margin-right: -1px; - animation-direction: reverse; - -webkit-animation-direction: reverse; - -moz-animation-direction: reverse; } /** * Progress bar animations. */ +.progress__bar--animate { + -webkit-animation: animate-stripes 3s linear infinite; + -moz-animation: animate-stripes 3s linear infinite; + animation: animate-stripes 3s linear infinite; + -webkit-transition: width 0.5s ease-out; + transition: width 0.5s ease-out; +} +[dir="rtl"] .progress__bar--animate { + -webkit-animation-direction: reverse; + animation-direction: reverse; +} @-webkit-keyframes animate-stripes { 0% {background-position: 0 0, 0 0;} 100% {background-position: 0 0, -80px 0;} }