diff --git a/core/core.libraries.yml b/core/core.libraries.yml index 41406af..5b469dc 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -197,6 +197,12 @@ drupal.machine-name: - core/drupal - core/drupalSettings +drupal.no-animate: + version: VERSION + css: + base: + misc/no-animate.css: {} + drupal.progress: version: VERSION js: diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 7bbd4ff..50c56b0 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1387,6 +1387,16 @@ function template_preprocess_html(&$variables) { } $variables['head_title'] = SafeMarkup::set($output); + // Turn off animations to improve accessibility. + if ($site_config->get('no_animate')) { + $variables['attributes']['class'][] = 'no-animate'; + $variables['html']['#attached']['library'][] = 'core/drupal.no-animate'; + $variables['html']['#attached']['js'][] = [ + 'type' => 'setting', + 'data' => ['noAnimate' => TRUE], + ]; + } + // Collect all attachments. This must happen in the preprocess function for // #type => html, to ensure that attachments added in #pre_render callbacks // for #type => html are included. diff --git a/core/misc/drupal.js b/core/misc/drupal.js index dcfad00..6ad03a6 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -9,6 +9,9 @@ document.documentElement.className += ' js'; // Allow other JavaScript libraries to use $. if (window.jQuery) { jQuery.noConflict(); + if (window.drupalSettings) { + jQuery.fx.off = drupalSettings.noAnimate; + } } // JavaScript should be made compatible with libraries other than jQuery by diff --git a/core/misc/no-animate.css b/core/misc/no-animate.css new file mode 100644 index 0000000..ac3f5b2 --- /dev/null +++ b/core/misc/no-animate.css @@ -0,0 +1,4 @@ +.no-animate * { + -webkit-transition: none !important; + transition: none !important; +} diff --git a/core/modules/system/src/Form/SiteAccessibility.php b/core/modules/system/src/Form/SiteAccessibility.php new file mode 100644 index 0000000..779fa33 --- /dev/null +++ b/core/modules/system/src/Form/SiteAccessibility.php @@ -0,0 +1,51 @@ +config('system.site'); + + $form['accessibility_no_animate'] = array( + '#type' => 'checkbox', + '#title' => t('Disable animations'), + '#default_value' => $site_config->get('no_animate'), + ); + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $this->config('system.site') + ->set('no_animate', $form_state->getValue('accessibility_no_animate')) + ->save(); + + parent::submitForm($form, $form_state); + } + +} diff --git a/core/modules/system/system.links.menu.yml b/core/modules/system/system.links.menu.yml index 1a0028f..d8295a7 100644 --- a/core/modules/system/system.links.menu.yml +++ b/core/modules/system/system.links.menu.yml @@ -153,3 +153,8 @@ system.status: parent: system.admin_reports description: 'Get a status report about your site''s operation and any detected problems.' route_name: system.status +system.accessibility_settings: + title: 'Accessibility' + description: 'Change global accessibility options.' + route_name: system.accessibility_settings + parent: system.admin_config_ui diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index fc05a95..d3e907a 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -456,3 +456,12 @@ system.admin_content: _title: 'Content' requirements: _permission: 'access administration pages' + +system.accessibility_settings: + path: '/admin/config/user-interface/accessibility' + defaults: + _form: 'Drupal\system\Form\SiteAccessibility' + _title: 'Accessibility' + requirements: + _permission: 'administer site configuration' +