Make WordPress Core

Changeset 34078 for branches/4.3


Ignore:
Timestamp:
09/12/2015 12:29:54 PM (10 years ago)
Author:
ocean90
Message:

Passwords: Refresh password fields when content is pasted into fields.

Use feature detection to determine whether password inputs should use the keyup or input event.

Merge of [34060] to the 4.3 branch.

Props peterwilsoncc, adamsilverstein.
Fixes #33398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3/src/wp-admin/js/user-profile.js

    r34063 r34078  
    88        $pass1Text,
    99        $pass1Label,
    10 
    1110        $pass2,
    12 
    1311        $weakRow,
    1412        $weakCheckbox,
    15 
    1613        $toggleButton,
    1714        $submitButtons,
    1815        $submitButton,
    19         currentPass;
     16        currentPass,
     17        inputEvent;
     18
     19    /*
     20     * Use feature detection to determine whether password inputs should use
     21     * the `keyup` or `input` event. Input is preferred but lacks support
     22     * in legacy browsers.
     23     */
     24    if ( 'oninput' in document.createElement( 'input' ) ) {
     25        inputEvent = 'input';
     26    } else {
     27        inputEvent = 'keyup';
     28    }
    2029
    2130    function generatePassword() {
     
    4958            .data( 'pw', $pass1.data( 'pw' ) )
    5059            .val( $pass1.val() )
    51             .on( 'keyup', function () {
     60            .on( inputEvent, function () {
    5261                if ( $pass1Text.val() === currentPass ) {
    5362                    return;
     
    6473        }
    6574
    66         $pass1.on( 'keyup pwupdate', function () {
     75        $pass1.on( inputEvent + ' pwupdate', function () {
    6776            if ( $pass1.val() === currentPass ) {
    6877                return;
     
    173182         * pass2 field to the pass1 field, then running check_pass_strength.
    174183         */
    175         $pass2 = $('#pass2').on( 'keyup', function () {
     184        $pass2 = $('#pass2').on( inputEvent, function () {
    176185            if ( $pass2.val().length > 0 ) {
    177186                $pass1.val( $pass2.val() );
     
    258267            select = $( '#display_name' );
    259268
    260         $('#pass1').val('').on( 'keyup pwupdate', check_pass_strength );
     269        $('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
    261270        $('#pass-strength-result').show();
    262271        $('.color-palette').click( function() {
Note: See TracChangeset for help on using the changeset viewer.