2
* very simple plugin to collapse a node witha given transition type
4
Y.namespace('Plugin').Collapse = Y.Base.create('collapse', Y.Plugin.Base, [], {
5
initializer: function() {
6
this.host = this.get('host');
8
this.state = this.get('state') || null;
10
this.config = this.getAttrs(['easing', 'duration']);
12
this.host.addClass('collapse');
13
// if state is set to closed/false, set height to 0
14
if (!this.get('state')) {
15
this.host.addClass('in');
16
this.host.setStyle('height', 0);
23
host.removeClass('collapse')
24
.addClass('collapsing');
26
plugin.config.height = host.get('scrollHeight') + 'px';
28
host.transition(plugin.config, function(e) {
29
this.replaceClass('collapsing', 'collapse')
32
this.collapse.set('state', true);
38
plugin.config.height = 0;
40
host.removeClass('collapse')
41
.addClass('collapsing');
43
host.transition(this.config, function() {
44
this.replaceClass('collapsing', 'collapse')
47
this.collapse.set('state', false);
52
if (this.get('state')) {
68
// truthy if open, falsey if closed