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: https://develop.svn.wordpress.org/trunk@21773 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
073cd101f5
commit
5b6d894b43
@ -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…
x
Reference in New Issue
Block a user