Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit 0dca9cd

Browse files
author
Marlow Payne
committed
Merge branch 'develop' into fix-62
2 parents e2f3dd7 + dcc548a commit 0dca9cd

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
6.0.1
22
- Fix [#62](https://github.com/mobify/bellows/issues/62): Use published Plugin dependency
3+
- Fix [#63](https://github.com/mobify/bellows/issues/63): Short circuit open if other items are opening
34
6.0.0
45
- Publish to NPM
56
- Remove Zepto support in favor of jQuery

dist/bellows.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@
137137
.attr('aria-hidden', true);
138138
},
139139

140+
/*
141+
Checks if other bellows items are currently opening
142+
*/
143+
_othersAreOpening: function() {
144+
return this.$bellows.find('.' + cssClasses.OPENING).length > 0;
145+
},
146+
140147
toggle: function($item) {
141148
$item = this._item($item);
142149

@@ -155,6 +162,11 @@
155162

156163
if (this.options.singleItemOpen) {
157164
this.closeAll();
165+
166+
// Fix #63
167+
if (this._othersAreOpening()) {
168+
return;
169+
}
158170
}
159171

160172
this._trigger('open', {item: $item});

dist/bellows.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/bellows.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@
137137
.attr('aria-hidden', true);
138138
},
139139

140+
/*
141+
Checks if other bellows items are currently opening
142+
*/
143+
_othersAreOpening: function() {
144+
return this.$bellows.find('.' + cssClasses.OPENING).length > 0;
145+
},
146+
140147
toggle: function($item) {
141148
$item = this._item($item);
142149

@@ -155,6 +162,11 @@
155162

156163
if (this.options.singleItemOpen) {
157164
this.closeAll();
165+
166+
// Fix #63
167+
if (this._othersAreOpening()) {
168+
return;
169+
}
158170
}
159171

160172
this._trigger('open', {item: $item});

tests/unit/plugin.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,5 +282,20 @@ define([
282282
expect($openDisabledItem.hasClass('bellows--is-open')).to.be.true;
283283
});
284284
});
285+
286+
describe('a Bellows instance with singleItemOpen set', function() {
287+
it('only allows a single item open when opening another item', function() {
288+
$element.bellows({
289+
singleItemOpen: true,
290+
opened: function() {
291+
$element.bellows('open', 1);
292+
$element.find('.bellows__item.bellows--is-open').to.have.length(1);
293+
done();
294+
}
295+
});
296+
297+
$element.bellows('open', 0);
298+
});
299+
});
285300
});
286301
});

0 commit comments

Comments
 (0)