# Yahoo! UI Library

### layout 2.5.1

Yahoo! UI Library > layout > YAHOO.widget.Layout

Show Private Show Protected

## Class YAHOO.widget.Layout - extends YAHOO.util.Element

Provides a fixed layout containing, top, bottom, left, right and center layout units. It can be applied to either the body or an element.

### Constructor

YAHOO.widget.Layout `( el , attrs )`

Parameters:
  `el <String/HTMLElement>` The element to make contain a layout.
  `attrs <Object>` Object liternal containing configuration parameters.

### Properties

#### _bottom `- private {YAHOO.widget.LayoutUnit} A LayoutUnit instance`

Reference to the bottom LayoutUnit Object

#### _center `- private {YAHOO.widget.LayoutUnit} A LayoutUnit instance`

Reference to the center LayoutUnit Object

#### _doc `- private HTMLElement`

Reference to the root element

#### _instances `- private static Object`

Internal hash table for all layout instances

#### _isBody `- private Boolean`

Flag to determine if we are using the body as the root element.

#### _left `- private {YAHOO.widget.LayoutUnit} A LayoutUnit instance`

Reference to the left LayoutUnit Object

#### _rendered `- private Boolean`

Set to true when the layout is rendered

#### _right `- private {YAHOO.widget.LayoutUnit} A LayoutUnit instance`

Reference to the right LayoutUnit Object

#### _sizes `- private Object`

A collection of the current sizes of all usable LayoutUnits to be used for calculations

#### _top `- private {YAHOO.widget.LayoutUnit} A LayoutUnit instance`

Reference to the top LayoutUnit Object

#### _zIndex `- private Number`

The zIndex to set all LayoutUnits to

#### browser `- Object`

A modified version of the YAHOO.env.ua object

#### Properties inherited from YAHOO.util.Element:

`DOM_EVENTS`

#### Properties inherited from YAHOO.util.AttributeProvider:

`_configs`

#### Properties inherited from YAHOO.util.EventProvider:

`__yui_events, __yui_subscribers`

### Methods

#### _createUnits

`private void _createUnits ( )`
Private method to create units from the config that was passed in.

Returns: `void`

#### _setBodySize

`private void _setBodySize ( set )`
Used to set the body size of the layout, sets the height and width of the parent container

Parameters:
  `set <Boolean>` If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)

Returns: `void`

#### _setCenter

`private void _setCenter ( set )`
Used to set the size and position of the center unit

Parameters:
  `set <Boolean>` If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)

Returns: `void`

#### _setSides

`private void _setSides ( set )`
Used to set the size and position of the left, right, top and bottom units

Parameters:
  `set <Boolean>` If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)

Returns: `void`

#### _setupBodyElements

`private void _setupBodyElements ( )`
Sets up the main doc element when using the body as the main element.

Returns: `void`

#### _setupElements

`private void _setupElements ( )`
Sets up the main doc element when not using the body as the main element.

Returns: `void`

#### _stamp

`private void _stamp ( )`
Stamps the root node with a secure classname for ease of use. Also sets the this.browser.standardsMode variable.

Returns: `void`

#### addUnit

`YAHOO.widget.LayoutUnit addUnit ( cfg )`
Add a unit to this layout and if the layout is rendered, resize the layout.

Parameters:
  `cfg <Object>` The config for the LayoutUnit that you want to add

Returns: `YAHOO.widget.LayoutUnit`
  The LayoutUnit instance

#### getLayoutById

`static Object getLayoutById ( )`
Get's a layout object by the HTML id of the element associated with the Layout object.

Returns: `Object`
  The Layout Object

#### getSizes

`Object getSizes ( )`
Get a reference to the internal Layout Unit sizes object used to build the layout wireframe

Returns: `Object`
  An object of the layout unit sizes

#### getUnitById

`YAHOO.widget.LayoutUnit getUnitById ( id )`
Get the LayoutUnit by it's HTML id

Parameters:
  `id <String>` The HTML element id of the unit

Returns: `YAHOO.widget.LayoutUnit`
  The LayoutUnit instance

#### getUnitByPosition

`YAHOO.widget.LayoutUnit getUnitByPosition ( pos )`
Get the LayoutUnit by it's position in this layout

Parameters:
  `pos <String>` The position of the unit in this layout

