]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/widget/widget-stdmod.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / widget / widget-stdmod.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add('widget-stdmod', function(Y) {
9
10 /**
11  * Provides standard module support for Widgets through an extension.
12  * 
13  * @module widget-stdmod
14  */
15     var L = Y.Lang,
16         Node = Y.Node,
17         UA = Y.UA,
18         Widget = Y.Widget,
19
20         EMPTY = "",
21         HD = "hd",
22         BD = "bd",
23         FT = "ft",
24         HEADER = "header",
25         BODY = "body",
26         FOOTER = "footer",
27         FILL_HEIGHT = "fillHeight",
28         STDMOD = "stdmod",
29         
30         NODE_SUFFIX = "Node",
31         CONTENT_SUFFIX = "Content",
32
33         FIRST_CHILD = "firstChild",
34         CHILD_NODES = "childNodes",
35         OWNER_DOCUMENT = "ownerDocument",
36
37         CONTENT_BOX = "contentBox",
38
39         HEIGHT = "height",
40         OFFSET_HEIGHT = "offsetHeight",
41         AUTO = "auto",
42
43         HeaderChange = "headerContentChange",
44         BodyChange = "bodyContentChange",
45         FooterChange = "footerContentChange",
46         FillHeightChange = "fillHeightChange",
47         HeightChange = "heightChange",
48         ContentUpdate = "contentUpdate",
49
50         RENDERUI = "renderUI",
51         BINDUI = "bindUI",
52         SYNCUI = "syncUI",
53
54         APPLY_PARSED_CONFIG = "_applyParsedConfig",
55
56         UI = Y.Widget.UI_SRC;
57
58     /**
59      * Widget extension, which can be used to add Standard Module support to the 
60      * base Widget class, through the <a href="Base.html#method_build">Base.build</a> 
61      * method.
62      * <p>
63      * The extension adds header, body and footer sections to the Widget's content box and 
64      * provides the corresponding methods and attributes to modify the contents of these sections.
65      * </p>
66      * @class WidgetStdMod
67      * @param {Object} The user configuration object
68      */
69     function StdMod(config) {
70
71         this._stdModNode = this.get(CONTENT_BOX);
72
73         Y.before(this._renderUIStdMod, this, RENDERUI);
74         Y.before(this._bindUIStdMod, this, BINDUI);
75         Y.before(this._syncUIStdMod, this, SYNCUI);
76     }
77
78     /**
79      * Constant used to refer the the standard module header, in methods which expect a section specifier
80      * 
81      * @property WidgetStdMod.HEADER
82      * @static
83      * @type String
84      */
85     StdMod.HEADER = HEADER;
86
87     /**
88      * Constant used to refer the the standard module body, in methods which expect a section specifier
89      * 
90      * @property WidgetStdMod.BODY
91      * @static
92      * @type String
93      */
94     StdMod.BODY = BODY;
95
96     /**
97      * Constant used to refer the the standard module footer, in methods which expect a section specifier
98      * 
99      * @property WidgetStdMod.FOOTER
100      * @static
101      * @type String
102      */
103     StdMod.FOOTER = FOOTER;
104
105     /**
106      * Constant used to specify insertion position, when adding content to sections of the standard module in 
107      * methods which expect a "where" argument.
108      * <p>
109      * Inserts new content <em>before</em> the sections existing content.
110      * </p>
111      * @property WidgetStdMod.AFTER
112      * @static
113      * @type String
114      */
115     StdMod.AFTER = "after";
116
117     /**
118      * Constant used to specify insertion position, when adding content to sections of the standard module in
119      * methods which expect a "where" argument.
120      * <p>
121      * Inserts new content <em>before</em> the sections existing content.
122      * </p>
123      * @property WidgetStdMod.BEFORE
124      * @static
125      * @type String
126      */
127     StdMod.BEFORE = "before";
128     /**
129      * Constant used to specify insertion position, when adding content to sections of the standard module in
130      * methods which expect a "where" argument.
131      * <p>
132      * <em>Replaces</em> the sections existing content, with new content.
133      * </p>
134      * @property WidgetStdMod.REPLACE
135      * @static
136      * @type String
137      */
138     StdMod.REPLACE = "replace";
139
140     var STD_HEADER = StdMod.HEADER,
141         STD_BODY = StdMod.BODY,
142         STD_FOOTER = StdMod.FOOTER,
143         
144         HEADER_CONTENT = STD_HEADER + CONTENT_SUFFIX,
145         FOOTER_CONTENT = STD_FOOTER + CONTENT_SUFFIX,
146         BODY_CONTENT = STD_BODY + CONTENT_SUFFIX;
147
148     /**
149      * Static property used to define the default attribute 
150      * configuration introduced by WidgetStdMod.
151      * 
152      * @property WidgetStdMod.ATTRS
153      * @type Object
154      * @static
155      */
156     StdMod.ATTRS = {
157
158         /**
159          * @attribute headerContent
160          * @type {String | Node}
161          * @default undefined
162          * @description The content to be added to the header section. This will replace any existing content
163          * in the header. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
164          */
165         headerContent: {
166             value:null
167         },
168
169         /**
170          * @attribute footerContent
171          * @type {String | Node}
172          * @default undefined
173          * @description The content to be added to the footer section. This will replace any existing content
174          * in the footer. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
175          */
176         footerContent: {
177             value:null
178         },
179         
180         /**
181          * @attribute bodyContent
182          * @type {String | Node}
183          * @default undefined
184          * @description The content to be added to the body section. This will replace any existing content
185          * in the body. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
186          */
187         bodyContent: {
188             value:null
189         },
190         
191         /**
192          * @attribute fillHeight
193          * @type {String}
194          * @default WidgetStdMod.BODY
195          * @description The section (WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER) which should be resized to fill the height of the standard module, when a 
196          * height is set on the Widget. If a height is not set on the widget, then all sections are sized based on 
197          * their content.
198          */
199         fillHeight: {
200             value: StdMod.BODY,
201             validator: function(val) {
202                  return this._validateFillHeight(val);
203             }
204         }
205     };
206
207     /**
208      * The HTML parsing rules for the WidgetStdMod class.
209      * 
210      * @property WidgetStdMod.HTML_PARSER
211      * @static
212      * @type Object
213      */
214     StdMod.HTML_PARSER = {
215         headerContent: function(contentBox) {
216             return this._parseStdModHTML(STD_HEADER);
217         },
218
219         bodyContent: function(contentBox) {
220             return this._parseStdModHTML(STD_BODY);
221         },
222
223         footerContent : function(contentBox) {
224             return this._parseStdModHTML(STD_FOOTER);
225         }
226     };
227
228     /**
229      * Static hash of default class names used for the header,
230      * body and footer sections of the standard module, keyed by
231      * the section identifier (WidgetStdMod.STD_HEADER, WidgetStdMod.STD_BODY, WidgetStdMod.STD_FOOTER)
232      *
233      * @property WidgetStdMod.SECTION_CLASS_NAMES
234      * @static
235      * @type Object
236      */
237     StdMod.SECTION_CLASS_NAMES = {
238         header: Widget.getClassName(HD),
239         body: Widget.getClassName(BD),
240         footer: Widget.getClassName(FT)
241     };
242
243     /**
244      * The template HTML strings for each of the standard module sections. Section entries are keyed by the section constants,
245      * WidgetStdMod.HEADER, WidgetStdMod.BODY, WidgetStdMod.FOOTER, and contain the HTML to be added for each section.
246      * e.g.
247      * <pre>
248      *    {
249      *       header : '&lt;div class="yui-widget-hd"&gt;&lt;/div&gt;',
250      *       body : '&lt;div class="yui-widget-bd"&gt;&lt;/div&gt;',
251      *       footer : '&lt;div class="yui-widget-ft"&gt;&lt;/div&gt;'
252      *    }
253      * </pre>
254      * @property WidgetStdMod.TEMPLATES
255      * @type Object
256      * @static
257      */
258     StdMod.TEMPLATES = {
259         header : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_HEADER] + '"></div>',
260         body : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_BODY] + '"></div>',
261         footer : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_FOOTER] + '"></div>'
262     };
263
264     StdMod.prototype = {
265
266         /**
267          * Synchronizes the UI to match the Widgets standard module state.
268          * <p>
269          * This method is invoked after syncUI is invoked for the Widget class
270          * using YUI's aop infrastructure.
271          * </p>
272          * @method _syncUIStdMod
273          * @protected
274          */
275         _syncUIStdMod : function() {
276             var stdModParsed = this._stdModParsed;
277
278             if (!stdModParsed || !stdModParsed[HEADER_CONTENT]) { 
279                 this._uiSetStdMod(STD_HEADER, this.get(HEADER_CONTENT)); 
280             }
281
282             if (!stdModParsed || !stdModParsed[BODY_CONTENT]) { 
283                 this._uiSetStdMod(STD_BODY, this.get(BODY_CONTENT));
284             }
285
286             if (!stdModParsed || !stdModParsed[FOOTER_CONTENT]) {
287                 this._uiSetStdMod(STD_FOOTER, this.get(FOOTER_CONTENT));
288             }
289
290             this._uiSetFillHeight(this.get(FILL_HEIGHT));
291         },
292
293         /**
294          * Creates/Initializes the DOM for standard module support.
295          * <p>
296          * This method is invoked after renderUI is invoked for the Widget class
297          * using YUI's aop infrastructure.
298          * </p>
299          * @method _renderUIStdMod
300          * @protected
301          */
302         _renderUIStdMod : function() {
303             this._stdModNode.addClass(Widget.getClassName(STDMOD));
304             this._renderStdModSections();
305         },
306
307         _renderStdModSections : function() {
308             if (L.isValue(this.get(HEADER_CONTENT))) { this._renderStdMod(STD_HEADER); }
309             if (L.isValue(this.get(BODY_CONTENT))) { this._renderStdMod(STD_BODY); }
310             if (L.isValue(this.get(FOOTER_CONTENT))) { this._renderStdMod(STD_FOOTER); }
311         },
312
313         /**
314          * Binds event listeners responsible for updating the UI state in response to 
315          * Widget standard module related state changes.
316          * <p>
317          * This method is invoked after bindUI is invoked for the Widget class
318          * using YUI's aop infrastructure.
319          * </p>
320          * @method _bindUIStdMod
321          * @protected
322          */
323         _bindUIStdMod : function() {
324             this.after(HeaderChange, this._afterHeaderChange);
325             this.after(BodyChange, this._afterBodyChange);
326             this.after(FooterChange, this._afterFooterChange);
327
328             this.after(FillHeightChange, this._afterFillHeightChange);
329             this.after(HeightChange, this._fillHeight);            
330             this.after(ContentUpdate, this._fillHeight);
331         },
332
333         /**
334          * Default attribute change listener for the headerContent attribute, responsible
335          * for updating the UI, in response to attribute changes.
336          *
337          * @method _afterHeaderChange
338          * @protected
339          * @param {EventFacade} e The event facade for the attribute change
340          */
341         _afterHeaderChange : function(e) {
342             if (e.src !== UI) {
343                 this._uiSetStdMod(STD_HEADER, e.newVal, e.stdModPosition);
344             }
345         },
346
347         /**
348          * Default attribute change listener for the bodyContent attribute, responsible
349          * for updating the UI, in response to attribute changes.
350          *
351          * @method _afterBodyChange
352          * @protected
353          * @param {EventFacade} e The event facade for the attribute change
354          */
355         _afterBodyChange : function(e) {
356             if (e.src !== UI) {
357                 this._uiSetStdMod(STD_BODY, e.newVal, e.stdModPosition);
358             }
359         },
360
361         /**
362          * Default attribute change listener for the footerContent attribute, responsible
363          * for updating the UI, in response to attribute changes.
364          *
365          * @method _afterFooterChange
366          * @protected
367          * @param {EventFacade} e The event facade for the attribute change
368          */
369         _afterFooterChange : function(e) {
370             if (e.src !== UI) {
371                 this._uiSetStdMod(STD_FOOTER, e.newVal, e.stdModPosition);
372             }
373         },
374
375         /**
376          * Default attribute change listener for the fillHeight attribute, responsible
377          * for updating the UI, in response to attribute changes.
378          * 
379          * @method _afterFillHeightChange
380          * @protected
381          * @param {EventFacade} e The event facade for the attribute change
382          */
383         _afterFillHeightChange: function (e) {
384             this._uiSetFillHeight(e.newVal);
385         },
386
387         /**
388          * Default validator for the fillHeight attribute. Verifies that the 
389          * value set is a valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER,
390          * or a falsey value if fillHeight is to be disabled.
391          *
392          * @method _validateFillHeight
393          * @protected
394          * @param {String} val The section which should be setup to fill height, or false/null to disable fillHeight
395          * @return true if valid, false if not
396          */
397         _validateFillHeight : function(val) {
398             return !val || val == StdMod.BODY || val == StdMod.HEADER || val == StdMod.FOOTER;    
399         },
400
401         /**
402          * Updates the rendered UI, to resize the provided section so that the standard module fills out 
403          * the specified widget height. Note: This method does not check whether or not a height is set 
404          * on the Widget.
405          * 
406          * @method _uiSetFillHeight
407          * @protected
408          * @param {String} fillSection A valid section specifier - one of WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER
409          */
410         _uiSetFillHeight : function(fillSection) {
411             var fillNode = this.getStdModNode(fillSection);
412             var currNode = this._currFillNode;
413
414             if (currNode && fillNode !== currNode){
415                 currNode.setStyle(HEIGHT, EMPTY);
416             }
417
418             if (fillNode) {
419                 this._currFillNode = fillNode;
420             }
421
422             this._fillHeight();
423         },
424
425         /**
426          * Updates the rendered UI, to resize the current section specified by the fillHeight attribute, so
427          * that the standard module fills out the Widget height. If a height has not been set on Widget,
428          * the section is not resized (height is set to "auto").
429          * 
430          * @method _fillHeight
431          * @private
432          */
433         _fillHeight : function() {
434             if (this.get(FILL_HEIGHT)) {
435                 var height = this.get(HEIGHT);
436                 if (height != EMPTY && height != AUTO) {
437                     this.fillHeight(this._currFillNode);    
438                 }
439             }
440         },
441
442         /**
443          * Updates the rendered UI, adding the provided content (either an HTML string, or node reference),
444          * to the specified section. The content is either added before, after or replaces existing content
445          * in the section, based on the value of the <code>where</code> argument.
446          * 
447          * @method _uiSetStdMod
448          * @protected
449          * 
450          * @param {String} section The section to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER. 
451          * @param {String | Node} content The new content (either as an HTML string, or Node reference) to add to the section
452          * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
453          * If not provided, the content will replace existing content in the section.
454          */
455         _uiSetStdMod : function(section, content, where) {
456             // Using isValue, so that "" is valid content 
457             if (L.isValue(content)) {
458                 var node = this.getStdModNode(section) || this._renderStdMod(section);
459
460                 this._addStdModContent(node, content, where);
461
462                 this.set(section + CONTENT_SUFFIX, this._getStdModContent(section), {src:UI});
463             } else {
464                 this._eraseStdMod(section);
465             }
466             this.fire(ContentUpdate);
467         },
468
469         /**
470          * Creates the DOM node for the given section, and inserts it into the correct location in the contentBox.
471          *
472          * @method _renderStdMod
473          * @protected
474          * @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
475          * @return {Node} A reference to the added section node
476          */
477         _renderStdMod : function(section) {
478
479             var contentBox = this.get(CONTENT_BOX),
480                 sectionNode = this._findStdModSection(section);
481
482             if (!sectionNode) {
483                 sectionNode = this._getStdModTemplate(section);
484             }
485
486             this._insertStdModSection(contentBox, section, sectionNode);
487
488             this[section + NODE_SUFFIX] = sectionNode;
489             return this[section + NODE_SUFFIX];
490         },
491
492         /**
493          * Removes the DOM node for the given section.
494          *
495          * @method _eraseStdMod
496          * @protected
497          * @param {String} section The section to remove. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
498          */
499         _eraseStdMod : function(section) {
500             var sectionNode = this.getStdModNode(section);
501             if (sectionNode) {
502                 sectionNode.remove(true);
503                 delete this[section + NODE_SUFFIX];
504             }
505         },
506
507         /**
508          * Helper method to insert the Node for the given section into the correct location in the contentBox.
509          *
510          * @method _insertStdModSection
511          * @private
512          * @param {Node} contentBox A reference to the Widgets content box.
513          * @param {String} section The section to create/render. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
514          * @param {Node} sectionNode The Node for the section.
515          */
516         _insertStdModSection : function(contentBox, section, sectionNode) {
517             var fc = contentBox.get(FIRST_CHILD);
518
519             if (section === STD_FOOTER || !fc) {
520                 contentBox.appendChild(sectionNode);
521             } else {
522                 if (section === STD_HEADER) {
523                     contentBox.insertBefore(sectionNode, fc);
524                 } else {
525                     var footer = this[STD_FOOTER + NODE_SUFFIX];
526                     if (footer) {
527                         contentBox.insertBefore(sectionNode, footer);
528                     } else {
529                         contentBox.appendChild(sectionNode);
530                     }
531                 }
532             }
533         },
534
535         /**
536          * Gets a new Node reference for the given standard module section, by cloning
537          * the stored template node.
538          *
539          * @method _getStdModTemplate
540          * @protected
541          * @param {String} section The section to create a new node for. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
542          * @return {Node} The new Node instance for the section
543          */
544         _getStdModTemplate : function(section) {
545             return Node.create(StdMod.TEMPLATES[section], this._stdModNode.get(OWNER_DOCUMENT));
546         },
547
548         /**
549          * Helper method to add content to a StdMod section node.
550          * The content is added either before, after or replaces the existing node content 
551          * based on the value of the <code>where</code> argument.
552          * 
553          * @method _addStdModContent
554          * @private
555          * 
556          * @param {Node} node The section Node to be updated.
557          * @param {Node|NodeList|String} children The new content Node, NodeList or String to be added to section Node provided.
558          * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
559          * If not provided, the content will replace existing content in the Node.
560          */
561         _addStdModContent : function(node, children, where) {
562
563             // StdMod where to Node where
564             switch (where) {
565                 case StdMod.BEFORE:  // 0 is before fistChild
566                     where = 0;
567                     break;
568                 case StdMod.AFTER:   // undefined is appendChild
569                     where = undefined;
570                     break;
571                 default:            // replace is replace, not specified is replace
572                     where = StdMod.REPLACE; 
573             }
574
575             node.insert(children, where);
576         },
577
578         /**
579          * Helper method to obtain the precise height of the node provided, including padding and border.
580          * The height could be a sub-pixel value for certain browsers, such as Firefox 3.
581          *
582          * @method _getPreciseHeight
583          * @private
584          * @param {Node} node The node for which the precise height is required.
585          * @return {Number} The height of the Node including borders and padding, possibly a float.
586          */
587         _getPreciseHeight : function(node) {
588             var height = (node) ? node.get(OFFSET_HEIGHT) : 0,
589                 getBCR = "getBoundingClientRect";
590
591             if (node && node.hasMethod(getBCR)) {
592                 var preciseRegion = node.invoke(getBCR);
593                 if (preciseRegion) {
594                     height = preciseRegion.bottom - preciseRegion.top;
595                 }
596             }
597
598             return height;
599         },
600
601         /**
602          * Helper method to to find the rendered node for the given section,
603          * if it exists.
604          * 
605          * @method _findStdModSection
606          * @private
607          * @param {String} section The section for which the render Node is to be found. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
608          * @return {Node} The rendered node for the given section, or null if not found.
609          */
610         _findStdModSection: function(section) {
611             return this.get(CONTENT_BOX).one("> ." + StdMod.SECTION_CLASS_NAMES[section]);
612         },
613
614         /**
615          * Utility method, used by WidgetStdMods HTML_PARSER implementation
616          * to extract data for each section from markup.
617          *
618          * @method _parseStdModHTML
619          * @private
620          * @param {String} section
621          * @return {String} Inner HTML string with the contents of the section
622          */
623         _parseStdModHTML : function(section) {
624
625             var node = this._findStdModSection(section);
626
627             if (node) {
628                 if (!this._stdModParsed) {
629                     this._stdModParsed = {};
630                     Y.before(this._applyStdModParsedConfig, this, APPLY_PARSED_CONFIG);
631                 }
632                 this._stdModParsed[section + CONTENT_SUFFIX] = 1;
633
634                 return node.get("innerHTML");
635             }
636
637             return null;
638         },
639
640         /**
641          * This method is injected before the _applyParsedConfig step in 
642          * the application of HTML_PARSER, and sets up the state to 
643          * identify whether or not we should remove the current DOM content
644          * or not, based on whether or not the current content attribute value
645          * was extracted from the DOM, or provided by the user configuration
646          * 
647          * @method _applyStdModParsedConfig
648          * @private
649          */
650         _applyStdModParsedConfig : function(node, cfg, parsedCfg) {
651             var parsed = this._stdModParsed; 
652             if (parsed) {
653                 parsed[HEADER_CONTENT] = !(HEADER_CONTENT in cfg) && (HEADER_CONTENT in parsed);
654                 parsed[BODY_CONTENT] = !(BODY_CONTENT in cfg) && (BODY_CONTENT in parsed);
655                 parsed[FOOTER_CONTENT] = !(FOOTER_CONTENT in cfg) && (FOOTER_CONTENT in parsed);
656             }
657         },
658
659         /**
660          * Retrieves the child nodes (content) of a standard module section
661          * 
662          * @method _getStdModContent
663          * @private
664          * @param {String} section The standard module section whose child nodes are to be retrieved. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
665          * @return {Node} The child node collection of the standard module section.
666          */
667         _getStdModContent : function(section) {
668             return (this[section + NODE_SUFFIX]) ? this[section + NODE_SUFFIX].get(CHILD_NODES) : null;
669         },
670
671         /**
672          * Updates the body section of the standard module with the content provided (either an HTML string, or node reference).
673          * <p>
674          * This method can be used instead of the corresponding section content attribute if you'd like to retain the current content of the section,
675          * and insert content before or after it, by specifying the <code>where</code> argument.
676          * </p>
677          * @method setStdModContent
678          * @param {String} section The standard module section whose content is to be updated. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
679          * @param {String | Node} content The content to be added, either an HTML string or a Node reference.
680          * @param {String} where Optional. Either WidgetStdMod.AFTER, WidgetStdMod.BEFORE or WidgetStdMod.REPLACE.
681          * If not provided, the content will replace existing content in the section.
682          */
683         setStdModContent : function(section, content, where) {
684             this.set(section + CONTENT_SUFFIX, content, {stdModPosition:where});
685         },
686
687         /**
688          * Returns the node reference for the given section. Note: The DOM is not queried for the node reference. The reference
689          * stored by the widget instance is returned if set.
690          * 
691          * @method getStdModNode
692          * @param {String} section The section whose node reference is required. Either WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER.
693          * @return {Node} The node reference for the section, or null if not set.
694          */
695         getStdModNode : function(section) {
696             return this[section + NODE_SUFFIX] || null;
697         },
698
699         /**
700          * Sets the height on the provided header, body or footer element to 
701          * fill out the height of the Widget. It determines the height of the 
702          * widgets bounding box, based on it's configured height value, and 
703          * sets the height of the provided section to fill out any 
704          * space remaining after the other standard module section heights 
705          * have been accounted for.
706          * 
707          * <p><strong>NOTE:</strong> This method is not designed to work if an explicit 
708          * height has not been set on the Widget, since for an "auto" height Widget, 
709          * the heights of the header/body/footer will drive the height of the Widget.</p>
710          *
711          * @method fillHeight
712          * @param {Node} node The node which should be resized to fill out the height
713          * of the Widget bounding box. Should be a standard module section node which belongs
714          * to the widget.
715          */
716         fillHeight : function(node) {
717             if (node) {
718                 var contentBox = this.get(CONTENT_BOX),
719                     stdModNodes = [this.headerNode, this.bodyNode, this.footerNode],
720                     stdModNode,
721                     cbContentHeight,
722                     filled = 0,
723                     remaining = 0,
724
725                     validNode = false;
726
727                 for (var i = 0, l = stdModNodes.length; i < l; i++) {
728                     stdModNode = stdModNodes[i];
729                     if (stdModNode) {
730                         if (stdModNode !== node) {
731                             filled += this._getPreciseHeight(stdModNode);
732                         } else {
733                             validNode = true;
734                         }
735                     }
736                 }
737
738                 if (validNode) {
739                     if (UA.ie || UA.opera) {
740                         // Need to set height to 0, to allow height to be reduced
741                         node.set(OFFSET_HEIGHT, 0);
742                     }
743
744                     cbContentHeight = contentBox.get(OFFSET_HEIGHT) -
745                             parseInt(contentBox.getComputedStyle("paddingTop"), 10) - 
746                             parseInt(contentBox.getComputedStyle("paddingBottom"), 10) - 
747                             parseInt(contentBox.getComputedStyle("borderBottomWidth"), 10) - 
748                             parseInt(contentBox.getComputedStyle("borderTopWidth"), 10);
749
750                     if (L.isNumber(cbContentHeight)) {
751                         remaining = cbContentHeight - filled;
752                         if (remaining >= 0) {
753                             node.set(OFFSET_HEIGHT, remaining);
754                         }
755                     }
756                 }
757             }
758         }
759     };
760
761     Y.WidgetStdMod = StdMod;
762
763
764 }, '3.3.0' ,{requires:['base-build', 'widget']});