Add Backbone property to the wp-backbone namespace. See #24424.

git-svn-id: http://core.svn.wordpress.org/trunk@24367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2013-05-26 06:34:33 +00:00
parent c4fe4ebd42
commit 452c0f4166
2 changed files with 17 additions and 13 deletions

View File

@ -854,12 +854,12 @@
// //
// This behavior has since been removed, and should not be used // This behavior has since been removed, and should not be used
// outside of the media manager. // outside of the media manager.
media.View = wp.View.extend({ media.View = wp.Backbone.View.extend({
constructor: function( options ) { constructor: function( options ) {
if ( options && options.controller ) if ( options && options.controller )
this.controller = options.controller; this.controller = options.controller;
wp.View.apply( this, arguments ); wp.Backbone.View.apply( this, arguments );
}, },
dispose: function() { dispose: function() {
@ -883,7 +883,7 @@
remove: function() { remove: function() {
this.dispose(); this.dispose();
return wp.View.prototype.remove.apply( this, arguments ); return wp.Backbone.View.prototype.remove.apply( this, arguments );
} }
}); });

View File

@ -26,18 +26,22 @@ window.wp = window.wp || {};
}); });
// wp.Subviews // Create the WordPress Backbone namespace.
// ----------- wp.Backbone = {};
// wp.Backbone.Subviews
// --------------------
// //
// A subview manager. // A subview manager.
wp.Subviews = function( view, views ) { wp.Backbone.Subviews = function( view, views ) {
this.view = view; this.view = view;
this._views = _.isArray( views ) ? { '': views } : views || {}; this._views = _.isArray( views ) ? { '': views } : views || {};
}; };
wp.Subviews.extend = Backbone.Model.extend; wp.Backbone.Subviews.extend = Backbone.Model.extend;
_.extend( wp.Subviews.prototype, { _.extend( wp.Backbone.Subviews.prototype, {
// ### Fetch all of the subviews // ### Fetch all of the subviews
// //
// Returns an array of all subviews. // Returns an array of all subviews.
@ -138,7 +142,7 @@ window.wp = window.wp || {};
this._views[ selector ] = next; this._views[ selector ] = next;
_.each( views, function( subview ) { _.each( views, function( subview ) {
var constructor = subview.Views || wp.Subviews, var constructor = subview.Views || wp.Backbone.Subviews,
subviews = subview.views = subview.views || new constructor( subview ); subviews = subview.views = subview.views || new constructor( subview );
subviews.parent = this.view; subviews.parent = this.view;
subviews.selector = selector; subviews.selector = selector;
@ -353,13 +357,13 @@ window.wp = window.wp || {};
}); });
// wp.View // wp.Backbone.View
// ------- // ----------------
// //
// The base view class. // The base view class.
wp.View = Backbone.View.extend({ wp.Backbone.View = Backbone.View.extend({
// The constructor for the `Views` manager. // The constructor for the `Views` manager.
Subviews: wp.Subviews, Subviews: wp.Backbone.Subviews,
constructor: function() { constructor: function() {
this.views = new this.Subviews( this, this.views ); this.views = new this.Subviews( this, this.views );