2018-02-19 21:13:27 +00:00
|
|
|
<template>
|
|
|
|
<div class="mkw-post-form">
|
2018-02-21 16:08:49 +00:00
|
|
|
<template v-if="props.design == 0">
|
2018-04-14 16:04:40 +00:00
|
|
|
<p class="title">%fa:pencil-alt%%i18n:@title%</p>
|
2018-02-19 21:13:27 +00:00
|
|
|
</template>
|
2018-05-28 16:44:15 +00:00
|
|
|
<textarea :disabled="posting" v-model="text" @keydown="onKeydown" :placeholder="placeholder"></textarea>
|
2018-04-14 16:04:40 +00:00
|
|
|
<button @click="post" :disabled="posting">%i18n:@note%</button>
|
2018-02-19 21:13:27 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2018-02-24 15:18:09 +00:00
|
|
|
import define from '../../../common/define-widget';
|
2018-02-19 21:13:27 +00:00
|
|
|
export default define({
|
|
|
|
name: 'post-form',
|
2018-02-21 06:30:03 +00:00
|
|
|
props: () => ({
|
2018-02-19 21:13:27 +00:00
|
|
|
design: 0
|
2018-02-21 06:30:03 +00:00
|
|
|
})
|
2018-02-19 21:13:27 +00:00
|
|
|
}).extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
posting: false,
|
|
|
|
text: ''
|
|
|
|
};
|
|
|
|
},
|
2018-05-28 16:44:15 +00:00
|
|
|
computed: {
|
|
|
|
placeholder(): string {
|
2018-05-28 17:00:45 +00:00
|
|
|
const xs = [
|
2018-05-28 16:44:15 +00:00
|
|
|
'%i18n:common.note-placeholders.a%',
|
|
|
|
'%i18n:common.note-placeholders.b%',
|
|
|
|
'%i18n:common.note-placeholders.c%',
|
|
|
|
'%i18n:common.note-placeholders.d%',
|
2018-05-28 17:00:45 +00:00
|
|
|
'%i18n:common.note-placeholders.e%',
|
|
|
|
'%i18n:common.note-placeholders.f%'
|
|
|
|
];
|
|
|
|
return xs[Math.floor(Math.random() * xs.length)];
|
2018-05-28 16:44:15 +00:00
|
|
|
}
|
|
|
|
},
|
2018-02-19 21:13:27 +00:00
|
|
|
methods: {
|
|
|
|
func() {
|
|
|
|
if (this.props.design == 1) {
|
|
|
|
this.props.design = 0;
|
|
|
|
} else {
|
|
|
|
this.props.design++;
|
|
|
|
}
|
2018-04-29 08:17:15 +00:00
|
|
|
this.save();
|
2018-02-19 21:13:27 +00:00
|
|
|
},
|
|
|
|
onKeydown(e) {
|
|
|
|
if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey)) this.post();
|
|
|
|
},
|
|
|
|
post() {
|
|
|
|
this.posting = true;
|
|
|
|
|
2018-04-07 17:30:37 +00:00
|
|
|
(this as any).api('notes/create', {
|
2018-02-19 21:13:27 +00:00
|
|
|
text: this.text
|
|
|
|
}).then(data => {
|
|
|
|
this.clear();
|
|
|
|
}).catch(err => {
|
|
|
|
alert('失敗した');
|
|
|
|
}).then(() => {
|
|
|
|
this.posting = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
clear() {
|
|
|
|
this.text = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-03-03 04:47:55 +00:00
|
|
|
@import '~const.styl'
|
|
|
|
|
2018-02-19 21:13:27 +00:00
|
|
|
.mkw-post-form
|
|
|
|
background #fff
|
|
|
|
overflow hidden
|
2018-04-28 23:51:17 +00:00
|
|
|
border solid 1px rgba(#000, 0.075)
|
2018-02-19 21:13:27 +00:00
|
|
|
border-radius 6px
|
|
|
|
|
|
|
|
> .title
|
|
|
|
z-index 1
|
|
|
|
margin 0
|
|
|
|
padding 0 16px
|
|
|
|
line-height 42px
|
|
|
|
font-size 0.9em
|
|
|
|
font-weight bold
|
|
|
|
color #888
|
2018-04-28 23:51:17 +00:00
|
|
|
box-shadow 0 1px rgba(#000, 0.07)
|
2018-02-19 21:13:27 +00:00
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
> textarea
|
|
|
|
display block
|
|
|
|
width 100%
|
|
|
|
max-width 100%
|
|
|
|
min-width 100%
|
|
|
|
padding 16px
|
|
|
|
margin-bottom 28px + 16px
|
|
|
|
border none
|
|
|
|
border-bottom solid 1px #eee
|
|
|
|
|
|
|
|
> button
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
bottom 8px
|
|
|
|
right 8px
|
|
|
|
margin 0
|
|
|
|
padding 0 10px
|
|
|
|
height 28px
|
|
|
|
color $theme-color-foreground
|
|
|
|
background $theme-color !important
|
|
|
|
outline none
|
|
|
|
border none
|
|
|
|
border-radius 4px
|
|
|
|
transition background 0.1s ease
|
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
background lighten($theme-color, 10%) !important
|
|
|
|
|
|
|
|
&:active
|
|
|
|
background darken($theme-color, 10%) !important
|
|
|
|
transition background 0s ease
|
|
|
|
|
|
|
|
</style>
|