# all files / src/layouts/ HorizontalLayout.js

100% Statements 9/9
75% Branches 3/4
100% Functions 1/1
100% Lines 9/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47

    1×

    4×

    4×

    4×

    4×
    4×
    2×

    1×
    1×
     /**
     * HorizontalLayout arranges its contents in a single line (using `display: inline-block` for its
     * items), with small margins between them. Convenient when you need to put a number of block-level
     * widgets on a single line next to each other.
     *
     * Note that inline elements, such as OO.ui.ButtonWidgets, do not need this wrapper.
     *
     *     @example
     *     // HorizontalLayout with a text input and a label
     *     var layout = new OO.ui.HorizontalLayout( {
     *       items: [
     *         new OO.ui.LabelWidget( { label: 'Label' } ),
     *         new OO.ui.TextInputWidget( { value: 'Text' } )
     *       ]
     *     } );
     *     $( 'body' ).append( layout.$element );
     *
     * @class
     * @extends OO.ui.Layout
     * @mixins OO.ui.mixin.GroupElement
     *
     * @constructor
     * @param {Object} [config] Configuration options
     * @cfg {OO.ui.Widget[]|OO.ui.Layout[]} [items] Widgets or other layouts to add to the layout.
     */
    OO.ui.HorizontalLayout = function OoUiHorizontalLayout( config ) {
    	// Configuration initialization
    	config = config || {};

    	// Parent constructor
    	OO.ui.HorizontalLayout.parent.call( this, config );

    	// Mixin constructors
    	OO.ui.mixin.GroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) );

    	// Initialization
    	this.$element.addClass( 'oo-ui-horizontalLayout' );
    	if ( Array.isArray( config.items ) ) {
    		this.addItems( config.items );
    	}
    };

    /* Setup */

    OO.inheritClass( OO.ui.HorizontalLayout, OO.ui.Layout );
    OO.mixinClass( OO.ui.HorizontalLayout, OO.ui.mixin.GroupElement );