This commit is contained in:
syuilo 2018-02-09 13:11:30 +09:00
parent d1aba96a29
commit 92a1429de9
38 changed files with 308 additions and 328 deletions

View File

@ -115,7 +115,7 @@
this.api('auth/deny', { this.api('auth/deny', {
token: this.session.token token: this.session.token
}).then(() => { }).then(() => {
this.trigger('denied'); this.$emit('denied');
}); });
}; };
@ -123,7 +123,7 @@
this.api('auth/accept', { this.api('auth/accept', {
token: this.session.token token: this.session.token
}).then(() => { }).then(() => {
this.trigger('accepted'); this.$emit('accepted');
}); });
}; };
</script> </script>

View File

@ -344,7 +344,7 @@
this.registerMessage = message => { this.registerMessage = message => {
message.is_me = message.user_id == this.I.id; message.is_me = message.user_id == this.I.id;
message._click = () => { message._click = () => {
this.trigger('navigate-user', message.is_me ? message.recipient : message.user); this.$emit('navigate-user', message.is_me ? message.recipient : message.user);
}; };
}; };
@ -400,7 +400,7 @@
}).then(users => { }).then(users => {
users.forEach(user => { users.forEach(user => {
user._click = () => { user._click = () => {
this.trigger('navigate-user', user); this.$emit('navigate-user', user);
this.searchResult = []; this.searchResult = [];
}; };
}); });

View File

@ -111,7 +111,7 @@
username: this.$refs.username.value username: this.$refs.username.value
}).then(user => { }).then(user => {
this.user = user; this.user = user;
this.trigger('user', user); this.$emit('user', user);
this.update(); this.update();
}); });
}; };

View File

@ -155,7 +155,7 @@
}; };
this.uploads.push(ctx); this.uploads.push(ctx);
this.trigger('change-uploads', this.uploads); this.$emit('change-uploads', this.uploads);
this.update(); this.update();
const reader = new FileReader(); const reader = new FileReader();
@ -176,10 +176,10 @@
xhr.onload = e => { xhr.onload = e => {
const driveFile = JSON.parse(e.target.response); const driveFile = JSON.parse(e.target.response);
this.trigger('uploaded', driveFile); this.$emit('uploaded', driveFile);
this.uploads = this.uploads.filter(x => x.id != id); this.uploads = this.uploads.filter(x => x.id != id);
this.trigger('change-uploads', this.uploads); this.$emit('change-uploads', this.uploads);
this.update(); this.update();
}; };

View File

@ -131,7 +131,7 @@
el.removeEventListener('mousedown', this.mousedown); el.removeEventListener('mousedown', this.mousedown);
}); });
this.trigger('closed'); this.$emit('closed');
this.$destroy(); this.$destroy();
}; };
</script> </script>

View File

@ -178,18 +178,18 @@
this.ok = () => { this.ok = () => {
this.cropper.getCroppedCanvas().toBlob(blob => { this.cropper.getCroppedCanvas().toBlob(blob => {
this.trigger('cropped', blob); this.$emit('cropped', blob);
this.$refs.window.close(); this.$refs.window.close();
}); });
}; };
this.skip = () => { this.skip = () => {
this.trigger('skipped'); this.$emit('skipped');
this.$refs.window.close(); this.$refs.window.close();
}; };
this.cancel = () => { this.cancel = () => {
this.trigger('canceled'); this.$emit('canceled');
this.$refs.window.close(); this.$refs.window.close();
}; };
</script> </script>

View File

@ -17,7 +17,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.ctx.on('closed', () => { this.$refs.ctx.on('closed', () => {
this.trigger('closed'); this.$emit('closed');
this.$destroy(); this.$destroy();
}); });
}); });

View File

