summaryrefslogtreecommitdiff
path: root/src/web/app/mobile
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-12-11 03:25:58 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-12-11 03:25:58 +0900
commitf849dcb7b91233eaad9b679feef512bb4ad1dcd5 (patch)
tree993a6ba8da066732101aba2b5d42a49a000d614f /src/web/app/mobile
parent#984 (diff)
downloadsharkey-f849dcb7b91233eaad9b679feef512bb4ad1dcd5.tar.gz
sharkey-f849dcb7b91233eaad9b679feef512bb4ad1dcd5.tar.bz2
sharkey-f849dcb7b91233eaad9b679feef512bb4ad1dcd5.zip
#983
Diffstat (limited to 'src/web/app/mobile')
-rw-r--r--src/web/app/mobile/tags/post-form.tag76
1 files changed, 30 insertions, 46 deletions
diff --git a/src/web/app/mobile/tags/post-form.tag b/src/web/app/mobile/tags/post-form.tag
index 3ac7296f73..f09f40bb5c 100644
--- a/src/web/app/mobile/tags/post-form.tag
+++ b/src/web/app/mobile/tags/post-form.tag
@@ -9,12 +9,11 @@
<div class="form">
<mk-post-preview if={ opts.reply } post={ opts.reply }/>
<textarea ref="text" disabled={ wait } oninput={ update } onkeydown={ onkeydown } onpaste={ onpaste } placeholder={ opts.reply ? '%i18n:mobile.tags.mk-post-form.reply-placeholder%' : '%i18n:mobile.tags.mk-post-form.post-placeholder%' }></textarea>
- <div class="attaches" if={ files.length != 0 }>
+ <div class="attaches" show={ files.length != 0 }>
<ul class="files" ref="attaches">
- <li class="file" each={ files }>
- <div class="img" style="background-image: url({ url + '?thumbnail&size=64' })" title={ name }></div>
+ <li class="file" each={ files } data-id={ id }>
+ <div class="img" style="background-image: url({ url + '?thumbnail&size=64' })" title={ name } onclick={ removeFile }></div>
</li>
- <li class="add" if={ files.length < 4 } title="%i18n:mobile.tags.mk-post-form.attach-media-from-local%" onclick={ selectFile }>%fa:plus%</li>
</ul>
</div>
<mk-poll-editor if={ poll } ref="poll" ondestroy={ onPollDestroyed }/>
@@ -93,12 +92,9 @@
> .file
display block
float left
- margin 4px
+ margin 0
padding 0
- cursor move
-
- &:hover > .remove
- display block
+ border solid 4px transparent
> .img
width 64px
@@ -106,38 +102,6 @@
background-size cover
background-position center center
- > .remove
- display none
- position absolute
- top -6px
- right -6px
- width 16px
- height 16px
- cursor pointer
-
- > .add
- display block
- float left
- margin 4px
- padding 0
- border dashed 2px rgba($theme-color, 0.2)
- cursor pointer
-
- &:hover
- border-color rgba($theme-color, 0.3)
-
- > [data-fa]
- color rgba($theme-color, 0.4)
-
- > [data-fa]
- display block
- width 60px
- height 60px
- line-height 60px
- text-align center
- font-size 1.2em
- color rgba($theme-color, 0.2)
-
> mk-uploader
margin 8px 0 0 0
padding 8px
@@ -181,6 +145,7 @@
</style>
<script>
+ import Sortable from 'sortablejs';
import getKao from '../../common/scripts/get-kao';
this.mixin('api');
@@ -200,6 +165,10 @@
});
this.refs.text.focus();
+
+ new Sortable(this.refs.attaches, {
+ animation: 150
+ });
});
this.onkeydown = e => {
@@ -247,6 +216,13 @@
this.update();
};
+ this.removeFile = e => {
+ const file = e.item;
+ this.files = this.files.filter(x => x.id != file.id);
+ this.trigger('change-files', this.files);
+ this.update();
+ };
+
this.addPoll = () => {
this.poll = true;
};
@@ -258,15 +234,23 @@
};
this.post = () => {
- this.wait = true;
+ this.update({
+ wait: true
+ });
- const files = this.files && this.files.length > 0
- ? this.files.map(f => f.id)
- : undefined;
+ const files = [];
+
+ if (this.files.length > 0) {
+ Array.from(this.refs.attaches.children).forEach(el => {
+ const id = el.getAttribute('data-id');
+ const file = this.files.find(f => f.id == id);
+ files.push(file);
+ });
+ }
this.api('posts/create', {
text: this.refs.text.value == '' ? undefined : this.refs.text.value,
- media_ids: files,
+ media_ids: this.files.length > 0 ? files.map(f => f.id) : undefined,
reply_id: opts.reply ? opts.reply.id : undefined,
poll: this.poll ? this.refs.poll.get() : undefined
}).then(data => {