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:
parent
4e36f55df7
commit
110978e2d3
|
@ -3566,13 +3566,15 @@
|
||||||
models = collection.models.slice( modelIndex, singleIndex + 1 );
|
models = collection.models.slice( modelIndex, singleIndex + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
selection.add( models ).single( model );
|
selection.add( models );
|
||||||
|
selection.single( model );
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If the `method` is set to `toggle`, just flip the selection
|
// If the `method` is set to `toggle`, just flip the selection
|
||||||
// status, regardless of whether the model is the single model.
|
// status, regardless of whether the model is the single model.
|
||||||
} else if ( 'toggle' === method ) {
|
} else if ( 'toggle' === method ) {
|
||||||
selection[ this.selected() ? 'remove' : 'add' ]( model ).single( model );
|
selection[ this.selected() ? 'remove' : 'add' ]( model );
|
||||||
|
selection.single( model );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3589,7 +3591,8 @@
|
||||||
// If the model is not selected, run the `method` on the
|
// If the model is not selected, run the `method` on the
|
||||||
// selection. By default, we `reset` the selection, but the
|
// selection. By default, we `reset` the selection, but the
|
||||||
// `method` can be set to `add` the model to the selection.
|
// `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.
|
// Silently shift the model to its new index.
|
||||||
collection.remove( model, {
|
collection.remove( model, {
|
||||||
silent: true
|
silent: true
|
||||||
}).add( model, {
|
});
|
||||||
|
collection.add( model, {
|
||||||
silent: true,
|
silent: true,
|
||||||
at: ui.item.index()
|
at: ui.item.index()
|
||||||
});
|
});
|
||||||
|
|
|
@ -340,10 +340,12 @@ window.wp = window.wp || {};
|
||||||
// The constructor for the `Views` manager.
|
// The constructor for the `Views` manager.
|
||||||
Subviews: wp.Backbone.Subviews,
|
Subviews: wp.Backbone.Subviews,
|
||||||
|
|
||||||
constructor: function() {
|
constructor: function( options ) {
|
||||||
this.views = new this.Subviews( this, this.views );
|
this.views = new this.Subviews( this, this.views );
|
||||||
this.on( 'ready', this.ready, this );
|
this.on( 'ready', this.ready, this );
|
||||||
|
|
||||||
|
this.options = options || {};
|
||||||
|
|
||||||
Backbone.View.apply( this, arguments );
|
Backbone.View.apply( this, arguments );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue