Finishing the search engine.

This commit is contained in:
Zoe Roux 2019-10-27 18:36:04 +01:00
parent 23c7d72675
commit 492329149f
3 changed files with 15 additions and 2 deletions

View File

@ -54,7 +54,7 @@
padding: 0; padding: 0;
transition: width 0.4s ease-in-out; transition: width 0.4s ease-in-out;
&:focus, .searching &:focus, &.searching
{ {
width: 12rem; width: 12rem;

View File

@ -43,7 +43,7 @@ export class AppComponent
openSearch() openSearch()
{ {
let input = <HTMLInputElement>document.getElementById("search"); let input: HTMLInputElement = <HTMLInputElement>document.getElementById("search");
input.value = ""; input.value = "";
input.focus(); input.focus();
@ -53,9 +53,15 @@ export class AppComponent
{ {
let query: string = event.target.value; let query: string = event.target.value;
if (query != "") if (query != "")
{
event.target.classList.add("searching");
this.router.navigate(["/search/" + query], { replaceUrl: this.router.url.startsWith("/search/") }); this.router.navigate(["/search/" + query], { replaceUrl: this.router.url.startsWith("/search/") });
}
else else
{
event.target.classList.remove("searching");
this.location.back(); this.location.back();
}
} }
} }

View File

@ -22,4 +22,11 @@ export class SearchComponent implements OnInit
this.title.setTitle(this.items.query + " - Kyoo"); this.title.setTitle(this.items.query + " - Kyoo");
}); });
} }
ngAfterViewInit()
{
let searchBar: HTMLInputElement = <HTMLInputElement>document.getElementById("search");
searchBar.classList.add("searching");
searchBar.value = this.items.query;
}
} }