@ -535,13 +535,13 @@
this.selectedFiles.push(file); this.selectedFiles.push(file);
} }
this.update(); this.update();
this.trigger('change-selection', this.selectedFiles); this.$emit('change-selection', this.selectedFiles);
} else { } else {
if (isAlreadySelected) { if (isAlreadySelected) {
this.trigger('selected', file); this.$emit('selected', file);
} else { } else {
this.selectedFiles = [file]; this.selectedFiles = [file];
this.trigger('change-selection', [file]); this.$emit('change-selection', [file]);
} }
} }
}; };
@ -578,7 +578,7 @@
if (folder.parent) dive(folder.parent); if (folder.parent) dive(folder.parent);
this.update(); this.update();
this.trigger('open-folder', folder); this.$emit('open-folder', folder);
this.fetch(); this.fetch();
}); });
}; };
@ -648,7 +648,7 @@
folder: null, folder: null,
hierarchyFolders: [] hierarchyFolders: []
}); });
this.trigger('move-root'); this.$emit('move-root');
this.fetch(); this.fetch();
}; };

View File

@ -49,7 +49,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.ctx.on('closed', () => { this.$refs.ctx.on('closed', () => {
this.trigger('closed'); this.$emit('closed');
this.$destroy(); this.$destroy();
}); });
}); });

View File

@ -29,7 +29,7 @@
this.$refs.ctx.open(pos); this.$refs.ctx.open(pos);
this.$refs.ctx.on('closed', () => { this.$refs.ctx.on('closed', () => {
this.trigger('closed'); this.$emit('closed');
this.$destroy(); this.$destroy();
}); });
}; };

View File

