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
94const LOADING = 'loading' ;
105const HIDDEN = 'hidden' ;
116const ERROR = 'error' ;
127
138const 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+ } ;
0 commit comments