2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.net/yui/license.txt
8 * @description <p>Provides a fixed layout containing, top, bottom, left, right and center layout units. It can be applied to either the body or an element.</p>
9 * @namespace YAHOO.widget
10 * @requires yahoo, dom, element, event
14 var Dom = YAHOO.util.Dom,
15 Event = YAHOO.util.Event,
21 * @extends YAHOO.util.Element
22 * @description <p>Provides a fixed layout containing, top, bottom, left, right and center layout units. It can be applied to either the body or an element.</p>
23 * @param {String/HTMLElement} el The element to make contain a layout.
24 * @param {Object} attrs Object liternal containing configuration parameters.
27 var Layout = function(el, config) {
28 if (Lang.isObject(el) && !el.tagName) {
32 if (Lang.isString(el)) {
43 attributes: config || {}
46 Layout.superclass.constructor.call(this, oConfig.element, oConfig.attributes);
52 * @property _instances
53 * @description Internal hash table for all layout instances
56 Layout._instances = {};
59 * @method getLayoutById
60 * @description Get's a layout object by the HTML id of the element associated with the Layout object.
61 * @return {Object} The Layout Object
63 Layout.getLayoutById = function(id) {
64 if (Layout._instances[id]) {
65 return Layout._instances[id];
70 YAHOO.extend(Layout, YAHOO.util.Element, {
73 * @description A modified version of the YAHOO.env.ua object
78 b.standardsMode = false;
85 * @description An object literal that contains a list of units in the layout
92 * @description Set to true when the layout is rendered
99 * @description The zIndex to set all LayoutUnits to
106 * @description A collection of the current sizes of all usable LayoutUnits to be used for calculations
112 * @method _setBodySize
113 * @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
114 * @description Used to set the body size of the layout, sets the height and width of the parent container
116 _setBodySize: function(set) {
118 set = ((set === false) ? false : true);
121 h = Dom.getClientHeight();
122 w = Dom.getClientWidth();
124 h = parseInt(this.getStyle('height'), 10);
125 w = parseInt(this.getStyle('width'), 10);
127 w = this.get('element').clientWidth;
130 h = this.get('element').clientHeight;
133 if (this.get('minWidth')) {
134 if (w < this.get('minWidth')) {
135 w = this.get('minWidth');
138 if (this.get('minHeight')) {
139 if (h < this.get('minHeight')) {
140 h = this.get('minHeight');
144 Dom.setStyle(this._doc, 'height', h + 'px');
145 Dom.setStyle(this._doc, 'width', w + 'px');
147 this._sizes.doc = { h: h, w: w };
153 * @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
154 * @description Used to set the size and position of the left, right, top and bottom units
156 _setSides: function(set) {
157 var h1 = ((this._units.top) ? this._units.top.get('height') : 0),
158 h2 = ((this._units.bottom) ? this._units.bottom.get('height') : 0),
159 h = this._sizes.doc.h,
160 w = this._sizes.doc.w;
161 set = ((set === false) ? false : true);
164 h: h1, w: ((this._units.top) ? w : 0),
167 this._sizes.bottom = {
168 h: h2, w: ((this._units.bottom) ? w : 0)
171 var newH = (h - (h1 + h2));
174 h: newH, w: ((this._units.left) ? this._units.left.get('width') : 0)
176 this._sizes.right = {
177 h: newH, w: ((this._units.right) ? this._units.right.get('width') : 0),
178 l: ((this._units.right) ? (w - this._units.right.get('width')) : 0),
179 t: ((this._units.top) ? this._sizes.top.h : 0)
182 if (this._units.right && set) {
183 this._units.right.set('top', this._sizes.right.t);
184 if (!this._units.right._collapsing) {
185 this._units.right.set('left', this._sizes.right.l);
187 this._units.right.set('height', this._sizes.right.h, true);
189 if (this._units.left) {
190 this._sizes.left.l = 0;
191 if (this._units.top) {
192 this._sizes.left.t = this._sizes.top.h;
194 this._sizes.left.t = 0;
197 this._units.left.set('top', this._sizes.left.t);
198 this._units.left.set('height', this._sizes.left.h, true);
199 this._units.left.set('left', 0);
202 if (this._units.bottom) {
203 this._sizes.bottom.t = this._sizes.top.h + this._sizes.left.h;
205 this._units.bottom.set('top', this._sizes.bottom.t);
206 this._units.bottom.set('width', this._sizes.bottom.w, true);
209 if (this._units.top) {
211 this._units.top.set('width', this._sizes.top.w, true);
214 this._setCenter(set);
219 * @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
220 * @description Used to set the size and position of the center unit
222 _setCenter: function(set) {
223 set = ((set === false) ? false : true);
224 var h = this._sizes.left.h;
225 var w = (this._sizes.doc.w - (this._sizes.left.w + this._sizes.right.w));
227 this._units.center.set('height', h, true);
228 this._units.center.set('width', w, true);
229 this._units.center.set('top', this._sizes.top.h);
230 this._units.center.set('left', this._sizes.left.w);
232 this._sizes.center = { h: h, w: w, t: this._sizes.top.h, l: this._sizes.left.w };
236 * @description Get a reference to the internal Layout Unit sizes object used to build the layout wireframe
237 * @return {Object} An object of the layout unit sizes
239 getSizes: function() {
243 * @method getUnitById
244 * @param {String} id The HTML element id of the unit
245 * @description Get the LayoutUnit by it's HTML id
246 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
248 getUnitById: function(id) {
249 return YAHOO.widget.LayoutUnit.getLayoutUnitById(id);
252 * @method getUnitByPosition
253 * @param {String} pos The position of the unit in this layout
254 * @description Get the LayoutUnit by it's position in this layout
255 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
257 getUnitByPosition: function(pos) {
259 pos = pos.toLowerCase();
260 if (this._units[pos]) {
261 return this._units[pos];
269 * @param {Object} unit The LayoutUnit that you want to remove
270 * @description Remove the unit from this layout and resize the layout.
272 removeUnit: function(unit) {
273 delete this._units[unit.get('position')];
278 * @param {Object} cfg The config for the LayoutUnit that you want to add
279 * @description Add a unit to this layout and if the layout is rendered, resize the layout.
280 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
282 addUnit: function(cfg) {
286 if (this._units[cfg.position]) {
293 if (Dom.get(cfg.id)) {
294 element = Dom.get(cfg.id);
300 element = cfg.element;
304 el = document.createElement('div');
305 var id = Dom.generateId();
310 element = document.createElement('div');
312 Dom.addClass(element, 'yui-layout-wrap');
313 if (this.browser.ie && !this.browser.standardsMode) {
315 element.style.zoom = 1;
319 el.insertBefore(element, el.firstChild);
321 el.appendChild(element);
323 this._doc.appendChild(el);
325 var h = false, w = false;
328 h = parseInt(cfg.height, 10);
331 w = parseInt(cfg.width, 10);
334 YAHOO.lang.augmentObject(unitConfig, cfg); // break obj ref
336 unitConfig.parent = this;
337 unitConfig.wrap = element;
338 unitConfig.height = h;
339 unitConfig.width = w;
341 var unit = new YAHOO.widget.LayoutUnit(el, unitConfig);
343 unit.on('heightChange', this.resize, this, true);
344 unit.on('widthChange', this.resize, this, true);
345 unit.on('gutterChange', this.resize, this, true);
346 this._units[cfg.position] = unit;
348 if (this._rendered) {
356 * @method _createUnits
357 * @description Private method to create units from the config that was passed in.
359 _createUnits: function() {
360 var units = this.get('units');
361 for (var i in units) {
362 if (Lang.hasOwnProperty(units, i)) {
363 this.addUnit(units[i]);
369 * @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units)
370 * @description Starts the chain of resize routines that will resize all the units.
371 * @return {<a href="YAHOO.widget.Layout.html">YAHOO.widget.Layout</a>} The Layout instance
373 resize: function(set) {
374 set = ((set === false) ? false : true);
376 var retVal = this.fireEvent('beforeResize');
377 if (retVal === false) {
380 if (this.browser.ie) {
382 Dom.removeClass(document.documentElement, 'yui-layout');
383 Dom.addClass(document.documentElement, 'yui-layout');
385 this.removeClass('yui-layout');
386 this.addClass('yui-layout');
390 this._setBodySize(set);
392 this.fireEvent('resize', { target: this, sizes: this._sizes });
398 * @method _setupBodyElements
399 * @description Sets up the main doc element when using the body as the main element.
401 _setupBodyElements: function() {
402 this._doc = Dom.get('layout-doc');
404 this._doc = document.createElement('div');
405 this._doc.id = 'layout-doc';
406 if (document.body.firstChild) {
407 document.body.insertBefore(this._doc, document.body.firstChild);
409 document.body.appendChild(this._doc);
414 Event.on(window, 'resize', this.resize, this, true);
415 Dom.addClass(this._doc, 'yui-layout-doc');
419 * @method _setupElements
420 * @description Sets up the main doc element when not using the body as the main element.
422 _setupElements: function() {
423 this._doc = this.getElementsByClassName('yui-layout-doc')[0];
425 this._doc = document.createElement('div');
426 this.get('element').appendChild(this._doc);
430 Dom.addClass(this._doc, 'yui-layout-doc');
435 * @description Flag to determine if we are using the body as the root element.
442 * @description Reference to the root element
449 * @description The Layout class' initialization method
451 init: function(p_oElement, p_oAttributes) {
455 Layout.superclass.init.call(this, p_oElement, p_oAttributes);
457 if (this.get('parent')) {
458 this._zIndex = this.get('parent')._zIndex + 10;
465 if (!Lang.isString(id)) {
466 id = Dom.generateId(id);
468 Layout._instances[id] = this;
472 * @description This method starts the render process, applying classnames and creating elements
473 * @return {<a href="YAHOO.widget.Layout.html">YAHOO.widget.Layout</a>} The Layout instance
477 var el = this.get('element');
478 if (el && el.tagName && (el.tagName.toLowerCase() == 'body')) {
480 Dom.addClass(document.body, 'yui-layout');
481 if (Dom.hasClass(document.body, 'yui-skin-sam')) {
482 //Move the class up so we can have a css chain
483 Dom.addClass(document.documentElement, 'yui-skin-sam');
484 Dom.removeClass(document.body, 'yui-skin-sam');
486 this._setupBodyElements();
488 this._isBody = false;
489 this.addClass('yui-layout');
490 this._setupElements();
493 this._rendered = true;
494 this.fireEvent('render');
501 * @description Stamps the root node with a secure classname for ease of use. Also sets the this.browser.standardsMode variable.
504 if (document.compatMode == 'CSS1Compat') {
505 this.browser.standardsMode = true;
507 if (window.location.href.toLowerCase().indexOf("https") === 0) {
508 Dom.addClass(document.documentElement, 'secure');
509 this.browser.secure = true;
514 * @method initAttributes
515 * @description Processes the config
517 initAttributes: function(attr) {
518 Layout.superclass.initAttributes.call(this, attr);
521 * @description An array of config definitions for the LayoutUnits to add to this layout
524 this.setAttributeConfig('units', {
526 validator: YAHOO.lang.isArray,
527 value: attr.units || []
531 * @attribute minHeight
532 * @description The minimum height in pixels
535 this.setAttributeConfig('minHeight', {
536 value: attr.minHeight || false,
537 validator: YAHOO.lang.isNumber
541 * @attribute minWidth
542 * @description The minimum width in pixels
545 this.setAttributeConfig('minWidth', {
546 value: attr.minWidth || false,
547 validator: YAHOO.lang.isNumber
552 * @description The height in pixels
555 this.setAttributeConfig('height', {
556 value: attr.height || false,
557 validator: YAHOO.lang.isNumber,
558 method: function(h) {
559 this.setStyle('height', h + 'px');
565 * @description The width in pixels
568 this.setAttributeConfig('width', {
569 value: attr.width || false,
570 validator: YAHOO.lang.isNumber,
571 method: function(w) {
572 this.setStyle('width', w + 'px');
578 * @description If this layout is to be used as a child of another Layout instance, this config will bind the resize events together.
579 * @type Object YAHOO.widget.Layout
581 this.setAttributeConfig('parent', {
583 value: attr.parent || false,
584 method: function(p) {
586 p.on('resize', this.resize, this, true);
593 * @description 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.
595 destroy: function() {
596 var par = this.get('parent');
598 par.removeListener('resize', this.resize, this, true);
600 Event.removeListener(window, 'resize', this.resize, this, true);
602 this.unsubscribeAll();
603 for (var u in this._units) {
604 if (Lang.hasOwnProperty(this._units, u)) {
605 if (this._units[u]) {
606 this._units[u].destroy(true);
611 Event.purgeElement(this.get('element'));
612 this.get('parentNode').removeChild(this.get('element'));
614 delete YAHOO.widget.Layout._instances[this.get('id')];
615 //Brutal Object Destroy
616 for (var i in this) {
617 if (Lang.hasOwnProperty(this, i)) {
629 * @description Returns a string representing the Layout.
632 toString: function() {
634 return 'Layout #' + this.get('id');
641 * @description Fired when this.resize is called
642 * @type YAHOO.util.CustomEvent
646 * @description Fired when the Resize Utility for a Unit fires it's startResize Event.
647 * @type YAHOO.util.CustomEvent
650 * @event beforeResize
651 * @description Fires at the beginning of the resize method. If you return false, the resize is cancelled.
652 * @type YAHOO.util.CustomEvent
656 * @description Fired after the render method completes.
657 * @type YAHOO.util.CustomEvent
660 YAHOO.widget.Layout = Layout;
663 * @description <p>Provides a fixed position unit containing a header, body and footer for use with a YAHOO.widget.Layout instance.</p>
664 * @namespace YAHOO.widget
665 * @requires yahoo, dom, element, event, layout
666 * @optional animation, dragdrop, selector
669 var Dom = YAHOO.util.Dom,
670 Sel = YAHOO.util.Selector,
671 Event = YAHOO.util.Event,
677 * @extends YAHOO.util.Element
678 * @description <p>Provides a fixed position unit containing a header, body and footer for use with a YAHOO.widget.Layout instance.</p>
679 * @param {String/HTMLElement} el The element to make a unit.
680 * @param {Object} attrs Object liternal containing configuration parameters.
683 var LayoutUnit = function(el, config) {
687 attributes: config || {}
690 LayoutUnit.superclass.constructor.call(this, oConfig.element, oConfig.attributes);
696 * @property _instances
697 * @description Internal hash table for all layout unit instances
700 LayoutUnit._instances = {};
703 * @method getLayoutUnitById
704 * @description Get's a layout unit object by the HTML id of the element associated with the Layout Unit object.
705 * @return {Object} The Layout Object
707 LayoutUnit.getLayoutUnitById = function(id) {
708 if (LayoutUnit._instances[id]) {
709 return LayoutUnit._instances[id];
714 YAHOO.extend(LayoutUnit, YAHOO.util.Element, {
716 * @property STR_CLOSE
717 * @description String used for close button title
720 STR_CLOSE: 'Click to close this pane.',
722 * @property STR_COLLAPSE
723 * @description String used for collapse button title
726 STR_COLLAPSE: 'Click to collapse this pane.',
728 * @property STR_EXPAND
729 * @description String used for expand button title
732 STR_EXPAND: 'Click to expand this pane.',
734 * The class name applied to dynamic tabs while loading.
735 * @property LOADING_CLASSNAME
737 * @default "disabled"
739 LOADING_CLASSNAME: 'loading',
742 * @description A modified version of the YAHOO.env.ua object
749 * @description A collection of the current sizes of the contents of this Layout Unit
756 * @description A reference to the Animation instance used by this LayouUnit
757 * @type YAHOO.util.Anim
763 * @description A reference to the Resize instance used by this LayoutUnit
764 * @type YAHOO.util.Resize
770 * @description A reference to the clip element used when collapsing the unit
777 * @description A simple hash table used to store the gutter to apply to the Unit
783 * @description A reference to the HTML element used for the Header
789 * @description A reference to the HTML element used for the body
795 * @description A reference to the HTML element used for the footer
801 * @property _collapsed
802 * @description Flag to determine if the unit is collapsed or not.
808 * @property _collapsing
809 * @description A flag set while the unit is being collapsed, used so we don't fire events while animating the size
815 * @property _lastWidth
816 * @description A holder for the last known width of the unit
822 * @property _lastHeight
823 * @description A holder for the last known height of the unit
830 * @description A holder for the last known top of the unit
836 * @property _lastLeft
837 * @description A holder for the last known left of the unit
843 * @property _lastScroll
844 * @description A holder for the last known scroll state of the unit
850 * @property _lastCenetrScroll
851 * @description A holder for the last known scroll state of the center unit
854 _lastCenterScroll: null,
857 * @property _lastScrollTop
858 * @description A holder for the last known scrollTop state of the unit
861 _lastScrollTop: null,
864 * @description Resize either the unit or it's clipped state, also updating the box inside
865 * @param {Boolean} force This will force full calculations even when the unit is collapsed
866 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
868 resize: function(force) {
869 var retVal = this.fireEvent('beforeResize');
870 if (retVal === false) {
873 if (!this._collapsing || (force === true)) {
874 var scroll = this.get('scroll');
875 this.set('scroll', false);
878 var hd = this._getBoxSize(this.header),
879 ft = this._getBoxSize(this.footer),
880 box = [this.get('height'), this.get('width')];
882 var nh = (box[0] - hd[0] - ft[0]) - (this._gutter.top + this._gutter.bottom),
883 nw = box[1] - (this._gutter.left + this._gutter.right);
885 var wrapH = (nh + (hd[0] + ft[0])),
888 if (this._collapsed && !this._collapsing) {
889 this._setHeight(this._clip, wrapH);
890 this._setWidth(this._clip, wrapW);
891 Dom.setStyle(this._clip, 'top', this.get('top') + this._gutter.top + 'px');
892 Dom.setStyle(this._clip, 'left', this.get('left') + this._gutter.left + 'px');
893 } else if (!this._collapsed || (this._collapsed && this._collapsing)) {
894 wrapH = this._setHeight(this.get('wrap'), wrapH);
895 wrapW = this._setWidth(this.get('wrap'), wrapW);
896 this._sizes.wrap.h = wrapH;
897 this._sizes.wrap.w = wrapW;
899 Dom.setStyle(this.get('wrap'), 'top', this._gutter.top + 'px');
900 Dom.setStyle(this.get('wrap'), 'left', this._gutter.left + 'px');
902 this._sizes.header.w = this._setWidth(this.header, wrapW);
903 this._sizes.header.h = hd[0];
905 this._sizes.footer.w = this._setWidth(this.footer, wrapW);
906 this._sizes.footer.h = ft[0];
908 Dom.setStyle(this.footer, 'bottom', '0px');
910 this._sizes.body.h = this._setHeight(this.body, (wrapH - (hd[0] + ft[0])));
911 this._sizes.body.w =this._setWidth(this.body, wrapW);
912 Dom.setStyle(this.body, 'top', hd[0] + 'px');
914 this.set('scroll', scroll);
915 this.fireEvent('resize');
923 * @description Sets the width of the element based on the border size of the element.
924 * @param {HTMLElement} el The HTMLElement to have it's width set
925 * @param {Number} w The width that you want it the element set to
926 * @return {Number} The new width, fixed for borders and IE QuirksMode
928 _setWidth: function(el, w) {
930 var b = this._getBorderSizes(el);
931 w = (w - (b[1] + b[3]));
932 w = this._fixQuirks(el, w, 'w');
936 Dom.setStyle(el, 'width', w + 'px');
943 * @description Sets the height of the element based on the border size of the element.
944 * @param {HTMLElement} el The HTMLElement to have it's height set
945 * @param {Number} h The height that you want it the element set to
946 * @return {Number} The new height, fixed for borders and IE QuirksMode
948 _setHeight: function(el, h) {
950 var b = this._getBorderSizes(el);
951 h = (h - (b[0] + b[2]));
952 h = this._fixQuirks(el, h, 'h');
956 Dom.setStyle(el, 'height', h + 'px');
963 * @description Fixes the box calculations for IE in QuirksMode
964 * @param {HTMLElement} el The HTMLElement to set the dimension on
965 * @param {Number} dim The number of the dimension to fix
966 * @param {String} side The dimension (h or w) to fix. Defaults to h
967 * @return {Number} The fixed dimension
969 _fixQuirks: function(el, dim, side) {
975 if (this.browser.ie && !this.browser.standardsMode) {
976 //Internet Explorer - Quirks Mode
977 var b = this._getBorderSizes(el),
978 bp = this._getBorderSizes(el.parentNode);
979 if ((b[i1] === 0) && (b[i2] === 0)) { //No Borders, check parent
980 if ((bp[i1] !== 0) && (bp[i2] !== 0)) { //Parent has Borders
981 dim = (dim - (bp[i1] + bp[i2]));
984 if ((bp[i1] === 0) && (bp[i2] === 0)) {
985 dim = (dim + (b[i1] + b[i2]));
993 * @method _getBoxSize
994 * @description Get's the elements clientHeight and clientWidth plus the size of the borders
995 * @param {HTMLElement} el The HTMLElement to get the size of
996 * @return {Array} An array of height and width
998 _getBoxSize: function(el) {
1001 if (this.browser.ie && !this.browser.standardsMode) {
1004 var b = this._getBorderSizes(el);
1005 size[0] = el.clientHeight + (b[0] + b[2]);
1006 size[1] = el.clientWidth + (b[1] + b[3]);
1012 * @method _getBorderSizes
1013 * @description Get the CSS border size of the element passed.
1014 * @param {HTMLElement} el The element to get the border size of
1015 * @return {Array} An array of the top, right, bottom, left borders.
1017 _getBorderSizes: function(el) {
1019 el = el || this.get('element');
1020 if (this.browser.ie && !this.browser.standardsMode) {
1023 s[0] = parseInt(Dom.getStyle(el, 'borderTopWidth'), 10);
1024 s[1] = parseInt(Dom.getStyle(el, 'borderRightWidth'), 10);
1025 s[2] = parseInt(Dom.getStyle(el, 'borderBottomWidth'), 10);
1026 s[3] = parseInt(Dom.getStyle(el, 'borderLeftWidth'), 10);
1028 //IE will return NaN on these if they are set to auto, we'll set them to 0
1029 for (var i = 0; i < s.length; i++) {
1038 * @method _createClip
1039 * @description Create the clip element used when the Unit is collapsed
1041 _createClip: function() {
1043 this._clip = document.createElement('div');
1044 this._clip.className = 'yui-layout-clip yui-layout-clip-' + this.get('position');
1045 this._clip.innerHTML = '<div class="collapse"></div>';
1046 var c = this._clip.firstChild;
1047 c.title = this.STR_EXPAND;
1048 Event.on(c, 'click', this.expand, this, true);
1049 this.get('element').parentNode.appendChild(this._clip);
1054 * @method _toggleClip
1055 * @description Toggle th current state of the Clip element and set it's height, width and position
1057 _toggleClip: function() {
1058 if (!this._collapsed) {
1060 var hd = this._getBoxSize(this.header),
1061 ft = this._getBoxSize(this.footer),
1062 box = [this.get('height'), this.get('width')];
1065 var nh = (box[0] - hd[0] - ft[0]) - (this._gutter.top + this._gutter.bottom),
1066 nw = box[1] - (this._gutter.left + this._gutter.right),
1067 wrapH = (nh + (hd[0] + ft[0]));
1069 switch (this.get('position')) {
1072 this._setWidth(this._clip, nw);
1073 this._setHeight(this._clip, this.get('collapseSize'));
1074 Dom.setStyle(this._clip, 'left', (this._lastLeft + this._gutter.left) + 'px');
1075 if (this.get('position') == 'bottom') {
1076 Dom.setStyle(this._clip, 'top', ((this._lastTop + this._lastHeight) - (this.get('collapseSize') - this._gutter.top)) + 'px');
1078 Dom.setStyle(this._clip, 'top', this.get('top') + this._gutter.top + 'px');
1083 this._setWidth(this._clip, this.get('collapseSize'));
1084 this._setHeight(this._clip, wrapH);
1085 Dom.setStyle(this._clip, 'top', (this.get('top') + this._gutter.top) + 'px');
1086 if (this.get('position') == 'right') {
1087 Dom.setStyle(this._clip, 'left', (((this._lastLeft + this._lastWidth) - this.get('collapseSize')) - this._gutter.left) + 'px');
1089 Dom.setStyle(this._clip, 'left', (this.get('left') + this._gutter.left) + 'px');
1094 Dom.setStyle(this._clip, 'display', 'block');
1095 this.setStyle('display', 'none');
1098 Dom.setStyle(this._clip, 'display', 'none');
1103 * @description Get a reference to the internal sizes object for this unit
1104 * @return {Object} An object of the sizes used for calculations
1106 getSizes: function() {
1111 * @description Toggles the Unit, replacing it with a clipped version.
1112 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
1114 toggle: function() {
1115 if (this._collapsed) {
1124 * @description Expand the Unit if it is collapsed.
1125 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
1127 expand: function() {
1128 if (!this._collapsed) {
1131 var retVal = this.fireEvent('beforeExpand');
1132 if (retVal === false) {
1136 this._collapsing = true;
1137 this.setStyle('zIndex', this.get('parent')._zIndex + 1);
1140 this.setStyle('display', 'none');
1143 switch (this.get('position')) {
1146 this.set('width', this._lastWidth, true);
1147 this.setStyle('width', this._lastWidth + 'px');
1148 this.get('parent').resize(false);
1149 s = this.get('parent').getSizes()[this.get('position')];
1150 this.set('height', s.h, true);
1157 if (this.get('position') == 'left') {
1158 attr.left.from = (left - s.w);
1159 this.setStyle('left', (left - s.w) + 'px');
1164 this.set('height', this._lastHeight, true);
1165 this.setStyle('height', this._lastHeight + 'px');
1166 this.get('parent').resize(false);
1167 s = this.get('parent').getSizes()[this.get('position')];
1168 this.set('width', s.w, true);
1175 if (this.get('position') == 'top') {
1176 this.setStyle('top', (top - s.h) + 'px');
1177 attr.top.from = (top - s.h);
1182 this._anim.attributes = attr;
1183 var exStart = function() {
1184 this.setStyle('display', 'block');
1186 this._anim.onStart.unsubscribe(exStart, this, true);
1188 var expand = function() {
1189 this._collapsing = false;
1190 this.setStyle('zIndex', this.get('parent')._zIndex);
1191 this.set('width', this._lastWidth);
1192 this.set('height', this._lastHeight);
1193 this._collapsed = false;
1195 this.set('scroll', this._lastScroll);
1196 if (this._lastScrollTop > 0) {
1197 this.body.scrollTop = this._lastScrollTop;
1199 this._anim.onComplete.unsubscribe(expand, this, true);
1200 this.fireEvent('expand');
1202 this._anim.onStart.subscribe(exStart, this, true);
1203 this._anim.onComplete.subscribe(expand, this, true);
1204 this._anim.animate();
1207 this._collapsing = false;
1209 this._collapsed = false;
1210 this.setStyle('zIndex', this.get('parent')._zIndex);
1211 this.setStyle('display', 'block');
1212 this.set('width', this._lastWidth);
1213 this.set('height', this._lastHeight);
1215 this.set('scroll', this._lastScroll);
1216 if (this._lastScrollTop > 0) {
1217 this.body.scrollTop = this._lastScrollTop;
1219 this.fireEvent('expand');
1225 * @description Collapse the Unit if it is not collapsed.
1226 * @return {<a href="YAHOO.widget.LayoutUnit.html">YAHOO.widget.LayoutUnit</a>} The LayoutUnit instance
1228 collapse: function() {
1229 if (this._collapsed) {
1232 var retValue = this.fireEvent('beforeCollapse');
1233 if (retValue === false) {
1239 this._collapsing = true;
1240 var w = this.get('width'),
1241 h = this.get('height'),
1243 this._lastWidth = w;
1244 this._lastHeight = h;
1245 this._lastScroll = this.get('scroll');
1246 this._lastScrollTop = this.body.scrollTop;
1247 this.set('scroll', false, true);
1248 this._lastLeft = parseInt(this.get('element').style.left, 10);
1249 this._lastTop = parseInt(this.get('element').style.top, 10);
1250 if (isNaN(this._lastTop)) {
1254 if (isNaN(this._lastLeft)) {
1256 this.set('left', 0);
1258 this.setStyle('zIndex', this.get('parent')._zIndex + 1);
1259 var pos = this.get('position');
1264 this.set('height', (this.get('collapseSize') + (this._gutter.top + this._gutter.bottom)));
1267 to: (this.get('top') - h)
1270 if (pos == 'bottom') {
1271 attr.top.to = (this.get('top') + h);
1276 this.set('width', (this.get('collapseSize') + (this._gutter.left + this._gutter.right)));
1279 to: -(this._lastWidth)
1282 if (pos == 'right') {
1284 to: (this.get('left') + w)
1290 this._anim.attributes = attr;
1291 var collapse = function() {
1292 this._collapsing = false;
1294 this.setStyle('zIndex', this.get('parent')._zIndex);
1295 this._collapsed = true;
1296 this.get('parent').resize();
1297 this._anim.onComplete.unsubscribe(collapse, this, true);
1298 this.fireEvent('collapse');
1300 this._anim.onComplete.subscribe(collapse, this, true);
1301 this._anim.animate();
1303 this._collapsing = false;
1304 this.setStyle('display', 'none');
1306 this.setStyle('zIndex', this.get('parent')._zIndex);
1307 this.get('parent').resize();
1308 this._collapsed = true;
1309 this.fireEvent('collapse');
1315 * @description Close the unit, removing it from the parent Layout.
1316 * @return {<a href="YAHOO.widget.Layout.html">YAHOO.widget.Layout</a>} The parent Layout instance
1319 this.setStyle('display', 'none');
1320 this.get('parent').removeUnit(this);
1321 this.fireEvent('close');
1323 this._clip.parentNode.removeChild(this._clip);
1326 return this.get('parent');
1329 * @property loadHandler
1330 * @description Callback method for the YUI Connection Manager used for load the body using AJAX
1334 success: function(o) {
1335 this.body.innerHTML = o.responseText;
1338 failure: function(o) {
1342 * @property dataConnection
1343 * @description YUI Connection Manager handler
1346 dataConnection: null,
1349 * @property _loading
1350 * @description During the loading process this variable will be true
1355 * @method loadContent
1356 * @description Loading the content of the unit using the connection manager
1357 * @return {object} YUI Connection Manager handler
1359 loadContent: function() {
1360 // load dynamic content unless already loading or loaded and caching
1361 if (YAHOO.util.Connect && this.get('dataSrc') && !this._loading && !this.get('dataLoaded')) {
1362 this._loading = true;
1363 Dom.addClass(this.body, this.LOADING_CLASSNAME);
1364 this.dataConnection = YAHOO.util.Connect.asyncRequest(
1365 this.get('loadMethod'),
1366 this.get('dataSrc'),
1368 success: function(o) {
1369 this.loadHandler.success.call(this, o);
1370 this.set('dataLoaded', true);
1371 this.dataConnection = null;
1372 Dom.removeClass(this.body, this.LOADING_CLASSNAME);
1373 this._loading = false;
1374 this.fireEvent('load');
1376 failure: function(o) {
1377 this.loadHandler.failure.call(this, o);
1378 this.dataConnection = null;
1379 Dom.removeClass(this.body, this.LOADING_CLASSNAME);
1380 this._loading = false;
1381 this.fireEvent('loadError', { error: o });
1384 timeout: this.get('dataTimeout')
1387 return this.dataConnection;
1394 * @description The initalization method inherited from Element.
1396 init: function(p_oElement, p_oAttributes) {
1422 LayoutUnit.superclass.init.call(this, p_oElement, p_oAttributes);
1424 this.browser = this.get('parent').browser;
1426 var id = p_oElement;
1427 if (!Lang.isString(id)) {
1428 id = Dom.generateId(id);
1430 LayoutUnit._instances[id] = this;
1432 this.setStyle('position', 'absolute');
1434 this.addClass('yui-layout-unit');
1435 this.addClass('yui-layout-unit-' + this.get('position'));
1438 var header = this.getElementsByClassName('yui-layout-hd', 'div')[0];
1440 this.header = header;
1442 var body = this.getElementsByClassName('yui-layout-bd', 'div')[0];
1446 var footer = this.getElementsByClassName('yui-layout-ft', 'div')[0];
1448 this.footer = footer;
1451 this.on('contentChange', this.resize, this, true);
1452 this._lastScrollTop = 0;
1454 this.set('animate', this.get('animate'));
1458 * @method initAttributes
1459 * @description Processes the config
1461 initAttributes: function(attr) {
1462 LayoutUnit.superclass.initAttributes.call(this, attr);
1467 * @description A reference to the wrap element
1470 this.setAttributeConfig('wrap', {
1471 value: attr.wrap || null,
1472 method: function(w) {
1474 var id = Dom.generateId(w);
1475 LayoutUnit._instances[id] = this;
1481 * @description Set this option to true if you want the LayoutUnit to fix the first layer of YUI CSS Grids (margins)
1484 this.setAttributeConfig('grids', {
1485 value: attr.grids || false
1490 * @description The current top positioning of the Unit
1493 this.setAttributeConfig('top', {
1494 value: attr.top || 0,
1495 validator: Lang.isNumber,
1496 method: function(t) {
1497 if (!this._collapsing) {
1498 this.setStyle('top', t + 'px');
1505 * @description The current left position of the Unit
1508 this.setAttributeConfig('left', {
1509 value: attr.left || 0,
1510 validator: Lang.isNumber,
1511 method: function(l) {
1512 if (!this._collapsing) {
1513 this.setStyle('left', l + 'px');
1519 * @attribute minWidth
1520 * @description The minWidth parameter passed to the Resize Utility
1523 this.setAttributeConfig('minWidth', {
1524 value: attr.minWidth || false,
1525 validator: YAHOO.lang.isNumber
1529 * @attribute maxWidth
1530 * @description The maxWidth parameter passed to the Resize Utility
1533 this.setAttributeConfig('maxWidth', {
1534 value: attr.maxWidth || false,
1535 validator: YAHOO.lang.isNumber
1539 * @attribute minHeight
1540 * @description The minHeight parameter passed to the Resize Utility
1543 this.setAttributeConfig('minHeight', {
1544 value: attr.minHeight || false,
1545 validator: YAHOO.lang.isNumber
1549 * @attribute maxHeight
1550 * @description The maxHeight parameter passed to the Resize Utility
1553 this.setAttributeConfig('maxHeight', {
1554 value: attr.maxHeight || false,
1555 validator: YAHOO.lang.isNumber
1560 * @description The height of the Unit
1563 this.setAttributeConfig('height', {
1565 validator: Lang.isNumber,
1566 method: function(h) {
1567 if (!this._collapsing) {
1571 this.setStyle('height', h + 'px');
1578 * @description The width of the Unit
1581 this.setAttributeConfig('width', {
1583 validator: Lang.isNumber,
1584 method: function(w) {
1585 if (!this._collapsing) {
1589 this.setStyle('width', w + 'px');
1595 * @description The CSS zIndex to give to the unit, so you can have overlapping elements such as menus in a unit.
1598 this.setAttributeConfig('zIndex', {
1599 value: attr.zIndex || false,
1600 method: function(z) {
1601 this.setStyle('zIndex', z);
1605 * @attribute position
1606 * @description The position (top, right, bottom, left or center) of the Unit in the Layout
1609 this.setAttributeConfig('position', {
1610 value: attr.position
1614 * @description The gutter that we should apply to the parent Layout around this Unit. Supports standard CSS markup: (2 4 0 5) or (2) or (2 5)
1617 this.setAttributeConfig('gutter', {
1618 value: attr.gutter || 0,
1619 validator: YAHOO.lang.isString,
1620 method: function(gutter) {
1621 var p = gutter.split(' ');
1623 this._gutter.top = parseInt(p[0], 10);
1625 this._gutter.right = parseInt(p[1], 10);
1627 this._gutter.right = this._gutter.top;
1630 this._gutter.bottom = parseInt(p[2], 10);
1632 this._gutter.bottom = this._gutter.top;
1635 this._gutter.left = parseInt(p[3], 10);
1637 this._gutter.left = this._gutter.right;
1639 this._gutter.left = this._gutter.top;
1646 * @description The parent Layout that we are assigned to
1647 * @type {Object} YAHOO.widget.Layout
1649 this.setAttributeConfig('parent', {
1651 value: attr.parent || false,
1652 method: function(p) {
1654 p.on('resize', this.resize, this, true);
1660 * @attribute collapseSize
1661 * @description The pixel size of the Clip that we will collapse to
1664 this.setAttributeConfig('collapseSize', {
1665 value: attr.collapseSize || 25,
1666 validator: YAHOO.lang.isNumber
1669 * @attribute duration
1670 * @description The duration to give the Animation Utility when animating the opening and closing of Units
1672 this.setAttributeConfig('duration', {
1673 value: attr.duration || 0.5
1677 * @description The Animation Easing to apply to the Animation instance for this unit.
1679 this.setAttributeConfig('easing', {
1680 value: attr.easing || ((YAHOO.util && YAHOO.util.Easing) ? YAHOO.util.Easing.BounceIn : 'false')
1683 * @attribute animate
1684 * @description Use animation to collapse/expand the unit
1687 this.setAttributeConfig('animate', {
1688 value: ((attr.animate === false) ? false : true),
1689 validator: function() {
1691 if (YAHOO.util.Anim) {
1696 method: function(anim) {
1698 this._anim = new YAHOO.util.Anim(this.get('element'), {}, this.get('duration'), this.get('easing'));
1706 * @description The text to use as the Header of the Unit
1708 this.setAttributeConfig('header', {
1709 value: attr.header || false,
1710 method: function(txt) {
1711 if (txt === false) {
1714 Dom.addClass(this.body, 'yui-layout-bd-nohd');
1715 this.header.parentNode.removeChild(this.header);
1720 var header = this.getElementsByClassName('yui-layout-hd', 'div')[0];
1722 header = this._createHeader();
1724 this.header = header;
1726 var h = this.header.getElementsByTagName('h2')[0];
1728 h = document.createElement('h2');
1729 this.header.appendChild(h);
1733 Dom.removeClass(this.body, 'yui-layout-bd-nohd');
1736 this.fireEvent('contentChange', { target: 'header' });
1741 * @description Use the proxy config setting for the Resize Utility
1744 this.setAttributeConfig('proxy', {
1746 value: ((attr.proxy === false) ? false : true)
1750 * @description The content for the body. If we find an element in the page with an id that matches the passed option we will move that element into the body of this unit.
1752 this.setAttributeConfig('body', {
1753 value: attr.body || false,
1754 method: function(content) {
1756 var body = this.getElementsByClassName('yui-layout-bd', 'div')[0];
1760 body = document.createElement('div');
1761 body.className = 'yui-layout-bd';
1763 this.get('wrap').appendChild(body);
1767 Dom.addClass(this.body, 'yui-layout-bd-nohd');
1769 Dom.addClass(this.body, 'yui-layout-bd-noft');
1773 if (Lang.isString(content)) {
1774 el = Dom.get(content);
1775 } else if (content && content.tagName) {
1779 var id = Dom.generateId(el);
1780 LayoutUnit._instances[id] = this;
1781 this.body.appendChild(el);
1783 this.body.innerHTML = content;
1788 this.fireEvent('contentChange', { target: 'body' });
1794 * @description The content for the footer. If we find an element in the page with an id that matches the passed option we will move that element into the footer of this unit.
1796 this.setAttributeConfig('footer', {
1797 value: attr.footer || false,
1798 method: function(content) {
1799 if (content === false) {
1802 Dom.addClass(this.body, 'yui-layout-bd-noft');
1803 this.footer.parentNode.removeChild(this.footer);
1808 var ft = this.getElementsByClassName('yui-layout-ft', 'div')[0];
1810 ft = document.createElement('div');
1811 ft.className = 'yui-layout-ft';
1813 this.get('wrap').appendChild(ft);
1819 if (Lang.isString(content)) {
1820 el = Dom.get(content);
1821 } else if (content && content.tagName) {
1825 this.footer.appendChild(el);
1827 this.footer.innerHTML = content;
1829 Dom.removeClass(this.body, 'yui-layout-bd-noft');
1831 this.fireEvent('contentChange', { target: 'footer' });
1836 * @description Adds a close icon to the unit
1838 this.setAttributeConfig('close', {
1839 value: attr.close || false,
1840 method: function(close) {
1841 //Position Center doesn't get this
1842 if (this.get('position') == 'center') {
1846 this._createHeader();
1848 var c = Dom.getElementsByClassName('close', 'div', this.header)[0];
1850 //Force some header text if there isn't any
1851 if (!this.get('header')) {
1852 this.set('header', ' ');
1855 c = document.createElement('div');
1856 c.className = 'close';
1857 this.header.appendChild(c);
1858 Event.on(c, 'click', this.close, this, true);
1860 c.title = this.STR_CLOSE;
1862 Event.purgeElement(c);
1863 c.parentNode.removeChild(c);
1865 this._configs.close.value = close;
1866 this.set('collapse', this.get('collapse')); //Reset so we get the right classnames
1871 * @attribute collapse
1872 * @description Adds a collapse icon to the unit
1874 this.setAttributeConfig('collapse', {
1875 value: attr.collapse || false,
1876 method: function(collapse) {
1877 //Position Center doesn't get this
1878 if (this.get('position') == 'center') {
1882 this._createHeader();
1884 var c = Dom.getElementsByClassName('collapse', 'div', this.header)[0];
1886 //Force some header text if there isn't any
1887 if (!this.get('header')) {
1888 this.set('header', ' ');
1891 c = document.createElement('div');
1892 this.header.appendChild(c);
1893 Event.on(c, 'click', this.collapse, this, true);
1895 c.title = this.STR_COLLAPSE;
1896 c.className = 'collapse' + ((this.get('close')) ? ' collapse-close' : '');
1898 Event.purgeElement(c);
1899 c.parentNode.removeChild(c);
1905 * @description Adds a class to the unit to allow for overflow: auto (yui-layout-scroll), default is overflow: hidden (yui-layout-noscroll). If true scroll bars will be placed on the element when the content exceeds the given area, false will put overflow hidden to hide the content. Passing null will render the content as usual overflow.
1906 * @type Boolean/Null
1909 this.setAttributeConfig('scroll', {
1910 value: (((attr.scroll === true) || (attr.scroll === false) || (attr.scroll === null)) ? attr.scroll : false),
1911 method: function(scroll) {
1912 if ((scroll === false) && !this._collapsed) { //Removing scroll bar
1914 if (this.body.scrollTop > 0) {
1915 this._lastScrollTop = this.body.scrollTop;
1920 if (scroll === true) {
1921 this.addClass('yui-layout-scroll');
1922 this.removeClass('yui-layout-noscroll');
1923 if (this._lastScrollTop > 0) {
1925 this.body.scrollTop = this._lastScrollTop;
1928 } else if (scroll === false) {
1929 this.removeClass('yui-layout-scroll');
1930 this.addClass('yui-layout-noscroll');
1931 } else if (scroll === null) {
1932 this.removeClass('yui-layout-scroll');
1933 this.removeClass('yui-layout-noscroll');
1939 * @description Config option to pass to the Resize Utility
1941 this.setAttributeConfig('hover', {
1943 value: attr.hover || false,
1944 validator: YAHOO.lang.isBoolean
1947 * @attribute useShim
1948 * @description Config option to pass to the Resize Utility
1950 this.setAttributeConfig('useShim', {
1951 value: attr.useShim || false,
1952 validator: YAHOO.lang.isBoolean,
1953 method: function(u) {
1955 this._resize.set('useShim', u);
1961 * @description Should a Resize instance be added to this unit
1964 this.setAttributeConfig('resize', {
1965 value: attr.resize || false,
1966 validator: function(r) {
1967 if (YAHOO.util && YAHOO.util.Resize) {
1972 method: function(resize) {
1973 if (resize && !this._resize) {
1974 //Position Center doesn't get this
1975 if (this.get('position') == 'center') {
1978 var handle = false; //To catch center
1979 switch (this.get('position')) {
1994 this.setStyle('position', 'absolute'); //Make sure Resize get's a position
1997 this._resize = new YAHOO.util.Resize(this.get('element'), {
1998 proxy: this.get('proxy'),
1999 hover: this.get('hover'),
2003 minWidth: this.get('minWidth'),
2004 maxWidth: this.get('maxWidth'),
2005 minHeight: this.get('minHeight'),
2006 maxHeight: this.get('maxHeight'),
2007 height: this.get('height'),
2008 width: this.get('width'),
2010 useShim: this.get('useShim'),
2014 this._resize._handles[handle].innerHTML = '<div class="yui-layout-resize-knob"></div>';
2016 if (this.get('proxy')) {
2017 var proxy = this._resize.getProxyEl();
2018 proxy.innerHTML = '<div class="yui-layout-handle-' + handle + '"></div>';
2020 this._resize.on('startResize', function(ev) {
2021 this._lastScroll = this.get('scroll');
2022 this.set('scroll', false);
2023 if (this.get('parent')) {
2024 this.get('parent').fireEvent('startResize');
2025 var c = this.get('parent').getUnitByPosition('center');
2026 this._lastCenterScroll = c.get('scroll');
2027 c.addClass(this._resize.CSS_RESIZING);
2028 c.set('scroll', false);
2030 this.fireEvent('startResize');
2032 this._resize.on('resize', function(ev) {
2033 this.set('height', ev.height);
2034 this.set('width', ev.width);
2036 this._resize.on('endResize', function(ev) {
2037 this.set('scroll', this._lastScroll);
2038 if (this.get('parent')) {
2039 var c = this.get('parent').getUnitByPosition('center');
2040 c.set('scroll', this._lastCenterScroll);
2041 c.removeClass(this._resize.CSS_RESIZING);
2044 this.fireEvent('endResize');
2049 this._resize.destroy();
2055 * The unit data source, used for loading content dynamically.
2056 * @attribute dataSrc
2059 this.setAttributeConfig('dataSrc', {
2063 * The method to use for the data request.
2064 * @attribute loadMethod
2068 this.setAttributeConfig('loadMethod', {
2069 value: attr.loadMethod || 'GET',
2070 validator: YAHOO.lang.isString
2073 * Whether or not any data has been loaded from the server.
2074 * @attribute dataLoaded
2077 this.setAttributeConfig('dataLoaded', {
2079 validator: YAHOO.lang.isBoolean,
2083 * Number if milliseconds before aborting and calling failure handler.
2084 * @attribute dataTimeout
2088 this.setAttributeConfig('dataTimeout', {
2089 value: attr.dataTimeout || null,
2090 validator: YAHOO.lang.isNumber
2095 * @method _cleanGrids
2096 * @description This method attempts to clean up the first level of the YUI CSS Grids, YAHOO.util.Selector is required for this operation.
2098 _cleanGrids: function() {
2099 if (this.get('grids')) {
2100 var b = Sel.query('div.yui-b', this.body, true);
2102 Dom.removeClass(b, 'yui-b');
2104 Event.onAvailable('yui-main', function() {
2105 Dom.setStyle(Sel.query('#yui-main'), 'margin-left', '0');
2106 Dom.setStyle(Sel.query('#yui-main'), 'margin-right', '0');
2112 * @method _createHeader
2113 * @description Creates the HTMLElement for the header
2114 * @return {HTMLElement} The new HTMLElement
2116 _createHeader: function() {
2117 var header = document.createElement('div');
2118 header.className = 'yui-layout-hd';
2119 if (this.get('firstChild')) {
2120 this.get('wrap').insertBefore(header, this.get('wrap').firstChild);
2122 this.get('wrap').appendChild(header);
2124 this.header = header;
2129 * @param {Boolean} force Don't report to the parent, because we are being called from the parent.
2130 * @description Removes this unit from the parent and cleans up after itself.
2131 * @return {<a href="YAHOO.widget.Layout.html">YAHOO.widget.Layout</a>} The parent Layout instance
2133 destroy: function(force) {
2135 this._resize.destroy();
2137 var par = this.get('parent');
2139 this.setStyle('display', 'none');
2141 this._clip.parentNode.removeChild(this._clip);
2146 par.removeUnit(this);
2150 par.removeListener('resize', this.resize, this, true);
2152 this.unsubscribeAll();
2153 Event.purgeElement(this.get('element'));
2154 this.get('parentNode').removeChild(this.get('element'));
2156 delete YAHOO.widget.LayoutUnit._instances[this.get('id')];
2157 //Brutal Object Destroy
2158 for (var i in this) {
2159 if (Lang.hasOwnProperty(this, i)) {
2169 * @description Returns a string representing the LayoutUnit.
2172 toString: function() {
2174 return 'LayoutUnit #' + this.get('id') + ' (' + this.get('position') + ')';
2176 return 'LayoutUnit';
2180 * @description Fired when this.resize is called
2181 * @type YAHOO.util.CustomEvent
2184 * @event startResize
2185 * @description Fired when the Resize Utility fires it's startResize Event.
2186 * @type YAHOO.util.CustomEvent
2190 * @description Fired when the Resize Utility fires it's endResize Event.
2191 * @type YAHOO.util.CustomEvent
2194 * @event beforeResize
2195 * @description Fired at the beginning of the resize method. If you return false, the resize is cancelled.
2196 * @type YAHOO.util.CustomEvent
2199 * @event contentChange
2200 * @description Fired when the content in the header, body or footer is changed via the API
2201 * @type YAHOO.util.CustomEvent
2205 * @description Fired when the unit is closed
2206 * @type YAHOO.util.CustomEvent
2209 * @event beforeCollapse
2210 * @description Fired before the unit is collapsed. If you return false, the collapse is cancelled.
2211 * @type YAHOO.util.CustomEvent
2215 * @description Fired when the unit is collapsed
2216 * @type YAHOO.util.CustomEvent
2220 * @description Fired when the unit is exanded
2221 * @type YAHOO.util.CustomEvent
2224 * @event beforeExpand
2225 * @description Fired before the unit is exanded. If you return false, the collapse is cancelled.
2226 * @type YAHOO.util.CustomEvent
2230 * @description Fired when data is loaded via the dataSrc config.
2231 * @type YAHOO.util.CustomEvent
2235 * @description Fired when an error occurs loading data via the dataSrc config. Error message is passed as argument to this event.
2236 * @type YAHOO.util.CustomEvent
2240 YAHOO.widget.LayoutUnit = LayoutUnit;
2242 YAHOO.register("layout", YAHOO.widget.Layout, {version: "2.7.0", build: "1799"});