@ -65,7 +65,7 @@
document.addEventListener('keydown', this.onDocumentKeydown); document.addEventListener('keydown', this.onDocumentKeydown);
window.addEventListener('scroll', this.onScroll); window.addEventListener('scroll', this.onScroll);
this.fetch(() => this.trigger('loaded')); this.fetch(() => this.$emit('loaded'));
}); });
this.on('unmount', () => { this.on('unmount', () => {

View File

@ -59,7 +59,7 @@
document.addEventListener('keydown', this.onDocumentKeydown); document.addEventListener('keydown', this.onDocumentKeydown);
window.addEventListener('scroll', this.onScroll); window.addEventListener('scroll', this.onScroll);
this.load(() => this.trigger('loaded')); this.load(() => this.$emit('loaded'));
}); });
this.on('unmount', () => { this.on('unmount', () => {

View File

@ -1,5 +1,5 @@
<template> <template>
<div :data-customize="customize"> <div :data-customize="customize">
<div class="customize" v-if="customize"> <div class="customize" v-if="customize">
<a href="/">%fa:check%完了</a> <a href="/">%fa:check%完了</a>
<div> <div>
@ -38,20 +38,206 @@
</div> </div>
<div class="main"> <div class="main">
<div class="left"> <div class="left">
<div ref="left" data-place="left"></div> <div ref="left" data-place="left">
<template v-for="widget in leftWidgets">
<div class="customize-container" v-if="customize" :key="widget.id" @contextmenu="onWidgetContextmenu.stop.prevent(widget.id)">
<component :is="widget.name" :widget="widget" :ref="widget.id"></component>
</div>
<template v-else>
<component :is="widget.name" :key="widget.id" :widget="widget" :ref="widget.id"></component>
</template>
</template>
</div>
</div> </div>
<main ref="main"> <main ref="main">
<div class="maintop" ref="maintop" data-place="main" v-if="customize"></div> <div class="maintop" ref="maintop" data-place="main" v-if="customize">
<mk-timeline-home-widget ref="tl" v-if="mode == 'timeline'"/> <template v-for="widget in centerWidgets">
<mk-mentions-home-widget ref="tl" v-if="mode == 'mentions'"/> <div class="customize-container" v-if="customize" :key="widget.id" @contextmenu="onWidgetContextmenu.stop.prevent(widget.id)">
<component :is="widget.name" :widget="widget" :ref="widget.id"></component>
</div>
<template v-else>
<component :is="widget.name" :key="widget.id" :widget="widget" :ref="widget.id"></component>
</template>
</template>
</div>
<mk-timeline-home-widget ref="tl" v-on:loaded="onTlLoaded" v-if="mode == 'timeline'"/>
<mk-mentions-home-widget ref="tl" v-on:loaded="onTlLoaded" v-if="mode == 'mentions'"/>
</main> </main>
<div class="right"> <div class="right">
<div ref="right" data-place="right"></div> <div ref="right" data-place="right">
<template v-for="widget in rightWidgets">
<div class="customize-container" v-if="customize" :key="widget.id" @contextmenu="onWidgetContextmenu.stop.prevent(widget.id)">
<component :is="widget.name" :widget="widget" :ref="widget.id"></component>
</div>
<template v-else>
<component :is="widget.name" :key="widget.id" :widget="widget" :ref="widget.id"></component>
</template>
</template>
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script lang="typescript">
import uuid from 'uuid';
import Sortable from 'sortablejs';
import I from '../../common/i';
import { resolveSrv } from 'dns';
export default {
props: {
customize: Boolean,
mode: {
type: String,
default: 'timeline'
}
},
data() {
return {
home: [],
bakedHomeData: null
};
},
methods: {
bakeHomeData() {
return JSON.stringify(this.I.client_settings.home);
},
onTlLoaded() {
this.$emit('loaded');
},
onMeRefreshed() {
if (this.bakedHomeData != this.bakeHomeData()) {
// TODO: i18n
alert('別の場所でホームが編集されました。ページを再度読み込みすると編集が反映されます。');
}
},
onWidgetContextmenu(widgetId) {
this.$refs[widgetId].func();
},
addWidget() {
const widget = {
name: this.$refs.widgetSelector.options[this.$refs.widgetSelector.selectedIndex].value,
id: uuid(),
place: 'left',
data: {}
};
this.I.client_settings.home.unshift(widget);
this.saveHome();
},
saveHome() {
/*const data = [];
Array.from(this.$refs.left.children).forEach(el => {
const id = el.getAttribute('data-widget-id');
const widget = this.I.client_settings.home.find(w => w.id == id);
widget.place = 'left';
data.push(widget);
});
Array.from(this.$refs.right.children).forEach(el => {
const id = el.getAttribute('data-widget-id');
const widget = this.I.client_settings.home.find(w => w.id == id);
widget.place = 'right';
data.push(widget);
});
Array.from(this.$refs.maintop.children).forEach(el => {
const id = el.getAttribute('data-widget-id');
const widget = this.I.client_settings.home.find(w => w.id == id);
widget.place = 'main';
data.push(widget);
});
this.api('i/update_home', {
home: data
}).then(() => {
this.I.update();
});*/
}
},
computed: {
leftWidgets() {
return this.I.client_settings.home.filter(w => w.place == 'left');
},
centerWidgets() {
return this.I.client_settings.home.filter(w => w.place == 'center');
},
rightWidgets() {
return this.I.client_settings.home.filter(w => w.place == 'right');
}
},
created() {
this.bakedHomeData = this.bakeHomeData();
},
mounted() {
this.I.on('refreshed', this.onMeRefreshed);
this.I.client_settings.home.forEach(widget => {
try {
this.setWidget(widget);
} catch (e) {
// noop
}
});
if (!this.opts.customize) {
if (this.$refs.left.children.length == 0) {
this.$refs.left.parentNode.removeChild(this.$refs.left);
}
if (this.$refs.right.children.length == 0) {
this.$refs.right.parentNode.removeChild(this.$refs.right);
}
}
if (this.opts.customize) {
dialog('%fa:info-circle%カスタマイズのヒント',
'<p>ホームのカスタマイズでは、ウィジェットを追加/削除したり、ドラッグ&ドロップして並べ替えたりすることができます。</p>' +
'<p>一部のウィジェットは、<strong><strong>右</strong>クリック</strong>することで表示を変更することができます。</p>' +
'<p>ウィジェットを削除するには、ヘッダーの<strong>「ゴミ箱」</strong>と書かれたエリアにウィジェットをドラッグ&ドロップします。</p>' +
'<p>カスタマイズを終了するには、右上の「完了」をクリックします。</p>',
[{
text: 'Got it!'
}]);
const sortableOption = {
group: 'kyoppie',
animation: 150,
onMove: evt => {
const id = evt.dragged.getAttribute('data-widget-id');
this.home.find(tag => tag.id == id).update({ place: evt.to.getAttribute('data-place') });
},
onSort: () => {
this.saveHome();
}
};
new Sortable(this.$refs.left, sortableOption);
new Sortable(this.$refs.right, sortableOption);
new Sortable(this.$refs.maintop, sortableOption);
new Sortable(this.$refs.trash, Object.assign({}, sortableOption, {
onAdd: evt => {
const el = evt.item;
const id = el.getAttribute('data-widget-id');
el.parentNode.removeChild(el);
this.I.client_settings.home = this.I.client_settings.home.filter(w => w.id != id);
this.saveHome();
}
}));
}
},
beforeDestroy() {
this.I.off('refreshed', this.onMeRefreshed);
this.home.forEach(widget => {
widget.unmount();
});
}
};
</script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
:scope :scope
display block display block
@ -184,209 +370,3 @@
margin 0 auto margin 0 auto
</style> </style>
<script lang="typescript">
import uuid from 'uuid';
import Sortable from 'sortablejs';
import dialog from '../scripts/dialog';
import ScrollFollower from '../scripts/scroll-follower';
this.mixin('i');
this.mixin('api');
this.mode = this.opts.mode || 'timeline';
this.home = [];
this.bakeHomeData = () => JSON.stringify(this.I.client_settings.home);
this.bakedHomeData = this.bakeHomeData();
this.on('mount', () => {
this.$refs.tl.on('loaded', () => {
this.trigger('loaded');
});
this.I.on('refreshed', this.onMeRefreshed);
this.I.client_settings.home.forEach(widget => {
try {
this.setWidget(widget);
} catch (e) {
// noop
}
});
if (!this.opts.customize) {
if (this.$refs.left.children.length == 0) {
this.$refs.left.parentNode.removeChild(this.$refs.left);
}
if (this.$refs.right.children.length == 0) {
this.$refs.right.parentNode.removeChild(this.$refs.right);
}
}
if (this.opts.customize) {
dialog('%fa:info-circle%カスタマイズのヒント',
'<p>ホームのカスタマイズでは、ウィジェットを追加/削除したり、ドラッグ&ドロップして並べ替えたりすることができます。</p>' +
'<p>一部のウィジェットは、<strong><strong>右</strong>クリック</strong>することで表示を変更することができます。</p>' +
'<p>ウィジェットを削除するには、ヘッダーの<strong>「ゴミ箱」</strong>と書かれたエリアにウィジェットをドラッグ&ドロップします。</p>' +
'<p>カスタマイズを終了するには、右上の「完了」をクリックします。</p>',
[{
text: 'Got it!'
}]);
const sortableOption = {
group: 'kyoppie',
animation: 150,
onMove: evt => {
const id = evt.dragged.getAttribute('data-widget-id');
this.home.find(tag => tag.id == id).update({ place: evt.to.getAttribute('data-place') });
},
onSort: () => {
this.saveHome();
}
};
new Sortable(this.$refs.left, sortableOption);
new Sortable(this.$refs.right, sortableOption);
new Sortable(this.$refs.maintop, sortableOption);
new Sortable(this.$refs.trash, Object.assign({}, sortableOption, {
onAdd: evt => {
const el = evt.item;
const id = el.getAttribute('data-widget-id');
el.parentNode.removeChild(el);
this.I.client_settings.home = this.I.client_settings.home.filter(w => w.id != id);
this.saveHome();
}
}));
}
if (!this.opts.customize) {
this.scrollFollowerLeft = this.$refs.left.parentNode ? new ScrollFollower(this.$refs.left, this.root.getBoundingClientRect().top) : null;
this.scrollFollowerRight = this.$refs.right.parentNode ? new ScrollFollower(this.$refs.right, this.root.getBoundingClientRect().top) : null;
}
});
this.on('unmount', () => {
this.I.off('refreshed', this.onMeRefreshed);
this.home.forEach(widget => {
widget.unmount();
});
if (!this.opts.customize) {
if (this.scrollFollowerLeft) this.scrollFollowerLeft.dispose();
if (this.scrollFollowerRight) this.scrollFollowerRight.dispose();
}
});
this.onMeRefreshed = () => {
if (this.bakedHomeData != this.bakeHomeData()) {
alert('別の場所でホームが編集されました。ページを再度読み込みすると編集が反映されます。');
}
};
this.setWidget = (widget, prepend = false) => {
const el = document.createElement(`mk-${widget.name}-home-widget`);
let actualEl;
if (this.opts.customize) {
const container = document.createElement('div');
container.classList.add('customize-container');
container.setAttribute('data-widget-id', widget.id);
container.appendChild(el);
actualEl = container;
} else {
actualEl = el;
}
switch (widget.place) {
case 'left':
if (prepend) {
this.$refs.left.insertBefore(actualEl, this.$refs.left.firstChild);
} else {
this.$refs.left.appendChild(actualEl);
}
break;
case 'right':
if (prepend) {
this.$refs.right.insertBefore(actualEl, this.$refs.right.firstChild);
} else {
this.$refs.right.appendChild(actualEl);
}
break;
case 'main':
if (this.opts.customize) {
this.$refs.maintop.appendChild(actualEl);
} else {
this.$refs.main.insertBefore(actualEl, this.$refs.tl.root);
}
break;
}
const tag = riot.mount(el, {
id: widget.id,
data: widget.data,
place: widget.place,
tl: this.$refs.tl
})[0];
this.home.push(tag);
if (this.opts.customize) {
actualEl.oncontextmenu = e => {
e.preventDefault();
e.stopImmediatePropagation();
if (tag.func) tag.func();
return false;
};
}
};
this.addWidget = () => {
const widget = {
name: this.$refs.widgetSelector.options[this.$refs.widgetSelector.selectedIndex].value,
id: uuid(),
place: 'left',
data: {}
};
this.I.client_settings.home.unshift(widget);
this.setWidget(widget, true);
this.saveHome();
};
this.saveHome = () => {
const data = [];
Array.from(this.$refs.left.children).forEach(el => {
const id = el.getAttribute('data-widget-id');
const widget = this.I.client_settings.home.find(w => w.id == id);
widget.place = 'left';
data.push(widget);
});
Array.from(this.$refs.right.children).forEach(el => {
const id = el.getAttribute('data-widget-id');
const widget = this.I.client_settings.home.find(w => w.id == id);
widget.place = 'right';
data.push(widget);
});
Array.from(this.$refs.maintop.children).forEach(el => {
const id = el.getAttribute('data-widget-id');
const widget = this.I.client_settings.home.find(w => w.id == id);
widget.place = 'main';
data.push(widget);
});
this.api('i/update_home', {
home: data
}).then(() => {
this.I.update();
});
};
</script>

View File

@ -324,7 +324,7 @@
}); });
this.$refs.uploader.on('change-uploads', uploads => { this.$refs.uploader.on('change-uploads', uploads => {
this.trigger('change-uploading-files', uploads); this.$emit('change-uploading-files', uploads);
}); });
this.autocomplete = new Autocomplete(this.$refs.text); this.autocomplete = new Autocomplete(this.$refs.text);
@ -340,7 +340,7 @@
this.update(); this.update();
this.$refs.poll.set(draft.data.poll); this.$refs.poll.set(draft.data.poll);
} }
this.trigger('change-files', this.files); this.$emit('change-files', this.files);
this.update(); this.update();
} }
@ -361,7 +361,7 @@
this.$refs.text.value = ''; this.$refs.text.value = '';
this.files = []; this.files = [];
this.poll = false; this.poll = false;
this.trigger('change-files'); this.$emit('change-files');
this.update(); this.update();
}; };
@ -444,14 +444,14 @@
this.addFile = file => { this.addFile = file => {
this.files.push(file); this.files.push(file);
this.trigger('change-files', this.files); this.$emit('change-files', this.files);
this.update(); this.update();
}; };
this.removeFile = e => { this.removeFile = e => {
const file = e.item; const file = e.item;
this.files = this.files.filter(x => x.id != file.id); this.files = this.files.filter(x => x.id != file.id);
this.trigger('change-files', this.files); this.$emit('change-files', this.files);
this.update(); this.update();
}; };
@ -487,7 +487,7 @@
}).then(data => { }).then(data => {
this.clear(); this.clear();
this.removeDraft(); this.removeDraft();
this.trigger('post'); this.$emit('post');
notify(this.repost notify(this.repost
? '%i18n:desktop.tags.mk-post-form.reposted%' ? '%i18n:desktop.tags.mk-post-form.reposted%'
: this.inReplyToPost : this.inReplyToPost

View File

@ -93,7 +93,7 @@
this.quote = false; this.quote = false;
this.cancel = () => { this.cancel = () => {
this.trigger('cancel'); this.$emit('cancel');
}; };
this.ok = () => { this.ok = () => {
@ -101,7 +101,7 @@
this.api('posts/create', { this.api('posts/create', {
repost_id: this.opts.post.id repost_id: this.opts.post.id
}).then(data => { }).then(data => {
this.trigger('posted'); this.$emit('posted');
notify('%i18n:desktop.tags.mk-repost-form.success%'); notify('%i18n:desktop.tags.mk-repost-form.success%');
}).catch(err => { }).catch(err => {
notify('%i18n:desktop.tags.mk-repost-form.failure%'); notify('%i18n:desktop.tags.mk-repost-form.failure%');
@ -118,7 +118,7 @@
}); });
this.$refs.form.on('post', () => { this.$refs.form.on('post', () => {
this.trigger('posted'); this.$emit('posted');
}); });
this.$refs.form.focus(); this.$refs.form.focus();

View File

@ -54,7 +54,7 @@
isEmpty: posts.length == 0 isEmpty: posts.length == 0
}); });
this.$refs.timeline.setPosts(posts); this.$refs.timeline.setPosts(posts);
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });

