Closes #12, #227 and #58
This commit is contained in:
syuilo 2017-03-18 20:05:11 +09:00
parent 2496cece91
commit 45e8331e26
150 changed files with 610 additions and 609 deletions

View file

@ -1,5 +1,5 @@
const getCaretCoordinates = require('textarea-caret');
const riot = require('riot');
import * as riot from 'riot';
/**
* オートコンプリートを管理するクラス
@ -127,4 +127,4 @@ class Autocomplete {
}
}
module.exports = Autocomplete;
export default Autocomplete;

View file

@ -1,6 +1,6 @@
const riot = require('riot');
import * as riot from 'riot';
module.exports = (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, {

View file

@ -1,7 +1,7 @@
require('fuckadblock');
const dialog = require('./dialog');
module.exports = () => {
export default () => {
if (fuckAdBlock === undefined) {
adBlockDetected();
} else {

View file

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

View file

@ -0,0 +1,8 @@
import dialog from './dialog';
export default () => {
dialog('<i class="fa fa-exclamation-triangle"></i>Not implemented yet',
'要求された操作は実装されていません。<br>→<a href="https://github.com/syuilo/misskey" target="_blank">Misskeyの開発に参加する</a>', [{
text: 'OK'
}]);
};

View file

@ -1,6 +1,6 @@
const riot = require('riot');
import * as riot from 'riot';
module.exports = message => {
export default message => {
const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
riot.mount(notification, {
message: message

View file

@ -1,6 +1,5 @@
const stream = require('../../common/scripts/stream');
const getPostSummary = require('../../common/scripts/get-post-summary');
const riot = require('riot');
module.exports = me => {
const s = stream(me);
@ -37,9 +36,5 @@ module.exports = me => {
setTimeout(n.close.bind(n), 6000);
});
riot.mixin('stream', {
stream: s.event,
getStreamState: s.getState,
streamStateEv: s.stateEv
});
return s;
};

View file

@ -1,9 +1,9 @@
const riot = require('riot');
const CONFIG = require('../../common/scripts/config');
const dialog = require('./dialog');
const api = require('../../common/scripts/api');
import * as riot from 'riot';
import CONFIG from '../../common/scripts/config';
import dialog from './dialog';
import api from '../../common/scripts/api';
module.exports = (I, cb, file = null) => {
export default (I, cb, file = null) => {
const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file,

View file

@ -1,9 +1,9 @@
const riot = require('riot');
const CONFIG = require('../../common/scripts/config');
const dialog = require('./dialog');
const api = require('../../common/scripts/api');
import * as riot from 'riot';
import CONFIG from '../../common/scripts/config';
import dialog from './dialog';
import api from '../../common/scripts/api';
module.exports = (I, cb, file = null) => {
export default (I, cb, file = null) => {
const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file,

View file

@ -1,66 +0,0 @@
const riot = require('riot');
riot.mixin('user-preview', {
init: function() {
const scan = () => {
this.root.querySelectorAll('[data-user-preview]:not([data-user-preview-attached])')
.forEach(attach.bind(this));
};
this.on('mount', scan);
this.on('updated', scan);
}
});
function attach(el) {
el.setAttribute('data-user-preview-attached', true);
const user = el.getAttribute('data-user-preview');
let tag = null;
let showTimer = null;
let hideTimer = null;
el.addEventListener('mouseover', () => {
clearTimeout(showTimer);
clearTimeout(hideTimer);
showTimer = setTimeout(show, 500);
});
el.addEventListener('mouseleave', () => {
clearTimeout(showTimer);
clearTimeout(hideTimer);
hideTimer = setTimeout(close, 500);
});
this.on('unmount', () => {
clearTimeout(showTimer);
clearTimeout(hideTimer);
close();
});
const show = () => {
if (tag) return;
const preview = document.createElement('mk-user-preview');
const rect = el.getBoundingClientRect();
const x = rect.left + el.offsetWidth + window.pageXOffset;
const y = rect.top + window.pageYOffset;
preview.style.top = y + 'px';
preview.style.left = x + 'px';
preview.addEventListener('mouseover', () => {
clearTimeout(hideTimer);
});
preview.addEventListener('mouseleave', () => {
clearTimeout(showTimer);
hideTimer = setTimeout(close, 500);
});
tag = riot.mount(document.body.appendChild(preview), {
user: user
})[0];
};
const close = () => {
if (tag) {
tag.close();
tag = null;
}
};
}