Skip to content

Commit f437a52

Browse files
committed
feature: client: images: migrate to EMS
1 parent 7192a56 commit f437a52

22 files changed

Lines changed: 49 additions & 47 deletions

client/client.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {tryToCatch} from 'try-to-catch';
99
import {addSlashToEnd} from 'format-io';
1010
import pascalCase from 'just-pascal-case';
1111
import currify from 'currify';
12-
import Images from './dom/images.js';
12+
import * as Images from './dom/images.mjs';
1313
import {unregisterSW} from './sw/register.js';
1414
import {getJsonFromFileTable} from './get-json-from-file-table.mjs';
1515
import {Key} from './key/index.mjs';

client/dom/current-file.spec.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,3 @@ function getDOM(overrides = {}) {
305305
},
306306
};
307307
}
308-

client/dom/directory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* global CloudCmd */
44
const philip = require('philip');
55

6-
const Images = require('./images');
6+
const Images = require('./images.mjs');
77
const {FS} = require('../../common/cloudfunc.mjs');
88
const DOM = require('.');
99
const Dialog = require('./dialog');
Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
/* global DOM */
2-
3-
'use strict';
4-
5-
const createElement = require('@cloudcmd/create-element');
6-
7-
const Images = module.exports;
2+
import createElement from '@cloudcmd/create-element';
83

94
const LOADING = 'loading';
105
const HIDDEN = 'hidden';
116
const ERROR = 'error';
127

138
const getLoadingType = () => isSVG() ? '-svg' : '-gif';
149

15-
module.exports.get = getElement;
10+
export const get = getElement;
11+
1612
/**
1713
* check SVG SMIL animation support
1814
*/
@@ -40,7 +36,7 @@ function getElement() {
4036
}
4137

4238
/* Функция создаёт картинку загрузки */
43-
module.exports.loading = () => {
39+
export const loading = () => {
4440
const element = getElement();
4541
const {classList} = element;
4642
const loadingImage = LOADING + getLoadingType();
@@ -52,7 +48,7 @@ module.exports.loading = () => {
5248
};
5349

5450
/* Функция создаёт картинку ошибки загрузки */
55-
module.exports.error = () => {
51+
export const error = () => {
5652
const element = getElement();
5753
const {classList} = element;
5854
const loadingImage = LOADING + getLoadingType();
@@ -63,14 +59,21 @@ module.exports.error = () => {
6359
return element;
6460
};
6561

66-
module.exports.show = show;
67-
module.exports.show.load = show;
68-
module.exports.show.error = error;
62+
show.load = show;
63+
show.error = (text) => {
64+
const image = Images.error();
65+
66+
DOM.show(image);
67+
image.title = text;
68+
69+
return image;
70+
};
71+
6972
/**
7073
* Function shows loading spinner
7174
* position = {top: true};
7275
*/
73-
function show(position, panel) {
76+
export function show(position, panel) {
7477
const image = Images.loading();
7578
const parent = image.parentElement;
7679
const refreshButton = DOM.getRefreshButton(panel);
@@ -96,27 +99,18 @@ function show(position, panel) {
9699
return image;
97100
}
98101

99-
function error(text) {
100-
const image = Images.error();
101-
102-
DOM.show(image);
103-
image.title = text;
104-
105-
return image;
106-
}
107-
108102
/**
109103
* hide load image
110104
*/
111-
module.exports.hide = () => {
105+
export const hide = () => {
112106
const element = Images.get();
113107

114108
DOM.hide(element);
115109

116110
return Images;
117111
};
118112

119-
module.exports.setProgress = (value, title) => {
113+
export const setProgress = (value, title) => {
120114
const DATA = 'data-progress';
121115
const element = Images.get();
122116

@@ -131,7 +125,7 @@ module.exports.setProgress = (value, title) => {
131125
return Images;
132126
};
133127

134-
module.exports.clearProgress = () => {
128+
export const clearProgress = () => {
135129
const DATA = 'data-progress';
136130
const element = Images.get();
137131

@@ -143,3 +137,13 @@ module.exports.clearProgress = () => {
143137

144138
return Images;
145139
};
140+
141+
const Images = {
142+
clearProgress,
143+
setProgress,
144+
show,
145+
hide,
146+
get,
147+
error,
148+
loading,
149+
};

client/dom/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* global CloudCmd */
44
const Util = require('../../common/util');
55

6-
const Images = require('./images');
6+
const Images = require('./images.mjs');
77
const RESTful = require('./rest');
88
const Storage = require('./storage');
99
const renameCurrent = require('./operations/rename-current');

client/dom/io/send-request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* global CloudCmd */
44
const {promisify} = require('es6-promisify');
55

6-
const Images = require('../images');
6+
const Images = require('../images.mjs');
77
const load = require('../load');
88

99
module.exports = promisify((params, callback) => {

client/dom/load.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const itype = require('itype');
44
const jonny = require('jonny');
55
const Emitify = require('emitify');
66
const exec = require('execon');
7-
const Images = require('./images');
7+
const Images = require('./images.mjs');
88

99
module.exports.getIdBySrc = getIdBySrc;
1010
/**

client/dom/rest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const {tryToCatch} = require('try-to-catch');
44

55
const {encode} = require('../../common/entity');
66

7-
const Images = require('./images');
7+
const Images = require('./images.mjs');
88
const IO = require('./io');
99
const Dialog = require('./dialog');
1010

client/dom/upload-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {eachSeries} = require('execon');
55
const wraptile = require('wraptile');
66

77
const load = require('./load');
8-
const Images = require('./images');
8+
const Images = require('./images.mjs');
99
const {alert} = require('./dialog');
1010

1111
const {FS} = require('../../common/cloudfunc.mjs');

client/modules/cloud.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const load = require('load.js');
99
const {ajax} = require('../dom/load');
1010

1111
const Files = require('../dom/files');
12-
const Images = require('../dom/images');
12+
const Images = require('../dom/images.mjs');
1313
const {log} = CloudCmd;
1414

1515
const upload = currify(_upload);

0 commit comments

Comments
 (0)