diff --git a/src/web/app/desktop/script.ts b/src/web/app/desktop/script.ts index 4f2ac61ee..3c560033f 100644 --- a/src/web/app/desktop/script.ts +++ b/src/web/app/desktop/script.ts @@ -35,6 +35,7 @@ init(async (launch) => { // Register components require('./views/components'); + // Launch the app const [app, os] = launch(os => ({ chooseDriveFolder, chooseDriveFile, @@ -65,19 +66,15 @@ init(async (launch) => { } } - app.$router.addRoutes([{ - path: '/', name: 'index', component: MkIndex - }, { - path: '/i/customize-home', component: MkHomeCustomize - }, { - path: '/i/drive', component: MkDrive - }, { - path: '/i/drive/folder/:folder', component: MkDrive - }, { - path: '/selectdrive', component: MkSelectDrive - }, { - path: '/:user', component: MkUser - }]); + // Routing + app.$router.addRoutes([ + { path: '/', name: 'index', component: MkIndex }, + { path: '/i/customize-home', component: MkHomeCustomize }, + { path: '/i/drive', component: MkDrive }, + { path: '/i/drive/folder/:folder', component: MkDrive }, + { path: '/selectdrive', component: MkSelectDrive }, + { path: '/:user', component: MkUser } + ]); }, true); function registerNotifications(stream: HomeStreamManager) { diff --git a/src/web/app/mobile/api/choose-drive-file.ts b/src/web/app/mobile/api/choose-drive-file.ts new file mode 100644 index 000000000..b1a78f236 --- /dev/null +++ b/src/web/app/mobile/api/choose-drive-file.ts @@ -0,0 +1,18 @@ +import Chooser from '../views/components/drive-file-chooser.vue'; + +export default function(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + const w = new Chooser({ + propsData: { + title: o.title, + multiple: o.multiple, + initFolder: o.currentFolder + } + }).$mount(); + w.$once('selected', file => { + res(file); + }); + document.body.appendChild(w.$el); + }); +} diff --git a/src/web/app/mobile/api/choose-drive-folder.ts b/src/web/app/mobile/api/choose-drive-folder.ts new file mode 100644 index 000000000..d1f97d148 --- /dev/null +++ b/src/web/app/mobile/api/choose-drive-folder.ts @@ -0,0 +1,17 @@ +import Chooser from '../views/components/drive-folder-chooser.vue'; + +export default function(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + const w = new Chooser({ + propsData: { + title: o.title, + initFolder: o.currentFolder + } + }).$mount(); + w.$once('selected', folder => { + res(folder); + }); + document.body.appendChild(w.$el); + }); +} diff --git a/src/web/app/mobile/api/dialog.ts b/src/web/app/mobile/api/dialog.ts new file mode 100644 index 000000000..a2378767b --- /dev/null +++ b/src/web/app/mobile/api/dialog.ts @@ -0,0 +1,5 @@ +export default function(opts) { + return new Promise((res, rej) => { + alert('dialog not implemented yet'); + }); +} diff --git a/src/web/app/mobile/api/input.ts b/src/web/app/mobile/api/input.ts new file mode 100644 index 000000000..fcff68cfb --- /dev/null +++ b/src/web/app/mobile/api/input.ts @@ -0,0 +1,5 @@ +export default function(opts) { + return new Promise((res, rej) => { + alert('input not implemented yet'); + }); +} diff --git a/src/web/app/mobile/api/post.ts b/src/web/app/mobile/api/post.ts new file mode 100644 index 000000000..11ffc779f --- /dev/null +++ b/src/web/app/mobile/api/post.ts @@ -0,0 +1,14 @@ + +export default opts => { + const app = document.getElementById('app'); + app.style.display = 'none'; + + function recover() { + app.style.display = 'block'; + } + + const form = riot.mount(document.body.appendChild(document.createElement('mk-post-form')), opts)[0]; + form + .on('cancel', recover) + .on('post', recover); +}; diff --git a/src/web/app/mobile/script.ts b/src/web/app/mobile/script.ts index f2d617f3a..339c9a8e4 100644 --- a/src/web/app/mobile/script.ts +++ b/src/web/app/mobile/script.ts @@ -5,9 +5,22 @@ // Style import './style.styl'; -require('./tags'); 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 updateAvatar from './api/update-avatar'; +import updateBanner from './api/update-banner'; + +import MkIndex from './views/pages/index.vue'; +import MkUser from './views/pages/user/user.vue'; +import MkSelectDrive from './views/pages/selectdrive.vue'; +import MkDrive from './views/pages/drive.vue'; + /** * init */ @@ -15,9 +28,30 @@ init((launch) => { // Register directives require('./views/directives'); + // Register components + require('./views/components'); + // http://qiita.com/junya/items/3ff380878f26ca447f85 document.body.setAttribute('ontouchstart', ''); - // Start routing - //route(mios); + // Launch the app + const [app, os] = launch(os => ({ + chooseDriveFolder, + chooseDriveFile, + dialog, + input, + post, + notify, + updateAvatar: updateAvatar(os), + updateBanner: updateBanner(os) + })); + + // Routing + app.$router.addRoutes([ + { path: '/', name: 'index', component: MkIndex }, + { path: '/i/drive', component: MkDrive }, + { path: '/i/drive/folder/:folder', component: MkDrive }, + { path: '/selectdrive', component: MkSelectDrive }, + { path: '/:user', component: MkUser } + ]); }, true); diff --git a/src/web/app/mobile/views/components/drive-folder-chooser.vue b/src/web/app/mobile/views/components/drive-folder-chooser.vue index 53cc67c6c..853078664 100644 --- a/src/web/app/mobile/views/components/drive-folder-chooser.vue +++ b/src/web/app/mobile/views/components/drive-folder-chooser.vue @@ -4,7 +4,7 @@

%i18n:mobile.tags.mk-drive-folder-selector.select-folder%

- +
{ // Entries const entry = { desktop: './src/web/app/desktop/script.ts', - //mobile: './src/web/app/mobile/script.ts', + mobile: './src/web/app/mobile/script.ts', //ch: './src/web/app/ch/script.ts', //stats: './src/web/app/stats/script.ts', //status: './src/web/app/status/script.ts',