-
Notifications
You must be signed in to change notification settings - Fork 0
/
collapse.js
42 lines (36 loc) · 1.05 KB
/
collapse.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$(document).ready(function() {
$('.minus').click(function() {
var $input = $(this).parent().find('input');
var count = parseInt($input.val()) - 1;
count = count < 0 ? 0 : count;
$input.val(count);
$input.change();
return false;
});
$('.plus').click(function() {
var $input = $(this).parent().find('input');
$input.val(parseInt($input.val()) + 1);
$input.change();
return false;
});
});
// to toggle arrow (and update text color) on click
var showingMore = false;
var showingExplanation = false;
function toggleArrow(id) {
var button = document.getElementById(id);
var collapsedQ = false;
if (id == "more") {
showingMore = collapsedQ = !showingMore
} else if (id == "explain") {
showingExplanation = collapsedQ = !showingExplanation
};
console.log(button.innerHTML);
if (collapsedQ) {
button.innerHTML = button.innerHTML.replace("▽", "△");
button.style = "color: #ddd";
} else {
button.innerHTML = button.innerHTML.replace("△", "▽");
button.style = "color: gray";
}
}