[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/widget-stdmod/ -> widget-stdmod.js (source)

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


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1