mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-02 00:57:40 +02:00
Media JS: Several improvements to the Attachment views.
* Bind Attachment details updates to the Attachments initialize method. * Improve Attachment view unbinding. * Re-render Attachment views when titles and captions are updated. see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@22339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fcde71fd77
commit
f3c673558a
@ -1039,18 +1039,25 @@
|
|||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.controller = this.options.controller;
|
this.controller = this.options.controller;
|
||||||
|
|
||||||
this.model.on( 'change:sizes change:uploading', this.render, this );
|
this.model.on( 'change:sizes change:uploading change:caption change:title', this.render, this );
|
||||||
this.model.on( 'change:percent', this.progress, this );
|
this.model.on( 'change:percent', this.progress, this );
|
||||||
this.model.on( 'add', this.select, this );
|
this.model.on( 'add', this.select, this );
|
||||||
this.model.on( 'remove', this.deselect, this );
|
this.model.on( 'remove', this.deselect, this );
|
||||||
|
|
||||||
|
// Update the model's details view.
|
||||||
|
this.model.on( 'selection:single selection:unsingle', this.details, this );
|
||||||
|
this.details( this.model, this.controller.state().get('selection') );
|
||||||
|
|
||||||
// Prevent default navigation on all links.
|
// Prevent default navigation on all links.
|
||||||
this.$el.on( 'click', 'a', this.preventDefault );
|
this.$el.on( 'click', 'a', this.preventDefault );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.model.off( null, null, this );
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var state = this.controller.state(),
|
var attachment = this.model.toJSON(),
|
||||||
attachment = this.model.toJSON(),
|
|
||||||
options = _.defaults( this.model.toJSON(), {
|
options = _.defaults( this.model.toJSON(), {
|
||||||
orientation: 'landscape',
|
orientation: 'landscape',
|
||||||
uploading: false,
|
uploading: false,
|
||||||
@ -1063,7 +1070,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
options.buttons = this.buttons;
|
options.buttons = this.buttons;
|
||||||
options.describe = state.get('describe');
|
options.describe = this.controller.state().get('describe');
|
||||||
|
|
||||||
if ( 'image' === options.type )
|
if ( 'image' === options.type )
|
||||||
_.extend( options, this.imageSize() );
|
_.extend( options, this.imageSize() );
|
||||||
@ -1079,17 +1086,9 @@
|
|||||||
if ( this.selected() )
|
if ( this.selected() )
|
||||||
this.select();
|
this.select();
|
||||||
|
|
||||||
// Update the model's details view.
|
|
||||||
this.model.on( 'selection:single selection:unsingle', this.details, this );
|
|
||||||
this.details( this.model, state.get('selection') );
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
|
||||||
this.model.off( 'single', this.details, this );
|
|
||||||
},
|
|
||||||
|
|
||||||
progress: function() {
|
progress: function() {
|
||||||
if ( this.$bar && this.$bar.length )
|
if ( this.$bar && this.$bar.length )
|
||||||
this.$bar.width( this.model.get('percent') + '%' );
|
this.$bar.width( this.model.get('percent') + '%' );
|
||||||
|
Loading…
Reference in New Issue
Block a user