mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
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:
parent
2af40744ec
commit
df241d2259
@ -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();
|
||||
|
2
wp-includes/js/media-grid.min.js
vendored
2
wp-includes/js/media-grid.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user