Skip to content
Snippets Groups Projects
Commit d44df46b authored by Henrik Askjer's avatar Henrik Askjer
Browse files

rework return buttons

parent b956be5a
No related branches found
No related tags found
No related merge requests found
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
</div> </div>
<div class="return_to_results" v-if="total_results && article"> <div class="return_to_results" v-if="total_results && article">
<router-link v-if="previous" :to="previous" @click.native="return_to_results()"> <router-link v-if="$store.state.searchRoute" :to="$store.state.searchRoute" @click.native="return_to_results()">
<v-icon left class="nav_arrow">chevron_left</v-icon>{{$t("back_to_results")}} <v-icon left class="nav_arrow">chevron_left</v-icon>{{$t("back_to_results")}}
</router-link> </router-link>
<a v-if="!this.previous" href="/"> <a v-if="!$store.state.searchRoute" href="/">
<v-icon left class="nav_arrow">chevron_left</v-icon>Søk etter andre ord <v-icon left class="nav_arrow">search</v-icon>Søk i ordbøkene
</a> </a>
</div> </div>
...@@ -221,9 +221,9 @@ function navigate_to_query(self, word) { ...@@ -221,9 +221,9 @@ function navigate_to_query(self, word) {
self.inflection_suggestions = [] self.inflection_suggestions = []
} }
self.waiting_for_articles = false self.waiting_for_articles = false
self.$store.commit('setSearchRoute', self.$route.fullPath)
self.replace_history() self.replace_history()
self.previous = self.$route.fullPath
}) })
}).catch(error =>{ }).catch(error =>{
...@@ -247,7 +247,6 @@ export default { ...@@ -247,7 +247,6 @@ export default {
monthly_bm: null, monthly_bm: null,
monthly_nn: null, monthly_nn: null,
event: null, event: null,
previous: this.$route.fullPath,
scope: "wb", scope: "wb",
pos_selected: "ALL", pos_selected: "ALL",
article_info: null, article_info: null,
...@@ -385,7 +384,9 @@ export default { ...@@ -385,7 +384,9 @@ export default {
self.$forceUpdate() self.$forceUpdate()
} }
) ).then(() => {
this.$store.commit('setSearchRoute', this.$route.fullPath)
})
}, },
generate_path: function(q) { generate_path: function(q) {
...@@ -435,7 +436,6 @@ export default { ...@@ -435,7 +436,6 @@ export default {
} }
}, },
details_click: function(item) { details_click: function(item) {
item.article.source = this.$route.fullPath
this.article = item.article this.article = item.article
this.replace_history() this.replace_history()
}, },
...@@ -511,7 +511,6 @@ export default { ...@@ -511,7 +511,6 @@ export default {
} }
}, },
created: function() { created: function() {
console.log("CREATED")
let self = this let self = this
window.onpopstate = function (event) { window.onpopstate = function (event) {
if (event.state) { if (event.state) {
......
...@@ -99,6 +99,13 @@ export default { ...@@ -99,6 +99,13 @@ export default {
this.$store.commit("setDefaultDict", value) this.$store.commit("setDefaultDict", value)
} }
} }
},
watch: {
$route(to, from) {
if (to.name == "about" && from.name != to.name) {
this.$store.commit('setDictRoute', from.fullPath)
}
} }
}
} }
</script> </script>
<template> <template>
<div> <div>
<v-app-bar elevate-on-scroll app class = "top-bar" dense dark color="primary"> <v-app-bar elevate-on-scroll app class = "top-bar" dense dark color="primary">
<div class="beta" :title="release">{{version_label}}</div> <v-app-bar-title class="beta" :title="release" aria-label="Ordbøkene: Bokmålsordboka og Nynorskordboka"><a href ="/">Ordbøkene</a></v-app-bar-title>
<v-spacer/>
<v-toolbar-items v-if="false">
<v-divider vertical/>
<v-btn text width="210" :class="$vuetify.breakpoint.name"><v-icon left>language</v-icon>Norsk (Bokmål)<v-icon right>expand_more</v-icon></v-btn>
<v-divider vertical/>
<v-menu :close-on-content-click="false" v-model="settingsMenu">
<template v-slot:activator= "{ on, attrs }">
<v-btn v-show="$route.name != 'about'" v-bind="attrs" v-on="on" text width="210"><v-icon left>settings</v-icon>{{$t("settings.title")}}<v-icon right>expand_more</v-icon></v-btn>
</template>
<v-card>
<v-card-text>
<LocaleMenu/>
<Settings/>
</v-card-text>
<v-card-actions><v-spacer/>
<v-btn rounded depressed @click='$store.commit("resetStore")'>{{$t('reset')}}</v-btn>
<v-btn rounded depressed @click="settingsMenu=false">{{$t("close")}}</v-btn>
</v-card-actions>
</v-card>
</v-menu>
<v-divider vertical/>
<v-btn text width="210" @click="toggleAbout"><v-icon left>{{$route.name=='about'? "chevron_left":"info"}}</v-icon>{{$route.name=='about'? "Tilbake":"Om ordbøkene"}}</v-btn>
<v-spacer/>
<v-divider vertical/> <v-divider vertical/>
<v-toolbar-items v-if="$route.name == 'about'">
<v-btn text @click.native="back" v-if="$store.state.dictRoute">{{$t('close')}}<v-icon right>close</v-icon></v-btn>
<v-btn text v-else @click.native="home">Søk i ordbøkene<v-icon right>search</v-icon></v-btn>
</v-toolbar-items> </v-toolbar-items>
<v-toolbar-items> <v-toolbar-items>
<v-divider vertical/>
<v-btn text @click="toggleAbout" v-if="$route.name == 'about'"><v-icon left>chevron_left</v-icon>{{$t("back")}}</v-btn>
</v-toolbar-items>
<v-btn id="top_menu"
:aria-expanded="menuOpen? 'true' : 'false'"
aria-haspopup="menu"
width="96px" v-if="$route.name != 'about'" aria-labelledby="menu_label" text @click.native="menuOpen = !menuOpen">
<span id="menu_label">{{$t('menu.title')}}</span><v-icon right>{{menuOpen? 'close' : 'menu'}}</v-icon></v-btn>
<v-divider vertical/>
<v-btn id="top_menu"
v-if="$route.name != 'about'"
:aria-expanded="menuOpen? 'true' : 'false'"
aria-haspopup="menu"
width="96px"
aria-labelledby="menu_label"
text @click.native="menuOpen = !menuOpen">
<span id="menu_label">{{$t('menu.title')}}</span><v-icon right>{{menuOpen? 'close' : 'menu'}}</v-icon></v-btn>
</v-toolbar-items>
<v-divider vertical/>
</v-app-bar> </v-app-bar>
<v-dialog origin="48px center" content-class="dialogMenu" aria-labelledby="menu_label" v-if="$route.name != 'about'" max-width="1200" width="1200" v-model="menuOpen" hide-overlay :fullscreen="$vuetify.breakpoint.xs" <v-dialog origin="48px center" content-class="dialogMenu" aria-labelledby="menu_label" max-width="1200" width="1200" v-model="menuOpen" hide-overlay :fullscreen="$vuetify.breakpoint.xs"
:close-on-content-click="false" transition="dialog-top-transition"> :close-on-content-click="false" transition="dialog-top-transition">
<Menu @close="menuOpen=false"/> <Menu @close="menuOpen=false"/>
</v-dialog> </v-dialog>
...@@ -79,9 +54,16 @@ export default { ...@@ -79,9 +54,16 @@ export default {
} }
}, },
methods: { methods: {
toggleAbout: function() { home: function() {
this.$route.name=='about'? this.$router.back(): this.$router.push('/om') console.log("HOME", this.$store.state.dictRoute)
this.$router.push('/')
},
back: function() {
console.log("BACK", this.$store.state.dictRoute)
this.$router.push(this.$store.state.dictRoute)
this.$store.commit('setDictRoute', null)
} }
}, },
components: { components: {
Menu, Menu,
......
...@@ -151,15 +151,6 @@ const store = new Vuex.Store({ ...@@ -151,15 +151,6 @@ const store = new Vuex.Store({
} }
}) })
router.beforeEach((to, from, next) => {
if (to.name == 'about') {
store.commit('setDictRoute', from.fullPath)
}
next()
})
new Vue({ new Vue({
router, router,
vuetify, vuetify,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment