CoreFiles by mySites.guru
button-group.js48 lines, 958 bytes, from wordpress-4.2-beta2.zip
Raw History Compare with 4.2-beta1
md5
0c52dd12bb812b5bdafecc5ef77aa11d
sha1
38a92aa5ddab12cf714ff85612499fc075fab7fe
sha256
07c60c94d3de1e489ed0d8752682fea16166e48a5514c0a5ceb2228b6de38ae0
/*globals _, Backbone */

/**
 * 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' ),
	$ = Backbone.$,
	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;
	}
});

module.exports = ButtonGroup;

The same content is in 3 releases, WordPress 4.2-beta1 to 4.2-beta3. See them all, or every version of this file.