summaryrefslogtreecommitdiff
path: root/src/web/app/desktop/scripts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-18 20:05:11 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-18 20:05:11 +0900
commit45e8331e261244628b134a18e3d0fbe0ebb3a7dc (patch)
tree44ac1719fcea0a61c33698b23fb89400141e00d9 /src/web/app/desktop/scripts
parentBetter notification (diff)
downloadsharkey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.tar.gz
sharkey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.tar.bz2
sharkey-45e8331e261244628b134a18e3d0fbe0ebb3a7dc.zip
:sushi:
Closes #12, #227 and #58
Diffstat (limited to 'src/web/app/desktop/scripts')
-rw-r--r--src/web/app/desktop/scripts/autocomplete.js4
-rw-r--r--src/web/app/desktop/scripts/dialog.js4
-rw-r--r--src/web/app/desktop/scripts/fuck-ad-block.js2
-rw-r--r--src/web/app/desktop/scripts/input-dialog.js4
-rw-r--r--src/web/app/desktop/scripts/not-implemented-exception.js8
-rw-r--r--src/web/app/desktop/scripts/notify.js4
-rw-r--r--src/web/app/desktop/scripts/stream.js7
-rw-r--r--src/web/app/desktop/scripts/update-avatar.js10
-rw-r--r--src/web/app/desktop/scripts/update-banner.js10
-rw-r--r--src/web/app/desktop/scripts/user-preview.js66
10 files changed, 28 insertions, 91 deletions
diff --git a/src/web/app/desktop/scripts/autocomplete.js b/src/web/app/desktop/scripts/autocomplete.js
index 60f28f5fab..8ca516e2a9 100644
--- a/src/web/app/desktop/scripts/autocomplete.js
+++ b/src/web/app/desktop/scripts/autocomplete.js
@@ -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;
diff --git a/src/web/app/desktop/scripts/dialog.js b/src/web/app/desktop/scripts/dialog.js
index 6fe7b6e8d7..c502d3fcb8 100644
--- a/src/web/app/desktop/scripts/dialog.js
+++ b/src/web/app/desktop/scripts/dialog.js
@@ -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, {
diff --git a/src/web/app/desktop/scripts/fuck-ad-block.js b/src/web/app/desktop/scripts/fuck-ad-block.js
index 38208d34c0..98f758026b 100644
--- a/src/web/app/desktop/scripts/fuck-ad-block.js
+++ b/src/web/app/desktop/scripts/fuck-ad-block.js
@@ -1,7 +1,7 @@
require('fuckadblock');
const dialog = require('./dialog');
-module.exports = () => {
+export default () => {
if (fuckAdBlock === undefined) {
adBlockDetected();
} else {
diff --git a/src/web/app/desktop/scripts/input-dialog.js b/src/web/app/desktop/scripts/input-dialog.js
index ab9c57401f..954fabfb67 100644
--- a/src/web/app/desktop/scripts/input-dialog.js
+++ b/src/web/app/desktop/scripts/input-dialog.js
@@ -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,
diff --git a/src/web/app/desktop/scripts/not-implemented-exception.js b/src/web/app/desktop/scripts/not-implemented-exception.js
new file mode 100644
index 0000000000..dd00c7662f
--- /dev/null
+++ b/src/web/app/desktop/scripts/not-implemented-exception.js
@@ -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'
+ }]);
+};
diff --git a/src/web/app/desktop/scripts/notify.js b/src/web/app/desktop/scripts/notify.js
index 048f22aea7..e58a8e4d36 100644
--- a/src/web/app/desktop/scripts/notify.js
+++ b/src/web/app/desktop/scripts/notify.js
@@ -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
diff --git a/src/web/app/desktop/scripts/stream.js b/src/web/app/desktop/scripts/stream.js
index ea1548ecfd..383b552075 100644
--- a/src/web/app/desktop/scripts/stream.js
+++ b/src/web/app/desktop/scripts/stream.js
@@ -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;
};
diff --git a/src/web/app/desktop/scripts/update-avatar.js b/src/web/app/desktop/scripts/update-avatar.js
index b3be78fc68..165c90567c 100644
--- a/src/web/app/desktop/scripts/update-avatar.js
+++ b/src/web/app/desktop/scripts/update-avatar.js
@@ -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,
diff --git a/src/web/app/desktop/scripts/update-banner.js b/src/web/app/desktop/scripts/update-banner.js
index e5c3dcf69b..d83b2bf1b1 100644
--- a/src/web/app/desktop/scripts/update-banner.js
+++ b/src/web/app/desktop/scripts/update-banner.js
@@ -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,
diff --git a/src/web/app/desktop/scripts/user-preview.js b/src/web/app/desktop/scripts/user-preview.js
deleted file mode 100644
index 1964384fde..0000000000
--- a/src/web/app/desktop/scripts/user-preview.js
+++ /dev/null
@@ -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;
- }
- };
-}