Make WordPress Core

Changeset 29072


Ignore:
Timestamp:
07/10/2014 06:09:46 PM (10 years ago)
Author:
wonderboymusic
Message:

Media Grid: hasNext and hasPrevious are functions that must be called. Otherwise they are always truthy properties.

See #24716.

File:
1 edited

Legend:

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

    r29071 r29072  
    433433            }
    434434
    435             this.options.hasPrevious = ( this.options.library.indexOf( this.options.model ) > 0 ) ? true : false;
    436             this.options.hasNext = ( this.options.library.indexOf( this.options.model ) < this.options.library.length - 1 ) ? true : false;
     435            this.options.hasPrevious = this.hasPrevious();
     436            this.options.hasNext = this.hasNext();
    437437
    438438            // Initialize modal container view.
     
    546546         */
    547547        previousMediaItem: function() {
    548             if ( ! this.options.hasPrevious )
     548            if ( ! this.hasPrevious() ) {
    549549                return;
     550            }
    550551            this.modal.close();
    551552            this.trigger( 'edit:attachment:previous', this.model );
     
    556557         */
    557558        nextMediaItem: function() {
    558             if ( ! this.options.hasNext )
     559            if ( ! this.hasNext() ) {
    559560                return;
     561            }
    560562            this.modal.close();
    561563            this.trigger( 'edit:attachment:next', this.model );
     
    589591            // The right arrow key
    590592            if ( event.keyCode === 39 ) {
    591                 if ( ! this.hasNext ) {
     593                if ( ! this.hasNext() ) {
    592594                    return;
    593595                }
     
    596598            // The left arrow key
    597599            if ( event.keyCode === 37 ) {
    598                 if ( ! this.hasPrevious ) {
     600                if ( ! this.hasPrevious() ) {
    599601                    return;
    600602                }
Note: See TracChangeset for help on using the changeset viewer.