View File

@ -27,7 +27,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.posts.on('loaded', () => { this.$refs.posts.on('loaded', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });
</script> </script>

View File

@ -166,7 +166,7 @@
}; };
this.ok = () => { this.ok = () => {
this.trigger('selected', this.multiple ? this.files : this.files[0]); this.$emit('selected', this.multiple ? this.files : this.files[0]);
this.$refs.window.close(); this.$refs.window.close();
}; };
</script> </script>

View File

@ -105,7 +105,7 @@
}; };
this.ok = () => { this.ok = () => {
this.trigger('selected', this.$refs.window.refs.browser.folder); this.$emit('selected', this.$refs.window.refs.browser.folder);
this.$refs.window.close(); this.$refs.window.close();
}; };
</script> </script>

View File

@ -76,7 +76,7 @@
user: user user: user
}); });
this.fetch(() => this.trigger('loaded')); this.fetch(() => this.$emit('loaded'));
}); });
}); });

View File

@ -32,7 +32,7 @@
fetching: false, fetching: false,
user: user user: user
}); });
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });
</script> </script>
@ -716,7 +716,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.tl.on('loaded', () => { this.$refs.tl.on('loaded', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
this.scrollFollowerLeft = new ScrollFollower(this.$refs.left, this.parent.root.getBoundingClientRect().top); this.scrollFollowerLeft = new ScrollFollower(this.$refs.left, this.parent.root.getBoundingClientRect().top);
@ -778,7 +778,7 @@
</style> </style>
<script lang="typescript"> <script lang="typescript">
this.on('mount', () => { this.on('mount', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
</script> </script>
</mk-user-graphs> </mk-user-graphs>

View File

@ -98,7 +98,7 @@
this.moreFetching = false; this.moreFetching = false;
this.on('mount', () => { this.on('mount', () => {
this.fetch(() => this.trigger('loaded')); this.fetch(() => this.$emit('loaded'));
}); });
this.fetch = cb => { this.fetch = cb => {

View File

@ -82,7 +82,7 @@
this.view++; this.view++;
if (this.view == 2) this.view = 0; if (this.view == 2) this.view = 0;
this.update(); this.update();
this.trigger('view-changed', this.view); this.$emit('view-changed', this.view);
}; };
</script> </script>
</mk-activity-widget> </mk-activity-widget>

View File

@ -231,7 +231,7 @@
}; };
this.open = () => { this.open = () => {
this.trigger('opening'); this.$emit('opening');
this.top(); this.top();
@ -257,7 +257,7 @@
//this.$refs.main.focus(); //this.$refs.main.focus();
setTimeout(() => { setTimeout(() => {
this.trigger('opened'); this.$emit('opened');
}, 300); }, 300);
}; };
@ -278,7 +278,7 @@
}; };
this.close = () => { this.close = () => {
this.trigger('closing'); this.$emit('closing');
if (this.isModal) { if (this.isModal) {
this.$refs.bg.style.pointerEvents = 'none'; this.$refs.bg.style.pointerEvents = 'none';
@ -301,7 +301,7 @@
}); });
setTimeout(() => { setTimeout(() => {
this.trigger('closed'); this.$emit('closed');
}, 300); }, 300);
}; };

