Made some visual changes but need to work on some searches occuring more than once.
This commit is contained in:
14
css/main.css
14
css/main.css
@@ -57,7 +57,10 @@ body {
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 99;
|
||||
border-radius: 6px; }
|
||||
border-radius: 6px;
|
||||
background: #2e2e2e;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
|
||||
.main #search-bar .autocomplete-items-container .autocomplete-item {
|
||||
width: 100%;
|
||||
background: #2e2e2e;
|
||||
@@ -68,14 +71,11 @@ body {
|
||||
padding: 7px 14px;
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
|
||||
box-sizing: border-box; }
|
||||
.main #search-bar .autocomplete-items-container .autocomplete-item:hover {
|
||||
background-color: red; }
|
||||
background: #3b3b3b; }
|
||||
.main #search-bar .autocomplete-items-container .autocomplete-active {
|
||||
background-color: DodgerBlue !important;
|
||||
color: #ffffff; }
|
||||
background: #353535; }
|
||||
@media only screen and (max-width: 791px) {
|
||||
.main #search-bar {
|
||||
width: 65%; } }
|
||||
|
||||
@@ -3,23 +3,27 @@ function autocomplete(inp, passedValues) {
|
||||
|
||||
/*execute a function when someone writes in the text field:*/
|
||||
inp.addEventListener("input", function(e) {
|
||||
var parentContainer, item, val = this.value;
|
||||
var item, val = this.value;
|
||||
var parentContainer = document.getElementsByClassName('autocomplete-items-container')[0];
|
||||
|
||||
/*close any already open lists of autocompleted values*/
|
||||
closeAllLists();
|
||||
if (!val) { return false;}
|
||||
if (!val) {
|
||||
parentContainer.style.paddingBottom = "0";
|
||||
return false;
|
||||
}
|
||||
currentFocus = -1;
|
||||
|
||||
/*create a DIV element that will contain the items (values):*/
|
||||
parentContainer = document.getElementsByClassName("autocomplete-items-container")[0];
|
||||
// Update some values of the parent container
|
||||
parentContainer.setAttribute("id", this.id + "autocomplete-list");
|
||||
parentContainer.style.paddingBottom = "1rem";
|
||||
|
||||
|
||||
/*for each item in the array...*/
|
||||
Object.keys(passedValues).forEach((el, i, arr) => {
|
||||
|
||||
/*check if the item starts with the same letters as the text field value:*/
|
||||
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
|
||||
if (arr[i].toLowerCase().includes(val.toLowerCase())) {
|
||||
/*create a DIV element for each matching element:*/
|
||||
item = document.createElement("DIV");
|
||||
item.setAttribute("class", "autocomplete-item");
|
||||
@@ -95,9 +99,9 @@ function autocomplete(inp, passedValues) {
|
||||
except the one passed as an argument:*/
|
||||
var x = document.getElementsByClassName("autocomplete-item");
|
||||
for (var i = 0; i < x.length; i++) {
|
||||
if (elmnt != x[i] && elmnt != inp) {
|
||||
x[i].parentNode.removeChild(x[i]);
|
||||
}
|
||||
if (elmnt != x[i]) {
|
||||
x[i].parentNode.removeChild(x[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,9 @@ body {
|
||||
right: 0;
|
||||
z-index: 99;
|
||||
border-radius: 6px;
|
||||
background: lighten($background, 5);
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
|
||||
|
||||
.autocomplete-item {
|
||||
width: 100%;
|
||||
@@ -105,17 +108,13 @@ body {
|
||||
color: $foreground;
|
||||
box-sizing: border-box;
|
||||
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
|
||||
|
||||
&:hover {
|
||||
background-color: red;
|
||||
background: lighten($background, 10);
|
||||
}
|
||||
}
|
||||
|
||||
.autocomplete-active {
|
||||
background-color: DodgerBlue !important;
|
||||
color: #ffffff;
|
||||
background: lighten($background, 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user