Media JS: Properly build detail views when the selection's single model changes. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22337 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c67117e150
commit
6deb5064ee
@ -135,7 +135,6 @@
|
|||||||
|
|
||||||
this.on( 'activate', this.activate, this );
|
this.on( 'activate', this.activate, this );
|
||||||
this.on( 'deactivate', this.deactivate, this );
|
this.on( 'deactivate', this.deactivate, this );
|
||||||
this.on( 'change:details', this.details, this );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
@ -147,6 +146,9 @@
|
|||||||
// automatically select any uploading attachments.
|
// automatically select any uploading attachments.
|
||||||
if ( this.get('multiple') )
|
if ( this.get('multiple') )
|
||||||
wp.Uploader.queue.on( 'add', this.selectUpload, this );
|
wp.Uploader.queue.on( 'add', this.selectUpload, this );
|
||||||
|
|
||||||
|
this.get('selection').on( 'selection:single', this.buildDetails, this );
|
||||||
|
this.get('selection').on( 'selection:unsingle', this.clearDetails, this );
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
@ -155,6 +157,8 @@
|
|||||||
this.get('selection').off( 'add remove', toolbar.visibility, toolbar );
|
this.get('selection').off( 'add remove', toolbar.visibility, toolbar );
|
||||||
|
|
||||||
wp.Uploader.queue.off( 'add', this.selectUpload, this );
|
wp.Uploader.queue.off( 'add', this.selectUpload, this );
|
||||||
|
this.get('selection').off( 'selection:single', this.buildDetails, this );
|
||||||
|
this.get('selection').off( 'selection:unsingle', this.clearDetails, this );
|
||||||
},
|
},
|
||||||
|
|
||||||
toolbar: function() {
|
toolbar: function() {
|
||||||
@ -179,7 +183,7 @@
|
|||||||
controller: frame
|
controller: frame
|
||||||
}) );
|
}) );
|
||||||
|
|
||||||
this.details({ silent: true });
|
this.details();
|
||||||
frame.sidebar().add({
|
frame.sidebar().add({
|
||||||
search: new media.view.Search({
|
search: new media.view.Search({
|
||||||
controller: frame,
|
controller: frame,
|
||||||
@ -211,24 +215,28 @@
|
|||||||
this.get('selection').add( attachment );
|
this.get('selection').add( attachment );
|
||||||
},
|
},
|
||||||
|
|
||||||
details: function( options ) {
|
details: function() {
|
||||||
var model = this.get('selection').single(),
|
var single = this.get('selection').single();
|
||||||
view;
|
this[ single ? 'buildDetails' : 'clearDetails' ]( single );
|
||||||
|
},
|
||||||
|
|
||||||
if ( model ) {
|
buildDetails: function( model ) {
|
||||||
view = new media.view.Attachment.Details({
|
this.frame.sidebar().add( 'details', new media.view.Attachment.Details({
|
||||||
controller: this.frame,
|
controller: this.frame,
|
||||||
model: model,
|
model: model,
|
||||||
priority: 80
|
priority: 80
|
||||||
});
|
}).render() );
|
||||||
} else {
|
return this;
|
||||||
view = new Backbone.View();
|
},
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! options || ! options.silent )
|
clearDetails: function( model ) {
|
||||||
view.render();
|
if ( this.get('selection').single() )
|
||||||
|
return this;
|
||||||
|
|
||||||
this.frame.sidebar().add( 'details', view, options );
|
this.frame.sidebar().add( 'details', new Backbone.View({
|
||||||
|
priority: 80
|
||||||
|
}).render() );
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleSelection: function( model ) {
|
toggleSelection: function( model ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user