2018-06-27 22:30:15 -04:00
|
|
|
/**
|
|
|
|
* @output wp-admin/js/user-profile.js
|
|
|
|
*/
|
|
|
|
|
2015-07-22 14:56:26 -04:00
|
|
|
/* global ajaxurl, pwsL10n, userProfileL10n */
|
2015-07-27 17:25:25 -04:00
|
|
|
(function($) {
|
|
|
|
var updateLock = false,
|
2015-07-22 12:56:27 -04:00
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
$pass1Row,
|
|
|
|
$pass1,
|
|
|
|
$pass2,
|
|
|
|
$weakRow,
|
|
|
|
$weakCheckbox,
|
2015-07-29 15:22:26 -04:00
|
|
|
$toggleButton,
|
2015-07-27 17:25:25 -04:00
|
|
|
$submitButtons,
|
2015-07-28 23:27:25 -04:00
|
|
|
$submitButton,
|
2019-01-09 21:57:50 -05:00
|
|
|
currentPass;
|
2015-07-27 17:25:25 -04:00
|
|
|
|
|
|
|
function generatePassword() {
|
|
|
|
if ( typeof zxcvbn !== 'function' ) {
|
2015-07-28 23:27:25 -04:00
|
|
|
setTimeout( generatePassword, 50 );
|
2016-07-01 08:45:29 -04:00
|
|
|
return;
|
|
|
|
} else if ( ! $pass1.val() ) {
|
|
|
|
// zxcvbn loaded before user entered password.
|
2015-07-28 23:27:25 -04:00
|
|
|
$pass1.val( $pass1.data( 'pw' ) );
|
2016-07-01 08:45:29 -04:00
|
|
|
$pass1.trigger( 'pwupdate' );
|
|
|
|
showOrHideWeakPasswordCheckbox();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// zxcvbn loaded after the user entered password, check strength.
|
|
|
|
check_pass_strength();
|
|
|
|
showOrHideWeakPasswordCheckbox();
|
2015-07-01 10:48:24 -04:00
|
|
|
}
|
2016-07-01 08:45:29 -04:00
|
|
|
|
|
|
|
if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) {
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
$pass1.attr( 'type', 'text' );
|
2016-07-01 08:45:29 -04:00
|
|
|
} else {
|
|
|
|
$toggleButton.trigger( 'click' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Once zxcvbn loads, passwords strength is known.
|
|
|
|
$( '#pw-weak-text-label' ).html( userProfileL10n.warnWeak );
|
2015-07-27 17:25:25 -04:00
|
|
|
}
|
2015-07-01 10:48:24 -04:00
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
function bindPass1() {
|
2015-07-28 23:27:25 -04:00
|
|
|
currentPass = $pass1.val();
|
2015-07-01 10:48:24 -04:00
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
if ( 1 === parseInt( $pass1.data( 'reveal' ), 10 ) ) {
|
|
|
|
generatePassword();
|
|
|
|
}
|
2015-07-22 12:56:27 -04:00
|
|
|
|
2019-01-09 21:57:50 -05:00
|
|
|
$pass1.on( 'input' + ' pwupdate', function () {
|
2015-07-28 17:11:26 -04:00
|
|
|
if ( $pass1.val() === currentPass ) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-01 10:48:24 -04:00
|
|
|
|
2015-07-28 17:11:26 -04:00
|
|
|
currentPass = $pass1.val();
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
|
|
|
|
$pass1.removeClass( 'short bad good strong' );
|
2016-07-01 08:45:29 -04:00
|
|
|
showOrHideWeakPasswordCheckbox();
|
2015-07-01 10:48:24 -04:00
|
|
|
} );
|
2015-07-27 17:25:25 -04:00
|
|
|
}
|
2015-07-01 10:48:24 -04:00
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
function resetToggle( show ) {
|
2015-09-25 09:54:24 -04:00
|
|
|
$toggleButton
|
|
|
|
.attr({
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
'aria-label': show ? userProfileL10n.ariaShow : userProfileL10n.ariaHide
|
2015-09-25 09:54:24 -04:00
|
|
|
})
|
|
|
|
.find( '.text' )
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
.text( show ? userProfileL10n.show : userProfileL10n.hide )
|
2015-09-25 09:54:24 -04:00
|
|
|
.end()
|
|
|
|
.find( '.dashicons' )
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
.removeClass( show ? 'dashicons-hidden' : 'dashicons-visibility' )
|
|
|
|
.addClass( show ? 'dashicons-visibility' : 'dashicons-hidden' );
|
2015-09-25 09:54:24 -04:00
|
|
|
}
|
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
function bindToggleButton() {
|
2015-07-29 15:22:26 -04:00
|
|
|
$toggleButton = $pass1Row.find('.wp-hide-pw');
|
|
|
|
$toggleButton.show().on( 'click', function () {
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
if ( 'password' === $pass1.attr( 'type' ) ) {
|
|
|
|
$pass1.attr( 'type', 'text' );
|
|
|
|
resetToggle( false );
|
|
|
|
} else {
|
|
|
|
$pass1.attr( 'type', 'password' );
|
|
|
|
resetToggle( true );
|
|
|
|
}
|
2015-07-27 17:25:25 -04:00
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
$pass1.focus();
|
2015-09-11 18:52:26 -04:00
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
if ( ! _.isUndefined( $pass1[0].setSelectionRange ) ) {
|
|
|
|
$pass1[0].setSelectionRange( 0, 100 );
|
2015-07-01 10:48:24 -04:00
|
|
|
}
|
2015-07-27 17:25:25 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function bindPasswordForm() {
|
|
|
|
var $passwordWrapper,
|
|
|
|
$generateButton,
|
|
|
|
$cancelButton;
|
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
$pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' );
|
2015-09-11 18:52:26 -04:00
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
// Hide the confirm password field when JavaScript support is enabled.
|
2015-07-27 17:25:25 -04:00
|
|
|
$('.user-pass2-wrap').hide();
|
|
|
|
|
2017-09-21 17:29:48 -04:00
|
|
|
$submitButton = $( '#submit, #wp-submit' ).on( 'click', function () {
|
2015-07-27 17:25:25 -04:00
|
|
|
updateLock = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$submitButtons = $submitButton.add( ' #createusersub' );
|
|
|
|
|
|
|
|
$weakRow = $( '.pw-weak' );
|
|
|
|
$weakCheckbox = $weakRow.find( '.pw-checkbox' );
|
|
|
|
$weakCheckbox.change( function() {
|
|
|
|
$submitButtons.prop( 'disabled', ! $weakCheckbox.prop( 'checked' ) );
|
2015-07-01 10:48:24 -04:00
|
|
|
} );
|
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
$pass1 = $('#pass1');
|
|
|
|
if ( $pass1.length ) {
|
|
|
|
bindPass1();
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
} else {
|
|
|
|
// Password field for the login form.
|
|
|
|
$pass1 = $( '#user_pass' );
|
2015-07-27 17:25:25 -04:00
|
|
|
}
|
|
|
|
|
2015-07-01 10:48:24 -04:00
|
|
|
/**
|
|
|
|
* Fix a LastPass mismatch issue, LastPass only changes pass2.
|
|
|
|
*
|
|
|
|
* This fixes the issue by copying any changes from the hidden
|
2015-07-28 23:27:25 -04:00
|
|
|
* pass2 field to the pass1 field, then running check_pass_strength.
|
2015-07-01 10:48:24 -04:00
|
|
|
*/
|
2019-01-09 21:57:50 -05:00
|
|
|
$pass2 = $( '#pass2' ).on( 'input', function () {
|
2015-07-27 17:25:25 -04:00
|
|
|
if ( $pass2.val().length > 0 ) {
|
|
|
|
$pass1.val( $pass2.val() );
|
2015-07-28 23:27:25 -04:00
|
|
|
$pass2.val('');
|
|
|
|
currentPass = '';
|
|
|
|
$pass1.trigger( 'pwupdate' );
|
2015-07-23 01:00:25 -04:00
|
|
|
}
|
2015-07-01 10:48:24 -04:00
|
|
|
} );
|
|
|
|
|
2015-11-16 15:49:26 -05:00
|
|
|
// Disable hidden inputs to prevent autofill and submission.
|
|
|
|
if ( $pass1.is( ':hidden' ) ) {
|
|
|
|
$pass1.prop( 'disabled', true );
|
|
|
|
$pass2.prop( 'disabled', true );
|
|
|
|
}
|
2015-11-10 15:41:26 -05:00
|
|
|
|
2015-09-21 23:57:24 -04:00
|
|
|
$passwordWrapper = $pass1Row.find( '.wp-pwd' );
|
|
|
|
$generateButton = $pass1Row.find( 'button.wp-generate-pw' );
|
2015-07-27 17:25:25 -04:00
|
|
|
|
|
|
|
bindToggleButton();
|
|
|
|
|
2015-09-21 23:57:24 -04:00
|
|
|
if ( $generateButton.length ) {
|
|
|
|
$passwordWrapper.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
$generateButton.show();
|
2015-07-27 17:25:25 -04:00
|
|
|
$generateButton.on( 'click', function () {
|
|
|
|
updateLock = true;
|
|
|
|
|
|
|
|
$generateButton.hide();
|
|
|
|
$passwordWrapper.show();
|
|
|
|
|
2015-11-10 15:41:26 -05:00
|
|
|
// Enable the inputs when showing.
|
|
|
|
$pass1.attr( 'disabled', false );
|
|
|
|
$pass2.attr( 'disabled', false );
|
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
if ( $pass1.val().length === 0 ) {
|
2015-07-29 00:30:24 -04:00
|
|
|
generatePassword();
|
|
|
|
}
|
2015-07-27 17:25:25 -04:00
|
|
|
} );
|
2015-07-22 12:56:27 -04:00
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
$cancelButton = $pass1Row.find( 'button.wp-cancel-pw' );
|
|
|
|
$cancelButton.on( 'click', function () {
|
|
|
|
updateLock = false;
|
2015-07-01 10:48:24 -04:00
|
|
|
|
2015-09-18 16:14:24 -04:00
|
|
|
// Clear any entered password.
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
$pass1.val( '' );
|
2015-09-18 16:14:24 -04:00
|
|
|
|
|
|
|
// Generate a new password.
|
|
|
|
wp.ajax.post( 'generate-password' )
|
|
|
|
.done( function( data ) {
|
|
|
|
$pass1.data( 'pw', data );
|
|
|
|
} );
|
|
|
|
|
2019-03-13 19:37:57 -04:00
|
|
|
$generateButton.show().focus();
|
2015-07-27 17:25:25 -04:00
|
|
|
$passwordWrapper.hide();
|
2015-08-26 20:11:21 -04:00
|
|
|
|
2015-12-11 16:54:27 -05:00
|
|
|
$weakRow.hide( 0, function () {
|
|
|
|
$weakCheckbox.removeProp( 'checked' );
|
|
|
|
} );
|
|
|
|
|
2015-11-10 15:41:26 -05:00
|
|
|
// Disable the inputs when hiding to prevent autofill and submission.
|
|
|
|
$pass1.prop( 'disabled', true );
|
|
|
|
$pass2.prop( 'disabled', true );
|
|
|
|
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
resetToggle( false );
|
2015-09-25 09:54:24 -04:00
|
|
|
|
2016-09-01 08:24:29 -04:00
|
|
|
if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) {
|
|
|
|
// Clear password field to prevent update
|
|
|
|
$pass1.val( '' ).trigger( 'pwupdate' );
|
|
|
|
$submitButtons.prop( 'disabled', false );
|
|
|
|
}
|
2015-07-27 17:25:25 -04:00
|
|
|
} );
|
2015-07-22 12:56:27 -04:00
|
|
|
|
2016-09-01 08:24:29 -04:00
|
|
|
$pass1Row.closest( 'form' ).on( 'submit', function () {
|
2015-07-27 17:25:25 -04:00
|
|
|
updateLock = false;
|
2015-07-22 12:56:27 -04:00
|
|
|
|
2015-11-24 16:17:27 -05:00
|
|
|
$pass1.prop( 'disabled', false );
|
|
|
|
$pass2.prop( 'disabled', false );
|
2015-07-27 17:25:25 -04:00
|
|
|
$pass2.val( $pass1.val() );
|
2015-07-01 10:48:24 -04:00
|
|
|
});
|
2015-07-27 17:25:25 -04:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
function check_pass_strength() {
|
2015-07-29 00:30:24 -04:00
|
|
|
var pass1 = $('#pass1').val(), strength;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-13 14:30:55 -04:00
|
|
|
$('#pass-strength-result').removeClass('short bad good strong empty');
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( ! pass1 ) {
|
2019-09-13 14:30:55 -04:00
|
|
|
$( '#pass-strength-result' ).addClass( 'empty' ).html( ' ' );
|
2012-08-22 20:04:18 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-29 00:30:24 -04:00
|
|
|
strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass1 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
switch ( strength ) {
|
2016-07-01 08:45:29 -04:00
|
|
|
case -1:
|
|
|
|
$( '#pass-strength-result' ).addClass( 'bad' ).html( pwsL10n.unknown );
|
|
|
|
break;
|
2012-08-22 20:04:18 -04:00
|
|
|
case 2:
|
2013-11-18 23:40:10 -05:00
|
|
|
$('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-11-18 23:40:10 -05:00
|
|
|
$('#pass-strength-result').addClass('good').html( pwsL10n.good );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-11-18 23:40:10 -05:00
|
|
|
$('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-11-18 23:40:10 -05:00
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-01 08:45:29 -04:00
|
|
|
function showOrHideWeakPasswordCheckbox() {
|
|
|
|
var passStrength = $('#pass-strength-result')[0];
|
|
|
|
|
|
|
|
if ( passStrength.className ) {
|
Login and Registration: Add a "Show password" button on the login page.
The ability for users to see the password they're typing improves usability and accessibility of the login users flow.
- brings the login screen in line with the same feature already used in the New User, Edit User, and Reset Password pages
- improves association of labels and input fields by using explicit association with `for` / `id` attributes
- slightly increases the "Remember me" label font size
Props johnbillion, Iceable, audrasjb, joyously, adamsilverstein, boemedia, DrewAPicture, shadyvb, birgire, peterwilsoncc, pento, anevins, davidbaumwald, whyisjake, afercia.
Fixes #42888.
Built from https://develop.svn.wordpress.org/trunk@46256
git-svn-id: http://core.svn.wordpress.org/trunk@46068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 14:06:57 -04:00
|
|
|
$pass1.addClass( passStrength.className );
|
2017-09-21 17:29:48 -04:00
|
|
|
if ( $( passStrength ).is( '.short, .bad' ) ) {
|
2016-07-01 08:45:29 -04:00
|
|
|
if ( ! $weakCheckbox.prop( 'checked' ) ) {
|
|
|
|
$submitButtons.prop( 'disabled', true );
|
|
|
|
}
|
|
|
|
$weakRow.show();
|
|
|
|
} else {
|
2019-09-13 14:30:55 -04:00
|
|
|
if ( $( passStrength ).is( '.empty' ) ) {
|
|
|
|
$submitButtons.prop( 'disabled', true );
|
|
|
|
$weakCheckbox.prop( 'checked', false );
|
|
|
|
} else {
|
|
|
|
$submitButtons.prop( 'disabled', false );
|
|
|
|
}
|
2016-07-01 08:45:29 -04:00
|
|
|
$weakRow.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
$(document).ready( function() {
|
2013-11-18 23:40:10 -05:00
|
|
|
var $colorpicker, $stylesheet, user_id, current_user_id,
|
2017-05-12 16:06:42 -04:00
|
|
|
select = $( '#display_name' ),
|
|
|
|
current_name = select.val(),
|
|
|
|
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-01-09 21:57:50 -05:00
|
|
|
$( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength );
|
2012-08-22 20:04:18 -04:00
|
|
|
$('#pass-strength-result').show();
|
|
|
|
$('.color-palette').click( function() {
|
|
|
|
$(this).siblings('input[name="admin_color"]').prop('checked', true);
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( select.length ) {
|
|
|
|
$('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
|
|
|
|
var dub = [],
|
|
|
|
inputs = {
|
|
|
|
display_nickname : $('#nickname').val() || '',
|
|
|
|
display_username : $('#user_login').val() || '',
|
|
|
|
display_firstname : $('#first_name').val() || '',
|
|
|
|
display_lastname : $('#last_name').val() || ''
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( inputs.display_firstname && inputs.display_lastname ) {
|
2013-11-18 23:40:10 -05:00
|
|
|
inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname;
|
|
|
|
inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname;
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$.each( $('option', select), function( i, el ){
|
|
|
|
dub.push( el.value );
|
|
|
|
});
|
|
|
|
|
|
|
|
$.each(inputs, function( id, value ) {
|
2013-11-18 23:40:10 -05:00
|
|
|
if ( ! value ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
return;
|
2013-11-18 23:40:10 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
|
|
|
|
|
2013-11-18 23:40:10 -05:00
|
|
|
if ( inputs[id].length && $.inArray( val, dub ) === -1 ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
dub.push(val);
|
|
|
|
$('<option />', {
|
|
|
|
'text': val
|
|
|
|
}).appendTo( select );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2017-05-12 16:06:42 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replaces "Howdy, *" in the admin toolbar whenever the display name dropdown is updated for one's own profile.
|
|
|
|
*/
|
|
|
|
select.on( 'change', function() {
|
|
|
|
if ( user_id !== current_user_id ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var display_name = $.trim( this.value ) || current_name;
|
|
|
|
|
|
|
|
greeting.text( display_name );
|
|
|
|
} );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
2013-11-18 23:40:10 -05:00
|
|
|
$colorpicker = $( '#color-picker' );
|
|
|
|
$stylesheet = $( '#colors-css' );
|
|
|
|
user_id = $( 'input#user_id' ).val();
|
|
|
|
current_user_id = $( 'input[name="checkuser_id"]' ).val();
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
2013-12-01 14:50:09 -05:00
|
|
|
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
|
2013-12-03 23:13:11 -05:00
|
|
|
var colors,
|
|
|
|
$this = $(this);
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
2013-12-01 14:50:09 -05:00
|
|
|
if ( $this.hasClass( 'selected' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
2013-12-01 14:50:09 -05:00
|
|
|
$this.siblings( '.selected' ).removeClass( 'selected' );
|
|
|
|
$this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true );
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
2013-12-01 14:50:09 -05:00
|
|
|
// Set color scheme
|
2013-11-18 23:40:10 -05:00
|
|
|
if ( user_id === current_user_id ) {
|
2014-02-06 17:16:11 -05:00
|
|
|
// Load the colors stylesheet.
|
|
|
|
// The default color scheme won't have one, so we'll need to create an element.
|
|
|
|
if ( 0 === $stylesheet.length ) {
|
|
|
|
$stylesheet = $( '<link rel="stylesheet" />' ).appendTo( 'head' );
|
|
|
|
}
|
2013-12-01 14:50:09 -05:00
|
|
|
$stylesheet.attr( 'href', $this.children( '.css_url' ).val() );
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
|
|
|
// repaint icons
|
2013-12-05 17:01:10 -05:00
|
|
|
if ( typeof wp !== 'undefined' && wp.svgPainter ) {
|
2013-12-03 23:13:11 -05:00
|
|
|
try {
|
|
|
|
colors = $.parseJSON( $this.children( '.icon_colors' ).val() );
|
|
|
|
} catch ( error ) {}
|
|
|
|
|
|
|
|
if ( colors ) {
|
2013-12-05 17:01:10 -05:00
|
|
|
wp.svgPainter.setColors( colors );
|
|
|
|
wp.svgPainter.paint();
|
2013-12-03 23:13:11 -05:00
|
|
|
}
|
2013-12-01 14:50:09 -05:00
|
|
|
}
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
|
|
|
|
// update user option
|
|
|
|
$.post( ajaxurl, {
|
2013-12-02 14:45:10 -05:00
|
|
|
action: 'save-user-color-scheme',
|
|
|
|
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
|
2013-12-07 02:46:21 -05:00
|
|
|
nonce: $('#color-nonce').val()
|
2015-02-09 21:23:28 -05:00
|
|
|
}).done( function( response ) {
|
|
|
|
if ( response.success ) {
|
|
|
|
$( 'body' ).removeClass( response.data.previousScheme ).addClass( response.data.currentScheme );
|
|
|
|
}
|
Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.
Color scheme selection on your own profile page gives you a preview and autosaves the selection.
Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.
Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.
props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.
Built from https://develop.svn.wordpress.org/trunk@26137
git-svn-id: http://core.svn.wordpress.org/trunk@26048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-13 14:38:38 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2015-07-27 17:25:25 -04:00
|
|
|
|
|
|
|
bindPasswordForm();
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2014-11-13 10:54:20 -05:00
|
|
|
$( '#destroy-sessions' ).on( 'click', function( e ) {
|
2014-11-13 10:21:21 -05:00
|
|
|
var $this = $(this);
|
|
|
|
|
2014-12-16 04:15:23 -05:00
|
|
|
wp.ajax.post( 'destroy-sessions', {
|
|
|
|
nonce: $( '#_wpnonce' ).val(),
|
|
|
|
user_id: $( '#user_id' ).val()
|
|
|
|
}).done( function( response ) {
|
|
|
|
$this.prop( 'disabled', true );
|
|
|
|
$this.siblings( '.notice' ).remove();
|
|
|
|
$this.before( '<div class="notice notice-success inline"><p>' + response.message + '</p></div>' );
|
|
|
|
}).fail( function( response ) {
|
|
|
|
$this.siblings( '.notice' ).remove();
|
|
|
|
$this.before( '<div class="notice notice-error inline"><p>' + response.message + '</p></div>' );
|
|
|
|
});
|
2014-11-13 10:21:21 -05:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2015-07-27 17:25:25 -04:00
|
|
|
window.generatePassword = generatePassword;
|
|
|
|
|
|
|
|
/* Warn the user if password was generated but not saved */
|
|
|
|
$( window ).on( 'beforeunload', function () {
|
|
|
|
if ( true === updateLock ) {
|
|
|
|
return userProfileL10n.warn;
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
})(jQuery);
|