Skip to content

Commit 26590d9

Browse files
committed
day 10
1 parent 8defa3e commit 26590d9

File tree

5 files changed

+85
-1
lines changed

5 files changed

+85
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Hold shift and checkboxes
2+
Watch this challenge live in [codepen]().
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*jshint esversion: 6 */
2+
3+
(function() {
4+
5+
const checkboxes = document.querySelectorAll('input');
6+
checkboxes.forEach(checkbox => checkbox.addEventListener('click', handleClick));
7+
let lastChecked;
8+
9+
function handleClick(e) {
10+
let inBetween = false;
11+
if(e.shiftKey && this.checked) {
12+
13+
checkboxes.forEach(checkbox => {
14+
if(this === checkbox || checkbox === lastChecked) {
15+
inBetween = !inBetween;
16+
}
17+
18+
if(inBetween) {
19+
checkbox.checked = true;
20+
}
21+
});
22+
}
23+
24+
lastChecked = this;
25+
}
26+
27+
})();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Hold shift and checkboxes</title>
6+
<link rel="stylesheet" href="style.css" media="screen" title="no title">
7+
</head>
8+
<body>
9+
<ul class="list">
10+
<li><input type="checkbox"><label>Task 1</label></li>
11+
<li><input type="checkbox"><label>Task 2</label></li>
12+
<li><input type="checkbox"><label>Task 3</label></li>
13+
<li><input type="checkbox"><label>Task 4</label></li>
14+
<li><input type="checkbox"><label>Task 5</label></li>
15+
<li><input type="checkbox"><label>Task 6</label></li>
16+
<li><input type="checkbox"><label>Task 7</label></li>
17+
<li><input type="checkbox"><label>Task 8</label></li>
18+
</ul>
19+
20+
<script type="text/javascript" src="app.js"></script>
21+
</body>
22+
</html>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
body{
2+
font-family: sans-serif;
3+
font-size: 1.2em;
4+
color: #383838;
5+
background-color: #e7e4e4;
6+
margin: 0;
7+
min-height: 100vh;
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
}
12+
13+
.list {
14+
list-style: none;
15+
padding-left: 0;
16+
}
17+
18+
li {
19+
margin: .8em;
20+
width: 15em;
21+
}
22+
23+
input[type=checkbox] {
24+
margin: 1em;
25+
}
26+
input[type=checkbox]:checked + label {
27+
text-decoration: line-through;
28+
}
29+
30+
label {
31+
margin: 1em;
32+
33+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ My goal is simply to learn the basics by doing many simple things rather than st
1414
7. [x] [Array Cardio II](./07-array-cardio-ii) - [Codepen](http://codepen.io/pouyio/pen/eBxVPr?editors=1111)
1515
8. [x] [Fun with HTML5 Canvas](./08-fun-with-HTML5-canvas) - [Codepen](http://codepen.io/pouyio/full/xRBqNL/)
1616
9. [x] [Dev Tools Domination](./09-must-know-dev-tool-tips) - [Codepen](http://codepen.io/pouyio/pen/BQbbdp?editors=1111#)
17-
10. [ ] Hold Shift and Check Checkboxes
17+
10. [x] [Hold Shift and Check Checkboxes](./10-hold-shift-and-checkboxes) - [Codepen]()
1818
11. [ ] Custom Video Player
1919
12. [ ] Key Sequence Detection
2020
13. [ ] Slide in on Scroll

0 commit comments

Comments
 (0)