This commit is contained in:
syuilo
2017-02-20 10:34:57 +09:00
parent 7791431717
commit 91d8ee5a52
101 changed files with 423 additions and 423 deletions

View File

@ -57,7 +57,7 @@
</style>
<script>
retry() {
this.retry = () => {
this.unmount();
this.opts.retry();
}

View File

@ -119,7 +119,7 @@
<script>
this.mixin('api');
onpaste(e) {
this.onpaste = (e) => {
const data = e.clipboardData;
const items = data.items;
for (let i = 0; i < items.length; i++) {
@ -130,17 +130,17 @@
}
}
onkeypress(e) {
this.onkeypress = (e) => {
if ((e.which == 10 || e.which == 13) && e.ctrlKey) {
this.send();
}
}
selectFile() {
this.selectFile = () => {
this.refs.file.click();
}
selectFileFromDrive() {
this.selectFileFromDrive = () => {
const browser = document.body.appendChild(document.createElement('mk-select-file-from-drive-window'));
const event = riot.observable();
riot.mount(browser, {
@ -152,7 +152,7 @@
});
}
send() {
this.send = () => {
this.sending = true;
this.api('messaging/messages/create', {
user_id: this.opts.user.id,
@ -166,7 +166,7 @@
this.update();
});
clear() {
this.clear = () => {
this.refs.text.value = '';
this.files = [];
this.update();

View File

@ -305,7 +305,7 @@
});
}
search() {
this.search = () => {
const q = this.refs.search.value;
if (q == '') {
this.searchResult = [];
@ -323,7 +323,7 @@
.catch (err) =>
console.error err
on-search-keydown(e) {
this.on-search-keydown = (e) => {
key = e.which
switch (key)
| 9, 40 => // Key[TAB] or Key[↓]
@ -331,7 +331,7 @@
e.stopPropagation();
this.refs.search-result.childNodes[0].focus();
on-search-result-keydown(i, e) {
this.on-search-result-keydown = (i, e) => {
key = e.which
switch (key)
| 10, 13 => // Key[ENTER]

View File

@ -128,18 +128,18 @@
this.mixin('api');
this.mixin('messaging-stream');
this.user = this.opts.user
this.init = true
this.sending = false
this.messages = []
this.user = this.opts.user;
this.init = true;
this.sending = false;
this.messages = [];
this.connection = new @MessagingStreamConnection this.I, @user.id
this.connection = new this.MessagingStreamConnection(this.I, this.user.id);
this.on('mount', () => {
@connection.event.on 'message' this.on-message
@connection.event.on 'read' this.on-read
this.connection.event.on('message' this.onMessage);
this.connection.event.on('read' this.onRead);
document.add-event-listener 'visibilitychange' this.on-visibilitychange
document.addEventListener 'visibilitychange' this.on-visibilitychange
this.api 'messaging/messages' do
user_id: @user.id
@ -156,7 +156,7 @@
@connection.event.off 'read' this.on-read
@connection.close!
document.remove-event-listener 'visibilitychange' this.on-visibilitychange
document.removeEventListener 'visibilitychange' this.on-visibilitychange
this.on('update', () => {
@messages.for-each (message) =>
@ -165,7 +165,7 @@
message._date = date
message._datetext = month + '月 ' + date + '日'
on-message(message) {
this.on-message = (message) => {
is-bottom = @is-bottom!
@messages.push message
@ -182,7 +182,7 @@
// Notify
@notify '新しいメッセージがあります'
on-read(ids) {
this.on-read = (ids) => {
if not Array.isArray ids then ids = [ids]
ids.for-each (id) =>
if (@messages.some (x) => x.id == id)
@ -190,15 +190,15 @@
@messages[exist].is_read = true
this.update();
is-bottom() {
this.is-bottom = () => {
current = this.root.scroll-top + this.root.offset-height
max = this.root.scroll-height
current > (max - 32)
scroll-to-bottom() {
this.scroll-to-bottom = () => {
this.root.scroll-top = this.root.scroll-height
notify(message) {
this.notify = (message) => {
n = document.createElement 'p'
n.inner-HTML = '<i class="fa fa-arrow-circle-down"></i>' + message
n.onclick = =>
@ -213,7 +213,7 @@
, 1000ms
, 4000ms
on-visibilitychange() {
this.on-visibilitychange = () => {
if document.hidden then return
@messages.for-each (message) =>
if message.user_id != this.I.id and not message.is_read

View File

@ -88,26 +88,26 @@
<script>
this.choices = ['', ''];
oninput(i, e) {
this.oninput = (i, e) => {
this.choices[i] = e.target.value;
}
add() {
this.add = () => {
this.choices.push('');
this.update();
this.refs.choices.childNodes[this.choices.length - 1].childNodes[0].focus();
}
remove(i) {
this.remove = (i) => {
this.choices = this.choices.filter((_, _i) => _i != i);
this.update();
}
destroy() {
this.destroy = () => {
this.opts.ondestroy();
}
get() {
this.get = () => {
return {
choices: this.choices.filter(choice => choice != '')
}

View File

@ -76,11 +76,11 @@
this.isVoted = this.poll.choices.some(c => c.is_voted);
this.result = this.isVoted;
toggleResult() {
this.toggleResult = () => {
this.result = !this.result;
}
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,

View File

@ -68,7 +68,7 @@
this.on('unmount', () => {
@stream.off 'signin' this.on-signin
on-signin(signin) {
this.on-signin = (signin) => {
@history.unshift signin
this.update();
</script>

View File

@ -102,7 +102,7 @@
this.user = null;
this.signing = false;
oninput() {
this.oninput = () => {
this.api 'users/show' do
username: this.refs.username.value
.then (user) =>
@ -110,7 +110,7 @@
this.trigger 'user' user
this.update();
onsubmit(e) {
this.onsubmit = (e) => {
e.preventDefault();
if this.refs.username.value == ''

View File

@ -199,7 +199,7 @@
head.appendChild script
});
on-change-username() {
this.on-change-username = () => {
username = this.refs.username.value
if username == ''
@ -232,7 +232,7 @@
this.username-state = 'error'
this.update();
on-change-password() {
this.on-change-password = () => {
password = this.refs.password.value
if password == ''
@ -252,7 +252,7 @@
this.refs.password-metar.style.width = (strength * 100) + '%'
on-change-password-retype() {
this.on-change-password-retype = () => {
password = this.refs.password.value
retyped-password = this.refs.password-retype.value
@ -265,7 +265,7 @@
else
this.password-retype-state = 'not-match'
onsubmit(e) {
this.onsubmit = (e) => {
e.preventDefault();
username = this.refs.username.value

View File

@ -22,7 +22,7 @@
if @mode == 'relative' or @mode == 'detail'
clear-interval @tickid
tick() {
this.tick = () => {
now = new Date!
ago = (now - @time) / 1000ms
this.relative = switch

View File

@ -145,7 +145,7 @@
this.uploads = []
upload(file, folder) {
this.upload = (file, folder) => {
id = Math.random!
ctx =