Update media-views and wp.Backbone.View for Backbone 1.1.

* Collection set/add/remove/reset methods now return models, not `this`, so they can no longer be chained.
 * Options passed to Backbone.View's constructor are no longer attached automatically. wp.Backbone.View now does this automatically.

See [27170] for Backbone 1.1 itself.

props gcorne.
fixes #26799.


git-svn-id: https://develop.svn.wordpress.org/trunk@27171 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2014-02-13 07:36:01 +00:00
parent 4e36f55df7
commit 110978e2d3
2 changed files with 11 additions and 5 deletions

View File

@ -3566,13 +3566,15 @@
models = collection.models.slice( modelIndex, singleIndex + 1 );
}
selection.add( models ).single( model );
selection.add( models );
selection.single( model );
return;
// If the `method` is set to `toggle`, just flip the selection
// status, regardless of whether the model is the single model.
} else if ( 'toggle' === method ) {
selection[ this.selected() ? 'remove' : 'add' ]( model ).single( model );
selection[ this.selected() ? 'remove' : 'add' ]( model );
selection.single( model );
return;
}
@ -3589,7 +3591,8 @@
// If the model is not selected, run the `method` on the
// selection. By default, we `reset` the selection, but the
// `method` can be set to `add` the model to the selection.
selection[ method ]( model ).single( model );
selection[ method ]( model );
selection.single( model );
}
},
@ -3994,7 +3997,8 @@
// Silently shift the model to its new index.
collection.remove( model, {
silent: true
}).add( model, {
});
collection.add( model, {
silent: true,
at: ui.item.index()
});

View File

@ -340,10 +340,12 @@ window.wp = window.wp || {};
// The constructor for the `Views` manager.
Subviews: wp.Backbone.Subviews,
constructor: function() {
constructor: function( options ) {
this.views = new this.Subviews( this, this.views );
this.on( 'ready', this.ready, this );
this.options = options || {};
Backbone.View.apply( this, arguments );
},