clickgo 3.0.0-dev
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/LICENSE +201 -0
- package/README.md +75 -0
- package/dist/app/demo/config.json +106 -0
- package/dist/app/demo/form/control/block/block.css +1 -0
- package/dist/app/demo/form/control/block/block.scss +17 -0
- package/dist/app/demo/form/control/block/block.xml +7 -0
- package/dist/app/demo/form/control/button/button.css +1 -0
- package/dist/app/demo/form/control/button/button.js +27 -0
- package/dist/app/demo/form/control/button/button.scss +18 -0
- package/dist/app/demo/form/control/button/button.xml +126 -0
- package/dist/app/demo/form/control/check/check.js +12 -0
- package/dist/app/demo/form/control/check/check.xml +13 -0
- package/dist/app/demo/form/control/dialog/dialog.js +8 -0
- package/dist/app/demo/form/control/dialog/dialog.xml +26 -0
- package/dist/app/demo/form/control/file/file.js +23 -0
- package/dist/app/demo/form/control/file/file.xml +25 -0
- package/dist/app/demo/form/control/form/form.css +1 -0
- package/dist/app/demo/form/control/form/form.js +38 -0
- package/dist/app/demo/form/control/form/form.scss +9 -0
- package/dist/app/demo/form/control/form/form.xml +28 -0
- package/dist/app/demo/form/control/greatview/greatview.css +1 -0
- package/dist/app/demo/form/control/greatview/greatview.js +92 -0
- package/dist/app/demo/form/control/greatview/greatview.scss +22 -0
- package/dist/app/demo/form/control/greatview/greatview.xml +89 -0
- package/dist/app/demo/form/control/img/img.xml +16 -0
- package/dist/app/demo/form/control/label/label.xml +11 -0
- package/dist/app/demo/form/control/list/list.css +1 -0
- package/dist/app/demo/form/control/list/list.js +194 -0
- package/dist/app/demo/form/control/list/list.scss +7 -0
- package/dist/app/demo/form/control/list/list.xml +91 -0
- package/dist/app/demo/form/control/loading/loading.xml +8 -0
- package/dist/app/demo/form/control/marquee/marquee.js +30 -0
- package/dist/app/demo/form/control/marquee/marquee.xml +36 -0
- package/dist/app/demo/form/control/menu/menu.js +8 -0
- package/dist/app/demo/form/control/menu/menu.xml +122 -0
- package/dist/app/demo/form/control/monaco/monaco.js +113 -0
- package/dist/app/demo/form/control/monaco/monaco.xml +27 -0
- package/dist/app/demo/form/control/overflow/overflow.css +1 -0
- package/dist/app/demo/form/control/overflow/overflow.js +70 -0
- package/dist/app/demo/form/control/overflow/overflow.scss +18 -0
- package/dist/app/demo/form/control/overflow/overflow.xml +98 -0
- package/dist/app/demo/form/control/property/property.js +129 -0
- package/dist/app/demo/form/control/property/property.xml +6 -0
- package/dist/app/demo/form/control/radio/radio.js +7 -0
- package/dist/app/demo/form/control/radio/radio.xml +12 -0
- package/dist/app/demo/form/control/scroll/scroll.js +14 -0
- package/dist/app/demo/form/control/scroll/scroll.xml +35 -0
- package/dist/app/demo/form/control/select/select.js +91 -0
- package/dist/app/demo/form/control/select/select.xml +74 -0
- package/dist/app/demo/form/control/tab/tab.js +75 -0
- package/dist/app/demo/form/control/tab/tab.xml +22 -0
- package/dist/app/demo/form/control/text/text.js +53 -0
- package/dist/app/demo/form/control/text/text.xml +37 -0
- package/dist/app/demo/form/control/view/view.css +1 -0
- package/dist/app/demo/form/control/view/view.js +73 -0
- package/dist/app/demo/form/control/view/view.scss +18 -0
- package/dist/app/demo/form/control/view/view.xml +94 -0
- package/dist/app/demo/form/event/form/form.css +1 -0
- package/dist/app/demo/form/event/form/form.js +129 -0
- package/dist/app/demo/form/event/form/form.scss +24 -0
- package/dist/app/demo/form/event/form/form.xml +16 -0
- package/dist/app/demo/form/event/screen/screen.js +51 -0
- package/dist/app/demo/form/event/screen/screen.xml +9 -0
- package/dist/app/demo/form/event/task/task.js +78 -0
- package/dist/app/demo/form/event/task/task.xml +20 -0
- package/dist/app/demo/form/main.css +1 -0
- package/dist/app/demo/form/main.js +25 -0
- package/dist/app/demo/form/main.scss +9 -0
- package/dist/app/demo/form/main.xml +49 -0
- package/dist/app/demo/form/method/core/core.js +25 -0
- package/dist/app/demo/form/method/core/core.xml +7 -0
- package/dist/app/demo/form/method/dom/dom.css +1 -0
- package/dist/app/demo/form/method/dom/dom.js +163 -0
- package/dist/app/demo/form/method/dom/dom.scss +10 -0
- package/dist/app/demo/form/method/dom/dom.xml +55 -0
- package/dist/app/demo/form/method/form/form.css +1 -0
- package/dist/app/demo/form/method/form/form.js +217 -0
- package/dist/app/demo/form/method/form/form.scss +3 -0
- package/dist/app/demo/form/method/form/form.xml +56 -0
- package/dist/app/demo/form/method/form/test.xml +5 -0
- package/dist/app/demo/form/method/fs/fs.js +88 -0
- package/dist/app/demo/form/method/fs/fs.xml +8 -0
- package/dist/app/demo/form/method/fs/text.js +15 -0
- package/dist/app/demo/form/method/fs/text.xml +3 -0
- package/dist/app/demo/form/method/task/locale1.json +3 -0
- package/dist/app/demo/form/method/task/locale2.json +3 -0
- package/dist/app/demo/form/method/task/task.js +153 -0
- package/dist/app/demo/form/method/task/task.xml +57 -0
- package/dist/app/demo/form/method/theme/theme.js +74 -0
- package/dist/app/demo/form/method/theme/theme.xml +9 -0
- package/dist/app/demo/form/method/tool/tool.js +64 -0
- package/dist/app/demo/form/method/tool/tool.xml +26 -0
- package/dist/app/demo/form/method/zip/zip.js +99 -0
- package/dist/app/demo/form/method/zip/zip.xml +12 -0
- package/dist/app/demo/global.css +3 -0
- package/dist/app/demo/res/icon.svg +1 -0
- package/dist/app/demo/res/img.jpg +0 -0
- package/dist/app/demo/res/r-1.svg +1 -0
- package/dist/app/demo/res/r-2.svg +1 -0
- package/dist/app/demo/res/sql.svg +1 -0
- package/dist/app/demo/res/txt.svg +1 -0
- package/dist/app/demo/res/zip.svg +1 -0
- package/dist/app/task/config.json +29 -0
- package/dist/app/task/form/bar/bar.js +299 -0
- package/dist/app/task/form/bar/bar.xml +47 -0
- package/dist/app/task/form/desktop/desktop.xml +1 -0
- package/dist/app/task/locale/en.json +11 -0
- package/dist/app/task/locale/ja.json +11 -0
- package/dist/app/task/locale/sc.json +11 -0
- package/dist/app/task/locale/tc.json +11 -0
- package/dist/clickgo.js +41 -0
- package/dist/clickgo.ts +51 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -0
- package/dist/icon.png +0 -0
- package/dist/index.js +88 -0
- package/dist/index.ts +92 -0
- package/dist/lib/control.js +365 -0
- package/dist/lib/control.ts +428 -0
- package/dist/lib/core.js +668 -0
- package/dist/lib/core.ts +732 -0
- package/dist/lib/dom.js +1471 -0
- package/dist/lib/dom.ts +1785 -0
- package/dist/lib/form.js +2101 -0
- package/dist/lib/form.ts +2496 -0
- package/dist/lib/fs.js +849 -0
- package/dist/lib/fs.ts +995 -0
- package/dist/lib/native.js +138 -0
- package/dist/lib/native.ts +219 -0
- package/dist/lib/task.js +686 -0
- package/dist/lib/task.ts +842 -0
- package/dist/lib/theme.js +159 -0
- package/dist/lib/theme.ts +196 -0
- package/dist/lib/tool.js +501 -0
- package/dist/lib/tool.ts +620 -0
- package/dist/lib/zip.js +352 -0
- package/dist/lib/zip.ts +434 -0
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +27 -0
- package/types/dev.d.ts +30 -0
- package/types/index.d.ts +673 -0
package/dist/lib/form.js
ADDED
|
@@ -0,0 +1,2101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.hide = exports.show = exports.flash = exports.setTopMost = exports.confirm = exports.dialog = exports.create = exports.remove = exports.doFocusAndPopEvent = exports.hidePop = exports.showPop = exports.removeFromPop = exports.appendToPop = exports.hideNotify = exports.notifyProgress = exports.notify = exports.hideDrag = exports.moveDrag = exports.showDrag = exports.hideRectangle = exports.showRectangle = exports.moveRectangle = exports.showCircular = exports.getRectByBorder = exports.getMaxZIndexID = exports.changeFocus = exports.getList = exports.send = exports.get = exports.getTaskId = exports.refreshMaxPosition = exports.bindDrag = exports.bindResize = exports.close = exports.max = exports.min = exports.simpleSystemTaskRoot = void 0;
|
|
13
|
+
const clickgo = require("../clickgo");
|
|
14
|
+
const core = require("./core");
|
|
15
|
+
const task = require("./task");
|
|
16
|
+
const tool = require("./tool");
|
|
17
|
+
const dom = require("./dom");
|
|
18
|
+
const control = require("./control");
|
|
19
|
+
const native = require("./native");
|
|
20
|
+
const info = {
|
|
21
|
+
'lastId': 0,
|
|
22
|
+
'lastZIndex': 999,
|
|
23
|
+
'topLastZIndex': 9999999,
|
|
24
|
+
'locale': {
|
|
25
|
+
'sc': {
|
|
26
|
+
'ok': '好',
|
|
27
|
+
'yes': '是',
|
|
28
|
+
'no': '否',
|
|
29
|
+
'cancel': '取消'
|
|
30
|
+
},
|
|
31
|
+
'tc': {
|
|
32
|
+
'ok': '好',
|
|
33
|
+
'yes': '是',
|
|
34
|
+
'no': '否',
|
|
35
|
+
'cancel': '取消'
|
|
36
|
+
},
|
|
37
|
+
'en': {
|
|
38
|
+
'ok': 'OK',
|
|
39
|
+
'yes': 'Yes',
|
|
40
|
+
'no': 'No',
|
|
41
|
+
'cancel': 'Cancel'
|
|
42
|
+
},
|
|
43
|
+
'ja': {
|
|
44
|
+
'ok': '好',
|
|
45
|
+
'yes': 'はい',
|
|
46
|
+
'no': 'いいえ',
|
|
47
|
+
'cancel': 'キャンセル'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const popInfo = {
|
|
52
|
+
'list': [],
|
|
53
|
+
'elList': [],
|
|
54
|
+
'lastZIndex': 0
|
|
55
|
+
};
|
|
56
|
+
const elements = {
|
|
57
|
+
'wrap': document.createElement('div'),
|
|
58
|
+
'list': document.createElement('div'),
|
|
59
|
+
'popList': document.createElement('div'),
|
|
60
|
+
'circular': document.createElement('div'),
|
|
61
|
+
'rectangle': document.createElement('div'),
|
|
62
|
+
'gesture': document.createElement('div'),
|
|
63
|
+
'drag': document.createElement('div'),
|
|
64
|
+
'dragIcon': undefined,
|
|
65
|
+
'system': document.createElement('div'),
|
|
66
|
+
'simpleSystemtask': document.createElement('div'),
|
|
67
|
+
'init': function () {
|
|
68
|
+
this.wrap.id = 'cg-wrap';
|
|
69
|
+
document.getElementsByTagName('body')[0].appendChild(this.wrap);
|
|
70
|
+
if (clickgo.getNative()) {
|
|
71
|
+
this.wrap.addEventListener('mouseenter', function () {
|
|
72
|
+
native.send('cg-mouse-ignore', 'false');
|
|
73
|
+
});
|
|
74
|
+
this.wrap.addEventListener('mouseleave', function () {
|
|
75
|
+
native.send('cg-mouse-ignore', 'true');
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
this.list.id = 'cg-form-list';
|
|
79
|
+
this.wrap.appendChild(this.list);
|
|
80
|
+
this.list.addEventListener('touchmove', function (e) {
|
|
81
|
+
if (e.cancelable) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
'passive': false
|
|
86
|
+
});
|
|
87
|
+
this.list.addEventListener('wheel', function (e) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
}, {
|
|
90
|
+
'passive': false
|
|
91
|
+
});
|
|
92
|
+
this.list.addEventListener('contextmenu', function (e) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
});
|
|
95
|
+
this.popList.id = 'cg-pop-list';
|
|
96
|
+
this.popList.addEventListener('contextmenu', function (e) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
});
|
|
99
|
+
this.wrap.appendChild(this.popList);
|
|
100
|
+
this.popList.addEventListener('touchmove', function (e) {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
}, {
|
|
103
|
+
'passive': false
|
|
104
|
+
});
|
|
105
|
+
this.circular.id = 'cg-circular';
|
|
106
|
+
this.wrap.appendChild(this.circular);
|
|
107
|
+
this.rectangle.setAttribute('data-pos', '');
|
|
108
|
+
this.rectangle.id = 'cg-rectangle';
|
|
109
|
+
this.wrap.appendChild(this.rectangle);
|
|
110
|
+
this.gesture.id = 'cg-gesture';
|
|
111
|
+
this.wrap.appendChild(this.gesture);
|
|
112
|
+
this.drag.id = 'cg-drag';
|
|
113
|
+
this.drag.innerHTML = '<svg width="16" height="16" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 8L40 40" stroke="#FFF" stroke-width="4" stroke-linecap="butt" stroke-linejoin="miter"/><path d="M8 40L40 8" stroke="#FFF" stroke-width="4" stroke-linecap="butt" stroke-linejoin="miter"/></svg>';
|
|
114
|
+
this.dragIcon = this.drag.childNodes[0];
|
|
115
|
+
this.wrap.appendChild(this.drag);
|
|
116
|
+
this.system.id = 'cg-system';
|
|
117
|
+
this.system.addEventListener('contextmenu', function (e) {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
});
|
|
120
|
+
this.wrap.appendChild(this.system);
|
|
121
|
+
this.system.addEventListener('touchmove', function (e) {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
}, {
|
|
124
|
+
'passive': false
|
|
125
|
+
});
|
|
126
|
+
this.simpleSystemtask.id = 'cg-simplesystemtask';
|
|
127
|
+
this.simpleSystemtask.addEventListener('contextmenu', function (e) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
});
|
|
130
|
+
this.wrap.appendChild(this.simpleSystemtask);
|
|
131
|
+
this.simpleSystemtask.addEventListener('touchmove', function (e) {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
}, {
|
|
134
|
+
'passive': false
|
|
135
|
+
});
|
|
136
|
+
const simpleSystemtaskApp = Vue.createApp({
|
|
137
|
+
'template': '<div v-for="(item, formId) of forms" class="cg-simplesystemtask-item" @click="click(parseInt(formId))"><div v-if="item.icon" class="cg-simplesystemtask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',
|
|
138
|
+
'data': function () {
|
|
139
|
+
return {
|
|
140
|
+
'forms': {}
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
'watch': {
|
|
144
|
+
'forms': {
|
|
145
|
+
handler: function () {
|
|
146
|
+
const length = Object.keys(this.forms).length;
|
|
147
|
+
if (length > 0) {
|
|
148
|
+
if (elements.simpleSystemtask.style.bottom !== '0px') {
|
|
149
|
+
elements.simpleSystemtask.style.bottom = '0px';
|
|
150
|
+
core.trigger('screenResize');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (elements.simpleSystemtask.style.bottom === '0px') {
|
|
155
|
+
elements.simpleSystemtask.style.bottom = '-46px';
|
|
156
|
+
core.trigger('screenResize');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
'deep': true
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
'methods': {
|
|
164
|
+
click: function (formId) {
|
|
165
|
+
changeFocus(formId);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
'mounted': function () {
|
|
169
|
+
exports.simpleSystemTaskRoot = this;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
simpleSystemtaskApp.mount('#cg-simplesystemtask');
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
elements.init();
|
|
176
|
+
function changeState(state, formId) {
|
|
177
|
+
if (!formId) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
const tid = getTaskId(formId);
|
|
181
|
+
const t = task.list[tid];
|
|
182
|
+
if (!t) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
switch (state) {
|
|
186
|
+
case 'max': {
|
|
187
|
+
t.forms[formId].vroot.$refs.form.maxMethod();
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case 'min': {
|
|
191
|
+
t.forms[formId].vroot.$refs.form.minMethod();
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
default: {
|
|
195
|
+
remove(formId);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
function min(formId) {
|
|
201
|
+
return changeState('min', formId);
|
|
202
|
+
}
|
|
203
|
+
exports.min = min;
|
|
204
|
+
function max(formId) {
|
|
205
|
+
return changeState('max', formId);
|
|
206
|
+
}
|
|
207
|
+
exports.max = max;
|
|
208
|
+
function close(formId) {
|
|
209
|
+
return changeState('close', formId);
|
|
210
|
+
}
|
|
211
|
+
exports.close = close;
|
|
212
|
+
function bindResize(e, border) {
|
|
213
|
+
const formWrap = dom.findParentByClass(e.target, 'cg-form-wrap');
|
|
214
|
+
if (!formWrap) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const formId = formWrap.dataset.formId;
|
|
218
|
+
if (!formId) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const fid = parseInt(formId);
|
|
222
|
+
const tid = getTaskId(fid);
|
|
223
|
+
const t = task.list[tid];
|
|
224
|
+
if (!t) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
t.forms[fid].vroot.$refs.form.resizeMethod(e, border);
|
|
228
|
+
}
|
|
229
|
+
exports.bindResize = bindResize;
|
|
230
|
+
function bindDrag(e) {
|
|
231
|
+
const formWrap = dom.findParentByClass(e.target, 'cg-form-wrap');
|
|
232
|
+
if (!formWrap) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const formId = formWrap.dataset.formId;
|
|
236
|
+
if (!formId) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const fid = parseInt(formId);
|
|
240
|
+
const tid = getTaskId(fid);
|
|
241
|
+
const t = task.list[tid];
|
|
242
|
+
if (!t) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
t.forms[fid].vroot.$refs.form.moveMethod(e, true);
|
|
246
|
+
}
|
|
247
|
+
exports.bindDrag = bindDrag;
|
|
248
|
+
function refreshMaxPosition() {
|
|
249
|
+
const area = core.getAvailArea();
|
|
250
|
+
for (let i = 0; i < elements.list.children.length; ++i) {
|
|
251
|
+
const el = elements.list.children.item(i);
|
|
252
|
+
const ef = el.children.item(0);
|
|
253
|
+
if (ef.dataset.cgMax === undefined) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
const taskId = parseInt(el.getAttribute('data-task-id'));
|
|
257
|
+
const formId = parseInt(el.getAttribute('data-form-id'));
|
|
258
|
+
if (!task.list[taskId]) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const vroot = task.list[taskId].forms[formId].vroot;
|
|
262
|
+
vroot.$refs.form.setPropData('left', area.left);
|
|
263
|
+
vroot.$refs.form.setPropData('top', area.top);
|
|
264
|
+
vroot.$refs.form.setPropData('width', area.width);
|
|
265
|
+
vroot.$refs.form.setPropData('height', area.height);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.refreshMaxPosition = refreshMaxPosition;
|
|
269
|
+
function getTaskId(formId) {
|
|
270
|
+
const formElement = elements.list.querySelector(`[data-form-id='${formId}']`);
|
|
271
|
+
if (!formElement) {
|
|
272
|
+
return 0;
|
|
273
|
+
}
|
|
274
|
+
const taskIdAttr = formElement.getAttribute('data-task-id');
|
|
275
|
+
if (!taskIdAttr) {
|
|
276
|
+
return 0;
|
|
277
|
+
}
|
|
278
|
+
return parseInt(taskIdAttr);
|
|
279
|
+
}
|
|
280
|
+
exports.getTaskId = getTaskId;
|
|
281
|
+
function get(formId) {
|
|
282
|
+
const taskId = getTaskId(formId);
|
|
283
|
+
if (taskId === 0) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
const item = task.list[taskId].forms[formId];
|
|
287
|
+
return {
|
|
288
|
+
'taskId': taskId,
|
|
289
|
+
'title': item.vroot.$refs.form.title,
|
|
290
|
+
'icon': item.vroot.$refs.form.iconData,
|
|
291
|
+
'stateMax': item.vroot.$refs.form.stateMaxData,
|
|
292
|
+
'stateMin': item.vroot.$refs.form.stateMinData,
|
|
293
|
+
'show': item.vroot.$refs.form.showData,
|
|
294
|
+
'focus': item.vroot.cgFocus
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
exports.get = get;
|
|
298
|
+
function send(formId, obj) {
|
|
299
|
+
const taskId = getTaskId(formId);
|
|
300
|
+
if (taskId === 0) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const item = task.list[taskId].forms[formId];
|
|
304
|
+
if (!item.vroot.cgReceive) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
item.vroot.cgReceive(obj);
|
|
308
|
+
}
|
|
309
|
+
exports.send = send;
|
|
310
|
+
function getList(taskId) {
|
|
311
|
+
if (!task.list[taskId]) {
|
|
312
|
+
return {};
|
|
313
|
+
}
|
|
314
|
+
const list = {};
|
|
315
|
+
for (const fid in task.list[taskId].forms) {
|
|
316
|
+
const item = task.list[taskId].forms[fid];
|
|
317
|
+
list[fid] = {
|
|
318
|
+
'taskId': taskId,
|
|
319
|
+
'title': item.vroot.$refs.form.title,
|
|
320
|
+
'icon': item.vroot.$refs.form.iconData,
|
|
321
|
+
'stateMax': item.vroot.$refs.form.stateMaxData,
|
|
322
|
+
'stateMin': item.vroot.$refs.form.stateMinData,
|
|
323
|
+
'show': item.vroot.$refs.form.showData,
|
|
324
|
+
'focus': item.vroot.cgFocus
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return list;
|
|
328
|
+
}
|
|
329
|
+
exports.getList = getList;
|
|
330
|
+
function changeFocus(formId = 0) {
|
|
331
|
+
var _a, _b;
|
|
332
|
+
if (typeof formId !== 'number') {
|
|
333
|
+
notify({
|
|
334
|
+
'title': 'Warning',
|
|
335
|
+
'content': 'The "formId" of "changeFocus" must be a number type.',
|
|
336
|
+
'type': 'warning'
|
|
337
|
+
});
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const focusElement = document.querySelector('#cg-form-list > [data-cg-focus]');
|
|
341
|
+
if (focusElement) {
|
|
342
|
+
const dataFormId = focusElement.getAttribute('data-form-id');
|
|
343
|
+
if (dataFormId) {
|
|
344
|
+
const dataFormIdNumber = parseInt(dataFormId);
|
|
345
|
+
if (dataFormIdNumber === formId) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
const taskId = parseInt((_a = focusElement.getAttribute('data-task-id')) !== null && _a !== void 0 ? _a : '0');
|
|
350
|
+
const t = task.list[taskId];
|
|
351
|
+
t.forms[dataFormIdNumber].vapp._container.removeAttribute('data-cg-focus');
|
|
352
|
+
t.forms[dataFormIdNumber].vroot._cgFocus = false;
|
|
353
|
+
core.trigger('formBlurred', taskId, dataFormIdNumber);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (formId === 0) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const el = document.querySelector(`#cg-form-list > [data-form-id='${formId}']`);
|
|
364
|
+
if (!el) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (el.children.item(0).dataset.cgMin !== undefined) {
|
|
368
|
+
min(formId);
|
|
369
|
+
}
|
|
370
|
+
const taskId = parseInt((_b = el.getAttribute('data-task-id')) !== null && _b !== void 0 ? _b : '0');
|
|
371
|
+
const t = task.list[taskId];
|
|
372
|
+
if (!t.forms[formId].vroot.cgCustomZIndex) {
|
|
373
|
+
if (t.forms[formId].vroot.cgTopMost) {
|
|
374
|
+
t.forms[formId].vroot.$refs.form.setPropData('zIndex', ++info.topLastZIndex);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
t.forms[formId].vroot.$refs.form.setPropData('zIndex', ++info.lastZIndex);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const maskFor = t.forms[formId].vroot.$refs.form.maskFor;
|
|
381
|
+
if ((typeof maskFor === 'number') && (task.list[taskId].forms[maskFor])) {
|
|
382
|
+
if (get(maskFor).stateMin) {
|
|
383
|
+
min(maskFor);
|
|
384
|
+
}
|
|
385
|
+
if (!task.list[taskId].forms[maskFor].vroot.cgCustomZIndex) {
|
|
386
|
+
if (task.list[taskId].forms[maskFor].vroot.cgTopMost) {
|
|
387
|
+
task.list[taskId].forms[maskFor].vroot.$refs.form.setPropData('zIndex', ++info.topLastZIndex);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
task.list[taskId].forms[maskFor].vroot.$refs.form.setPropData('zIndex', ++info.lastZIndex);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
task.list[taskId].forms[maskFor].vapp._container.dataset.cgFocus = '';
|
|
394
|
+
task.list[taskId].forms[maskFor].vroot._cgFocus = true;
|
|
395
|
+
core.trigger('formFocused', taskId, maskFor);
|
|
396
|
+
clickgo.form.flash(maskFor, taskId);
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
t.forms[formId].vapp._container.dataset.cgFocus = '';
|
|
400
|
+
t.forms[formId].vroot._cgFocus = true;
|
|
401
|
+
core.trigger('formFocused', taskId, formId);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.changeFocus = changeFocus;
|
|
405
|
+
function getMaxZIndexID(out = {}) {
|
|
406
|
+
var _a, _b;
|
|
407
|
+
let zIndex = 0;
|
|
408
|
+
let formId = null;
|
|
409
|
+
for (let i = 0; i < elements.list.children.length; ++i) {
|
|
410
|
+
const formWrap = elements.list.children.item(i);
|
|
411
|
+
const formInner = formWrap.children.item(0);
|
|
412
|
+
const z = parseInt(formInner.style.zIndex);
|
|
413
|
+
if (z > 9999999) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (formInner.dataset.cgMin !== undefined) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
const tid = parseInt(formWrap.getAttribute('data-task-id'));
|
|
420
|
+
if ((_a = out.taskIds) === null || _a === void 0 ? void 0 : _a.includes(tid)) {
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
const fid = parseInt(formWrap.getAttribute('data-form-id'));
|
|
424
|
+
if ((_b = out.formIds) === null || _b === void 0 ? void 0 : _b.includes(fid)) {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (z > zIndex) {
|
|
428
|
+
zIndex = z;
|
|
429
|
+
formId = fid;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return formId;
|
|
433
|
+
}
|
|
434
|
+
exports.getMaxZIndexID = getMaxZIndexID;
|
|
435
|
+
function getRectByBorder(border) {
|
|
436
|
+
var _a, _b, _c, _d;
|
|
437
|
+
const area = core.getAvailArea();
|
|
438
|
+
let width, height, left, top;
|
|
439
|
+
if (typeof border === 'string') {
|
|
440
|
+
switch (border) {
|
|
441
|
+
case 'lt': {
|
|
442
|
+
width = area.width / 2;
|
|
443
|
+
height = area.height / 2;
|
|
444
|
+
left = area.left;
|
|
445
|
+
top = area.top;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
case 't': {
|
|
449
|
+
width = area.width;
|
|
450
|
+
height = area.height;
|
|
451
|
+
left = area.left;
|
|
452
|
+
top = area.top;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case 'tr': {
|
|
456
|
+
width = area.width / 2;
|
|
457
|
+
height = area.height / 2;
|
|
458
|
+
left = area.left + area.width / 2;
|
|
459
|
+
top = area.top;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
case 'r': {
|
|
463
|
+
width = area.width / 2;
|
|
464
|
+
height = area.height;
|
|
465
|
+
left = area.left + area.width / 2;
|
|
466
|
+
top = area.top;
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
case 'rb': {
|
|
470
|
+
width = area.width / 2;
|
|
471
|
+
height = area.height / 2;
|
|
472
|
+
left = area.left + area.width / 2;
|
|
473
|
+
top = area.top + area.height / 2;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
case 'b': {
|
|
477
|
+
width = area.width;
|
|
478
|
+
height = area.height / 2;
|
|
479
|
+
left = area.left;
|
|
480
|
+
top = area.top + area.height / 2;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
case 'bl': {
|
|
484
|
+
width = area.width / 2;
|
|
485
|
+
height = area.height / 2;
|
|
486
|
+
left = area.left;
|
|
487
|
+
top = area.top + area.height / 2;
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
case 'l': {
|
|
491
|
+
width = area.width / 2;
|
|
492
|
+
height = area.height;
|
|
493
|
+
left = area.left;
|
|
494
|
+
top = area.top;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
default: {
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
width = (_a = border.width) !== null && _a !== void 0 ? _a : area.width;
|
|
504
|
+
height = (_b = border.height) !== null && _b !== void 0 ? _b : area.height;
|
|
505
|
+
left = (_c = border.left) !== null && _c !== void 0 ? _c : area.left;
|
|
506
|
+
top = (_d = border.top) !== null && _d !== void 0 ? _d : area.top;
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
'width': width,
|
|
510
|
+
'height': height,
|
|
511
|
+
'left': left,
|
|
512
|
+
'top': top
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
exports.getRectByBorder = getRectByBorder;
|
|
516
|
+
function showCircular(x, y) {
|
|
517
|
+
elements.circular.style.transition = 'none';
|
|
518
|
+
requestAnimationFrame(function () {
|
|
519
|
+
elements.circular.style.width = '6px';
|
|
520
|
+
elements.circular.style.height = '6px';
|
|
521
|
+
elements.circular.style.left = (x - 3).toString() + 'px';
|
|
522
|
+
elements.circular.style.top = (y - 3).toString() + 'px';
|
|
523
|
+
elements.circular.style.opacity = '1';
|
|
524
|
+
requestAnimationFrame(function () {
|
|
525
|
+
elements.circular.style.transition = 'all .3s ease-out';
|
|
526
|
+
requestAnimationFrame(function () {
|
|
527
|
+
elements.circular.style.width = '60px';
|
|
528
|
+
elements.circular.style.height = '60px';
|
|
529
|
+
elements.circular.style.left = (x - 30).toString() + 'px';
|
|
530
|
+
elements.circular.style.top = (y - 30).toString() + 'px';
|
|
531
|
+
elements.circular.style.opacity = '0';
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
exports.showCircular = showCircular;
|
|
537
|
+
function moveRectangle(border) {
|
|
538
|
+
var _a, _b, _c, _d;
|
|
539
|
+
const dataReady = (_a = elements.rectangle.getAttribute('data-ready')) !== null && _a !== void 0 ? _a : '0';
|
|
540
|
+
if (dataReady === '0') {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const dataBorder = (_b = elements.rectangle.getAttribute('data-border')) !== null && _b !== void 0 ? _b : '';
|
|
544
|
+
const setDataBorder = typeof border === 'string' ? border : `o-${border.left}-${(_c = border.top) !== null && _c !== void 0 ? _c : 'n'}-${border.width}-${(_d = border.height) !== null && _d !== void 0 ? _d : 'n'}`;
|
|
545
|
+
if (dataBorder === setDataBorder) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
elements.rectangle.setAttribute('data-dir', setDataBorder);
|
|
549
|
+
const pos = getRectByBorder(border);
|
|
550
|
+
const width = pos.width - 20;
|
|
551
|
+
const height = pos.height - 20;
|
|
552
|
+
const left = pos.left + 10;
|
|
553
|
+
const top = pos.top + 10;
|
|
554
|
+
if (width !== undefined && height !== undefined && left !== undefined && top !== undefined) {
|
|
555
|
+
elements.rectangle.style.width = width.toString() + 'px';
|
|
556
|
+
elements.rectangle.style.height = height.toString() + 'px';
|
|
557
|
+
elements.rectangle.style.left = left.toString() + 'px';
|
|
558
|
+
elements.rectangle.style.top = top.toString() + 'px';
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
exports.moveRectangle = moveRectangle;
|
|
562
|
+
function showRectangle(x, y, border) {
|
|
563
|
+
elements.rectangle.style.transition = 'none';
|
|
564
|
+
requestAnimationFrame(function () {
|
|
565
|
+
elements.rectangle.style.width = '5px';
|
|
566
|
+
elements.rectangle.style.height = '5px';
|
|
567
|
+
elements.rectangle.style.left = (x - 10).toString() + 'px';
|
|
568
|
+
elements.rectangle.style.top = (y - 10).toString() + 'px';
|
|
569
|
+
elements.rectangle.style.opacity = '1';
|
|
570
|
+
elements.rectangle.setAttribute('data-ready', '0');
|
|
571
|
+
elements.rectangle.setAttribute('data-dir', '');
|
|
572
|
+
requestAnimationFrame(function () {
|
|
573
|
+
elements.rectangle.style.transition = 'all .2s ease-out';
|
|
574
|
+
requestAnimationFrame(function () {
|
|
575
|
+
elements.rectangle.setAttribute('data-ready', '1');
|
|
576
|
+
moveRectangle(border);
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
exports.showRectangle = showRectangle;
|
|
582
|
+
function hideRectangle() {
|
|
583
|
+
elements.rectangle.style.opacity = '0';
|
|
584
|
+
}
|
|
585
|
+
exports.hideRectangle = hideRectangle;
|
|
586
|
+
function showDrag() {
|
|
587
|
+
elements.drag.style.opacity = '1';
|
|
588
|
+
}
|
|
589
|
+
exports.showDrag = showDrag;
|
|
590
|
+
function moveDrag(opt) {
|
|
591
|
+
if (opt.top) {
|
|
592
|
+
elements.drag.style.top = opt.top.toString() + 'px';
|
|
593
|
+
}
|
|
594
|
+
if (opt.left) {
|
|
595
|
+
elements.drag.style.left = opt.left.toString() + 'px';
|
|
596
|
+
}
|
|
597
|
+
if (opt.width) {
|
|
598
|
+
elements.drag.style.width = opt.width.toString() + 'px';
|
|
599
|
+
}
|
|
600
|
+
if (opt.height) {
|
|
601
|
+
elements.drag.style.height = opt.height.toString() + 'px';
|
|
602
|
+
}
|
|
603
|
+
if (opt.icon) {
|
|
604
|
+
if (elements.dragIcon) {
|
|
605
|
+
elements.dragIcon.style.display = 'block';
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
if (elements.dragIcon) {
|
|
610
|
+
elements.dragIcon.style.display = 'none';
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
exports.moveDrag = moveDrag;
|
|
615
|
+
function hideDrag() {
|
|
616
|
+
elements.drag.style.opacity = '0';
|
|
617
|
+
}
|
|
618
|
+
exports.hideDrag = hideDrag;
|
|
619
|
+
let notifyTop = 10;
|
|
620
|
+
let notifyId = 0;
|
|
621
|
+
function notify(opt) {
|
|
622
|
+
var _a;
|
|
623
|
+
const nid = ++notifyId;
|
|
624
|
+
let timeout = 5000;
|
|
625
|
+
if (opt.timeout !== undefined) {
|
|
626
|
+
if (opt.timeout <= 0 || opt.timeout > 30000) {
|
|
627
|
+
timeout = 30000;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
timeout = opt.timeout;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
if (opt.progress && !opt.type) {
|
|
634
|
+
opt.type = 'progress';
|
|
635
|
+
}
|
|
636
|
+
const el = document.createElement('div');
|
|
637
|
+
const y = notifyTop;
|
|
638
|
+
el.classList.add('cg-system-notify');
|
|
639
|
+
el.setAttribute('data-notifyid', nid.toString());
|
|
640
|
+
el.style.transform = `translateY(${y}px) translateX(280px)`;
|
|
641
|
+
el.style.opacity = '1';
|
|
642
|
+
el.innerHTML = `<div class="cg-system-icon cg-${tool.escapeHTML((_a = opt.type) !== null && _a !== void 0 ? _a : 'primary')}"></div>
|
|
643
|
+
<div style="flex: 1;">
|
|
644
|
+
<div class="cg-system-notify-title">${tool.escapeHTML(opt.title)}</div>
|
|
645
|
+
<div class="cg-system-notify-content">${tool.escapeHTML(opt.content).replace(/\r\n/g, '\n').replace(/\r/g, '\n').replace(/\n/g, '<br>')}</div>
|
|
646
|
+
${opt.progress ? '<div class="cg-system-notify-progress"></div>' : ''}
|
|
647
|
+
</div>`;
|
|
648
|
+
if (opt.icon) {
|
|
649
|
+
el.childNodes.item(0).style.background = 'url(' + opt.icon + ')';
|
|
650
|
+
el.childNodes.item(0).style.backgroundSize = '16px';
|
|
651
|
+
}
|
|
652
|
+
elements.system.appendChild(el);
|
|
653
|
+
notifyTop += el.offsetHeight + 10;
|
|
654
|
+
requestAnimationFrame(function () {
|
|
655
|
+
el.style.transform = `translateY(${y}px) translateX(-10px)`;
|
|
656
|
+
const timer = window.setTimeout(function () {
|
|
657
|
+
hideNotify(nid);
|
|
658
|
+
}, timeout);
|
|
659
|
+
el.setAttribute('data-timer', timer.toString());
|
|
660
|
+
});
|
|
661
|
+
return nid;
|
|
662
|
+
}
|
|
663
|
+
exports.notify = notify;
|
|
664
|
+
function notifyProgress(notifyId, per) {
|
|
665
|
+
const el = elements.system.querySelector(`[data-notifyid="${notifyId}"]`);
|
|
666
|
+
if (!el) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const progress = el.querySelector('.cg-system-notify-progress');
|
|
670
|
+
if (!progress) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (per > 100) {
|
|
674
|
+
per = 100;
|
|
675
|
+
}
|
|
676
|
+
if (per === 1) {
|
|
677
|
+
const o = parseFloat(progress.style.width);
|
|
678
|
+
if (o > 1) {
|
|
679
|
+
per = 100;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
if (per === 100) {
|
|
683
|
+
progress.style.transitionDelay = '.1s';
|
|
684
|
+
}
|
|
685
|
+
progress.style.width = (per < 1 ? per * 100 : per).toString() + '%';
|
|
686
|
+
}
|
|
687
|
+
exports.notifyProgress = notifyProgress;
|
|
688
|
+
function hideNotify(notifyId) {
|
|
689
|
+
const el = elements.system.querySelector(`[data-notifyid="${notifyId}"]`);
|
|
690
|
+
if (!el) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
clearTimeout(parseInt(el.getAttribute('data-timer')));
|
|
694
|
+
const notifyHeight = el.offsetHeight;
|
|
695
|
+
el.style.opacity = '0';
|
|
696
|
+
setTimeout(function () {
|
|
697
|
+
notifyTop -= notifyHeight + 10;
|
|
698
|
+
const notifyElementList = document.getElementsByClassName('cg-system-notify');
|
|
699
|
+
let needSub = false;
|
|
700
|
+
for (const notifyElement of notifyElementList) {
|
|
701
|
+
if (notifyElement === el) {
|
|
702
|
+
needSub = true;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
if (needSub) {
|
|
706
|
+
notifyElement.style.transform = notifyElement.style.transform.replace(/translateY\(([0-9]+)px\)/, function (t, t1) {
|
|
707
|
+
return `translateY(${parseInt(t1) - notifyHeight - 10}px)`;
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
el.remove();
|
|
712
|
+
}, 100);
|
|
713
|
+
}
|
|
714
|
+
exports.hideNotify = hideNotify;
|
|
715
|
+
function appendToPop(el) {
|
|
716
|
+
elements.popList.appendChild(el);
|
|
717
|
+
}
|
|
718
|
+
exports.appendToPop = appendToPop;
|
|
719
|
+
function removeFromPop(el) {
|
|
720
|
+
elements.popList.removeChild(el);
|
|
721
|
+
}
|
|
722
|
+
exports.removeFromPop = removeFromPop;
|
|
723
|
+
let lastShowPopTime = 0;
|
|
724
|
+
function showPop(el, pop, direction, opt = {}) {
|
|
725
|
+
var _a, _b;
|
|
726
|
+
if (opt.null === undefined) {
|
|
727
|
+
opt.null = false;
|
|
728
|
+
}
|
|
729
|
+
if (opt.size === undefined) {
|
|
730
|
+
opt.size = {};
|
|
731
|
+
}
|
|
732
|
+
if (!pop && !opt.null) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
const now = Date.now();
|
|
736
|
+
if (now - lastShowPopTime < 5) {
|
|
737
|
+
lastShowPopTime = now;
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
lastShowPopTime = now;
|
|
741
|
+
if (el.dataset.cgPopOpen !== undefined) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
const parentPop = dom.findParentByData(el, 'cg-pop');
|
|
745
|
+
if (parentPop) {
|
|
746
|
+
for (let i = 0; i < popInfo.list.length; ++i) {
|
|
747
|
+
if (popInfo.list[i] !== parentPop) {
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
if (!popInfo.elList[i + 1]) {
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
hidePop(popInfo.elList[i + 1]);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
hidePop();
|
|
758
|
+
}
|
|
759
|
+
if (!pop) {
|
|
760
|
+
popInfo.elList.push(el);
|
|
761
|
+
el.dataset.cgPopOpen = '';
|
|
762
|
+
el.dataset.cgLevel = (popInfo.elList.length - 1).toString();
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
const width = (_a = opt.size.width) !== null && _a !== void 0 ? _a : (pop ? pop.offsetWidth : 0);
|
|
766
|
+
const height = (_b = opt.size.height) !== null && _b !== void 0 ? _b : (pop ? pop.offsetHeight : 0);
|
|
767
|
+
let left, top;
|
|
768
|
+
if (typeof direction === 'string') {
|
|
769
|
+
const bcr = el.getBoundingClientRect();
|
|
770
|
+
if (direction === 'v') {
|
|
771
|
+
left = bcr.left;
|
|
772
|
+
top = bcr.top + bcr.height;
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
left = bcr.left + bcr.width - 2;
|
|
776
|
+
top = bcr.top - 2;
|
|
777
|
+
}
|
|
778
|
+
if (width + left > document.body.clientWidth) {
|
|
779
|
+
if (direction === 'v') {
|
|
780
|
+
left = bcr.left + bcr.width - width;
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
left = bcr.left - width + 2;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (height + top > document.body.clientHeight) {
|
|
787
|
+
if (direction === 'v') {
|
|
788
|
+
top = bcr.top - height;
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
top = bcr.top + bcr.height - height + 2;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
let x;
|
|
797
|
+
let y;
|
|
798
|
+
if (direction instanceof MouseEvent) {
|
|
799
|
+
x = direction.clientX;
|
|
800
|
+
y = direction.clientY;
|
|
801
|
+
}
|
|
802
|
+
else if (direction instanceof TouchEvent) {
|
|
803
|
+
x = direction.touches[0].clientX;
|
|
804
|
+
y = direction.touches[0].clientY;
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
x = direction.x;
|
|
808
|
+
y = direction.y;
|
|
809
|
+
}
|
|
810
|
+
left = x + 5;
|
|
811
|
+
top = y + 7;
|
|
812
|
+
if (width + left > document.body.clientWidth) {
|
|
813
|
+
left = x - width - 5;
|
|
814
|
+
}
|
|
815
|
+
if (height + top > document.body.clientHeight) {
|
|
816
|
+
top = y - height - 5;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (left < 0) {
|
|
820
|
+
left = 0;
|
|
821
|
+
}
|
|
822
|
+
if (top < 0) {
|
|
823
|
+
top = 0;
|
|
824
|
+
}
|
|
825
|
+
pop.style.left = left.toString() + 'px';
|
|
826
|
+
pop.style.top = top.toString() + 'px';
|
|
827
|
+
pop.style.zIndex = (++popInfo.lastZIndex).toString();
|
|
828
|
+
if (opt.size.width) {
|
|
829
|
+
pop.style.width = opt.size.width.toString() + 'px';
|
|
830
|
+
}
|
|
831
|
+
if (opt.size.height) {
|
|
832
|
+
pop.style.height = opt.size.height.toString() + 'px';
|
|
833
|
+
}
|
|
834
|
+
popInfo.list.push(pop);
|
|
835
|
+
popInfo.elList.push(el);
|
|
836
|
+
pop.dataset.cgOpen = '';
|
|
837
|
+
pop.dataset.cgLevel = (popInfo.list.length - 1).toString();
|
|
838
|
+
el.dataset.cgPopOpen = '';
|
|
839
|
+
el.dataset.cgLevel = (popInfo.elList.length - 1).toString();
|
|
840
|
+
}
|
|
841
|
+
exports.showPop = showPop;
|
|
842
|
+
function hidePop(pop) {
|
|
843
|
+
if (!pop) {
|
|
844
|
+
if (popInfo.elList.length === 0) {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
hidePop(popInfo.elList[0]);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
let isPop = false;
|
|
851
|
+
if (pop.dataset.cgPopOpen !== undefined) {
|
|
852
|
+
}
|
|
853
|
+
else if (pop.dataset.cgOpen !== undefined) {
|
|
854
|
+
isPop = true;
|
|
855
|
+
}
|
|
856
|
+
else {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const level = pop.dataset.cgLevel ? parseInt(pop.dataset.cgLevel) : -1;
|
|
860
|
+
if (level === -1) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
if (popInfo.elList[level + 1]) {
|
|
864
|
+
hidePop(popInfo.elList[level + 1]);
|
|
865
|
+
}
|
|
866
|
+
if (isPop) {
|
|
867
|
+
pop.removeAttribute('data-cg-open');
|
|
868
|
+
pop.removeAttribute('data-cg-level');
|
|
869
|
+
popInfo.elList[level].removeAttribute('data-cg-pop-open');
|
|
870
|
+
popInfo.elList[level].removeAttribute('data-cg-level');
|
|
871
|
+
}
|
|
872
|
+
else {
|
|
873
|
+
if (popInfo.list[level]) {
|
|
874
|
+
popInfo.list[level].removeAttribute('data-cg-open');
|
|
875
|
+
popInfo.list[level].removeAttribute('data-cg-level');
|
|
876
|
+
}
|
|
877
|
+
pop.removeAttribute('data-cg-pop-open');
|
|
878
|
+
pop.removeAttribute('data-cg-level');
|
|
879
|
+
}
|
|
880
|
+
popInfo.list.splice(level);
|
|
881
|
+
popInfo.elList.splice(level);
|
|
882
|
+
}
|
|
883
|
+
exports.hidePop = hidePop;
|
|
884
|
+
function doFocusAndPopEvent(e) {
|
|
885
|
+
var _a, _b;
|
|
886
|
+
if (dom.hasTouchButMouse(e)) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const target = e.target;
|
|
890
|
+
if (!target) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
const element = target;
|
|
894
|
+
if (element.dataset.cgPopOpen !== undefined) {
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const paths = (_a = e.path) !== null && _a !== void 0 ? _a : (e.composedPath ? e.composedPath() : []);
|
|
898
|
+
for (const item of paths) {
|
|
899
|
+
if (!item.tagName) {
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
if (item.tagName.toLowerCase() === 'body') {
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
if (item.id === 'cg-pop-list') {
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
if (item.dataset.cgPopOpen !== undefined) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
for (const item of paths) {
|
|
913
|
+
if (!item.tagName) {
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
if (item.tagName.toLowerCase() === 'body') {
|
|
917
|
+
break;
|
|
918
|
+
}
|
|
919
|
+
if (item.classList.contains('cg-form-wrap')) {
|
|
920
|
+
const formId = parseInt((_b = item.getAttribute('data-form-id')) !== null && _b !== void 0 ? _b : '0');
|
|
921
|
+
changeFocus(formId);
|
|
922
|
+
hidePop();
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
hidePop();
|
|
927
|
+
changeFocus();
|
|
928
|
+
}
|
|
929
|
+
exports.doFocusAndPopEvent = doFocusAndPopEvent;
|
|
930
|
+
window.addEventListener('touchstart', doFocusAndPopEvent, {
|
|
931
|
+
'passive': true
|
|
932
|
+
});
|
|
933
|
+
window.addEventListener('mousedown', doFocusAndPopEvent);
|
|
934
|
+
function remove(formId) {
|
|
935
|
+
const taskId = getTaskId(formId);
|
|
936
|
+
let title = '';
|
|
937
|
+
let icon = '';
|
|
938
|
+
if (task.list[taskId].forms[formId]) {
|
|
939
|
+
title = task.list[taskId].forms[formId].vroot.$refs.form.title;
|
|
940
|
+
icon = task.list[taskId].forms[formId].vroot.$refs.form.iconData;
|
|
941
|
+
if (task.list[taskId].forms[formId].vroot.$refs.form.maskFrom !== undefined) {
|
|
942
|
+
const fid = task.list[taskId].forms[formId].vroot.$refs.form.maskFrom;
|
|
943
|
+
task.list[taskId].forms[fid].vroot.$refs.form.maskFor = undefined;
|
|
944
|
+
}
|
|
945
|
+
task.list[taskId].forms[formId].vroot.$refs.form.$data.showData = false;
|
|
946
|
+
setTimeout(function () {
|
|
947
|
+
const fid = getMaxZIndexID({
|
|
948
|
+
'formIds': [formId]
|
|
949
|
+
});
|
|
950
|
+
if (fid) {
|
|
951
|
+
changeFocus(fid);
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
changeFocus();
|
|
955
|
+
}
|
|
956
|
+
if (!task.list[taskId]) {
|
|
957
|
+
return true;
|
|
958
|
+
}
|
|
959
|
+
task.list[taskId].forms[formId].vapp.unmount();
|
|
960
|
+
task.list[taskId].forms[formId].vapp._container.remove();
|
|
961
|
+
delete task.list[taskId].forms[formId];
|
|
962
|
+
dom.removeStyle(taskId, 'form', formId);
|
|
963
|
+
core.trigger('formRemoved', taskId, formId, title, icon);
|
|
964
|
+
if (Object.keys(task.list[taskId].forms).length === 0) {
|
|
965
|
+
task.end(taskId);
|
|
966
|
+
}
|
|
967
|
+
}, 100);
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
exports.remove = remove;
|
|
975
|
+
function getForm(taskId, formId) {
|
|
976
|
+
if (!taskId) {
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
const t = task.list[taskId];
|
|
980
|
+
if (!t) {
|
|
981
|
+
return null;
|
|
982
|
+
}
|
|
983
|
+
if (!formId) {
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
const form = t.forms[formId];
|
|
987
|
+
if (!form) {
|
|
988
|
+
return null;
|
|
989
|
+
}
|
|
990
|
+
return form;
|
|
991
|
+
}
|
|
992
|
+
function create(opt) {
|
|
993
|
+
var _a, _b, _c, _d;
|
|
994
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
995
|
+
if (typeof opt === 'string') {
|
|
996
|
+
return 0;
|
|
997
|
+
}
|
|
998
|
+
if (!opt.taskId) {
|
|
999
|
+
return -1;
|
|
1000
|
+
}
|
|
1001
|
+
if (opt.path && (!opt.path.endsWith('/') || !((_a = opt.path) === null || _a === void 0 ? void 0 : _a.startsWith('/')))) {
|
|
1002
|
+
return -2;
|
|
1003
|
+
}
|
|
1004
|
+
const taskId = opt.taskId;
|
|
1005
|
+
const t = task.list[taskId];
|
|
1006
|
+
if (!t) {
|
|
1007
|
+
return -3;
|
|
1008
|
+
}
|
|
1009
|
+
let form = null;
|
|
1010
|
+
if (opt.formId) {
|
|
1011
|
+
if (!t.forms[opt.formId]) {
|
|
1012
|
+
return -4;
|
|
1013
|
+
}
|
|
1014
|
+
form = t.forms[opt.formId];
|
|
1015
|
+
}
|
|
1016
|
+
let topMost = (_b = opt.topMost) !== null && _b !== void 0 ? _b : false;
|
|
1017
|
+
if (form === null || form === void 0 ? void 0 : form.vroot.cgTopMost) {
|
|
1018
|
+
topMost = true;
|
|
1019
|
+
}
|
|
1020
|
+
if (opt.mask && form) {
|
|
1021
|
+
form.vroot.$refs.form.maskFor = 0;
|
|
1022
|
+
}
|
|
1023
|
+
const base = form ? form.vroot.cgPath : '/';
|
|
1024
|
+
let filePath = '', newBase = '';
|
|
1025
|
+
if (opt.file) {
|
|
1026
|
+
filePath = clickgo.tool.urlResolve(base, opt.file);
|
|
1027
|
+
newBase = filePath.slice(0, filePath.lastIndexOf('/') + 1);
|
|
1028
|
+
}
|
|
1029
|
+
else {
|
|
1030
|
+
newBase = (_c = opt.path) !== null && _c !== void 0 ? _c : base;
|
|
1031
|
+
}
|
|
1032
|
+
const app = t.app;
|
|
1033
|
+
const formId = ++info.lastId;
|
|
1034
|
+
const invoke = {};
|
|
1035
|
+
if (clickgo.getSafe()) {
|
|
1036
|
+
invoke.window = undefined;
|
|
1037
|
+
invoke.loader = undefined;
|
|
1038
|
+
const ks = Object.getOwnPropertyNames(window);
|
|
1039
|
+
for (const k of ks) {
|
|
1040
|
+
if (k.includes('Event')) {
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
if (k.includes('-')) {
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
if (/^[0-9]+$/.test(k)) {
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
if ([
|
|
1050
|
+
'require',
|
|
1051
|
+
'__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch'
|
|
1052
|
+
].includes(k)) {
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
invoke[k] = undefined;
|
|
1056
|
+
}
|
|
1057
|
+
invoke.console = {
|
|
1058
|
+
log: function (message, ...optionalParams) {
|
|
1059
|
+
console.log(message, ...optionalParams);
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
invoke.loader = {
|
|
1063
|
+
require: function (paths, files, opt) {
|
|
1064
|
+
return loader.require(paths, files, opt);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
invoke.Object = {
|
|
1068
|
+
defineProperty: function () {
|
|
1069
|
+
return;
|
|
1070
|
+
},
|
|
1071
|
+
keys: function (o) {
|
|
1072
|
+
return Object.keys(o);
|
|
1073
|
+
},
|
|
1074
|
+
assign: function (o, o2) {
|
|
1075
|
+
if (o.controlName !== undefined) {
|
|
1076
|
+
return o;
|
|
1077
|
+
}
|
|
1078
|
+
return Object.assign(o, o2);
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
invoke.navigator = {};
|
|
1082
|
+
if (navigator.clipboard) {
|
|
1083
|
+
invoke.navigator.clipboard = navigator.clipboard;
|
|
1084
|
+
}
|
|
1085
|
+
invoke.invokeClickgo = {
|
|
1086
|
+
getVersion: function () {
|
|
1087
|
+
return clickgo.getVersion();
|
|
1088
|
+
},
|
|
1089
|
+
getNative() {
|
|
1090
|
+
return clickgo.getNative();
|
|
1091
|
+
},
|
|
1092
|
+
getSafe() {
|
|
1093
|
+
return clickgo.getSafe();
|
|
1094
|
+
},
|
|
1095
|
+
getCdn() {
|
|
1096
|
+
return clickgo.getCdn();
|
|
1097
|
+
},
|
|
1098
|
+
'control': {
|
|
1099
|
+
read: function (blob) {
|
|
1100
|
+
return clickgo.control.read(blob);
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
'core': {
|
|
1104
|
+
'config': clickgo.core.config,
|
|
1105
|
+
initModules: function (names) {
|
|
1106
|
+
return clickgo.core.initModules(names);
|
|
1107
|
+
},
|
|
1108
|
+
getModule: function (name) {
|
|
1109
|
+
return clickgo.core.getModule(name);
|
|
1110
|
+
},
|
|
1111
|
+
setSystemEventListener: function (name, func, fid) {
|
|
1112
|
+
clickgo.core.setSystemEventListener(name, func, fid !== null && fid !== void 0 ? fid : formId, taskId);
|
|
1113
|
+
},
|
|
1114
|
+
removeSystemEventListener: function (name, fid) {
|
|
1115
|
+
clickgo.core.removeSystemEventListener(name, fid !== null && fid !== void 0 ? fid : formId, taskId);
|
|
1116
|
+
},
|
|
1117
|
+
trigger: function (name, param1 = '', param2 = '') {
|
|
1118
|
+
if (!['formTitleChanged', 'formIconChanged', 'formStateMinChanged', 'formStateMaxChanged', 'formShowChanged'].includes(name)) {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
clickgo.core.trigger(name, taskId, formId, param1, param2);
|
|
1122
|
+
},
|
|
1123
|
+
readApp: function (blob) {
|
|
1124
|
+
return clickgo.core.readApp(blob);
|
|
1125
|
+
},
|
|
1126
|
+
getAvailArea: function () {
|
|
1127
|
+
return clickgo.core.getAvailArea();
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
'dom': {
|
|
1131
|
+
setGlobalCursor: function (type) {
|
|
1132
|
+
clickgo.dom.setGlobalCursor(type);
|
|
1133
|
+
},
|
|
1134
|
+
hasTouchButMouse: function (e) {
|
|
1135
|
+
return clickgo.dom.hasTouchButMouse(e);
|
|
1136
|
+
},
|
|
1137
|
+
getStyleCount: function (taskId, type) {
|
|
1138
|
+
return clickgo.dom.getStyleCount(taskId, type);
|
|
1139
|
+
},
|
|
1140
|
+
getSize: function (el) {
|
|
1141
|
+
return clickgo.dom.getSize(el);
|
|
1142
|
+
},
|
|
1143
|
+
watchSize: function (el, cb, immediate = false) {
|
|
1144
|
+
return clickgo.dom.watchSize(el, cb, immediate, taskId);
|
|
1145
|
+
},
|
|
1146
|
+
unwatchSize: function (el) {
|
|
1147
|
+
clickgo.dom.unwatchSize(el, taskId);
|
|
1148
|
+
},
|
|
1149
|
+
clearWatchSize() {
|
|
1150
|
+
clickgo.dom.clearWatchSize(taskId);
|
|
1151
|
+
},
|
|
1152
|
+
watch: function (el, cb, mode = 'default', immediate = false) {
|
|
1153
|
+
clickgo.dom.watch(el, cb, mode, immediate, taskId);
|
|
1154
|
+
},
|
|
1155
|
+
unwatch: function (el) {
|
|
1156
|
+
clickgo.dom.unwatch(el, taskId);
|
|
1157
|
+
},
|
|
1158
|
+
clearWatch: function () {
|
|
1159
|
+
clickgo.dom.clearWatch(taskId);
|
|
1160
|
+
},
|
|
1161
|
+
watchStyle: function (el, name, cb, immediate = false) {
|
|
1162
|
+
clickgo.dom.watchStyle(el, name, cb, immediate);
|
|
1163
|
+
},
|
|
1164
|
+
isWatchStyle: function (el) {
|
|
1165
|
+
return clickgo.dom.isWatchStyle(el);
|
|
1166
|
+
},
|
|
1167
|
+
bindDown: function (oe, opt) {
|
|
1168
|
+
clickgo.dom.bindDown(oe, opt);
|
|
1169
|
+
},
|
|
1170
|
+
bindGesture: function (e, opt) {
|
|
1171
|
+
clickgo.dom.bindGesture(e, opt);
|
|
1172
|
+
},
|
|
1173
|
+
bindLong: function (e, long) {
|
|
1174
|
+
clickgo.dom.bindLong(e, long);
|
|
1175
|
+
},
|
|
1176
|
+
bindDrag: function (e, opt) {
|
|
1177
|
+
clickgo.dom.bindDrag(e, opt);
|
|
1178
|
+
},
|
|
1179
|
+
'is': clickgo.dom.is,
|
|
1180
|
+
bindMove: function (e, opt) {
|
|
1181
|
+
return clickgo.dom.bindMove(e, opt);
|
|
1182
|
+
},
|
|
1183
|
+
bindResize: function (e, opt) {
|
|
1184
|
+
clickgo.dom.bindResize(e, opt);
|
|
1185
|
+
},
|
|
1186
|
+
findParentByData: function (el, name) {
|
|
1187
|
+
return clickgo.dom.findParentByData(el, name);
|
|
1188
|
+
},
|
|
1189
|
+
findParentByClass: function (el, name) {
|
|
1190
|
+
return clickgo.dom.findParentByClass(el, name);
|
|
1191
|
+
},
|
|
1192
|
+
siblings: function (el) {
|
|
1193
|
+
return clickgo.dom.siblings(el);
|
|
1194
|
+
},
|
|
1195
|
+
siblingsData: function (el, name) {
|
|
1196
|
+
return clickgo.dom.siblingsData(el, name);
|
|
1197
|
+
},
|
|
1198
|
+
fullscreen: function () {
|
|
1199
|
+
return clickgo.dom.fullscreen();
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
'form': {
|
|
1203
|
+
min: function (fid) {
|
|
1204
|
+
return clickgo.form.min(fid !== null && fid !== void 0 ? fid : formId);
|
|
1205
|
+
},
|
|
1206
|
+
max: function max(fid) {
|
|
1207
|
+
return clickgo.form.max(fid !== null && fid !== void 0 ? fid : formId);
|
|
1208
|
+
},
|
|
1209
|
+
close: function (fid) {
|
|
1210
|
+
return clickgo.form.close(fid !== null && fid !== void 0 ? fid : formId);
|
|
1211
|
+
},
|
|
1212
|
+
bindResize: function (e, border) {
|
|
1213
|
+
clickgo.form.bindResize(e, border);
|
|
1214
|
+
},
|
|
1215
|
+
bindDrag: function (e) {
|
|
1216
|
+
clickgo.form.bindDrag(e);
|
|
1217
|
+
},
|
|
1218
|
+
getTaskId: function (fid) {
|
|
1219
|
+
return clickgo.form.getTaskId(fid);
|
|
1220
|
+
},
|
|
1221
|
+
get: function (fid) {
|
|
1222
|
+
return clickgo.form.get(fid);
|
|
1223
|
+
},
|
|
1224
|
+
send: function (fid, obj) {
|
|
1225
|
+
obj.taskId = taskId;
|
|
1226
|
+
obj.formId = formId;
|
|
1227
|
+
clickgo.form.send(fid, obj);
|
|
1228
|
+
},
|
|
1229
|
+
getList: function (tid) {
|
|
1230
|
+
return clickgo.form.getList(tid);
|
|
1231
|
+
},
|
|
1232
|
+
changeFocus: function (fid = 0) {
|
|
1233
|
+
clickgo.form.changeFocus(fid);
|
|
1234
|
+
},
|
|
1235
|
+
getMaxZIndexID: function (out) {
|
|
1236
|
+
return clickgo.form.getMaxZIndexID(out);
|
|
1237
|
+
},
|
|
1238
|
+
getRectByBorder: function (border) {
|
|
1239
|
+
return clickgo.form.getRectByBorder(border);
|
|
1240
|
+
},
|
|
1241
|
+
showCircular: function (x, y) {
|
|
1242
|
+
clickgo.form.showCircular(x, y);
|
|
1243
|
+
},
|
|
1244
|
+
moveRectangle: function (border) {
|
|
1245
|
+
clickgo.form.moveRectangle(border);
|
|
1246
|
+
},
|
|
1247
|
+
showRectangle: function (x, y, border) {
|
|
1248
|
+
clickgo.form.showRectangle(x, y, border);
|
|
1249
|
+
},
|
|
1250
|
+
hideRectangle: function () {
|
|
1251
|
+
clickgo.form.hideRectangle();
|
|
1252
|
+
},
|
|
1253
|
+
showDrag: function () {
|
|
1254
|
+
clickgo.form.showDrag();
|
|
1255
|
+
},
|
|
1256
|
+
moveDrag: function (opt) {
|
|
1257
|
+
clickgo.form.moveDrag(opt);
|
|
1258
|
+
},
|
|
1259
|
+
hideDrag: function () {
|
|
1260
|
+
clickgo.form.hideDrag();
|
|
1261
|
+
},
|
|
1262
|
+
notify: function (opt) {
|
|
1263
|
+
return clickgo.form.notify(opt);
|
|
1264
|
+
},
|
|
1265
|
+
notifyProgress: function (notifyId, per) {
|
|
1266
|
+
clickgo.form.notifyProgress(notifyId, per);
|
|
1267
|
+
},
|
|
1268
|
+
hideNotify: function (notifyId) {
|
|
1269
|
+
clickgo.form.hideNotify(notifyId);
|
|
1270
|
+
},
|
|
1271
|
+
showPop: function (el, pop, direction, opt = {}) {
|
|
1272
|
+
clickgo.form.showPop(el, pop, direction, opt);
|
|
1273
|
+
},
|
|
1274
|
+
hidePop: function (pop) {
|
|
1275
|
+
clickgo.form.hidePop(pop);
|
|
1276
|
+
},
|
|
1277
|
+
create: function (opt) {
|
|
1278
|
+
if (typeof opt === 'string') {
|
|
1279
|
+
opt = {
|
|
1280
|
+
'file': opt
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
opt.taskId = taskId;
|
|
1284
|
+
opt.formId = formId;
|
|
1285
|
+
return clickgo.form.create(opt);
|
|
1286
|
+
},
|
|
1287
|
+
dialog: function (opt) {
|
|
1288
|
+
if (typeof opt === 'string') {
|
|
1289
|
+
opt = {
|
|
1290
|
+
'content': opt
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
opt.formId = formId;
|
|
1294
|
+
return clickgo.form.dialog(opt);
|
|
1295
|
+
},
|
|
1296
|
+
confirm: function (opt) {
|
|
1297
|
+
if (typeof opt === 'string') {
|
|
1298
|
+
opt = {
|
|
1299
|
+
'content': opt
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
opt.formId = formId;
|
|
1303
|
+
return clickgo.form.confirm(opt);
|
|
1304
|
+
},
|
|
1305
|
+
setTopMost: function (top, opt = {}) {
|
|
1306
|
+
opt.taskId = taskId;
|
|
1307
|
+
opt.formId = formId;
|
|
1308
|
+
clickgo.form.setTopMost(top, opt);
|
|
1309
|
+
},
|
|
1310
|
+
flash: function (fid) {
|
|
1311
|
+
clickgo.form.flash(fid !== null && fid !== void 0 ? fid : formId, taskId);
|
|
1312
|
+
},
|
|
1313
|
+
show: function (fid) {
|
|
1314
|
+
clickgo.form.show(fid !== null && fid !== void 0 ? fid : formId, taskId);
|
|
1315
|
+
},
|
|
1316
|
+
hide: function (fid) {
|
|
1317
|
+
clickgo.form.hide(fid !== null && fid !== void 0 ? fid : formId, taskId);
|
|
1318
|
+
}
|
|
1319
|
+
},
|
|
1320
|
+
'fs': {
|
|
1321
|
+
getContent: function (path, options = {}) {
|
|
1322
|
+
if (!options.files) {
|
|
1323
|
+
options.files = t.files;
|
|
1324
|
+
}
|
|
1325
|
+
if (!options.current) {
|
|
1326
|
+
options.current = t.path;
|
|
1327
|
+
}
|
|
1328
|
+
return clickgo.fs.getContent(path, options);
|
|
1329
|
+
},
|
|
1330
|
+
putContent: function (path, data, options = {}) {
|
|
1331
|
+
if (!options.current) {
|
|
1332
|
+
options.current = t.path;
|
|
1333
|
+
}
|
|
1334
|
+
return clickgo.fs.putContent(path, data, options);
|
|
1335
|
+
},
|
|
1336
|
+
readLink: function (path, options = {}) {
|
|
1337
|
+
if (!options.current) {
|
|
1338
|
+
options.current = t.path;
|
|
1339
|
+
}
|
|
1340
|
+
return clickgo.fs.readLink(path, options);
|
|
1341
|
+
},
|
|
1342
|
+
symlink: function (fPath, linkPath, options = {}) {
|
|
1343
|
+
if (!options.current) {
|
|
1344
|
+
options.current = t.path;
|
|
1345
|
+
}
|
|
1346
|
+
return clickgo.fs.symlink(fPath, linkPath, options);
|
|
1347
|
+
},
|
|
1348
|
+
unlink: function (path, options = {}) {
|
|
1349
|
+
if (!options.current) {
|
|
1350
|
+
options.current = t.path;
|
|
1351
|
+
}
|
|
1352
|
+
return clickgo.fs.unlink(path, options);
|
|
1353
|
+
},
|
|
1354
|
+
stats: function (path, options = {}) {
|
|
1355
|
+
if (!options.files) {
|
|
1356
|
+
options.files = t.files;
|
|
1357
|
+
}
|
|
1358
|
+
if (!options.current) {
|
|
1359
|
+
options.current = t.path;
|
|
1360
|
+
}
|
|
1361
|
+
return clickgo.fs.stats(path, options);
|
|
1362
|
+
},
|
|
1363
|
+
isDir: function (path, options = {}) {
|
|
1364
|
+
if (!options.files) {
|
|
1365
|
+
options.files = t.files;
|
|
1366
|
+
}
|
|
1367
|
+
if (!options.current) {
|
|
1368
|
+
options.current = t.path;
|
|
1369
|
+
}
|
|
1370
|
+
return clickgo.fs.isDir(path, options);
|
|
1371
|
+
},
|
|
1372
|
+
isFile: function (path, options = {}) {
|
|
1373
|
+
if (!options.files) {
|
|
1374
|
+
options.files = t.files;
|
|
1375
|
+
}
|
|
1376
|
+
if (!options.current) {
|
|
1377
|
+
options.current = t.path;
|
|
1378
|
+
}
|
|
1379
|
+
return clickgo.fs.isFile(path, options);
|
|
1380
|
+
},
|
|
1381
|
+
mkdir: function (path, mode, options = {}) {
|
|
1382
|
+
if (!options.current) {
|
|
1383
|
+
options.current = t.path;
|
|
1384
|
+
}
|
|
1385
|
+
return clickgo.fs.mkdir(path, mode, options);
|
|
1386
|
+
},
|
|
1387
|
+
rmdir: function (path, options = {}) {
|
|
1388
|
+
if (!options.current) {
|
|
1389
|
+
options.current = t.path;
|
|
1390
|
+
}
|
|
1391
|
+
return clickgo.fs.rmdir(path, options);
|
|
1392
|
+
},
|
|
1393
|
+
rmdirDeep: function (path, options = {}) {
|
|
1394
|
+
if (!options.current) {
|
|
1395
|
+
options.current = t.path;
|
|
1396
|
+
}
|
|
1397
|
+
return clickgo.fs.rmdirDeep(path, options);
|
|
1398
|
+
},
|
|
1399
|
+
chmod: function (path, mod, options = {}) {
|
|
1400
|
+
if (!options.current) {
|
|
1401
|
+
options.current = t.path;
|
|
1402
|
+
}
|
|
1403
|
+
return clickgo.fs.chmod(path, mod, options);
|
|
1404
|
+
},
|
|
1405
|
+
rename(oldPath, newPath, options = {}) {
|
|
1406
|
+
if (!options.current) {
|
|
1407
|
+
options.current = t.path;
|
|
1408
|
+
}
|
|
1409
|
+
return clickgo.fs.rename(oldPath, newPath, options);
|
|
1410
|
+
},
|
|
1411
|
+
readDir(path, options = {}) {
|
|
1412
|
+
if (!options.files) {
|
|
1413
|
+
options.files = t.files;
|
|
1414
|
+
}
|
|
1415
|
+
if (!options.current) {
|
|
1416
|
+
options.current = t.path;
|
|
1417
|
+
}
|
|
1418
|
+
return clickgo.fs.readDir(path, options);
|
|
1419
|
+
},
|
|
1420
|
+
copyFolder(from, to, options = {}) {
|
|
1421
|
+
if (!options.current) {
|
|
1422
|
+
options.current = t.path;
|
|
1423
|
+
}
|
|
1424
|
+
return clickgo.fs.copyFolder(from, to, options);
|
|
1425
|
+
},
|
|
1426
|
+
copyFile(src, dest, options = {}) {
|
|
1427
|
+
if (!options.current) {
|
|
1428
|
+
options.current = t.path;
|
|
1429
|
+
}
|
|
1430
|
+
return clickgo.fs.copyFile(src, dest, options);
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
'native': {
|
|
1434
|
+
getListeners: function () {
|
|
1435
|
+
return clickgo.native.getListeners();
|
|
1436
|
+
},
|
|
1437
|
+
send: function (name, param, handler) {
|
|
1438
|
+
return clickgo.native.send(name, param, handler, taskId);
|
|
1439
|
+
},
|
|
1440
|
+
on: function (name, handler, id, once = false) {
|
|
1441
|
+
clickgo.native.on(name, handler, id, once, taskId);
|
|
1442
|
+
},
|
|
1443
|
+
once: function (name, handler, id) {
|
|
1444
|
+
clickgo.native.once(name, handler, id, taskId);
|
|
1445
|
+
},
|
|
1446
|
+
off: function (name, handler) {
|
|
1447
|
+
clickgo.native.off(name, handler, taskId);
|
|
1448
|
+
},
|
|
1449
|
+
clearListener: function () {
|
|
1450
|
+
clickgo.native.clearListener(taskId);
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
'task': {
|
|
1454
|
+
onFrame: function (fun, opt = {}) {
|
|
1455
|
+
opt.taskId = taskId;
|
|
1456
|
+
opt.formId = formId;
|
|
1457
|
+
return clickgo.task.onFrame(fun, opt);
|
|
1458
|
+
},
|
|
1459
|
+
offFrame: function (ft, opt = {}) {
|
|
1460
|
+
opt.taskId = taskId;
|
|
1461
|
+
clickgo.task.offFrame(ft, opt);
|
|
1462
|
+
},
|
|
1463
|
+
get: function (tid) {
|
|
1464
|
+
return clickgo.task.get(tid);
|
|
1465
|
+
},
|
|
1466
|
+
getList: function () {
|
|
1467
|
+
return clickgo.task.getList();
|
|
1468
|
+
},
|
|
1469
|
+
run: function (url, opt = {}) {
|
|
1470
|
+
opt.taskId = taskId;
|
|
1471
|
+
return clickgo.task.run(url, opt);
|
|
1472
|
+
},
|
|
1473
|
+
end: function (tid) {
|
|
1474
|
+
return clickgo.task.end(tid !== null && tid !== void 0 ? tid : taskId);
|
|
1475
|
+
},
|
|
1476
|
+
loadLocaleData: function (lang, data, pre = '') {
|
|
1477
|
+
clickgo.task.loadLocaleData(lang, data, pre, taskId);
|
|
1478
|
+
},
|
|
1479
|
+
loadLocale: function (lang, path) {
|
|
1480
|
+
return clickgo.task.loadLocale(lang, path, taskId, formId);
|
|
1481
|
+
},
|
|
1482
|
+
clearLocale: function () {
|
|
1483
|
+
clickgo.task.clearLocale(taskId);
|
|
1484
|
+
},
|
|
1485
|
+
setLocale: function (lang, path) {
|
|
1486
|
+
return clickgo.task.setLocale(lang, path, taskId, formId);
|
|
1487
|
+
},
|
|
1488
|
+
setLocaleLang: function (lang) {
|
|
1489
|
+
clickgo.task.setLocaleLang(lang, taskId);
|
|
1490
|
+
},
|
|
1491
|
+
clearLocaleLang: function () {
|
|
1492
|
+
clickgo.task.clearLocaleLang(taskId);
|
|
1493
|
+
},
|
|
1494
|
+
createTimer: function (fun, delay, opt = {}) {
|
|
1495
|
+
opt.taskId = taskId;
|
|
1496
|
+
if (!opt.formId) {
|
|
1497
|
+
opt.formId = formId;
|
|
1498
|
+
}
|
|
1499
|
+
return clickgo.task.createTimer(fun, delay, opt);
|
|
1500
|
+
},
|
|
1501
|
+
removeTimer: function (timer) {
|
|
1502
|
+
clickgo.task.removeTimer(timer, taskId);
|
|
1503
|
+
},
|
|
1504
|
+
sleep: function (fun, delay) {
|
|
1505
|
+
return clickgo.task.sleep(fun, delay, taskId, formId);
|
|
1506
|
+
},
|
|
1507
|
+
systemTaskInfo: clickgo.task.systemTaskInfo,
|
|
1508
|
+
setSystem: function (fid) {
|
|
1509
|
+
return clickgo.task.setSystem(fid !== null && fid !== void 0 ? fid : formId, taskId);
|
|
1510
|
+
},
|
|
1511
|
+
clearSystem: function () {
|
|
1512
|
+
return clickgo.task.clearSystem(taskId);
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1515
|
+
'theme': {
|
|
1516
|
+
read: function (blob) {
|
|
1517
|
+
return clickgo.theme.read(blob);
|
|
1518
|
+
},
|
|
1519
|
+
load: function (theme) {
|
|
1520
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1521
|
+
if (!theme) {
|
|
1522
|
+
return false;
|
|
1523
|
+
}
|
|
1524
|
+
return clickgo.theme.load(theme, taskId);
|
|
1525
|
+
});
|
|
1526
|
+
},
|
|
1527
|
+
remove: function (name) {
|
|
1528
|
+
return clickgo.theme.remove(name, taskId);
|
|
1529
|
+
},
|
|
1530
|
+
clear: function () {
|
|
1531
|
+
return clickgo.theme.clear(taskId);
|
|
1532
|
+
},
|
|
1533
|
+
setGlobal: function (theme) {
|
|
1534
|
+
return clickgo.theme.setGlobal(theme);
|
|
1535
|
+
},
|
|
1536
|
+
clearGlobal: function () {
|
|
1537
|
+
clickgo.theme.clearGlobal();
|
|
1538
|
+
}
|
|
1539
|
+
},
|
|
1540
|
+
'tool': {
|
|
1541
|
+
blob2ArrayBuffer: function (blob) {
|
|
1542
|
+
return clickgo.tool.blob2ArrayBuffer(blob);
|
|
1543
|
+
},
|
|
1544
|
+
clone: function (obj) {
|
|
1545
|
+
return clickgo.tool.clone(obj);
|
|
1546
|
+
},
|
|
1547
|
+
sleep: function (ms = 0) {
|
|
1548
|
+
return clickgo.tool.sleep(ms);
|
|
1549
|
+
},
|
|
1550
|
+
purify: function (text) {
|
|
1551
|
+
return clickgo.tool.purify(text);
|
|
1552
|
+
},
|
|
1553
|
+
createObjectURL: function (object) {
|
|
1554
|
+
return clickgo.tool.createObjectURL(object, taskId);
|
|
1555
|
+
},
|
|
1556
|
+
revokeObjectURL: function (url) {
|
|
1557
|
+
clickgo.tool.revokeObjectURL(url, taskId);
|
|
1558
|
+
},
|
|
1559
|
+
rand: function (min, max) {
|
|
1560
|
+
return clickgo.tool.rand(min, max);
|
|
1561
|
+
},
|
|
1562
|
+
'RANDOM_N': clickgo.tool.RANDOM_N,
|
|
1563
|
+
'RANDOM_U': clickgo.tool.RANDOM_U,
|
|
1564
|
+
'RANDOM_L': clickgo.tool.RANDOM_L,
|
|
1565
|
+
'RANDOM_UN': clickgo.tool.RANDOM_UN,
|
|
1566
|
+
'RANDOM_LN': clickgo.tool.RANDOM_LN,
|
|
1567
|
+
'RANDOM_LU': clickgo.tool.RANDOM_LU,
|
|
1568
|
+
'RANDOM_LUN': clickgo.tool.RANDOM_LUN,
|
|
1569
|
+
'RANDOM_V': clickgo.tool.RANDOM_V,
|
|
1570
|
+
'RANDOM_LUNS': clickgo.tool.RANDOM_LUNS,
|
|
1571
|
+
random: function (length = 8, source = clickgo.tool.RANDOM_LN, block = '') {
|
|
1572
|
+
return clickgo.tool.random(length, source, block);
|
|
1573
|
+
},
|
|
1574
|
+
getBoolean: function (param) {
|
|
1575
|
+
return clickgo.tool.getBoolean(param);
|
|
1576
|
+
},
|
|
1577
|
+
escapeHTML: function (html) {
|
|
1578
|
+
return clickgo.tool.escapeHTML(html);
|
|
1579
|
+
},
|
|
1580
|
+
request: function (url, opt) {
|
|
1581
|
+
return clickgo.tool.request(url, opt);
|
|
1582
|
+
},
|
|
1583
|
+
parseUrl: function (url) {
|
|
1584
|
+
return clickgo.tool.parseUrl(url);
|
|
1585
|
+
},
|
|
1586
|
+
urlResolve: function (from, to) {
|
|
1587
|
+
return clickgo.tool.urlResolve(from, to);
|
|
1588
|
+
},
|
|
1589
|
+
blob2Text: function (blob) {
|
|
1590
|
+
return clickgo.tool.blob2Text(blob);
|
|
1591
|
+
},
|
|
1592
|
+
blob2DataUrl: function (blob) {
|
|
1593
|
+
return clickgo.tool.blob2DataUrl(blob);
|
|
1594
|
+
},
|
|
1595
|
+
execCommand: function (ac) {
|
|
1596
|
+
clickgo.tool.execCommand(ac);
|
|
1597
|
+
}
|
|
1598
|
+
},
|
|
1599
|
+
'zip': {
|
|
1600
|
+
get: function (data) {
|
|
1601
|
+
return clickgo.zip.get(data);
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
else {
|
|
1607
|
+
invoke.invokeClickgo = clickgo;
|
|
1608
|
+
}
|
|
1609
|
+
const preprocess = clickgo.getSafe() ? function (code, path) {
|
|
1610
|
+
const exec = /eval\W/.exec(code);
|
|
1611
|
+
if (exec) {
|
|
1612
|
+
notify({
|
|
1613
|
+
'title': 'Error',
|
|
1614
|
+
'content': `The "eval" is prohibited.\nFile: "${path}".`,
|
|
1615
|
+
'type': 'danger'
|
|
1616
|
+
});
|
|
1617
|
+
return '';
|
|
1618
|
+
}
|
|
1619
|
+
return code;
|
|
1620
|
+
} : undefined;
|
|
1621
|
+
const components = yield control.init(t.id, formId, newBase, preprocess, invoke);
|
|
1622
|
+
if (!components) {
|
|
1623
|
+
if ((form === null || form === void 0 ? void 0 : form.vroot.$refs.form.maskFor) !== undefined) {
|
|
1624
|
+
form.vroot.$refs.form.maskFor = undefined;
|
|
1625
|
+
}
|
|
1626
|
+
return -5;
|
|
1627
|
+
}
|
|
1628
|
+
let style = opt.style;
|
|
1629
|
+
let layout = opt.layout;
|
|
1630
|
+
if (filePath) {
|
|
1631
|
+
if (!filePath.startsWith('/package/')) {
|
|
1632
|
+
return -6;
|
|
1633
|
+
}
|
|
1634
|
+
const file = filePath.slice(8);
|
|
1635
|
+
const layoutFile = app.files[file + '.xml'];
|
|
1636
|
+
if (layoutFile) {
|
|
1637
|
+
layout = layoutFile.replace(/^\ufeff/, '');
|
|
1638
|
+
}
|
|
1639
|
+
const styleFile = app.files[file + '.css'];
|
|
1640
|
+
if (styleFile) {
|
|
1641
|
+
style = styleFile.replace(/^\ufeff/, '');
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
if (layout === undefined) {
|
|
1645
|
+
if ((form === null || form === void 0 ? void 0 : form.vroot.$refs.form.maskFor) !== undefined) {
|
|
1646
|
+
form.vroot.$refs.form.maskFor = undefined;
|
|
1647
|
+
}
|
|
1648
|
+
return -7;
|
|
1649
|
+
}
|
|
1650
|
+
let data = {};
|
|
1651
|
+
let methods = {};
|
|
1652
|
+
let computed = {};
|
|
1653
|
+
let watch = {};
|
|
1654
|
+
let beforeCreate = undefined;
|
|
1655
|
+
let created = undefined;
|
|
1656
|
+
let beforeMount = undefined;
|
|
1657
|
+
let mounted = undefined;
|
|
1658
|
+
let beforeUpdate = undefined;
|
|
1659
|
+
let updated = undefined;
|
|
1660
|
+
let beforeUnmount = undefined;
|
|
1661
|
+
let unmounted = undefined;
|
|
1662
|
+
let receive = undefined;
|
|
1663
|
+
let expo = opt.code;
|
|
1664
|
+
if ((filePath === null || filePath === void 0 ? void 0 : filePath.startsWith('/package/')) && app.files[filePath.slice(8) + '.js']) {
|
|
1665
|
+
const file = filePath.slice(8);
|
|
1666
|
+
if (app.files[file + '.js']) {
|
|
1667
|
+
app.files['/invoke/clickgo.js'] = `module.exports = invokeClickgo;`;
|
|
1668
|
+
expo = loader.require(file, app.files, {
|
|
1669
|
+
'dir': '/',
|
|
1670
|
+
'invoke': invoke,
|
|
1671
|
+
'preprocess': preprocess,
|
|
1672
|
+
'map': {
|
|
1673
|
+
'clickgo': '/invoke/clickgo'
|
|
1674
|
+
}
|
|
1675
|
+
})[0];
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
if (expo) {
|
|
1679
|
+
data = (_d = expo.data) !== null && _d !== void 0 ? _d : {};
|
|
1680
|
+
methods = expo.methods || {};
|
|
1681
|
+
computed = expo.computed || {};
|
|
1682
|
+
watch = expo.watch || {};
|
|
1683
|
+
beforeCreate = expo.beforeCreate;
|
|
1684
|
+
created = expo.created;
|
|
1685
|
+
beforeMount = expo.beforeMount;
|
|
1686
|
+
mounted = expo.mounted;
|
|
1687
|
+
beforeUpdate = expo.beforeUpdate;
|
|
1688
|
+
updated = expo.updated;
|
|
1689
|
+
beforeUnmount = expo.beforeUnmount;
|
|
1690
|
+
unmounted = expo.unmounted;
|
|
1691
|
+
receive = expo.receive;
|
|
1692
|
+
}
|
|
1693
|
+
let prep = '';
|
|
1694
|
+
if (style) {
|
|
1695
|
+
const r = tool.stylePrepend(style);
|
|
1696
|
+
prep = r.prep;
|
|
1697
|
+
style = yield tool.styleUrl2DataUrl(newBase, r.style, app.files);
|
|
1698
|
+
}
|
|
1699
|
+
layout = tool.purify(layout);
|
|
1700
|
+
layout = tool.layoutAddTagClassAndReTagName(layout, true);
|
|
1701
|
+
layout = tool.layoutInsertAttr(layout, ':cg-focus=\'cgFocus\'', {
|
|
1702
|
+
'include': [/^cg-.+/]
|
|
1703
|
+
});
|
|
1704
|
+
const prepList = ['cg-task' + opt.taskId.toString() + '_'];
|
|
1705
|
+
if (prep !== '') {
|
|
1706
|
+
prepList.push(prep);
|
|
1707
|
+
}
|
|
1708
|
+
layout = tool.layoutClassPrepend(layout, prepList);
|
|
1709
|
+
layout = tool.eventsAttrWrap(layout);
|
|
1710
|
+
elements.list.insertAdjacentHTML('beforeend', `<div class="cg-form-wrap" data-form-id="${formId.toString()}" data-task-id="${opt.taskId.toString()}"></div>`);
|
|
1711
|
+
const el = elements.list.children.item(elements.list.children.length - 1);
|
|
1712
|
+
computed.taskId = {
|
|
1713
|
+
get: function () {
|
|
1714
|
+
return taskId;
|
|
1715
|
+
},
|
|
1716
|
+
set: function () {
|
|
1717
|
+
notify({
|
|
1718
|
+
'title': 'Error',
|
|
1719
|
+
'content': `The software tries to modify the system variable "taskId".\nPath: ${this.cgPath}`,
|
|
1720
|
+
'type': 'danger'
|
|
1721
|
+
});
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
computed.formId = {
|
|
1726
|
+
get: function () {
|
|
1727
|
+
return formId;
|
|
1728
|
+
},
|
|
1729
|
+
set: function () {
|
|
1730
|
+
notify({
|
|
1731
|
+
'title': 'Error',
|
|
1732
|
+
'content': `The software tries to modify the system variable "formId".\nPath: ${this.cgPath}`,
|
|
1733
|
+
'type': 'danger'
|
|
1734
|
+
});
|
|
1735
|
+
return;
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
computed.controlName = {
|
|
1739
|
+
get: function () {
|
|
1740
|
+
return 'root';
|
|
1741
|
+
},
|
|
1742
|
+
set: function () {
|
|
1743
|
+
notify({
|
|
1744
|
+
'title': 'Error',
|
|
1745
|
+
'content': `The software tries to modify the system variable "controlName".\nPath: ${this.cgPath}`,
|
|
1746
|
+
'type': 'danger'
|
|
1747
|
+
});
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
};
|
|
1751
|
+
data._cgFocus = false;
|
|
1752
|
+
computed.cgFocus = {
|
|
1753
|
+
get: function () {
|
|
1754
|
+
return this._cgFocus;
|
|
1755
|
+
},
|
|
1756
|
+
set: function () {
|
|
1757
|
+
notify({
|
|
1758
|
+
'title': 'Error',
|
|
1759
|
+
'content': `The software tries to modify the system variable "cgFocus".\nPath: ${this.cgPath}`,
|
|
1760
|
+
'type': 'danger'
|
|
1761
|
+
});
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
computed.cgPath = {
|
|
1766
|
+
get: function () {
|
|
1767
|
+
return newBase;
|
|
1768
|
+
},
|
|
1769
|
+
set: function () {
|
|
1770
|
+
notify({
|
|
1771
|
+
'title': 'Error',
|
|
1772
|
+
'content': `The software tries to modify the system variable "cgPath".\nPath: ${this.cgPath}`,
|
|
1773
|
+
'type': 'danger'
|
|
1774
|
+
});
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
computed.cgPrep = {
|
|
1779
|
+
get: function () {
|
|
1780
|
+
return prep;
|
|
1781
|
+
},
|
|
1782
|
+
set: function () {
|
|
1783
|
+
notify({
|
|
1784
|
+
'title': 'Error',
|
|
1785
|
+
'content': `The software tries to modify the system variable "cgPrep".\nPath: ${this._cgPath}`,
|
|
1786
|
+
'type': 'danger'
|
|
1787
|
+
});
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
data._cgCustomZIndex = false;
|
|
1792
|
+
computed.cgCustomZIndex = {
|
|
1793
|
+
get: function () {
|
|
1794
|
+
return this._cgCustomZIndex;
|
|
1795
|
+
},
|
|
1796
|
+
set: function () {
|
|
1797
|
+
notify({
|
|
1798
|
+
'title': 'Error',
|
|
1799
|
+
'content': `The software tries to modify the system variable "cgCustomZIndex".\nPath: ${this.cgPath}`,
|
|
1800
|
+
'type': 'danger'
|
|
1801
|
+
});
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
if (topMost) {
|
|
1806
|
+
data._cgTopMost = true;
|
|
1807
|
+
}
|
|
1808
|
+
else {
|
|
1809
|
+
data._cgTopMost = false;
|
|
1810
|
+
}
|
|
1811
|
+
computed.cgTopMost = {
|
|
1812
|
+
get: function () {
|
|
1813
|
+
return this._cgTopMost;
|
|
1814
|
+
},
|
|
1815
|
+
set: function () {
|
|
1816
|
+
notify({
|
|
1817
|
+
'title': 'Error',
|
|
1818
|
+
'content': `The software tries to modify the system variable "cgTopMost".\nPath: ${this.cgPath}`,
|
|
1819
|
+
'type': 'danger'
|
|
1820
|
+
});
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1824
|
+
computed.cgLocale = function () {
|
|
1825
|
+
if (task.list[this.taskId].locale.lang === '') {
|
|
1826
|
+
return core.config.locale;
|
|
1827
|
+
}
|
|
1828
|
+
return task.list[this.taskId].locale.lang;
|
|
1829
|
+
};
|
|
1830
|
+
computed.l = function () {
|
|
1831
|
+
return (key) => {
|
|
1832
|
+
var _a, _b, _c, _d;
|
|
1833
|
+
return (_d = (_b = (_a = task.list[this.taskId].locale.data[this.cgLocale]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = task.list[this.taskId].locale.data['en']) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : 'LocaleError';
|
|
1834
|
+
};
|
|
1835
|
+
};
|
|
1836
|
+
methods.cgClassPrepend = function (cla) {
|
|
1837
|
+
if (typeof cla !== 'string') {
|
|
1838
|
+
return cla;
|
|
1839
|
+
}
|
|
1840
|
+
return `cg-task${this.taskId}_${cla} ${this.cgPrep}${cla}`;
|
|
1841
|
+
};
|
|
1842
|
+
methods.cgAllowEvent = function (e) {
|
|
1843
|
+
return dom.allowEvent(e);
|
|
1844
|
+
};
|
|
1845
|
+
methods.cgReceive = function (obj) {
|
|
1846
|
+
receive === null || receive === void 0 ? void 0 : receive.call(this, obj);
|
|
1847
|
+
};
|
|
1848
|
+
if (style) {
|
|
1849
|
+
dom.pushStyle(taskId, style, 'form', formId);
|
|
1850
|
+
}
|
|
1851
|
+
const rtn = yield new Promise(function (resolve) {
|
|
1852
|
+
const vapp = Vue.createApp({
|
|
1853
|
+
'template': layout.replace(/^<cg-form/, '<cg-form ref="form"'),
|
|
1854
|
+
'data': function () {
|
|
1855
|
+
return tool.clone(data);
|
|
1856
|
+
},
|
|
1857
|
+
'methods': methods,
|
|
1858
|
+
'computed': computed,
|
|
1859
|
+
'watch': watch,
|
|
1860
|
+
'beforeCreate': beforeCreate,
|
|
1861
|
+
'created': created,
|
|
1862
|
+
'beforeMount': beforeMount,
|
|
1863
|
+
'mounted': function () {
|
|
1864
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1865
|
+
yield this.$nextTick();
|
|
1866
|
+
if (this.$refs.form.icon !== '') {
|
|
1867
|
+
const icon = yield clickgo.fs.getContent(this.$refs.form.icon);
|
|
1868
|
+
this.$refs.form.iconData = (icon instanceof Blob) ? yield clickgo.tool.blob2DataUrl(icon) : '';
|
|
1869
|
+
}
|
|
1870
|
+
resolve({
|
|
1871
|
+
'vapp': vapp,
|
|
1872
|
+
'vroot': this
|
|
1873
|
+
});
|
|
1874
|
+
});
|
|
1875
|
+
},
|
|
1876
|
+
'beforeUpdate': beforeUpdate,
|
|
1877
|
+
'updated': function () {
|
|
1878
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1879
|
+
yield this.$nextTick();
|
|
1880
|
+
updated === null || updated === void 0 ? void 0 : updated.call(this);
|
|
1881
|
+
});
|
|
1882
|
+
},
|
|
1883
|
+
'beforeUnmount': beforeUnmount,
|
|
1884
|
+
'unmounted': unmounted,
|
|
1885
|
+
});
|
|
1886
|
+
vapp.config.errorHandler = function (err, vm, info) {
|
|
1887
|
+
notify({
|
|
1888
|
+
'title': 'Runtime Error',
|
|
1889
|
+
'content': `Message: ${err.message}\ntask id: ${vm.taskId}\nForm id: ${vm.formId}`,
|
|
1890
|
+
'type': 'danger'
|
|
1891
|
+
});
|
|
1892
|
+
core.trigger('error', vm.taskId, vm.formId, err, info);
|
|
1893
|
+
};
|
|
1894
|
+
for (const key in components) {
|
|
1895
|
+
vapp.component(key, components[key]);
|
|
1896
|
+
}
|
|
1897
|
+
vapp.mount(el);
|
|
1898
|
+
});
|
|
1899
|
+
const nform = {
|
|
1900
|
+
'id': formId,
|
|
1901
|
+
'vapp': rtn.vapp,
|
|
1902
|
+
'vroot': rtn.vroot,
|
|
1903
|
+
'events': {}
|
|
1904
|
+
};
|
|
1905
|
+
t.forms[formId] = nform;
|
|
1906
|
+
if (opt.mask && form) {
|
|
1907
|
+
form.vroot.$refs.form.maskFor = formId;
|
|
1908
|
+
nform.vroot.$refs.form.maskFrom = form.id;
|
|
1909
|
+
}
|
|
1910
|
+
yield tool.sleep(34);
|
|
1911
|
+
if (mounted) {
|
|
1912
|
+
try {
|
|
1913
|
+
yield mounted.call(rtn.vroot, opt.data);
|
|
1914
|
+
}
|
|
1915
|
+
catch (err) {
|
|
1916
|
+
if ((nform === null || nform === void 0 ? void 0 : nform.vroot.$refs.form.maskFor) !== undefined) {
|
|
1917
|
+
nform.vroot.$refs.form.maskFor = undefined;
|
|
1918
|
+
}
|
|
1919
|
+
core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error.');
|
|
1920
|
+
t.forms[formId] = undefined;
|
|
1921
|
+
delete t.forms[formId];
|
|
1922
|
+
rtn.vapp.unmount();
|
|
1923
|
+
rtn.vapp._container.remove();
|
|
1924
|
+
dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
|
|
1925
|
+
return -8;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
const area = core.getAvailArea();
|
|
1929
|
+
if (!rtn.vroot.$refs.form.stateMaxData) {
|
|
1930
|
+
if (rtn.vroot.$refs.form.left === -1) {
|
|
1931
|
+
rtn.vroot.$refs.form.setPropData('left', (area.width - rtn.vroot.$el.offsetWidth) / 2);
|
|
1932
|
+
}
|
|
1933
|
+
if (rtn.vroot.$refs.form.top === -1) {
|
|
1934
|
+
rtn.vroot.$refs.form.setPropData('top', (area.height - rtn.vroot.$el.offsetHeight) / 2);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
if (rtn.vroot.$refs.form.zIndex !== -1) {
|
|
1938
|
+
rtn.vroot._cgCustomZIndex = true;
|
|
1939
|
+
}
|
|
1940
|
+
if (rtn.vroot.$refs.form.$data.show !== false) {
|
|
1941
|
+
rtn.vroot.$refs.form.$data.showData = true;
|
|
1942
|
+
}
|
|
1943
|
+
core.trigger('formCreated', taskId, formId, rtn.vroot.$refs.form.title, rtn.vroot.$refs.form.iconData);
|
|
1944
|
+
changeFocus(formId);
|
|
1945
|
+
return nform;
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
exports.create = create;
|
|
1949
|
+
function dialog(opt) {
|
|
1950
|
+
return new Promise(function (resolve) {
|
|
1951
|
+
var _a, _b, _c;
|
|
1952
|
+
if (typeof opt === 'string') {
|
|
1953
|
+
opt = {
|
|
1954
|
+
'content': opt
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
const formId = opt.formId;
|
|
1958
|
+
if (!formId) {
|
|
1959
|
+
resolve('');
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
const taskId = getTaskId(formId);
|
|
1963
|
+
const t = task.list[taskId];
|
|
1964
|
+
if (!t) {
|
|
1965
|
+
resolve('');
|
|
1966
|
+
return;
|
|
1967
|
+
}
|
|
1968
|
+
const locale = t.forms[formId].vroot.cgLocale;
|
|
1969
|
+
if (opt.buttons === undefined) {
|
|
1970
|
+
opt.buttons = [(_b = (_a = info.locale[locale]) === null || _a === void 0 ? void 0 : _a.ok) !== null && _b !== void 0 ? _b : info.locale['en'].ok];
|
|
1971
|
+
}
|
|
1972
|
+
create({
|
|
1973
|
+
'taskId': taskId,
|
|
1974
|
+
'formId': formId,
|
|
1975
|
+
'layout': `<form title="${(_c = opt.title) !== null && _c !== void 0 ? _c : 'dialog'}" width="auto" height="auto" :min="false" :max="false" :resize="false" border="${opt.title ? 'normal' : 'plain'}" direction="v"><dialog :buttons="buttons" @select="select"${opt.direction ? ` direction="${opt.direction}"` : ''}>${opt.content}</dialog></form>`,
|
|
1976
|
+
'code': {
|
|
1977
|
+
data: {
|
|
1978
|
+
'buttons': opt.buttons
|
|
1979
|
+
},
|
|
1980
|
+
methods: {
|
|
1981
|
+
select: function (button) {
|
|
1982
|
+
var _a, _b;
|
|
1983
|
+
const event = {
|
|
1984
|
+
'go': true,
|
|
1985
|
+
preventDefault: function () {
|
|
1986
|
+
this.go = false;
|
|
1987
|
+
}
|
|
1988
|
+
};
|
|
1989
|
+
(_b = (_a = opt).select) === null || _b === void 0 ? void 0 : _b.call(_a, event, button);
|
|
1990
|
+
if (event.go) {
|
|
1991
|
+
close(this.formId);
|
|
1992
|
+
resolve(button);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
},
|
|
1997
|
+
'mask': true
|
|
1998
|
+
}).catch((e) => {
|
|
1999
|
+
throw e;
|
|
2000
|
+
});
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
exports.dialog = dialog;
|
|
2004
|
+
function confirm(opt) {
|
|
2005
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2006
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2007
|
+
if (typeof opt === 'string') {
|
|
2008
|
+
opt = {
|
|
2009
|
+
'content': opt
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
const formId = opt.formId;
|
|
2013
|
+
if (!formId) {
|
|
2014
|
+
return false;
|
|
2015
|
+
}
|
|
2016
|
+
const taskId = getTaskId(formId);
|
|
2017
|
+
const t = task.list[taskId];
|
|
2018
|
+
if (!t) {
|
|
2019
|
+
return false;
|
|
2020
|
+
}
|
|
2021
|
+
const locale = t.forms[formId].vroot.cgLocale;
|
|
2022
|
+
const buttons = [(_b = (_a = info.locale[locale]) === null || _a === void 0 ? void 0 : _a.yes) !== null && _b !== void 0 ? _b : info.locale['en'].yes, (_d = (_c = info.locale[locale]) === null || _c === void 0 ? void 0 : _c.no) !== null && _d !== void 0 ? _d : info.locale['en'].no];
|
|
2023
|
+
if (opt.cancel) {
|
|
2024
|
+
buttons.push((_f = (_e = info.locale[locale]) === null || _e === void 0 ? void 0 : _e.cancel) !== null && _f !== void 0 ? _f : info.locale['en'].cancel);
|
|
2025
|
+
}
|
|
2026
|
+
const res = yield dialog({
|
|
2027
|
+
'formId': formId,
|
|
2028
|
+
'content': opt.content,
|
|
2029
|
+
'buttons': buttons
|
|
2030
|
+
});
|
|
2031
|
+
if (res === ((_h = (_g = info.locale[locale]) === null || _g === void 0 ? void 0 : _g.yes) !== null && _h !== void 0 ? _h : info.locale['en'].yes)) {
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
2034
|
+
if (res === ((_k = (_j = info.locale[locale]) === null || _j === void 0 ? void 0 : _j.cancel) !== null && _k !== void 0 ? _k : info.locale['en'].cancel)) {
|
|
2035
|
+
return 0;
|
|
2036
|
+
}
|
|
2037
|
+
return false;
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
exports.confirm = confirm;
|
|
2041
|
+
function setTopMost(top, opt = {}) {
|
|
2042
|
+
const form = getForm(opt.taskId, opt.formId);
|
|
2043
|
+
if (!form) {
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
form.vroot.$data._cgCustomZIndex = false;
|
|
2047
|
+
if (top) {
|
|
2048
|
+
form.vroot.$data._cgTopMost = true;
|
|
2049
|
+
if (!form.vroot.cgFocus) {
|
|
2050
|
+
changeFocus(form.id);
|
|
2051
|
+
}
|
|
2052
|
+
else {
|
|
2053
|
+
form.vroot.$refs.form.setPropData('zIndex', ++info.topLastZIndex);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
else {
|
|
2057
|
+
form.vroot.$data._cgTopMost = false;
|
|
2058
|
+
form.vroot.$refs.form.setPropData('zIndex', ++info.lastZIndex);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
exports.setTopMost = setTopMost;
|
|
2062
|
+
function flash(formId, taskId) {
|
|
2063
|
+
var _a;
|
|
2064
|
+
const form = getForm(taskId, formId);
|
|
2065
|
+
if (!form) {
|
|
2066
|
+
return;
|
|
2067
|
+
}
|
|
2068
|
+
if (!form.vroot.cgFocus) {
|
|
2069
|
+
changeFocus(form.id);
|
|
2070
|
+
}
|
|
2071
|
+
if ((_a = form.vroot.$refs.form) === null || _a === void 0 ? void 0 : _a.flashTimer) {
|
|
2072
|
+
clearTimeout(form.vroot.$refs.form.flashTimer);
|
|
2073
|
+
form.vroot.$refs.form.flashTimer = undefined;
|
|
2074
|
+
}
|
|
2075
|
+
form.vroot.$refs.form.flashTimer = setTimeout(() => {
|
|
2076
|
+
if (form.vroot.$refs.form) {
|
|
2077
|
+
form.vroot.$refs.form.flashTimer = undefined;
|
|
2078
|
+
}
|
|
2079
|
+
}, 1000);
|
|
2080
|
+
core.trigger('formFlash', taskId, formId);
|
|
2081
|
+
}
|
|
2082
|
+
exports.flash = flash;
|
|
2083
|
+
function show(formId, taskId) {
|
|
2084
|
+
const form = getForm(taskId, formId);
|
|
2085
|
+
if (!form) {
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
2088
|
+
form.vroot.$refs.form.$data.showData = true;
|
|
2089
|
+
}
|
|
2090
|
+
exports.show = show;
|
|
2091
|
+
function hide(formId, taskId) {
|
|
2092
|
+
const form = getForm(taskId, formId);
|
|
2093
|
+
if (!form) {
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
form.vroot.$refs.form.$data.showData = false;
|
|
2097
|
+
}
|
|
2098
|
+
exports.hide = hide;
|
|
2099
|
+
window.addEventListener('resize', function () {
|
|
2100
|
+
task.refreshSystemPosition();
|
|
2101
|
+
});
|