API: layout YAHOO.widget.Layout (YUI Library)

# Yahoo! UI Library

### layout 2.8.0r4

Yahoo! UI Library > layout > YAHOO.widget.Layout
Search:
Filters Show Private Show Protected Show Deprecated

## 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

#### _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.

#### _rendered - `private Boolean`

Set to true when the layout is rendered

#### _sizes - `private Object`

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

#### _units - `private Object`

An object literal that contains a list of units in the layout

#### _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`

### 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

#### destroy

`void destroy ( )`
Removes this layout from the page and destroys all units that it contains. This will destroy all data inside the layout and it's children.

Returns: `void`

#### 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 ( Boolean/Event )`
Starts the chain of resize routines that will resize all the units.

Parameters:
  `Boolean/Event <object>` set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units). This can also have an attribute event passed to it.

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

#### toString

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

Returns: `String`

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

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

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

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

### Events

#### beforeHeightChange

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

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

#### beforeMinHeightChange

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

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

#### beforeMinWidthChange

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

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

#### beforeParentChange

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

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

#### beforeResize

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

#### beforeUnitsChange

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

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

#### beforeWidthChange

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

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

#### heightChange

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

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

#### minHeightChange

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

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

#### minWidthChange

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

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

#### parentChange

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

Parameters:
  `event <{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 ( event )`
Fires when the value for the configuration attribute 'units' changes.

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

#### widthChange

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

Parameters:
  `event <{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 © 2009 Yahoo! Inc. All rights reserved.