mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
chore(upload) es2015-ify
This commit is contained in:
parent
fe1978d289
commit
750ab79d4c
1 changed files with 64 additions and 53 deletions
117
client/upload.js
117
client/upload.js
|
|
@ -1,63 +1,74 @@
|
|||
/* global CloudCmd, Util, DOM */
|
||||
/* global CloudCmd, DOM */
|
||||
|
||||
'use strict';
|
||||
|
||||
const exec = require('execon');
|
||||
|
||||
const load = require('./load');
|
||||
const Files = require('./files');
|
||||
|
||||
CloudCmd.Upload = UploadProto;
|
||||
|
||||
function UploadProto() {
|
||||
var Images = DOM.Images,
|
||||
Files = DOM.Files,
|
||||
|
||||
Upload = this;
|
||||
Images.show.load('top');
|
||||
|
||||
function init() {
|
||||
Images.show.load('top');
|
||||
|
||||
Util.exec.series([
|
||||
CloudCmd.View,
|
||||
Upload.show
|
||||
]);
|
||||
}
|
||||
exec.series([
|
||||
CloudCmd.View,
|
||||
show
|
||||
]);
|
||||
|
||||
this.show = function() {
|
||||
Images.show.load('top');
|
||||
|
||||
Files.get('upload', function(error, data) {
|
||||
CloudCmd.View.show(data, {
|
||||
autoSize : true,
|
||||
afterShow : afterShow
|
||||
});
|
||||
});
|
||||
|
||||
DOM.load.style({
|
||||
id : 'upload-css',
|
||||
inner : '[data-name=js-upload-file-button] {' +
|
||||
'font-family: "Droid Sans Mono", "Ubuntu Mono", "Consolas", monospace;' +
|
||||
'font-size: 20px;' +
|
||||
'width: 97%' +
|
||||
'}'
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
CloudCmd.View.hide();
|
||||
};
|
||||
|
||||
function afterShow() {
|
||||
var button = DOM.getByDataName('js-upload-file-button');
|
||||
|
||||
Images.hide();
|
||||
|
||||
DOM.Events.add('change', button, (event) => {
|
||||
const files = event.target.files;
|
||||
|
||||
Upload.hide();
|
||||
|
||||
DOM.uploadFiles(files);
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
return exports;
|
||||
}
|
||||
|
||||
const {Images} = DOM;
|
||||
|
||||
module.exports.show = show;
|
||||
module.exports.hide = hide;
|
||||
|
||||
function show() {
|
||||
Images.show.load('top');
|
||||
|
||||
Files.get('upload', (error, data) => {
|
||||
const autoSize = true;
|
||||
|
||||
CloudCmd.View.show(data, {
|
||||
autoSize,
|
||||
afterShow,
|
||||
});
|
||||
});
|
||||
|
||||
const fontFamily = [
|
||||
'"Droid Sans Mono"',
|
||||
'"Ubuntu Mono"',
|
||||
'"Consolas"',
|
||||
'monospace'
|
||||
].join(', ');
|
||||
|
||||
load.style({
|
||||
id : 'upload-css',
|
||||
inner : '[data-name=js-upload-file-button] {' +
|
||||
`font-family: ${fontFamily};` +
|
||||
'font-size: 20px;' +
|
||||
'width: 97%' +
|
||||
'}'
|
||||
});
|
||||
}
|
||||
|
||||
function hide() {
|
||||
CloudCmd.View.hide();
|
||||
}
|
||||
|
||||
function afterShow() {
|
||||
const button = DOM.getByDataName('js-upload-file-button');
|
||||
|
||||
Images.hide();
|
||||
|
||||
DOM.Events.add('change', button, ({target}) => {
|
||||
const {files} = target;
|
||||
|
||||
hide();
|
||||
|
||||
DOM.uploadFiles(files);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue