summaryrefslogtreecommitdiff
path: root/src/web
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-11 18:47:21 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-11 18:47:21 +0900
commitff29e7bb14e2d5f1356134cad5c1e0e60377ea50 (patch)
treee292b77aef6d554d17add0905207c81e159568bf /src/web
parent[Client] Fix bug (diff)
downloadmisskey-ff29e7bb14e2d5f1356134cad5c1e0e60377ea50.tar.gz
misskey-ff29e7bb14e2d5f1356134cad5c1e0e60377ea50.tar.bz2
misskey-ff29e7bb14e2d5f1356134cad5c1e0e60377ea50.zip
#258
Diffstat (limited to 'src/web')
-rw-r--r--src/web/app/common/tags/poll-editor.tag15
-rw-r--r--src/web/app/common/tags/poll.tag6
-rw-r--r--src/web/app/desktop/tags/post-form-window.tag28
-rw-r--r--src/web/app/desktop/tags/post-form.tag28
4 files changed, 49 insertions, 28 deletions
diff --git a/src/web/app/common/tags/poll-editor.tag b/src/web/app/common/tags/poll-editor.tag
index 9d9b28c763..447486ec8e 100644
--- a/src/web/app/common/tags/poll-editor.tag
+++ b/src/web/app/common/tags/poll-editor.tag
@@ -90,27 +90,32 @@
this.oninput = (i, e) => {
this.choices[i] = e.target.value;
- }
+ };
this.add = () => {
this.choices.push('');
this.update();
this.refs.choices.childNodes[this.choices.length - 1].childNodes[0].focus();
- }
+ };
this.remove = (i) => {
this.choices = this.choices.filter((_, _i) => _i != i);
this.update();
- }
+ };
this.destroy = () => {
this.opts.ondestroy();
- }
+ };
this.get = () => {
return {
choices: this.choices.filter(choice => choice != '')
}
- }
+ };
+
+ this.set = data => {
+ if (data.choices.length == 0) return;
+ this.choices = data.choices;
+ };
</script>
</mk-poll-editor>
diff --git a/src/web/app/common/tags/poll.tag b/src/web/app/common/tags/poll.tag
index 6ddaf77595..ce6460bce9 100644
--- a/src/web/app/common/tags/poll.tag
+++ b/src/web/app/common/tags/poll.tag
@@ -78,9 +78,9 @@
this.toggleResult = () => {
this.result = !this.result;
- }
+ };
- this.vote = (id) => {
+ this.vote = id => {
if (this.poll.choices.some(c => c.is_voted)) return;
this.api('posts/polls/vote', {
post_id: this.post.id,
@@ -99,6 +99,6 @@
total: this.total + 1
});
});
- }
+ };
</script>
</mk-poll>
diff --git a/src/web/app/desktop/tags/post-form-window.tag b/src/web/app/desktop/tags/post-form-window.tag
index 4f2ea25389..956e83ac6e 100644
--- a/src/web/app/desktop/tags/post-form-window.tag
+++ b/src/web/app/desktop/tags/post-form-window.tag
@@ -1,13 +1,19 @@
<mk-post-form-window>
- <mk-window ref="window" is-modal={ true } colored={ true }><yield to="header"><span if={ !parent.opts.reply }>新規投稿</span><span if={ parent.opts.reply }>返信</span><span class="files" if={ parent.files.length != 0 }>添付: { parent.files.length }ファイル</span><span class="uploading-files" if={ parent.uploadingFiles.length != 0 }>{ parent.uploadingFiles.length }個のファイルをアップロード中
- <mk-ellipsis></mk-ellipsis></span></yield>
-<yield to="content">
- <div class="ref" if={ parent.opts.reply }>
- <mk-post-preview post={ parent.opts.reply }></mk-post-preview>
- </div>
- <div class="body">
- <mk-post-form ref="form" reply={ parent.opts.reply }></mk-post-form>
- </div></yield>
+ <mk-window ref="window" is-modal={ true } colored={ true }>
+ <yield to="header">
+ <span if={ !parent.opts.reply }>新規投稿</span>
+ <span if={ parent.opts.reply }>返信</span>
+ <span class="files" if={ parent.files.length != 0 }>添付: { parent.files.length }ファイル</span>
+ <span class="uploading-files" if={ parent.uploadingFiles.length != 0 }>{ parent.uploadingFiles.length }個のファイルをアップロード中<mk-ellipsis></mk-ellipsis></span>
+ </yield>
+ <yield to="content">
+ <div class="ref" if={ parent.opts.reply }>
+ <mk-post-preview post={ parent.opts.reply }></mk-post-preview>
+ </div>
+ <div class="body">
+ <mk-post-form ref="form" reply={ parent.opts.reply }></mk-post-form>
+ </div>
+ </yield>
</mk-window>
<style>
:scope
@@ -48,13 +54,13 @@
this.refs.window.refs.form.on('change-uploading-files', files => {
this.update({
- uploadingFiles: files
+ uploadingFiles: files || []
});
});
this.refs.window.refs.form.on('change-files', files => {
this.update({
- files: files
+ files: files || []
});
});
});
diff --git a/src/web/app/desktop/tags/post-form.tag b/src/web/app/desktop/tags/post-form.tag
index 47fd6bf4a8..c4c1214c75 100644
--- a/src/web/app/desktop/tags/post-form.tag
+++ b/src/web/app/desktop/tags/post-form.tag
@@ -4,11 +4,12 @@
<div class="medias { with: poll }" if={ files.length != 0 }>
<ul>
<li each={ files }>
- <div class="img" style="background-image: url({ url + '?thumbnail&size=64' })" title={ name }></div><img class="remove" onclick={ _remove } src="/resources/desktop/remove.png" title="添付取り消し" alt=""/>
+ <div class="img" style="background-image: url({ url + '?thumbnail&size=64' })" title={ name }></div>
+ <img class="remove" onclick={ removeFile } src="/resources/desktop/remove.png" title="添付取り消し" alt=""/>
</li>
<li class="add" if={ files.length < 4 } title="PCからファイルを添付" onclick={ selectFile }><i class="fa fa-plus"></i></li>
</ul>
- <p class="remain">残り{ 4 - files.length }</p>
+ <p class="remain">{ 4 - files.length }/4</p>
</div>
<mk-poll-editor if={ poll } ref="poll" ondestroy={ onPollDestroyed }></mk-poll-editor>
</div>
@@ -334,10 +335,18 @@
this.autocomplete = new this.Autocomplete(this.refs.text);
this.autocomplete.attach();
+ // 書きかけの投稿を復元
let draft = localStorage.getItem('post-draft');
if (draft) {
draft = JSON.parse(draft);
this.refs.text.value = draft.text;
+ this.files = draft.files;
+ if (draft.poll) {
+ this.poll = true;
+ this.update();
+ this.refs.poll.set(draft.poll);
+ }
+ this.trigger('change-files', this.files);
this.update();
}
});
@@ -418,17 +427,18 @@
};
this.addFile = file => {
- file._remove = () => {
- this.files = this.files.filter(x => x.id != file.id);
- this.trigger('change-files', this.files);
- this.update();
- };
-
this.files.push(file);
this.trigger('change-files', this.files);
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;
};
@@ -477,7 +487,7 @@
const context = {
text: this.refs.text.value,
files: this.files,
- poll: this.poll ? this.refs.poll.get() : undefined
+ poll: this.poll && this.refs.poll ? this.refs.poll.get() : undefined
};
localStorage.setItem('post-draft', JSON.stringify(context));