なんかもうめっちゃ変えた
This commit is contained in:
parent
f8dddc81e2
commit
bc9a8283c6
77 changed files with 170 additions and 165 deletions
|
|
@ -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;
|
||||
|
|
@ -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,
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
require('fuckadblock');
|
||||
import dialog from './dialog';
|
||||
|
||||
declare var fuckAdBlock: any;
|
||||
|
||||
export default () => {
|
||||
if (fuckAdBlock === undefined) {
|
||||
adBlockDetected();
|
||||
|
|
@ -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,
|
||||
|
|
@ -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
|
||||
});
|
||||
};
|
||||
|
|
@ -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,
|
||||
|
|
@ -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];
|
||||
|
|
@ -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];
|
||||
Loading…
Add table
Add a link
Reference in a new issue