misskey/src/client/app/desktop/api/choose-drive-file.ts

30 lines
720 B
TypeScript
Raw Normal View History

2018-05-27 06:49:09 +02:00
import OS from '../../mios';
2018-02-22 13:15:24 +01:00
import { url } from '../../config';
2018-02-18 04:35:18 +01:00
import MkChooseFileFromDriveWindow from '../views/components/choose-file-from-drive-window.vue';
2018-05-27 06:49:09 +02:00
export default (os: OS) => opts => {
2018-02-18 04:35:18 +01:00
return new Promise((res, rej) => {
const o = opts || {};
2018-02-22 13:15:24 +01:00
if (document.body.clientWidth > 800) {
2018-05-27 06:49:09 +02:00
const w = os.new(MkChooseFileFromDriveWindow, {
title: o.title,
multiple: o.multiple,
initFolder: o.currentFolder
});
2018-02-22 13:15:24 +01:00
w.$once('selected', file => {
res(file);
});
document.body.appendChild(w.$el);
} else {
window['cb'] = file => {
res(file);
};
2018-06-16 11:42:49 +02:00
window.open(url + `/selectdrive?multiple=${o.multiple}`,
2018-03-03 08:39:53 +01:00
'choose_drive_window',
2018-02-22 13:15:24 +01:00
'height=500, width=800');
}
2018-02-18 04:35:18 +01:00
});
2018-05-27 06:49:09 +02:00
};