Sharkey/src/client/app/desktop/views/components/post-form.vue

300 lines
7.6 KiB
Vue
Raw Normal View History

2018-02-11 18:06:17 +02:00
<template>
2019-05-20 22:21:43 +03:00
<div class="gjisdzwh"
2018-02-26 23:25:17 +02:00
@dragover.stop="onDragover"
2018-02-11 18:06:17 +02:00
@dragenter="onDragenter"
@dragleave="onDragleave"
2018-02-26 23:25:17 +02:00
@drop.stop="onDrop"
2018-02-11 18:06:17 +02:00
>
<div class="content">
2018-04-28 23:28:34 +03:00
<div v-if="visibility == 'specified'" class="visibleUsers">
<span v-for="u in visibleUsers">
2018-12-06 09:09:33 +02:00
<mk-user-name :user="u"/><a @click="removeVisibleUser(u)">[x]</a>
</span>
<a @click="addVisibleUser">{{ $t('@.post-form.add-visible-user') }}</a>
2018-04-28 23:28:34 +03:00
</div>
2018-08-17 00:03:03 +03:00
<div class="hashtags" v-if="recentHashtags.length > 0 && $store.state.settings.suggestRecentHashtags">
<b>{{ $t('@.post-form.recent-tags') }}:</b>
<a v-for="tag in recentHashtags.slice(0, 5)" @click="addTag(tag)" :title="$t('@.post-form.click-to-tagging')">#{{ tag }}</a>
</div>
<div class="with-quote" v-if="quoteId">{{ $t('@.post-form.quote-attached') }}</div>
<div class="local-only" v-if="localOnly == true">{{ $t('@.post-form.local-only-message') }}</div>
2019-05-27 12:06:01 +03:00
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('@.post-form.cw-placeholder')" v-autocomplete="{ model: 'cw' }">
2018-11-12 17:12:55 +02:00
<div class="textarea">
<textarea :class="{ with: (files.length != 0 || poll) }"
ref="text" v-model="text" :disabled="posting"
@keydown="onKeydown" @paste="onPaste" :placeholder="placeholder"
v-autocomplete="{ model: 'text' }"
2018-11-12 17:12:55 +02:00
></textarea>
<button class="emoji" @click="emoji" ref="emoji">
<fa :icon="['far', 'laugh']"/>
</button>
<x-post-form-attaches class="files" :class="{ with: poll }" :files="files"/>
2019-05-20 21:45:07 +03:00
<x-poll-editor class="poll-editor" v-if="poll" ref="poll" @destroyed="poll = false" @updated="onPollUpdate()"/>
2018-11-12 17:12:55 +02:00
</div>
2018-02-11 18:06:17 +02:00
</div>
2018-02-22 19:09:48 +02:00
<mk-uploader ref="uploader" @uploaded="attachMedia" @change="onChangeUploadings"/>
<button class="upload" :title="$t('@.post-form.attach-media-from-local')" @click="chooseFile"><fa icon="upload"/></button>
<button class="drive" :title="$t('@.post-form.attach-media-from-drive')" @click="chooseFileFromDrive"><fa icon="cloud"/></button>
<button class="kao" :title="$t('@.post-form.insert-a-kao')" @click="kao"><fa :icon="['far', 'smile']"/></button>
<button class="poll" :title="$t('@.post-form.create-poll')" @click="poll = !poll"><fa icon="chart-pie"/></button>
<button class="cw" :title="$t('@.post-form.hide-contents')" @click="useCw = !useCw"><fa :icon="['far', 'eye-slash']"/></button>
<button class="geo" :title="$t('@.post-form.attach-location-information')" @click="geo ? removeGeo() : setGeo()"><fa icon="map-marker-alt"/></button>
<button class="visibility" :title="$t('@.post-form.visibility')" @click="setVisibility" ref="visibilityButton">
<span v-if="visibility === 'public'"><fa icon="globe"/></span>
<span v-if="visibility === 'home'"><fa icon="home"/></span>
<span v-if="visibility === 'followers'"><fa icon="unlock"/></span>
<span v-if="visibility === 'specified'"><fa icon="envelope"/></span>
</button>
2018-11-09 01:26:32 +02:00
<p class="text-count" :class="{ over: trimmedLength(text) > maxNoteTextLength }">{{ maxNoteTextLength - trimmedLength(text) }}</p>
2018-12-12 18:18:17 +02:00
<ui-button primary :wait="posting" class="submit" :disabled="!canPost" @click="post">
{{ posting ? $t('@.post-form.posting') : submitText }}<mk-ellipsis v-if="posting"/>
2018-12-12 18:18:17 +02:00
</ui-button>
2018-09-15 22:34:46 +03:00
<input ref="file" type="file" multiple="multiple" tabindex="-1" @change="onChangeFile"/>
2018-02-11 18:06:17 +02:00
<div class="dropzone" v-if="draghover"></div>
</div>
</template>
2018-02-12 05:21:26 +02:00
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import form from '../../../common/scripts/post-form';
2018-02-12 05:21:26 +02:00
export default Vue.extend({
i18n: i18n('desktop/views/components/post-form.vue'),
2019-01-03 05:34:08 +02:00
mixins: [
form({
onSuccess: self => {
self.$notify(self.renote
? self.$t('reposted')
: self.reply
? self.$t('replied')
: self.$t('posted'));
},
onFailure: self => {
self.$notify(self.renote
? self.$t('renote-failed')
: self.reply
? self.$t('reply-failed')
: self.$t('note-failed'));
2018-02-12 11:49:06 +02:00
}
}),
],
2018-02-12 05:21:26 +02:00
});
</script>
2018-02-12 11:49:06 +02:00
<style lang="stylus" scoped>
2019-05-20 22:21:43 +03:00
.gjisdzwh
2018-02-12 11:49:06 +02:00
display block
padding 16px
2018-09-27 08:32:48 +03:00
background var(--desktopPostFormBg)
2018-09-30 16:45:24 +03:00
overflow hidden
2018-02-12 11:49:06 +02:00
&:after
content ""
display block
clear both
> .content
2018-04-22 11:04:52 +03:00
> input
2018-11-12 17:12:55 +02:00
> .textarea > textarea
2018-02-12 11:49:06 +02:00
display block
width 100%
2018-04-22 11:04:52 +03:00
padding 12px
2018-02-12 11:49:06 +02:00
font-size 16px
2018-09-27 08:32:48 +03:00
color var(--desktopPostFormTextareaFg)
background var(--desktopPostFormTextareaBg)
2018-02-12 11:49:06 +02:00
outline none
2018-09-26 14:19:35 +03:00
border solid 1px var(--primaryAlpha01)
2018-02-12 11:49:06 +02:00
border-radius 4px
2018-04-22 11:04:52 +03:00
transition border-color .2s ease
2018-11-16 10:41:52 +02:00
padding-right 30px
2018-02-12 11:49:06 +02:00
&:hover
2018-09-26 14:19:35 +03:00
border-color var(--primaryAlpha02)
2018-02-12 11:49:06 +02:00
transition border-color .1s ease
2018-04-22 11:04:52 +03:00
&:focus
2018-09-26 14:19:35 +03:00
border-color var(--primaryAlpha05)
2018-04-22 11:04:52 +03:00
transition border-color 0s ease
&:disabled
opacity 0.5
&::-webkit-input-placeholder
2018-09-26 14:19:35 +03:00
color var(--primaryAlpha03)
2018-04-22 11:04:52 +03:00
> input
margin-bottom 8px
2018-11-12 17:12:55 +02:00
> .textarea
> .emoji
position absolute
top 0
right 0
padding 10px
font-size 18px
color var(--text)
opacity 0.5
2018-04-22 11:04:52 +03:00
2018-11-12 17:12:55 +02:00
&:hover
color var(--textHighlighted)
opacity 1
2018-02-12 11:49:06 +02:00
2018-11-12 17:12:55 +02:00
&:active
color var(--primary)
opacity 1
2018-02-12 11:49:06 +02:00
2018-11-12 17:12:55 +02:00
> textarea
margin 0
max-width 100%
min-width 100%
min-height 84px
&:hover
& + * + *
2018-11-12 17:21:49 +02:00
& + * + * + *
2018-11-12 17:12:55 +02:00
border-color var(--primaryAlpha02)
transition border-color .1s ease
&:focus
& + * + *
2018-11-12 17:21:49 +02:00
& + * + * + *
2018-11-12 17:12:55 +02:00
border-color var(--primaryAlpha05)
transition border-color 0s ease
& + .emoji
opacity 0.7
&.with
border-bottom solid 1px var(--primaryAlpha01) !important
border-radius 4px 4px 0 0
2018-02-12 11:49:06 +02:00
2018-11-12 17:21:49 +02:00
> .files
margin 0
padding 0
background var(--desktopPostFormTextareaBg)
border solid 1px var(--primaryAlpha01)
border-top none
border-radius 0 0 4px 4px
transition border-color .3s ease
&.with
border-bottom solid 1px var(--primaryAlpha01) !important
border-radius 0
2019-05-20 21:45:07 +03:00
> .poll-editor
2018-11-12 17:21:49 +02:00
background var(--desktopPostFormTextareaBg)
border solid 1px var(--primaryAlpha01)
border-top none
border-radius 0 0 4px 4px
transition border-color .3s ease
2018-04-28 23:28:34 +03:00
> .visibleUsers
margin-bottom 8px
font-size 14px
> span
margin-right 16px
2018-09-27 11:42:51 +03:00
color var(--primary)
2018-04-28 23:28:34 +03:00
> .hashtags
2018-07-20 20:58:44 +03:00
margin 0 0 8px 0
overflow hidden
2018-07-20 19:21:27 +03:00
white-space nowrap
2018-07-20 20:58:44 +03:00
font-size 14px
> b
2018-09-27 11:42:51 +03:00
color var(--primary)
2018-07-20 20:58:44 +03:00
> *
2018-07-20 20:58:44 +03:00
margin-right 8px
2018-07-20 19:21:27 +03:00
white-space nowrap
> .local-only
margin 0 0 8px 0
color var(--primary)
2018-02-16 08:38:12 +02:00
> .mk-uploader
2018-02-12 11:49:06 +02:00
margin 8px 0 0 0
padding 8px
2018-09-26 14:19:35 +03:00
border solid 1px var(--primaryAlpha02)
2018-02-12 11:49:06 +02:00
border-radius 4px
2018-02-16 08:38:12 +02:00
input[type='file']
2018-02-12 11:49:06 +02:00
display none
2018-02-16 08:38:12 +02:00
.submit
2018-02-12 11:49:06 +02:00
display block
position absolute
bottom 16px
right 16px
width 110px
height 40px
2018-04-29 03:00:41 +03:00
> .text-count
pointer-events none
display block
position absolute
bottom 16px
right 138px
margin 0
line-height 40px
2018-09-26 14:19:35 +03:00
color var(--primaryAlpha05)
2018-04-29 03:00:41 +03:00
&.over
color #ec3828
2018-03-03 09:35:15 +02:00
> .upload
> .drive
> .kao
> .poll
2018-11-09 01:26:32 +02:00
> .cw
2018-03-05 01:44:37 +02:00
> .geo
2018-04-28 11:25:56 +03:00
> .visibility
2018-02-12 11:49:06 +02:00
display inline-block
cursor pointer
padding 0
margin 8px 4px 0 0
width 40px
height 40px
font-size 1em
2018-09-28 09:56:50 +03:00
color var(--desktopPostFormTransparentButtonFg)
2018-02-12 11:49:06 +02:00
background transparent
outline none
border solid 1px transparent
border-radius 4px
&:hover
background transparent
2018-09-28 09:56:50 +03:00
border-color var(--primaryAlpha03)
2018-02-12 11:49:06 +02:00
&:active
2018-09-26 14:19:35 +03:00
color var(--primaryAlpha06)
2018-09-28 09:56:50 +03:00
background linear-gradient(to bottom, var(--desktopPostFormTransparentButtonActiveGradientStart) 0%, var(--desktopPostFormTransparentButtonActiveGradientEnd) 100%)
2018-09-26 14:19:35 +03:00
border-color var(--primaryAlpha05)
2018-04-29 02:51:17 +03:00
box-shadow 0 2px 4px rgba(#000, 0.15) inset
2018-02-12 11:49:06 +02:00
&:focus
&:after
content ""
pointer-events none
position absolute
top -5px
right -5px
bottom -5px
left -5px
2018-09-26 14:19:35 +03:00
border 2px solid var(--primaryAlpha03)
2018-02-12 11:49:06 +02:00
border-radius 8px
> .dropzone
position absolute
left 0
top 0
width 100%
height 100%
2018-09-26 14:19:35 +03:00
border dashed 2px var(--primaryAlpha05)
2018-02-12 11:49:06 +02:00
pointer-events none
</style>