Skip to content

Commit 18ce96a

Browse files
SunboXSergioCrisostomo
authored andcommitted
Keep multiple elements open, only close on "click"
Added new config option "keepOpen" to keep multiple elements open (no auto collapsing). To close a element you have to "click" the trigger again. Defaults to "false", so this won´t be a breaking change.
1 parent c6a90c3 commit 18ce96a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Source/Fx/Fx.Accordion.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Fx.Accordion = new Class({
3838
alwaysHide: false,
3939
trigger: 'click',
4040
initialDisplayFx: true,
41-
resetHeight: true
41+
resetHeight: true,
42+
keepOpen: false
4243
},
4344

4445
initialize: function(){
@@ -182,15 +183,17 @@ Fx.Accordion = new Class({
182183
elements.each(function(el, i){
183184
obj[i] = {};
184185
var hide;
185-
if (i != index){
186-
hide = true;
187-
} else if (options.alwaysHide && ((el.offsetHeight > 0 && options.height) || el.offsetWidth > 0 && options.width)){
188-
hide = true;
189-
this.selfHidden = true;
186+
if(!options.keepOpen || i == index){
187+
if (i != index){
188+
hide = true;
189+
} else if (options.alwaysHide && ((el.offsetHeight > 0 && options.height) || el.offsetWidth > 0 && options.width)){
190+
hide = true;
191+
this.selfHidden = true;
192+
}
193+
this.fireEvent(hide ? 'background' : 'active', [this.togglers[i], el]);
194+
for (var fx in effects) obj[i][fx] = hide ? 0 : el[effects[fx]];
195+
if (!useFx && !hide && options.resetHeight) obj[i].height = 'auto';
190196
}
191-
this.fireEvent(hide ? 'background' : 'active', [this.togglers[i], el]);
192-
for (var fx in effects) obj[i][fx] = hide ? 0 : el[effects[fx]];
193-
if (!useFx && !hide && options.resetHeight) obj[i].height = 'auto';
194197
}, this);
195198

196199
this.internalChain.clearChain();

0 commit comments

Comments
 (0)