src/cm/media/js/lib/yui/yui3-3.15.0/build/widget-stdmod/widget-stdmod.js
changeset 602 e16a97fb364a
equal deleted inserted replaced
601:d334a616c023 602:e16a97fb364a
       
     1 YUI.add('widget-stdmod', function (Y, NAME) {
       
     2 
       
     3 /**
       
     4  * Provides standard module support for Widgets through an extension.
       
     5  *
       
     6  * @module widget-stdmod
       
     7  */
       
     8     var L = Y.Lang,
       
     9         Node = Y.Node,
       
    10         UA = Y.UA,
       
    11         Widget = Y.Widget,
       
    12 
       
    13         EMPTY = "",
       
    14         HD = "hd",
       
    15         BD = "bd",
       
    16         FT = "ft",
       
    17         HEADER = "header",
       
    18         BODY = "body",
       
    19         FOOTER = "footer",
       
    20         FILL_HEIGHT = "fillHeight",
       
    21         STDMOD = "stdmod",
       
    22 
       
    23         NODE_SUFFIX = "Node",
       
    24         CONTENT_SUFFIX = "Content",
       
    25 
       
    26         FIRST_CHILD = "firstChild",
       
    27         CHILD_NODES = "childNodes",
       
    28         OWNER_DOCUMENT = "ownerDocument",
       
    29 
       
    30         CONTENT_BOX = "contentBox",
       
    31 
       
    32         HEIGHT = "height",
       
    33         OFFSET_HEIGHT = "offsetHeight",
       
    34         AUTO = "auto",
       
    35 
       
    36         HeaderChange = "headerContentChange",
       
    37         BodyChange = "bodyContentChange",
       
    38         FooterChange = "footerContentChange",
       
    39         FillHeightChange = "fillHeightChange",
       
    40         HeightChange = "heightChange",
       
    41         ContentUpdate = "contentUpdate",
       
    42 
       
    43         RENDERUI = "renderUI",
       
    44         BINDUI = "bindUI",
       
    45         SYNCUI = "syncUI",
       
    46 
       
    47         APPLY_PARSED_CONFIG = "_applyParsedConfig",
       
    48 
       
    49         UI = Y.Widget.UI_SRC;
       
    50 
       
    51     /**
       
    52      * Widget extension, which can be used to add Standard Module support to the
       
    53      * base Widget class, through the <a href="Base.html#method_build">Base.build</a>
       
    54      * method.
       
    55      * <p>
       
    56      * The extension adds header, body and footer sections to the Widget's content box and
       
    57      * provides the corresponding methods and attributes to modify the contents of these sections.
       
    58      * </p>
       
    59      * @class WidgetStdMod
       
    60      * @param {Object} The user configuration object
       
    61      */
       
    62     function StdMod(config) {}
       
    63 
       
    64     /**
       
    65      * Constant used to refer the the standard module header, in methods which expect a section specifier
       
    66      *
       
    67      * @property HEADER
       
    68      * @static
       
    69      * @type String
       
    70      */
       
    71     StdMod.HEADER = HEADER;
       
    72 
       
    73     /**
       
    74      * Constant used to refer the the standard module body, in methods which expect a section specifier
       
    75      *
       
    76      * @property BODY
       
    77      * @static
       
    78      * @type String
       
    79      */
       
    80     StdMod.BODY = BODY;
       
    81 
       
    82     /**
       
    83      * Constant used to refer the the standard module footer, in methods which expect a section specifier
       
    84      *
       
    85      * @property FOOTER
       
    86      * @static
       
    87      * @type String
       
    88      */
       
    89     StdMod.FOOTER = FOOTER;
       
    90 
       
    91     /**
       
    92      * Constant used to specify insertion position, when adding content to sections of the standard module in
       
    93      * methods which expect a "where" argument.
       
    94      * <p>
       
    95      * Inserts new content <em>before</em> the sections existing content.
       
    96      * </p>
       
    97      * @property AFTER
       
    98      * @static
       
    99      * @type String
       
   100      */
       
   101     StdMod.AFTER = "after";
       
   102 
       
   103     /**
       
   104      * Constant used to specify insertion position, when adding content to sections of the standard module in
       
   105      * methods which expect a "where" argument.
       
   106      * <p>
       
   107      * Inserts new content <em>before</em> the sections existing content.
       
   108      * </p>
       
   109      * @property BEFORE
       
   110      * @static
       
   111      * @type String
       
   112      */
       
   113     StdMod.BEFORE = "before";
       
   114     /**
       
   115      * Constant used to specify insertion position, when adding content to sections of the standard module in
       
   116      * methods which expect a "where" argument.
       
   117      * <p>
       
   118      * <em>Replaces</em> the sections existing content, with new content.
       
   119      * </p>
       
   120      * @property REPLACE
       
   121      * @static
       
   122      * @type String
       
   123      */
       
   124     StdMod.REPLACE = "replace";
       
   125 
       
   126     var STD_HEADER = StdMod.HEADER,
       
   127         STD_BODY = StdMod.BODY,
       
   128         STD_FOOTER = StdMod.FOOTER,
       
   129 
       
   130         HEADER_CONTENT = STD_HEADER + CONTENT_SUFFIX,
       
   131         FOOTER_CONTENT = STD_FOOTER + CONTENT_SUFFIX,
       
   132         BODY_CONTENT = STD_BODY + CONTENT_SUFFIX;
       
   133 
       
   134     /**
       
   135      * Static property used to define the default attribute
       
   136      * configuration introduced by WidgetStdMod.
       
   137      *
       
   138      * @property ATTRS
       
   139      * @type Object
       
   140      * @static
       
   141      */
       
   142     StdMod.ATTRS = {
       
   143 
       
   144         /**
       
   145          * @attribute headerContent
       
   146          * @type HTML
       
   147          * @default undefined
       
   148          * @description The content to be added to the header section. This will replace any existing content
       
   149          * in the header. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
       
   150          */
       
   151         headerContent: {
       
   152             value:null
       
   153         },
       
   154 
       
   155         /**
       
   156          * @attribute footerContent
       
   157          * @type HTML
       
   158          * @default undefined
       
   159          * @description The content to be added to the footer section. This will replace any existing content
       
   160          * in the footer. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
       
   161          */
       
   162         footerContent: {
       
   163             value:null
       
   164         },
       
   165 
       
   166         /**
       
   167          * @attribute bodyContent
       
   168          * @type HTML
       
   169          * @default undefined
       
   170          * @description The content to be added to the body section. This will replace any existing content
       
   171          * in the body. If you want to append, or insert new content, use the <a href="#method_setStdModContent">setStdModContent</a> method.
       
   172          */
       
   173         bodyContent: {
       
   174             value:null
       
   175         },
       
   176 
       
   177         /**
       
   178          * @attribute fillHeight
       
   179          * @type {String}
       
   180          * @default WidgetStdMod.BODY
       
   181          * @description The section (WidgetStdMod.HEADER, WidgetStdMod.BODY or WidgetStdMod.FOOTER) which should be resized to fill the height of the standard module, when a
       
   182          * height is set on the Widget. If a height is not set on the widget, then all sections are sized based on
       
   183          * their content.
       
   184          */
       
   185         fillHeight: {
       
   186             value: StdMod.BODY,
       
   187             validator: function(val) {
       
   188                  return this._validateFillHeight(val);
       
   189             }
       
   190         }
       
   191     };
       
   192 
       
   193     /**
       
   194      * The HTML parsing rules for the WidgetStdMod class.
       
   195      *
       
   196      * @property HTML_PARSER
       
   197      * @static
       
   198      * @type Object
       
   199      */
       
   200     StdMod.HTML_PARSER = {
       
   201         headerContent: function(contentBox) {
       
   202             return this._parseStdModHTML(STD_HEADER);
       
   203         },
       
   204 
       
   205         bodyContent: function(contentBox) {
       
   206             return this._parseStdModHTML(STD_BODY);
       
   207         },
       
   208 
       
   209         footerContent : function(contentBox) {
       
   210             return this._parseStdModHTML(STD_FOOTER);
       
   211         }
       
   212     };
       
   213 
       
   214     /**
       
   215      * Static hash of default class names used for the header,
       
   216      * body and footer sections of the standard module, keyed by
       
   217      * the section identifier (WidgetStdMod.STD_HEADER, WidgetStdMod.STD_BODY, WidgetStdMod.STD_FOOTER)
       
   218      *
       
   219      * @property SECTION_CLASS_NAMES
       
   220      * @static
       
   221      * @type Object
       
   222      */
       
   223     StdMod.SECTION_CLASS_NAMES = {
       
   224         header: Widget.getClassName(HD),
       
   225         body: Widget.getClassName(BD),
       
   226         footer: Widget.getClassName(FT)
       
   227     };
       
   228 
       
   229     /**
       
   230      * The template HTML strings for each of the standard module sections. Section entries are keyed by the section constants,
       
   231      * WidgetStdMod.HEADER, WidgetStdMod.BODY, WidgetStdMod.FOOTER, and contain the HTML to be added for each section.
       
   232      * e.g.
       
   233      * <pre>
       
   234      *    {
       
   235      *       header : '&lt;div class="yui-widget-hd"&gt;&lt;/div&gt;',
       
   236      *       body : '&lt;div class="yui-widget-bd"&gt;&lt;/div&gt;',
       
   237      *       footer : '&lt;div class="yui-widget-ft"&gt;&lt;/div&gt;'
       
   238      *    }
       
   239      * </pre>
       
   240      * @property TEMPLATES
       
   241      * @type Object
       
   242      * @static
       
   243      */
       
   244     StdMod.TEMPLATES = {
       
   245         header : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_HEADER] + '"></div>',
       
   246         body : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_BODY] + '"></div>',
       
   247         footer : '<div class="' + StdMod.SECTION_CLASS_NAMES[STD_FOOTER] + '"></div>'
       
   248     };
       
   249 
       
   250     StdMod.prototype = {
       
   251 
       
   252         initializer : function() {
       
   253             this._stdModNode = this.get(CONTENT_BOX);
       
   254 
       
   255             Y.before(this._renderUIStdMod, this, RENDERUI);
       
   256             Y.before(this._bindUIStdMod, this, BINDUI);
       
   257             Y.before(this._syncUIStdMod, this, SYNCUI);
       
   258         },
       
   259 
       
   260         /**
       
   261          * Synchronizes the UI to match the Widgets standard module state.
       
   262          * <p>
       
   263          * This method is invoked after syncUI is invoked for the Widget class
       
   264          * using YUI's aop infrastructure.
       
   265          * </p>
       
   266          * @method _syncUIStdMod
       
   267          * @protected
       
   268          */
       
   269         _syncUIStdMod : function() {
       
   270             var stdModParsed = this._stdModParsed;
       
   271 
       
   272             if (!stdModParsed || !stdModParsed[HEADER_CONTENT]) {
       
   273                 this._uiSetStdMod(STD_HEADER, this.get(HEADER_CONTENT));
       
   274             }
       
   275 
       
   276             if (!stdModParsed || !stdModParsed[BODY_CONTENT]) {
       
   277                 this._uiSetStdMod(STD_BODY, this.get(BODY_CONTENT));
       
   278             }
       
   279 
       
   280             if (!stdModParsed || !stdModParsed[FOOTER_CONTENT]) {
       
   281                 this._uiSetStdMod(STD_FOOTER, this.get(FOOTER_CONTENT));
       
   282             }
       
   283 
       
   284             this._uiSetFillHeight(this.get(FILL_HEIGHT));
       
   285         },
       
   286 
       
   287         /**
       
   288          * Creates/Initializes the DOM for standard module support.
       
   289          * <p>
       
   290          * This method is invoked after renderUI is invoked for the Widget class
       
   291          * using YUI's aop infrastructure.
       
   292          * </p>
       
   293          * @method _renderUIStdMod
       
   294          * @protected
       
   295          */
       
   296         _renderUIStdMod : function() {
       
   297             this._stdModNode.addClass(Widget.getClassName(STDMOD));
       
   298             this._renderStdModSections();
       
   299 
       
   300             //This normally goes in bindUI but in order to allow setStdModContent() to work before renderUI
       
   301             //stage, these listeners should be set up at the earliest possible time.
       
   302             this.after(HeaderChange, this._afterHeaderChange);
       
   303             this.after(BodyChange, this._afterBodyChange);
       
   304             this.after(FooterChange, this._afterFooterChange);
       
   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.getStdModNode(this.get(FILL_HEIGHT)));
       
   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, true);
       
   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             //var node = this.getStdModNode(section) || this._renderStdMod(section);
       
   685             this.set(section + CONTENT_SUFFIX, content, {stdModPosition:where});
       
   686             //this._addStdModContent(node, content, where);
       
   687         },
       
   688 
       
   689         /**
       
   690         Returns the node reference for the specified `section`.
       
   691 
       
   692         **Note:** The DOM is not queried for the node reference. The reference
       
   693         stored by the widget instance is returned if it was set. Passing a
       
   694         truthy for `forceCreate` will create the section node if it does not
       
   695         already exist.
       
   696 
       
   697         @method getStdModNode
       
   698         @param {String} section The section whose node reference is required.
       
   699             Either `WidgetStdMod.HEADER`, `WidgetStdMod.BODY`, or
       
   700             `WidgetStdMod.FOOTER`.
       
   701         @param {Boolean} forceCreate Whether the section node should be created
       
   702             if it does not already exist.
       
   703         @return {Node} The node reference for the `section`, or null if not set.
       
   704         **/
       
   705         getStdModNode : function(section, forceCreate) {
       
   706             var node = this[section + NODE_SUFFIX] || null;
       
   707 
       
   708             if (!node && forceCreate) {
       
   709                 node = this._renderStdMod(section);
       
   710             }
       
   711 
       
   712             return node;
       
   713         },
       
   714 
       
   715         /**
       
   716          * Sets the height on the provided header, body or footer element to
       
   717          * fill out the height of the Widget. It determines the height of the
       
   718          * widgets bounding box, based on it's configured height value, and
       
   719          * sets the height of the provided section to fill out any
       
   720          * space remaining after the other standard module section heights
       
   721          * have been accounted for.
       
   722          *
       
   723          * <p><strong>NOTE:</strong> This method is not designed to work if an explicit
       
   724          * height has not been set on the Widget, since for an "auto" height Widget,
       
   725          * the heights of the header/body/footer will drive the height of the Widget.</p>
       
   726          *
       
   727          * @method fillHeight
       
   728          * @param {Node} node The node which should be resized to fill out the height
       
   729          * of the Widget bounding box. Should be a standard module section node which belongs
       
   730          * to the widget.
       
   731          */
       
   732         fillHeight : function(node) {
       
   733             if (node) {
       
   734                 var contentBox = this.get(CONTENT_BOX),
       
   735                     stdModNodes = [this.headerNode, this.bodyNode, this.footerNode],
       
   736                     stdModNode,
       
   737                     cbContentHeight,
       
   738                     filled = 0,
       
   739                     remaining = 0,
       
   740 
       
   741                     validNode = false;
       
   742 
       
   743                 for (var i = 0, l = stdModNodes.length; i < l; i++) {
       
   744                     stdModNode = stdModNodes[i];
       
   745                     if (stdModNode) {
       
   746                         if (stdModNode !== node) {
       
   747                             filled += this._getPreciseHeight(stdModNode);
       
   748                         } else {
       
   749                             validNode = true;
       
   750                         }
       
   751                     }
       
   752                 }
       
   753 
       
   754                 if (validNode) {
       
   755                     if (UA.ie || UA.opera) {
       
   756                         // Need to set height to 0, to allow height to be reduced
       
   757                         node.set(OFFSET_HEIGHT, 0);
       
   758                     }
       
   759 
       
   760                     cbContentHeight = contentBox.get(OFFSET_HEIGHT) -
       
   761                             parseInt(contentBox.getComputedStyle("paddingTop"), 10) -
       
   762                             parseInt(contentBox.getComputedStyle("paddingBottom"), 10) -
       
   763                             parseInt(contentBox.getComputedStyle("borderBottomWidth"), 10) -
       
   764                             parseInt(contentBox.getComputedStyle("borderTopWidth"), 10);
       
   765 
       
   766                     if (L.isNumber(cbContentHeight)) {
       
   767                         remaining = cbContentHeight - filled;
       
   768                         if (remaining >= 0) {
       
   769                             node.set(OFFSET_HEIGHT, remaining);
       
   770                         }
       
   771                     }
       
   772                 }
       
   773             }
       
   774         }
       
   775     };
       
   776 
       
   777     Y.WidgetStdMod = StdMod;
       
   778 
       
   779 
       
   780 }, '@VERSION@', {"requires": ["base-build", "widget"]});