dtable-ui-component 0.1.84 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/DTablePopover/index.js +115 -0
- package/lib/DTablePopover/utils.js +5 -0
- package/lib/DTableSelect/index.js +140 -0
- package/lib/DTableSwitch/index.js +27 -0
- package/lib/FormulaFormatter/index.js +7 -7
- package/lib/index.js +5 -1
- package/package.json +2 -1
- package/es/app.css +0 -20
- package/es/app.js +0 -91
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/components/cell-editor/checkbox-editor.js +0 -104
- package/es/components/cell-editor/collaborator-editor.js +0 -236
- package/es/components/cell-editor/date-editor.js +0 -151
- package/es/components/cell-editor/index.js +0 -9
- package/es/components/cell-editor/link-editor.js +0 -303
- package/es/components/cell-editor/multiple-select-editor.js +0 -237
- package/es/components/cell-editor/number-editor.js +0 -154
- package/es/components/cell-editor/single-select-editor.js +0 -202
- package/es/components/cell-editor/text-editor.js +0 -122
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
- package/es/components/cell-factory/cell-formatter-factory.js +0 -25
- package/es/components/cell-formatter/auto-number-formatter.js +0 -35
- package/es/components/cell-formatter/button-formatter.js +0 -55
- package/es/components/cell-formatter/checkbox-formatter.js +0 -44
- package/es/components/cell-formatter/collaborator-formatter.js +0 -91
- package/es/components/cell-formatter/creator-formatter.js +0 -87
- package/es/components/cell-formatter/ctime-formatter.js +0 -57
- package/es/components/cell-formatter/date-formatter.js +0 -59
- package/es/components/cell-formatter/duration-formatter.js +0 -37
- package/es/components/cell-formatter/email-formatter.js +0 -35
- package/es/components/cell-formatter/file-formatter.js +0 -63
- package/es/components/cell-formatter/formatter-config.js +0 -31
- package/es/components/cell-formatter/formula-formatter.js +0 -164
- package/es/components/cell-formatter/geolocation-formatter.js +0 -52
- package/es/components/cell-formatter/image-formatter.js +0 -153
- package/es/components/cell-formatter/index.js +0 -27
- package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
- package/es/components/cell-formatter/link-formatter.js +0 -144
- package/es/components/cell-formatter/long-text-formatter.js +0 -106
- package/es/components/cell-formatter/mtime-formatter.js +0 -57
- package/es/components/cell-formatter/multiple-select-formatter.js +0 -69
- package/es/components/cell-formatter/number-formatter.js +0 -46
- package/es/components/cell-formatter/rate-formatter.js +0 -79
- package/es/components/cell-formatter/single-select-formatter.js +0 -69
- package/es/components/cell-formatter/text-formatter.js +0 -55
- package/es/components/cell-formatter/url-formatter.js +0 -35
- package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
- package/es/components/common/collaborator-item.js +0 -63
- package/es/components/common/edit-editor-button.js +0 -56
- package/es/components/common/images-lazy-load.js +0 -150
- package/es/components/common/link-editor-option.js +0 -113
- package/es/components/common/mobile/mb-editor-header.js +0 -48
- package/es/components/common/modal-portal.js +0 -44
- package/es/components/common/select-editor-option.js +0 -106
- package/es/components/common/select-item.js +0 -58
- package/es/components/file-uploader/index.js +0 -53
- package/es/components/loading.js +0 -7
- package/es/components/toast/alert.js +0 -150
- package/es/components/toast/index.js +0 -3
- package/es/components/toast/toast.js +0 -179
- package/es/components/toast/toastManager.js +0 -170
- package/es/components/toast/toaster.js +0 -76
- package/es/constants/cell-types.js +0 -25
- package/es/constants/index.js +0 -48
- package/es/css/cell-editor.css +0 -614
- package/es/css/cell-formatter.css +0 -241
- package/es/css/custom-rc-calendar.css +0 -118
- package/es/css/image-previewer-ligntbox.css +0 -87
- package/es/css/loading.css +0 -54
- package/es/index.js +0 -6
- package/es/lang/index.js +0 -50
- package/es/locals/de.js +0 -2
- package/es/locals/en.js +0 -17
- package/es/locals/fr.js +0 -2
- package/es/locals/zh-CN.js +0 -17
- package/es/utils/cell-value-validator.js +0 -32
- package/es/utils/column-utils.js +0 -7
- package/es/utils/editor-utils.js +0 -71
- package/es/utils/normalize-long-text-value.js +0 -68
- package/es/utils/number-precision.js +0 -163
- package/es/utils/utils.js +0 -116
- package/es/utils/value-format-utils.js +0 -495
package/es/utils/editor-utils.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
2
|
-
|
|
3
|
-
var zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
4
|
-
|
|
5
|
-
var enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
6
|
-
|
|
7
|
-
var frFR = require('@seafile/seafile-calendar/lib/locale/fr_FR');
|
|
8
|
-
|
|
9
|
-
var deDE = require('@seafile/seafile-calendar/lib/locale/de_DE');
|
|
10
|
-
|
|
11
|
-
var esES = require('@seafile/seafile-calendar/lib/locale/es_ES');
|
|
12
|
-
|
|
13
|
-
var plPL = require('@seafile/seafile-calendar/lib/locale/pl_PL');
|
|
14
|
-
|
|
15
|
-
var csCZ = require('@seafile/seafile-calendar/lib/locale/cs_CZ');
|
|
16
|
-
|
|
17
|
-
export var initDateEditorLanguage = function initDateEditorLanguage(lang) {
|
|
18
|
-
var language;
|
|
19
|
-
|
|
20
|
-
switch (lang) {
|
|
21
|
-
case 'zh-cn':
|
|
22
|
-
language = zhCN;
|
|
23
|
-
break;
|
|
24
|
-
|
|
25
|
-
case 'zh-tw':
|
|
26
|
-
language = zhTW;
|
|
27
|
-
break;
|
|
28
|
-
|
|
29
|
-
case 'en':
|
|
30
|
-
language = enUS;
|
|
31
|
-
break;
|
|
32
|
-
|
|
33
|
-
case 'fr':
|
|
34
|
-
language = frFR;
|
|
35
|
-
break;
|
|
36
|
-
|
|
37
|
-
case 'de':
|
|
38
|
-
language = deDE;
|
|
39
|
-
break;
|
|
40
|
-
|
|
41
|
-
case 'es':
|
|
42
|
-
language = esES;
|
|
43
|
-
break;
|
|
44
|
-
|
|
45
|
-
case 'es-ar':
|
|
46
|
-
language = esES;
|
|
47
|
-
break;
|
|
48
|
-
|
|
49
|
-
case 'es-mx':
|
|
50
|
-
language = esES;
|
|
51
|
-
break;
|
|
52
|
-
|
|
53
|
-
case 'pl':
|
|
54
|
-
language = plPL;
|
|
55
|
-
break;
|
|
56
|
-
|
|
57
|
-
case 'cs':
|
|
58
|
-
language = csCZ;
|
|
59
|
-
break;
|
|
60
|
-
|
|
61
|
-
default:
|
|
62
|
-
language = zhCN;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return language;
|
|
66
|
-
};
|
|
67
|
-
export var getSelectOptionItem = function getSelectOptionItem(options, optionId) {
|
|
68
|
-
return options.find(function (option) {
|
|
69
|
-
return option.id === optionId;
|
|
70
|
-
});
|
|
71
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var hrefReg = /\[.+\]\(\S+\)|<img src=(\S+).+\/>|!\[\]\(\S+\)|<\S+>/g,
|
|
2
|
-
imageReg1 = /^<img src="(\S+)" .+\/>/,
|
|
3
|
-
imageReg2 = /^!\[\]\((\S+)\)/,
|
|
4
|
-
linkReg1 = /^\[.+\]\(\S+\)/,
|
|
5
|
-
linkReg2 = /^<\S+>$/;
|
|
6
|
-
|
|
7
|
-
var getLinks = function getLinks(hrefList) {
|
|
8
|
-
var hrefObj = {
|
|
9
|
-
links: [],
|
|
10
|
-
images: []
|
|
11
|
-
};
|
|
12
|
-
hrefList.forEach(function (href) {
|
|
13
|
-
if (href.search(linkReg1) >= 0 || href.search(linkReg2) >= 0) {
|
|
14
|
-
hrefObj.links.push(href);
|
|
15
|
-
} else {
|
|
16
|
-
var imageSrcList = href.match(imageReg1);
|
|
17
|
-
var imageSrcList1 = href.match(imageReg2);
|
|
18
|
-
|
|
19
|
-
if (imageSrcList) {
|
|
20
|
-
hrefObj.images.push(imageSrcList[1]);
|
|
21
|
-
} else if (imageSrcList1) {
|
|
22
|
-
hrefObj.images.push(imageSrcList1[1]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return hrefObj;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var getPreviewContent = function getPreviewContent(markdownContent) {
|
|
30
|
-
var preview = '';
|
|
31
|
-
var newMarkdownContent = markdownContent.replace(hrefReg, '');
|
|
32
|
-
|
|
33
|
-
for (var index = 0; index < newMarkdownContent.length; index++) {
|
|
34
|
-
if (newMarkdownContent[index] === '#') {
|
|
35
|
-
continue;
|
|
36
|
-
} else if (newMarkdownContent[index] === '\n') {
|
|
37
|
-
preview += ' ';
|
|
38
|
-
} else {
|
|
39
|
-
preview += newMarkdownContent[index];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (preview.length === 30) {
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var hrefList = markdownContent.match(hrefReg);
|
|
48
|
-
|
|
49
|
-
if (hrefList) {
|
|
50
|
-
var _getLinks = getLinks(hrefList),
|
|
51
|
-
images = _getLinks.images,
|
|
52
|
-
links = _getLinks.links;
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
preview: preview,
|
|
56
|
-
images: images,
|
|
57
|
-
links: links
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
preview: preview,
|
|
63
|
-
images: [],
|
|
64
|
-
links: []
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default getPreviewContent;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @desc Solve the problem of floating calculation, avoid multiple digits after the decimal point and loss of calculation accuracy.
|
|
5
|
-
* example: 3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Correct wrong data
|
|
10
|
-
* strip(0.09999999999999998)=0.1
|
|
11
|
-
*/
|
|
12
|
-
function strip(num) {
|
|
13
|
-
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
|
|
14
|
-
return +parseFloat(num.toPrecision(precision));
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Return digits length of a number
|
|
18
|
-
* @param {*number} num Input number
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function digitLength(num) {
|
|
23
|
-
// Get digit length of e
|
|
24
|
-
var eSplit = num.toString().split(/[eE]/);
|
|
25
|
-
var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
|
|
26
|
-
return len > 0 ? len : 0;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Convert decimals to integers and support scientific notation. If it is a decimal, it is enlarged to an integer
|
|
30
|
-
* @param {*number} num Number of inputs
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function float2Fixed(num) {
|
|
35
|
-
if (num.toString().indexOf('e') === -1) {
|
|
36
|
-
return Number(num.toString().replace('.', ''));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var dLen = digitLength(num);
|
|
40
|
-
return dLen > 0 ? strip(num * Math.pow(10, dLen)) : num;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check whether the number is out of range, and give a prompt if it is out of range
|
|
44
|
-
* @param {*number} num Number of inputs
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function checkBoundary(num) {
|
|
49
|
-
if (_boundaryCheckingState) {
|
|
50
|
-
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
|
|
51
|
-
console.warn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Exact multiplication
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
function times(num1, num2) {
|
|
61
|
-
for (var _len = arguments.length, others = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
62
|
-
others[_key - 2] = arguments[_key];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (others.length > 0) {
|
|
66
|
-
return times.apply(void 0, [times(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
var num1Changed = float2Fixed(num1);
|
|
70
|
-
var num2Changed = float2Fixed(num2);
|
|
71
|
-
var baseNum = digitLength(num1) + digitLength(num2);
|
|
72
|
-
var leftValue = num1Changed * num2Changed;
|
|
73
|
-
checkBoundary(leftValue);
|
|
74
|
-
return leftValue / Math.pow(10, baseNum);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Exact addition
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
function plus(num1, num2) {
|
|
82
|
-
for (var _len2 = arguments.length, others = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
83
|
-
others[_key2 - 2] = arguments[_key2];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (others.length > 0) {
|
|
87
|
-
return plus.apply(void 0, [plus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
91
|
-
return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Exact subtraction
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function minus(num1, num2) {
|
|
99
|
-
for (var _len3 = arguments.length, others = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
100
|
-
others[_key3 - 2] = arguments[_key3];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (others.length > 0) {
|
|
104
|
-
return minus.apply(void 0, [minus(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
|
|
108
|
-
return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Exact division
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
function divide(num1, num2) {
|
|
116
|
-
for (var _len4 = arguments.length, others = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
117
|
-
others[_key4 - 2] = arguments[_key4];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (others.length > 0) {
|
|
121
|
-
return divide.apply(void 0, [divide(num1, num2), others[0]].concat(_toConsumableArray(others.slice(1))));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
var num1Changed = float2Fixed(num1);
|
|
125
|
-
var num2Changed = float2Fixed(num2);
|
|
126
|
-
checkBoundary(num1Changed);
|
|
127
|
-
checkBoundary(num2Changed); // fix: Similar to 10 ** -4 is 0.00009999999999999999, strip correction
|
|
128
|
-
|
|
129
|
-
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* rounding
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
function round(num, ratio) {
|
|
137
|
-
var base = Math.pow(10, ratio);
|
|
138
|
-
return divide(Math.round(times(num, base)), base);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
var _boundaryCheckingState = true;
|
|
142
|
-
/**
|
|
143
|
-
* Whether to perform boundary check, default true
|
|
144
|
-
* @param flag Mark switch, true is on, false is off, default is true
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
function enableBoundaryChecking() {
|
|
148
|
-
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
149
|
-
_boundaryCheckingState = flag;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export { strip, plus, minus, times, divide, round, digitLength, float2Fixed, enableBoundaryChecking };
|
|
153
|
-
export default {
|
|
154
|
-
strip: strip,
|
|
155
|
-
plus: plus,
|
|
156
|
-
minus: minus,
|
|
157
|
-
times: times,
|
|
158
|
-
divide: divide,
|
|
159
|
-
round: round,
|
|
160
|
-
digitLength: digitLength,
|
|
161
|
-
float2Fixed: float2Fixed,
|
|
162
|
-
enableBoundaryChecking: enableBoundaryChecking
|
|
163
|
-
};
|
package/es/utils/utils.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
var FILEEXT_ICON_MAP = {
|
|
2
|
-
// text file
|
|
3
|
-
md: "txt.png",
|
|
4
|
-
txt: "txt.png",
|
|
5
|
-
// pdf file
|
|
6
|
-
pdf: "pdf.png",
|
|
7
|
-
// document file
|
|
8
|
-
doc: "word.png",
|
|
9
|
-
docx: "word.png",
|
|
10
|
-
odt: "word.png",
|
|
11
|
-
fodt: "word.png",
|
|
12
|
-
ppt: "ppt.png",
|
|
13
|
-
pptx: "ppt.png",
|
|
14
|
-
odp: "ppt.png",
|
|
15
|
-
fodp: "ppt.png",
|
|
16
|
-
xls: "excel.png",
|
|
17
|
-
xlsx: "excel.png",
|
|
18
|
-
ods: "excel.png",
|
|
19
|
-
fods: "excel.png",
|
|
20
|
-
// video
|
|
21
|
-
mp4: "video.png",
|
|
22
|
-
ogv: "video.png",
|
|
23
|
-
webm: "video.png",
|
|
24
|
-
mov: "video.png",
|
|
25
|
-
flv: "video.png",
|
|
26
|
-
wmv: "video.png",
|
|
27
|
-
rmvb: "video.png",
|
|
28
|
-
// music file
|
|
29
|
-
mp3: "music.png",
|
|
30
|
-
oga: "music.png",
|
|
31
|
-
ogg: "music.png",
|
|
32
|
-
flac: "music.png",
|
|
33
|
-
aac: "music.png",
|
|
34
|
-
ac3: "music.png",
|
|
35
|
-
wma: "music.png",
|
|
36
|
-
// image file
|
|
37
|
-
jpg: "pic.png",
|
|
38
|
-
jpeg: "pic.png",
|
|
39
|
-
png: "pic.png",
|
|
40
|
-
svg: "pic.png",
|
|
41
|
-
gif: "pic.png",
|
|
42
|
-
bmp: "pic.png",
|
|
43
|
-
ico: "pic.png",
|
|
44
|
-
// folder dir
|
|
45
|
-
folder: "folder-192.png",
|
|
46
|
-
// default
|
|
47
|
-
default: "file.png"
|
|
48
|
-
};
|
|
49
|
-
export var getFileIconUrl = function getFileIconUrl(filename, direntType) {
|
|
50
|
-
if (direntType === "dir") {
|
|
51
|
-
var _iconUrl = "assets/images/folder/" + FILEEXT_ICON_MAP["folder"];
|
|
52
|
-
|
|
53
|
-
return _iconUrl;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var iconUrl = "";
|
|
57
|
-
|
|
58
|
-
if (filename.lastIndexOf(".") === -1) {
|
|
59
|
-
iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP["default"];
|
|
60
|
-
return iconUrl;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var file_ext = filename.substr(filename.lastIndexOf(".") + 1).toLowerCase();
|
|
64
|
-
|
|
65
|
-
if (FILEEXT_ICON_MAP[file_ext]) {
|
|
66
|
-
iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP[file_ext];
|
|
67
|
-
} else {
|
|
68
|
-
iconUrl = "assets/images/file/192/" + FILEEXT_ICON_MAP["default"];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return iconUrl;
|
|
72
|
-
};
|
|
73
|
-
export var getImageThumbnailUrl = function getImageThumbnailUrl(url, server) {
|
|
74
|
-
if (server && url.indexOf(server) > -1) {
|
|
75
|
-
return url.replace("/workspace", "/thumbnail/workspace") + "?size=256";
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return url;
|
|
79
|
-
};
|
|
80
|
-
export var debounce = function debounce(fn, wait) {
|
|
81
|
-
var timeout = null;
|
|
82
|
-
return function () {
|
|
83
|
-
if (timeout !== null) clearTimeout(timeout);
|
|
84
|
-
timeout = setTimeout(fn, wait);
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
export var throttle = function throttle(func, delay) {
|
|
88
|
-
var timer = null;
|
|
89
|
-
var startTime = Date.now();
|
|
90
|
-
return function () {
|
|
91
|
-
var curTime = Date.now();
|
|
92
|
-
var remaining = delay - (curTime - startTime);
|
|
93
|
-
var context = this;
|
|
94
|
-
var args = arguments;
|
|
95
|
-
clearTimeout(timer);
|
|
96
|
-
|
|
97
|
-
if (remaining <= 0) {
|
|
98
|
-
func.apply(context, args);
|
|
99
|
-
startTime = Date.now();
|
|
100
|
-
} else {
|
|
101
|
-
timer = setTimeout(func, remaining);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
export var isFunction = function isFunction(functionToCheck) {
|
|
106
|
-
var getType = {};
|
|
107
|
-
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
108
|
-
};
|
|
109
|
-
export var isInternalImg = function isInternalImg(url) {
|
|
110
|
-
if (!url) return;
|
|
111
|
-
return url.indexOf(window.dtable.server) > -1;
|
|
112
|
-
};
|
|
113
|
-
export var checkSVGImage = function checkSVGImage(url) {
|
|
114
|
-
if (!url) return false;
|
|
115
|
-
return url.substr(-4).toLowerCase() === '.svg';
|
|
116
|
-
};
|