2014-12-16 04:15:23 -05:00
|
|
|
/* global ajaxurl, pwsL10n */
|
2012-08-22 20:04:18 -04:00
|
|
|
(function($){
|
2015-07-01 10:48:24 -04:00
|
|
|
$(function(){
|
|
|
|
var pw_new = $('.user-pass1-wrap'),
|
|
|
|
pw_line = pw_new.find('.wp-pwd'),
|
|
|
|
pw_field = $('#pass1'),
|
|
|
|
pw_field2 = $('#pass2'),
|
|
|
|
pw_togglebtn = pw_new.find('.wp-hide-pw'),
|
|
|
|
pw_generatebtn = pw_new.find('button.wp-generate-pw'),
|
|
|
|
pw_2 = $('.user-pass2-wrap'),
|
|
|
|
parentform = pw_new.closest('form'),
|
|
|
|
pw_strength = $('#pass-strength-result'),
|
|
|
|
pw_submitbtn_edit = $('#submit'),
|
|
|
|
pw_submitbtn_new = $( '#createusersub' ),
|
|
|
|
pw_checkbox = $('.pw-checkbox'),
|
|
|
|
pw_weak = $('.pw-weak')
|
|
|
|
;
|
|
|
|
|
2015-07-01 14:13:24 -04:00
|
|
|
var generatePassword = window.generatePassword = function() {
|
|
|
|
if ( typeof zxcvbn !== 'function' ) {
|
|
|
|
setTimeout( generatePassword, 50 );
|
|
|
|
} else {
|
|
|
|
pw_field.val( pw_field.data( 'pw' ) );
|
|
|
|
pw_field.trigger( 'propertychange' );
|
|
|
|
pw_field.attr( 'type', 'text' ).focus();
|
|
|
|
pw_field[0].setSelectionRange(100, 100);
|
|
|
|
}
|
2015-07-01 10:48:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
pw_2.hide();
|
|
|
|
pw_line.hide();
|
|
|
|
pw_togglebtn.show();
|
|
|
|
pw_generatebtn.show();
|
|
|
|
|
|
|
|
if ( pw_field.data( 'reveal' ) == 1 ) {
|
|
|
|
generatePassword();
|
|
|
|
}
|
|
|
|
|
|
|
|
parentform.on('submit', function(){
|
|
|
|
pw_field2.val( pw_field.val() );
|
|
|
|
pw_field.attr('type', 'password');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
pw_field.on('input propertychange', function(){
|
|
|
|
setTimeout( function(){
|
|
|
|
var cssClass = pw_strength.attr('class');
|
|
|
|
pw_field.removeClass( 'short bad good strong' );
|
|
|
|
if ( 'undefined' !== typeof cssClass ) {
|
|
|
|
pw_field.addClass( cssClass );
|
|
|
|
if ( cssClass == 'short' || cssClass == 'bad' ) {
|
|
|
|
if ( ! pw_checkbox.attr( 'checked' ) ) {
|
|
|
|
pw_submitbtn_new.attr( 'disabled','disabled' );
|
|
|
|
pw_submitbtn_edit.attr( 'disabled','disabled' );
|
|
|
|
}
|
|
|
|
pw_weak.show();
|
|
|
|
} else {
|
|
|
|
pw_submitbtn_new.removeAttr( 'disabled' );
|
|
|
|
pw_submitbtn_edit.removeAttr( 'disabled' );
|
|
|
|
pw_weak.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 1 );
|
|
|
|
} );
|
|
|
|
|
|
|
|
pw_checkbox.change( function() {
|
|
|
|
if ( pw_checkbox.attr( 'checked' ) ) {
|
|
|
|
pw_submitbtn_new.removeAttr( 'disabled' );
|
|
|
|
pw_submitbtn_edit.removeAttr( 'disabled' );
|
|
|
|
} else {
|
|
|
|
pw_submitbtn_new.attr( 'disabled','disabled' );
|
|
|
|
pw_submitbtn_edit.attr( 'disabled','disabled' );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fix a LastPass mismatch issue, LastPass only changes pass2.
|
|
|
|
*
|
|
|
|
* This fixes the issue by copying any changes from the hidden
|
|
|
|
* pass2 field to the pass1 field.
|
|
|
|
*/
|
|
|
|
pw_field2.on( 'input propertychange', function() {
|
|
|
|
pw_field.val( pw_field2.val() );
|
|
|
|
pw_field.trigger( 'propertychange' );
|
|
|
|
} );
|
|
|
|
|
|
|
|
pw_new.on( 'click', 'button.wp-generate-pw', function(){
|
|
|
|
pw_generatebtn.hide();
|
|
|
|
pw_line.show();
|
|
|
|
generatePassword();
|
|
|
|
});
|
|
|
|
|
|
|
|
pw_togglebtn.on( 'click', function() {
|
|
|
|
var show = pw_togglebtn.attr( 'data-toggle' );
|
|
|
|
if ( show == 1 ) {
|
|
|
|
pw_field.attr( 'type', 'text' );
|
|
|
|
pw_togglebtn.attr( 'data-toggle', 0 )
|
|
|
|
.find( '.text' )
|
|
|
|
.text( 'hide' )
|
|
|
|
;
|
|
|
|
} else {
|
|
|
|
pw_field.attr( 'type', 'password' );
|
|
|
|
pw_togglebtn.attr( 'data-toggle', 1 )
|
|
|
|
.find( '.text' )
|
|
|
|
.text( 'show' )
|
|
|
|
;
|
|
|
|
}
|
|
|
|
pw_field.focus();
|
|
|
|
pw_field[0].setSelectionRange(100, 100);
|
|
|
|
});
|
|
|
|
});
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
function check_pass_strength() {
|
2013-11-18 23:40:10 -05:00
|
|
|
var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
$('#pass-strength-result').removeClass('short bad good strong');
|
|
|
|
if ( ! pass1 ) {
|
|
|
|
$('#pass-strength-result').html( pwsL10n.empty );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-28 02:47:10 -04:00
|
|
|
strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
switch ( strength ) {
|
|
|
|
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'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready( function() {
|
2013-11-18 23:40:10 -05:00
|
|
|
var $colorpicker, $stylesheet, user_id, current_user_id,
|
|
|
|
select = $( '#display_name' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2015-02-20 08:05:27 -05:00
|
|
|
$('#pass1').val('').on( 'input propertychange', check_pass_strength );
|
|
|
|
$('#pass2').val('').on( 'input propertychange', 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 );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
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();
|
|
|
|
});
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
})(jQuery);
|