blob: 179e93604b0b80d68c4cc823fffedbaed2901a68 [file] [log] [blame]
Huguet57ae6d9742018-07-23 01:07:26 +02001// Get the box
2var searchBox = document.getElementById('searchBox');
3
4// Get the button that opens the box
5var searchButton = document.getElementById("searchButton");
6
7// Get the <span> element that closes the box
8var closeBox = document.getElementsByClassName("closeBox")[0];
9
10// When the user clicks the button, open the box
11searchButton.onclick = function() {
Huguet57ac6d0c52018-07-23 18:37:16 +020012 dialog.close();
Huguet57ae6d9742018-07-23 01:07:26 +020013 searchBox.style.display = "block";
Huguet57004b1552018-07-23 03:29:12 +020014 // Focus on the search input bar
15 document.getElementById("searchInput").focus();
Huguet57ae6d9742018-07-23 01:07:26 +020016}
17
18// When the user clicks on <span> (x), close the box
19closeBox.onclick = function() {
20 searchBox.style.display = "none";
Huguet57004b1552018-07-23 03:29:12 +020021 // Empty the input bar
22 var searchInput = document.getElementById('searchInput');
23 searchInput.value = "";
Huguet57ae6d9742018-07-23 01:07:26 +020024}
25
26// When the user clicks anywhere outside of the box, close it
27window.onclick = function(event) {
28 if (event.target == searchBox) {
29 searchBox.style.display = "none";
Huguet57004b1552018-07-23 03:29:12 +020030 // Empty the input bar
31 var searchInput = document.getElementById('searchInput');
32 searchInput.value = "";
Huguet57ae6d9742018-07-23 01:07:26 +020033 }
34}