-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbasic-header.js
51 lines (42 loc) · 1.28 KB
/
basic-header.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Ember from 'ember';
import layout from '../templates/components/basic-header';
const { computed } = Ember;
export default Ember.Component.extend({
layout,
tagName: 'th',
attributeBindings: ['scope'],
classNameBindings: ['alignCenter:center', 'alignRight:right', 'textWrap'],
alignCenter: computed.equal('column.align', 'center'),
alignRight: computed.equal('column.align', 'right'),
textWrap: computed.equal('column.textWrap', true),
column: null,
resizable: computed.readOnly('column.resizable'),
/**
* Accessability attribute that, for screen readers, unambiguously establishes
* the cells that the header comprised by this <th> element relates to.
* @see: http://webaim.org/techniques/tables/data#scope
*/
scope: 'col',
didRender() {
let table = this.get('table');
this._setColumnWidth();
table.ensureEqualHeaderHeight();
},
updateColumnWidths: Ember.observer('column.width', function() {
let table = this.get('table');
table.columnWidthsChanged();
}),
_setColumnWidth() {
const width = this.get('column.width');
if (!width) {
return;
}
this.element.style.width = `${width}px`;
},
actions: {
onColumnWidthChange() {
this._setColumnWidth();
this.attrs.onColumnWidthChange();
}
}
});