| Total Complexity | 2 |
| Complexity/F | 1 |
| Lines of Code | 53 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | import Backbone from 'backbone'; |
||
|
|
|||
| 2 | import _ from 'underscore'; |
||
| 3 | import { |
||
| 4 | Backgrid |
||
| 5 | } from './core.js'; |
||
| 6 | /** |
||
| 7 | EmptyRow is a simple container view that takes a list of column and render a |
||
| 8 | row with a single column. |
||
| 9 | |||
| 10 | @class Backgrid.EmptyRow |
||
| 11 | @extends Backbone.View |
||
| 12 | */ |
||
| 13 | var EmptyRow = Backbone.View.extend({ |
||
| 14 | |||
| 15 | /** @property */ |
||
| 16 | tagName: "tr", |
||
| 17 | |||
| 18 | /** @property {string|function(): string} */ |
||
| 19 | emptyText: null, |
||
| 20 | |||
| 21 | /** |
||
| 22 | Initializer. |
||
| 23 | |||
| 24 | @param {Object} options |
||
| 25 | @param {string|function(): string} options.emptyText |
||
| 26 | @param {Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>} options.columns Column metadata. |
||
| 27 | */ |
||
| 28 | initialize: function (options) { |
||
| 29 | this.emptyText = options.emptyText; |
||
| 30 | this.columns = options.columns; |
||
| 31 | }, |
||
| 32 | |||
| 33 | /** |
||
| 34 | Renders an empty row. |
||
| 35 | */ |
||
| 36 | render: function () { |
||
| 37 | this.$el.empty(); |
||
| 38 | |||
| 39 | var td = document.createElement("td"); |
||
| 40 | td.setAttribute("colspan", this.columns.length); |
||
| 41 | var span = document.createElement("span"); |
||
| 42 | span.innerHTML = _.result(this, "emptyText"); |
||
| 43 | td.appendChild(span); |
||
| 44 | |||
| 45 | this.el.className = "empty"; |
||
| 46 | this.el.appendChild(td); |
||
| 47 | |||
| 48 | return this; |
||
| 49 | } |
||
| 50 | }); |
||
| 51 | export { |
||
| 52 | EmptyRow |
||
| 53 | }; |
||
| 54 |