summaryrefslogtreecommitdiff
path: root/src/client/app/mobile/script.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-11-09 16:00:29 +0900
committerGitHub <noreply@github.com>2018-11-09 16:00:29 +0900
commit3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa (patch)
tree3af53c7b8d5ecc5f0c21cbc5abec3ec5254606b0 /src/client/app/mobile/script.ts
parent[Client] Fix bug (diff)
downloadsharkey-3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa.tar.gz
sharkey-3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa.tar.bz2
sharkey-3f79c9ae4927d4186c708e130ecbb1ea4f72d9fa.zip
Refactor client (#3178)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
Diffstat (limited to 'src/client/app/mobile/script.ts')
-rw-r--r--src/client/app/mobile/script.ts101
1 files changed, 86 insertions, 15 deletions
diff --git a/src/client/app/mobile/script.ts b/src/client/app/mobile/script.ts
index 9412c85980..707aae087b 100644
--- a/src/client/app/mobile/script.ts
+++ b/src/client/app/mobile/script.ts
@@ -2,6 +2,7 @@
* Mobile Client
*/
+import Vue from 'vue';
import VueRouter from 'vue-router';
// Style
@@ -9,13 +10,6 @@ import './style.styl';
import init from '../init';
-import chooseDriveFolder from './api/choose-drive-folder';
-import chooseDriveFile from './api/choose-drive-file';
-import dialog from './api/dialog';
-import input from './api/input';
-import post from './api/post';
-import notify from './api/notify';
-
import MkIndex from './views/pages/index.vue';
import MkSignup from './views/pages/signup.vue';
import MkUser from './views/pages/user.vue';
@@ -39,10 +33,94 @@ import MkTag from './views/pages/tag.vue';
import MkShare from './views/pages/share.vue';
import MkFollow from '../common/views/pages/follow.vue';
+import PostForm from './views/components/post-form-dialog.vue';
+import FileChooser from './views/components/drive-file-chooser.vue';
+import FolderChooser from './views/components/drive-folder-chooser.vue';
+import Dialog from './views/components/dialog.vue';
+
/**
* init
*/
init((launch) => {
+ Vue.mixin({
+ methods: {
+ $post(opts) {
+ const o = opts || {};
+
+ document.documentElement.style.overflow = 'hidden';
+
+ function recover() {
+ document.documentElement.style.overflow = 'auto';
+ }
+
+ const vm = this.$root.new(PostForm, {
+ reply: o.reply,
+ renote: o.renote
+ });
+
+ vm.$once('cancel', recover);
+ vm.$once('posted', recover);
+ if (o.cb) vm.$once('closed', o.cb);
+ (vm as any).focus();
+ },
+
+ $chooseDriveFile(opts) {
+ return new Promise((res, rej) => {
+ const o = opts || {};
+ const vm = this.$root.new(FileChooser, {
+ title: o.title,
+ multiple: o.multiple,
+ initFolder: o.currentFolder
+ });
+ vm.$once('selected', file => {
+ res(file);
+ });
+ });
+ },
+
+ $chooseDriveFolder(opts) {
+ return new Promise((res, rej) => {
+ const o = opts || {};
+ const vm = this.$root.new(FolderChooser, {
+ title: o.title,
+ initFolder: o.currentFolder
+ });
+ vm.$once('selected', folder => {
+ res(folder);
+ });
+ });
+ },
+
+ $input(opts) {
+ return new Promise<string>((res, rej) => {
+ const x = window.prompt(opts.title);
+ if (x) {
+ res(x);
+ }
+ });
+ },
+
+ $dialog(opts) {
+ return new Promise<string>((res, rej) => {
+ const o = opts || {};
+ const d = this.$root.new(Dialog, {
+ title: o.title,
+ text: o.text,
+ modal: o.modal,
+ buttons: o.actions
+ });
+ d.$once('clicked', id => {
+ res(id);
+ });
+ });
+ },
+
+ $notify(message) {
+ alert(message);
+ }
+ }
+ });
+
// Register directives
require('./views/directives');
@@ -85,12 +163,5 @@ init((launch) => {
});
// Launch the app
- launch(router, os => ({
- chooseDriveFolder,
- chooseDriveFile,
- dialog: dialog(os),
- input,
- post: post(os),
- notify
- }));
+ launch(router);
}, true);