better click handler
This commit is contained in:
parent
8780e0191e
commit
bebb3fcfa6
4 changed files with 30 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ library.add(
|
|||
const Notification = {
|
||||
data () {
|
||||
return {
|
||||
selecting: false,
|
||||
statusExpanded: false,
|
||||
unmuted: false,
|
||||
showingApproveConfirmDialog: false,
|
||||
|
|
@ -62,11 +63,35 @@ const Notification = {
|
|||
UserLink,
|
||||
ConfirmModal
|
||||
},
|
||||
mounted () {
|
||||
document.addEventListener('selectionchange', this.onContentSelect)
|
||||
},
|
||||
unmounted () {
|
||||
document.removeEventListener('selectionchange', this.onContentSelect)
|
||||
},
|
||||
methods: {
|
||||
toggleStatusExpanded () {
|
||||
if (!this.expandable) return
|
||||
this.statusExpanded = !this.statusExpanded
|
||||
},
|
||||
onContentSelect () {
|
||||
const { isCollapsed, anchorNode, offsetNode } = document.getSelection()
|
||||
if (isCollapsed) {
|
||||
this.selecting = false
|
||||
return
|
||||
}
|
||||
const within = this.$refs.root.contains(anchorNode) || this.$refs.root.contains(offsetNode)
|
||||
if (within) {
|
||||
this.selecting = true
|
||||
} else {
|
||||
this.selecting = false
|
||||
}
|
||||
},
|
||||
onContentClick (e) {
|
||||
if (!this.selecting && !e.target.closest('a') && !e.target.closest('button')) {
|
||||
this.toggleStatusExpanded()
|
||||
}
|
||||
},
|
||||
generateUserProfileLink (user) {
|
||||
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<article
|
||||
v-if="notification.type === 'mention' || notification.type === 'status'"
|
||||
ref="root"
|
||||
>
|
||||
<Status
|
||||
class="Notification"
|
||||
|
|
@ -12,6 +13,7 @@
|
|||
<article
|
||||
class="NotificationParent"
|
||||
:class="{ '-expandable': expandable }"
|
||||
ref="root"
|
||||
v-else
|
||||
>
|
||||
<div
|
||||
|
|
@ -256,7 +258,7 @@
|
|||
:compact="!statusExpanded"
|
||||
:status="notification.status"
|
||||
:collapse="!statusExpanded"
|
||||
@click="toggleStatusExpanded()"
|
||||
@click="onContentClick"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ const StatusContent = {
|
|||
parseReadyDone: false
|
||||
}
|
||||
},
|
||||
emits: ['parseReady'],
|
||||
computed: {
|
||||
localCollapseSubjectDefault () {
|
||||
return this.mergedConfig.collapseMessageWithSubject
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ const StatusContent = {
|
|||
'controlledShowingLongSubject',
|
||||
'controlledToggleShowingLongSubject'
|
||||
],
|
||||
emits: ['parseReady', 'mediaplay', 'mediapause'],
|
||||
data () {
|
||||
return {
|
||||
uncontrolledShowingTall: this.fullContent || (this.inConversation && this.focused),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue