Merge pull request #566 from h3poteto/fix/shortcut

Fix shortcut events
This commit is contained in:
AkiraFukushima 2018-08-24 08:31:17 +09:00 committed by GitHub
commit 24e39837a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 195 additions and 51 deletions

View File

@ -9,6 +9,7 @@
</el-row> </el-row>
</el-header> </el-header>
<el-container> <el-container>
<div v-shortkey="['esc']" @shortkey="close"></div>
<login-form></login-form> <login-form></login-form>
</el-container> </el-container>
</el-container> </el-container>

View File

@ -5,7 +5,7 @@
:element-loading-text="$t('message.loading')" :element-loading-text="$t('message.loading')"
element-loading-spinner="el-icon-loading" element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)" element-loading-background="rgba(0, 0, 0, 0.8)"
v-shortkey="{help: ['h']}" v-shortkey="shortcutEnabled ? {help: ['h']} : {}"
@shortkey="handleKey" @shortkey="handleKey"
> >
<side-menu></side-menu> <side-menu></side-menu>
@ -21,7 +21,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import SideMenu from './TimelineSpace/SideMenu' import SideMenu from './TimelineSpace/SideMenu'
import HeaderMenu from './TimelineSpace/HeaderMenu' import HeaderMenu from './TimelineSpace/HeaderMenu'
import Contents from './TimelineSpace/Contents' import Contents from './TimelineSpace/Contents'
@ -42,7 +42,13 @@ export default {
...mapState({ ...mapState({
loading: state => state.TimelineSpace.loading, loading: state => state.TimelineSpace.loading,
collapse: state => state.TimelineSpace.SideMenu.collapse collapse: state => state.TimelineSpace.SideMenu.collapse
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.modalOpened
}
}, },
created () { created () {
this.$store.commit('TimelineSpace/changeLoading', true) this.$store.commit('TimelineSpace/changeLoading', true)

View File

@ -4,6 +4,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="focused" :focused="focused"
:overlaid="overlaid"
@focusNext="$emit('focusNext')" @focusNext="$emit('focusNext')"
@focusPrev="$emit('focusPrev')" @focusPrev="$emit('focusPrev')"
@select="$emit('selectNotification')" @select="$emit('selectNotification')"
@ -12,6 +13,7 @@
<follow v-else-if="message.type === 'follow'" <follow v-else-if="message.type === 'follow'"
:message="message" :message="message"
:focused="focused" :focused="focused"
:overlaid="overlaid"
@focusNext="$emit('focusNext')" @focusNext="$emit('focusNext')"
@focusPrev="$emit('focusPrev')" @focusPrev="$emit('focusPrev')"
@select="$emit('selectNotification')" @select="$emit('selectNotification')"
@ -21,6 +23,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="focused" :focused="focused"
:overlaid="overlaid"
@focusNext="$emit('focusNext')" @focusNext="$emit('focusNext')"
@focusPrev="$emit('focusPrev')" @focusPrev="$emit('focusPrev')"
@select="$emit('selectNotification')" @select="$emit('selectNotification')"
@ -30,6 +33,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="focused" :focused="focused"
:overlaid="overlaid"
@focusNext="$emit('focusNext')" @focusNext="$emit('focusNext')"
@focusPrev="$emit('focusPrev')" @focusPrev="$emit('focusPrev')"
@select="$emit('selectNotification')" @select="$emit('selectNotification')"
@ -58,6 +62,10 @@ export default {
focused: { focused: {
type: Boolean, type: Boolean,
defalt: false defalt: false
},
overlaid: {
type: Boolean,
default: false
} }
}, },
components: { Favourite, Follow, Mention, Reblog } components: { Favourite, Follow, Mention, Reblog }

View File

@ -2,7 +2,7 @@
<div <div
class="status" class="status"
tabIndex="0" tabIndex="0"
v-shortkey="focused ? {next: ['j'], prev: ['k']} : {}" v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k']} : {}"
@shortkey="handleStatusControl" @shortkey="handleStatusControl"
ref="status" ref="status"
@click="$emit('select')" @click="$emit('select')"
@ -91,6 +91,10 @@ export default {
focused: { focused: {
type: Boolean, type: Boolean,
default: false default: false
},
overlaid: {
type: Boolean,
default: false
} }
}, },
data () { data () {
@ -99,6 +103,11 @@ export default {
showAttachments: false showAttachments: false
} }
}, },
computed: {
shortcutEnabled: function () {
return this.focused && !this.overlaid
}
},
mounted () { mounted () {
if (this.focused) { if (this.focused) {
this.$refs.status.focus() this.$refs.status.focus()

View File

@ -2,7 +2,7 @@
<div <div
class="follow" class="follow"
tabIndex="0" tabIndex="0"
v-shortkey="focused ? {next: ['j'], prev: ['k']} : {}" v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k']} : {}"
@shortkey="handleStatusControl" @shortkey="handleStatusControl"
ref="status" ref="status"
@click="$emit('select')" @click="$emit('select')"
@ -34,6 +34,15 @@ export default {
focused: { focused: {
type: Boolean, type: Boolean,
default: false default: false
},
overlaid: {
type: Boolean,
default: false
}
},
computed: {
shortcutEnabled: function () {
return this.focused && !this.overlaid
} }
}, },
mounted () { mounted () {

View File

@ -4,6 +4,7 @@
:message="message.status" :message="message.status"
:filter="filter" :filter="filter"
:focused="focused" :focused="focused"
:overlaid="overlaid"
v-on:update="updateToot" v-on:update="updateToot"
@focusNext="$emit('focusNext')" @focusNext="$emit('focusNext')"
@focusPrev="$emit('focusPrev')" @focusPrev="$emit('focusPrev')"
@ -30,6 +31,10 @@ export default {
focused: { focused: {
type: Boolean, type: Boolean,
default: false default: false
},
overlaid: {
type: Boolean,
default: false
} }
}, },
components: { Toot }, components: { Toot },

View File

@ -2,7 +2,7 @@
<div <div
class="status" class="status"
tabIndex="0" tabIndex="0"
v-shortkey="focused ? {next: ['j'], prev: ['k']} : {}" v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k']} : {}"
@shortkey="handleStatusControl" @shortkey="handleStatusControl"
ref="status" ref="status"
@click="$emit('select')" @click="$emit('select')"
@ -91,6 +91,10 @@ export default {
focused: { focused: {
type: Boolean, type: Boolean,
default: false default: false
},
overlaid: {
type: Boolean,
default: false
} }
}, },
data () { data () {
@ -99,6 +103,11 @@ export default {
showAttachments: false showAttachments: false
} }
}, },
computed: {
shortcutEnabled: function () {
return this.focused && !this.overlaid
}
},
mounted () { mounted () {
if (this.focused) { if (this.focused) {
this.$refs.status.focus() this.$refs.status.focus()

View File

@ -2,7 +2,7 @@
<div <div
class="status" class="status"
tabIndex="0" tabIndex="0"
v-shortkey="focused ? {next: ['j'], prev: ['k'], reply: ['r'], boost: ['b'], fav: ['f'], open: ['o'], profile: ['p']} : {}" v-shortkey="shortcutEnabled ? {next: ['j'], prev: ['k'], reply: ['r'], boost: ['b'], fav: ['f'], open: ['o'], profile: ['p']} : {}"
@shortkey="handleTootControl" @shortkey="handleTootControl"
ref="status" ref="status"
@click="$emit('selectToot')" @click="$emit('selectToot')"
@ -142,12 +142,19 @@ export default {
focused: { focused: {
type: Boolean, type: Boolean,
default: false default: false
},
overlaid: {
type: Boolean,
default: false
} }
}, },
computed: { computed: {
...mapState({ ...mapState({
displayNameStyle: state => state.App.displayNameStyle displayNameStyle: state => state.App.displayNameStyle
}) }),
shortcutEnabled: function () {
return this.focused && !this.overlaid
}
}, },
mounted () { mounted () {
if (this.focused) { if (this.focused) {
@ -387,6 +394,7 @@ export default {
handleTootControl (event) { handleTootControl (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
console.log(this.shortcutEnabled)
this.$emit('focusNext') this.$emit('focusNext')
break break
case 'prev': case 'prev':

View File

@ -1,5 +1,5 @@
<template> <template>
<div id="favourites" v-shortkey="{next: ['j']}" @shortkey="handleKey"> <div id="favourites" v-shortkey="shortcutEnabled ? {next: ['j']} : {}" @shortkey="handleKey">
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
<div class="fav" v-for="message in favourites" v-bind:key="message.id"> <div class="fav" v-for="message in favourites" v-bind:key="message.id">
@ -7,6 +7,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="message.uri === focusedId" :focused="message.uri === focusedId"
:overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updateToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@ -25,7 +26,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Toot from './Cards/Toot' import Toot from './Cards/Toot'
import scrollTop from '../../utils/scroll' import scrollTop from '../../utils/scroll'
@ -46,7 +47,13 @@ export default {
favourites: state => state.TimelineSpace.Contents.Favourites.favourites, favourites: state => state.TimelineSpace.Contents.Favourites.favourites,
lazyLoading: state => state.TimelineSpace.Contents.Favourites.lazyLoading, lazyLoading: state => state.TimelineSpace.Contents.Favourites.lazyLoading,
filter: state => state.TimelineSpace.Contents.Favourites.filter filter: state => state.TimelineSpace.Contents.Favourites.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedId && !this.modalOpened
}
}, },
created () { created () {
this.$store.commit('TimelineSpace/changeLoading', true) this.$store.commit('TimelineSpace/changeLoading', true)
@ -171,9 +178,7 @@ export default {
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
if (!this.focusedId) { this.focusedId = this.favourites[0].uri
this.focusedId = this.favourites[0].uri
}
break break
} }
} }

View File

@ -9,7 +9,7 @@
</el-button> </el-button>
</div> </div>
<div class="form-item input"> <div class="form-item input">
<input v-model="tag" :placeholder="$t('hashtag.tag_name')" class="search-keyword" v-shortkey="['enter']" @shortkey="search" autofocus></input> <input v-model="tag" :placeholder="$t('hashtag.tag_name')" class="search-keyword" v-shortkey.avoid v-on:keyup.enter="search" autofocus></input>
</div> </div>
<div class="form-item" v-show="tagPage()"> <div class="form-item" v-show="tagPage()">
<el-button type="text" @click="save"> <el-button type="text" @click="save">

View File

@ -1,5 +1,5 @@
<template> <template>
<div name="tag" v-shortkey="{next:['j']}" @shortkey="handleKey"> <div name="tag" v-shortkey="shortcutEnabled ? {next:['j']} : {}" @shortkey="handleKey">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div> <div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
@ -9,6 +9,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="message.uri === focusedId" :focused="message.uri === focusedId"
:overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updateToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@ -27,7 +28,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Toot from '../Cards/Toot' import Toot from '../Cards/Toot'
import scrollTop from '../../../utils/scroll' import scrollTop from '../../../utils/scroll'
@ -49,7 +50,13 @@ export default {
heading: state => state.TimelineSpace.Contents.Hashtag.Tag.heading, heading: state => state.TimelineSpace.Contents.Hashtag.Tag.heading,
unread: state => state.TimelineSpace.Contents.Hashtag.Tag.unreadTimeline, unread: state => state.TimelineSpace.Contents.Hashtag.Tag.unreadTimeline,
filter: state => state.TimelineSpace.Contents.Hashtag.Tag.filter filter: state => state.TimelineSpace.Contents.Hashtag.Tag.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedId && !this.modalOpened
}
}, },
mounted () { mounted () {
this.$store.commit('TimelineSpace/changeLoading', true) this.$store.commit('TimelineSpace/changeLoading', true)
@ -209,9 +216,7 @@ export default {
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
if (!this.focusedId) { this.focusedId = this.timeline[0].uri
this.focusedId = this.timeline[0].uri
}
break break
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div id="home" v-shortkey="{next: ['j']}" @shortkey="handleKey"> <div id="home" v-shortkey="shortcutEnabled ? {next: ['j']} : {}" @shortkey="handleKey">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div> <div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
@ -9,6 +9,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="message.uri === focusedId" :focused="message.uri === focusedId"
:overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updateToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@ -28,7 +29,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Toot from './Cards/Toot' import Toot from './Cards/Toot'
import scrollTop from '../../utils/scroll' import scrollTop from '../../utils/scroll'
@ -49,7 +50,13 @@ export default {
heading: state => state.TimelineSpace.Contents.Home.heading, heading: state => state.TimelineSpace.Contents.Home.heading,
unread: state => state.TimelineSpace.Contents.Home.unreadTimeline, unread: state => state.TimelineSpace.Contents.Home.unreadTimeline,
filter: state => state.TimelineSpace.Contents.Home.filter filter: state => state.TimelineSpace.Contents.Home.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedId && !this.modalOpened
}
}, },
mounted () { mounted () {
this.$store.commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', false) this.$store.commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', false)
@ -176,9 +183,7 @@ export default {
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
if (!this.focusedId) { this.focusedId = this.timeline[0].uri
this.focusedId = this.timeline[0].uri
}
break break
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div name="list"> <div name="list" v-shortkey="shortcutEnabled ? {next:['j']} : {}" @shortkey="handleKey">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div> <div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
@ -9,6 +9,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="message.uri === focusedId" :focused="message.uri === focusedId"
:overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updateToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@ -27,7 +28,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Toot from '../Cards/Toot' import Toot from '../Cards/Toot'
import scrollTop from '../../../utils/scroll' import scrollTop from '../../../utils/scroll'
@ -49,7 +50,13 @@ export default {
heading: state => state.TimelineSpace.Contents.Lists.Show.heading, heading: state => state.TimelineSpace.Contents.Lists.Show.heading,
unread: state => state.TimelineSpace.Contents.Lists.Show.unreadTimeline, unread: state => state.TimelineSpace.Contents.Lists.Show.unreadTimeline,
filter: state => state.TimelineSpace.Contents.Lists.Show.filter filter: state => state.TimelineSpace.Contents.Lists.Show.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedId && !this.modalOpened
}
}, },
created () { created () {
this.$store.commit('TimelineSpace/changeLoading', true) this.$store.commit('TimelineSpace/changeLoading', true)
@ -201,6 +208,13 @@ export default {
}, },
focusToot (message) { focusToot (message) {
this.focusedId = message.uri this.focusedId = message.uri
},
handleKey (event) {
switch (event.srcKey) {
case 'next':
this.focusedId = this.timeline[0].uri
break
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div id="local" v-shortkey="{next: ['j']}" @shortkey="handleKey"> <div id="local" v-shortkey="shortcutEnabled ? {next: ['j']} : {}" @shortkey="handleKey">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div> <div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
@ -9,6 +9,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="message.uri === focusedId" :focused="message.uri === focusedId"
:overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updateToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@ -28,7 +29,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Toot from './Cards/Toot' import Toot from './Cards/Toot'
import scrollTop from '../../utils/scroll' import scrollTop from '../../utils/scroll'
@ -49,7 +50,13 @@ export default {
heading: state => state.TimelineSpace.Contents.Local.heading, heading: state => state.TimelineSpace.Contents.Local.heading,
unread: state => state.TimelineSpace.Contents.Local.unreadTimeline, unread: state => state.TimelineSpace.Contents.Local.unreadTimeline,
filter: state => state.TimelineSpace.Contents.Local.filter filter: state => state.TimelineSpace.Contents.Local.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedId && !this.modalOpened
}
}, },
mounted () { mounted () {
this.$store.commit('TimelineSpace/SideMenu/changeUnreadLocalTimeline', false) this.$store.commit('TimelineSpace/SideMenu/changeUnreadLocalTimeline', false)
@ -79,6 +86,7 @@ export default {
} }
}, },
focusedId: function (newState, oldState) { focusedId: function (newState, oldState) {
console.log(newState)
if (newState && this.heading) { if (newState && this.heading) {
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false) this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false)
} else if (newState === null && !this.heading) { } else if (newState === null && !this.heading) {
@ -155,6 +163,7 @@ export default {
}, },
focusNext () { focusNext () {
const currentIndex = this.timeline.findIndex(toot => this.focusedId === toot.uri) const currentIndex = this.timeline.findIndex(toot => this.focusedId === toot.uri)
console.log(currentIndex)
if (currentIndex === -1) { if (currentIndex === -1) {
this.focusedId = this.timeline[0].uri this.focusedId = this.timeline[0].uri
} else if (currentIndex < this.timeline.length) { } else if (currentIndex < this.timeline.length) {
@ -171,13 +180,12 @@ export default {
}, },
focusToot (message) { focusToot (message) {
this.focusedId = message.uri this.focusedId = message.uri
console.log(this.focusedId)
}, },
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
if (!this.focusedId) { this.focusedId = this.timeline[0].uri
this.focusedId = this.timeline[0].uri
}
break break
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div id="notifications" v-shortkey="{next: ['j']}" @shortkey="handleKey"> <div id="notifications" v-shortkey="shortcutEnabled ? {next: ['j']} : {}" @shortkey="handleKey">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div> <div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
@ -9,6 +9,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="index === focusedIndex" :focused="index === focusedIndex"
:overlaid="modalOpened"
@focusNext="focusNext" @focusNext="focusNext"
@focusPrev="focusPrev" @focusPrev="focusPrev"
@selectNotification="focusNotification(index)" @selectNotification="focusNotification(index)"
@ -26,7 +27,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Notification from './Cards/Notification' import Notification from './Cards/Notification'
import scrollTop from '../../utils/scroll' import scrollTop from '../../utils/scroll'
@ -47,7 +48,13 @@ export default {
heading: state => state.TimelineSpace.Contents.Notifications.heading, heading: state => state.TimelineSpace.Contents.Notifications.heading,
unread: state => state.TimelineSpace.Contents.Notifications.unreadNotifications, unread: state => state.TimelineSpace.Contents.Notifications.unreadNotifications,
filter: state => state.TimelineSpace.Contents.Notifications.filter filter: state => state.TimelineSpace.Contents.Notifications.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedIndex && !this.modalOpened
}
}, },
mounted () { mounted () {
this.$store.commit('TimelineSpace/SideMenu/changeUnreadNotifications', false) this.$store.commit('TimelineSpace/SideMenu/changeUnreadNotifications', false)
@ -161,9 +168,7 @@ export default {
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
if (!this.focusedIndex) { this.focusedIndex = 0
this.focusedIndex = 0
}
break break
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div id="public" v-shortkey="{next: ['j']}" @shortkey="handleKey"> <div id="public" v-shortkey="shortcutEnabled ? {next: ['j']} : {}" @shortkey="handleKey">
<div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div> <div class="unread">{{ unread.length > 0 ? unread.length : '' }}</div>
<div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()"> <div v-shortkey="{linux: ['ctrl', 'r'], mac: ['meta', 'r']}" @shortkey="reload()">
</div> </div>
@ -9,6 +9,7 @@
:message="message" :message="message"
:filter="filter" :filter="filter"
:focused="message.uri === focusedId" :focused="message.uri === focusedId"
:overlaid="modalOpened"
v-on:update="updateToot" v-on:update="updateToot"
v-on:delete="deleteToot" v-on:delete="deleteToot"
@focusNext="focusNext" @focusNext="focusNext"
@ -28,7 +29,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex' import { mapState, mapGetters } from 'vuex'
import Toot from './Cards/Toot' import Toot from './Cards/Toot'
import scrollTop from '../../utils/scroll' import scrollTop from '../../utils/scroll'
@ -49,7 +50,13 @@ export default {
heading: state => state.TimelineSpace.Contents.Public.heading, heading: state => state.TimelineSpace.Contents.Public.heading,
unread: state => state.TimelineSpace.Contents.Public.unreadTimeline, unread: state => state.TimelineSpace.Contents.Public.unreadTimeline,
filter: state => state.TimelineSpace.Contents.Public.filter filter: state => state.TimelineSpace.Contents.Public.filter
}) }),
...mapGetters('TimelineSpace/Modals', [
'modalOpened'
]),
shortcutEnabled: function () {
return !this.focusedId && !this.modalOpened
}
}, },
created () { created () {
this.$store.commit('TimelineSpace/changeLoading', true) this.$store.commit('TimelineSpace/changeLoading', true)
@ -198,9 +205,7 @@ export default {
handleKey (event) { handleKey (event) {
switch (event.srcKey) { switch (event.srcKey) {
case 'next': case 'next':
if (!this.focusedId) { this.focusedId = this.timeline[0].uri
this.focusedId = this.timeline[0].uri
}
break break
} }
} }

View File

@ -10,7 +10,7 @@
:value="item.target"> :value="item.target">
</el-option> </el-option>
</el-select> </el-select>
<input v-model="query" :placeholder="$t('search.keyword')" class="search-keyword" v-shortkey="['enter']" @shortkey="search" autofocus></input> <input v-model="query" :placeholder="$t('search.keyword')" class="search-keyword" v-shortkey.avoid v-on:keyup.enter="search" autofocus></input>
<div class="clearfix"></div> <div class="clearfix"></div>
</el-form> </el-form>
</div> </div>

View File

@ -1,6 +1,6 @@
<template> <template>
<transition name="slide-detail"> <transition name="slide-detail">
<div id="side_bar" v-if="openSideBar"> <div id="side_bar" v-if="openSideBar" v-shortkey="['esc']" @shortkey="close">
<div class="header"> <div class="header">
<i class="el-icon-loading" v-show="loading"></i> <i class="el-icon-loading" v-show="loading"></i>
<i class="el-icon-close" @click="close"></i> <i class="el-icon-close" @click="close"></i>

View File

@ -17,7 +17,9 @@
<div> <div>
<el-form> <el-form>
<el-form-item :label="$t('header_menu.filter.title')"> <el-form-item :label="$t('header_menu.filter.title')">
<el-input v-model="filter" :placeholder="$t('header_menu.filter.placeholder')"></el-input> <div class="input-wrapper">
<input v-model="filter" :placeholder="$t('header_menu.filter.placeholder')" v-shortkey.avoid v-on:keyup.enter="applyFilter(filter)"></input>
</div>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="applyFilter(filter)">{{ $t('header_menu.filter.apply') }}</el-button> <el-button type="primary" @click="applyFilter(filter)">{{ $t('header_menu.filter.apply') }}</el-button>
@ -234,4 +236,33 @@ export default {
} }
} }
} }
.input-wrapper {
position: relative;
font-size: 14px;
display: inline-block;
width: 100%;
input {
background-color: #fff;
background-image: none;
border-radius: 4px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
color: #606266;
display: inline-block;
font-size: inherit;
height: 40px;
line-height: 40px;
outline: none;
padding: 0 15px;
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
width: 100%;
&:focus {
outline: none;
border-color: #409eff;
}
}
}
</style> </style>

View File

@ -14,6 +14,17 @@ const Modals = {
ListMembership, ListMembership,
AddListMember, AddListMember,
Shortcut Shortcut
},
getters: {
modalOpened: (state, getters, rootState) => {
const imageViewer = rootState.TimelineSpace.Modals.ImageViewer.modalOpen
const newToot = rootState.TimelineSpace.Modals.NewToot.modalOpen
const jump = rootState.TimelineSpace.Modals.Jump.modalOpen
const listMembership = rootState.TimelineSpace.Modals.ListMembership.modalOpen
const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen
const shortcut = rootState.TimelineSpace.Modals.Jump.modalOpen
return imageViewer || newToot || jump || listMembership || addListMember || shortcut
}
} }
} }