src/cm/media/js/lib/yui/yui3-3.15.0/build/datatable-foot/datatable-foot.js
changeset 602 e16a97fb364a
equal deleted inserted replaced
601:d334a616c023 602:e16a97fb364a
       
     1 YUI.add('datatable-foot', function (Y, NAME) {
       
     2 
       
     3 /**
       
     4 View class responsible for rendering the `<tfoot>` section of a table. Can be
       
     5 used as the default `footerView` for `Y.DataTable.Base` and `Y.DataTable`
       
     6 classes.
       
     7 
       
     8 @module datatable
       
     9 @submodule datatable-foot
       
    10 @since 3.11.0
       
    11 **/
       
    12 
       
    13 
       
    14 Y.namespace('DataTable').FooterView = Y.Base.create('tableFooter', Y.View, [], {
       
    15     // -- Instance properties -------------------------------------------------
       
    16 
       
    17     /**
       
    18     HTML templates used to create the `<tfoot>` containing the table footers.
       
    19 
       
    20     @property TFOOT_TEMPLATE
       
    21     @type {String}
       
    22     @default '<tfoot class="{className}"/>'
       
    23     @since 3.11.0
       
    24     **/
       
    25     TFOOT_TEMPLATE: '<tfoot class="{className}"/>',
       
    26 
       
    27     // -- Public methods ------------------------------------------------------
       
    28 
       
    29     /**
       
    30     Returns the generated CSS classname based on the input.  If the `host`
       
    31     attribute is configured, it will attempt to relay to its `getClassName`
       
    32     or use its static `NAME` property as a string base.
       
    33 
       
    34     If `host` is absent or has neither method nor `NAME`, a CSS classname
       
    35     will be generated using this class's `NAME`.
       
    36 
       
    37     @method getClassName
       
    38     @param {String} token* Any number of token strings to assemble the
       
    39         classname from.
       
    40     @return {String}
       
    41     @protected
       
    42     @since 3.11.0
       
    43     **/
       
    44     getClassName: function () {
       
    45         // TODO: add attribute with setter? to host to use property this.host
       
    46         // for performance
       
    47         var host = this.host,
       
    48             NAME = (host && host.constructor.NAME) ||
       
    49                     this.constructor.NAME;
       
    50 
       
    51         if (host && host.getClassName) {
       
    52             return host.getClassName.apply(host, arguments);
       
    53         } else {
       
    54             return Y.ClassNameManager.getClassName
       
    55                 .apply(Y.ClassNameManager,
       
    56                        [NAME].concat(Y.Array(arguments, 0, true)));
       
    57         }
       
    58     },
       
    59 
       
    60     /**
       
    61     Creates the `<tfoot>` Node and inserts it after the `<thead>` Node.
       
    62 
       
    63     @method render
       
    64     @return {FooterView} The instance
       
    65     @chainable
       
    66     @since 3.11.0
       
    67     **/
       
    68     render: function () {
       
    69         var tfoot    = this.tfootNode ||
       
    70                         (this.tfootNode = this._createTFootNode());
       
    71 
       
    72         if (this.host && this.host._theadNode) {
       
    73             this.host._theadNode.insert(tfoot, 'after');
       
    74         }
       
    75 
       
    76         return this;
       
    77     },
       
    78 
       
    79     /**
       
    80     Creates the `<tfoot>` node that will store the footer rows and cells.
       
    81 
       
    82     @method _createTFootNode
       
    83     @return {Node}
       
    84     @protected
       
    85     @since 3.11.0
       
    86     **/
       
    87     _createTFootNode: function () {
       
    88         return Y.Node.create(Y.Lang.sub(this.TFOOT_TEMPLATE, {
       
    89             className: this.getClassName('foot')
       
    90         }));
       
    91     },
       
    92 
       
    93     /**
       
    94     Initializes the instance. Reads the following configuration properties:
       
    95 
       
    96       * `host`    - The object to serve as source of truth for column info
       
    97 
       
    98     @method initializer
       
    99     @param {Object} config Configuration data
       
   100     @protected
       
   101     @since 3.11.0
       
   102     **/
       
   103     initializer: function (config) {
       
   104         this.host  = (config && config.host);
       
   105     }
       
   106 
       
   107 
       
   108 
       
   109 });
       
   110 
       
   111 
       
   112 }, '@VERSION@', {"requires": ["datatable-core", "view"]});