API Docs for: 3.18.1
Show:

File: datatable/js/foot.js

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