Returns: `YAHOO.widget.LayoutUnit`
  The LayoutUnit instance

#### init

`private void init ( )`
The Layout class' initialization method

Returns: `void`

#### initAttributes

`private void initAttributes ( )`
Processes the config

Returns: `void`

#### removeUnit

`void removeUnit ( unit )`
Remove the unit from this layout and resize the layout.

Parameters:
  `unit <Object>` The LayoutUnit that you want to remove

Returns: `void`

#### render

`YAHOO.widget.Layout render ( )`
This method starts the render process, applying classnames and creating elements

Returns: `YAHOO.widget.Layout`
  The Layout instance

#### resize

`YAHOO.widget.Layout resize ( set )`
Starts the chain of resize routines that will resize all the units.

Parameters:
  `set <Boolean>` If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)

Returns: `YAHOO.widget.Layout`
  The Layout instance

#### toString

`String toString ( )`
Returns a string representing the Layout.

Returns: `String`

#### Methods inherited from YAHOO.util.Element:

`_registerHTMLAttr, addClass, addListener, appendChild, appendTo, fireQueue, getElementsByClassName, getElementsByTagName, getStyle, hasChildNodes, hasClass, initAttributes, insertBefore, on, removeChild, removeClass, removeListener, replaceChild, replaceClass, setStyle, subscribe`

#### Methods inherited from YAHOO.util.AttributeProvider:

`configureAttribute, fireBeforeChangeEvent, fireChangeEvent, get, getAttributeConfig, getAttributeKeys, refresh, register, resetAttributeConfig, resetValue, set, setAttributeConfig, setAttributes`

#### Methods inherited from YAHOO.util.EventProvider:

`createEvent, fireEvent, hasEvent, subscribe, unsubscribe, unsubscribeAll`

### Events

#### beforeHeightChange

`beforeHeightChange ( eventInfo )`
Fires before the value for the configuration attribute 'height' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### beforeMinHeightChange

`beforeMinHeightChange ( eventInfo )`
Fires before the value for the configuration attribute 'minHeight' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### beforeMinWidthChange

`beforeMinWidthChange ( eventInfo )`
Fires before the value for the configuration attribute 'minWidth' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### beforeParentChange

`beforeParentChange ( eventInfo )`
Fires before the value for the configuration attribute 'parent' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### beforeResize

`beforeResize ( )`
Firef at the beginning of the resize method. If you return false, the resize is cancelled.

#### beforeUnitsChange

`beforeUnitsChange ( eventInfo )`
Fires before the value for the configuration attribute 'units' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### beforeWidthChange

`beforeWidthChange ( eventInfo )`
Fires before the value for the configuration attribute 'width' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### heightChange

`heightChange ( eventInfo )`
Fires when the value for the configuration attribute 'height' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### minHeightChange

`minHeightChange ( eventInfo )`
Fires when the value for the configuration attribute 'minHeight' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### minWidthChange

`minWidthChange ( eventInfo )`
Fires when the value for the configuration attribute 'minWidth' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### parentChange

`parentChange ( eventInfo )`
Fires when the value for the configuration attribute 'parent' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### render

`render ( )`
Fired after the render method completes.

#### resize

`resize ( )`
Fired when this.resize is called

#### startResize

`startResize ( )`
Fired when the Resize Utility for a Unit fires it's startResize Event.

#### unitsChange

`unitsChange ( eventInfo )`
Fires when the value for the configuration attribute 'units' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### widthChange

`widthChange ( eventInfo )`
Fires when the value for the configuration attribute 'width' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### Events inherited from YAHOO.util.Element:

`appendTo, available, beforeAppendTo, beforeElementChange, contentReady, elementChange,`

### Configuration Attributes

#### height `- Number`

The height in pixels

#### minHeight `- Number`

The minimum height in pixels

#### minWidth `- Number`

The minimum width in pixels

#### parent `- Object YAHOO.widget.Layout`

If this layout is to be used as a child of another Layout instance, this config will bind the resize events together.

#### units `- Array`

An array of config definitions for the LayoutUnits to add to this layout

#### width `- Number`

The width in pixels

#### Configuration attributes inherited from YAHOO.util.Element:

`element,`

Copyright © 2007 Yahoo! Inc. All rights reserved.