mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Media JS: Apply selection when Attachment models are initially rendered.
This allows us to automatically retain selections when the library context is changed (e.g. when searching. This changes the Attachment view's select() and deselect() methods so that they can be triggered directly. see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@21773 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8763c79698
commit
1e28b7c8cb
@ -547,6 +547,10 @@
|
||||
else
|
||||
delete this.$bar;
|
||||
|
||||
// Check if the model is selected.
|
||||
if ( this.controller.selection.has( this.model ) )
|
||||
this.select();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -561,13 +565,21 @@
|
||||
},
|
||||
|
||||
select: function( model, collection ) {
|
||||
if ( collection === this.controller.selection )
|
||||
this.$el.addClass('selected');
|
||||
// If a collection is provided, check if it's the selection.
|
||||
// If it's not, bail; we're in another selection's event loop.
|
||||
if ( collection && collection !== this.controller.selection )
|
||||
return;
|
||||
|
||||
this.$el.addClass('selected');
|
||||
},
|
||||
|
||||
deselect: function( model, collection ) {
|
||||
if ( collection === this.controller.selection )
|
||||
this.$el.removeClass('selected');
|
||||
// If a collection is provided, check if it's the selection.
|
||||
// If it's not, bail; we're in another selection's event loop.
|
||||
if ( collection && collection !== this.controller.selection )
|
||||
return;
|
||||
|
||||
this.$el.removeClass('selected');
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user