View File

@ -57,12 +57,12 @@
</style> </style>
<script lang="typescript"> <script lang="typescript">
this.cancel = () => { this.cancel = () => {
this.trigger('canceled'); this.$emit('canceled');
this.$destroy(); this.$destroy();
}; };
this.ok = () => { this.ok = () => {
this.trigger('selected', this.$refs.browser.folder); this.$emit('selected', this.$refs.browser.folder);
this.$destroy(); this.$destroy();
}; };
</script> </script>

View File

@ -70,18 +70,18 @@
}); });
this.$refs.browser.on('selected', file => { this.$refs.browser.on('selected', file => {
this.trigger('selected', file); this.$emit('selected', file);
this.$destroy(); this.$destroy();
}); });
}); });
this.cancel = () => { this.cancel = () => {
this.trigger('canceled'); this.$emit('canceled');
this.$destroy(); this.$destroy();
}; };
this.ok = () => { this.ok = () => {
this.trigger('selected', this.files); this.$emit('selected', this.files);
this.$destroy(); this.$destroy();
}; };
</script> </script>

View File

@ -274,7 +274,7 @@
if (folder.parent) dive(folder.parent); if (folder.parent) dive(folder.parent);
this.update(); this.update();
this.trigger('open-folder', this.folder, silent); this.$emit('open-folder', this.folder, silent);
this.fetch(); this.fetch();
}); });
}; };
@ -343,7 +343,7 @@
folder: null, folder: null,
hierarchyFolders: [] hierarchyFolders: []
}); });
this.trigger('move-root'); this.$emit('move-root');
this.fetch(); this.fetch();
} }
@ -359,7 +359,7 @@
fetching: true fetching: true
}); });
this.trigger('begin-fetch'); this.$emit('begin-fetch');
let fetchedFolders = null; let fetchedFolders = null;
let fetchedFiles = null; let fetchedFiles = null;
@ -402,11 +402,11 @@
fetching: false fetching: false
}); });
// 一連の読み込みが完了したイベントを発行 // 一連の読み込みが完了したイベントを発行
this.trigger('fetched'); this.$emit('fetched');
} else { } else {
flag = true; flag = true;
// 一連の読み込みが半分完了したイベントを発行 // 一連の読み込みが半分完了したイベントを発行
this.trigger('fetch-mid'); this.$emit('fetch-mid');
} }
}; };
@ -455,9 +455,9 @@
this.selectedFiles.push(file); this.selectedFiles.push(file);
} }
this.update(); this.update();
this.trigger('change-selection', this.selectedFiles); this.$emit('change-selection', this.selectedFiles);
} else { } else {
this.trigger('selected', file); this.$emit('selected', file);
} }
} else { } else {
this.cf(file); this.cf(file);
@ -482,7 +482,7 @@
if (file.folder) dive(file.folder); if (file.folder) dive(file.folder);
this.update(); this.update();
this.trigger('open-file', this.file, silent); this.$emit('open-file', this.file, silent);
}); });
}; };

