なんかもうめっちゃ変えた

This commit is contained in:
syuilo 2017-11-13 18:05:35 +09:00
parent f8dddc81e2
commit bc9a8283c6
77 changed files with 170 additions and 165 deletions

View file

@ -52,7 +52,7 @@ function attach(el) {
clearTimeout(showTimer);
hideTimer = setTimeout(close, 500);
});
tag = riot.mount(document.body.appendChild(preview), {
tag = (riot as any).mount(document.body.appendChild(preview), {
user: user
})[0];
};

View file

@ -3,7 +3,7 @@ import * as riot from 'riot';
// ミックスインにオプションを渡せないのアレ
// SEE: https://github.com/riot/riot/issues/2434
riot.mixin('widget', {
(riot as any).mixin('widget', {
init: function() {
this.mixin('i');
this.mixin('api');

View file

@ -3,7 +3,7 @@
*/
import * as riot from 'riot';
const route = require('page');
import * as route from 'page';
let page = null;
export default me => {
@ -83,12 +83,12 @@ export default me => {
mount(document.createElement('mk-not-found'));
}
riot.mixin('page', {
(riot as any).mixin('page', {
page: route
});
// EXEC
route();
(route as any)();
};
function mount(content) {

View file

@ -11,7 +11,7 @@ import * as riot from 'riot';
import init from '../init';
import route from './router';
import fuckAdBlock from './scripts/fuck-ad-block';
import getPostSummary from '../../../common/get-post-summary.ts';
import getPostSummary from '../../../common/get-post-summary';
/**
* init
@ -27,11 +27,11 @@ init(async (me, stream) => {
*/
if ('Notification' in window) {
// 許可を得ていなかったらリクエスト
if (Notification.permission == 'default') {
if ((Notification as any).permission == 'default') {
await Notification.requestPermission();
}
if (Notification.permission == 'granted') {
if ((Notification as any).permission == 'granted') {
registerNotifications(stream);
}
}
@ -82,7 +82,7 @@ function registerNotifications(stream) {
});
n.onclick = () => {
n.close();
riot.mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), {
(riot as any).mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), {
user: message.user
});
};

View file

@ -1,10 +1,12 @@
const getCaretCoordinates = require('textarea-caret');
import getCaretCoordinates = require('textarea-caret');
import * as riot from 'riot';
/**
*
*/
class Autocomplete {
private suggestion: any;
private textarea: any;
/**
*
@ -23,22 +25,22 @@ class Autocomplete {
/**
*
*/
attach() {
public attach() {
this.textarea.addEventListener('input', this.onInput);
}
/**
*
*/
detach() {
public detach() {
this.textarea.removeEventListener('input', this.onInput);
this.close();
}
/**
* [Private]
*
*/
onInput() {
private onInput() {
this.close();
const caret = this.textarea.selectionStart;
@ -56,9 +58,9 @@ class Autocomplete {
}
/**
* [Private]
*
*/
open(type, q) {
private open(type, q) {
// 既に開いているサジェストは閉じる
this.close();
@ -81,7 +83,7 @@ class Autocomplete {
const el = document.body.appendChild(tag);
// マウント
this.suggestion = riot.mount(el, {
this.suggestion = (riot as any).mount(el, {
textarea: this.textarea,
complete: this.complete,
close: this.close,
@ -91,9 +93,9 @@ class Autocomplete {
}
/**
* [Private]
*
*/
close() {
private close() {
if (this.suggestion == null) return;
this.suggestion.unmount();
@ -103,9 +105,9 @@ class Autocomplete {
}
/**
* [Private]
*
*/
complete(user) {
private complete(user) {
this.close();
const value = user.username;

View file

@ -1,9 +1,9 @@
import * as riot from 'riot';
export default (title, text, buttons, canThrough, onThrough) => {
export default (title, text, buttons, canThrough?, onThrough?) => {
const dialog = document.body.appendChild(document.createElement('mk-dialog'));
const controller = riot.observable();
riot.mount(dialog, {
(riot as any).mount(dialog, {
controller: controller,
title: title,
text: text,

View file

@ -1,6 +1,8 @@
require('fuckadblock');
import dialog from './dialog';
declare var fuckAdBlock: any;
export default () => {
if (fuckAdBlock === undefined) {
adBlockDetected();

View file

@ -2,7 +2,7 @@ import * as riot from 'riot';
export default (title, placeholder, defaultValue, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, {
return (riot as any).mount(dialog, {
title: title,
placeholder: placeholder,
'default': defaultValue,

View file

@ -2,7 +2,7 @@ import * as riot from 'riot';
export default message => {
const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
riot.mount(notification, {
(riot as any).mount(notification, {
message: message
});
};

View file

@ -2,7 +2,7 @@ import * as riot from 'riot';
export default (title, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, {
return (riot as any).mount(dialog, {
title: title,
type: 'password',
onOk: onOk,

View file

@ -5,7 +5,7 @@ import api from '../../common/scripts/api';
export default (I, cb, file = null) => {
const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), {
const cropper = (riot as any).mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file,
title: 'アバターとして表示する部分を選択',
aspectRatio: 1 / 1
@ -37,7 +37,7 @@ export default (I, cb, file = null) => {
};
const upload = (data, folder) => {
const progress = riot.mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
const progress = (riot as any).mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
title: '新しいアバターをアップロードしています'
})[0];
@ -46,7 +46,7 @@ export default (I, cb, file = null) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true);
xhr.onload = e => {
const file = JSON.parse(e.target.response);
const file = JSON.parse((e.target as any).response);
progress.close();
set(file);
};
@ -75,7 +75,7 @@ export default (I, cb, file = null) => {
if (file) {
fileSelected(file);
} else {
const browser = riot.mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
const browser = (riot as any).mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
multiple: false,
title: '<i class="fa fa-picture-o"></i>アバターにする画像を選択'
})[0];

View file

@ -5,7 +5,7 @@ import api from '../../common/scripts/api';
export default (I, cb, file = null) => {
const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), {
const cropper = (riot as any).mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file,
title: 'バナーとして表示する部分を選択',
aspectRatio: 16 / 9
@ -37,7 +37,7 @@ export default (I, cb, file = null) => {
};
const upload = (data, folder) => {
const progress = riot.mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
const progress = (riot as any).mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
title: '新しいバナーをアップロードしています'
})[0];
@ -46,7 +46,7 @@ export default (I, cb, file = null) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true);
xhr.onload = e => {
const file = JSON.parse(e.target.response);
const file = JSON.parse((e.target as any).response);
progress.close();
set(file);
};
@ -75,7 +75,7 @@ export default (I, cb, file = null) => {
if (file) {
fileSelected(file);
} else {
const browser = riot.mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
const browser = (riot as any).mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
multiple: false,
title: '<i class="fa fa-picture-o"></i>バナーにする画像を選択'
})[0];

View file

@ -177,7 +177,7 @@
};
this.applySelect = () => {
this.refs.users.children.forEach(el => {
Array.from(this.refs.users.children).forEach(el => {
el.removeAttribute('data-selected');
});

View file

@ -408,7 +408,7 @@
// ドロップされてきたものがファイルだったら
if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(file => {
Array.from(e.dataTransfer.files).forEach(file => {
this.upload(file, this.folder);
});
return false;
@ -510,7 +510,7 @@
};
this.changeFileInput = () => {
this.refs.fileInput.files.forEach(file => {
Array.from(this.refs.fileInput.files).forEach(file => {
this.upload(file, this.folder);
});
};

View file

@ -109,7 +109,7 @@
// ファイルだったら
if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(file => {
Array.from(e.dataTransfer.files).forEach(file => {
this.browser.upload(file, this.folder);
});
return false;

View file

@ -55,7 +55,7 @@
// ファイルだったら
if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(file => {
Array.from(e.dataTransfer.files).forEach(file => {
this.browser.upload(file, this.folder);
});
return false;

View file

@ -129,7 +129,7 @@
this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => {
Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);
});
}

View file

@ -273,7 +273,7 @@
this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => {
Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);
});

View file

@ -405,7 +405,7 @@
// ファイルだったら
if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(this.upload);
Array.from(e.dataTransfer.files).forEach(this.upload);
}
};
@ -414,7 +414,7 @@
};
this.onpaste = e => {
e.clipboardData.items.forEach(item => {
Array.from(e.clipboardData.items).forEach(item => {
if (item.kind == 'file') {
this.upload(item.getAsFile());
}
@ -435,7 +435,7 @@
};
this.changeFile = () => {
this.refs.file.files.forEach(this.upload);
Array.from(this.refs.file.files).forEach(this.upload);
};
this.upload = file => {

View file

@ -45,7 +45,7 @@
const tokens = this.post.ast;
this.refs.text.innerHTML = compile(tokens, false);
this.refs.text.children.forEach(e => {
Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);
});
}

View file

@ -498,7 +498,7 @@
this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', compile(tokens));
this.refs.text.children.forEach(e => {
Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e);
});