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