2021-05-10 23:44:28 +05:30
|
|
|
<template>
|
2021-12-27 20:16:28 +05:30
|
|
|
<nav class="uk-navbar w-100 relative" :style="[{ background: backgroundColor, colour: foregroundColor }]" uk-navbar>
|
2021-04-01 03:39:39 +05:30
|
|
|
<div class="uk-navbar-left">
|
2021-12-27 20:16:26 +05:30
|
|
|
<router-link
|
|
|
|
class="uk-navbar-item uk-logo font-bold font-2xl font-sans font-bold"
|
|
|
|
:style="[{ colour: foregroundColor }]"
|
|
|
|
to="/"
|
2021-08-22 15:57:09 +05:30
|
|
|
><img
|
|
|
|
alt="logo"
|
|
|
|
src="/img/icons/logo.svg"
|
|
|
|
height="32"
|
|
|
|
width="32"
|
|
|
|
style="margin-bottom: 6px; margin-right: -13px"
|
|
|
|
/>iped</router-link
|
2021-04-01 03:39:39 +05:30
|
|
|
>
|
|
|
|
</div>
|
2021-12-27 20:16:26 +05:30
|
|
|
<div class="uk-navbar-center uk-flex md:visible">
|
2021-04-01 03:39:39 +05:30
|
|
|
<input
|
2021-10-09 00:22:51 +05:30
|
|
|
v-model="searchText"
|
2021-04-07 14:57:17 +05:30
|
|
|
class="uk-input uk-width-medium"
|
2021-04-01 03:39:39 +05:30
|
|
|
type="text"
|
2021-09-22 03:28:25 +05:30
|
|
|
role="search"
|
|
|
|
:title="$t('actions.search')"
|
|
|
|
:placeholder="$t('actions.search')"
|
2021-04-07 14:52:55 +05:30
|
|
|
@keyup="onKeyUp"
|
2021-12-04 12:34:44 +05:30
|
|
|
@keypress="onKeyPress"
|
2021-04-01 03:39:39 +05:30
|
|
|
@focus="onInputFocus"
|
|
|
|
@blur="onInputBlur"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="uk-navbar-right">
|
|
|
|
<ul class="uk-navbar-nav">
|
|
|
|
<li>
|
2021-10-09 00:22:51 +05:30
|
|
|
<router-link v-t="'titles.preferences'" to="/preferences" />
|
2021-04-01 03:39:39 +05:30
|
|
|
</li>
|
2021-07-17 04:26:41 +05:30
|
|
|
<li v-if="shouldShowLogin">
|
2021-10-09 00:22:51 +05:30
|
|
|
<router-link v-t="'titles.login'" to="/login" />
|
2021-07-17 04:26:41 +05:30
|
|
|
</li>
|
|
|
|
<li v-if="shouldShowLogin">
|
2021-10-09 00:22:51 +05:30
|
|
|
<router-link v-t="'titles.register'" to="/register" />
|
2021-07-17 04:26:41 +05:30
|
|
|
</li>
|
2021-08-22 15:57:09 +05:30
|
|
|
<li v-if="shouldShowHistory">
|
2021-10-09 00:22:51 +05:30
|
|
|
<router-link v-t="'titles.history'" to="/history" />
|
2021-08-22 15:57:09 +05:30
|
|
|
</li>
|
2021-07-17 04:26:41 +05:30
|
|
|
<li v-if="authenticated">
|
2021-10-09 00:22:51 +05:30
|
|
|
<router-link v-t="'titles.feed'" to="/feed" />
|
2021-07-17 04:26:41 +05:30
|
|
|
</li>
|
2021-04-01 03:39:39 +05:30
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2021-12-27 20:16:26 +05:30
|
|
|
<div class="w-full md:hidden">
|
2021-04-01 03:39:39 +05:30
|
|
|
<input
|
2021-10-09 00:22:51 +05:30
|
|
|
v-model="searchText"
|
2021-04-01 03:39:39 +05:30
|
|
|
class="uk-input"
|
|
|
|
type="text"
|
2021-09-22 03:28:25 +05:30
|
|
|
role="search"
|
|
|
|
:title="$t('actions.search')"
|
|
|
|
:placeholder="$t('actions.search')"
|
2021-04-07 14:52:55 +05:30
|
|
|
@keyup="onKeyUp"
|
2021-12-04 12:34:44 +05:30
|
|
|
@keypress="onKeyPress"
|
2021-04-01 03:39:39 +05:30
|
|
|
@focus="onInputFocus"
|
|
|
|
@blur="onInputBlur"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<SearchSuggestions
|
2021-04-06 15:40:17 +05:30
|
|
|
v-show="searchText && suggestionsVisible"
|
2021-04-07 14:52:55 +05:30
|
|
|
ref="searchSuggestions"
|
2021-10-09 00:22:51 +05:30
|
|
|
:search-text="searchText"
|
|
|
|
@searchchange="onSearchTextChange"
|
2021-04-01 03:39:39 +05:30
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import SearchSuggestions from "@/components/SearchSuggestions";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2021-05-10 23:44:28 +05:30
|
|
|
SearchSuggestions,
|
2021-04-01 03:39:39 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
searchText: "",
|
2021-05-10 23:44:28 +05:30
|
|
|
suggestionsVisible: false,
|
2021-04-01 03:39:39 +05:30
|
|
|
};
|
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
computed: {
|
|
|
|
shouldShowLogin(_this) {
|
|
|
|
return _this.getAuthToken() == null;
|
|
|
|
},
|
2021-08-22 15:57:09 +05:30
|
|
|
shouldShowHistory(_this) {
|
|
|
|
return _this.getPreferenceBoolean("watchHistory", false);
|
|
|
|
},
|
2021-07-17 04:26:41 +05:30
|
|
|
},
|
2021-04-01 03:39:39 +05:30
|
|
|
methods: {
|
2021-04-07 14:52:55 +05:30
|
|
|
onKeyUp(e) {
|
2021-12-04 12:34:44 +05:30
|
|
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
this.$refs.searchSuggestions.onKeyUp(e);
|
|
|
|
},
|
|
|
|
onKeyPress(e) {
|
2021-04-01 03:39:39 +05:30
|
|
|
if (e.key === "Enter") {
|
2021-07-15 00:52:00 +05:30
|
|
|
e.target.blur();
|
2021-04-01 03:39:39 +05:30
|
|
|
this.$router.push({
|
|
|
|
name: "SearchResults",
|
2021-05-10 23:44:28 +05:30
|
|
|
query: { search_query: this.searchText },
|
2021-04-01 03:39:39 +05:30
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onInputFocus() {
|
|
|
|
this.suggestionsVisible = true;
|
|
|
|
},
|
|
|
|
onInputBlur() {
|
|
|
|
this.suggestionsVisible = false;
|
2021-04-06 15:40:17 +05:30
|
|
|
},
|
|
|
|
onSearchTextChange(searchText) {
|
|
|
|
this.searchText = searchText;
|
2021-05-10 23:44:28 +05:30
|
|
|
},
|
|
|
|
},
|
2021-04-01 03:39:39 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|