View File

@ -22,7 +22,7 @@
this.init = new Promise((res, rej) => { this.init = new Promise((res, rej) => {
this.api('posts/timeline').then(posts => { this.api('posts/timeline').then(posts => {
res(posts); res(posts);
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });

View File

@ -16,7 +16,7 @@
<script lang="typescript"> <script lang="typescript">
this.on('mount', () => { this.on('mount', () => {
this.$refs.tl.on('loaded', () => { this.$refs.tl.on('loaded', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });
</script> </script>

View File

@ -106,7 +106,7 @@
notifications: notifications notifications: notifications
}); });
this.trigger('fetched'); this.$emit('fetched');
}); });
this.connection.on('notification', this.onNotification); this.connection.on('notification', this.onNotification);

View File

@ -161,7 +161,7 @@
}); });
this.$refs.uploader.on('change-uploads', uploads => { this.$refs.uploader.on('change-uploads', uploads => {
this.trigger('change-uploading-files', uploads); this.$emit('change-uploading-files', uploads);
}); });
this.$refs.text.focus(); this.$refs.text.focus();
@ -207,19 +207,19 @@
this.addFile = file => { this.addFile = file => {
file._remove = () => { file._remove = () => {
this.files = this.files.filter(x => x.id != file.id); this.files = this.files.filter(x => x.id != file.id);
this.trigger('change-files', this.files); this.$emit('change-files', this.files);
this.update(); this.update();
}; };
this.files.push(file); this.files.push(file);
this.trigger('change-files', this.files); this.$emit('change-files', this.files);
this.update(); this.update();
}; };
this.removeFile = e => { this.removeFile = e => {
const file = e.item; const file = e.item;
this.files = this.files.filter(x => x.id != file.id); this.files = this.files.filter(x => x.id != file.id);
this.trigger('change-files', this.files); this.$emit('change-files', this.files);
this.update(); this.update();
}; };
@ -254,7 +254,7 @@
reply_id: opts.reply ? opts.reply.id : undefined, reply_id: opts.reply ? opts.reply.id : undefined,
poll: this.poll ? this.$refs.poll.get() : undefined poll: this.poll ? this.$refs.poll.get() : undefined
}).then(data => { }).then(data => {
this.trigger('post'); this.$emit('post');
this.$destroy(); this.$destroy();
}).catch(err => { }).catch(err => {
this.update({ this.update({
@ -264,7 +264,7 @@
}; };
this.cancel = () => { this.cancel = () => {
this.trigger('cancel'); this.$emit('cancel');
this.$destroy(); this.$destroy();
}; };

View File

@ -27,7 +27,7 @@
this.init = new Promise((res, rej) => { this.init = new Promise((res, rej) => {
this.api('posts/search', parse(this.query)).then(posts => { this.api('posts/search', parse(this.query)).then(posts => {
res(posts); res(posts);
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });

View File

@ -9,7 +9,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.posts.on('loaded', () => { this.$refs.posts.on('loaded', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });
</script> </script>

View File

@ -21,7 +21,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.list.on('loaded', () => { this.$refs.list.on('loaded', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });
</script> </script>

View File

@ -21,7 +21,7 @@
this.on('mount', () => { this.on('mount', () => {
this.$refs.list.on('loaded', () => { this.$refs.list.on('loaded', () => {
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });
</script> </script>

View File

@ -18,7 +18,7 @@
with_media: this.withMedia with_media: this.withMedia
}).then(posts => { }).then(posts => {
res(posts); res(posts);
this.trigger('loaded'); this.$emit('loaded');
}); });
}); });

View File

@ -201,7 +201,7 @@
}).then(user => { }).then(user => {
this.fetching = false; this.fetching = false;
this.user = user; this.user = user;
this.trigger('loaded', user); this.$emit('loaded', user);
this.update(); this.update();
}); });
}); });

View File

@ -87,7 +87,7 @@
this.moreFetching = false; this.moreFetching = false;
this.on('mount', () => { this.on('mount', () => {
this.fetch(() => this.trigger('loaded')); this.fetch(() => this.$emit('loaded'));
}); });
this.fetch = cb => { this.fetch = cb => {