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

Commit a530948

Browse files
author
Steve Calvert
committed
Rebuilding and merging changes from master
2 parents 9113d4a + 4c30194 commit a530948

File tree

6 files changed

+140
-5
lines changed

6 files changed

+140
-5
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bellows",
3-
"version": "5.0.1",
3+
"version": "5.1.1",
44
"homepage": "https://github.com/mobify/bellows",
55
"authors": [
66
"Mobify <jobs@mobify.com>"

dist/bellows.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
Bellows.__super__.call(this, element, options, Bellows.DEFAULTS);
3434
}
3535

36-
Bellows.VERSION = '5.0.1';
36+
Bellows.VERSION = '5.1.1';
3737

3838
Bellows.DEFAULTS = {
3939
singleItemOpen: false,
@@ -208,6 +208,22 @@
208208
});
209209
},
210210

211+
toggleAll: function() {
212+
var plugin = this;
213+
214+
this.$bellows.find('.' + cssClasses.ITEM).each(function() {
215+
plugin.toggle($(this));
216+
});
217+
},
218+
219+
openAll: function() {
220+
var plugin = this;
221+
222+
this.$bellows.find('.' + cssClasses.ITEM + ':not(.' + cssClasses.OPENED + ')').each(function() {
223+
plugin.open($(this));
224+
});
225+
},
226+
211227
closeAll: function() {
212228
var plugin = this;
213229

dist/bellows.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type" : "git",
55
"url" : "https://github.com/mobify/bellows.git"
66
},
7-
"version": "5.0.1",
7+
"version": "5.1.1",
88
"description": "A mobile first accordion UI plugin",
99
"devDependencies": {
1010
"grunt": "~0.4.x",

src/js/bellows.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@
208208
});
209209
},
210210

211+
toggleAll: function() {
212+
var plugin = this;
213+
214+
this.$bellows.find('.' + cssClasses.ITEM).each(function() {
215+
plugin.toggle($(this));
216+
});
217+
},
218+
219+
openAll: function() {
220+
var plugin = this;
221+
222+
this.$bellows.find('.' + cssClasses.ITEM + ':not(.' + cssClasses.OPENED + ')').each(function() {
223+
plugin.open($(this));
224+
});
225+
},
226+
211227
closeAll: function() {
212228
var plugin = this;
213229

tests/unit/plugin.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,109 @@ define([
8888
$element.bellows('open', 0);
8989
});
9090

91+
it('opens all bellows items using the openAll method', function(done) {
92+
93+
var openCount = 0;
94+
95+
$element.bellows({
96+
opened: function(e, ui) {
97+
expect(ui.item.hasClass('bellows--is-open')).to.be.true;
98+
openCount++;
99+
100+
if (openCount === 2) {
101+
done();
102+
}
103+
}
104+
});
105+
106+
$element.bellows('openAll');
107+
});
108+
109+
it('closes all bellows items using the closeAll method', function(done) {
110+
111+
var openCount = 0;
112+
var closeCount = 0;
113+
114+
$element.bellows({
115+
opened: function(e, ui) {
116+
openCount++;
117+
if (openCount === 2) {
118+
$element.bellows('closeAll');
119+
}
120+
},
121+
closed: function(e, ui) {
122+
expect(ui.item.hasClass('bellows--is-open')).to.be.false;
123+
closeCount++;
124+
125+
if (closeCount === 2) {
126+
done();
127+
}
128+
}
129+
});
130+
131+
$element.bellows('openAll');
132+
});
133+
134+
it('opens all bellows items when not all are open', function(done) {
135+
136+
var openedSingle = false;
137+
138+
$element.bellows({
139+
opened: function(e, ui) {
140+
if (!openedSingle) {
141+
openedSingle = true;
142+
$element.bellows('openAll');
143+
return;
144+
}
145+
146+
expect($element.find('.bellows--is-open')).to.have.length(2);
147+
done();
148+
}
149+
});
150+
151+
$element.bellows('open', 0);
152+
});
153+
154+
it('closes all bellows items when not all are closed', function(done) {
155+
156+
$element.bellows({
157+
opened: function(e, ui) {
158+
$element.bellows('closeAll');
159+
},
160+
closed: function(e, ui) {
161+
expect($element.find('.bellows__item:not(.bellows--is-open)')).to.have.length(2);
162+
done();
163+
}
164+
});
165+
166+
$element.bellows('open', 0);
167+
});
168+
169+
it('toggles all bellows items', function(done) {
170+
171+
var openCount = 0;
172+
var closeCount = 0;
173+
174+
$element.bellows({
175+
opened: function(e, ui) {
176+
openCount++;
177+
if (openCount === 2) {
178+
$element.bellows('toggleAll');
179+
}
180+
},
181+
closed: function(e, ui) {
182+
closeCount++;
183+
184+
if (closeCount === 2) {
185+
expect($element.find('.bellows__item:not(.bellows--is-open)')).to.have.length(2);
186+
done();
187+
}
188+
}
189+
});
190+
191+
$element.bellows('toggleAll');
192+
});
193+
91194
it('removes aria-hidden attribute when open', function(done) {
92195
$element.bellows({
93196
opened: function(e, ui) {

0 commit comments

Comments
 (0)