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

See #24716.

Built from https://develop.svn.wordpress.org/trunk@29072


git-svn-id: http://core.svn.wordpress.org/trunk@28858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-10 18:10:15 +00:00
parent 2af40744ec
commit df241d2259
2 changed files with 9 additions and 7 deletions

View File

@ -432,8 +432,8 @@
this.on( 'router:render', this.browseRouter, this );
}
this.options.hasPrevious = ( this.options.library.indexOf( this.options.model ) > 0 ) ? true : false;
this.options.hasNext = ( this.options.library.indexOf( this.options.model ) < this.options.library.length - 1 ) ? true : false;
this.options.hasPrevious = this.hasPrevious();
this.options.hasNext = this.hasNext();
// Initialize modal container view.
if ( this.options.modal ) {
@ -545,8 +545,9 @@
* Click handler to switch to the previous media item.
*/
previousMediaItem: function() {
if ( ! this.options.hasPrevious )
if ( ! this.hasPrevious() ) {
return;
}
this.modal.close();
this.trigger( 'edit:attachment:previous', this.model );
},
@ -555,8 +556,9 @@
* Click handler to switch to the next media item.
*/
nextMediaItem: function() {
if ( ! this.options.hasNext )
if ( ! this.hasNext() ) {
return;
}
this.modal.close();
this.trigger( 'edit:attachment:next', this.model );
},
@ -588,14 +590,14 @@
}
// The right arrow key
if ( event.keyCode === 39 ) {
if ( ! this.hasNext ) {
if ( ! this.hasNext() ) {
return;
}
this.nextMediaItem();
}
// The left arrow key
if ( event.keyCode === 37 ) {
if ( ! this.hasPrevious ) {
if ( ! this.hasPrevious() ) {
return;
}
this.previousMediaItem();

File diff suppressed because one or more lines are too long