-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathmd-card-collapsible.js
More file actions
37 lines (31 loc) · 949 Bytes
/
md-card-collapsible.js
File metadata and controls
37 lines (31 loc) · 949 Bytes
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
import { computed } from '@ember/object';
import Component from '@ember/component';
import layout from '../templates/components/md-card-collapsible';
import jQuery from 'jquery';
export default Component.extend({
layout,
tagName: 'ul',
classNames: ['collapsible'],
attributeBindings: ['data-collapsible'],
accordion: true,
'data-collapsible': computed(function() {
return this.get('accordion') ? 'accordion' : 'expandable';
}),
didInsertElement() {
this._super(...arguments);
this._setupCollapsible();
},
_setupCollapsible() {
const accordion = this.get('accordion');
jQuery().collapsible({ accordion });
},
_teardownCollapsible() {
const $panelHeaders = jQuery('> li > .collapsible-header');
jQuery().off('click.collapse', '.collapsible-header');
$panelHeaders.off('click.collapse');
},
willDestroyElement() {
this._super(...arguments);
this._teardownCollapsible();
}
});