mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-16 12:05:26 +02:00
wip
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
import * as riot from 'riot';
|
||||
|
||||
export default (title, text, buttons, canThrough?, onThrough?) => {
|
||||
const dialog = document.body.appendChild(document.createElement('mk-dialog'));
|
||||
const controller = riot.observable();
|
||||
(riot as any).mount(dialog, {
|
||||
controller: controller,
|
||||
title: title,
|
||||
text: text,
|
||||
buttons: buttons,
|
||||
canThrough: canThrough,
|
||||
onThrough: onThrough
|
||||
});
|
||||
controller.trigger('open');
|
||||
return controller;
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
require('fuckadblock');
|
||||
import dialog from './dialog';
|
||||
|
||||
declare const fuckAdBlock: any;
|
||||
|
||||
export default () => {
|
||||
if (fuckAdBlock === undefined) {
|
||||
adBlockDetected();
|
||||
} else {
|
||||
fuckAdBlock.onDetected(adBlockDetected);
|
||||
}
|
||||
};
|
||||
|
||||
function adBlockDetected() {
|
||||
dialog('%fa:exclamation-triangle%広告ブロッカーを無効にしてください',
|
||||
'<strong>Misskeyは広告を掲載していません</strong>が、広告をブロックする機能が有効だと一部の機能が利用できなかったり、不具合が発生する場合があります。',
|
||||
[{
|
||||
text: 'OK'
|
||||
}]);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import * as riot from 'riot';
|
||||
|
||||
export default (title, placeholder, defaultValue, onOk, onCancel) => {
|
||||
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
|
||||
return (riot as any).mount(dialog, {
|
||||
title: title,
|
||||
placeholder: placeholder,
|
||||
'default': defaultValue,
|
||||
onOk: onOk,
|
||||
onCancel: onCancel
|
||||
});
|
||||
};
|
||||
@@ -1,8 +0,0 @@
|
||||
import dialog from './dialog';
|
||||
|
||||
export default () => {
|
||||
dialog('%fa:exclamation-triangle%Not implemented yet',
|
||||
'要求された操作は実装されていません。<br>→<a href="https://github.com/syuilo/misskey" target="_blank">Misskeyの開発に参加する</a>', [{
|
||||
text: 'OK'
|
||||
}]);
|
||||
};
|
||||
@@ -1,8 +0,0 @@
|
||||
import * as riot from 'riot';
|
||||
|
||||
export default message => {
|
||||
const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
|
||||
(riot as any).mount(notification, {
|
||||
message: message
|
||||
});
|
||||
};
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* 要素をスクロールに追従させる
|
||||
*/
|
||||
export default class ScrollFollower {
|
||||
private follower: Element;
|
||||
private containerTop: number;
|
||||
private topPadding: number;
|
||||
|
||||
constructor(follower: Element, topPadding: number) {
|
||||
//#region
|
||||
this.follow = this.follow.bind(this);
|
||||
//#endregion
|
||||
|
||||
this.follower = follower;
|
||||
this.containerTop = follower.getBoundingClientRect().top;
|
||||
this.topPadding = topPadding;
|
||||
|
||||
window.addEventListener('scroll', this.follow);
|
||||
window.addEventListener('resize', this.follow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 追従解除
|
||||
*/
|
||||
public dispose() {
|
||||
window.removeEventListener('scroll', this.follow);
|
||||
window.removeEventListener('resize', this.follow);
|
||||
}
|
||||
|
||||
private follow() {
|
||||
const windowBottom = window.scrollY + window.innerHeight;
|
||||
const windowTop = window.scrollY + this.topPadding;
|
||||
|
||||
const rect = this.follower.getBoundingClientRect();
|
||||
const followerBottom = (rect.top + window.scrollY) + rect.height;
|
||||
const screenHeight = window.innerHeight - this.topPadding;
|
||||
|
||||
// スクロールの上部(+余白)がフォロワーコンテナの上部よりも上方にある
|
||||
if (window.scrollY + this.topPadding < this.containerTop) {
|
||||
// フォロワーをコンテナの最上部に合わせる
|
||||
(this.follower.parentNode as any).style.marginTop = '0px';
|
||||
return;
|
||||
}
|
||||
|
||||
// スクロールの下部がフォロワーの下部よりも下方にある かつ 表示領域の縦幅がフォロワーの縦幅よりも狭い
|
||||
if (windowBottom > followerBottom && rect.height > screenHeight) {
|
||||
// フォロワーの下部をスクロール下部に合わせる
|
||||
const top = (windowBottom - rect.height) - this.containerTop;
|
||||
(this.follower.parentNode as any).style.marginTop = `${top}px`;
|
||||
return;
|
||||
}
|
||||
|
||||
// スクロールの上部(+余白)がフォロワーの上部よりも上方にある または 表示領域の縦幅がフォロワーの縦幅よりも広い
|
||||
if (windowTop < rect.top + window.scrollY || rect.height < screenHeight) {
|
||||
// フォロワーの上部をスクロール上部(+余白)に合わせる
|
||||
const top = windowTop - this.containerTop;
|
||||
(this.follower.parentNode as any).style.marginTop = `${top}px`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
declare const _API_URL_: string;
|
||||
|
||||
import * as riot from 'riot';
|
||||
import dialog from './dialog';
|
||||
import api from '../../common/scripts/api';
|
||||
|
||||
export default (I, cb, file = null) => {
|
||||
const fileSelected = file => {
|
||||
const cropper = (riot as any).mount(document.body.appendChild(document.createElement('mk-crop-window')), {
|
||||
file: file,
|
||||
title: 'アバターとして表示する部分を選択',
|
||||
aspectRatio: 1 / 1
|
||||
})[0];
|
||||
|
||||
cropper.on('cropped', blob => {
|
||||
const data = new FormData();
|
||||
data.append('i', I.token);
|
||||
data.append('file', blob, file.name + '.cropped.png');
|
||||
|
||||
api(I, 'drive/folders/find', {
|
||||
name: 'アイコン'
|
||||
}).then(iconFolder => {
|
||||
if (iconFolder.length === 0) {
|
||||
api(I, 'drive/folders/create', {
|
||||
name: 'アイコン'
|
||||
}).then(iconFolder => {
|
||||
upload(data, iconFolder);
|
||||
});
|
||||
} else {
|
||||
upload(data, iconFolder[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
cropper.on('skipped', () => {
|
||||
set(file);
|
||||
});
|
||||
};
|
||||
|
||||
const upload = (data, folder) => {
|
||||
const progress = (riot as any).mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
|
||||
title: '新しいアバターをアップロードしています'
|
||||
})[0];
|
||||
|
||||
if (folder) data.append('folder_id', folder.id);
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', _API_URL_ + '/drive/files/create', true);
|
||||
xhr.onload = e => {
|
||||
const file = JSON.parse((e.target as any).response);
|
||||
progress.close();
|
||||
set(file);
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = e => {
|
||||
if (e.lengthComputable) progress.updateProgress(e.loaded, e.total);
|
||||
};
|
||||
|
||||
xhr.send(data);
|
||||
};
|
||||
|
||||
const set = file => {
|
||||
api(I, 'i/update', {
|
||||
avatar_id: file.id
|
||||
}).then(i => {
|
||||
dialog('%fa:info-circle%アバターを更新しました',
|
||||
'新しいアバターが反映されるまで時間がかかる場合があります。',
|
||||
[{
|
||||
text: 'わかった'
|
||||
}]);
|
||||
|
||||
if (cb) cb(i);
|
||||
});
|
||||
};
|
||||
|
||||
if (file) {
|
||||
fileSelected(file);
|
||||
} else {
|
||||
const browser = (riot as any).mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
|
||||
multiple: false,
|
||||
title: '%fa:image%アバターにする画像を選択'
|
||||
})[0];
|
||||
|
||||
browser.one('selected', file => {
|
||||
fileSelected(file);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,88 +0,0 @@
|
||||
declare const _API_URL_: string;
|
||||
|
||||
import * as riot from 'riot';
|
||||
import dialog from './dialog';
|
||||
import api from '../../common/scripts/api';
|
||||
|
||||
export default (I, cb, file = null) => {
|
||||
const fileSelected = file => {
|
||||
const cropper = (riot as any).mount(document.body.appendChild(document.createElement('mk-crop-window')), {
|
||||
file: file,
|
||||
title: 'バナーとして表示する部分を選択',
|
||||
aspectRatio: 16 / 9
|
||||
})[0];
|
||||
|
||||
cropper.on('cropped', blob => {
|
||||
const data = new FormData();
|
||||
data.append('i', I.token);
|
||||
data.append('file', blob, file.name + '.cropped.png');
|
||||
|
||||
api(I, 'drive/folders/find', {
|
||||
name: 'バナー'
|
||||
}).then(iconFolder => {
|
||||
if (iconFolder.length === 0) {
|
||||
api(I, 'drive/folders/create', {
|
||||
name: 'バナー'
|
||||
}).then(iconFolder => {
|
||||
upload(data, iconFolder);
|
||||
});
|
||||
} else {
|
||||
upload(data, iconFolder[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
cropper.on('skipped', () => {
|
||||
set(file);
|
||||
});
|
||||
};
|
||||
|
||||
const upload = (data, folder) => {
|
||||
const progress = (riot as any).mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
|
||||
title: '新しいバナーをアップロードしています'
|
||||
})[0];
|
||||
|
||||
if (folder) data.append('folder_id', folder.id);
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', _API_URL_ + '/drive/files/create', true);
|
||||
xhr.onload = e => {
|
||||
const file = JSON.parse((e.target as any).response);
|
||||
progress.close();
|
||||
set(file);
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = e => {
|
||||
if (e.lengthComputable) progress.updateProgress(e.loaded, e.total);
|
||||
};
|
||||
|
||||
xhr.send(data);
|
||||
};
|
||||
|
||||
const set = file => {
|
||||
api(I, 'i/update', {
|
||||
banner_id: file.id
|
||||
}).then(i => {
|
||||
dialog('%fa:info-circle%バナーを更新しました',
|
||||
'新しいバナーが反映されるまで時間がかかる場合があります。',
|
||||
[{
|
||||
text: 'わかりました。'
|
||||
}]);
|
||||
|
||||
if (cb) cb(i);
|
||||
});
|
||||
};
|
||||
|
||||
if (file) {
|
||||
fileSelected(file);
|
||||
} else {
|
||||
const browser = (riot as any).mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
|
||||
multiple: false,
|
||||
title: '%fa:image%バナーにする画像を選択'
|
||||
})[0];
|
||||
|
||||
browser.one('selected', file => {
|
||||
fileSelected(file);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user