2021-05-10 18:14:28 +00:00
|
|
|
<template>
|
2021-12-27 14:46:33 +00:00
|
|
|
<nav class="grid grid-cols-3 px-2 sm:px-4 py-2.5 w-full relative">
|
|
|
|
<div>
|
2021-12-27 14:46:34 +00:00
|
|
|
<router-link class="flex font-bold text-3xl items-center font-sans font-bold" to="/"
|
2021-08-22 10:27:09 +00:00
|
|
|
><img
|
|
|
|
alt="logo"
|
|
|
|
src="/img/icons/logo.svg"
|
|
|
|
height="32"
|
|
|
|
width="32"
|
2021-12-27 14:46:33 +00:00
|
|
|
class="w-10 mr-[-0.6rem]"
|
2021-08-22 10:27:09 +00:00
|
|
|
/>iped</router-link
|
2021-03-31 22:09:39 +00:00
|
|
|
>
|
|
|
|
</div>
|
2021-12-27 14:46:33 +00:00
|
|
|
<div class="flex justify-center items-center <md:hidden">
|
2021-03-31 22:09:39 +00:00
|
|
|
<input
|
2021-10-08 18:52:51 +00:00
|
|
|
v-model="searchText"
|
2021-12-27 14:46:33 +00:00
|
|
|
class="input !w-72 h-10"
|
2021-03-31 22:09:39 +00:00
|
|
|
type="text"
|
2021-09-21 21:58:25 +00:00
|
|
|
role="search"
|
|
|
|
:title="$t('actions.search')"
|
|
|
|
:placeholder="$t('actions.search')"
|
2021-04-07 09:22:55 +00:00
|
|
|
@keyup="onKeyUp"
|
2021-12-04 07:04:44 +00:00
|
|
|
@keypress="onKeyPress"
|
2021-03-31 22:09:39 +00:00
|
|
|
@focus="onInputFocus"
|
|
|
|
@blur="onInputBlur"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-12-27 14:46:33 +00:00
|
|
|
<div>
|
|
|
|
<ul class="flex float-right text-1xl children:pl-3">
|
2021-03-31 22:09:39 +00:00
|
|
|
<li>
|
2021-10-08 18:52:51 +00:00
|
|
|
<router-link v-t="'titles.preferences'" to="/preferences" />
|
2021-03-31 22:09:39 +00:00
|
|
|
</li>
|
2021-07-16 22:56:41 +00:00
|
|
|
<li v-if="shouldShowLogin">
|
2021-10-08 18:52:51 +00:00
|
|
|
<router-link v-t="'titles.login'" to="/login" />
|
2021-07-16 22:56:41 +00:00
|
|
|
</li>
|
|
|
|
<li v-if="shouldShowLogin">
|
2021-10-08 18:52:51 +00:00
|
|
|
<router-link v-t="'titles.register'" to="/register" />
|
2021-07-16 22:56:41 +00:00
|
|
|
</li>
|
2021-08-22 10:27:09 +00:00
|
|
|
<li v-if="shouldShowHistory">
|
2021-10-08 18:52:51 +00:00
|
|
|
<router-link v-t="'titles.history'" to="/history" />
|
2021-08-22 10:27:09 +00:00
|
|
|
</li>
|
2021-07-16 22:56:41 +00:00
|
|
|
<li v-if="authenticated">
|
2021-10-08 18:52:51 +00:00
|
|
|
<router-link v-t="'titles.feed'" to="/feed" />
|
2021-07-16 22:56:41 +00:00
|
|
|
</li>
|
2021-03-31 22:09:39 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2021-12-27 14:46:26 +00:00
|
|
|
<div class="w-full md:hidden">
|
2021-03-31 22:09:39 +00:00
|
|
|
<input
|
2021-10-08 18:52:51 +00:00
|
|
|
v-model="searchText"
|
2021-12-27 14:46:29 +00:00
|
|
|
class="input"
|
2021-03-31 22:09:39 +00:00
|
|
|
type="text"
|
2021-09-21 21:58:25 +00:00
|
|
|
role="search"
|
|
|
|
:title="$t('actions.search')"
|
|
|
|
:placeholder="$t('actions.search')"
|
2021-04-07 09:22:55 +00:00
|
|
|
@keyup="onKeyUp"
|
2021-12-04 07:04:44 +00:00
|
|
|
@keypress="onKeyPress"
|
2021-03-31 22:09:39 +00:00
|
|
|
@focus="onInputFocus"
|
|
|
|
@blur="onInputBlur"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<SearchSuggestions
|
2021-04-06 10:10:17 +00:00
|
|
|
v-show="searchText && suggestionsVisible"
|
2021-04-07 09:22:55 +00:00
|
|
|
ref="searchSuggestions"
|
2021-10-08 18:52:51 +00:00
|
|
|
:search-text="searchText"
|
|
|
|
@searchchange="onSearchTextChange"
|
2021-03-31 22:09:39 +00:00
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import SearchSuggestions from "@/components/SearchSuggestions";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2021-05-10 18:14:28 +00:00
|
|
|
SearchSuggestions,
|
2021-03-31 22:09:39 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
searchText: "",
|
2021-05-10 18:14:28 +00:00
|
|
|
suggestionsVisible: false,
|
2021-03-31 22:09:39 +00:00
|
|
|
};
|
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
computed: {
|
|
|
|
shouldShowLogin(_this) {
|
|
|
|
return _this.getAuthToken() == null;
|
|
|
|
},
|
2021-08-22 10:27:09 +00:00
|
|
|
shouldShowHistory(_this) {
|
|
|
|
return _this.getPreferenceBoolean("watchHistory", false);
|
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
},
|
2021-03-31 22:09:39 +00:00
|
|
|
methods: {
|
2021-04-07 09:22:55 +00:00
|
|
|
onKeyUp(e) {
|
2021-12-04 07:04:44 +00:00
|
|
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
this.$refs.searchSuggestions.onKeyUp(e);
|
|
|
|
},
|
|
|
|
onKeyPress(e) {
|
2021-03-31 22:09:39 +00:00
|
|
|
if (e.key === "Enter") {
|
2021-07-14 19:22:00 +00:00
|
|
|
e.target.blur();
|
2021-03-31 22:09:39 +00:00
|
|
|
this.$router.push({
|
|
|
|
name: "SearchResults",
|
2021-05-10 18:14:28 +00:00
|
|
|
query: { search_query: this.searchText },
|
2021-03-31 22:09:39 +00:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onInputFocus() {
|
|
|
|
this.suggestionsVisible = true;
|
|
|
|
},
|
|
|
|
onInputBlur() {
|
|
|
|
this.suggestionsVisible = false;
|
2021-04-06 10:10:17 +00:00
|
|
|
},
|
|
|
|
onSearchTextChange(searchText) {
|
|
|
|
this.searchText = searchText;
|
2021-05-10 18:14:28 +00:00
|
|
|
},
|
|
|
|
},
|
2021-03-31 22:09:39 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|