Newer
Older
<div class="autocomplete-container" :class="$vuetify.breakpoint.name">
v-model="select"
:loading="loading"
:items="items"
:search-input.sync="search"
:menu-props="{rounded: 'b-xl', maxHeight: $vuetify.breakpoint.name === 'xs' ? 190 : 500, transition: 'fade-transition', allowOverflow: true}"
:class="($refs.autocomplete && $refs.autocomplete.hasDisplayedItems && $refs.autocomplete.isMenuActive && 'rounded-t-xl') || 'rounded-xl'"
full-width
:dense="$vuetify.breakpoint.smAndDown"
<div v-if="!$parent.error && $parent.lang=='bm,nn'">
<a v-if="$parent.search_results.bm && $parent.search_results.bm.length > 0" href="#result0" class="accessibility_link" tabindex="0">Gå til treff i Bokmålsordboka</a>
<a :v-if="$parent.search_results.nn && $parent.search_results.nn.length > 0" :href="'#result'+($parent.search_results.bm? $parent.search_results.bm.length : 0)" class="accessibility_link" tabindex="0">Gå til treff i Nynorskordboka</a>
</div>
<div v-else>
<a href="#result0" class="accessibility_link" tabindex="0">Gå til hovedinnhold</a>
</div>
<a href="#top_menu" class="accessibility_link"
@click="$store.commit('toggle', 'menuOpen')"
aria-label="Hopp til toppmeny"
Henrik Askjer
committed
Henrik Askjer
committed
Henrik Askjer
committed
<v-btn min-width="0px"
v-bind="attrs"
v-on="on"
plain
depressed color = "primary" text @click.native="items=[]">
</span><span v-if="$vuetify.breakpoint.smAndDown">{{$parent.lang}}</span><v-icon>expand_more</v-icon></v-btn>
<v-list-item v-for="item in ['bm,nn','bm','nn'].map(l => {return {label: $t(`dicts.${l}`), tag: l}})" :key="item.tag"
active-class="v-list-item--active" :class="$parent.lang == item.tag ? 'v-list-item--active' : ''" @click="$parent.update_lang_form(item.tag)">
<v-list-item-title >{{ item.label }}</v-list-item-title>
</v-list-item>
</v-list>
Henrik Askjer
committed
Henrik Askjer
committed
Søk: <strong>{{data.item.match}}</strong> </span>
<span v-if="data.item.lang">
<span class="searchLemma">
{{data.item.match}}
({{["bm","nn","bm,nn"][data.item.lang-1]}})
},
data: function() {
return {
loading: false,
items: [],
inflection_suggestions: null,
select: this.$route.query? this.$route.query.q : null,
}
},
watch: {
search (val) {
const time = Date.now()
if (! val) {
this.items = []
} else {
this.run_query(val, time)
this.items = []
item.inflection_suggestions = this.inflection_suggestions
item.similar = this.similar
Henrik Askjer
committed
},
$route (to, from) {
this.select = to.query.q
get_lang() {
return this.$parent.lang
},
run_query(q, time) {
if (this.items[0]) {
if (this.items[0].time < time) {
// Whitespace necessary in case option already exists in dropdown
this.items.splice(0,1, {q, match: q, time})
}
}
else {
this.items.push({q, match: q, time})
}
let params = {q, dict: self.get_lang(), n: 6, dform: 'int', meta: 'n', scope: "wb"}
if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
if (response.data.a.exact) {
suggestions = response.data.a.exact.map(item => ({q: q, match: item[0], time: time, lang: [item[1]], w: true}))
}
Henrik Askjer
committed
self.inflection_suggestions = response.data.a.inflect
self.similar = response.data.a.similar
if (suggestions[0].q != suggestions[0].match) {
suggestions.unshift({q, match: q, time})
}
self.items = [{q, match: q, time}]
Henrik Askjer
committed
submit(item) {
this.$emit('submit', item)
let self = this
if (!self.$store.state.noMouse) self.$refs.autocomplete.$refs.input.select()
else self.$refs.autocomplete.$refs.input.blur()
if (! this.$route.hash) {
window.scrollTo(0,0)
this.$refs.autocomplete.focus()
}
Henrik Askjer
committed
v-toolbar {
z-index: 2000 !important;
}
color: var(--v-primary-base);
padding-left: 10px;
padding-right: 10px;
.search-field-button {
padding-right: 0px !important;
.accessibility_link {
display: inline;
position: absolute;
left: -10000px;
}
.accessibility_link:focus {
position: absolute;
left: 48px;
top : 48px;
background-color: white;
padding: 10px;
z-index: 10000;
}