2015-03-05 04:12:26 +00:00
|
|
|
/*globals _, Backbone */
|
2015-02-22 06:56:27 +00:00
|
|
|
|
2015-02-09 00:43:50 +00:00
|
|
|
/**
|
|
|
|
* wp.media.view.ButtonGroup
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
2015-03-31 02:03:29 +00:00
|
|
|
var $ = Backbone.$,
|
2015-02-09 00:43:50 +00:00
|
|
|
ButtonGroup;
|
|
|
|
|
2015-03-31 02:03:29 +00:00
|
|
|
ButtonGroup = wp.media.View.extend({
|
2015-02-09 00:43:50 +00:00
|
|
|
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 {
|
2015-03-31 02:03:29 +00:00
|
|
|
return new wp.media.view.Button( button ).render();
|
2015-02-09 00:43:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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 16:01:29 +00:00
|
|
|
module.exports = ButtonGroup;
|