2018-03-12 17:42:47 +01:00
|
|
|
<template>
|
|
|
|
<el-dialog
|
2018-08-12 14:26:44 +02:00
|
|
|
:title="$t('modals.new_toot.title')"
|
2018-03-12 17:42:47 +01:00
|
|
|
:visible.sync="newTootModal"
|
2018-08-16 16:59:05 +02:00
|
|
|
:before-close="closeConfirm"
|
2018-03-12 17:42:47 +01:00
|
|
|
width="400px"
|
2019-05-07 16:22:01 +02:00
|
|
|
class="new-toot-modal"
|
|
|
|
>
|
2018-10-21 04:17:59 +02:00
|
|
|
<el-form v-on:submit.prevent="toot" role="form">
|
2018-07-15 03:34:08 +02:00
|
|
|
<div class="spoiler" v-show="showContentWarning">
|
2018-11-29 17:39:48 +01:00
|
|
|
<div class="el-input">
|
|
|
|
<input type="text" class="el-input__inner" :placeholder="$t('modals.new_toot.cw')" v-model="spoiler" v-shortkey.avoid />
|
|
|
|
</div>
|
2018-05-25 01:31:41 +02:00
|
|
|
</div>
|
2020-06-18 16:35:51 +02:00
|
|
|
<Status
|
|
|
|
v-model="status"
|
|
|
|
:opened="newTootModal"
|
|
|
|
:fixCursorPos="hashtagInserting"
|
|
|
|
:height="statusHeight"
|
|
|
|
@paste="onPaste"
|
|
|
|
@toot="toot"
|
|
|
|
/>
|
2018-03-12 17:42:47 +01:00
|
|
|
</el-form>
|
2019-07-16 18:36:19 +02:00
|
|
|
<Poll
|
|
|
|
v-if="openPoll"
|
|
|
|
v-model="polls"
|
|
|
|
@addPoll="addPoll"
|
|
|
|
@removePoll="removePoll"
|
|
|
|
:defaultExpire="pollExpire"
|
|
|
|
@changeExpire="changeExpire"
|
2020-06-18 16:35:51 +02:00
|
|
|
ref="poll"
|
2019-07-16 18:36:19 +02:00
|
|
|
></Poll>
|
2020-06-18 16:35:51 +02:00
|
|
|
<div class="preview" ref="preview">
|
2018-04-09 14:10:25 +02:00
|
|
|
<div class="image-wrapper" v-for="media in attachedMedias" v-bind:key="media.id">
|
2018-03-29 06:36:47 +02:00
|
|
|
<img :src="media.preview_url" class="preview-image" />
|
2018-11-19 15:56:49 +01:00
|
|
|
<el-button type="text" @click="removeAttachment(media)" class="remove-image"><icon name="times-circle"></icon></el-button>
|
2018-11-24 01:54:45 +01:00
|
|
|
<textarea
|
|
|
|
maxlength="420"
|
|
|
|
class="image-description"
|
|
|
|
:placeholder="$t('modals.new_toot.description')"
|
2019-05-13 17:25:09 +02:00
|
|
|
:value="mediaDescriptions[media.id]"
|
|
|
|
@input="updateDescription(media.id, $event.target.value)"
|
2019-05-07 16:22:01 +02:00
|
|
|
v-shortkey="{ left: ['arrowleft'], right: ['arrowright'] }"
|
2018-12-24 16:39:57 +01:00
|
|
|
@shortkey="handleDescriptionKey"
|
2018-11-24 01:54:45 +01:00
|
|
|
role="textbox"
|
|
|
|
contenteditable="true"
|
2019-05-07 16:22:01 +02:00
|
|
|
aria-multiline="true"
|
|
|
|
>
|
2018-11-24 01:54:45 +01:00
|
|
|
</textarea>
|
2018-03-29 06:36:47 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-29 05:09:28 +02:00
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
<div class="upload-image">
|
2019-07-15 17:02:33 +02:00
|
|
|
<el-button size="small" type="text" @click="selectImage" :title="$t('modals.new_toot.footer.add_image')">
|
2018-08-21 02:18:11 +02:00
|
|
|
<icon name="camera"></icon>
|
|
|
|
</el-button>
|
2019-05-07 16:22:01 +02:00
|
|
|
<input name="image" type="file" class="image-input" ref="image" @change="onChangeImage" :key="attachedMediaId" />
|
2018-03-29 05:09:28 +02:00
|
|
|
</div>
|
2019-07-15 12:42:33 +02:00
|
|
|
<div class="poll">
|
2019-07-15 17:02:33 +02:00
|
|
|
<el-button size="small" type="text" @click="togglePollForm" :title="$t('modals.new_toot.footer.poll')">
|
2019-07-15 12:42:33 +02:00
|
|
|
<icon name="poll"></icon>
|
|
|
|
</el-button>
|
|
|
|
</div>
|
2018-04-11 13:45:26 +02:00
|
|
|
<div class="privacy">
|
2018-04-11 16:12:51 +02:00
|
|
|
<el-dropdown trigger="click" @command="changeVisibility">
|
2019-07-15 17:02:33 +02:00
|
|
|
<el-button size="small" type="text" :title="$t('modals.new_toot.footer.change_visibility')">
|
2018-08-21 02:18:11 +02:00
|
|
|
<icon :name="visibilityIcon"></icon>
|
|
|
|
</el-button>
|
2018-04-11 13:45:26 +02:00
|
|
|
<el-dropdown-menu slot="dropdown">
|
2018-08-10 17:59:48 +02:00
|
|
|
<el-dropdown-item :command="visibilityList.Public.value">
|
|
|
|
<icon name="globe" class="privacy-icon"></icon>
|
2018-08-14 02:03:52 +02:00
|
|
|
{{ $t(visibilityList.Public.name) }}
|
2018-08-10 17:59:48 +02:00
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="visibilityList.Unlisted.value">
|
|
|
|
<icon name="unlock" class="privacy-icon"></icon>
|
2018-08-14 02:03:52 +02:00
|
|
|
{{ $t(visibilityList.Unlisted.name) }}
|
2018-08-10 17:59:48 +02:00
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="visibilityList.Private.value">
|
|
|
|
<icon name="lock" class="privacy-icon"></icon>
|
2018-08-14 02:03:52 +02:00
|
|
|
{{ $t(visibilityList.Private.name) }}
|
2018-08-10 17:59:48 +02:00
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="visibilityList.Direct.value">
|
|
|
|
<icon name="envelope" class="privacy-icon" scale="0.8"></icon>
|
2018-08-14 02:03:52 +02:00
|
|
|
{{ $t(visibilityList.Direct.name) }}
|
2018-08-10 17:59:48 +02:00
|
|
|
</el-dropdown-item>
|
2018-04-11 13:45:26 +02:00
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</div>
|
2018-07-15 03:34:08 +02:00
|
|
|
<div class="sensitive" v-show="attachedMedias.length > 0">
|
2019-05-07 16:22:01 +02:00
|
|
|
<el-button
|
|
|
|
size="small"
|
|
|
|
type="text"
|
|
|
|
@click="changeSensitive"
|
2019-07-15 17:02:33 +02:00
|
|
|
:title="$t('modals.new_toot.footer.change_sensitive')"
|
2019-05-07 16:22:01 +02:00
|
|
|
:aria-pressed="sensitive"
|
|
|
|
>
|
2018-12-08 01:21:44 +01:00
|
|
|
<icon name="eye-slash" v-show="!sensitive"></icon>
|
|
|
|
<icon name="eye" v-show="sensitive"></icon>
|
2018-05-24 16:38:24 +02:00
|
|
|
</el-button>
|
|
|
|
</div>
|
2018-05-25 01:31:41 +02:00
|
|
|
<div class="content-warning">
|
2019-05-07 16:22:01 +02:00
|
|
|
<el-button
|
|
|
|
size="small"
|
|
|
|
type="text"
|
|
|
|
@click="showContentWarning = !showContentWarning"
|
2019-07-15 17:02:33 +02:00
|
|
|
:title="$t('modals.new_toot.footer.add_cw')"
|
2019-05-07 16:22:01 +02:00
|
|
|
:class="showContentWarning ? '' : 'clickable'"
|
|
|
|
:aria-pressed="showContentWarning"
|
|
|
|
>
|
2018-09-18 15:19:11 +02:00
|
|
|
<span class="cw-text">CW</span>
|
2018-05-25 01:31:41 +02:00
|
|
|
</el-button>
|
|
|
|
</div>
|
2018-09-18 15:30:31 +02:00
|
|
|
<div class="pined-hashtag">
|
2019-05-07 16:22:01 +02:00
|
|
|
<el-button
|
|
|
|
size="small"
|
|
|
|
type="text"
|
|
|
|
@click="pinedHashtag = !pinedHashtag"
|
2019-07-15 17:02:33 +02:00
|
|
|
:title="$t('modals.new_toot.footer.pined_hashtag')"
|
2019-05-07 16:22:01 +02:00
|
|
|
:class="pinedHashtag ? '' : 'clickable'"
|
|
|
|
:aria-pressed="pinedHashtag"
|
|
|
|
>
|
2018-09-18 15:30:31 +02:00
|
|
|
<icon name="hashtag"></icon>
|
|
|
|
</el-button>
|
|
|
|
</div>
|
2019-05-07 16:22:01 +02:00
|
|
|
<div class="info">
|
|
|
|
<img src="../../../assets/images/loading-spinner-wide.svg" v-show="loading" class="loading" />
|
|
|
|
<span class="text-count">{{ tootMax - status.length }}</span>
|
|
|
|
|
|
|
|
<el-button class="toot-action" size="small" @click="closeConfirm(close)">{{ $t('modals.new_toot.cancel') }}</el-button>
|
|
|
|
<el-button class="toot-action" size="small" type="primary" @click="toot" :loading="blockSubmit">{{
|
|
|
|
$t('modals.new_toot.toot')
|
|
|
|
}}</el-button>
|
|
|
|
</div>
|
2018-03-29 08:49:39 +02:00
|
|
|
<div class="clearfix"></div>
|
2018-03-29 05:09:28 +02:00
|
|
|
</div>
|
2020-06-18 16:35:51 +02:00
|
|
|
<resize-observer @notify="handleResize" />
|
2018-03-12 17:42:47 +01:00
|
|
|
</el-dialog>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-19 14:24:06 +02:00
|
|
|
import { mapState, mapGetters } from 'vuex'
|
2018-08-12 16:17:57 +02:00
|
|
|
import Visibility from '~/src/constants/visibility'
|
2018-08-06 18:09:00 +02:00
|
|
|
import Status from './NewToot/Status'
|
2019-07-15 14:38:03 +02:00
|
|
|
import Poll from './NewToot/Poll'
|
2019-07-20 15:21:40 +02:00
|
|
|
import { NewTootTootLength, NewTootAttachLength, NewTootModalOpen, NewTootBlockSubmit, NewTootPollInvalid } from '@/errors/validations'
|
2018-03-14 14:19:17 +01:00
|
|
|
|
2018-03-12 17:42:47 +01:00
|
|
|
export default {
|
2018-03-29 04:25:35 +02:00
|
|
|
name: 'new-toot',
|
2018-08-06 18:09:00 +02:00
|
|
|
components: {
|
2019-07-15 14:38:03 +02:00
|
|
|
Status,
|
|
|
|
Poll
|
2018-08-06 18:09:00 +02:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
data() {
|
2018-03-21 15:37:46 +01:00
|
|
|
return {
|
2018-11-12 14:18:33 +01:00
|
|
|
status: '',
|
|
|
|
spoiler: '',
|
2018-08-10 17:59:48 +02:00
|
|
|
showContentWarning: false,
|
2019-07-15 12:42:33 +02:00
|
|
|
visibilityList: Visibility,
|
2019-07-16 14:51:33 +02:00
|
|
|
openPoll: false,
|
2019-07-20 15:09:55 +02:00
|
|
|
polls: [],
|
2019-07-16 18:36:19 +02:00
|
|
|
pollExpire: {
|
|
|
|
label: this.$t('modals.new_toot.poll.expires.1_day'),
|
|
|
|
value: 3600 * 24
|
2020-06-18 16:35:51 +02:00
|
|
|
},
|
|
|
|
statusHeight: 240
|
2018-03-21 15:37:46 +01:00
|
|
|
}
|
|
|
|
},
|
2018-03-12 17:42:47 +01:00
|
|
|
computed: {
|
2018-09-19 14:24:06 +02:00
|
|
|
...mapState('TimelineSpace/Modals/NewToot', {
|
2019-05-07 16:22:01 +02:00
|
|
|
replyToId: state => {
|
2018-09-19 14:24:06 +02:00
|
|
|
if (state.replyToMessage !== null) {
|
|
|
|
return state.replyToMessage.id
|
2018-03-14 14:19:17 +01:00
|
|
|
} else {
|
|
|
|
return null
|
|
|
|
}
|
2018-03-29 06:05:19 +02:00
|
|
|
},
|
2018-09-19 14:24:06 +02:00
|
|
|
attachedMedias: state => state.attachedMedias,
|
|
|
|
attachedMediaId: state => state.attachedMediaId,
|
2019-05-13 17:25:09 +02:00
|
|
|
mediaDescriptions: state => state.mediaDescriptions,
|
2018-09-19 14:24:06 +02:00
|
|
|
blockSubmit: state => state.blockSubmit,
|
|
|
|
visibility: state => state.visibility,
|
|
|
|
sensitive: state => state.sensitive,
|
2018-11-12 14:18:33 +01:00
|
|
|
initialStatus: state => state.initialStatus,
|
2018-11-17 19:27:58 +01:00
|
|
|
initialSpoiler: state => state.initialSpoiler,
|
2019-05-07 16:22:01 +02:00
|
|
|
visibilityIcon: state => {
|
2018-09-19 14:24:06 +02:00
|
|
|
switch (state.visibility) {
|
2018-08-01 16:41:05 +02:00
|
|
|
case Visibility.Public.value:
|
2018-04-11 16:12:51 +02:00
|
|
|
return 'globe'
|
2018-08-01 16:41:05 +02:00
|
|
|
case Visibility.Unlisted.value:
|
2018-04-11 16:12:51 +02:00
|
|
|
return 'unlock'
|
2018-08-01 16:41:05 +02:00
|
|
|
case Visibility.Private.value:
|
2018-04-11 16:12:51 +02:00
|
|
|
return 'lock'
|
2018-08-01 16:41:05 +02:00
|
|
|
case Visibility.Direct.value:
|
2018-04-11 16:12:51 +02:00
|
|
|
return 'envelope'
|
|
|
|
default:
|
|
|
|
return 'globe'
|
|
|
|
}
|
2019-05-07 16:22:01 +02:00
|
|
|
},
|
|
|
|
loading: state => state.loading
|
2018-03-14 14:19:17 +01:00
|
|
|
}),
|
2018-10-02 13:49:37 +02:00
|
|
|
...mapState('TimelineSpace', {
|
|
|
|
tootMax: state => state.tootMax
|
|
|
|
}),
|
2019-05-07 16:22:01 +02:00
|
|
|
...mapGetters('TimelineSpace/Modals/NewToot', ['hashtagInserting']),
|
2018-03-12 17:42:47 +01:00
|
|
|
newTootModal: {
|
2019-05-07 16:22:01 +02:00
|
|
|
get() {
|
2018-03-29 04:25:35 +02:00
|
|
|
return this.$store.state.TimelineSpace.Modals.NewToot.modalOpen
|
2018-03-12 17:42:47 +01:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
set(value) {
|
2018-06-19 15:44:33 +02:00
|
|
|
if (value) {
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/openModal')
|
|
|
|
} else {
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/closeModal')
|
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
2018-03-14 14:19:17 +01:00
|
|
|
},
|
2018-09-19 14:24:06 +02:00
|
|
|
pinedHashtag: {
|
2019-05-07 16:22:01 +02:00
|
|
|
get() {
|
2018-09-19 14:24:06 +02:00
|
|
|
return this.$store.state.TimelineSpace.Modals.NewToot.pinedHashtag
|
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
set(value) {
|
2018-09-19 14:24:06 +02:00
|
|
|
this.$store.commit('TimelineSpace/Modals/NewToot/changePinedHashtag', value)
|
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
2018-03-13 00:41:03 +01:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
created() {
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/setupLoading')
|
|
|
|
},
|
2018-04-10 16:13:43 +02:00
|
|
|
watch: {
|
2020-04-11 10:23:40 +02:00
|
|
|
newTootModal: function (newState, oldState) {
|
2018-04-10 16:13:43 +02:00
|
|
|
if (!oldState && newState) {
|
2018-11-17 19:27:58 +01:00
|
|
|
this.showContentWarning = this.initialSpoiler
|
2018-11-12 14:18:33 +01:00
|
|
|
this.status = this.initialStatus
|
2018-11-17 19:27:58 +01:00
|
|
|
this.spoiler = this.initialSpoiler
|
2018-04-10 16:13:43 +02:00
|
|
|
}
|
2018-03-13 02:04:07 +01:00
|
|
|
}
|
|
|
|
},
|
2018-03-13 00:41:03 +01:00
|
|
|
methods: {
|
2019-05-07 16:22:01 +02:00
|
|
|
close() {
|
2018-08-04 05:09:13 +02:00
|
|
|
this.filteredAccount = []
|
2019-07-20 18:11:52 +02:00
|
|
|
this.openPoll = false
|
|
|
|
this.polls = []
|
2019-07-16 18:36:19 +02:00
|
|
|
this.pollExpire = {
|
|
|
|
label: this.$t('modals.new_toot.poll.expires.1_day'),
|
|
|
|
value: 3600 * 24
|
|
|
|
}
|
2019-05-27 15:56:54 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/resetMediaCount')
|
2018-06-19 15:44:33 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/closeModal')
|
2018-03-21 15:37:46 +01:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
async toot() {
|
2019-05-13 17:25:09 +02:00
|
|
|
const form = {
|
2018-04-11 16:19:25 +02:00
|
|
|
status: this.status,
|
2019-07-16 16:56:00 +02:00
|
|
|
spoiler: this.spoiler,
|
2019-07-16 18:36:19 +02:00
|
|
|
polls: this.polls,
|
|
|
|
pollExpireSeconds: this.pollExpire.value
|
2018-03-29 06:16:15 +02:00
|
|
|
}
|
2018-04-09 09:49:41 +02:00
|
|
|
|
2019-05-14 16:33:28 +02:00
|
|
|
try {
|
2019-06-03 15:27:50 +02:00
|
|
|
const status = await this.$store.dispatch('TimelineSpace/Modals/NewToot/postToot', form)
|
2019-05-14 16:33:28 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/updateHashtags', status.tags)
|
|
|
|
this.close()
|
|
|
|
} catch (err) {
|
2019-05-13 17:25:09 +02:00
|
|
|
console.error(err)
|
2019-05-14 16:33:28 +02:00
|
|
|
if (err instanceof NewTootTootLength) {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('validation.new_toot.toot_length', { min: 1, max: this.tootMax }),
|
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
} else if (err instanceof NewTootAttachLength) {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('validation.new_toot.attach_length', { max: 4 }),
|
|
|
|
type: 'error'
|
2019-07-20 15:21:40 +02:00
|
|
|
})
|
|
|
|
} else if (err instanceof NewTootPollInvalid) {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('validation.new_toot.poll_invalid'),
|
|
|
|
type: 'error'
|
2019-05-14 16:33:28 +02:00
|
|
|
})
|
|
|
|
} else if (err instanceof NewTootModalOpen || err instanceof NewTootBlockSubmit) {
|
|
|
|
// Nothing
|
|
|
|
} else {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('message.toot_error'),
|
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 05:09:28 +02:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
selectImage() {
|
2018-03-29 05:09:28 +02:00
|
|
|
this.$refs.image.click()
|
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
onChangeImage(e) {
|
2018-03-29 06:05:19 +02:00
|
|
|
if (e.target.files.item(0) === null || e.target.files.item(0) === undefined) {
|
|
|
|
return
|
|
|
|
}
|
2018-05-27 15:05:29 +02:00
|
|
|
const file = e.target.files.item(0)
|
2018-06-14 02:05:03 +02:00
|
|
|
if (!file.type.includes('image') && !file.type.includes('video')) {
|
2018-03-29 06:05:19 +02:00
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('validation.new_toot.attach_image'),
|
2018-03-29 06:05:19 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
2018-05-27 15:05:29 +02:00
|
|
|
this.updateImage(file)
|
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
onPaste(e) {
|
2019-05-09 17:05:40 +02:00
|
|
|
const mimeTypes = window.clipboard.availableFormats().filter(type => type.startsWith('image'))
|
2018-08-20 05:22:35 +02:00
|
|
|
if (mimeTypes.length === 0) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
e.preventDefault()
|
2019-11-20 15:32:12 +01:00
|
|
|
const image = window.clipboard.readImage()
|
2018-08-20 05:22:35 +02:00
|
|
|
let data
|
|
|
|
if (/^image\/jpe?g$/.test(mimeTypes[0])) {
|
|
|
|
data = image.toJPEG(100)
|
|
|
|
} else {
|
|
|
|
data = image.toPNG()
|
|
|
|
}
|
|
|
|
const file = new File([data], 'clipboard.picture', { type: mimeTypes[0] })
|
|
|
|
this.updateImage(file)
|
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
updateImage(file) {
|
2019-05-27 15:56:54 +02:00
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/incrementMediaCount')
|
2020-06-18 16:35:51 +02:00
|
|
|
this.$store
|
|
|
|
.dispatch('TimelineSpace/Modals/NewToot/uploadImage', file)
|
|
|
|
.then(() => {
|
|
|
|
this.statusHeight = this.statusHeight - this.$refs.preview.offsetHeight
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.$message({
|
|
|
|
message: this.$t('message.attach_error'),
|
|
|
|
type: 'error'
|
|
|
|
})
|
2018-03-29 06:05:19 +02:00
|
|
|
})
|
2018-03-29 06:36:47 +02:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
removeAttachment(media) {
|
2020-06-18 16:35:51 +02:00
|
|
|
const previousHeight = this.$refs.preview.offsetHeight
|
|
|
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/removeMedia', media).then(() => {
|
|
|
|
this.statusHeight = this.statusHeight + previousHeight
|
|
|
|
})
|
2018-03-29 08:49:39 +02:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
changeVisibility(level) {
|
2018-08-10 17:59:48 +02:00
|
|
|
this.$store.commit('TimelineSpace/Modals/NewToot/changeVisibilityValue', level)
|
2018-05-24 16:38:24 +02:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
changeSensitive() {
|
2018-05-24 16:38:24 +02:00
|
|
|
this.$store.commit('TimelineSpace/Modals/NewToot/changeSensitive', !this.sensitive)
|
2018-08-16 16:59:05 +02:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
closeConfirm(done) {
|
2018-08-16 16:59:05 +02:00
|
|
|
if (this.status.length === 0) {
|
|
|
|
done()
|
|
|
|
} else {
|
2019-05-07 16:22:01 +02:00
|
|
|
this.$confirm(this.$t('modals.new_toot.close_confirm'), {
|
|
|
|
confirmButtonText: this.$t('modals.new_toot.close_confirm_ok'),
|
|
|
|
cancelButtonText: this.$t('modals.new_toot.close_confirm_cancel')
|
|
|
|
})
|
2018-08-16 16:59:05 +02:00
|
|
|
.then(_ => {
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
.catch(_ => {})
|
|
|
|
}
|
2018-12-24 16:39:57 +01:00
|
|
|
},
|
2019-05-07 16:22:01 +02:00
|
|
|
handleDescriptionKey(event) {
|
2018-12-24 16:39:57 +01:00
|
|
|
const current = event.target.selectionStart
|
|
|
|
switch (event.srcKey) {
|
|
|
|
case 'left':
|
|
|
|
event.target.setSelectionRange(current - 1, current - 1)
|
|
|
|
break
|
|
|
|
case 'right':
|
|
|
|
event.target.setSelectionRange(current + 1, current + 1)
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
return true
|
|
|
|
}
|
2019-05-13 17:25:09 +02:00
|
|
|
},
|
|
|
|
updateDescription(id, value) {
|
|
|
|
this.$store.commit('TimelineSpace/Modals/NewToot/updateMediaDescription', { id: id, description: value })
|
2019-07-15 12:42:33 +02:00
|
|
|
},
|
2020-06-18 16:35:51 +02:00
|
|
|
async togglePollForm() {
|
|
|
|
const previousHeight = this.$refs.poll ? this.$refs.poll.$el.offsetHeight : 0
|
|
|
|
const toggle = () => {
|
|
|
|
this.openPoll = !this.openPoll
|
|
|
|
if (this.openPoll) {
|
|
|
|
this.polls = ['', '']
|
|
|
|
} else {
|
|
|
|
this.polls = []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await toggle()
|
|
|
|
console.log(this.$refs.poll)
|
2019-07-20 15:09:55 +02:00
|
|
|
if (this.openPoll) {
|
2020-06-18 16:35:51 +02:00
|
|
|
this.statusHeight = this.statusHeight - this.$refs.poll.$el.offsetHeight
|
2019-07-20 15:09:55 +02:00
|
|
|
} else {
|
2020-06-18 16:35:51 +02:00
|
|
|
this.statusHeight = this.statusHeight + previousHeight
|
2019-07-20 15:09:55 +02:00
|
|
|
}
|
2019-07-16 14:51:33 +02:00
|
|
|
},
|
|
|
|
addPoll() {
|
|
|
|
this.polls.push('')
|
|
|
|
},
|
|
|
|
removePoll(id) {
|
|
|
|
this.polls.splice(id, 1)
|
2019-07-16 18:36:19 +02:00
|
|
|
},
|
|
|
|
changeExpire(obj) {
|
|
|
|
this.pollExpire = obj
|
2020-06-18 16:35:51 +02:00
|
|
|
},
|
|
|
|
handleResize(event) {
|
|
|
|
const pollHeight = this.$refs.poll ? this.$refs.poll.$el.offsetHeight : 0
|
|
|
|
this.statusHeight = event.height - 63 - 54 - this.$refs.preview.offsetHeight - pollHeight
|
2018-03-13 00:41:03 +01:00
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2018-03-14 09:14:47 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.new-toot-modal /deep/ {
|
2020-06-18 16:35:51 +02:00
|
|
|
.el-dialog {
|
|
|
|
background-color: #f2f6fc;
|
|
|
|
overflow: hidden;
|
|
|
|
resize: both;
|
|
|
|
}
|
|
|
|
|
2018-03-12 17:42:47 +01:00
|
|
|
.el-dialog__header {
|
|
|
|
background-color: #4a5664;
|
|
|
|
|
|
|
|
.el-dialog__title {
|
|
|
|
color: #ebeef5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-dialog__body {
|
|
|
|
padding: 0;
|
|
|
|
|
2018-05-25 01:31:41 +02:00
|
|
|
.spoiler {
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 4px 0;
|
|
|
|
background-color: #4a5664;
|
|
|
|
|
|
|
|
input {
|
|
|
|
border-radius: 0;
|
2018-05-28 14:13:30 +02:00
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
color: #c0c4cc;
|
|
|
|
}
|
2018-05-25 01:31:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-29 06:36:47 +02:00
|
|
|
.preview {
|
|
|
|
box-sizing: border-box;
|
2018-11-19 15:56:49 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
flex-wrap: wrap;
|
2018-03-29 06:36:47 +02:00
|
|
|
|
|
|
|
.image-wrapper {
|
|
|
|
position: relative;
|
2018-11-19 15:56:49 +01:00
|
|
|
flex: 1 1 0;
|
|
|
|
min-width: 40%;
|
|
|
|
height: 150px;
|
|
|
|
margin: 4px;
|
2018-03-29 06:36:47 +02:00
|
|
|
|
|
|
|
.preview-image {
|
2018-11-19 15:56:49 +01:00
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
object-fit: cover;
|
|
|
|
border: 0;
|
|
|
|
border-radius: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.image-description {
|
|
|
|
position: absolute;
|
2018-11-19 19:17:38 +01:00
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
2018-11-19 15:56:49 +01:00
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: 0;
|
|
|
|
border-bottom-left-radius: 8px;
|
|
|
|
border-bottom-right-radius: 8px;
|
|
|
|
background: linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0, rgba(0, 0, 0, 0.35) 80%, transparent);
|
|
|
|
font-size: var(--font-base-size);
|
|
|
|
color: #fff;
|
|
|
|
opacity: 1;
|
|
|
|
resize: none;
|
2018-11-24 01:54:45 +01:00
|
|
|
overflow: scroll;
|
2018-11-19 15:56:49 +01:00
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
color: #c0c4cc;
|
|
|
|
}
|
2018-03-29 06:36:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.remove-image {
|
|
|
|
position: absolute;
|
2018-11-19 15:56:49 +01:00
|
|
|
top: 2px;
|
|
|
|
left: 2px;
|
2018-03-29 08:49:39 +02:00
|
|
|
padding: 0;
|
2018-03-29 06:36:47 +02:00
|
|
|
cursor: pointer;
|
2018-11-19 15:56:49 +01:00
|
|
|
font-size: 1.5rem;
|
|
|
|
|
|
|
|
.fa-icon {
|
2020-04-11 10:23:40 +02:00
|
|
|
font-size: 0.9rem;
|
2018-11-19 15:56:49 +01:00
|
|
|
width: auto;
|
|
|
|
height: 1em;
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 100%;
|
|
|
|
}
|
2018-03-29 06:36:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.el-dialog__footer {
|
|
|
|
background-color: #f2f6fc;
|
2020-04-11 10:23:40 +02:00
|
|
|
font-size: var(--base-font-size);
|
2020-06-18 16:35:51 +02:00
|
|
|
padding-bottom: 0;
|
|
|
|
margin-bottom: 20px;
|
2018-03-13 02:52:28 +01:00
|
|
|
|
2018-03-29 05:09:28 +02:00
|
|
|
.upload-image {
|
|
|
|
text-align: left;
|
2018-03-29 08:49:39 +02:00
|
|
|
float: left;
|
2018-03-29 05:09:28 +02:00
|
|
|
|
|
|
|
.image-input {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 12:42:33 +02:00
|
|
|
.poll {
|
|
|
|
float: left;
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
|
2018-04-11 13:45:26 +02:00
|
|
|
.privacy {
|
|
|
|
float: left;
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
|
2018-05-24 16:38:24 +02:00
|
|
|
.sensitive {
|
|
|
|
float: left;
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
|
2018-05-25 01:31:41 +02:00
|
|
|
.content-warning {
|
|
|
|
float: left;
|
|
|
|
margin-left: 8px;
|
|
|
|
|
2018-09-18 15:19:11 +02:00
|
|
|
.cw-text {
|
2018-05-25 01:31:41 +02:00
|
|
|
font-weight: 800;
|
2018-09-18 15:19:11 +02:00
|
|
|
line-height: 18px;
|
2018-05-25 01:31:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-18 15:30:31 +02:00
|
|
|
.pined-hashtag {
|
|
|
|
float: left;
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.clickable {
|
|
|
|
color: #909399;
|
|
|
|
}
|
|
|
|
|
2019-05-07 16:22:01 +02:00
|
|
|
.info {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
.loading {
|
|
|
|
width: 18px;
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.text-count {
|
|
|
|
padding-right: 10px;
|
|
|
|
color: #909399;
|
|
|
|
}
|
2018-03-13 02:52:28 +01:00
|
|
|
}
|
2018-11-17 19:27:58 +01:00
|
|
|
|
|
|
|
.toot-action {
|
|
|
|
font-size: var(--base-font-size);
|
|
|
|
margin-top: 2px;
|
|
|
|
margin-bottom: 2px;
|
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
|
|
|
}
|
2018-04-11 13:45:26 +02:00
|
|
|
|
|
|
|
.privacy-icon {
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
2018-03-12 17:42:47 +01:00
|
|
|
</style>
|