2015-03-04 23:12:26 -05:00
|
|
|
/*globals _, Backbone */
|
2015-02-22 01:56:27 -05:00
|
|
|
|
2015-02-08 19:43:50 -05:00
|
|
|
/**
|
|
|
|
* wp.media.view.ButtonGroup
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
|
|
|
var View = require( './view.js' ),
|
|
|
|
Button = require( './button.js' ),
|
2015-03-04 23:12:26 -05:00
|
|
|
$ = Backbone.$,
|
2015-02-08 19:43:50 -05:00
|
|
|
ButtonGroup;
|
|
|
|
|
|
|
|
ButtonGroup = View.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
className: 'button-group button-large media-button-group',
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
/**
|
|
|
|
* @member {wp.media.view.Button[]}
|
|
|
|
*/
|
|
|
|
this.buttons = _.map( this.options.buttons || [], function( button ) {
|
|
|
|
if ( button instanceof Backbone.View ) {
|
|
|
|
return button;
|
|
|
|
} else {
|
|
|
|
return new Button( button ).render();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
delete this.options.buttons;
|
|
|
|
|
|
|
|
if ( this.options.classes ) {
|
|
|
|
this.$el.addClass( this.options.classes );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {wp.media.view.ButtonGroup}
|
|
|
|
*/
|
|
|
|
render: function() {
|
|
|
|
this.$el.html( $( _.pluck( this.buttons, 'el' ) ).detach() );
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-09 11:01:29 -05:00
|
|
|
module.exports = ButtonGroup;
|