From 52a07405f93b907a34c136e1577d3105a8f4fec3 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Wed, 21 Aug 2019 18:37:49 +1000 Subject: [PATCH] Issue #3061265 by lauriii, quiron, Niyas, bnjmnm, huzooka, catch: Use specific class for password confirm message --- core/modules/user/user.es6.js | 8 ++------ core/modules/user/user.js | 4 ++-- core/modules/user/user.libraries.yml | 1 + core/modules/user/user.theme.es6.js | 17 +++++++++++++++++ core/modules/user/user.theme.js | 12 ++++++++++++ core/themes/stable/js/user.theme.es6.js | 17 +++++++++++++++++ core/themes/stable/js/user.theme.js | 12 ++++++++++++ core/themes/stable/stable.info.yml | 4 ++++ core/themes/stable/stable.libraries.yml | 4 ++++ 9 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 core/modules/user/user.theme.es6.js create mode 100644 core/modules/user/user.theme.js create mode 100644 core/themes/stable/js/user.theme.es6.js create mode 100644 core/themes/stable/js/user.theme.js create mode 100644 core/themes/stable/stable.libraries.yml diff --git a/core/modules/user/user.es6.js b/core/modules/user/user.es6.js index 4739e1528d43..a91b9a123984 100644 --- a/core/modules/user/user.es6.js +++ b/core/modules/user/user.es6.js @@ -34,18 +34,14 @@ $passwordInputParentWrapper .find('input.js-password-confirm') .parent() - .append( - `<div aria-live="polite" aria-atomic="true" class="password-confirm js-password-confirm">${ - translate.confirmTitle - } <span></span></div>`, - ) + .append(Drupal.theme('passwordConfirmMessage', translate)) .addClass('confirm-parent'); const $confirmInput = $passwordInputParentWrapper.find( 'input.js-password-confirm', ); const $confirmResult = $passwordInputParentWrapper.find( - 'div.js-password-confirm', + 'div.js-password-confirm-message', ); const $confirmChild = $confirmResult.find('span'); diff --git a/core/modules/user/user.js b/core/modules/user/user.js index ec9735cf08a5..40852ff8bcb8 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -19,10 +19,10 @@ $passwordInputParent.addClass('password-parent'); - $passwordInputParentWrapper.find('input.js-password-confirm').parent().append('<div aria-live="polite" aria-atomic="true" class="password-confirm js-password-confirm">' + translate.confirmTitle + ' <span></span></div>').addClass('confirm-parent'); + $passwordInputParentWrapper.find('input.js-password-confirm').parent().append(Drupal.theme('passwordConfirmMessage', translate)).addClass('confirm-parent'); var $confirmInput = $passwordInputParentWrapper.find('input.js-password-confirm'); - var $confirmResult = $passwordInputParentWrapper.find('div.js-password-confirm'); + var $confirmResult = $passwordInputParentWrapper.find('div.js-password-confirm-message'); var $confirmChild = $confirmResult.find('span'); if (settings.password.showStrengthIndicator) { diff --git a/core/modules/user/user.libraries.yml b/core/modules/user/user.libraries.yml index 73e4e1581468..0e6e9533a2e5 100644 --- a/core/modules/user/user.libraries.yml +++ b/core/modules/user/user.libraries.yml @@ -2,6 +2,7 @@ drupal.user: version: VERSION js: user.js: {} + user.theme.js: {} css: component: css/user.module.css: {} diff --git a/core/modules/user/user.theme.es6.js b/core/modules/user/user.theme.es6.js new file mode 100644 index 000000000000..f3e14650366e --- /dev/null +++ b/core/modules/user/user.theme.es6.js @@ -0,0 +1,17 @@ +/** + * @file + * Theme elements for user password forms. + */ + +(Drupal => { + /** + * Constucts a password confirm message element + * + * @return {string} + * A string representing a DOM fragment. + */ + Drupal.theme.passwordConfirmMessage = translate => + `<div aria-live="polite" aria-atomic="true" class="password-confirm-message js-password-confirm-message">${ + translate.confirmTitle + } <span></span></div>`; +})(Drupal); diff --git a/core/modules/user/user.theme.js b/core/modules/user/user.theme.js new file mode 100644 index 000000000000..8b7b0280c887 --- /dev/null +++ b/core/modules/user/user.theme.js @@ -0,0 +1,12 @@ +/** +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ + +(function (Drupal) { + Drupal.theme.passwordConfirmMessage = function (translate) { + return "<div aria-live=\"polite\" aria-atomic=\"true\" class=\"password-confirm-message js-password-confirm-message\">" + translate.confirmTitle + " <span></span></div>"; + }; +})(Drupal); \ No newline at end of file diff --git a/core/themes/stable/js/user.theme.es6.js b/core/themes/stable/js/user.theme.es6.js new file mode 100644 index 000000000000..4f10529b007e --- /dev/null +++ b/core/themes/stable/js/user.theme.es6.js @@ -0,0 +1,17 @@ +/** + * @file + * Stable theme overrides for user password forms. + */ + +(Drupal => { + /** + * Constucts a password confirm message element + * + * @return {string} + * A string representing a DOM fragment. + */ + Drupal.theme.passwordConfirmMessage = translate => + `<div aria-live="polite" aria-atomic="true" class="password-confirm js-password-confirm js-password-confirm-message">${ + translate.confirmTitle + } <span></span></div>`; +})(Drupal); diff --git a/core/themes/stable/js/user.theme.js b/core/themes/stable/js/user.theme.js new file mode 100644 index 000000000000..a85ae4e43b81 --- /dev/null +++ b/core/themes/stable/js/user.theme.js @@ -0,0 +1,12 @@ +/** +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ + +(function (Drupal) { + Drupal.theme.passwordConfirmMessage = function (translate) { + return "<div aria-live=\"polite\" aria-atomic=\"true\" class=\"password-confirm js-password-confirm js-password-confirm-message\">" + translate.confirmTitle + " <span></span></div>"; + }; +})(Drupal); \ No newline at end of file diff --git a/core/themes/stable/stable.info.yml b/core/themes/stable/stable.info.yml index 2d2aa148c5c6..c14e3966b5de 100644 --- a/core/themes/stable/stable.info.yml +++ b/core/themes/stable/stable.info.yml @@ -308,3 +308,7 @@ libraries-override: theme: css/views_ui.admin.theme.css: css/views_ui/views_ui.admin.theme.css css/views_ui.contextual.css: css/views_ui/views_ui.contextual.css + +libraries-extend: + user/drupal.user: + - stable/drupal.user diff --git a/core/themes/stable/stable.libraries.yml b/core/themes/stable/stable.libraries.yml new file mode 100644 index 000000000000..354e1b1e9e24 --- /dev/null +++ b/core/themes/stable/stable.libraries.yml @@ -0,0 +1,4 @@ +drupal.user: + version: VERSION + js: + js/user.theme.js: {} -- GitLab