Make WordPress Core

Changeset 29556


Ignore:
Timestamp:
08/20/2014 07:28:11 PM (11 years ago)
Author:
wonderboymusic
Message:

Cleanup after [29220]:

  • media.view.Attachment should not reach outside itself with global jQuery selectors
  • media.view.Attachment.Details will re-render when media.view.Attachment's single status changes. Add a ready callback to apply initial input focus

See #23560.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-views.js

    r29555 r29556  
    48944894                selection.add( models );
    48954895                selection.single( model );
    4896 
    4897                 // When selecting attachments, focus should be transferred to the right details panel
    4898                 if ( ! isTouchDevice ) {
    4899                     $('.attachment-details input').first().focus();
    4900                 }
    4901 
    49024896                return;
    49034897
     
    49074901                selection[ this.selected() ? 'remove' : 'add' ]( model );
    49084902                selection.single( model );
    4909 
    4910                 if ( ! isTouchDevice && this.selected() ) {
    4911                     // When selecting an attachment, focus should be transferred to the right details panel
    4912                     $('.attachment-details input').first().focus();
    4913                 }
    4914 
    49154903                return;
    49164904            } else if ( 'add' === method ) {
     
    49754963
    49764964            // Add 'selected' class to model, set aria-checked to true and make the checkbox tabable.
    4977             this.$el.addClass( 'selected' ).attr( 'aria-checked', true )
    4978                     .find( '.check' ).attr( 'tabindex', '0' );
    4979 
    4980             // When selecting an attachment, focus should be transferred to the right details panel.
    4981             if ( ! isTouchDevice ) {
    4982                 $('.attachment-details input').first().focus();
    4983             }
     4965            this.$el.addClass( 'selected' ).attr( 'aria-checked', true ).find( '.check' ).attr( 'tabindex', '0' );
    49844966        },
    49854967        /**
     
    65036485                rerenderOnModelChange: false
    65046486            });
     6487
     6488            this.on( 'ready', this.initialFocus );
    65056489            /**
    65066490             * call 'initialize' directly on the parent class
    65076491             */
    65086492            media.view.Attachment.prototype.initialize.apply( this, arguments );
     6493        },
     6494
     6495        initialFocus: function() {
     6496            if ( ! isTouchDevice ) {
     6497                this.$( ':input' ).eq( 0 ).focus();
     6498            }
    65096499        },
    65106500        /**
Note: See TracChangeset for help on using the changeset viewer.