2018-06-28 04:30:15 +02:00
|
|
|
/**
|
|
|
|
* @output wp-admin/js/user-profile.js
|
|
|
|
*/
|
|
|
|
|
2015-07-22 20:56:26 +02:00
|
|
|
/* global ajaxurl, pwsL10n, userProfileL10n */
|
2015-07-27 23:25:25 +02:00
|
|
|
(function($) {
|
|
|
|
var updateLock = false,
|
2015-07-22 18:56:27 +02:00
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass1Row,
|
|
|
|
$pass1Wrap,
|
|
|
|
$pass1,
|
|
|
|
$pass1Text,
|
2015-09-12 00:52:26 +02:00
|
|
|
$pass1Label,
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass2,
|
|
|
|
$weakRow,
|
|
|
|
$weakCheckbox,
|
2015-07-29 21:22:26 +02:00
|
|
|
$toggleButton,
|
2015-07-27 23:25:25 +02:00
|
|
|
$submitButtons,
|
2015-07-29 05:27:25 +02:00
|
|
|
$submitButton,
|
2015-09-11 23:52:27 +02:00
|
|
|
currentPass,
|
|
|
|
inputEvent;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use feature detection to determine whether password inputs should use
|
|
|
|
* the `keyup` or `input` event. Input is preferred but lacks support
|
|
|
|
* in legacy browsers.
|
|
|
|
*/
|
|
|
|
if ( 'oninput' in document.createElement( 'input' ) ) {
|
|
|
|
inputEvent = 'input';
|
|
|
|
} else {
|
|
|
|
inputEvent = 'keyup';
|
|
|
|
}
|
2015-07-27 23:25:25 +02:00
|
|
|
|
|
|
|
function generatePassword() {
|
|
|
|
if ( typeof zxcvbn !== 'function' ) {
|
2015-07-29 05:27:25 +02:00
|
|
|
setTimeout( generatePassword, 50 );
|
2016-07-01 14:45:29 +02:00
|
|
|
return;
|
|
|
|
} else if ( ! $pass1.val() ) {
|
|
|
|
// zxcvbn loaded before user entered password.
|
2015-07-29 05:27:25 +02:00
|
|
|
$pass1.val( $pass1.data( 'pw' ) );
|
2016-07-01 14:45:29 +02:00
|
|
|
$pass1.trigger( 'pwupdate' );
|
|
|
|
showOrHideWeakPasswordCheckbox();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// zxcvbn loaded after the user entered password, check strength.
|
|
|
|
check_pass_strength();
|
|
|
|
showOrHideWeakPasswordCheckbox();
|
2015-07-01 16:48:24 +02:00
|
|
|
}
|
2016-07-01 14:45:29 +02:00
|
|
|
|
|
|
|
if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) {
|
|
|
|
$pass1Wrap.addClass( 'show-password' );
|
|
|
|
} else {
|
|
|
|
$toggleButton.trigger( 'click' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Once zxcvbn loads, passwords strength is known.
|
|
|
|
$( '#pw-weak-text-label' ).html( userProfileL10n.warnWeak );
|
2015-07-27 23:25:25 +02:00
|
|
|
}
|
2015-07-01 16:48:24 +02:00
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
function bindPass1() {
|
2015-07-29 05:27:25 +02:00
|
|
|
currentPass = $pass1.val();
|
2015-07-01 16:48:24 +02:00
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass1Wrap = $pass1.parent();
|
|
|
|
|
|
|
|
$pass1Text = $( '<input type="text"/>' )
|
|
|
|
.attr( {
|
|
|
|
'id': 'pass1-text',
|
|
|
|
'name': 'pass1-text',
|
|
|
|
'autocomplete': 'off'
|
|
|
|
} )
|
|
|
|
.addClass( $pass1[0].className )
|
|
|
|
.data( 'pw', $pass1.data( 'pw' ) )
|
|
|
|
.val( $pass1.val() )
|
2015-09-11 23:52:27 +02:00
|
|
|
.on( inputEvent, function () {
|
2015-07-29 05:27:25 +02:00
|
|
|
if ( $pass1Text.val() === currentPass ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$pass2.val( $pass1Text.val() );
|
|
|
|
$pass1.val( $pass1Text.val() ).trigger( 'pwupdate' );
|
|
|
|
currentPass = $pass1Text.val();
|
2015-07-27 23:25:25 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
$pass1.after( $pass1Text );
|
|
|
|
|
|
|
|
if ( 1 === parseInt( $pass1.data( 'reveal' ), 10 ) ) {
|
|
|
|
generatePassword();
|
|
|
|
}
|
2015-07-22 18:56:27 +02:00
|
|
|
|
2015-09-11 23:52:27 +02:00
|
|
|
$pass1.on( inputEvent + ' pwupdate', function () {
|
2015-07-28 23:11:26 +02:00
|
|
|
if ( $pass1.val() === currentPass ) {
|
|
|
|
return;
|
|
|
|
}
|
2015-07-01 16:48:24 +02:00
|
|
|
|
2015-07-28 23:11:26 +02:00
|
|
|
currentPass = $pass1.val();
|
2015-08-17 20:46:25 +02:00
|
|
|
if ( $pass1Text.val() !== currentPass ) {
|
|
|
|
$pass1Text.val( currentPass );
|
|
|
|
}
|
2015-07-28 23:11:26 +02:00
|
|
|
$pass1.add( $pass1Text ).removeClass( 'short bad good strong' );
|
2016-07-01 14:45:29 +02:00
|
|
|
showOrHideWeakPasswordCheckbox();
|
2015-07-01 16:48:24 +02:00
|
|
|
} );
|
2015-07-27 23:25:25 +02:00
|
|
|
}
|
2015-07-01 16:48:24 +02:00
|
|
|
|
2015-09-25 15:54:24 +02:00
|
|
|
function resetToggle() {
|
|
|
|
$toggleButton
|
|
|
|
.data( 'toggle', 0 )
|
|
|
|
.attr({
|
|
|
|
'aria-label': userProfileL10n.ariaHide
|
|
|
|
})
|
|
|
|
.find( '.text' )
|
|
|
|
.text( userProfileL10n.hide )
|
|
|
|
.end()
|
|
|
|
.find( '.dashicons' )
|
|
|
|
.removeClass( 'dashicons-visibility' )
|
|
|
|
.addClass( 'dashicons-hidden' );
|
|
|
|
|
|
|
|
$pass1Text.focus();
|
|
|
|
|
|
|
|
$pass1Label.attr( 'for', 'pass1-text' );
|
|
|
|
}
|
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
function bindToggleButton() {
|
2015-07-29 21:22:26 +02:00
|
|
|
$toggleButton = $pass1Row.find('.wp-hide-pw');
|
|
|
|
$toggleButton.show().on( 'click', function () {
|
|
|
|
if ( 1 === parseInt( $toggleButton.data( 'toggle' ), 10 ) ) {
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass1Wrap.addClass( 'show-password' );
|
|
|
|
|
2015-09-25 15:54:24 +02:00
|
|
|
resetToggle();
|
2015-09-12 00:52:26 +02:00
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) {
|
|
|
|
$pass1Text[0].setSelectionRange( 0, 100 );
|
|
|
|
}
|
2015-07-01 16:48:24 +02:00
|
|
|
} else {
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass1Wrap.removeClass( 'show-password' );
|
2015-07-29 21:22:26 +02:00
|
|
|
$toggleButton
|
2015-07-27 23:25:25 +02:00
|
|
|
.data( 'toggle', 1 )
|
|
|
|
.attr({
|
|
|
|
'aria-label': userProfileL10n.ariaShow
|
|
|
|
})
|
|
|
|
.find( '.text' )
|
|
|
|
.text( userProfileL10n.show )
|
|
|
|
.end()
|
|
|
|
.find( '.dashicons' )
|
|
|
|
.removeClass('dashicons-hidden')
|
|
|
|
.addClass('dashicons-visibility');
|
|
|
|
|
|
|
|
$pass1.focus();
|
|
|
|
|
2015-09-12 00:52:26 +02:00
|
|
|
$pass1Label.attr( 'for', 'pass1' );
|
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
if ( ! _.isUndefined( $pass1[0].setSelectionRange ) ) {
|
|
|
|
$pass1[0].setSelectionRange( 0, 100 );
|
|
|
|
}
|
2015-07-01 16:48:24 +02:00
|
|
|
}
|
2015-07-27 23:25:25 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function bindPasswordForm() {
|
|
|
|
var $passwordWrapper,
|
|
|
|
$generateButton,
|
|
|
|
$cancelButton;
|
|
|
|
|
|
|
|
$pass1Row = $('.user-pass1-wrap');
|
2015-09-12 01:05:24 +02:00
|
|
|
$pass1Label = $pass1Row.find('th label').attr( 'for', 'pass1-text' );
|
2015-09-12 00:52:26 +02:00
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
// hide this
|
|
|
|
$('.user-pass2-wrap').hide();
|
|
|
|
|
2017-09-21 23:29:48 +02:00
|
|
|
$submitButton = $( '#submit, #wp-submit' ).on( 'click', function () {
|
2015-07-27 23:25:25 +02: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 16:48:24 +02:00
|
|
|
} );
|
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass1 = $('#pass1');
|
|
|
|
if ( $pass1.length ) {
|
|
|
|
bindPass1();
|
|
|
|
}
|
|
|
|
|
2015-07-01 16:48:24 +02:00
|
|
|
/**
|
|
|
|
* Fix a LastPass mismatch issue, LastPass only changes pass2.
|
|
|
|
*
|
|
|
|
* This fixes the issue by copying any changes from the hidden
|
2015-07-29 05:27:25 +02:00
|
|
|
* pass2 field to the pass1 field, then running check_pass_strength.
|
2015-07-01 16:48:24 +02:00
|
|
|
*/
|
2015-09-11 23:52:27 +02:00
|
|
|
$pass2 = $('#pass2').on( inputEvent, function () {
|
2015-07-27 23:25:25 +02:00
|
|
|
if ( $pass2.val().length > 0 ) {
|
|
|
|
$pass1.val( $pass2.val() );
|
2015-07-29 05:27:25 +02:00
|
|
|
$pass2.val('');
|
|
|
|
currentPass = '';
|
|
|
|
$pass1.trigger( 'pwupdate' );
|
2015-07-23 07:00:25 +02:00
|
|
|
}
|
2015-07-01 16:48:24 +02:00
|
|
|
} );
|
|
|
|
|
2015-11-16 21:49:26 +01:00
|
|
|
// Disable hidden inputs to prevent autofill and submission.
|
|
|
|
if ( $pass1.is( ':hidden' ) ) {
|
|
|
|
$pass1.prop( 'disabled', true );
|
|
|
|
$pass2.prop( 'disabled', true );
|
|
|
|
$pass1Text.prop( 'disabled', true );
|
|
|
|
}
|
2015-11-10 21:41:26 +01:00
|
|
|
|
2015-09-22 05:57:24 +02:00
|
|
|
$passwordWrapper = $pass1Row.find( '.wp-pwd' );
|
|
|
|
$generateButton = $pass1Row.find( 'button.wp-generate-pw' );
|
2015-07-27 23:25:25 +02:00
|
|
|
|
|
|
|
bindToggleButton();
|
|
|
|
|
2015-09-22 05:57:24 +02:00
|
|
|
if ( $generateButton.length ) {
|
|
|
|
$passwordWrapper.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
$generateButton.show();
|
2015-07-27 23:25:25 +02:00
|
|
|
$generateButton.on( 'click', function () {
|
|
|
|
updateLock = true;
|
|
|
|
|
|
|
|
$generateButton.hide();
|
|
|
|
$passwordWrapper.show();
|
|
|
|
|
2015-11-10 21:41:26 +01:00
|
|
|
// Enable the inputs when showing.
|
|
|
|
$pass1.attr( 'disabled', false );
|
|
|
|
$pass2.attr( 'disabled', false );
|
|
|
|
$pass1Text.attr( 'disabled', false );
|
|
|
|
|
2015-07-29 06:30:24 +02:00
|
|
|
if ( $pass1Text.val().length === 0 ) {
|
|
|
|
generatePassword();
|
|
|
|
}
|
2015-07-27 23:25:25 +02:00
|
|
|
|
2015-07-22 18:56:27 +02:00
|
|
|
_.defer( function() {
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass1Text.focus();
|
|
|
|
if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) {
|
|
|
|
$pass1Text[0].setSelectionRange( 0, 100 );
|
2015-07-22 18:56:27 +02:00
|
|
|
}
|
|
|
|
}, 0 );
|
2015-07-27 23:25:25 +02:00
|
|
|
} );
|
2015-07-22 18:56:27 +02:00
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
$cancelButton = $pass1Row.find( 'button.wp-cancel-pw' );
|
|
|
|
$cancelButton.on( 'click', function () {
|
|
|
|
updateLock = false;
|
2015-07-01 16:48:24 +02:00
|
|
|
|
2015-09-18 22:14:24 +02:00
|
|
|
// Clear any entered password.
|
|
|
|
$pass1Text.val( '' );
|
|
|
|
|
|
|
|
// Generate a new password.
|
|
|
|
wp.ajax.post( 'generate-password' )
|
|
|
|
.done( function( data ) {
|
|
|
|
$pass1.data( 'pw', data );
|
|
|
|
} );
|
|
|
|
|
2015-07-27 23:25:25 +02:00
|
|
|
$generateButton.show();
|
|
|
|
$passwordWrapper.hide();
|
2015-08-27 02:11:21 +02:00
|
|
|
|
2015-12-11 22:54:27 +01:00
|
|
|
$weakRow.hide( 0, function () {
|
|
|
|
$weakCheckbox.removeProp( 'checked' );
|
|
|
|
} );
|
|
|
|
|
2015-11-10 21:41:26 +01:00
|
|
|
// Disable the inputs when hiding to prevent autofill and submission.
|
|
|
|
$pass1.prop( 'disabled', true );
|
|
|
|
$pass2.prop( 'disabled', true );
|
|
|
|
$pass1Text.prop( 'disabled', true );
|
|
|
|
|
2015-09-25 15:54:24 +02:00
|
|
|
resetToggle();
|
|
|
|
|
2016-09-01 14:24:29 +02: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 23:25:25 +02:00
|
|
|
} );
|
2015-07-22 18:56:27 +02:00
|
|
|
|
2016-09-01 14:24:29 +02:00
|
|
|
$pass1Row.closest( 'form' ).on( 'submit', function () {
|
2015-07-27 23:25:25 +02:00
|
|
|
updateLock = false;
|
2015-07-22 18:56:27 +02:00
|
|
|
|
2015-11-24 22:17:27 +01:00
|
|
|
$pass1.prop( 'disabled', false );
|
|
|
|
$pass2.prop( 'disabled', false );
|
2015-07-27 23:25:25 +02:00
|
|
|
$pass2.val( $pass1.val() );
|
|
|
|
$pass1Wrap.removeClass( 'show-password' );
|
2015-07-01 16:48:24 +02:00
|
|
|
});
|
2015-07-27 23:25:25 +02:00
|
|
|
}
|
2012-08-23 02:04:18 +02:00
|
|
|
|
|
|
|
function check_pass_strength() {
|
2015-07-29 06:30:24 +02:00
|
|
|
var pass1 = $('#pass1').val(), strength;
|
2012-08-23 02:04:18 +02:00
|
|
|
|
|
|
|
$('#pass-strength-result').removeClass('short bad good strong');
|
|
|
|
if ( ! pass1 ) {
|
2015-07-11 22:48:24 +02:00
|
|
|
$('#pass-strength-result').html( ' ' );
|
2012-08-23 02:04:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-29 06:30:24 +02:00
|
|
|
strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass1 );
|
2012-08-23 02:04:18 +02:00
|
|
|
|
|
|
|
switch ( strength ) {
|
2016-07-01 14:45:29 +02:00
|
|
|
case -1:
|
|
|
|
$( '#pass-strength-result' ).addClass( 'bad' ).html( pwsL10n.unknown );
|
|
|
|
break;
|
2012-08-23 02:04:18 +02:00
|
|
|
case 2:
|
2013-11-19 05:40:10 +01:00
|
|
|
$('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
|
2012-08-23 02:04:18 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-11-19 05:40:10 +01:00
|
|
|
$('#pass-strength-result').addClass('good').html( pwsL10n.good );
|
2012-08-23 02:04:18 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-11-19 05:40:10 +01:00
|
|
|
$('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
|
2012-08-23 02:04:18 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-11-19 05:40:10 +01:00
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
|
2012-08-23 02:04:18 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-01 14:45:29 +02:00
|
|
|
function showOrHideWeakPasswordCheckbox() {
|
|
|
|
var passStrength = $('#pass-strength-result')[0];
|
|
|
|
|
|
|
|
if ( passStrength.className ) {
|
|
|
|
$pass1.add( $pass1Text ).addClass( passStrength.className );
|
2017-09-21 23:29:48 +02:00
|
|
|
if ( $( passStrength ).is( '.short, .bad' ) ) {
|
2016-07-01 14:45:29 +02:00
|
|
|
if ( ! $weakCheckbox.prop( 'checked' ) ) {
|
|
|
|
$submitButtons.prop( 'disabled', true );
|
|
|
|
}
|
|
|
|
$weakRow.show();
|
|
|
|
} else {
|
|
|
|
$submitButtons.prop( 'disabled', false );
|
|
|
|
$weakRow.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 02:04:18 +02:00
|
|
|
$(document).ready( function() {
|
2013-11-19 05:40:10 +01:00
|
|
|
var $colorpicker, $stylesheet, user_id, current_user_id,
|
2017-05-12 22:06:42 +02:00
|
|
|
select = $( '#display_name' ),
|
|
|
|
current_name = select.val(),
|
|
|
|
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
|
2012-08-23 02:04:18 +02:00
|
|
|
|
2015-09-11 23:52:27 +02:00
|
|
|
$('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
|
2012-08-23 02:04:18 +02: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-19 05:40:10 +01:00
|
|
|
inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname;
|
|
|
|
inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname;
|
2012-08-23 02:04:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$.each( $('option', select), function( i, el ){
|
|
|
|
dub.push( el.value );
|
|
|
|
});
|
|
|
|
|
|
|
|
$.each(inputs, function( id, value ) {
|
2013-11-19 05:40:10 +01:00
|
|
|
if ( ! value ) {
|
2012-08-23 02:04:18 +02:00
|
|
|
return;
|
2013-11-19 05:40:10 +01:00
|
|
|
}
|
2012-08-23 02:04:18 +02:00
|
|
|
|
|
|
|
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
|
|
|
|
|
2013-11-19 05:40:10 +01:00
|
|
|
if ( inputs[id].length && $.inArray( val, dub ) === -1 ) {
|
2012-08-23 02:04:18 +02:00
|
|
|
dub.push(val);
|
|
|
|
$('<option />', {
|
|
|
|
'text': val
|
|
|
|
}).appendTo( select );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2017-05-12 22:06:42 +02: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-23 02:04:18 +02: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 20:38:38 +01:00
|
|
|
|
2013-11-19 05:40:10 +01: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 20:38:38 +01:00
|
|
|
|
2013-12-01 20:50:09 +01:00
|
|
|
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
|
2013-12-04 05:13:11 +01: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 20:38:38 +01:00
|
|
|
|
2013-12-01 20:50:09 +01: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 20:38:38 +01:00
|
|
|
|
2013-12-01 20:50:09 +01: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 20:38:38 +01:00
|
|
|
|
2013-12-01 20:50:09 +01:00
|
|
|
// Set color scheme
|
2013-11-19 05:40:10 +01:00
|
|
|
if ( user_id === current_user_id ) {
|
2014-02-06 23:16:11 +01: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 20:50:09 +01: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 20:38:38 +01:00
|
|
|
|
|
|
|
// repaint icons
|
2013-12-05 23:01:10 +01:00
|
|
|
if ( typeof wp !== 'undefined' && wp.svgPainter ) {
|
2013-12-04 05:13:11 +01:00
|
|
|
try {
|
|
|
|
colors = $.parseJSON( $this.children( '.icon_colors' ).val() );
|
|
|
|
} catch ( error ) {}
|
|
|
|
|
|
|
|
if ( colors ) {
|
2013-12-05 23:01:10 +01:00
|
|
|
wp.svgPainter.setColors( colors );
|
|
|
|
wp.svgPainter.paint();
|
2013-12-04 05:13:11 +01:00
|
|
|
}
|
2013-12-01 20:50:09 +01: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 20:38:38 +01:00
|
|
|
|
|
|
|
// update user option
|
|
|
|
$.post( ajaxurl, {
|
2013-12-02 20:45:10 +01:00
|
|
|
action: 'save-user-color-scheme',
|
|
|
|
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
|
2013-12-07 08:46:21 +01:00
|
|
|
nonce: $('#color-nonce').val()
|
2015-02-10 03:23:28 +01: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 20:38:38 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2015-07-27 23:25:25 +02:00
|
|
|
|
|
|
|
bindPasswordForm();
|
2012-08-23 02:04:18 +02:00
|
|
|
});
|
|
|
|
|
2014-11-13 16:54:20 +01:00
|
|
|
$( '#destroy-sessions' ).on( 'click', function( e ) {
|
2014-11-13 16:21:21 +01:00
|
|
|
var $this = $(this);
|
|
|
|
|
2014-12-16 10:15:23 +01: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 16:21:21 +01:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2015-07-27 23:25:25 +02: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-23 02:04:18 +02:00
|
|
|
})(jQuery);
|