# all files / src/layouts/ PanelLayout.js

93.33% Statements 14/15
100% Branches 8/8
50% Functions 1/2
93.33% Lines 14/15

    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67

    1×

    134×

    134×

    134×
    134×
    29×

    134×
    29×

    134×
    105×

    134×
    28×

    1×

    1×

     /**
     * PanelLayouts expand to cover the entire area of their parent. They can be configured with scrolling, padding,
     * and a frame, and are often used together with {@link OO.ui.StackLayout StackLayouts}.
     *
     *     @example
     *     // Example of a panel layout
     *     var panel = new OO.ui.PanelLayout( {
     *         expanded: false,
     *         framed: true,
     *         padded: true,
     *         $content: $( '<p>A panel layout with padding and a frame.</p>' )
     *     } );
     *     $( 'body' ).append( panel.$element );
     *
     * @class
     * @extends OO.ui.Layout
     *
     * @constructor
     * @param {Object} [config] Configuration options
     * @cfg {boolean} [scrollable=false] Allow vertical scrolling
     * @cfg {boolean} [padded=false] Add padding between the content and the edges of the panel.
     * @cfg {boolean} [expanded=true] Expand the panel to fill the entire parent element.
     * @cfg {boolean} [framed=false] Render the panel with a frame to visually separate it from outside content.
     */
    OO.ui.PanelLayout = function OoUiPanelLayout( config ) {
    	// Configuration initialization
    	config = $.extend( {
    		scrollable: false,
    		padded: false,
    		expanded: true,
    		framed: false
    	}, config );

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

    	// Initialization
    	this.$element.addClass( 'oo-ui-panelLayout' );
    	if ( config.scrollable ) {
    		this.$element.addClass( 'oo-ui-panelLayout-scrollable' );
    	}
    	if ( config.padded ) {
    		this.$element.addClass( 'oo-ui-panelLayout-padded' );
    	}
    	if ( config.expanded ) {
    		this.$element.addClass( 'oo-ui-panelLayout-expanded' );
    	}
    	if ( config.framed ) {
    		this.$element.addClass( 'oo-ui-panelLayout-framed' );
    	}
    };

    /* Setup */

    OO.inheritClass( OO.ui.PanelLayout, OO.ui.Layout );

    /* Methods */

    /**
     * Focus the panel layout
     *
     * The default implementation just focuses the first focusable element in the panel
     */
    OO.ui.PanelLayout.prototype.focus = function () {
    	OO.ui.findFocusable( this.$element ).focus();
    };