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;
transition: width 0.4s ease-in-out;
&:focus, .searching
&:focus, &.searching
{
width: 12rem;

View File

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

View File

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