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

Commit 79eff70

Browse files
committed
downloads.js: minor tweaks.
1 parent df599c4 commit 79eff70

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

source/assets/js/downloads.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
$(function() {
44
'use strict';
55

6-
var $el = $('.toggleLink');
6+
var $toggleLink = $('.toggleLink');
7+
var $totalToggleLinkCount = $('.toggleLink').length;
78

8-
if ($el.length === 0) {
9+
if ($totalToggleLinkCount === 0) {
910
return;
1011
}
1112

12-
var collapsedToggleLinkCount = $('.toggleLink.collapsed').length;
13-
var totalToggleLinkCount = $el.length;
13+
var $collapsedToggleLinkCount = $('.toggleLink.collapsed').length;
1414

15-
function checkButtonState() {
16-
if (collapsedToggleLinkCount === 0) {
15+
function setButtonState() {
16+
if ($collapsedToggleLinkCount === 0) {
1717
// All elements are expanded
1818
$('.closeAll').prop('disabled', false);
1919
$('.expandAll').prop('disabled', true);
20-
} else if (collapsedToggleLinkCount === totalToggleLinkCount) {
20+
} else if ($collapsedToggleLinkCount === $totalToggleLinkCount) {
2121
// All elements are collapsed
2222
$('.closeAll').prop('disabled', true);
2323
$('.expandAll').prop('disabled', false);
@@ -27,27 +27,27 @@ $(function() {
2727
}
2828
}
2929

30-
$el.on('click', function() {
30+
$toggleLink.on('click', function() {
3131
// If the .toggleLink element has the `.collapsed` class,
32-
// decrease or increase the collapsedToggleLinkCount
32+
// decrease or increase the $collapsedToggleLinkCount
3333
if ($(this).hasClass('collapsed')) {
34-
collapsedToggleLinkCount--;
34+
$collapsedToggleLinkCount--;
3535
} else {
36-
collapsedToggleLinkCount++;
36+
$collapsedToggleLinkCount++;
3737
}
3838

39-
checkButtonState();
39+
setButtonState();
4040
});
4141

4242
$('.closeAll').click(function() {
4343
$('.panel-collapse.in').collapse('hide'); // hide any `panel`s
44-
collapsedToggleLinkCount = totalToggleLinkCount; // reset the global count
45-
checkButtonState();
44+
$collapsedToggleLinkCount = $totalToggleLinkCount; // reset the global count
45+
setButtonState();
4646
});
4747

4848
$('.expandAll').click(function() {
4949
$('.panel-collapse:not(".in")').collapse('show'); // show any `panel`s
50-
collapsedToggleLinkCount = 0; // reset the global count
51-
checkButtonState();
50+
$collapsedToggleLinkCount = 0; // reset the global count
51+
setButtonState();
5252
});
5353
});

0 commit comments

Comments
 (0)