2017-06-29 08:11:46 +00:00
|
|
|
<template>
|
2017-08-01 19:49:56 +00:00
|
|
|
<button @click="change" :aria-label="$t('buttons.switchView')" :title="$t('buttons.switchView')" class="action" id="switch-view-button">
|
2017-06-29 08:11:46 +00:00
|
|
|
<i class="material-icons">{{ icon() }}</i>
|
2017-08-01 19:49:56 +00:00
|
|
|
<span>{{ $t('buttons.switchView') }}</span>
|
2017-06-29 08:11:46 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'switch-button',
|
|
|
|
methods: {
|
|
|
|
change: function (event) {
|
2017-07-10 09:30:51 +00:00
|
|
|
// If we are on mobile we should close the dropdown.
|
|
|
|
this.$store.commit('closeHovers')
|
|
|
|
|
2017-06-30 16:49:05 +00:00
|
|
|
let display = 'mosaic'
|
2017-06-29 08:11:46 +00:00
|
|
|
|
2017-07-03 10:04:14 +00:00
|
|
|
if (this.$store.state.req.display === 'mosaic') {
|
2017-06-30 16:49:05 +00:00
|
|
|
display = 'list'
|
2017-06-29 08:11:46 +00:00
|
|
|
}
|
|
|
|
|
2017-06-30 16:49:05 +00:00
|
|
|
this.$store.commit('listingDisplay', display)
|
2017-07-20 18:00:51 +00:00
|
|
|
let path = this.$store.state.baseURL
|
|
|
|
if (path === '') path = '/'
|
|
|
|
document.cookie = `display=${display}; max-age=31536000; path=${path}`
|
2017-06-29 08:11:46 +00:00
|
|
|
},
|
|
|
|
icon: function () {
|
2017-07-03 10:04:14 +00:00
|
|
|
if (this.$store.state.req.display === 'mosaic') return 'view_list'
|
2017-06-29 08:11:46 +00:00
|
|
|
return 'view_module'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|